options { STATIC = false; JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(Parser) package edu.neu.ccs.demeter.aplib.sg; 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; } } CollectVisitor _CollectVisitor() : { CollectVisitor it = null; } { { it=new CollectVisitor(); } { return it; } } SelectorLanguage _SelectorLanguage() : { SelectorLanguage it = null; StrategyLanguage _strategylanguage; NodeSubsetLanguage _nodesubsetlanguage; } { { it=new SelectorLanguage(); } "strategies" _strategylanguage=_StrategyLanguage() { it.set_strategylanguage(_strategylanguage); } "node" "sets" _nodesubsetlanguage=_NodeSubsetLanguage() { it.set_nodesubsetlanguage(_nodesubsetlanguage); } { return it; } } StrategyLanguage _StrategyLanguage() : { StrategyLanguage it = null; StrategyDef_NPList _strategydef_nplist; } { { it=new StrategyLanguage(); } _strategydef_nplist=_StrategyDef_NPList() { it.set_strategydef_nplist(_strategydef_nplist); } { return it; } } StrategyDef _StrategyDef() : { StrategyDef it = null; StrategyName _strategyname; StrategyExpression _strategyexpression; } { { it=new StrategyDef(); } _strategyname=_StrategyName() { it.set_strategyname(_strategyname); } "=" _strategyexpression=_StrategyExpression() { it.set_strategyexpression(_strategyexpression); } ";" { return it; } } NodeSubsetLanguage _NodeSubsetLanguage() : { NodeSubsetLanguage it = null; NodeSubsetSpec_PList _nodesubsetspec_plist; } { { it=new NodeSubsetLanguage(); } _nodesubsetspec_plist=_NodeSubsetSpec_PList() { it.set_nodesubsetspec_plist(_nodesubsetspec_plist); } { return it; } } NodeSubsetSpec _NodeSubsetSpec() : { NodeSubsetSpec it = null; NodeSubsetName _nodesubsetname; NodeSubsetExpression _nodesubsetexpression; } { { it=new NodeSubsetSpec(); } _nodesubsetname=_NodeSubsetName() { it.set_nodesubsetname(_nodesubsetname); } "=" _nodesubsetexpression=_NodeSubsetExpression() { it.set_nodesubsetexpression(_nodesubsetexpression); } ";" { return it; } } NodeSubsetExpression _NodeSubsetExpression() : { NodeSubsetExpression it = null; } { ( it=_Simple() | it=_Compound() ) { return it; } } void common_NodeSubsetExpression(NodeSubsetExpression it) : { } { { } } Simple _Simple() : { Simple it = null; } { ( it=_NodeSubsetName() | it=_ClassNameSet() | it=_GraphNodes() | it=_GraphNodeRegExp() ) { return it; } } void common_Simple(Simple it) : { } { common_NodeSubsetExpression(it) { } } Compound _Compound() : { Compound it = null; Operator _op; NodeSubsetExpression_List _args; } { { it=new Compound(); } "(" _op=_Operator() { it.set_op(_op); } _args=_NodeSubsetExpression_List() { it.set_args(_args); } ")" common_NodeSubsetExpression(it) { return it; } } Operator _Operator() : { Operator it = null; } { ( it=_Union() | it=_Intersection() | it=_Complement() ) { return it; } } void common_Operator(Operator it) : { } { { } } Union _Union() : { Union it = null; } { { it=new Union(); } "||" common_Operator(it) { return it; } } Intersection _Intersection() : { Intersection it = null; } { { it=new Intersection(); } "&&" common_Operator(it) { return it; } } Complement _Complement() : { Complement it = null; } { { it=new Complement(); } "!" common_Operator(it) { return it; } } ClassNameSet _ClassNameSet() : { ClassNameSet it = null; ClassName_BCList _classname_bclist; } { { it=new ClassNameSet(); } _classname_bclist=_ClassName_BCList() { it.set_classname_bclist(_classname_bclist); } common_Simple(it) { return it; } } GraphNodes _GraphNodes() : { GraphNodes it = null; StrategyName _strategyname; } { { it=new GraphNodes(); } "(nodes" _strategyname=_StrategyName() { it.set_strategyname(_strategyname); } ")" common_Simple(it) { return it; } } GraphNodeRegExp _GraphNodeRegExp() : { GraphNodeRegExp it = null; ClassName _classname; WildCard _wildcard; } { { it=new GraphNodeRegExp(); } "(regexp" _classname=_ClassName() { it.set_classname(_classname); } _wildcard=_WildCard() { it.set_wildcard(_wildcard); } ")" common_Simple(it) { return it; } } WildCard _WildCard() : { WildCard it = null; } { { it=new WildCard(); } "*" { return it; } } StrategyExpression _StrategyExpression() : { StrategyExpression it = null; Strategy _strategy; } { { it=new StrategyExpression(); } _strategy=_Strategy() { it.set_strategy(_strategy); } { return it; } } Strategy _Strategy() : { Strategy it = null; } { ( it=_SimpleStrategy() | it=_StrategyCombination() | it=_StrategyReference() ) { return it; } } void common_Strategy(Strategy it) : { } { { } } SimpleStrategy _SimpleStrategy() : { SimpleStrategy it = null; } { ( it=_StrategyGraph() | it=_PathDirective() ) { return it; } } void common_SimpleStrategy(SimpleStrategy it) : { NameMap _parsedNameMap; } { [ "with" _parsedNameMap=_NameMap() { it.set_parsedNameMap(_parsedNameMap); } ] common_Strategy(it) { } } StrategyGraph _StrategyGraph() : { StrategyGraph it = null; SGEdge_SList _edges; } { { it=new StrategyGraph(); } "{" _edges=_SGEdge_SList() { it.set_edges(_edges); } "}" common_SimpleStrategy(it) { return it; } } SGEdge _SGEdge() : { SGEdge it = null; SourceMarker _sourcemarker; GlobSpec _source; TargetMarker _targetmarker; GlobSpec _target; NegativeConstraint _constraint; } { { it=new SGEdge(); } [ _sourcemarker=_SourceMarker() { it.set_sourcemarker(_sourcemarker); } ] _source=_GlobSpec() { it.set_source(_source); } "->" [ _targetmarker=_TargetMarker() { it.set_targetmarker(_targetmarker); } ] _target=_GlobSpec() { it.set_target(_target); } [ _constraint=_NegativeConstraint() { it.set_constraint(_constraint); } ] { return it; } } SourceMarker _SourceMarker() : { SourceMarker it = null; } { { it=new SourceMarker(); } "source:" { return it; } } TargetMarker _TargetMarker() : { TargetMarker it = null; } { { it=new TargetMarker(); } "target:" { return it; } } PathDirective _PathDirective() : { PathDirective it = null; SourceDirective _source; NegativeConstraint _constraint; PathSegment_List _segments; TargetDirective _target; } { { it=new PathDirective(); } _source=_SourceDirective() { it.set_source(_source); } [ _constraint=_NegativeConstraint() { it.set_constraint(_constraint); } ] _segments=_PathSegment_List() { it.set_segments(_segments); } _target=_TargetDirective() { it.set_target(_target); } common_SimpleStrategy(it) { return it; } } SourceDirective _SourceDirective() : { SourceDirective it = null; } { ( it=_From() ) { return it; } } void common_SourceDirective(SourceDirective it) : { ClassGlobSpec _sources; } { _sources=_ClassGlobSpec() { it.set_sources(_sources); } { } } From _From() : { From it = null; } { { it=new From(); } "from" common_SourceDirective(it) { return it; } } PathSegment _PathSegment() : { PathSegment it = null; PositiveConstraint _node; NegativeConstraint _constraint; } { { it=new PathSegment(); } _node=_PositiveConstraint() { it.set_node(_node); } [ _constraint=_NegativeConstraint() { it.set_constraint(_constraint); } ] { return it; } } Constraint _Constraint() : { Constraint it = null; } { ( it=_PositiveConstraint() | it=_NegativeConstraint() ) { return it; } } void common_Constraint(Constraint it) : { GlobSpec _glob; } { _glob=_GlobSpec() { it.set_glob(_glob); } { } } PositiveConstraint _PositiveConstraint() : { PositiveConstraint it = null; } { ( it=_Through() | it=_Via() ) { return it; } } void common_PositiveConstraint(PositiveConstraint it) : { } { common_Constraint(it) { } } Through _Through() : { Through it = null; } { { it=new Through(); } "through" common_PositiveConstraint(it) { return it; } } Via _Via() : { Via it = null; } { { it=new Via(); } "via" common_PositiveConstraint(it) { return it; } } NegativeConstraint _NegativeConstraint() : { NegativeConstraint it = null; } { ( it=_Bypassing() | it=_OnlyThrough() ) { return it; } } void common_NegativeConstraint(NegativeConstraint it) : { } { common_Constraint(it) { } } Bypassing _Bypassing() : { Bypassing it = null; } { { it=new Bypassing(); } "bypassing" common_NegativeConstraint(it) { return it; } } OnlyThrough _OnlyThrough() : { OnlyThrough it = null; } { { it=new OnlyThrough(); } "only-through" common_NegativeConstraint(it) { return it; } } TargetDirective _TargetDirective() : { TargetDirective it = null; } { ( it=_To() | it=_ToStop() ) { return it; } } void common_TargetDirective(TargetDirective it) : { ClassGlobSpec _targets; } { _targets=_ClassGlobSpec() { it.set_targets(_targets); } { } } To _To() : { To it = null; } { { it=new To(); } "to" common_TargetDirective(it) { return it; } } ToStop _ToStop() : { ToStop it = null; } { { it=new ToStop(); } "to-stop" common_TargetDirective(it) { return it; } } StrategyCombination _StrategyCombination() : { StrategyCombination it = null; } { ( it=_Join() | it=_Merge() | it=_Intersect() ) { return it; } } void common_StrategyCombination(StrategyCombination it) : { Strategy _first; Strategy_Commalist _rest; } { "(" _first=_Strategy() { it.set_first(_first); } "," _rest=_Strategy_Commalist() { it.set_rest(_rest); } ")" common_Strategy(it) { } } Join _Join() : { Join it = null; } { { it=new Join(); } "join" common_StrategyCombination(it) { return it; } } Merge _Merge() : { Merge it = null; } { { it=new Merge(); } "merge" common_StrategyCombination(it) { return it; } } Intersect _Intersect() : { Intersect it = null; } { { it=new Intersect(); } "intersect" common_StrategyCombination(it) { return it; } } StrategyReference _StrategyReference() : { StrategyReference it = null; Ident _ident; } { { it=new StrategyReference(); } _ident=_Ident() { it.set_ident(_ident); } common_Strategy(it) { return it; } } SymbolicNameMap _SymbolicNameMap() : { SymbolicNameMap it = null; } { ( it=_NameMap() ) { return it; } } void common_SymbolicNameMap(SymbolicNameMap it) : { } { { } } NameMap _NameMap() : { NameMap it = null; NameBinding_Commalist _bindings; } { { it=new NameMap(); } "{" [ _bindings=_NameBinding_Commalist() { it.set_bindings(_bindings); } ] "}" common_SymbolicNameMap(it) { return it; } } NameBinding _NameBinding() : { NameBinding it = null; Name _sgName; ClassGlobSpec _cgNames; } { { it=new NameBinding(); } _sgName=_Name() { it.set_sgName(_sgName); } "=" _cgNames=_ClassGlobSpec() { it.set_cgNames(_cgNames); } { return it; } } GlobSpec _GlobSpec() : { GlobSpec it = null; } { ( it=_OneGlob() | it=_GlobSet() ) { return it; } } void common_GlobSpec(GlobSpec it) : { } { { } } OneGlob _OneGlob() : { OneGlob it = null; Glob _glob; } { { it=new OneGlob(); } _glob=_Glob() { it.set_glob(_glob); } common_GlobSpec(it) { return it; } } GlobSet _GlobSet() : { GlobSet it = null; Glob_Commalist _globs; } { { it=new GlobSet(); } "{" [ _globs=_Glob_Commalist() { it.set_globs(_globs); } ] "}" common_GlobSpec(it) { return it; } } Glob _Glob() : { Glob it = null; } { ( it=_ClassGlob() | it=_EdgeGlob() ) { return it; } } void common_Glob(Glob it) : { } { { } } EdgeGlob _EdgeGlob() : { EdgeGlob it = null; } { ( it=_PartGlob() | it=_SubclassGlob() | it=_SuperclassGlob() ) { return it; } } void common_EdgeGlob(EdgeGlob it) : { } { common_Glob(it) { } } ClassGlob _ClassGlob() : { ClassGlob it = null; ClassNameGlob _name; } { { it=new ClassGlob(); } _name=_ClassNameGlob() { it.set_name(_name); } common_Glob(it) { return it; } } PartGlob _PartGlob() : { PartGlob it = null; SourceGlob _source; PartNameGlob _name; TargetGlob _target; } { { it=new PartGlob(); } "->" _source=_SourceGlob() { it.set_source(_source); } "," _name=_PartNameGlob() { it.set_name(_name); } "," _target=_TargetGlob() { it.set_target(_target); } common_EdgeGlob(it) { return it; } } SubclassGlob _SubclassGlob() : { SubclassGlob it = null; SourceGlob _source; TargetGlob _target; } { { it=new SubclassGlob(); } "=>" _source=_SourceGlob() { it.set_source(_source); } "," _target=_TargetGlob() { it.set_target(_target); } common_EdgeGlob(it) { return it; } } SuperclassGlob _SuperclassGlob() : { SuperclassGlob it = null; SourceGlob _source; TargetGlob _target; } { { it=new SuperclassGlob(); } ":>" _source=_SourceGlob() { it.set_source(_source); } "," _target=_TargetGlob() { it.set_target(_target); } common_EdgeGlob(it) { return it; } } SourceGlob _SourceGlob() : { SourceGlob it = null; ClassNameGlob _name; } { { it=new SourceGlob(); } _name=_ClassNameGlob() { it.set_name(_name); } { return it; } } TargetGlob _TargetGlob() : { TargetGlob it = null; ClassNameGlob _name; } { { it=new TargetGlob(); } _name=_ClassNameGlob() { it.set_name(_name); } { return it; } } ClassNameGlob _ClassNameGlob() : { ClassNameGlob it = null; } { ( it=_ClassNameExact() | it=_AnyClass() ) { return it; } } void common_ClassNameGlob(ClassNameGlob it) : { } { { } } ClassNameExact _ClassNameExact() : { ClassNameExact it = null; ClassName _classname; } { { it=new ClassNameExact(); } _classname=_ClassName() { it.set_classname(_classname); } common_ClassNameGlob(it) { return it; } } AnyClass _AnyClass() : { AnyClass it = null; } { { it=new AnyClass(); } "*" common_ClassNameGlob(it) { return it; } } PartNameGlob _PartNameGlob() : { PartNameGlob it = null; } { ( it=_PartNameExact() | it=_AnyPart() ) { return it; } } void common_PartNameGlob(PartNameGlob it) : { } { { } } PartNameExact _PartNameExact() : { PartNameExact it = null; PartName _partname; } { { it=new PartNameExact(); } _partname=_PartName() { it.set_partname(_partname); } common_PartNameGlob(it) { return it; } } AnyPart _AnyPart() : { AnyPart it = null; } { { it=new AnyPart(); } "*" common_PartNameGlob(it) { return it; } } ClassGlobSpec _ClassGlobSpec() : { ClassGlobSpec it = null; } { ( it=_OneClassGlob() | it=_ClassGlobSet() ) { return it; } } void common_ClassGlobSpec(ClassGlobSpec it) : { } { { } } OneClassGlob _OneClassGlob() : { OneClassGlob it = null; ClassGlob _classglob; } { { it=new OneClassGlob(); } _classglob=_ClassGlob() { it.set_classglob(_classglob); } common_ClassGlobSpec(it) { return it; } } ClassGlobSet _ClassGlobSet() : { ClassGlobSet it = null; ClassGlob_Commalist _globs; } { { it=new ClassGlobSet(); } "{" _globs=_ClassGlob_Commalist() { it.set_globs(_globs); } "}" common_ClassGlobSpec(it) { 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; Ident _name; } { { it=new PartName(); } _name=_Ident() { it.set_name(_name); } { return it; } } Name _Name() : { Name it = null; Nonempty_Name _first; } { { it=new Name(); } _first=_Nonempty_Name() { it.set_first(_first); } { return it; } } StrategyName _StrategyName() : { StrategyName it = null; Ident _name; } { { it=new StrategyName(); } _name=_Ident() { it.set_name(_name); } { return it; } } NodeSubsetName _NodeSubsetName() : { NodeSubsetName it = null; Ident _name; } { { it=new NodeSubsetName(); } _name=_Ident() { it.set_name(_name); } common_Simple(it) { return it; } } StrategyDef_NPList _StrategyDef_NPList() : { StrategyDef_NPList it = null; Nonempty_StrategyDef_NPList _first; } { { it=new StrategyDef_NPList(); } "(" _first=_Nonempty_StrategyDef_NPList() { it.set_first(_first); } ")" { return it; } } NodeSubsetSpec_PList _NodeSubsetSpec_PList() : { NodeSubsetSpec_PList it = null; Nonempty_NodeSubsetSpec_PList _first; } { { it=new NodeSubsetSpec_PList(); } "(" [ _first=_Nonempty_NodeSubsetSpec_PList() { it.set_first(_first); } ] ")" { return it; } } NodeSubsetExpression_List _NodeSubsetExpression_List() : { NodeSubsetExpression_List it = null; Nonempty_NodeSubsetExpression_List _first; } { { it=new NodeSubsetExpression_List(); } [ _first=_Nonempty_NodeSubsetExpression_List() { it.set_first(_first); } ] { return it; } } ClassName_BCList _ClassName_BCList() : { ClassName_BCList it = null; Nonempty_ClassName_BCList _first; } { { it=new ClassName_BCList(); } "{" _first=_Nonempty_ClassName_BCList() { it.set_first(_first); } "}" { return it; } } SGEdge_SList _SGEdge_SList() : { SGEdge_SList it = null; Nonempty_SGEdge_SList _first; } { { it=new SGEdge_SList(); } _first=_Nonempty_SGEdge_SList() { it.set_first(_first); } { return it; } } PathSegment_List _PathSegment_List() : { PathSegment_List it = null; Nonempty_PathSegment_List _first; } { { it=new PathSegment_List(); } [ _first=_Nonempty_PathSegment_List() { it.set_first(_first); } ] { return it; } } Strategy_Commalist _Strategy_Commalist() : { Strategy_Commalist it = null; Nonempty_Strategy_Commalist _first; } { { it=new Strategy_Commalist(); } _first=_Nonempty_Strategy_Commalist() { it.set_first(_first); } { return it; } } NameBinding_Commalist _NameBinding_Commalist() : { NameBinding_Commalist it = null; Nonempty_NameBinding_Commalist _first; } { { it=new NameBinding_Commalist(); } _first=_Nonempty_NameBinding_Commalist() { it.set_first(_first); } { return it; } } Glob_Commalist _Glob_Commalist() : { Glob_Commalist it = null; Nonempty_Glob_Commalist _first; } { { it=new Glob_Commalist(); } _first=_Nonempty_Glob_Commalist() { it.set_first(_first); } { return it; } } ClassGlob_Commalist _ClassGlob_Commalist() : { ClassGlob_Commalist it = null; Nonempty_ClassGlob_Commalist _first; } { { it=new ClassGlob_Commalist(); } _first=_Nonempty_ClassGlob_Commalist() { it.set_first(_first); } { return it; } } Nonempty_Name _Nonempty_Name() : { Nonempty_Name it = null; Ident _it; Nonempty_Name _next; } { { it=new Nonempty_Name(); } _it=_Ident() { it.set_it(_it); } [ "." _next=_Nonempty_Name() { it.set_next(_next); } ] { return it; } } Nonempty_StrategyDef_NPList _Nonempty_StrategyDef_NPList() : { Nonempty_StrategyDef_NPList it = null; StrategyDef _it; Nonempty_StrategyDef_NPList _next; } { { it=new Nonempty_StrategyDef_NPList(); } _it=_StrategyDef() { it.set_it(_it); } [ _next=_Nonempty_StrategyDef_NPList() { it.set_next(_next); } ] { return it; } } Nonempty_NodeSubsetSpec_PList _Nonempty_NodeSubsetSpec_PList() : { Nonempty_NodeSubsetSpec_PList it = null; NodeSubsetSpec _it; Nonempty_NodeSubsetSpec_PList _next; } { { it=new Nonempty_NodeSubsetSpec_PList(); } _it=_NodeSubsetSpec() { it.set_it(_it); } [ _next=_Nonempty_NodeSubsetSpec_PList() { it.set_next(_next); } ] { return it; } } Nonempty_NodeSubsetExpression_List _Nonempty_NodeSubsetExpression_List() : { Nonempty_NodeSubsetExpression_List it = null; NodeSubsetExpression _it; Nonempty_NodeSubsetExpression_List _next; } { { it=new Nonempty_NodeSubsetExpression_List(); } _it=_NodeSubsetExpression() { it.set_it(_it); } [ _next=_Nonempty_NodeSubsetExpression_List() { it.set_next(_next); } ] { return it; } } Nonempty_ClassName_BCList _Nonempty_ClassName_BCList() : { Nonempty_ClassName_BCList it = null; ClassName _it; Nonempty_ClassName_BCList _next; } { { it=new Nonempty_ClassName_BCList(); } _it=_ClassName() { it.set_it(_it); } [ "," _next=_Nonempty_ClassName_BCList() { it.set_next(_next); } ] { return it; } } Nonempty_SGEdge_SList _Nonempty_SGEdge_SList() : { Nonempty_SGEdge_SList it = null; SGEdge _it; Nonempty_SGEdge_SList _next; } { { it=new Nonempty_SGEdge_SList(); } _it=_SGEdge() { it.set_it(_it); } [ _next=_Nonempty_SGEdge_SList() { it.set_next(_next); } ] { return it; } } Nonempty_PathSegment_List _Nonempty_PathSegment_List() : { Nonempty_PathSegment_List it = null; PathSegment _it; Nonempty_PathSegment_List _next; } { { it=new Nonempty_PathSegment_List(); } _it=_PathSegment() { it.set_it(_it); } [ _next=_Nonempty_PathSegment_List() { it.set_next(_next); } ] { return it; } } Nonempty_Strategy_Commalist _Nonempty_Strategy_Commalist() : { Nonempty_Strategy_Commalist it = null; Strategy _it; Nonempty_Strategy_Commalist _next; } { { it=new Nonempty_Strategy_Commalist(); } _it=_Strategy() { it.set_it(_it); } [ "," _next=_Nonempty_Strategy_Commalist() { it.set_next(_next); } ] { return it; } } Nonempty_NameBinding_Commalist _Nonempty_NameBinding_Commalist() : { Nonempty_NameBinding_Commalist it = null; NameBinding _it; Nonempty_NameBinding_Commalist _next; } { { it=new Nonempty_NameBinding_Commalist(); } _it=_NameBinding() { it.set_it(_it); } [ "," _next=_Nonempty_NameBinding_Commalist() { it.set_next(_next); } ] { return it; } } Nonempty_Glob_Commalist _Nonempty_Glob_Commalist() : { Nonempty_Glob_Commalist it = null; Glob _it; Nonempty_Glob_Commalist _next; } { { it=new Nonempty_Glob_Commalist(); } _it=_Glob() { it.set_it(_it); } [ "," _next=_Nonempty_Glob_Commalist() { it.set_next(_next); } ] { return it; } } Nonempty_ClassGlob_Commalist _Nonempty_ClassGlob_Commalist() : { Nonempty_ClassGlob_Commalist it = null; ClassGlob _it; Nonempty_ClassGlob_Commalist _next; } { { it=new Nonempty_ClassGlob_Commalist(); } _it=_ClassGlob() { it.set_it(_it); } [ "," _next=_Nonempty_ClassGlob_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 }