Commit 1b483860 authored by Anders Nilsson's avatar Anders Nilsson

Switched to using javacc instead of beaver, at least for now. beaver

code is still here, but should probably be removed sometime.
parent ef19301b
parser/semantic.cache
......@@ -13,11 +13,13 @@
<!-- "tools" is the directory where generators and libraries are located. -->
<property name="tools" value="tools"/>
<property name="javacc.home" value="tools/javacc-4.0"/>
<!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/>
<!-- <taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/> -->
<!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
<taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver.jar"/>
<!-- <taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver.jar"/> -->
<!-- "jastadd" is an ant task class in jastadd2.jar -->
<taskdef name="jastadd" classname="jastadd.JastAddTask" classpath="tools/jastadd2.jar"/>
......@@ -27,34 +29,38 @@
</target>
<!-- generate compiler source files -->
<target name="gen">
<target name="gen" description="Generate compiler source files">
<!-- create AST node types and weave aspect modules -->
<echo message = "Running JastAdd"/>
<jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true">
<!-- <jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true"> -->
<jastadd package="${package}" rewrite="true" beaver="false" novisitcheck="true">
<fileset dir=".">
<include name="**/*.ast"/>
<include name="**/*.jrag"/>
<include name="**/*.jadd"/>
</fileset>
</jastadd>
<jjtree target="owl.jjt" outputdirectory="${package}" javacchome="${javacc.home}"/>
<javacc target="${package}/owl.jj" outputdirectory="${package}" javacchome="${javacc.home}"/>
<!-- generate the scanner -->
<echo message = "Running jflex"/>
<jflex file="parser/java14.flex" outdir="parser" nobak="yes"/>
<!-- <echo message = "Running jflex"/> -->
<!-- <jflex file="parser/java14.flex" outdir="parser" nobak="yes"/> -->
<!-- generate the scanner -->
<jflex file="parser/unicode.flex" outdir="parser" nobak="yes"/>
<!-- <jflex file="parser/unicode.flex" outdir="parser" nobak="yes"/> -->
<!-- generate the parser phase 1, create a full .lalr specification from fragments-->
<echo message = "Running parser phase 1"/>
<concat destfile="parser/JavaParser.all" binary="true">
<fileset dir=".">
<include name="parser/java14.parser"/>
</fileset>
</concat>
<!-- <echo message = "Running parser phase 1"/> -->
<!-- <concat destfile="parser/JavaParser.all" binary="true"> -->
<!-- <fileset dir="."> -->
<!-- <include name="parser/java14.parser"/> -->
<!-- </fileset> -->
<!-- </concat> -->
<!-- generate the parser phase 2, translating .lalr to .beaver -->
<java classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main">
<arg line="parser/JavaParser.all parser/JavaParser.beaver"/>
</java>
<!-- <java classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main"> -->
<!-- <arg line="parser/JavaParser.all parser/JavaParser.beaver"/> -->
<!-- </java> -->
<!-- generate the parser phase 3, translating .beaver to .java -->
<beaver file="parser/JavaParser.beaver" terminalNames="yes" compress="no" useSwitch="yes"/>
<!-- <beaver file="parser/JavaParser.beaver" terminalNames="yes" compress="no" useSwitch="yes"/> -->
</target>
<!-- remove generated source files and .class files -->
......
options {
MULTI = true;
VISITOR = true;
NODE_DEFAULT_VOID = true;
NODE_SCOPE_HOOK = false;
JAVA_UNICODE_ESCAPE = true;
STATIC = false;
} // options
PARSER_BEGIN(OwlParser)
package AST;
public class OwlParser {
}
PARSER_END(OwlParser)
//--------------------------------------------------------------------//
// LEXICAL TOKENS //
//--------------------------------------------------------------------//
<DEFAULT, BOUNDS> SKIP : /* WHITE SPACE */
{
" "
|
"\t"
|
"\n"
|
"\r"
|
"\f"
}// WHITE SPACE
// <DEFAULT,BOUNDS> SPECIAL_TOKEN : /* COMMENTS */
// {
// <SLASH_SLASH_COMMENT : "//" (~["\n","\r"])* >
// }
SPECIAL_TOKEN : /* COMMENTS */
{
// <SLASH_STAR_COMMENT : "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/" >
<XML_COMMENT : "<!--" (~["-","-",">"])* "-->" >
}// COMMENTS
<BOUNDS> TOKEN: {
< BEGINCOMMENT : "<!--" >
| < ENDCOMMENT : "-->" >
}
<DEFAULT, BOUNDS> TOKEN : /* RESERVED WORDS AND LITERALS */
{
< XML : "xml" >
| < XML_BASE : "xml:base" >
| < XMLNS : "xmlns" >
| < XMLNS_RDF : "xmlns:rdf" >
| < XMLNS_XSD : "xmlns:xsd" >
| < XMLNS_RDFS : "xmlns:rdfs" >
| < XMLNS_OWL : "xmlns:owl" >
| < RDF_RDF : "rdf:RDF" >
| < RDF_ABOUT : "rdf:about" >
| < RDF_ID : "rdf:ID" >
| < RDF_RESOURCE : "rdf:resource" >
| < RDFS_SUBCLASSOF : "rdfs:subClassOf" >
| < OWL_ONTOLOGY : "owl:Ontology" >
| < OWL_CLASS : "owl:Class" >
| < OWL_DISJOINTWITH : "owl:DisjointWith" >
| < OWL_RESTRICTION : "owl:Restriction" >
| < OWL_ONPROPERTY : "owl:onProperty" >
| < OWL_OBJECTPROPERTY : "owl:ObjectProperty" >
| < OWL_SOMEVALUESFROM : "owl:someValuesFrom" >
}// RESERVED WORDS AND LITERALS
<DEFAULT, BOUNDS> TOKEN : /* LITERALS */
{
< INTEGER_LITERAL:
<DECIMAL_LITERAL> (["l","L"])?
|
<HEX_LITERAL> (["l","L"])?
|
<OCTAL_LITERAL> (["l","L"])?
>
|
< #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
|
< #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
|
< #OCTAL_LITERAL: "0" (["0"-"7"])* >
|
< FLOATING_POINT_LITERAL:
(["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
|
"." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
|
(["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
|
(["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
>
|
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
|
< CHARACTER_LITERAL:
"'"
( (~["'","\\","\n","\r"])
|
("\\"
( ["n","t","b","r","f","\\","'","\""]
|
["0"-"7"] ( ["0"-"7"] )?
|
["0"-"3"] ["0"-"7"] ["0"-"7"]
)
)
)
"'"
>
|
< STRING_LITERAL:
"\""
( (~["\"","\\","\n","\r"])
|
("\\"
( ["n","t","b","r","f","\\","'","\""]
|
["0"-"7"] ( ["0"-"7"] )?
|
["0"-"3"] ["0"-"7"] ["0"-"7"]
)
)
)*
"\""
>
}// LITERALS
<DEFAULT, BOUNDS> TOKEN : /* IDENTIFIERS */
{
< IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
|
< #LETTER:
[
"\u0024",
"\u0041"-"\u005a",
"\u005f",
"\u0061"-"\u007a",
"\u00c0"-"\u00d6",
"\u00d8"-"\u00f6",
"\u00f8"-"\u00ff",
"\u0100"-"\u1fff",
"\u3040"-"\u318f",
"\u3300"-"\u337f",
"\u3400"-"\u3d2d",
"\u4e00"-"\u9fff",
"\uf900"-"\ufaff"
]
>
|
< #DIGIT:
[
"\u0030"-"\u0039",
"\u0660"-"\u0669",
"\u06f0"-"\u06f9",
"\u0966"-"\u096f",
"\u09e6"-"\u09ef",
"\u0a66"-"\u0a6f",
"\u0ae6"-"\u0aef",
"\u0b66"-"\u0b6f",
"\u0be7"-"\u0bef",
"\u0c66"-"\u0c6f",
"\u0ce6"-"\u0cef",
"\u0d66"-"\u0d6f",
"\u0e50"-"\u0e59",
"\u0ed0"-"\u0ed9",
"\u1040"-"\u1049"
]
>
}// IDENTIFIERS
<DEFAULT,BOUNDS> TOKEN : /* SEPARATORS */
{
< LPAREN : "(" >
| < RPAREN : ")" >
| < LBRACE : "{" >
| < RBRACE : "}" >
| < LBRACKET : "[" >
| < RBRACKET : "]" >
| < SEMICOLON : ";" >
| < COMMA : "," >
| < DOT : "." >
}// SEPARATORS
// <DEFAULT,BOUNDS> TOKEN : /* OPERATORS */
// {
// < ASSIGN : "=" >
// | < GT : ">" >
// | < LT : "<" >
// | < BANG : "!" >
// | < TILDE : "~" >
// | < HOOK : "?" >
// | < COLON : ":" >
// | < EQ : "==" >
// | < LE : "<=" >
// | < GE : ">=" >
// | < NE : "!=" >
// | < SC_OR : "||" >
// | < SC_AND : "&&" >
// | < INCR : "++" >
// | < DECR : "--" >
// | < PLUS : "+" >
// | < MINUS : "-" >
// | < STAR : "*" >
// | < SLASH : "/" >
// | < BIT_AND : "&" >
// | < BIT_OR : "|" >
// | < XOR : "^" >
// | < REM : "%" >
// | < LSHIFT : "<<" >
// | < RSIGNEDSHIFT : ">>" >
// | < RUNSIGNEDSHIFT : ">>>" >
// | < PLUSASSIGN : "+=" >
// | < MINUSASSIGN : "-=" >
// | < STARASSIGN : "*=" >
// | < SLASHASSIGN : "/=" >
// | < ANDASSIGN : "&=" >
// | < ORASSIGN : "|=" >
// | < XORASSIGN : "^=" >
// | < REMASSIGN : "%=" >
// | < LSHIFTASSIGN : "<<=" >
// | < RSIGNEDSHIFTASSIGN : ">>=" >
// | < RUNSIGNEDSHIFTASSIGN : ">>>=" >
// }// OPERATORS
//--------------------------------------------------------------------//
// THE OWL LANGUAGE GRAMMAR //
//--------------------------------------------------------------------//
Specification Specification() #Specification : {}
{
"<?" <XML> AttributeList() "?>"
{ return jjtThis; }
}
Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
-Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistribution in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
Neither the name of Sun Microsystems, Inc. or the names of contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
You acknowledge that this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
#!/bin/sh
JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
esac
java -classpath "$JAR" javacc "$@"
@echo off
java -classpath "%~f0\..\lib\javacc.jar" javacc %1 %2 %3 %4 %5 %6 %7 %8 %9
#!/bin/sh
JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
esac
java -classpath "$JAR" jjdoc "$@"
@echo off
java -classpath "%~f0\..\lib\javacc.jar" jjdoc %1 %2 %3 %4 %5 %6 %7 %8 %9
#!/bin/sh
JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
esac
java -classpath "$JAR" jjtree "$@"
@echo off
java -classpath "%~f0\..\lib\javacc.jar" jjtree %1 %2 %3 %4 %5 %6 %7 %8 %9
This diff is collapsed.
<HTML>
<!--
Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
intellectual property rights relating to technology embodied in the product
that is described in this document. In particular, and without limitation,
these intellectual property rights may include one or more of the U.S.
patents listed at http://www.sun.com/patents and one or more additional
patents or pending patent applications in the U.S. and in other countries.
U.S. Government Rights - Commercial software. Government users are subject
to the Sun Microsystems, Inc. standard license agreement and applicable
provisions of the FAR and its supplements. Use is subject to license terms.
Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
product is covered and controlled by U.S. Export Control laws and may be
subject to the export or import laws in other countries. Nuclear, missile,
chemical biological weapons or nuclear maritime end uses or end users, whether
direct or indirect, are strictly prohibited. Export or reexport to countries
subject to U.S. embargo or to entities identified on U.S. export exclusion
lists, including, but not limited to, the denied persons and specially
designated nationals lists is strictly prohibited.
-->
<HEAD>
<title>JavaCC: JJDoc Documentation</title>
<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
</HEAD>
<BODY bgcolor="#FFFFFF" >
<H1>JavaCC [tm]: JJDoc Documentation</H1>
JJDoc takes a JavaCC [tm] parser specification and produces documentation
for the BNF grammar. It can operate in three modes, determined by
command line options.</p>
<dl>
<dt><code>TEXT</code></dt>
<dd>(default false)
<p>Setting <code>TEXT</code> to true causes JJDoc to generate
a plain text format description of the BNF. Some formatting
is done via tab characters, but the intention is to leave it
as plain as possible.</p>
<p>The default value of <code>TEXT</code> causes JJDoc to
generate a hyperlinked HTML document.</p>
</dd>
<dt><code>ONE_TABLE</code></dt>
<dd>(default true)
<p>The default value of <code>ONE_TABLE</code> is used to
generate a single HTML table for the BNF. Setting it to
false will produce one table for every production in the
grammar.</p>
</dd>
<dt><code>OUTPUT_FILE</code></dt>
<dd>The default behavior is to put the JJDoc output into a file
with either .html or .txt added as a suffix to the input
file's base name. You can supply a different file name with
this option.
</dd>
</dl>
<p>When in <code>TEXT</code> mode, or when <code>ONE_TABLE</code>
is false, comments in the JavaCC source that immediately precede a
production are passed through to the generated documentation.</p>
<HR>
</BODY>
</HTML>
This diff is collapsed.
This diff is collapsed.
<HTML>
<!--
Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
intellectual property rights relating to technology embodied in the product
that is described in this document. In particular, and without limitation,
these intellectual property rights may include one or more of the U.S.
patents listed at http://www.sun.com/patents and one or more additional
patents or pending patent applications in the U.S. and in other countries.
U.S. Government Rights - Commercial software. Government users are subject
to the Sun Microsystems, Inc. standard license agreement and applicable
provisions of the FAR and its supplements. Use is subject to license terms.
Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
product is covered and controlled by U.S. Export Control laws and may be
subject to the export or import laws in other countries. Nuclear, missile,
chemical biological weapons or nuclear maritime end uses or end users, whether
direct or indirect, are strictly prohibited. Export or reexport to countries
subject to U.S. embargo or to entities identified on U.S. export exclusion
lists, including, but not limited to, the denied persons and specially
designated nationals lists is strictly prohibited.
-->
<HEAD>
<title>JavaCC Command Line Syntax</title>
<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
</HEAD>
<BODY bgcolor="#FFFFFF" >
<H1>JavaCC [tm]: Command Line Syntax</H1>
First, you can obtain a synopsis of the command line syntax by simply
typing "javacc". This is what you get:
<P>
<PRE>
% javacc
<<< Version and copyright info>>>
Usage:
javacc option-settings inputfile
"option-settings" is a sequence of settings separated by spaces.
Each option setting must be of one of the following forms:
-optionname=value (e.g., -STATIC=false)
-optionname:value (e.g., -STATIC:false)
-optionname (equivalent to -optionname=true. e.g., -STATIC)
-NOoptionname (equivalent to -optionname=false. e.g., -NOSTATIC)
Option settings are not case-sensitive, so one can say "-nOsTaTiC" instead
of "-NOSTATIC". Option values must be appropriate for the corresponding
option, and must be either an integer, a boolean, or a string value.
The integer valued options are:
LOOKAHEAD (default 1)
CHOICE_AMBIGUITY_CHECK (default 2)
OTHER_AMBIGUITY_CHECK (default 1)
The boolean valued options are:
STATIC (default true)
DEBUG_PARSER (default false)
DEBUG_LOOKAHEAD (default false)
DEBUG_TOKEN_MANAGER (default false)
OPTIMIZE_TOKEN_MANAGER (default true)
ERROR_REPORTING (default true)
JAVA_UNICODE_ESCAPE (default false)
UNICODE_INPUT (default false)
IGNORE_CASE (default false)
COMMON_TOKEN_ACTION (default false)
USER_TOKEN_MANAGER (default false)
USER_CHAR_STREAM (default false)
BUILD_PARSER (default true)
BUILD_TOKEN_MANAGER (default true)
TOKEN_MANAGER_USES_PARSER (default false)
SANITY_CHECK (default true)
FORCE_LA_CHECK (default false)
CACHE_TOKENS (default false)
KEEP_LINE_COLUMN (default true)
The string valued options are:
OUTPUT_DIRECTORY (default Current Directory)
EXAMPLE:
javacc -STATIC=false -LOOKAHEAD:2 -debug_parser mygrammar.jj
ABOUT JavaCC:
JavaCC is a parser generator for the Java [tm] programming
language originally built by
Sriram Sankar (http://www.cs.stanford.edu/~sankar) and
Sreeni Viswanadha (http://www.cs.albany.edu/~sreeni).
%
</PRE>
<P>
The above help message pretty much explains everything. The options are
explained in detail in
<A HREF="javaccgrm.html#prod2">the description of the JavaCC
input syntax (click here)</A>.
<P>
Any option may be set either on the command line as shown in the help message
above, or in the grammar file as describe in
<A HREF="javaccgrm.html">the JavaCC input file syntax document</A>.
The effect is exactly the same. If the same option is set in both the
command line and the grammar file, then the option setting in the command
line takes precedence.
<P>
</BODY>
</HTML>
<HTML>
<!--
Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
intellectual property rights relating to technology embodied in the product
that is described in this document. In particular, and without limitation,
these intellectual property rights may include one or more of the U.S.
patents listed at http://www.sun.com/patents and one or more additional
patents or pending patent applications in the U.S. and in other countries.
U.S. Government Rights - Commercial software. Government users are subject
to the Sun Microsystems, Inc. standard license agreement and applicable
provisions of the FAR and its supplements. Use is subject to license terms.
Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
product is covered and controlled by U.S. Export Control laws and may be
subject to the export or import laws in other countries. Nuclear, missile,
chemical biological weapons or nuclear maritime end uses or end users, whether
direct or indirect, are strictly prohibited. Export or reexport to countries
subject to U.S. embargo or to entities identified on U.S. export exclusion
lists, including, but not limited to, the denied persons and specially
designated nationals lists is strictly prohibited.
-->
<HEAD>
<title>JavaCC Documentation Index</title>
<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
</HEAD>
<BODY bgcolor="#FFFFFF" >
<H1>JavaCC [tm]: Documentation Index</H1>
By following the links from this page you should be able to obtain all
necessary documentation on JavaCC [tm].
<P>
If you have further questions, please do not hesitate to
<a href="mailinglist.html">contact us</a>.
We recommend the following step-by-step process to learning JavaCC:
<UL>