1 // $ANTLR 2.7.5 (20050128): "lang4.g" -> "RookBaseParser.cs"$
4 using System
.Collections
;
6 using Castle
.Rook
.Compiler
.AST
;
7 using Castle
.Rook
.Compiler
.Services
;
9 namespace Castle
.Rook
.Compiler
.Parser
11 // Generate the header common to all output files.
14 using TokenBuffer
= antlr
.TokenBuffer
;
15 using TokenStreamException
= antlr
.TokenStreamException
;
16 using TokenStreamIOException
= antlr
.TokenStreamIOException
;
17 using ANTLRException
= antlr
.ANTLRException
;
18 using LLkParser
= antlr
.LLkParser
;
19 using Token
= antlr
.Token
;
20 using IToken
= antlr
.IToken
;
21 using TokenStream
= antlr
.TokenStream
;
22 using RecognitionException
= antlr
.RecognitionException
;
23 using NoViableAltException
= antlr
.NoViableAltException
;
24 using MismatchedTokenException
= antlr
.MismatchedTokenException
;
25 using SemanticException
= antlr
.SemanticException
;
26 using ParserSharedInputState
= antlr
.ParserSharedInputState
;
27 using BitSet
= antlr
.collections
.impl
.BitSet
;
29 public class RookBaseParser
: antlr
.LLkParser
31 public const int EOF
= 1;
32 public const int NULL_TREE_LOOKAHEAD
= 3;
33 public const int CLASS
= 4;
34 public const int DO
= 5;
35 public const int END
= 6;
36 public const int DEF
= 7;
37 public const int OPERATOR
= 8;
38 public const int BEGIN
= 9;
39 public const int WHILE
= 10;
40 public const int TYPE
= 11;
41 public const int METHOD_CALL
= 12;
42 public const int SUPER_CTOR_CALL
= 13;
43 public const int POST_INC
= 14;
44 public const int POST_DEC
= 15;
45 public const int EXPR
= 16;
46 public const int ELIST
= 17;
47 public const int INDEX_OP
= 18;
48 public const int UNARY_MINUS
= 19;
49 public const int UNARY_PLUS
= 20;
50 public const int TYPECAST
= 21;
51 public const int ARRAY_DECLARATOR
= 22;
52 public const int NUM_INT
= 23;
53 public const int NUM_DOUBLE
= 24;
54 public const int NUM_FLOAT
= 25;
55 public const int NUM_LONG
= 26;
56 public const int STATEMENT_END
= 27;
57 public const int IDENT
= 28;
58 public const int DOT
= 29;
59 public const int COLONCOLON
= 30;
60 public const int COLON
= 31;
61 public const int STATICIDENT
= 32;
62 public const int INSTIDENT
= 33;
63 public const int SEMI
= 34;
64 public const int LITERAL_namespace
= 35;
65 public const int SL
= 36;
66 public const int LITERAL_self
= 37;
67 public const int LITERAL_override
= 38;
68 public const int LITERAL_abstract
= 39;
69 public const int LITERAL_new
= 40;
70 public const int LITERAL_final
= 41;
71 public const int LITERAL_public
= 42;
72 public const int LITERAL_private
= 43;
73 public const int LITERAL_protected
= 44;
74 public const int LITERAL_internal
= 45;
75 public const int COMMA
= 46;
76 public const int ASSIGN
= 47;
77 public const int LITERAL_initialize
= 48;
78 public const int LPAREN
= 49;
79 public const int RPAREN
= 50;
80 public const int LITERAL_require
= 51;
81 public const int LTHAN
= 52;
82 public const int STAR
= 53;
83 public const int BAND
= 54;
84 public const int PLUS_ASSIGN
= 55;
85 public const int MINUS_ASSIGN
= 56;
86 public const int STAR_ASSIGN
= 57;
87 public const int DIV_ASSIGN
= 58;
88 public const int MOD_ASSIGN
= 59;
89 public const int BAND_ASSIGN
= 60;
90 public const int BOR_ASSIGN
= 61;
91 public const int BXOR_ASSIGN
= 62;
92 public const int LITERAL_if
= 63;
93 public const int LITERAL_unless
= 64;
94 public const int LITERAL_until
= 65;
95 public const int LITERAL_redo
= 66;
96 public const int LITERAL_break
= 67;
97 public const int LITERAL_next
= 68;
98 public const int LITERAL_retry
= 69;
99 public const int LITERAL_lambda
= 70;
100 public const int LCURLY
= 71;
101 public const int RCURLY
= 72;
102 public const int LITERAL_raise
= 73;
103 public const int LITERAL_yield
= 74;
104 public const int BOR
= 75;
105 public const int LITERAL_or
= 76;
106 public const int LITERAL_and
= 77;
107 public const int LITERAL_not
= 78;
108 public const int LNOT
= 79;
109 public const int GT
= 80;
110 public const int EQUAL
= 81;
111 public const int GE
= 82;
112 public const int LE
= 83;
113 public const int NOT_EQUAL
= 84;
114 public const int LITERAL_is
= 85;
115 public const int BXOR
= 86;
116 public const int PLUS
= 87;
117 public const int MINUS
= 88;
118 public const int SLASH
= 89;
119 public const int PERCENT
= 90;
120 public const int BNOT
= 91;
121 public const int LBRACK
= 92;
122 public const int RBRACK
= 93;
123 public const int LITERAL_base
= 94;
124 public const int STRING_LITERAL
= 95;
125 public const int CHAR_LITERAL
= 96;
127 public const int DOTDOT
= 98;
128 public const int DOTDOTDOT
= 99;
129 public const int MAPASSIGN
= 100;
130 public const int QUESTION
= 101;
131 public const int DIV
= 102;
132 public const int INC
= 103;
133 public const int DEC
= 104;
134 public const int MOD
= 105;
135 public const int SR
= 106;
136 public const int SR_ASSIGN
= 107;
137 public const int BSR
= 108;
138 public const int BSR_ASSIGN
= 109;
139 public const int SL_ASSIGN
= 110;
140 public const int LOR
= 111;
141 public const int LAND
= 112;
142 public const int NEWLINE
= 113;
143 public const int SL_NEWLINE
= 114;
144 public const int SL_COMMENT
= 115;
145 public const int WS
= 116;
146 public const int ESC
= 117;
147 public const int HEX_DIGIT
= 118;
148 public const int VOCAB
= 119;
149 public const int NUMBER
= 120;
150 public const int Int
= 121;
151 public const int NonZeroDigit
= 122;
152 public const int FloatTrailer
= 123;
153 public const int Exponent
= 124;
154 public const int CONTINUED_LINE
= 125;
157 public IErrorReport ErrorReport
;
159 private bool withinStatic
, withinFinal
, withinAbstract
, withinNew
, withinOverride
;
161 private ISymbolTable topLevelScope
;
163 AccessLevel currentAccessLevel
= AccessLevel
.Public
;
165 public override void reportError(RecognitionException ex
)
167 LexicalPosition lpos
= new LexicalPosition( ex
.getLine(), ex
.getColumn() );
169 ErrorReport
.Error( ex
.getFilename(), lpos
, ex
.Message
);
172 // TODO: Research for a better way to set lexical information
174 private void SetLexical(IASTNode node
, IToken t
)
176 node
.Position
.Line
= t
.getLine();
177 node
.Position
.Column
= t
.getColumn();
180 private Stack scopes
= new Stack();
182 private void PushScope(IASTNode node
, ScopeType scopeType
)
184 if (node
.DefiningSymbolTable
!= null)
186 throw new ArgumentException("We can't override a scope");
189 node
.DefiningSymbolTable
= new SymbolTable( GetCurrentScope(), scopeType
);
191 ISymbolTable scope
= node
.DefiningSymbolTable
;
193 if (scope
== null) throw new ArgumentNullException("null scope?");
198 private void PopScope()
203 private ISymbolTable
GetCurrentScope()
205 if (scopes
.Count
== 0) return topLevelScope
;
207 return scopes
.Peek() as ISymbolTable
;
210 protected void initialize()
212 tokenNames
= tokenNames_
;
216 protected RookBaseParser(TokenBuffer tokenBuf
, int k
) : base(tokenBuf
, k
)
221 public RookBaseParser(TokenBuffer tokenBuf
) : this(tokenBuf
,2)
225 protected RookBaseParser(TokenStream lexer
, int k
) : base(lexer
,k
)
230 public RookBaseParser(TokenStream lexer
) : this(lexer
,2)
234 public RookBaseParser(ParserSharedInputState state
) : base(state
,2)
239 public String
qualified_name() //throws RecognitionException, TokenStreamException
245 String name
= String
.Empty
; ident
= null;
249 if (0==inputState
.guessing
)
256 if ((LA(1)==DOT
||LA(1)==COLONCOLON
))
264 if (0==inputState
.guessing
)
273 if (0==inputState
.guessing
)
281 throw new NoViableAltException(LT(1), getFilename());
287 if (0==inputState
.guessing
)
289 name
+= t2
.getText();
294 goto _loop4_breakloop
;
300 if (0==inputState
.guessing
)
307 public Identifier
identifier() //throws RecognitionException, TokenStreamException
311 ident
= null; TypeReference tr
= null;
320 if (0==inputState
.guessing
)
322 ident
.TypeReference
= tr
;
335 throw new NoViableAltException(LT(1), getFilename());
342 public Identifier
name() //throws RecognitionException, TokenStreamException
357 if (0==inputState
.guessing
)
359 ident
= new OpaqueIdentifier(t1
.getText());
367 if (0==inputState
.guessing
)
369 ident
= new StaticVarIdentifier(t2
.getText());
377 if (0==inputState
.guessing
)
379 ident
= new InstanceVarIdentifier(t3
.getText());
385 throw new NoViableAltException(LT(1), getFilename());
391 public TypeReference
type() //throws RecognitionException, TokenStreamException
399 if (0==inputState
.guessing
)
402 tr
= new TypeReference(n
);
408 public Identifier
identifier_withtype() //throws RecognitionException, TokenStreamException
412 ident
= null; TypeReference tr
= null;
416 if (0==inputState
.guessing
)
418 ident
.TypeReference
= tr
;
423 protected void statement_term() //throws RecognitionException, TokenStreamException
433 match(STATEMENT_END
);
443 match(Token
.EOF_TYPE
);
448 throw new NoViableAltException(LT(1), getFilename());
455 protected void nothing() //throws RecognitionException, TokenStreamException
460 if ((LA(1)==EOF
||LA(1)==STATEMENT_END
) && (tokenSet_0_
.member(LA(2))))
467 match(STATEMENT_END
);
472 match(Token
.EOF_TYPE
);
477 throw new NoViableAltException(LT(1), getFilename());
482 else if ((tokenSet_0_
.member(LA(1))) && (tokenSet_1_
.member(LA(2)))) {
486 throw new NoViableAltException(LT(1), getFilename());
492 public SourceUnit
sourceUnit(
493 CompilationUnit cunit
494 ) //throws RecognitionException, TokenStreamException
499 topLevelScope
= cunit
.DefiningSymbolTable
;
500 unit
= new SourceUnit(cunit
, getFilename());
501 PushScope(unit
, ScopeType
.SourceUnit
);
508 case LITERAL_namespace
:
510 namespace_declaration(unit
.Namespaces
);
527 case LITERAL_require
:
546 suite(unit
.Statements
);
551 throw new NoViableAltException(LT(1), getFilename());
556 match(Token
.EOF_TYPE
);
557 if (0==inputState
.guessing
)
560 cunit
.SourceUnits
.Add(unit
);
562 if (!ErrorReport
.HasErrors
&& scopes
.Count
!= 0)
563 ErrorReport
.Error("Invalid scope count. " +
564 "Something seems to be very wrong. Contact Castle's team and report the " +
565 "code that caused this error.");
571 public void namespace_declaration(
573 ) //throws RecognitionException, TokenStreamException
578 NamespaceDescriptor nsdec
= new NamespaceDescriptor();
579 PushScope(nsdec
, ScopeType
.Namespace
);
580 namespaces
.Add(nsdec
); String qn
= null;
581 TypeDefinitionStatement typeDef
= null;
584 try { // for error handling
586 match(LITERAL_namespace
);
589 if (0==inputState
.guessing
)
598 typeDef
=type_def_statement();
599 if (0==inputState
.guessing
)
601 nsdec
.TypeDefinitions
.Add(typeDef
);
606 goto _loop22_breakloop
;
613 if (0==inputState
.guessing
)
618 catch (RecognitionException ex
)
620 if (0 == inputState
.guessing
)
623 recover(ex
,tokenSet_2_
);
634 ) //throws RecognitionException, TokenStreamException
637 IStatement stmt
= null;
642 if ((tokenSet_3_
.member(LA(1))))
645 if (0==inputState
.guessing
)
647 if (stmt
!= null) stmts
.Add(stmt
);
652 goto _loop25_breakloop
;
660 public TypeDefinitionStatement
type_def_statement() //throws RecognitionException, TokenStreamException
662 TypeDefinitionStatement tdstmt
;
664 tdstmt
= null; currentAccessLevel
= AccessLevel
.Public
;
666 tdstmt
=class_def_statement();
670 public IStatement
statement() //throws RecognitionException, TokenStreamException
681 stmt
=type_def_statement();
684 case LITERAL_require
:
686 stmt
=require_statement();
690 bool synPredMatched39
= false;
691 if (((tokenSet_4_
.member(LA(1))) && (LA(2)==COLON
)))
694 synPredMatched39
= true;
695 inputState
.guessing
++;
698 declaration_statement();
701 catch (RecognitionException
)
703 synPredMatched39
= false;
706 inputState
.guessing
--;
708 if ( synPredMatched39
)
710 stmt
=declaration_statement();
712 else if ((tokenSet_5_
.member(LA(1))) && (tokenSet_6_
.member(LA(2)))) {
713 stmt
=expression_statement();
717 throw new NoViableAltException(LT(1), getFilename());
725 public void type_suite(
727 ) //throws RecognitionException, TokenStreamException
730 IStatement stmt
= null;
735 if ((tokenSet_7_
.member(LA(1))))
739 if ((tokenSet_3_
.member(LA(1))) && (tokenSet_8_
.member(LA(2))))
742 if (0==inputState
.guessing
)
744 if (stmt
!= null) stmts
.Add(stmt
);
747 else if ((LA(1)==CLASS
) && (LA(2)==SL
)) {
752 throw new NoViableAltException(LT(1), getFilename());
759 goto _loop29_breakloop
;
767 protected void access_level() //throws RecognitionException, TokenStreamException
776 match(LITERAL_public
);
777 if (0==inputState
.guessing
)
779 currentAccessLevel
= AccessLevel
.Public
;
783 case LITERAL_private
:
785 match(LITERAL_private
);
786 if (0==inputState
.guessing
)
788 currentAccessLevel
= AccessLevel
.Private
;
792 case LITERAL_protected
:
794 match(LITERAL_protected
);
795 if (0==inputState
.guessing
)
797 currentAccessLevel
= AccessLevel
.Protected
;
801 case LITERAL_internal
:
803 match(LITERAL_internal
);
804 if (0==inputState
.guessing
)
806 currentAccessLevel
= AccessLevel
.Internal
;
822 case LITERAL_require
:
845 throw new NoViableAltException(LT(1), getFilename());
851 protected void method_scope(
853 ) //throws RecognitionException, TokenStreamException
856 IStatement stmt
= null; int index
=0;
866 if (0==inputState
.guessing
)
872 case LITERAL_override
:
874 match(LITERAL_override
);
875 if (0==inputState
.guessing
)
877 index
= 1; withinOverride
= true;
881 case LITERAL_abstract
:
883 match(LITERAL_abstract
);
884 if (0==inputState
.guessing
)
886 index
= 2; withinAbstract
= true;
893 if (0==inputState
.guessing
)
895 index
= 3; withinNew
= true;
901 match(LITERAL_final
);
902 if (0==inputState
.guessing
)
904 index
= 4; withinFinal
= true;
910 throw new NoViableAltException(LT(1), getFilename());
918 if ((tokenSet_7_
.member(LA(1))))
922 if (0==inputState
.guessing
)
924 if (stmt
!= null) stmts
.Add(stmt
);
929 goto _loop33_breakloop
;
937 if (0==inputState
.guessing
)
941 withinStatic
= false;
943 withinOverride
= false;
945 withinAbstract
= false;
954 public MultipleVariableDeclarationStatement
declaration_statement() //throws RecognitionException, TokenStreamException
956 MultipleVariableDeclarationStatement stmt
;
959 stmt
= new MultipleVariableDeclarationStatement(currentAccessLevel
);
960 Identifier ident
= null;
961 IExpression initExp
= null;
964 ident
=identifier_withtype();
965 if (0==inputState
.guessing
)
967 stmt
.AddIdentifier(ident
);
975 ident
=identifier_withtype();
976 if (0==inputState
.guessing
)
978 stmt
.AddIdentifier(ident
);
983 goto _loop42_breakloop
;
996 if (0==inputState
.guessing
)
998 stmt
.AddInitExp(initExp
);
1007 if (0==inputState
.guessing
)
1009 stmt
.AddInitExp(initExp
);
1014 goto _loop45_breakloop
;
1018 _loop45_breakloop: ;
1030 throw new NoViableAltException(LT(1), getFilename());
1037 public IStatement
expression_statement() //throws RecognitionException, TokenStreamException
1041 stmt
= null; PostfixCondition pfc
= null; IExpression exp
= null; IExpression rhs
= null;
1042 AugType rel
= AugType
.Undefined
;
1044 if ((tokenSet_9_
.member(LA(1))))
1063 case LITERAL_lambda
:
1074 case STRING_LITERAL
:
1092 if (0==inputState
.guessing
)
1094 exp
= new AugAssignmentExpression(exp
, rhs
, rel
);
1104 if ((LA(1)==ASSIGN
))
1108 if (0==inputState
.guessing
)
1110 exp
= new AssignmentExpression(exp
, rhs
);
1115 if (_cnt75
>= 1) { goto _loop75_breakloop; }
else { throw new NoViableAltException(LT(1), getFilename());; }
1120 _loop75_breakloop: ;
1129 case LITERAL_unless
:
1136 throw new NoViableAltException(LT(1), getFilename());
1147 exp
=flow_expressions();
1152 throw new NoViableAltException(LT(1), getFilename());
1161 case LITERAL_unless
:
1164 pfc
=postFixCondition();
1165 if (0==inputState
.guessing
)
1167 exp
.PostfixCondition
= pfc
;
1179 throw new NoViableAltException(LT(1), getFilename());
1183 if (0==inputState
.guessing
)
1185 stmt
= new ExpressionStatement(exp
);
1188 else if ((LA(1)==DEF
) && (tokenSet_10_
.member(LA(2)))) {
1189 stmt
=method_def_statement();
1191 else if ((LA(1)==DEF
) && (LA(2)==LITERAL_initialize
)) {
1192 stmt
=constructor_def_statement();
1196 throw new NoViableAltException(LT(1), getFilename());
1202 public RequireDirectiveStatement
require_statement() //throws RecognitionException, TokenStreamException
1204 RequireDirectiveStatement rd
;
1206 rd
= null; String ident
= null;
1208 match(LITERAL_require
);
1209 ident
=qualified_name();
1210 if (0==inputState
.guessing
)
1212 rd
= new RequireDirectiveStatement(ident
);
1217 public IExpression
test() //throws RecognitionException, TokenStreamException
1221 exp
= null; IExpression rhs
= null;
1241 case STRING_LITERAL
:
1248 if ((LA(1)==LITERAL_or
))
1252 if (0==inputState
.guessing
)
1254 exp
= new BinaryExpression(exp
, rhs
, BinaryOp
.Or
);
1259 goto _loop100_breakloop
;
1263 _loop100_breakloop: ;
1267 case LITERAL_lambda
:
1284 throw new NoViableAltException(LT(1), getFilename());
1290 public ConstructorDefinitionStatement
constructor_def_statement() //throws RecognitionException, TokenStreamException
1292 ConstructorDefinitionStatement mdstmt
;
1295 mdstmt
= new ConstructorDefinitionStatement( currentAccessLevel
);
1299 match(LITERAL_initialize
);
1315 methodParams(mdstmt
);
1324 throw new NoViableAltException(LT(1), getFilename());
1339 throw new NoViableAltException(LT(1), getFilename());
1344 suite(mdstmt
.Statements
);
1349 public void methodParams(
1350 MethodDefinitionStatement mdstmt
1351 ) //throws RecognitionException, TokenStreamException
1354 ParameterVarIdentifier param
= null;
1356 param
=methodParam();
1357 if (0==inputState
.guessing
)
1359 mdstmt
.AddFormalParameter( param
);
1367 param
=methodParam();
1368 if (0==inputState
.guessing
)
1370 mdstmt
.AddFormalParameter( param
);
1375 goto _loop63_breakloop
;
1379 _loop63_breakloop: ;
1383 public MethodDefinitionStatement
method_def_statement() //throws RecognitionException, TokenStreamException
1385 MethodDefinitionStatement mdstmt
;
1388 mdstmt
= new MethodDefinitionStatement( currentAccessLevel
);
1389 String qn
= null; TypeReference retType
= null;
1394 qn
=qualified_name();
1395 if (0==inputState
.guessing
)
1398 if (qn
.StartsWith("self."))
1400 mdstmt
.IsStatic
= true;
1401 mdstmt
.Name
= qn
.Substring( "self.".Length
);
1407 PushScope(mdstmt
, ScopeType
.Method
);
1425 methodParams(mdstmt
);
1434 throw new NoViableAltException(LT(1), getFilename());
1455 throw new NoViableAltException(LT(1), getFilename());
1469 throw new NoViableAltException(LT(1), getFilename());
1474 if (0==inputState
.guessing
)
1476 mdstmt
.ReturnType
= retType
;
1478 suite(mdstmt
.Statements
);
1480 if (0==inputState
.guessing
)
1487 protected void modifier(
1488 MethodDefinitionStatement mdstmt
1489 ) //throws RecognitionException, TokenStreamException
1495 case LITERAL_override
:
1497 match(LITERAL_override
);
1498 if (0==inputState
.guessing
)
1500 mdstmt
.IsOverride
= true;
1507 if (0==inputState
.guessing
)
1509 mdstmt
.IsNewSlot
= true;
1513 case LITERAL_abstract
:
1515 match(LITERAL_abstract
);
1516 if (0==inputState
.guessing
)
1518 mdstmt
.IsAbstract
= true;
1524 match(LITERAL_final
);
1525 if (0==inputState
.guessing
)
1527 mdstmt
.IsFinal
= true;
1532 if (((LA(1)==IDENT
) && (tokenSet_11_
.member(LA(2))))&&( withinOverride
))
1534 if (0==inputState
.guessing
)
1536 mdstmt
.IsOverride
= true;
1539 else if (((LA(1)==IDENT
) && (tokenSet_11_
.member(LA(2))))&&( withinNew
)) {
1540 if (0==inputState
.guessing
)
1542 mdstmt
.IsNewSlot
= true;
1545 else if (((LA(1)==IDENT
) && (tokenSet_11_
.member(LA(2))))&&( withinAbstract
)) {
1546 if (0==inputState
.guessing
)
1548 mdstmt
.IsAbstract
= true;
1551 else if (((LA(1)==IDENT
) && (tokenSet_11_
.member(LA(2))))&&( withinFinal
)) {
1552 if (0==inputState
.guessing
)
1554 mdstmt
.IsFinal
= true;
1557 else if (((LA(1)==IDENT
) && (tokenSet_11_
.member(LA(2))))&&( withinStatic
)) {
1558 if (0==inputState
.guessing
)
1560 mdstmt
.IsStatic
= true;
1563 else if ((LA(1)==IDENT
) && (tokenSet_11_
.member(LA(2)))) {
1567 throw new NoViableAltException(LT(1), getFilename());
1572 public TypeDefinitionStatement
class_def_statement() //throws RecognitionException, TokenStreamException
1574 TypeDefinitionStatement tdstmt
;
1577 tdstmt
= null; String qn
= null;
1582 if (0==inputState
.guessing
)
1584 tdstmt
= new TypeDefinitionStatement( currentAccessLevel
, t
.getText() );
1585 PushScope(tdstmt
, ScopeType
.Type
);
1609 throw new NoViableAltException(LT(1), getFilename());
1613 qn
=qualified_name();
1614 if (0==inputState
.guessing
)
1616 tdstmt
.BaseTypes
.Add( new TypeReference(qn
) );
1624 qn
=qualified_name();
1625 if (0==inputState
.guessing
)
1627 tdstmt
.BaseTypes
.Add( new TypeReference(qn
) );
1632 goto _loop60_breakloop
;
1636 _loop60_breakloop: ;
1648 throw new NoViableAltException(LT(1), getFilename());
1653 type_suite(tdstmt
.Statements
);
1655 if (0==inputState
.guessing
)
1662 public ParameterVarIdentifier
methodParam() //throws RecognitionException, TokenStreamException
1664 ParameterVarIdentifier param
;
1666 IExpression exp
= null; Identifier ident
= null; param
= null;
1676 if (0==inputState
.guessing
)
1678 param
= ParameterVarIdentifier
.FromIdentifier(ParameterType
.Ordinary
, ident
);
1686 if (0==inputState
.guessing
)
1688 param
= ParameterVarIdentifier
.FromIdentifier(ParameterType
.Block
, ident
);
1693 bool synPredMatched67
= false;
1694 if (((LA(1)==STAR
) && (tokenSet_4_
.member(LA(2)))))
1697 synPredMatched67
= true;
1698 inputState
.guessing
++;
1702 identifier_withtype();
1705 catch (RecognitionException
)
1707 synPredMatched67
= false;
1710 inputState
.guessing
--;
1712 if ( synPredMatched67
)
1715 ident
=identifier_withtype();
1716 if (0==inputState
.guessing
)
1718 param
= ParameterVarIdentifier
.FromIdentifier(ParameterType
.Params
, ident
);
1721 else if ((LA(1)==STAR
) && (tokenSet_4_
.member(LA(2)))) {
1724 if (0==inputState
.guessing
)
1726 param
= ParameterVarIdentifier
.FromIdentifier(ParameterType
.List
, ident
);
1731 throw new NoViableAltException(LT(1), getFilename());
1742 if (0==inputState
.guessing
)
1744 param
.InitExpression
= exp
;
1756 throw new NoViableAltException(LT(1), getFilename());
1763 public IExpression
expression() //throws RecognitionException, TokenStreamException
1767 exp
= null; IExpression rhs
= null;
1777 if (0==inputState
.guessing
)
1779 exp
= new BinaryExpression(exp
, rhs
, BinaryOp
.Xor
);
1784 goto _loop115_breakloop
;
1788 _loop115_breakloop: ;
1793 public CompoundExpression
compound() //throws RecognitionException, TokenStreamException
1795 CompoundExpression cexp
;
1797 cexp
= new CompoundExpression();
1814 throw new NoViableAltException(LT(1), getFilename());
1818 if (0==inputState
.guessing
)
1820 PushScope(cexp
, ScopeType
.Compound
);
1823 suite(cexp
.Statements
);
1825 if (0==inputState
.guessing
)
1832 public AugType
augassign() //throws RecognitionException, TokenStreamException
1836 rel
= AugType
.Undefined
;
1843 if (0==inputState
.guessing
)
1845 rel
= AugType
.PlusAssign
;
1851 match(MINUS_ASSIGN
);
1852 if (0==inputState
.guessing
)
1854 rel
= AugType
.MinusAssign
;
1861 if (0==inputState
.guessing
)
1863 rel
= AugType
.MultAssign
;
1870 if (0==inputState
.guessing
)
1872 rel
= AugType
.DivAssign
;
1879 if (0==inputState
.guessing
)
1881 rel
= AugType
.ModAssign
;
1888 if (0==inputState
.guessing
)
1890 rel
= AugType
.BitwiseAndAssign
;
1897 if (0==inputState
.guessing
)
1899 rel
= AugType
.BitwiseOrAssign
;
1906 if (0==inputState
.guessing
)
1908 rel
= AugType
.BitwiseXorAssign
;
1914 throw new NoViableAltException(LT(1), getFilename());
1920 public IExpression
flow_expressions() //throws RecognitionException, TokenStreamException
1930 match(LITERAL_redo
);
1931 if (0==inputState
.guessing
)
1933 exp
= new RedoExpression();
1939 match(LITERAL_break
);
1940 if (0==inputState
.guessing
)
1942 exp
= new BreakExpression();
1948 match(LITERAL_next
);
1949 if (0==inputState
.guessing
)
1951 exp
= new NextExpression();
1957 match(LITERAL_retry
);
1958 if (0==inputState
.guessing
)
1960 exp
= new RetryExpression();
1966 throw new NoViableAltException(LT(1), getFilename());
1972 public PostfixCondition
postFixCondition() //throws RecognitionException, TokenStreamException
1974 PostfixCondition pfc
;
1976 pfc
= null; IExpression exp
;
1985 if (0==inputState
.guessing
)
1987 pfc
= new PostfixCondition(PostfixConditionType
.If
);
1991 case LITERAL_unless
:
1993 match(LITERAL_unless
);
1994 if (0==inputState
.guessing
)
1996 pfc
= new PostfixCondition(PostfixConditionType
.Unless
);
2003 if (0==inputState
.guessing
)
2005 pfc
= new PostfixCondition(PostfixConditionType
.While
);
2011 match(LITERAL_until
);
2012 if (0==inputState
.guessing
)
2014 pfc
= new PostfixCondition(PostfixConditionType
.Until
);
2020 throw new NoViableAltException(LT(1), getFilename());
2025 if (0==inputState
.guessing
)
2027 pfc
.Condition
= exp
;
2033 public LambdaExpression
lambda() //throws RecognitionException, TokenStreamException
2035 LambdaExpression lexp
;
2037 BlockExpression bexp
=null; lexp
= null;
2039 match(LITERAL_lambda
);
2041 if (0==inputState
.guessing
)
2043 lexp
= new LambdaExpression(bexp
);
2048 public BlockExpression
block() //throws RecognitionException, TokenStreamException
2050 BlockExpression bexp
;
2052 bexp
= new BlockExpression();
2054 if (0==inputState
.guessing
)
2056 PushScope(bexp
, ScopeType
.Block
);
2090 case LITERAL_require
:
2095 case LITERAL_lambda
:
2106 case STRING_LITERAL
:
2113 throw new NoViableAltException(LT(1), getFilename());
2140 case LITERAL_require
:
2145 case LITERAL_lambda
:
2156 case STRING_LITERAL
:
2163 throw new NoViableAltException(LT(1), getFilename());
2167 suite(bexp
.Statements
);
2200 case LITERAL_require
:
2205 case LITERAL_lambda
:
2217 case STRING_LITERAL
:
2224 throw new NoViableAltException(LT(1), getFilename());
2250 case LITERAL_require
:
2255 case LITERAL_lambda
:
2267 case STRING_LITERAL
:
2274 throw new NoViableAltException(LT(1), getFilename());
2278 suite(bexp
.Statements
);
2285 throw new NoViableAltException(LT(1), getFilename());
2289 if (0==inputState
.guessing
)
2296 public void blockargs(
2297 BlockExpression bexp
2298 ) //throws RecognitionException, TokenStreamException
2301 ParameterVarIdentifier ident
= null;
2304 ident
=methodParam();
2305 if (0==inputState
.guessing
)
2307 bexp
.AddBlockFormalParameter(ident
);
2315 ident
=methodParam();
2316 if (0==inputState
.guessing
)
2318 bexp
.AddBlockFormalParameter(ident
);
2323 goto _loop97_breakloop
;
2327 _loop97_breakloop: ;
2332 public RaiseExpression
raise() //throws RecognitionException, TokenStreamException
2334 RaiseExpression rexp
;
2336 rexp
= null; IExpression exp
;
2338 match(LITERAL_raise
);
2340 if (0==inputState
.guessing
)
2342 rexp
= new RaiseExpression(exp
);
2347 public YieldExpression
yield() //throws RecognitionException, TokenStreamException
2349 YieldExpression rexp
;
2351 rexp
= new YieldExpression();
2353 match(LITERAL_yield
);
2354 expressionList(rexp
.ExpColl
);
2358 public void expressionList(
2360 ) //throws RecognitionException, TokenStreamException
2363 IExpression exp
= null;
2366 if (0==inputState
.guessing
)
2373 if ((LA(1)==COMMA
) && (tokenSet_12_
.member(LA(2))))
2377 if (0==inputState
.guessing
)
2384 goto _loop112_breakloop
;
2388 _loop112_breakloop: ;
2392 public IExpression
and_test() //throws RecognitionException, TokenStreamException
2396 exp
= null; IExpression rhs
= null;
2402 if ((LA(1)==LITERAL_and
))
2406 if (0==inputState
.guessing
)
2408 exp
= new BinaryExpression(exp
, rhs
, BinaryOp
.And
);
2413 goto _loop103_breakloop
;
2417 _loop103_breakloop: ;
2422 public IExpression
not_test() //throws RecognitionException, TokenStreamException
2426 exp
= null; IExpression inner
= null;
2448 throw new NoViableAltException(LT(1), getFilename());
2453 if (0==inputState
.guessing
)
2455 exp
= new UnaryExpression(inner
, UnaryOp
.Not
);
2473 case STRING_LITERAL
:
2481 throw new NoViableAltException(LT(1), getFilename());
2487 public IExpression
comparison() //throws RecognitionException, TokenStreamException
2491 exp
= null; IExpression rhs
= null; BinaryOp op
= BinaryOp
.Undefined
;
2497 if ((tokenSet_13_
.member(LA(1))))
2501 if (0==inputState
.guessing
)
2503 exp
= new BinaryExpression(exp
, rhs
, op
);
2508 goto _loop108_breakloop
;
2512 _loop108_breakloop: ;
2517 public BinaryOp
comp_op() //throws RecognitionException, TokenStreamException
2521 op
= BinaryOp
.Undefined
;
2528 if (0==inputState
.guessing
)
2530 op
= BinaryOp
.LessThan
;
2537 if (0==inputState
.guessing
)
2539 op
= BinaryOp
.GreaterThan
;
2546 if (0==inputState
.guessing
)
2548 op
= BinaryOp
.Equal
;
2555 if (0==inputState
.guessing
)
2557 op
= BinaryOp
.GreaterEqual
;
2564 if (0==inputState
.guessing
)
2566 op
= BinaryOp
.LessEqual
;
2573 if (0==inputState
.guessing
)
2575 op
= BinaryOp
.NotEqual
;
2582 if (0==inputState
.guessing
)
2590 throw new NoViableAltException(LT(1), getFilename());
2596 public IExpression
xor_expr() //throws RecognitionException, TokenStreamException
2600 exp
= null; IExpression rhs
= null;
2606 if ((LA(1)==BOR
) && (tokenSet_12_
.member(LA(2))))
2610 if (0==inputState
.guessing
)
2612 exp
= new BinaryExpression(exp
, rhs
, BinaryOp
.Or2
);
2617 goto _loop118_breakloop
;
2621 _loop118_breakloop: ;
2626 public IExpression
and_expr() //throws RecognitionException, TokenStreamException
2630 exp
= null; IExpression rhs
= null;
2640 if (0==inputState
.guessing
)
2642 exp
= new BinaryExpression(exp
, rhs
, BinaryOp
.And2
);
2647 goto _loop121_breakloop
;
2651 _loop121_breakloop: ;
2656 public IExpression
arith_expr() //throws RecognitionException, TokenStreamException
2661 exp
= null; IExpression rhs
= null;
2667 if ((LA(1)==PLUS
||LA(1)==MINUS
))
2685 throw new NoViableAltException(LT(1), getFilename());
2690 if (0==inputState
.guessing
)
2692 exp
= new BinaryExpression(exp
, rhs
, t
!= null ? BinaryOp
.Plus
: BinaryOp
.Minus
);
2697 goto _loop125_breakloop
;
2701 _loop125_breakloop: ;
2706 public IExpression
term() //throws RecognitionException, TokenStreamException
2710 exp
= null; IExpression rhs
= null; BinaryOp op
= BinaryOp
.Undefined
;
2716 if ((tokenSet_14_
.member(LA(1))))
2724 if (0==inputState
.guessing
)
2733 if (0==inputState
.guessing
)
2742 if (0==inputState
.guessing
)
2750 throw new NoViableAltException(LT(1), getFilename());
2755 if (0==inputState
.guessing
)
2757 exp
= new BinaryExpression(exp
, rhs
, op
);
2762 goto _loop129_breakloop
;
2766 _loop129_breakloop: ;
2771 public IExpression
unary() //throws RecognitionException, TokenStreamException
2775 exp
= null; IExpression inner
= null; UnaryOp op
= UnaryOp
.Plus
;
2789 if (0==inputState
.guessing
)
2798 if (0==inputState
.guessing
)
2807 if (0==inputState
.guessing
)
2809 op
= UnaryOp
.BitwiseNot
;
2815 throw new NoViableAltException(LT(1), getFilename());
2820 if (0==inputState
.guessing
)
2822 exp
= new UnaryExpression(inner
, op
);
2837 case STRING_LITERAL
:
2845 throw new NoViableAltException(LT(1), getFilename());
2851 public IExpression
primary() //throws RecognitionException, TokenStreamException
2861 if ((tokenSet_15_
.member(LA(1))))
2867 goto _loop134_breakloop
;
2871 _loop134_breakloop: ;
2876 public IExpression
atom() //throws RecognitionException, TokenStreamException
2898 case LITERAL_lambda
:
2909 case STRING_LITERAL
:
2921 throw new NoViableAltException(LT(1), getFilename());
2948 case STRING_LITERAL
:
2960 throw new NoViableAltException(LT(1), getFilename());
2977 case STRING_LITERAL
:
2985 match(LITERAL_self
);
2986 if (0==inputState
.guessing
)
2988 exp
= SelfReferenceExpression
.Instance
;
2994 match(LITERAL_base
);
2995 if (0==inputState
.guessing
)
2997 exp
= BaseReferenceExpression
.Instance
;
3002 bool synPredMatched137
= false;
3003 if (((LA(1)==LPAREN
) && (tokenSet_12_
.member(LA(2)))))
3006 synPredMatched137
= true;
3007 inputState
.guessing
++;
3013 catch (RecognitionException
)
3015 synPredMatched137
= false;
3018 inputState
.guessing
--;
3020 if ( synPredMatched137
)
3024 else if ((LA(1)==LPAREN
) && (tokenSet_16_
.member(LA(2)))) {
3037 case LITERAL_lambda
:
3048 case STRING_LITERAL
:
3060 throw new NoViableAltException(LT(1), getFilename());
3068 throw new NoViableAltException(LT(1), getFilename());
3074 public IExpression
trailer(
3076 ) //throws RecognitionException, TokenStreamException
3082 exp
= null; BlockExpression temp
= null; String qp
= String
.Empty
;
3089 if (0==inputState
.guessing
)
3091 exp
= new MethodInvocationExpression(inner
);
3104 case LITERAL_lambda
:
3115 case STRING_LITERAL
:
3118 arglist((exp
as MethodInvocationExpression
).Arguments
);
3127 throw new NoViableAltException(LT(1), getFilename());
3138 if (0==inputState
.guessing
)
3152 if (0==inputState
.guessing
)
3154 exp
= new MemberAccessExpression(inner
, t1
.getText());
3159 if ((LA(1)==DOT
) && (LA(2)==97))
3163 if (0==inputState
.guessing
)
3165 exp
= new NullCheckExpression(inner
);
3168 else if ((LA(1)==DOT
) && (LA(2)==IDENT
)) {
3172 if (0==inputState
.guessing
)
3174 exp
= new MemberAccessExpression(inner
, t
.getText());
3179 throw new NoViableAltException(LT(1), getFilename());
3185 public IExpression
range() //throws RecognitionException, TokenStreamException
3190 rex
= null; IExpression lhs
= null; IExpression rhs
= null;
3210 throw new NoViableAltException(LT(1), getFilename());
3216 if (0==inputState
.guessing
)
3218 rex
= new RangeExpression(lhs
, rhs
, t
!= null);
3223 public ListExpression
listmaker() //throws RecognitionException, TokenStreamException
3227 exp
= new ListExpression(); IExpression item
;
3230 if (0==inputState
.guessing
)
3241 if (0==inputState
.guessing
)
3248 goto _loop153_breakloop
;
3252 _loop153_breakloop: ;
3257 public DictExpression
dictmaker() //throws RecognitionException, TokenStreamException
3261 exp
= new DictExpression(); IExpression key
, value;
3266 if (0==inputState
.guessing
)
3268 exp
.Add(key
, value);
3279 if (0==inputState
.guessing
)
3281 exp
.Add(key
, value);
3286 goto _loop156_breakloop
;
3290 _loop156_breakloop: ;
3295 public VariableReferenceExpression
varref() //throws RecognitionException, TokenStreamException
3297 VariableReferenceExpression vre
;
3299 Identifier ident
= null; vre
= null;
3302 if (0==inputState
.guessing
)
3304 vre
= new VariableReferenceExpression(ident
);
3309 public ConstExpression
constantref() //throws RecognitionException, TokenStreamException
3311 ConstExpression lre
;
3326 if (0==inputState
.guessing
)
3328 lre
= new ConstExpression(t1
.getText(), ConstExpressionType
.IntLiteral
);
3336 if (0==inputState
.guessing
)
3338 lre
= new ConstExpression(t2
.getText(), ConstExpressionType
.LongLiteral
);
3346 if (0==inputState
.guessing
)
3348 lre
= new ConstExpression(t3
.getText(), ConstExpressionType
.FloatLiteral
);
3352 case STRING_LITERAL
:
3355 match(STRING_LITERAL
);
3356 if (0==inputState
.guessing
)
3358 lre
= new ConstExpression(t5
.getText(), ConstExpressionType
.StringLiteral
);
3365 match(CHAR_LITERAL
);
3366 if (0==inputState
.guessing
)
3368 lre
= new ConstExpression(t6
.getText(), ConstExpressionType
.CharLiteral
);
3374 throw new NoViableAltException(LT(1), getFilename());
3380 public void arglist(
3382 ) //throws RecognitionException, TokenStreamException
3388 if (0==inputState
.guessing
)
3399 if (0==inputState
.guessing
)
3406 goto _loop149_breakloop
;
3410 _loop149_breakloop: ;
3414 public IExpression
argument() //throws RecognitionException, TokenStreamException
3424 private void initializeFactory()
3428 public static readonly string[] tokenNames_
= new string[] {
3432 @"""NULL_TREE_LOOKAHEAD""",
3442 @"""SUPER_CTOR_CALL""",
3451 @"""ARRAY_DECLARATOR""",
3456 @"""STATEMENT_END""",
3485 @"""MINUS_ASSIGN""",
3524 @"""STRING_LITERAL""",
3525 @"""CHAR_LITERAL""",
3551 @"""NonZeroDigit""",
3552 @"""FloatTrailer""",
3554 @"""CONTINUED_LINE"""
3557 private static long[] mk_tokenSet_0_()
3559 long[] data
= { 2814952142275314L, 7944065020L, 0L, 0L}
;
3562 public static readonly BitSet tokenSet_0_
= new BitSet(mk_tokenSet_0_());
3563 private static long[] mk_tokenSet_1_()
3565 long[] data
= { -66073802045710L, 128849018879L, 0L, 0L}
;
3568 public static readonly BitSet tokenSet_1_
= new BitSet(mk_tokenSet_1_());
3569 private static long[] mk_tokenSet_2_()
3571 long[] data
= { 134217730L, 0L}
;
3574 public static readonly BitSet tokenSet_2_
= new BitSet(mk_tokenSet_2_());
3575 private static long[] mk_tokenSet_3_()
3577 long[] data
= { 2814900468449968L, 7944062716L, 0L, 0L}
;
3580 public static readonly BitSet tokenSet_3_
= new BitSet(mk_tokenSet_3_());
3581 private static long[] mk_tokenSet_4_()
3583 long[] data
= { 13153337344L, 0L}
;
3586 public static readonly BitSet tokenSet_4_
= new BitSet(mk_tokenSet_4_());
3587 private static long[] mk_tokenSet_5_()
3589 long[] data
= { 563100654764704L, 7944062716L, 0L, 0L}
;
3592 public static readonly BitSet tokenSet_5_
= new BitSet(mk_tokenSet_5_());
3593 private static long[] mk_tokenSet_6_()
3595 long[] data
= { -2388244507392990L, 8589934531L, 0L, 0L}
;
3598 public static readonly BitSet tokenSet_6_
= new BitSet(mk_tokenSet_6_());
3599 private static long[] mk_tokenSet_7_()
3601 long[] data
= { 2880871166116528L, 7944062716L, 0L, 0L}
;
3604 public static readonly BitSet tokenSet_7_
= new BitSet(mk_tokenSet_7_());
3605 private static long[] mk_tokenSet_8_()
3607 long[] data
= { -2388242359909342L, 8589934531L, 0L, 0L}
;
3610 public static readonly BitSet tokenSet_8_
= new BitSet(mk_tokenSet_8_());
3611 private static long[] mk_tokenSet_9_()
3613 long[] data
= { 563100654764576L, 7944062716L, 0L, 0L}
;
3616 public static readonly BitSet tokenSet_9_
= new BitSet(mk_tokenSet_9_());
3617 private static long[] mk_tokenSet_10_()
3619 long[] data
= { 4123437039616L, 0L}
;
3622 public static readonly BitSet tokenSet_10_
= new BitSet(mk_tokenSet_10_());
3623 private static long[] mk_tokenSet_11_()
3625 long[] data
= { 562968878120962L, 0L}
;
3628 public static readonly BitSet tokenSet_11_
= new BitSet(mk_tokenSet_11_());
3629 private static long[] mk_tokenSet_12_()
3631 long[] data
= { 563100654764032L, 7944011904L, 0L, 0L}
;
3634 public static readonly BitSet tokenSet_12_
= new BitSet(mk_tokenSet_12_());
3635 private static long[] mk_tokenSet_13_()
3637 long[] data
= { 4503599627370496L, 4128768L, 0L, 0L}
;
3640 public static readonly BitSet tokenSet_13_
= new BitSet(mk_tokenSet_13_());
3641 private static long[] mk_tokenSet_14_()
3643 long[] data
= { 9007199254740992L, 100663296L, 0L, 0L}
;
3646 public static readonly BitSet tokenSet_14_
= new BitSet(mk_tokenSet_14_());
3647 private static long[] mk_tokenSet_15_()
3649 long[] data
= { 562951564034080L, 128L, 0L, 0L}
;
3652 public static readonly BitSet tokenSet_15_
= new BitSet(mk_tokenSet_15_());
3653 private static long[] mk_tokenSet_16_()
3655 long[] data
= { 1689000561606656L, 7944062656L, 0L, 0L}
;
3658 public static readonly BitSet tokenSet_16_
= new BitSet(mk_tokenSet_16_());