options { LOOKAHEAD=21; } PARSER_BEGIN(GrailHierarchy) public class GrailHierarchy {} PARSER_END(GrailHierarchy) SKIP : { " " | "\r" | "\t" | "\n" } /* COMMENTS */ MORE : { "\"" : IN_COMMENT } MORE : { /* for now skip everything in comment state */ < ~["\""] > } SPECIAL_TOKEN : { : DEFAULT /* Comment carried over from MORE clause */ } TOKEN : { < NEWSUB: "newSub" > | < ADDSUB: "addSub" > | < ADDSUPER: "addSuper" > | < NEWATTRIBUTE: "newAttribute" > | < G: "grammatically"> | < G_S: "grammaticallyAndSensibly"> | < N: "necessarily"> | < S: "sensibly"> | < S_N: "sensiblyAndNecessarily"> | < S_TN: "sensiblyAndTopicNecessarily"> | < S_VN: "sensiblyAndValueNecessarily"> | < TN: "topicNecessarily"> | < WHICH: "which"> | < WHICHG: "whichG"> | < SPECIALISEDBY: "specialisedBy"> | < REFINEDALONG: "refinedAlong"> | < NAME: "name" > | < IGNORE: ( "rep" | "rename" | "model" | "gender" | "externalComment" | "author" ) > | < INT : (["0"-"9"])+ > | < ID: ()* > /*| < ID: ()+ >*/ | < ALPHA: (["a"-"z","A"-"Z"]) > | < ALPHANUM: (["a"-"z","A"-"Z","_","-","0"-"9"]) > | < LSQBRACKET: "[" > | < RSQBRACKET: "]" > | < LRBRACKET: "(" > | < RRBRACKET: ")" > | < LTBRACKET: "<" > | < GTBRACKET: ">" > | < SEMI: ";"> | < COLON: "."> | < CAR: ( "allAll" | "manyMany" | "oneMany" | "manyOne" | "oneOne" ) > } void CompilationUnit(): {} { (grail())* } void grail(): {} { grailSingle() ( grailRepeat() )* } void grailRepeat(): {} { operatorExpression() } void grailSingle(): {} { expression() operatorExpression() } void operatorExpression(): {} { simpleExpression() | parameterizedExpression() | attributeExpression() } void simpleExpression(): {} { simpleOperator() expression() } void parameterizedExpression(): {} { parameterizedOperator() property() expression() } void attributeExpression(): {} { attributeOperator() property() property() (cardinality())+ } void cardinality(): {} { /* allAll is not necessary, so this will only use the last cardinality given */ } void expression(): {} { classSingle() | expressionList() | whichConjunction() } void classSingle(): {} { } void expressionList(): {} { ( expression() )+ } void whichConjunction(): {} { expression() whichOperator() angleBracketsOrPropertyExpression() } void angleBracketsOrPropertyExpression(): {} { propertyExpression() | anglePairList() } void propertyExpression(): {} { property() expression() } void property(): {} { } void anglePairList(): {} { ( propertyExpression() )+ } void parameterizedOperator(): {} { | | | | | | | } void whichOperator(): {} { | } void simpleOperator(): {} { | | | | | } void attributeOperator(): {} { }