options { STATIC = false; JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(Parser) package edu.neu.ccs.demeter.aplib.cd; import java.util.*; import java.io.*; import edu.neu.ccs.demeter.aplib.*; import edu.neu.ccs.demeter.*; public class Parser { // oit is uugly. Why isn't there a Character.valueOf(String)? static char unescapifyChar(String s) { char c = s.charAt(0); if (c == '\\') { switch (s.charAt(1)) { case 'n': c = '\n'; break; case 't': c = '\t'; break; case 'b': c = '\b'; break; case 'r': c = '\r'; break; case 'f': c = '\f'; break; case '\\': c = '\\'; break; case '\'': c = '\''; break; case '\"': c = '\"'; break; default: c = (char) Integer.parseInt(s.substring(1, s.length()), 8); break; } } return c; } // Even uglier... static String unescapify(String s) { char str[] = new char[s.length()]; int i = 0, o = 0; while (i < s.length()) { char c = s.charAt(i++); if (c == '\\') { int j = i + 1; while (j < s.length() && Character.digit(s.charAt(j), 8) != -1) { j++; } c = unescapifyChar(s.substring(i-1, j)); i = j; } str[o++] = c; } return String.valueOf(str, 0, o); } } PARSER_END(Parser) Main _Main() : { Main it = null; } { { it=new Main(); } { return it; } } ClassGraph _ClassGraph() : { ClassGraph it = null; Preamble _preamble; ClassGraphEntry_SList _classes; } { { it=new ClassGraph(); } [ _preamble=_Preamble() { it.set_preamble(_preamble); } ] [ _classes=_ClassGraphEntry_SList() { it.set_classes(_classes); } ] { return it; } } Preamble _Preamble() : { Preamble it = null; Package _pkg; LocalImports _localimports; } { { it=new Preamble(); } _pkg=_Package() { it.set_pkg(_pkg); } _localimports=_LocalImports() { it.set_localimports(_localimports); } { return it; } } Package _Package() : { Package it = null; PackageName _packagename; } { { it=new Package(); } "package" _packagename=_PackageName() { it.set_packagename(_packagename); } ";" { return it; } } LocalImports _LocalImports() : { LocalImports it = null; Import_SList _imports; } { { it=new LocalImports(); } [ _imports=_Import_SList() { it.set_imports(_imports); } ] { return it; } } Import _Import() : { Import it = null; PackageName _packagename; ImportAllClasses _importallclasses; } { { it=new Import(); } "import" _packagename=_PackageName() { it.set_packagename(_packagename); } [ _importallclasses=_ImportAllClasses() { it.set_importallclasses(_importallclasses); } ] ";" { return it; } } ImportAllClasses _ImportAllClasses() : { ImportAllClasses it = null; } { { it=new ImportAllClasses(); } ".*" { return it; } } ClassGraphEntry _ClassGraphEntry() : { ClassGraphEntry it = null; } { ( LOOKAHEAD ( 2 )it=_Directive() | it=_Definition() ) { return it; } } void common_ClassGraphEntry(ClassGraphEntry it) : { } { { } } Directive _Directive() : { Directive it = null; } { ( it=_ParseDirective() | it=_VisitorDirective() ) { return it; } } void common_Directive(Directive it) : { } { common_ClassGraphEntry(it) { } } ParseDirective _ParseDirective() : { ParseDirective it = null; ParseKeyword _parsekeyword; } { { it=new ParseDirective(); } _parsekeyword=_ParseKeyword() { it.set_parsekeyword(_parsekeyword); } common_Directive(it) { return it; } } VisitorDirective _VisitorDirective() : { VisitorDirective it = null; VisitorKeyword _visitorkeyword; } { { it=new VisitorDirective(); } _visitorkeyword=_VisitorKeyword() { it.set_visitorkeyword(_visitorkeyword); } common_Directive(it) { return it; } } Definition _Definition() : { Definition it = null; } { ( it=_ClassDef() ) { return it; } } void common_Definition(Definition it) : { } { common_ClassGraphEntry(it) { } } ClassDef _ClassDef() : { ClassDef it = null; ClassKeyword_List _keywords; ParamClassName _paramclassname; ParseDirective _parsedirective; ClassParts _classparts; EOFtoken _eoftoken; } { { it=new ClassDef(); } _keywords=_ClassKeyword_List() { it.set_keywords(_keywords); } _paramclassname=_ParamClassName() { it.set_paramclassname(_paramclassname); } [ _parsedirective=_ParseDirective() { it.set_parsedirective(_parsedirective); } ] _classparts=_ClassParts() { it.set_classparts(_classparts); } [ _eoftoken=_EOFtoken() { it.set_eoftoken(_eoftoken); } ] "." common_Definition(it) { return it; } } ClassKeyword_List _ClassKeyword_List() : { ClassKeyword_List it = null; Nonempty_ClassKeyword_List _first; } { { it=new ClassKeyword_List(); } [ LOOKAHEAD ( 1 ) _first=_Nonempty_ClassKeyword_List() { it.set_first(_first); } ] { return it; } } ParamClassName _ParamClassName() : { ParamClassName it = null; ClassName _classname; ClassName_Commalist _parameters; } { { it=new ParamClassName(); } _classname=_ClassName() { it.set_classname(_classname); } [ "(" _parameters=_ClassName_Commalist() { it.set_parameters(_parameters); } ")" ] { return it; } } ClassParts _ClassParts() : { ClassParts it = null; } { ( it=_ConstOrAltClass() | it=_RepetitionClass() ) { return it; } } void common_ClassParts(ClassParts it) : { } { { } } ConstOrAltClass _ConstOrAltClass() : { ConstOrAltClass it = null; } { ( it=_ConstructionClass() | it=_AlternationClass() ) { return it; } } void common_ConstOrAltClass(ConstOrAltClass it) : { PartOrSyntax_List _parts; ClassParents _parents; } { _parts=_PartOrSyntax_List() { it.set_parts(_parts); } _parents=_ClassParents() { it.set_parents(_parents); } common_ClassParts(it) { } } PartOrSyntax _PartOrSyntax() : { PartOrSyntax it = null; } { ( it=_Part() | it=_OptionalPart() | it=_Syntax() ) { return it; } } void common_PartOrSyntax(PartOrSyntax it) : { } { { } } Part _Part() : { Part it = null; PartName _partname; PartKeyword_List _keywords; ClassSpec _classspec; PartInit _partinit; } { { it=new Part(); } [ "<" _partname=_PartName() { it.set_partname(_partname); } ">" ] _keywords=_PartKeyword_List() { it.set_keywords(_keywords); } _classspec=_ClassSpec() { it.set_classspec(_classspec); } [ LOOKAHEAD ( 2 ) _partinit=_PartInit() { it.set_partinit(_partinit); } ] common_PartOrSyntax(it) { return it; } } PartKeyword_List _PartKeyword_List() : { PartKeyword_List it = null; Nonempty_PartKeyword_List _first; } { { it=new PartKeyword_List(); } [ LOOKAHEAD ( 1 ) _first=_Nonempty_PartKeyword_List() { it.set_first(_first); } ] { return it; } } PartInit _PartInit() : { PartInit it = null; PartInitKeyword _partinitkeyword; JavaCode _javacode; } { { it=new PartInit(); } _partinitkeyword=_PartInitKeyword() { it.set_partinitkeyword(_partinitkeyword); } _javacode=_JavaCode() { it.set_javacode(_javacode); } { return it; } } OptionalPart _OptionalPart() : { OptionalPart it = null; LocalLookahead _locallookahead; Part_Sandwich _part; } { { it=new OptionalPart(); } "[" [ LOOKAHEAD ( 2 ) _locallookahead=_LocalLookahead() { it.set_locallookahead(_locallookahead); } ] _part=_Part_Sandwich() { it.set_part(_part); } "]" common_PartOrSyntax(it) { return it; } } ClassParents _ClassParents() : { ClassParents it = null; Superclasses _superclasses; Interfaces _interfaces; } { { it=new ClassParents(); } [ _superclasses=_Superclasses() { it.set_superclasses(_superclasses); } ] [ _interfaces=_Interfaces() { it.set_interfaces(_interfaces); } ] { return it; } } Superclasses _Superclasses() : { Superclasses it = null; ExtendsKeyword _extendskeyword; Superclass_Commalist _superclasses; } { { it=new Superclasses(); } _extendskeyword=_ExtendsKeyword() { it.set_extendskeyword(_extendskeyword); } _superclasses=_Superclass_Commalist() { it.set_superclasses(_superclasses); } { return it; } } Superclass _Superclass() : { Superclass it = null; ClassSpec _classspec; } { { it=new Superclass(); } _classspec=_ClassSpec() { it.set_classspec(_classspec); } { return it; } } Interfaces _Interfaces() : { Interfaces it = null; ImplementsKeyword _implementskeyword; Interface_Commalist _interfaces; } { { it=new Interfaces(); } _implementskeyword=_ImplementsKeyword() { it.set_implementskeyword(_implementskeyword); } _interfaces=_Interface_Commalist() { it.set_interfaces(_interfaces); } { return it; } } Interface _Interface() : { Interface it = null; ClassSpec _classspec; } { { it=new Interface(); } _classspec=_ClassSpec() { it.set_classspec(_classspec); } { return it; } } ConstructionClass _ConstructionClass() : { ConstructionClass it = null; } { { it=new ConstructionClass(); } "=" common_ConstOrAltClass(it) { return it; } } AlternationClass _AlternationClass() : { AlternationClass it = null; Subclass_Barlist _subclasses; CommonKeyword _commonkeyword; } { { it=new AlternationClass(); } ":" [ LOOKAHEAD ( _Subclass(), { !getToken(1).image.equals("common") } ) _subclasses=_Subclass_Barlist() { it.set_subclasses(_subclasses); } ] [ LOOKAHEAD ( 1 ) _commonkeyword=_CommonKeyword() { it.set_commonkeyword(_commonkeyword); } ] common_ConstOrAltClass(it) { return it; } } Subclass _Subclass() : { Subclass it = null; LocalLookahead _locallookahead; ClassSpec _classspec; } { { it=new Subclass(); } [ LOOKAHEAD ( 2 ) _locallookahead=_LocalLookahead() { it.set_locallookahead(_locallookahead); } ] _classspec=_ClassSpec() { it.set_classspec(_classspec); } { return it; } } LocalLookahead _LocalLookahead() : { LocalLookahead it = null; LookaheadKeyword _lookaheadkeyword; JavaCode _javacode; } { { it=new LocalLookahead(); } _lookaheadkeyword=_LookaheadKeyword() { it.set_lookaheadkeyword(_lookaheadkeyword); } _javacode=_JavaCode() { it.set_javacode(_javacode); } { return it; } } RepetitionClass _RepetitionClass() : { RepetitionClass it = null; RepeatedPart_Sandwich _sandwiched; } { { it=new RepetitionClass(); } "~" _sandwiched=_RepeatedPart_Sandwich() { it.set_sandwiched(_sandwiched); } common_ClassParts(it) { return it; } } RepeatedPart _RepeatedPart() : { RepeatedPart it = null; ClassSpec _nonempty; OpenBrace _openbrace; LocalLookahead _locallookahead; RepeatedElement_Sandwich _repeated; } { { it=new RepeatedPart(); } [ _nonempty=_ClassSpec() { it.set_nonempty(_nonempty); } ] _openbrace=_OpenBrace() { it.set_openbrace(_openbrace); } [ LOOKAHEAD ( 2 ) _locallookahead=_LocalLookahead() { it.set_locallookahead(_locallookahead); } ] _repeated=_RepeatedElement_Sandwich() { it.set_repeated(_repeated); } "}" { return it; } } OpenBrace _OpenBrace() : { OpenBrace it = null; } { { it=new OpenBrace(); } "{" { return it; } } RepeatedElement _RepeatedElement() : { RepeatedElement it = null; ClassSpec _classspec; } { { it=new RepeatedElement(); } _classspec=_ClassSpec() { it.set_classspec(_classspec); } { return it; } } ClassSpec _ClassSpec() : { ClassSpec it = null; ClassName _classname; ClassSpec_Commalist _actual_parameters; } { { it=new ClassSpec(); } _classname=_ClassName() { it.set_classname(_classname); } [ "(" _actual_parameters=_ClassSpec_Commalist() { it.set_actual_parameters(_actual_parameters); } ")" ] { return it; } } Syntax _Syntax() : { Syntax it = null; } { ( it=_PlainSyntax() | it=_PrintCommand() ) { return it; } } void common_Syntax(Syntax it) : { } { common_PartOrSyntax(it) { } } PlainSyntax _PlainSyntax() : { PlainSyntax it = null; String _string; } { { it=new PlainSyntax(); } _string=_String() { it.set_string(_string); } common_Syntax(it) { return it; } } PrintCommand _PrintCommand() : { PrintCommand it = null; } { ( it=_PrintIndent() | it=_PrintUnindent() | it=_PrintSkip() | it=_PrintSpace() ) { return it; } } void common_PrintCommand(PrintCommand it) : { } { common_Syntax(it) { } } PrintIndent _PrintIndent() : { PrintIndent it = null; } { { it=new PrintIndent(); } "+" common_PrintCommand(it) { return it; } } PrintUnindent _PrintUnindent() : { PrintUnindent it = null; } { { it=new PrintUnindent(); } "-" common_PrintCommand(it) { return it; } } PrintSkip _PrintSkip() : { PrintSkip it = null; } { { it=new PrintSkip(); } "*l" common_PrintCommand(it) { return it; } } PrintSpace _PrintSpace() : { PrintSpace it = null; } { { it=new PrintSpace(); } "*s" common_PrintCommand(it) { return it; } } PackageName _PackageName() : { PackageName it = null; Nonempty_PackageName _first; } { { it=new PackageName(); } _first=_Nonempty_PackageName() { it.set_first(_first); } { return it; } } ClassName _ClassName() : { ClassName it = null; Name _name; } { { it=new ClassName(); } _name=_Name() { it.set_name(_name); } { return it; } } PartName _PartName() : { PartName it = null; IdentOrKeyword _name; } { { it=new PartName(); } _name=_IdentOrKeyword() { it.set_name(_name); } { return it; } } JavaCode _JavaCode() : { JavaCode it = null; Text _code; } { { it=new JavaCode(); } _code=_Text() { it.set_code(_code); } { return it; } } Name _Name() : { Name it = null; Nonempty_Name _first; } { { it=new Name(); } _first=_Nonempty_Name() { it.set_first(_first); } { return it; } } IdentOrKeyword _IdentOrKeyword() : { IdentOrKeyword it = null; } { ( it=_ParseIdent() | it=_NoParseIdent() | it=_VisitorsIdent() | it=_EndVisitorsIdent() | it=_VisitorIdent() | it=_NotParsedIdent() | it=_DerivedIdent() | it=_InitIdent() | it=_CommonIdent() | it=_LookaheadIdent() | it=_OtherIdent() ) { return it; } } void common_IdentOrKeyword(IdentOrKeyword it) : { } { { } } ParseIdent _ParseIdent() : { ParseIdent it = null; } { { it=new ParseIdent(); } "parse" common_IdentOrKeyword(it) { return it; } } NoParseIdent _NoParseIdent() : { NoParseIdent it = null; } { { it=new NoParseIdent(); } "noparse" common_IdentOrKeyword(it) { return it; } } VisitorsIdent _VisitorsIdent() : { VisitorsIdent it = null; } { { it=new VisitorsIdent(); } "visitors" common_IdentOrKeyword(it) { return it; } } EndVisitorsIdent _EndVisitorsIdent() : { EndVisitorsIdent it = null; } { { it=new EndVisitorsIdent(); } "endvisitors" common_IdentOrKeyword(it) { return it; } } VisitorIdent _VisitorIdent() : { VisitorIdent it = null; } { { it=new VisitorIdent(); } "visitor" common_IdentOrKeyword(it) { return it; } } NotParsedIdent _NotParsedIdent() : { NotParsedIdent it = null; } { { it=new NotParsedIdent(); } "notparsed" common_IdentOrKeyword(it) { return it; } } DerivedIdent _DerivedIdent() : { DerivedIdent it = null; } { { it=new DerivedIdent(); } "derived" common_IdentOrKeyword(it) { return it; } } InitIdent _InitIdent() : { InitIdent it = null; } { { it=new InitIdent(); } "init" common_IdentOrKeyword(it) { return it; } } CommonIdent _CommonIdent() : { CommonIdent it = null; } { { it=new CommonIdent(); } "common" common_IdentOrKeyword(it) { return it; } } LookaheadIdent _LookaheadIdent() : { LookaheadIdent it = null; } { { it=new LookaheadIdent(); } "lookahead" common_IdentOrKeyword(it) { return it; } } OtherIdent _OtherIdent() : { OtherIdent it = null; Ident _id; } { { it=new OtherIdent(); } _id=_Ident() { it.set_id(_id); } common_IdentOrKeyword(it) { return it; } } ParseKeyword _ParseKeyword() : { ParseKeyword it = null; } { ( it=_DoParse() | it=_DontParse() ) { return it; } } void common_ParseKeyword(ParseKeyword it) : { } { { } } DoParse _DoParse() : { DoParse it = null; } { { it=new DoParse(); } "parse" common_ParseKeyword(it) { return it; } } DontParse _DontParse() : { DontParse it = null; } { { it=new DontParse(); } "noparse" common_ParseKeyword(it) { return it; } } VisitorKeyword _VisitorKeyword() : { VisitorKeyword it = null; } { ( it=_BeginVisitors() | it=_EndVisitors() ) { return it; } } void common_VisitorKeyword(VisitorKeyword it) : { } { { } } BeginVisitors _BeginVisitors() : { BeginVisitors it = null; } { { it=new BeginVisitors(); } "visitors" common_VisitorKeyword(it) { return it; } } EndVisitors _EndVisitors() : { EndVisitors it = null; } { { it=new EndVisitors(); } "endvisitors" common_VisitorKeyword(it) { return it; } } ClassKeyword _ClassKeyword() : { ClassKeyword it = null; } { ( it=_PublicClass() | it=_FinalClass() | it=_InterfaceClass() | it=_VisitorClass() | it=_NotParsedClass() ) { return it; } } void common_ClassKeyword(ClassKeyword it) : { } { { } } PublicClass _PublicClass() : { PublicClass it = null; } { { it=new PublicClass(); } "public" common_ClassKeyword(it) { return it; } } FinalClass _FinalClass() : { FinalClass it = null; } { { it=new FinalClass(); } "final" common_ClassKeyword(it) { return it; } } InterfaceClass _InterfaceClass() : { InterfaceClass it = null; } { { it=new InterfaceClass(); } "interface" common_ClassKeyword(it) { return it; } } VisitorClass _VisitorClass() : { VisitorClass it = null; } { { it=new VisitorClass(); } "visitor" common_ClassKeyword(it) { return it; } } NotParsedClass _NotParsedClass() : { NotParsedClass it = null; } { { it=new NotParsedClass(); } "notparsed" common_ClassKeyword(it) { return it; } } PartKeyword _PartKeyword() : { PartKeyword it = null; } { ( it=_FinalPart() | it=_StaticPart() | it=_ReadOnlyPart() | it=_PrivatePart() | it=_DerivedPart() ) { return it; } } void common_PartKeyword(PartKeyword it) : { } { { } } FinalPart _FinalPart() : { FinalPart it = null; } { { it=new FinalPart(); } "final" common_PartKeyword(it) { return it; } } StaticPart _StaticPart() : { StaticPart it = null; } { { it=new StaticPart(); } "static" common_PartKeyword(it) { return it; } } ReadOnlyPart _ReadOnlyPart() : { ReadOnlyPart it = null; } { { it=new ReadOnlyPart(); } "read-only" common_PartKeyword(it) { return it; } } PrivatePart _PrivatePart() : { PrivatePart it = null; } { { it=new PrivatePart(); } "private" common_PartKeyword(it) { return it; } } DerivedPart _DerivedPart() : { DerivedPart it = null; } { { it=new DerivedPart(); } "derived" common_PartKeyword(it) { return it; } } PartInitKeyword _PartInitKeyword() : { PartInitKeyword it = null; } { { it=new PartInitKeyword(); } "init" { return it; } } ExtendsKeyword _ExtendsKeyword() : { ExtendsKeyword it = null; } { { it=new ExtendsKeyword(); } "extends" { return it; } } ImplementsKeyword _ImplementsKeyword() : { ImplementsKeyword it = null; } { { it=new ImplementsKeyword(); } "implements" { return it; } } CommonKeyword _CommonKeyword() : { CommonKeyword it = null; } { { it=new CommonKeyword(); } "common" { return it; } } LookaheadKeyword _LookaheadKeyword() : { LookaheadKeyword it = null; } { { it=new LookaheadKeyword(); } "lookahead" { return it; } } EOFtoken _EOFtoken() : { EOFtoken it = null; } { { it=new EOFtoken(); } "EOF" { return it; } } ClassGraphEntry_SList _ClassGraphEntry_SList() : { ClassGraphEntry_SList it = null; Nonempty_ClassGraphEntry_SList _first; } { { it=new ClassGraphEntry_SList(); } _first=_Nonempty_ClassGraphEntry_SList() { it.set_first(_first); } { return it; } } Import_SList _Import_SList() : { Import_SList it = null; Nonempty_Import_SList _first; } { { it=new Import_SList(); } _first=_Nonempty_Import_SList() { it.set_first(_first); } { return it; } } ClassName_Commalist _ClassName_Commalist() : { ClassName_Commalist it = null; Nonempty_ClassName_Commalist _first; } { { it=new ClassName_Commalist(); } _first=_Nonempty_ClassName_Commalist() { it.set_first(_first); } { return it; } } PartOrSyntax_List _PartOrSyntax_List() : { PartOrSyntax_List it = null; Nonempty_PartOrSyntax_List _first; } { { it=new PartOrSyntax_List(); } [ _first=_Nonempty_PartOrSyntax_List() { it.set_first(_first); } ] { return it; } } Part_Sandwich _Part_Sandwich() : { Part_Sandwich it = null; Syntax_List _first; Part _inner; Syntax_List _second; } { { it=new Part_Sandwich(); } _first=_Syntax_List() { it.set_first(_first); } _inner=_Part() { it.set_inner(_inner); } _second=_Syntax_List() { it.set_second(_second); } { return it; } } Superclass_Commalist _Superclass_Commalist() : { Superclass_Commalist it = null; Nonempty_Superclass_Commalist _first; } { { it=new Superclass_Commalist(); } _first=_Nonempty_Superclass_Commalist() { it.set_first(_first); } { return it; } } Interface_Commalist _Interface_Commalist() : { Interface_Commalist it = null; Nonempty_Interface_Commalist _first; } { { it=new Interface_Commalist(); } _first=_Nonempty_Interface_Commalist() { it.set_first(_first); } { return it; } } Subclass_Barlist _Subclass_Barlist() : { Subclass_Barlist it = null; Nonempty_Subclass_Barlist _first; } { { it=new Subclass_Barlist(); } _first=_Nonempty_Subclass_Barlist() { it.set_first(_first); } { return it; } } RepeatedPart_Sandwich _RepeatedPart_Sandwich() : { RepeatedPart_Sandwich it = null; Syntax_List _first; RepeatedPart _inner; Syntax_List _second; } { { it=new RepeatedPart_Sandwich(); } _first=_Syntax_List() { it.set_first(_first); } _inner=_RepeatedPart() { it.set_inner(_inner); } _second=_Syntax_List() { it.set_second(_second); } { return it; } } RepeatedElement_Sandwich _RepeatedElement_Sandwich() : { RepeatedElement_Sandwich it = null; Syntax_List _first; RepeatedElement _inner; Syntax_List _second; } { { it=new RepeatedElement_Sandwich(); } _first=_Syntax_List() { it.set_first(_first); } _inner=_RepeatedElement() { it.set_inner(_inner); } _second=_Syntax_List() { it.set_second(_second); } { return it; } } Syntax_List _Syntax_List() : { Syntax_List it = null; Nonempty_Syntax_List _first; } { { it=new Syntax_List(); } [ _first=_Nonempty_Syntax_List() { it.set_first(_first); } ] { return it; } } ClassSpec_Commalist _ClassSpec_Commalist() : { ClassSpec_Commalist it = null; Nonempty_ClassSpec_Commalist _first; } { { it=new ClassSpec_Commalist(); } _first=_Nonempty_ClassSpec_Commalist() { it.set_first(_first); } { return it; } } Nonempty_ClassKeyword_List _Nonempty_ClassKeyword_List() : { Nonempty_ClassKeyword_List it = null; ClassKeyword _it; Nonempty_ClassKeyword_List _next; } { { it=new Nonempty_ClassKeyword_List(); } _it=_ClassKeyword() { it.set_it(_it); } [ LOOKAHEAD ( 1 ) _next=_Nonempty_ClassKeyword_List() { it.set_next(_next); } ] { return it; } } Nonempty_PartKeyword_List _Nonempty_PartKeyword_List() : { Nonempty_PartKeyword_List it = null; PartKeyword _it; Nonempty_PartKeyword_List _next; } { { it=new Nonempty_PartKeyword_List(); } _it=_PartKeyword() { it.set_it(_it); } [ LOOKAHEAD ( 1 ) _next=_Nonempty_PartKeyword_List() { it.set_next(_next); } ] { return it; } } Nonempty_PackageName _Nonempty_PackageName() : { Nonempty_PackageName it = null; IdentOrKeyword _it; Nonempty_PackageName _next; } { { it=new Nonempty_PackageName(); } _it=_IdentOrKeyword() { it.set_it(_it); } [ LOOKAHEAD ( 2 ) "." _next=_Nonempty_PackageName() { it.set_next(_next); } ] { return it; } } Nonempty_Name _Nonempty_Name() : { Nonempty_Name it = null; IdentOrKeyword _it; Nonempty_Name _next; } { { it=new Nonempty_Name(); } _it=_IdentOrKeyword() { it.set_it(_it); } [ LOOKAHEAD ( "." _IdentOrKeyword(), { getToken(3).image.equals(".") || getToken(3).kind == EOF || ("=:~(".indexOf(getToken(3).image) == -1 && !getToken(2).image.equals("visitor") && !getToken(2).image.equals("notparsed") && !getToken(2).image.equals("parse") && !getToken(2).image.equals("noparse") && !getToken(2).image.equals("visitors") && !getToken(2).image.equals("endvisitors")) } ) "." _next=_Nonempty_Name() { it.set_next(_next); } ] { return it; } } Nonempty_ClassGraphEntry_SList _Nonempty_ClassGraphEntry_SList() : { Nonempty_ClassGraphEntry_SList it = null; ClassGraphEntry _it; Nonempty_ClassGraphEntry_SList _next; } { { it=new Nonempty_ClassGraphEntry_SList(); } _it=_ClassGraphEntry() { it.set_it(_it); } [ _next=_Nonempty_ClassGraphEntry_SList() { it.set_next(_next); } ] { return it; } } Nonempty_Import_SList _Nonempty_Import_SList() : { Nonempty_Import_SList it = null; Import _it; Nonempty_Import_SList _next; } { { it=new Nonempty_Import_SList(); } _it=_Import() { it.set_it(_it); } [ _next=_Nonempty_Import_SList() { it.set_next(_next); } ] { return it; } } Nonempty_ClassName_Commalist _Nonempty_ClassName_Commalist() : { Nonempty_ClassName_Commalist it = null; ClassName _it; Nonempty_ClassName_Commalist _next; } { { it=new Nonempty_ClassName_Commalist(); } _it=_ClassName() { it.set_it(_it); } [ "," _next=_Nonempty_ClassName_Commalist() { it.set_next(_next); } ] { return it; } } Nonempty_PartOrSyntax_List _Nonempty_PartOrSyntax_List() : { Nonempty_PartOrSyntax_List it = null; PartOrSyntax _it; Nonempty_PartOrSyntax_List _next; } { { it=new Nonempty_PartOrSyntax_List(); } _it=_PartOrSyntax() { it.set_it(_it); } [ _next=_Nonempty_PartOrSyntax_List() { it.set_next(_next); } ] { return it; } } Nonempty_Superclass_Commalist _Nonempty_Superclass_Commalist() : { Nonempty_Superclass_Commalist it = null; Superclass _it; Nonempty_Superclass_Commalist _next; } { { it=new Nonempty_Superclass_Commalist(); } _it=_Superclass() { it.set_it(_it); } [ "," _next=_Nonempty_Superclass_Commalist() { it.set_next(_next); } ] { return it; } } Nonempty_Interface_Commalist _Nonempty_Interface_Commalist() : { Nonempty_Interface_Commalist it = null; Interface _it; Nonempty_Interface_Commalist _next; } { { it=new Nonempty_Interface_Commalist(); } _it=_Interface() { it.set_it(_it); } [ "," _next=_Nonempty_Interface_Commalist() { it.set_next(_next); } ] { return it; } } Nonempty_Subclass_Barlist _Nonempty_Subclass_Barlist() : { Nonempty_Subclass_Barlist it = null; Subclass _it; Nonempty_Subclass_Barlist _next; } { { it=new Nonempty_Subclass_Barlist(); } _it=_Subclass() { it.set_it(_it); } [ "|" _next=_Nonempty_Subclass_Barlist() { it.set_next(_next); } ] { return it; } } Nonempty_Syntax_List _Nonempty_Syntax_List() : { Nonempty_Syntax_List it = null; Syntax _it; Nonempty_Syntax_List _next; } { { it=new Nonempty_Syntax_List(); } _it=_Syntax() { it.set_it(_it); } [ _next=_Nonempty_Syntax_List() { it.set_next(_next); } ] { return it; } } Nonempty_ClassSpec_Commalist _Nonempty_ClassSpec_Commalist() : { Nonempty_ClassSpec_Commalist it = null; ClassSpec _it; Nonempty_ClassSpec_Commalist _next; } { { it=new Nonempty_ClassSpec_Commalist(); } _it=_ClassSpec() { it.set_it(_it); } [ "," _next=_Nonempty_ClassSpec_Commalist() { it.set_next(_next); } ] { return it; } } boolean _boolean() : { Token t; }{ ( t= { return true; } | t= { return false; } ) } char _char() : { Token t; } { t= { String s = t.image; return unescapifyChar(s.substring(1, s.length()-1)); } } byte _byte() : { int i; } { i=_int() { return (byte) i; } } short _short() : { int i; } { i=_int() { return (short) i; } } int _int() : { Number num; } { num=_Number() { return num.intValue(); } } long _long() : { Number num; } { num=_Number() { return num.longValue(); } } float _float() : { Number num; } { num=_Number() { return num.floatValue(); } } double _double() : { Number num; } { num=_Number() { return num.doubleValue(); } } Boolean _Boolean() : { Token t; }{ ( t= { return Boolean.TRUE; } | t= { return Boolean.FALSE; } ) } Character _Character() : { char c; } { c=_char() { return new Character(c); } } Integer _Integer() : { int i; } { i = _int() { return new Integer(i); } } Long _Long() : { long l; } { l=_long() { return new Long(l); } } Float _Float() : { float f; } { f=_float() { return new Float(f); } } Double _Double() : { double d; } { d=_double() { return new Double(d); } } Number _Number() : { Token t; String s = null; int radix = 0; Number num = null; } { ( ( t= { s = t.image; radix = 10; } | t= { // Strip off the "0x". s = t.image.substring(2, t.image.length()); radix = 16; } | t= { s = t.image; radix = 8; } ) { switch (s.charAt(s.length()-1)) { case 'l': case 'L': s = s.substring(0, s.length()-1); num = new Long(new java.math.BigInteger(s, radix).longValue()); break; default: num = new Integer(new java.math.BigInteger(s, radix).intValue()); break; } } | t= { s = t.image; switch (s.charAt(s.length()-1)) { case 'd': case 'D': num = Double.valueOf(s.substring(0, s.length()-1)); break; case 'f': case 'F': num = Float.valueOf(s.substring(0, s.length()-1)); break; default: num = Float.valueOf(s); break; } } ) { return num; } } String _String() : { Token t; } { t= { String s = t.image; return unescapify(s.substring(1, s.length()-1)); } } StringBuffer _StringBuffer() : { String s; } { s=_String() { return new StringBuffer(s); } } Ident _Ident() : { Token t; } { t= { return new Ident(t.image); } } Text _Text() : { Token t; } { t= { String s = t.image; return new Text(s.substring(2, s.length()-2)); } } Line _Line() : { Token t; } { { token_source.SwitchTo(1); } t= { return new Line(t.image); } } Word _Word() : { Token t; } { { token_source.SwitchTo(2); } t= { return new Word(t.image); } } // Lexical specification (largely taken from Java.jack): SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : { /* LITERALS */ < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? > | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ (["l","L"])? > | < OCTAL_LITERAL: "0" (["0"-"7"])* (["l","L"])? > | < FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])+ ()? (["f","F","d","D"])? | "." (["0"-"9"])+ ()? (["f","F","d","D"])? | (["0"-"9"])+ (["f","F","d","D"])? | (["0"-"9"])+ ()? ["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"] ) ) )* "\"" > | < TEXT_LITERAL: ( "(@" (~["@"])* ( "@" ~[")"] (~["@"])* )* "@)" ) | ( "{{" (~["}"])* ( "}" ~["}"] (~["}"])* )* "}}" ) > | < TRUE: "true" > | < FALSE: "false" > } TOKEN : { /* IDENTIFIERS */ < IDENTIFIER: (|)* > | < #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" ] > } TOKEN : { < LINE: (~["\n","\r"])* > : DEFAULT } SKIP : { " " | "\t" | "\n" | "\r" } TOKEN : { < WORD: (~[" ","\t","\n","\r"])* > : DEFAULT }