Commit a4187c4a authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Working on new JavaCC parser, get emptyStackException at the moment

parent 684e1497
......@@ -7,4 +7,3 @@ plugins
testontologies/ontologyV06_Jambalaya.properties
siaras/Parser.java
siaras/Siaras.ast
siaras/Siaras.jjt
......@@ -11,8 +11,36 @@ aspect AbsGrammarGeneration {
}
public void Start.genAbsGrammar(PrintStream pStream) {
pStream.println("Start ::= Device*;");
pStream.println("// Predefined types");
pStream.println("Start ::= Element*;");
pStream.println("abstract Thing ::=;");
pStream.println("abstract Element;");
pStream.println("ComplexElement ::= <IDENTIFIER> Attribute* Element*;");
pStream.println("abstract SimpleElement : Element;");
pStream.println("StringElement : SimpleElement ::= <IDENTIFIER>;");
pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;");
pStream.println("FloatElement : SimpleElement ::= <FLOAT_LITERAL>;");
pStream.println("Attribute ::= Value;");
pStream.println("RdfDatatype : Attribute ::= ;");
pStream.println("RdfId : Attribute ::= ;");
pStream.println("Xmlns : Attribute ::= ;");
pStream.println("XmlnsProtege : Attribute ::= ;");
pStream.println("XmlnsRdf : Attribute ::= ;");
pStream.println("XmlnsXsd : Attribute ::= ;");
pStream.println("XmlnsRdfs : Attribute ::= ;");
pStream.println("XmlnsOwl : Attribute ::= ;");
pStream.println("XmlnsDaml : Attribute ::= ;");
pStream.println("XmlnsP1 : Attribute ::= ;");
pStream.println("XmlnsDc : Attribute ::= ;");
pStream.println("XmlBase : Attribute ::= ;");
pStream.println("RdfResource : Attribute ::= ;");
pStream.println("RdfAbout : Attribute ::= ;");
pStream.println("RdfParseType : Attribute ::= ;");
pStream.println("Version : Attribute ::= ;");
pStream.println("Value ::= <STRING_LITERAL>;");
pStream.println("AttrValue ::= <STRING_LITERAL>;");
pStream.println();
pStream.println("// Generated types");
super.genAbsGrammar(pStream);
}
......
......@@ -24,9 +24,9 @@ public class GenCompiler extends Parser {
PrintStream pStream = new PrintStream(new File(fileName));
ast.genAbsGrammar(pStream);
// Generate JavaCC configuration
fileName = "siaras/Siaras.jjt";
pStream = new PrintStream(new File(fileName));
ast.genJavaCC(pStream);
// fileName = "siaras/Siaras.jjt";
// pStream = new PrintStream(new File(fileName));
// ast.genJavaCC(pStream);
// Generate Parser.java
fileName = "siaras/Parser.java";
pStream = new PrintStream(new File(fileName));
......
options {
MULTI = true;
VISITOR = true;
NODE_DEFAULT_VOID = true;
NODE_SCOPE_HOOK = false;
NODE_PREFIX = "";
JAVA_UNICODE_ESCAPE = true;
STATIC = false;
} // options
PARSER_BEGIN(SiarasParser)
package AST;
public class SiarasParser {
}
PARSER_END(SiarasParser)
//--------------------------------------------------------------------//
// 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 : "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/" >
< "<!--" ( ~["-"] | ( "-" ~["-"] ) )* "-->">
| < "<rdfs:comment" ( ~["<"] | ( "<" ~["/"] ) )* "</rdfs:comment>" >
// <XML_COMMENT : "<!--" (~["-","-",">"])* "-->" >
}// COMMENTS
// <BOUNDS> TOKEN: {
// < BEGINCOMMENT : "<!--" >
// | < ENDCOMMENT : "-->" >
// }
<DEFAULT, BOUNDS> TOKEN : /* RESERVED WORDS AND LITERALS */
{
// < OWL_ALLVALUESFROM : "owl:allValuesFrom" >
// | < OWL_ALLDIFFERENT : "owl:AllDifferent" >
// | < OWL_CARDINALITY : "owl:cardinality" >
// | < OWL_CLASS : "owl:Class" >
// | < OWL_DATARANGE : "owl:DataRange" >
// | < OWL_DATATYPEPROPERTY : "owl:DatatypeProperty" >
// | < OWL_DISJOINTWITH : "owl:disjointWith" >
// | < OWL_EQUIVALENTCLASS : "owl:equivalentClass" >
// | < OWL_FUNCTIONALPROPERTY : "owl:FunctionalProperty" >
// | < OWL_IMPORTS : "owl:imports" >
// | < OWL_INTERSECTIONOF : "owl:intersectionOf" >
// | < OWL_INVERSEOF : "owl:inverseOf" >
// | < OWL_MINCARDINALITY : "owl:minCardinality" >
// | < OWL_OBJECTPROPERTY : "owl:ObjectProperty" >
// | < OWL_ONPROPERTY : "owl:onProperty" >
// | < OWL_ONEOF : "owl:oneOf" >
// | < OWL_ONTOLOGY : "owl:Ontology" >
// | < OWL_RESTRICTION : "owl:Restriction" >
// | < OWL_SOMEVALUESFROM : "owl:someValuesFrom" >
// | < OWL_UNIONOF : "owl:unionOf" >
// | < RDF_RDF : "rdf:RDF" >
< RDF_ABOUT : "rdf:about" >
| < RDF_DATATYPE : "rdf:datatype" >
| < RDF_ID : "rdf:ID" >
// | < RDF_FIRST : "rdf:first" >
// | < RDF_REST : "rdf:rest" >
| < RDF_PARSETYPE : "rdf:parseType" >
| < RDF_RESOURCE : "rdf:resource" >
// | < RDF_TYPE : "rdf:type" >
| < RDFS_COMMENT : "rdfs:comment" >
// | < RDFS_DOMAIN : "rdfs:domain" >
// | < RDFS_RANGE : "rdfs:range" >
// | < RDFS_SUBCLASSOF : "rdfs:subClassOf" >
// | < RDFS_SUBPROPERTYOF : "rdfs:subPropertyOf" >
| < VERSION : "version" >
// | < XML : "xml" >
| < XML_BASE : "xml:base" >
| < XMLNS : "xmlns" >
| < XMLNS_DAML : "xmlns:daml" >
| < XMLNS_DC : "xmlns:dc" >
| < XMLNS_P1 : "xmlns:p1" >
| < XMLNS_PROTEGE : "xmlns:protege" >
| < XMLNS_RDF : "xmlns:rdf" >
| < XMLNS_XSD : "xmlns:xsd" >
| < XMLNS_RDFS : "xmlns:rdfs" >
| < XMLNS_OWL : "xmlns:owl" >
}// 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"])* >
|
< FLOAT_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"]
)
)
)*
"\""
>
// |
// < TOKEN_LITERAL:
// ( (~[" ","\\","\n","\r"])
// )*
// >
}// 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
// <DEFAULT,BOUNDS> TOKEN : /* TEXT */
// {
// < TEXT : <LETTER> (~["<",">"])* >
// }// TEXT
//--------------------------------------------------------------------//
// THE OWL LANGUAGE GRAMMAR //
//--------------------------------------------------------------------//
Start Start() #Start : {}
{
("<?xml version=\"1.0\"?>")?
ElementList()
{ return jjtThis; }
}
// void Specification() #Specification : {}
// {
// XmlHeader()
// RdfDeclaration()
// }
// void XmlHeader() #XmlHeader : {}
// {
// "<?" <XML> AttributeList() "?>"
// }
// void RdfDeclaration() #RdfDeclaration : {}
// {
// "<" <RDF_RDF> AttributeList() ">"
// ElementList()
// "</" <RDF_RDF> ">"
// }
void ElementList() #List : {}
{
(Element())*
}
void AttributeList() #List : {}
{
(Attribute())*
}
void ComplexElement() #ComplexElement : {Token t;}
{
"<" t=<IDENTIFIER> AttributeList()
(">" ElementList() "</" <IDENTIFIER> ">" | ElementList() "/>")
{jjtThis.setIDENTIFIER(t.image);}
}
void Element() : {}
{
ComplexElement()
| SimpleElement()
}
void SimpleElement() : {}
{
IntElement()
| FloatElement()
| StringElement()
}
void IntElement() #IntElement : { Token t; }
{
t = <INTEGER_LITERAL>
{jjtThis.setINTEGER_LITERAL(t.image);}
}
void FloatElement() #FloatElement : { Token t; }
{
t = <FLOAT_LITERAL>
{jjtThis.setFLOAT_LITERAL(t.image);}
}
void StringElement() #StringElement : { Token t; }
{
t = <IDENTIFIER>
{jjtThis.setIDENTIFIER(t.image);}
}
// void OwlElement() : {}
// {
// OwlOntology()
// | OwlAllDifferent()
// | OwlAllValuesFrom()
// | OwlCardinality()
// | OwlClass()
// | OwlDataRange()
// | OwlDatatypeProperty()
// | OwlDisjointWith()
// | OwlEquivalentClass()
// | OwlFunctionalProperty()
// | OwlImports()
// | OwlIntersectionOf()
// | OwlInverseOf()
// | OwlMinCardinality()
// | OwlObjectProperty()
// | OwlOneOf()
// | OwlOnProperty()
// | OwlSomeValuesFrom()
// | OwlRestriction()
// | OwlUnionOf()
// }
// void OwlOntology() #OwlOntology : {}
// {
// <OWL_ONTOLOGY> AttributeList()
// (">" ElementList() "</" <OWL_ONTOLOGY> ">" | ElementList() "/>")
// }
// void OwlAllDifferent() #OwlAllDifferent : {}
// {
// <OWL_ALLDIFFERENT> AttributeList()
// (">" ElementList() "</" <OWL_ALLDIFFERENT> ">" | ElementList() "/>")
// }
// void OwlAllValuesFrom() #OwlAllValuesFrom : {}
// {
// <OWL_ALLVALUESFROM> AttributeList()
// (">" ElementList() "</" <OWL_ALLVALUESFROM> ">" | ElementList() "/>")
// }
// void OwlCardinality() #OwlCardinality : {}
// {
// <OWL_CARDINALITY> AttributeList()
// (">" ElementList() "</" <OWL_CARDINALITY> ">" | ElementList() "/>")
// }
// void OwlClass() #OwlClass : {}
// {
// <OWL_CLASS> AttributeList()
// (">" ElementList() "</" <OWL_CLASS> ">" | ElementList() "/>")
// }
// void OwlDataRange() #OwlDataRange : {}
// {
// <OWL_DATARANGE> AttributeList()
// (">" ElementList() "</" <OWL_DATARANGE> ">" | ElementList() "/>")
// }
// void OwlDatatypeProperty() #OwlDatatypeProperty : {}
// {
// <OWL_DATATYPEPROPERTY> AttributeList()
// (">" ElementList() "</" <OWL_DATATYPEPROPERTY> ">" | ElementList() "/>")
// }
// void OwlDisjointWith() #OwlDisjointWith : {}
// {
// <OWL_DISJOINTWITH> AttributeList()
// (">" ElementList() "</" <OWL_DISJOINTWITH> ">" | ElementList() "/>")
// }
// void OwlEquivalentClass() #OwlEquivalentClass : {}
// {
// <OWL_EQUIVALENTCLASS> AttributeList()
// (">" ElementList() "</" <OWL_EQUIVALENTCLASS> ">" | ElementList() "/>")
// }
// void OwlFunctionalProperty() #OwlFunctionalProperty : {}
// {
// <OWL_FUNCTIONALPROPERTY> AttributeList()
// (">" ElementList() "</" <OWL_FUNCTIONALPROPERTY> ">" | ElementList() "/>")
// }
// void OwlImports () #OwlImports : {}
// {
// <OWL_IMPORTS> AttributeList()
// (">" ElementList() "</" <OWL_IMPORTS> ">" | ElementList() "/>")
// }
// void OwlIntersectionOf () #OwlIntersectionOf : {}
// {
// <OWL_INTERSECTIONOF> AttributeList()
// (">" ElementList() "</" <OWL_INTERSECTIONOF> ">" | ElementList() "/>")
// }
// void OwlInverseOf () #OwlInverseOf : {}
// {
// <OWL_INVERSEOF> AttributeList()
// (">" ElementList() "</" <OWL_INVERSEOF> ">" | ElementList() "/>")
// }
// void OwlMinCardinality () #OwlMinCardinality : {}
// {
// <OWL_MINCARDINALITY> AttributeList()
// (">" ElementList() "</" <OWL_MINCARDINALITY> ">" | ElementList() "/>")
// }
// void OwlObjectProperty () #OwlObjectProperty : {}
// {
// <OWL_OBJECTPROPERTY> AttributeList()
// (">" ElementList() "</" <OWL_OBJECTPROPERTY> ">" | ElementList() "/>")
// }
// void OwlOneOf () #OwlOneOf : {}
// {
// <OWL_ONEOF> AttributeList()
// (">" ElementList() "</" <OWL_ONEOF> ">" | ElementList() "/>")
// }
// void OwlOnProperty () #OwlOnProperty : {}
// {
// <OWL_ONPROPERTY> AttributeList()
// (">" ElementList() "</" <OWL_ONPROPERTY> ">" | ElementList() "/>")
// }
// void OwlSomeValuesFrom () #OwlSomeValuesFrom : {}
// {
// <OWL_SOMEVALUESFROM> AttributeList()
// (">" ElementList() "</" <OWL_SOMEVALUESFROM> ">" | ElementList() "/>")
// }
// void OwlRestriction () #OwlRestriction : {}
// {
// <OWL_RESTRICTION> AttributeList()
// (">" ElementList() "</" <OWL_RESTRICTION> ">" | ElementList() "/>")
// }
// void OwlUnionOf () #OwlUnionOf : {}
// {
// <OWL_UNIONOF> AttributeList()
// (">" ElementList() "</" <OWL_UNIONOF> ">" | ElementList() "/>")
// }
// void RdfElement() : {}
// {
// RdfType()
// | RdfFirst()
// | RdfRest()
// | RdfsComment()
// | RdfsDomain()
// | RdfsRange()
// | RdfsSubClassOf()
// | RdfsSubPropertyOf()
// }
// void RdfType() #RdfType : {}
// {
// <RDF_TYPE> AttributeList()
// (">" ElementList() "</" <RDF_TYPE> ">" | ElementList() "/>")
// }
// void RdfFirst() #RdfFirst : {}
// {
// <RDF_FIRST> AttributeList()
// (">" ElementList() "</" <RDF_FIRST> ">" | ElementList() "/>")
// }
// void RdfRest() #RdfRest : {}
// {
// <RDF_REST> AttributeList()
// (">" ElementList() "</" <RDF_REST> ">" | ElementList() "/>")
// }
// void RdfsComment() #RdfsComment : {}
// {
// <RDFS_COMMENT> AttributeList()
// (">" ElementList() "</" <RDFS_COMMENT> ">" | ElementList() "/>")
// }
// void RdfsDomain() #RdfsDomain : {}
// {
// <RDFS_DOMAIN> AttributeList()
// (">" ElementList() "</" <RDFS_DOMAIN> ">" | ElementList() "/>")
// }
// void RdfsRange() #RdfsRange : {}
// {
// <RDFS_RANGE> AttributeList()
// (">" ElementList() "</" <RDFS_RANGE> ">" | ElementList() "/>")
// }
// void RdfsSubClassOf() #RdfsSubClassOf : {}
// {
// <RDFS_SUBCLASSOF> AttributeList()
// (">" ElementList() "</" <RDFS_SUBCLASSOF> ">" | ElementList() "/>")
// }
// void RdfsSubPropertyOf() #RdfsSubPropertyOf : {}
// {
// <RDFS_SUBPROPERTYOF> AttributeList()
// (">" ElementList() "</" <RDFS_SUBPROPERTYOF> ">" | ElementList() "/>")
// }
// void AttributeList() #List : {}
// {