aboutsummaryrefslogtreecommitdiff
path: root/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions')
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammar.g3103
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexer.cs693
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexerHelper.cs32
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParser.cs1556
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParserHelper.cs43
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.cs845
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.g390
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammarHelper.cs119
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammar.g3103
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexer.cs693
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexerHelper.cs32
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParser.cs1560
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParserHelper.cs43
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.cs850
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.g390
-rw-r--r--runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammarHelper.cs119
16 files changed, 0 insertions, 6971 deletions
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammar.g3 b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammar.g3
deleted file mode 100644
index 6edb6d3..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammar.g3
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-grammar DebugGrammar;
-
-options
-{
- language=CSharp3;
- output=AST;
- ASTLabelType=CommonTree;
-}
-
-tokens
-{
- // define pseudo-operations
- FUNC;
- CALL;
-}
-
-@lexer::namespace{Antlr3.Runtime.Test.BuildOptions}
-@parser::namespace{Antlr3.Runtime.Test.BuildOptions}
-
-// START:stat
-prog: ( stat )*
- ;
-
-stat: expr NEWLINE -> expr
- | ID '=' expr NEWLINE -> ^('=' ID expr)
- | func NEWLINE -> func
- | NEWLINE -> // ignore
- ;
-
-func: ID '(' formalPar ')' '=' expr -> ^(FUNC ID formalPar expr)
- ;
- finally {
- functionDefinitions.Add($func.tree);
- }
-
-formalPar
- : ID
- | INT
- ;
-
-// END:stat
-
-// START:expr
-expr: multExpr (('+'^|'-'^) multExpr)*
- ;
-
-multExpr
- : atom (('*'|'/'|'%')^ atom)*
- ;
-
-atom: INT
- | ID
- | '(' expr ')' -> expr
- | ID '(' expr ')' -> ^(CALL ID expr)
- ;
-// END:expr
-
-// START:tokens
-ID : ('a'..'z'|'A'..'Z')+
- ;
-
-INT : '0'..'9'+
- ;
-
-NEWLINE
- : '\r'? '\n'
- ;
-
-WS : (' '|'\t')+ { Skip(); }
- ;
-// END:tokens
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexer.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexer.cs
deleted file mode 100644
index ab2235e..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexer.cs
+++ /dev/null
@@ -1,693 +0,0 @@
-// $ANTLR 3.1.2 BuildOptions\\DebugGrammar.g3 2009-09-30 13:18:14
-
-// The variable 'variable' is assigned but its value is never used.
-#pragma warning disable 219
-// Unreachable code detected.
-#pragma warning disable 162
-
-
-using System.Collections.Generic;
-using Antlr.Runtime;
-using Stack = System.Collections.Generic.Stack<object>;
-using List = System.Collections.IList;
-using ArrayList = System.Collections.Generic.List<object>;
-
-[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.1.2")]
-[System.CLSCompliant(false)]
-public partial class DebugGrammarLexer : Lexer
-{
- public const int EOF=-1;
- public const int T__10=10;
- public const int T__11=11;
- public const int T__12=12;
- public const int T__13=13;
- public const int T__14=14;
- public const int T__15=15;
- public const int T__16=16;
- public const int T__17=17;
- public const int CALL=4;
- public const int FUNC=5;
- public const int ID=6;
- public const int INT=7;
- public const int NEWLINE=8;
- public const int WS=9;
-
- // delegates
- // delegators
-
- public DebugGrammarLexer() {}
- public DebugGrammarLexer( ICharStream input )
- : this( input, new RecognizerSharedState() )
- {
- }
- public DebugGrammarLexer( ICharStream input, RecognizerSharedState state )
- : base( input, state )
- {
-
- }
- public override string GrammarFileName { get { return "BuildOptions\\DebugGrammar.g3"; } }
-
- // $ANTLR start "T__10"
- private void mT__10()
- {
- try
- {
- int _type = T__10;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:7:9: ( '-' )
- // BuildOptions\\DebugGrammar.g3:7:9: '-'
- {
- Match('-');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__10"
-
- // $ANTLR start "T__11"
- private void mT__11()
- {
- try
- {
- int _type = T__11;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:8:9: ( '%' )
- // BuildOptions\\DebugGrammar.g3:8:9: '%'
- {
- Match('%');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__11"
-
- // $ANTLR start "T__12"
- private void mT__12()
- {
- try
- {
- int _type = T__12;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:9:9: ( '(' )
- // BuildOptions\\DebugGrammar.g3:9:9: '('
- {
- Match('(');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__12"
-
- // $ANTLR start "T__13"
- private void mT__13()
- {
- try
- {
- int _type = T__13;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:10:9: ( ')' )
- // BuildOptions\\DebugGrammar.g3:10:9: ')'
- {
- Match(')');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__13"
-
- // $ANTLR start "T__14"
- private void mT__14()
- {
- try
- {
- int _type = T__14;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:11:9: ( '*' )
- // BuildOptions\\DebugGrammar.g3:11:9: '*'
- {
- Match('*');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__14"
-
- // $ANTLR start "T__15"
- private void mT__15()
- {
- try
- {
- int _type = T__15;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:12:9: ( '/' )
- // BuildOptions\\DebugGrammar.g3:12:9: '/'
- {
- Match('/');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__15"
-
- // $ANTLR start "T__16"
- private void mT__16()
- {
- try
- {
- int _type = T__16;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:13:9: ( '+' )
- // BuildOptions\\DebugGrammar.g3:13:9: '+'
- {
- Match('+');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__16"
-
- // $ANTLR start "T__17"
- private void mT__17()
- {
- try
- {
- int _type = T__17;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:14:9: ( '=' )
- // BuildOptions\\DebugGrammar.g3:14:9: '='
- {
- Match('=');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__17"
-
- // $ANTLR start "ID"
- private void mID()
- {
- try
- {
- int _type = ID;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:88:9: ( ( 'a' .. 'z' | 'A' .. 'Z' )+ )
- // BuildOptions\\DebugGrammar.g3:88:9: ( 'a' .. 'z' | 'A' .. 'Z' )+
- {
- // BuildOptions\\DebugGrammar.g3:88:9: ( 'a' .. 'z' | 'A' .. 'Z' )+
- int cnt1=0;
- for ( ; ; )
- {
- int alt1=2;
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>='A' && LA1_0<='Z')||(LA1_0>='a' && LA1_0<='z')) )
- {
- alt1=1;
- }
-
-
- switch ( alt1 )
- {
- case 1:
- // BuildOptions\\DebugGrammar.g3:
- {
- input.Consume();
-
-
- }
- break;
-
- default:
- if ( cnt1 >= 1 )
- goto loop1;
-
- EarlyExitException eee1 = new EarlyExitException( 1, input );
- throw eee1;
- }
- cnt1++;
- }
- loop1:
- ;
-
-
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "ID"
-
- // $ANTLR start "INT"
- private void mINT()
- {
- try
- {
- int _type = INT;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:91:9: ( ( '0' .. '9' )+ )
- // BuildOptions\\DebugGrammar.g3:91:9: ( '0' .. '9' )+
- {
- // BuildOptions\\DebugGrammar.g3:91:9: ( '0' .. '9' )+
- int cnt2=0;
- for ( ; ; )
- {
- int alt2=2;
- int LA2_0 = input.LA(1);
-
- if ( ((LA2_0>='0' && LA2_0<='9')) )
- {
- alt2=1;
- }
-
-
- switch ( alt2 )
- {
- case 1:
- // BuildOptions\\DebugGrammar.g3:
- {
- input.Consume();
-
-
- }
- break;
-
- default:
- if ( cnt2 >= 1 )
- goto loop2;
-
- EarlyExitException eee2 = new EarlyExitException( 2, input );
- throw eee2;
- }
- cnt2++;
- }
- loop2:
- ;
-
-
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "INT"
-
- // $ANTLR start "NEWLINE"
- private void mNEWLINE()
- {
- try
- {
- int _type = NEWLINE;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:95:7: ( ( '\\r' )? '\\n' )
- // BuildOptions\\DebugGrammar.g3:95:7: ( '\\r' )? '\\n'
- {
- // BuildOptions\\DebugGrammar.g3:95:7: ( '\\r' )?
- int alt3=2;
- int LA3_0 = input.LA(1);
-
- if ( (LA3_0=='\r') )
- {
- alt3=1;
- }
- switch ( alt3 )
- {
- case 1:
- // BuildOptions\\DebugGrammar.g3:95:0: '\\r'
- {
- Match('\r');
-
- }
- break;
-
- }
-
- Match('\n');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "NEWLINE"
-
- // $ANTLR start "WS"
- private void mWS()
- {
- try
- {
- int _type = WS;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\DebugGrammar.g3:98:9: ( ( ' ' | '\\t' )+ )
- // BuildOptions\\DebugGrammar.g3:98:9: ( ' ' | '\\t' )+
- {
- // BuildOptions\\DebugGrammar.g3:98:9: ( ' ' | '\\t' )+
- int cnt4=0;
- for ( ; ; )
- {
- int alt4=2;
- int LA4_0 = input.LA(1);
-
- if ( (LA4_0=='\t'||LA4_0==' ') )
- {
- alt4=1;
- }
-
-
- switch ( alt4 )
- {
- case 1:
- // BuildOptions\\DebugGrammar.g3:
- {
- input.Consume();
-
-
- }
- break;
-
- default:
- if ( cnt4 >= 1 )
- goto loop4;
-
- EarlyExitException eee4 = new EarlyExitException( 4, input );
- throw eee4;
- }
- cnt4++;
- }
- loop4:
- ;
-
-
- Skip();
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "WS"
-
- public override void mTokens()
- {
- // BuildOptions\\DebugGrammar.g3:1:10: ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | ID | INT | NEWLINE | WS )
- int alt5=12;
- switch ( input.LA(1) )
- {
- case '-':
- {
- alt5=1;
- }
- break;
- case '%':
- {
- alt5=2;
- }
- break;
- case '(':
- {
- alt5=3;
- }
- break;
- case ')':
- {
- alt5=4;
- }
- break;
- case '*':
- {
- alt5=5;
- }
- break;
- case '/':
- {
- alt5=6;
- }
- break;
- case '+':
- {
- alt5=7;
- }
- break;
- case '=':
- {
- alt5=8;
- }
- break;
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- case 'G':
- case 'H':
- case 'I':
- case 'J':
- case 'K':
- case 'L':
- case 'M':
- case 'N':
- case 'O':
- case 'P':
- case 'Q':
- case 'R':
- case 'S':
- case 'T':
- case 'U':
- case 'V':
- case 'W':
- case 'X':
- case 'Y':
- case 'Z':
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z':
- {
- alt5=9;
- }
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- alt5=10;
- }
- break;
- case '\n':
- case '\r':
- {
- alt5=11;
- }
- break;
- case '\t':
- case ' ':
- {
- alt5=12;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 5, 0, input);
-
- throw nvae;
- }
- }
-
- switch ( alt5 )
- {
- case 1:
- // BuildOptions\\DebugGrammar.g3:1:10: T__10
- {
- mT__10();
-
- }
- break;
- case 2:
- // BuildOptions\\DebugGrammar.g3:1:16: T__11
- {
- mT__11();
-
- }
- break;
- case 3:
- // BuildOptions\\DebugGrammar.g3:1:22: T__12
- {
- mT__12();
-
- }
- break;
- case 4:
- // BuildOptions\\DebugGrammar.g3:1:28: T__13
- {
- mT__13();
-
- }
- break;
- case 5:
- // BuildOptions\\DebugGrammar.g3:1:34: T__14
- {
- mT__14();
-
- }
- break;
- case 6:
- // BuildOptions\\DebugGrammar.g3:1:40: T__15
- {
- mT__15();
-
- }
- break;
- case 7:
- // BuildOptions\\DebugGrammar.g3:1:46: T__16
- {
- mT__16();
-
- }
- break;
- case 8:
- // BuildOptions\\DebugGrammar.g3:1:52: T__17
- {
- mT__17();
-
- }
- break;
- case 9:
- // BuildOptions\\DebugGrammar.g3:1:58: ID
- {
- mID();
-
- }
- break;
- case 10:
- // BuildOptions\\DebugGrammar.g3:1:61: INT
- {
- mINT();
-
- }
- break;
- case 11:
- // BuildOptions\\DebugGrammar.g3:1:65: NEWLINE
- {
- mNEWLINE();
-
- }
- break;
- case 12:
- // BuildOptions\\DebugGrammar.g3:1:73: WS
- {
- mWS();
-
- }
- break;
-
- }
-
- }
-
-
- #region DFA
-
- protected override void InitDFAs()
- {
- base.InitDFAs();
- }
-
-
- #endregion
-
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexerHelper.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexerHelper.cs
deleted file mode 100644
index 7271295..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarLexerHelper.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * [The "BSD licence"]
- * Copyright (c) 2005-2008 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParser.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParser.cs
deleted file mode 100644
index 7274b21..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParser.cs
+++ /dev/null
@@ -1,1556 +0,0 @@
-// $ANTLR 3.1.2 BuildOptions\\DebugGrammar.g3 2009-09-30 13:18:13
-
-// The variable 'variable' is assigned but its value is never used.
-#pragma warning disable 219
-// Unreachable code detected.
-#pragma warning disable 162
-
-
-using System.Collections.Generic;
-using Antlr.Runtime;
-using Stack = System.Collections.Generic.Stack<object>;
-using List = System.Collections.IList;
-using ArrayList = System.Collections.Generic.List<object>;
-
-using Antlr.Runtime.Debug;
-using IOException = System.IO.IOException;
-
-using Antlr.Runtime.Tree;
-using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;
-
-[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.1.2")]
-[System.CLSCompliant(false)]
-public partial class DebugGrammarParser : DebugParser
-{
- internal static readonly string[] tokenNames = new string[] {
- "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CALL", "FUNC", "ID", "INT", "NEWLINE", "WS", "'-'", "'%'", "'('", "')'", "'*'", "'/'", "'+'", "'='"
- };
- public const int EOF=-1;
- public const int T__10=10;
- public const int T__11=11;
- public const int T__12=12;
- public const int T__13=13;
- public const int T__14=14;
- public const int T__15=15;
- public const int T__16=16;
- public const int T__17=17;
- public const int CALL=4;
- public const int FUNC=5;
- public const int ID=6;
- public const int INT=7;
- public const int NEWLINE=8;
- public const int WS=9;
-
- // delegates
- // delegators
-
- public static readonly string[] ruleNames =
- new string[]
- {
- "invalidRule", "atom", "expr", "formalPar", "func", "multExpr", "prog",
- "stat"
- };
-
- int ruleLevel = 0;
- public virtual int RuleLevel { get { return ruleLevel; } }
- public virtual void IncRuleLevel() { ruleLevel++; }
- public virtual void DecRuleLevel() { ruleLevel--; }
- public DebugGrammarParser( ITokenStream input )
- : this( input, DebugEventSocketProxy.DefaultDebuggerPort, new RecognizerSharedState() )
- {
- }
- public DebugGrammarParser( ITokenStream input, int port, RecognizerSharedState state )
- : base( input, state )
- {
- InitializeTreeAdaptor();
- if ( TreeAdaptor == null )
- TreeAdaptor = new CommonTreeAdaptor();
- DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, adaptor );
- DebugListener = proxy;
- TokenStream = new DebugTokenStream( input, proxy );
- try
- {
- proxy.Handshake();
- }
- catch ( IOException ioe )
- {
- ReportError( ioe );
- }
- ITreeAdaptor adap = new CommonTreeAdaptor();
- TreeAdaptor = adap;
- proxy.TreeAdaptor = adap;
- }
- public DebugGrammarParser( ITokenStream input, IDebugEventListener dbg )
- : base( input, dbg )
- {
- InitializeTreeAdaptor();
- if ( TreeAdaptor == null )
- TreeAdaptor = new CommonTreeAdaptor();
-
- ITreeAdaptor adap = new CommonTreeAdaptor();
- TreeAdaptor = adap;
-
- }
- protected virtual bool EvalPredicate( bool result, string predicate )
- {
- dbg.SemanticPredicate( result, predicate );
- return result;
- }
-
- // Implement this function in your helper file to use a custom tree adaptor
- partial void InitializeTreeAdaptor();
- protected DebugTreeAdaptor adaptor;
-
- public ITreeAdaptor TreeAdaptor
- {
- get
- {
- return adaptor;
- }
- set
- {
- this.adaptor = new DebugTreeAdaptor(dbg,adaptor);
-
- }
- }
-
-
- public override string[] TokenNames { get { return DebugGrammarParser.tokenNames; } }
- public override string GrammarFileName { get { return "BuildOptions\\DebugGrammar.g3"; } }
-
-
- #region Rules
- public class prog_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "prog"
- // BuildOptions\\DebugGrammar.g3:50:0: prog : ( stat )* ;
- private DebugGrammarParser.prog_return prog( )
- {
- DebugGrammarParser.prog_return retval = new DebugGrammarParser.prog_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- DebugGrammarParser.stat_return stat1 = default(DebugGrammarParser.stat_return);
-
-
- try
- {
- dbg.EnterRule( GrammarFileName, "prog" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 50, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:50:7: ( ( stat )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:50:7: ( stat )*
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 50, 6 );
- // BuildOptions\\DebugGrammar.g3:50:7: ( stat )*
- try
- {
- dbg.EnterSubRule( 1 );
-
- for ( ; ; )
- {
- int alt1=2;
- try
- {
- dbg.EnterDecision( 1 );
-
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>=ID && LA1_0<=NEWLINE)||LA1_0==12) )
- {
- alt1=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 1 );
- }
-
- switch ( alt1 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:50:9: stat
- {
- dbg.Location( 50, 8 );
- PushFollow(Follow._stat_in_prog53);
- stat1=stat();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, stat1.Tree);
-
- }
- break;
-
- default:
- goto loop1;
- }
- }
-
- loop1:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 1 );
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(51, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "prog" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "prog"
-
- public class stat_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "stat"
- // BuildOptions\\DebugGrammar.g3:53:0: stat : ( expr NEWLINE -> expr | ID '=' expr NEWLINE -> ^( '=' ID expr ) | func NEWLINE -> func | NEWLINE ->);
- private DebugGrammarParser.stat_return stat( )
- {
- DebugGrammarParser.stat_return retval = new DebugGrammarParser.stat_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken NEWLINE3=null;
- IToken ID4=null;
- IToken char_literal5=null;
- IToken NEWLINE7=null;
- IToken NEWLINE9=null;
- IToken NEWLINE10=null;
- DebugGrammarParser.expr_return expr2 = default(DebugGrammarParser.expr_return);
- DebugGrammarParser.expr_return expr6 = default(DebugGrammarParser.expr_return);
- DebugGrammarParser.func_return func8 = default(DebugGrammarParser.func_return);
-
- CommonTree NEWLINE3_tree=null;
- CommonTree ID4_tree=null;
- CommonTree char_literal5_tree=null;
- CommonTree NEWLINE7_tree=null;
- CommonTree NEWLINE9_tree=null;
- CommonTree NEWLINE10_tree=null;
- RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
- RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
- RewriteRuleITokenStream stream_17=new RewriteRuleITokenStream(adaptor,"token 17");
- RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
- RewriteRuleSubtreeStream stream_func=new RewriteRuleSubtreeStream(adaptor,"rule func");
- try
- {
- dbg.EnterRule( GrammarFileName, "stat" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 53, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:53:9: ( expr NEWLINE -> expr | ID '=' expr NEWLINE -> ^( '=' ID expr ) | func NEWLINE -> func | NEWLINE ->)
- int alt2=4;
- try
- {
- dbg.EnterDecision( 2 );
-
- try
- {
- isCyclicDecision = true;
- alt2 = dfa2.Predict(input);
- }
- catch ( NoViableAltException nvae )
- {
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
- finally
- {
- dbg.ExitDecision( 2 );
- }
-
- switch ( alt2 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:53:9: expr NEWLINE
- {
- dbg.Location( 53, 8 );
- PushFollow(Follow._expr_in_stat70);
- expr2=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr2.Tree);
- dbg.Location( 53, 13 );
- NEWLINE3=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat72);
- stream_NEWLINE.Add(NEWLINE3);
-
-
-
- {
- // AST REWRITE
- // elements: expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 53:41: -> expr
- {
- dbg.Location( 53, 43 );
- adaptor.AddChild(root_0, stream_expr.NextTree());
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\DebugGrammar.g3:54:9: ID '=' expr NEWLINE
- {
- dbg.Location( 54, 8 );
- ID4=(IToken)Match(input,ID,Follow._ID_in_stat105);
- stream_ID.Add(ID4);
-
- dbg.Location( 54, 11 );
- char_literal5=(IToken)Match(input,17,Follow._17_in_stat107);
- stream_17.Add(char_literal5);
-
- dbg.Location( 54, 15 );
- PushFollow(Follow._expr_in_stat109);
- expr6=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr6.Tree);
- dbg.Location( 54, 20 );
- NEWLINE7=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat111);
- stream_NEWLINE.Add(NEWLINE7);
-
-
-
- {
- // AST REWRITE
- // elements: 17, ID, expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 54:41: -> ^( '=' ID expr )
- {
- dbg.Location( 54, 43 );
- // BuildOptions\\DebugGrammar.g3:54:44: ^( '=' ID expr )
- {
- CommonTree root_1 = (CommonTree)adaptor.Nil();
- dbg.Location( 54, 45 );
- root_1 = (CommonTree)adaptor.BecomeRoot(stream_17.NextNode(), root_1);
-
- dbg.Location( 54, 49 );
- adaptor.AddChild(root_1, stream_ID.NextNode());
- dbg.Location( 54, 52 );
- adaptor.AddChild(root_1, stream_expr.NextTree());
-
- adaptor.AddChild(root_0, root_1);
- }
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\DebugGrammar.g3:55:9: func NEWLINE
- {
- dbg.Location( 55, 8 );
- PushFollow(Follow._func_in_stat143);
- func8=func();
-
- state._fsp--;
-
- stream_func.Add(func8.Tree);
- dbg.Location( 55, 13 );
- NEWLINE9=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat145);
- stream_NEWLINE.Add(NEWLINE9);
-
-
-
- {
- // AST REWRITE
- // elements: func
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 55:41: -> func
- {
- dbg.Location( 55, 43 );
- adaptor.AddChild(root_0, stream_func.NextTree());
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 4:
- dbg.EnterAlt( 4 );
-
- // BuildOptions\\DebugGrammar.g3:56:9: NEWLINE
- {
- dbg.Location( 56, 8 );
- NEWLINE10=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat178);
- stream_NEWLINE.Add(NEWLINE10);
-
-
-
- {
- // AST REWRITE
- // elements:
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 56:41: ->
- {
- dbg.Location( 57, 4 );
- root_0 = null;
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(57, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "stat" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "stat"
-
- public class func_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "func"
- // BuildOptions\\DebugGrammar.g3:59:0: func : ID '(' formalPar ')' '=' expr -> ^( FUNC ID formalPar expr ) ;
- private DebugGrammarParser.func_return func( )
- {
- DebugGrammarParser.func_return retval = new DebugGrammarParser.func_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken ID11=null;
- IToken char_literal12=null;
- IToken char_literal14=null;
- IToken char_literal15=null;
- DebugGrammarParser.formalPar_return formalPar13 = default(DebugGrammarParser.formalPar_return);
- DebugGrammarParser.expr_return expr16 = default(DebugGrammarParser.expr_return);
-
- CommonTree ID11_tree=null;
- CommonTree char_literal12_tree=null;
- CommonTree char_literal14_tree=null;
- CommonTree char_literal15_tree=null;
- RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
- RewriteRuleITokenStream stream_12=new RewriteRuleITokenStream(adaptor,"token 12");
- RewriteRuleITokenStream stream_13=new RewriteRuleITokenStream(adaptor,"token 13");
- RewriteRuleITokenStream stream_17=new RewriteRuleITokenStream(adaptor,"token 17");
- RewriteRuleSubtreeStream stream_formalPar=new RewriteRuleSubtreeStream(adaptor,"rule formalPar");
- RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
- try
- {
- dbg.EnterRule( GrammarFileName, "func" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 59, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:59:9: ( ID '(' formalPar ')' '=' expr -> ^( FUNC ID formalPar expr ) )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:59:9: ID '(' formalPar ')' '=' expr
- {
- dbg.Location( 59, 8 );
- ID11=(IToken)Match(input,ID,Follow._ID_in_func219);
- stream_ID.Add(ID11);
-
- dbg.Location( 59, 12 );
- char_literal12=(IToken)Match(input,12,Follow._12_in_func222);
- stream_12.Add(char_literal12);
-
- dbg.Location( 59, 16 );
- PushFollow(Follow._formalPar_in_func224);
- formalPar13=formalPar();
-
- state._fsp--;
-
- stream_formalPar.Add(formalPar13.Tree);
- dbg.Location( 59, 26 );
- char_literal14=(IToken)Match(input,13,Follow._13_in_func226);
- stream_13.Add(char_literal14);
-
- dbg.Location( 59, 30 );
- char_literal15=(IToken)Match(input,17,Follow._17_in_func228);
- stream_17.Add(char_literal15);
-
- dbg.Location( 59, 34 );
- PushFollow(Follow._expr_in_func230);
- expr16=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr16.Tree);
-
-
- {
- // AST REWRITE
- // elements: ID, formalPar, expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 59:41: -> ^( FUNC ID formalPar expr )
- {
- dbg.Location( 59, 43 );
- // BuildOptions\\DebugGrammar.g3:59:44: ^( FUNC ID formalPar expr )
- {
- CommonTree root_1 = (CommonTree)adaptor.Nil();
- dbg.Location( 59, 45 );
- root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(FUNC, "FUNC"), root_1);
-
- dbg.Location( 59, 50 );
- adaptor.AddChild(root_1, stream_ID.NextNode());
- dbg.Location( 59, 53 );
- adaptor.AddChild(root_1, stream_formalPar.NextTree());
- dbg.Location( 59, 63 );
- adaptor.AddChild(root_1, stream_expr.NextTree());
-
- adaptor.AddChild(root_0, root_1);
- }
-
- }
-
- retval.tree = root_0;
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
-
- functionDefinitions.Add(((CommonTree)retval.Tree));
-
- }
- dbg.Location(60, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "func" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "func"
-
- public class formalPar_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "formalPar"
- // BuildOptions\\DebugGrammar.g3:65:0: formalPar : ( ID | INT );
- private DebugGrammarParser.formalPar_return formalPar( )
- {
- DebugGrammarParser.formalPar_return retval = new DebugGrammarParser.formalPar_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken set17=null;
-
- CommonTree set17_tree=null;
-
- try
- {
- dbg.EnterRule( GrammarFileName, "formalPar" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 65, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:66:9: ( ID | INT )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 66, 8 );
- set17=(IToken)input.LT(1);
- if ( (input.LA(1)>=ID && input.LA(1)<=INT) )
- {
- input.Consume();
- adaptor.AddChild(root_0, (CommonTree)adaptor.Create(set17));
- state.errorRecovery=false;
- }
- else
- {
- MismatchedSetException mse = new MismatchedSetException(null,input);
- dbg.RecognitionException( mse );
- throw mse;
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(68, 1);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "formalPar" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "formalPar"
-
- public class expr_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "expr"
- // BuildOptions\\DebugGrammar.g3:73:0: expr : multExpr ( ( '+' | '-' ) multExpr )* ;
- private DebugGrammarParser.expr_return expr( )
- {
- DebugGrammarParser.expr_return retval = new DebugGrammarParser.expr_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken char_literal19=null;
- IToken char_literal20=null;
- DebugGrammarParser.multExpr_return multExpr18 = default(DebugGrammarParser.multExpr_return);
- DebugGrammarParser.multExpr_return multExpr21 = default(DebugGrammarParser.multExpr_return);
-
- CommonTree char_literal19_tree=null;
- CommonTree char_literal20_tree=null;
-
- try
- {
- dbg.EnterRule( GrammarFileName, "expr" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 73, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:73:9: ( multExpr ( ( '+' | '-' ) multExpr )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:73:9: multExpr ( ( '+' | '-' ) multExpr )*
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 73, 8 );
- PushFollow(Follow._multExpr_in_expr288);
- multExpr18=multExpr();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, multExpr18.Tree);
- dbg.Location( 73, 17 );
- // BuildOptions\\DebugGrammar.g3:73:18: ( ( '+' | '-' ) multExpr )*
- try
- {
- dbg.EnterSubRule( 4 );
-
- for ( ; ; )
- {
- int alt4=2;
- try
- {
- dbg.EnterDecision( 4 );
-
- int LA4_0 = input.LA(1);
-
- if ( (LA4_0==10||LA4_0==16) )
- {
- alt4=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 4 );
- }
-
- switch ( alt4 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:73:19: ( '+' | '-' ) multExpr
- {
- dbg.Location( 73, 18 );
- // BuildOptions\\DebugGrammar.g3:73:19: ( '+' | '-' )
- int alt3=2;
- try
- {
- dbg.EnterSubRule( 3 );
- try
- {
- dbg.EnterDecision( 3 );
-
- int LA3_0 = input.LA(1);
-
- if ( (LA3_0==16) )
- {
- alt3=1;
- }
- else if ( (LA3_0==10) )
- {
- alt3=2;
- }
- else
- {
- NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
- finally
- {
- dbg.ExitDecision( 3 );
- }
-
- switch ( alt3 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:73:20: '+'
- {
- dbg.Location( 73, 22 );
- char_literal19=(IToken)Match(input,16,Follow._16_in_expr292);
- char_literal19_tree = (CommonTree)adaptor.Create(char_literal19);
- root_0 = (CommonTree)adaptor.BecomeRoot(char_literal19_tree, root_0);
-
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\DebugGrammar.g3:73:25: '-'
- {
- dbg.Location( 73, 27 );
- char_literal20=(IToken)Match(input,10,Follow._10_in_expr295);
- char_literal20_tree = (CommonTree)adaptor.Create(char_literal20);
- root_0 = (CommonTree)adaptor.BecomeRoot(char_literal20_tree, root_0);
-
-
- }
- break;
-
- }
- }
- finally
- {
- dbg.ExitSubRule( 3 );
- }
-
- dbg.Location( 73, 30 );
- PushFollow(Follow._multExpr_in_expr299);
- multExpr21=multExpr();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, multExpr21.Tree);
-
- }
- break;
-
- default:
- goto loop4;
- }
- }
-
- loop4:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 4 );
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(74, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "expr" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "expr"
-
- public class multExpr_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "multExpr"
- // BuildOptions\\DebugGrammar.g3:76:0: multExpr : atom ( ( '*' | '/' | '%' ) atom )* ;
- private DebugGrammarParser.multExpr_return multExpr( )
- {
- DebugGrammarParser.multExpr_return retval = new DebugGrammarParser.multExpr_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken set23=null;
- DebugGrammarParser.atom_return atom22 = default(DebugGrammarParser.atom_return);
- DebugGrammarParser.atom_return atom24 = default(DebugGrammarParser.atom_return);
-
- CommonTree set23_tree=null;
-
- try
- {
- dbg.EnterRule( GrammarFileName, "multExpr" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 76, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:77:9: ( atom ( ( '*' | '/' | '%' ) atom )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:77:9: atom ( ( '*' | '/' | '%' ) atom )*
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 77, 8 );
- PushFollow(Follow._atom_in_multExpr320);
- atom22=atom();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, atom22.Tree);
- dbg.Location( 77, 13 );
- // BuildOptions\\DebugGrammar.g3:77:14: ( ( '*' | '/' | '%' ) atom )*
- try
- {
- dbg.EnterSubRule( 5 );
-
- for ( ; ; )
- {
- int alt5=2;
- try
- {
- dbg.EnterDecision( 5 );
-
- int LA5_0 = input.LA(1);
-
- if ( (LA5_0==11||(LA5_0>=14 && LA5_0<=15)) )
- {
- alt5=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 5 );
- }
-
- switch ( alt5 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:77:15: ( '*' | '/' | '%' ) atom
- {
- dbg.Location( 77, 27 );
- set23=(IToken)input.LT(1);
- set23=(IToken)input.LT(1);
- if ( input.LA(1)==11||(input.LA(1)>=14 && input.LA(1)<=15) )
- {
- input.Consume();
- root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set23), root_0);
- state.errorRecovery=false;
- }
- else
- {
- MismatchedSetException mse = new MismatchedSetException(null,input);
- dbg.RecognitionException( mse );
- throw mse;
- }
-
- dbg.Location( 77, 29 );
- PushFollow(Follow._atom_in_multExpr332);
- atom24=atom();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, atom24.Tree);
-
- }
- break;
-
- default:
- goto loop5;
- }
- }
-
- loop5:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 5 );
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(78, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "multExpr" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "multExpr"
-
- public class atom_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "atom"
- // BuildOptions\\DebugGrammar.g3:80:0: atom : ( INT | ID | '(' expr ')' -> expr | ID '(' expr ')' -> ^( CALL ID expr ) );
- private DebugGrammarParser.atom_return atom( )
- {
- DebugGrammarParser.atom_return retval = new DebugGrammarParser.atom_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken INT25=null;
- IToken ID26=null;
- IToken char_literal27=null;
- IToken char_literal29=null;
- IToken ID30=null;
- IToken char_literal31=null;
- IToken char_literal33=null;
- DebugGrammarParser.expr_return expr28 = default(DebugGrammarParser.expr_return);
- DebugGrammarParser.expr_return expr32 = default(DebugGrammarParser.expr_return);
-
- CommonTree INT25_tree=null;
- CommonTree ID26_tree=null;
- CommonTree char_literal27_tree=null;
- CommonTree char_literal29_tree=null;
- CommonTree ID30_tree=null;
- CommonTree char_literal31_tree=null;
- CommonTree char_literal33_tree=null;
- RewriteRuleITokenStream stream_12=new RewriteRuleITokenStream(adaptor,"token 12");
- RewriteRuleITokenStream stream_13=new RewriteRuleITokenStream(adaptor,"token 13");
- RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
- RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
- try
- {
- dbg.EnterRule( GrammarFileName, "atom" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 80, -1 );
-
- try
- {
- // BuildOptions\\DebugGrammar.g3:80:9: ( INT | ID | '(' expr ')' -> expr | ID '(' expr ')' -> ^( CALL ID expr ) )
- int alt6=4;
- try
- {
- dbg.EnterDecision( 6 );
-
- switch ( input.LA(1) )
- {
- case INT:
- {
- alt6=1;
- }
- break;
- case ID:
- {
- int LA6_2 = input.LA(2);
-
- if ( (LA6_2==12) )
- {
- alt6=4;
- }
- else if ( (LA6_2==NEWLINE||(LA6_2>=10 && LA6_2<=11)||(LA6_2>=13 && LA6_2<=16)) )
- {
- alt6=2;
- }
- else
- {
- NoViableAltException nvae = new NoViableAltException("", 6, 2, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
- break;
- case 12:
- {
- alt6=3;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 6, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
-
- }
- finally
- {
- dbg.ExitDecision( 6 );
- }
-
- switch ( alt6 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugGrammar.g3:80:9: INT
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 80, 8 );
- INT25=(IToken)Match(input,INT,Follow._INT_in_atom348);
- INT25_tree = (CommonTree)adaptor.Create(INT25);
- adaptor.AddChild(root_0, INT25_tree);
-
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\DebugGrammar.g3:81:9: ID
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 81, 8 );
- ID26=(IToken)Match(input,ID,Follow._ID_in_atom358);
- ID26_tree = (CommonTree)adaptor.Create(ID26);
- adaptor.AddChild(root_0, ID26_tree);
-
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\DebugGrammar.g3:82:9: '(' expr ')'
- {
- dbg.Location( 82, 8 );
- char_literal27=(IToken)Match(input,12,Follow._12_in_atom368);
- stream_12.Add(char_literal27);
-
- dbg.Location( 82, 12 );
- PushFollow(Follow._expr_in_atom370);
- expr28=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr28.Tree);
- dbg.Location( 82, 17 );
- char_literal29=(IToken)Match(input,13,Follow._13_in_atom372);
- stream_13.Add(char_literal29);
-
-
-
- {
- // AST REWRITE
- // elements: expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 82:25: -> expr
- {
- dbg.Location( 82, 27 );
- adaptor.AddChild(root_0, stream_expr.NextTree());
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 4:
- dbg.EnterAlt( 4 );
-
- // BuildOptions\\DebugGrammar.g3:83:9: ID '(' expr ')'
- {
- dbg.Location( 83, 8 );
- ID30=(IToken)Match(input,ID,Follow._ID_in_atom389);
- stream_ID.Add(ID30);
-
- dbg.Location( 83, 11 );
- char_literal31=(IToken)Match(input,12,Follow._12_in_atom391);
- stream_12.Add(char_literal31);
-
- dbg.Location( 83, 15 );
- PushFollow(Follow._expr_in_atom393);
- expr32=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr32.Tree);
- dbg.Location( 83, 20 );
- char_literal33=(IToken)Match(input,13,Follow._13_in_atom395);
- stream_13.Add(char_literal33);
-
-
-
- {
- // AST REWRITE
- // elements: ID, expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 83:25: -> ^( CALL ID expr )
- {
- dbg.Location( 83, 27 );
- // BuildOptions\\DebugGrammar.g3:83:28: ^( CALL ID expr )
- {
- CommonTree root_1 = (CommonTree)adaptor.Nil();
- dbg.Location( 83, 29 );
- root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(CALL, "CALL"), root_1);
-
- dbg.Location( 83, 34 );
- adaptor.AddChild(root_1, stream_ID.NextNode());
- dbg.Location( 83, 37 );
- adaptor.AddChild(root_1, stream_expr.NextTree());
-
- adaptor.AddChild(root_0, root_1);
- }
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(84, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "atom" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "atom"
- #endregion Rules
-
-
- #region DFA
- DFA2 dfa2;
-
- protected override void InitDFAs()
- {
- base.InitDFAs();
- dfa2 = new DFA2( this );
- }
-
- class DFA2 : DFA
- {
-
- const string DFA2_eotS =
- "\xA\xFFFF";
- const string DFA2_eofS =
- "\xA\xFFFF";
- const string DFA2_minS =
- "\x1\x6\x1\xFFFF\x1\x8\x1\xFFFF\x1\x6\x1\xFFFF\x2\xA\x1\x8\x1\xFFFF";
- const string DFA2_maxS =
- "\x1\xC\x1\xFFFF\x1\x11\x1\xFFFF\x1\xC\x1\xFFFF\x2\x10\x1\x11\x1\xFFFF";
- const string DFA2_acceptS =
- "\x1\xFFFF\x1\x1\x1\xFFFF\x1\x4\x1\xFFFF\x1\x2\x3\xFFFF\x1\x3";
- const string DFA2_specialS =
- "\xA\xFFFF}>";
- static readonly string[] DFA2_transitionS =
- {
- "\x1\x2\x1\x1\x1\x3\x3\xFFFF\x1\x1",
- "",
- "\x1\x1\x1\xFFFF\x2\x1\x1\x4\x1\xFFFF\x3\x1\x1\x5",
- "",
- "\x1\x7\x1\x6\x4\xFFFF\x1\x1",
- "",
- "\x2\x1\x1\xFFFF\x1\x8\x3\x1",
- "\x3\x1\x1\x8\x3\x1",
- "\x1\x1\x1\xFFFF\x2\x1\x2\xFFFF\x3\x1\x1\x9",
- ""
- };
-
- static readonly short[] DFA2_eot = DFA.UnpackEncodedString(DFA2_eotS);
- static readonly short[] DFA2_eof = DFA.UnpackEncodedString(DFA2_eofS);
- static readonly char[] DFA2_min = DFA.UnpackEncodedStringToUnsignedChars(DFA2_minS);
- static readonly char[] DFA2_max = DFA.UnpackEncodedStringToUnsignedChars(DFA2_maxS);
- static readonly short[] DFA2_accept = DFA.UnpackEncodedString(DFA2_acceptS);
- static readonly short[] DFA2_special = DFA.UnpackEncodedString(DFA2_specialS);
- static readonly short[][] DFA2_transition;
-
- static DFA2()
- {
- int numStates = DFA2_transitionS.Length;
- DFA2_transition = new short[numStates][];
- for ( int i=0; i < numStates; i++ )
- {
- DFA2_transition[i] = DFA.UnpackEncodedString(DFA2_transitionS[i]);
- }
- }
-
- public DFA2( BaseRecognizer recognizer )
- {
- this.recognizer = recognizer;
- this.decisionNumber = 2;
- this.eot = DFA2_eot;
- this.eof = DFA2_eof;
- this.min = DFA2_min;
- this.max = DFA2_max;
- this.accept = DFA2_accept;
- this.special = DFA2_special;
- this.transition = DFA2_transition;
- }
- public override string GetDescription()
- {
- return "53:0: stat : ( expr NEWLINE -> expr | ID '=' expr NEWLINE -> ^( '=' ID expr ) | func NEWLINE -> func | NEWLINE ->);";
- }
- public override void Error( NoViableAltException nvae )
- {
- ((DebugParser)recognizer).dbg.RecognitionException( nvae );
- }
- }
-
-
- #endregion DFA
-
- #region Follow sets
- private static class Follow
- {
- public static readonly BitSet _stat_in_prog53 = new BitSet(new ulong[]{0x11C2UL});
- public static readonly BitSet _expr_in_stat70 = new BitSet(new ulong[]{0x100UL});
- public static readonly BitSet _NEWLINE_in_stat72 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_stat105 = new BitSet(new ulong[]{0x20000UL});
- public static readonly BitSet _17_in_stat107 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_stat109 = new BitSet(new ulong[]{0x100UL});
- public static readonly BitSet _NEWLINE_in_stat111 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _func_in_stat143 = new BitSet(new ulong[]{0x100UL});
- public static readonly BitSet _NEWLINE_in_stat145 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _NEWLINE_in_stat178 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_func219 = new BitSet(new ulong[]{0x1000UL});
- public static readonly BitSet _12_in_func222 = new BitSet(new ulong[]{0xC0UL});
- public static readonly BitSet _formalPar_in_func224 = new BitSet(new ulong[]{0x2000UL});
- public static readonly BitSet _13_in_func226 = new BitSet(new ulong[]{0x20000UL});
- public static readonly BitSet _17_in_func228 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_func230 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _set_in_formalPar267 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _multExpr_in_expr288 = new BitSet(new ulong[]{0x10402UL});
- public static readonly BitSet _16_in_expr292 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _10_in_expr295 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _multExpr_in_expr299 = new BitSet(new ulong[]{0x10402UL});
- public static readonly BitSet _atom_in_multExpr320 = new BitSet(new ulong[]{0xC802UL});
- public static readonly BitSet _set_in_multExpr323 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _atom_in_multExpr332 = new BitSet(new ulong[]{0xC802UL});
- public static readonly BitSet _INT_in_atom348 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_atom358 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _12_in_atom368 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_atom370 = new BitSet(new ulong[]{0x2000UL});
- public static readonly BitSet _13_in_atom372 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_atom389 = new BitSet(new ulong[]{0x1000UL});
- public static readonly BitSet _12_in_atom391 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_atom393 = new BitSet(new ulong[]{0x2000UL});
- public static readonly BitSet _13_in_atom395 = new BitSet(new ulong[]{0x2UL});
-
- }
- #endregion Follow sets
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParserHelper.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParserHelper.cs
deleted file mode 100644
index 638100e..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugGrammarParserHelper.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace Antlr3.Runtime.Test.BuildOptions
-{
- using System.Collections.Generic;
- using Antlr.Runtime.Tree;
-
- partial class DebugGrammarParser
- {
- /** List of function definitions. Must point at the FUNC nodes. */
- List<CommonTree> functionDefinitions = new List<CommonTree>();
- }
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.cs
deleted file mode 100644
index c9122e5..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.cs
+++ /dev/null
@@ -1,845 +0,0 @@
-// $ANTLR 3.1.2 BuildOptions\\DebugTreeGrammar.g3 2009-09-30 13:18:15
-
-// The variable 'variable' is assigned but its value is never used.
-#pragma warning disable 219
-// Unreachable code detected.
-#pragma warning disable 162
-
-
-//import java.util.Map;
-//import java.util.HashMap;
-using BigInteger = java.math.BigInteger;
-using Console = System.Console;
-
-
-using System.Collections.Generic;
-using Antlr.Runtime;
-using Antlr.Runtime.Tree;
-using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;using Stack = System.Collections.Generic.Stack<object>;
-using List = System.Collections.IList;
-using ArrayList = System.Collections.Generic.List<object>;
-
-using Antlr.Runtime.Debug;
-using IOException = System.IO.IOException;
-[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.1.2")]
-[System.CLSCompliant(false)]
-public partial class DebugTreeGrammar : DebugTreeParser
-{
- internal static readonly string[] tokenNames = new string[] {
- "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CALL", "FUNC", "ID", "INT", "NEWLINE", "WS", "'-'", "'%'", "'('", "')'", "'*'", "'/'", "'+'", "'='"
- };
- public const int EOF=-1;
- public const int T__10=10;
- public const int T__11=11;
- public const int T__12=12;
- public const int T__13=13;
- public const int T__14=14;
- public const int T__15=15;
- public const int T__16=16;
- public const int T__17=17;
- public const int CALL=4;
- public const int FUNC=5;
- public const int ID=6;
- public const int INT=7;
- public const int NEWLINE=8;
- public const int WS=9;
-
- // delegates
- // delegators
-
- public static readonly string[] ruleNames =
- new string[]
- {
- "invalidRule", "call", "expr", "prog", "stat"
- };
-
- int ruleLevel = 0;
- public virtual int RuleLevel { get { return ruleLevel; } }
- public virtual void IncRuleLevel() { ruleLevel++; }
- public virtual void DecRuleLevel() { ruleLevel--; }
- public DebugTreeGrammar( ITreeNodeStream input )
- : this( input, DebugEventSocketProxy.DefaultDebuggerPort, new RecognizerSharedState() )
- {
- }
- public DebugTreeGrammar( ITreeNodeStream input, int port, RecognizerSharedState state )
- : base( input, state )
- {
- DebugEventSocketProxy proxy = new DebugEventSocketProxy( this, port, input.TreeAdaptor );
- DebugListener = proxy;
- try
- {
- proxy.Handshake();
- }
- catch ( IOException ioe )
- {
- ReportError( ioe );
- }
- }
- public DebugTreeGrammar( ITreeNodeStream input, IDebugEventListener dbg )
- : base( input, dbg, new RecognizerSharedState() )
- {
-
- }
- protected virtual bool EvalPredicate( bool result, string predicate )
- {
- dbg.SemanticPredicate( result, predicate );
- return result;
- }
-
-
- public override string[] TokenNames { get { return DebugTreeGrammar.tokenNames; } }
- public override string GrammarFileName { get { return "BuildOptions\\DebugTreeGrammar.g3"; } }
-
-
- #region Rules
-
- // $ANTLR start "prog"
- // BuildOptions\\DebugTreeGrammar.g3:53:0: prog : ( stat )* ;
- private void prog( )
- {
- try
- {
- dbg.EnterRule( GrammarFileName, "prog" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 53, -1 );
-
- try
- {
- // BuildOptions\\DebugTreeGrammar.g3:53:9: ( ( stat )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugTreeGrammar.g3:53:9: ( stat )*
- {
- dbg.Location( 53, 8 );
- // BuildOptions\\DebugTreeGrammar.g3:53:9: ( stat )*
- try
- {
- dbg.EnterSubRule( 1 );
-
- for ( ; ; )
- {
- int alt1=2;
- try
- {
- dbg.EnterDecision( 1 );
-
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>=CALL && LA1_0<=INT)||(LA1_0>=10 && LA1_0<=11)||(LA1_0>=14 && LA1_0<=17)) )
- {
- alt1=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 1 );
- }
-
- switch ( alt1 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugTreeGrammar.g3:53:0: stat
- {
- dbg.Location( 53, 8 );
- PushFollow(Follow._stat_in_prog48);
- stat();
-
- state._fsp--;
-
-
- }
- break;
-
- default:
- goto loop1;
- }
- }
-
- loop1:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 1 );
- }
-
-
- }
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(54, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "prog" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return ;
- }
- // $ANTLR end "prog"
-
-
- // $ANTLR start "stat"
- // BuildOptions\\DebugTreeGrammar.g3:56:0: stat : ( expr | ^( '=' ID expr ) | ^( FUNC ( . )+ ) );
- private void stat( )
- {
- CommonTree ID2=null;
- BigInteger expr1 = default(BigInteger);
- BigInteger expr3 = default(BigInteger);
-
- try
- {
- dbg.EnterRule( GrammarFileName, "stat" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 56, -1 );
-
- try
- {
- // BuildOptions\\DebugTreeGrammar.g3:56:9: ( expr | ^( '=' ID expr ) | ^( FUNC ( . )+ ) )
- int alt3=3;
- try
- {
- dbg.EnterDecision( 3 );
-
- switch ( input.LA(1) )
- {
- case CALL:
- case ID:
- case INT:
- case 10:
- case 11:
- case 14:
- case 15:
- case 16:
- {
- alt3=1;
- }
- break;
- case 17:
- {
- alt3=2;
- }
- break;
- case FUNC:
- {
- alt3=3;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
-
- }
- finally
- {
- dbg.ExitDecision( 3 );
- }
-
- switch ( alt3 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugTreeGrammar.g3:56:9: expr
- {
- dbg.Location( 56, 8 );
- PushFollow(Follow._expr_in_stat63);
- expr1=expr();
-
- state._fsp--;
-
- dbg.Location( 56, 35 );
- string result = expr1.ToString();
- Console.Out.WriteLine(expr1 + " (about " + result[0] + "*10^" + (result.Length-1) + ")");
-
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\DebugTreeGrammar.g3:59:9: ^( '=' ID expr )
- {
- dbg.Location( 59, 8 );
- dbg.Location( 59, 10 );
- Match(input,17,Follow._17_in_stat98);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 59, 14 );
- ID2=(CommonTree)Match(input,ID,Follow._ID_in_stat100);
- dbg.Location( 59, 17 );
- PushFollow(Follow._expr_in_stat102);
- expr3=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 59, 35 );
- globalMemory[(ID2!=null?ID2.Text:null)] = expr3;
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\DebugTreeGrammar.g3:60:9: ^( FUNC ( . )+ )
- {
- dbg.Location( 60, 8 );
- dbg.Location( 60, 10 );
- Match(input,FUNC,Follow._FUNC_in_stat128);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 60, 15 );
- // BuildOptions\\DebugTreeGrammar.g3:60:16: ( . )+
- int cnt2=0;
- try
- {
- dbg.EnterSubRule( 2 );
-
- for ( ; ; )
- {
- int alt2=2;
- try
- {
- dbg.EnterDecision( 2 );
-
- int LA2_0 = input.LA(1);
-
- if ( ((LA2_0>=CALL && LA2_0<=17)) )
- {
- alt2=1;
- }
- else if ( (LA2_0==UP) )
- {
- alt2=2;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 2 );
- }
-
- switch ( alt2 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugTreeGrammar.g3:60:0: .
- {
- dbg.Location( 60, 15 );
- MatchAny(input);
-
- }
- break;
-
- default:
- if ( cnt2 >= 1 )
- goto loop2;
-
- EarlyExitException eee2 = new EarlyExitException( 2, input );
- dbg.RecognitionException( eee2 );
-
- throw eee2;
- }
- cnt2++;
- }
- loop2:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 2 );
- }
-
-
- Match(input, TokenTypes.Up, null);
-
- }
- break;
-
- }
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(61, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "stat" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return ;
- }
- // $ANTLR end "stat"
-
-
- // $ANTLR start "expr"
- // BuildOptions\\DebugTreeGrammar.g3:63:0: expr returns [BigInteger value] : ( ^( '+' a= expr b= expr ) | ^( '-' a= expr b= expr ) | ^( '*' a= expr b= expr ) | ^( '/' a= expr b= expr ) | ^( '%' a= expr b= expr ) | ID | INT | call );
- private BigInteger expr( )
- {
- BigInteger value = default(BigInteger);
-
- CommonTree ID4=null;
- CommonTree INT5=null;
- BigInteger a = default(BigInteger);
- BigInteger b = default(BigInteger);
- BigInteger call6 = default(BigInteger);
-
- try
- {
- dbg.EnterRule( GrammarFileName, "expr" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 63, -1 );
-
- try
- {
- // BuildOptions\\DebugTreeGrammar.g3:64:9: ( ^( '+' a= expr b= expr ) | ^( '-' a= expr b= expr ) | ^( '*' a= expr b= expr ) | ^( '/' a= expr b= expr ) | ^( '%' a= expr b= expr ) | ID | INT | call )
- int alt4=8;
- try
- {
- dbg.EnterDecision( 4 );
-
- switch ( input.LA(1) )
- {
- case 16:
- {
- alt4=1;
- }
- break;
- case 10:
- {
- alt4=2;
- }
- break;
- case 14:
- {
- alt4=3;
- }
- break;
- case 15:
- {
- alt4=4;
- }
- break;
- case 11:
- {
- alt4=5;
- }
- break;
- case ID:
- {
- alt4=6;
- }
- break;
- case INT:
- {
- alt4=7;
- }
- break;
- case CALL:
- {
- alt4=8;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
-
- }
- finally
- {
- dbg.ExitDecision( 4 );
- }
-
- switch ( alt4 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugTreeGrammar.g3:64:9: ^( '+' a= expr b= expr )
- {
- dbg.Location( 64, 8 );
- dbg.Location( 64, 10 );
- Match(input,16,Follow._16_in_expr172);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 64, 15 );
- PushFollow(Follow._expr_in_expr176);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 64, 22 );
- PushFollow(Follow._expr_in_expr180);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 64, 35 );
- value = a.add(b);
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\DebugTreeGrammar.g3:65:9: ^( '-' a= expr b= expr )
- {
- dbg.Location( 65, 8 );
- dbg.Location( 65, 10 );
- Match(input,10,Follow._10_in_expr200);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 65, 15 );
- PushFollow(Follow._expr_in_expr204);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 65, 22 );
- PushFollow(Follow._expr_in_expr208);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 65, 35 );
- value = a.subtract(b);
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\DebugTreeGrammar.g3:66:9: ^( '*' a= expr b= expr )
- {
- dbg.Location( 66, 8 );
- dbg.Location( 66, 10 );
- Match(input,14,Follow._14_in_expr228);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 66, 15 );
- PushFollow(Follow._expr_in_expr232);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 66, 22 );
- PushFollow(Follow._expr_in_expr236);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 66, 35 );
- value = a.multiply(b);
-
- }
- break;
- case 4:
- dbg.EnterAlt( 4 );
-
- // BuildOptions\\DebugTreeGrammar.g3:67:9: ^( '/' a= expr b= expr )
- {
- dbg.Location( 67, 8 );
- dbg.Location( 67, 10 );
- Match(input,15,Follow._15_in_expr256);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 67, 15 );
- PushFollow(Follow._expr_in_expr260);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 67, 22 );
- PushFollow(Follow._expr_in_expr264);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 67, 35 );
- value = a.divide(b);
-
- }
- break;
- case 5:
- dbg.EnterAlt( 5 );
-
- // BuildOptions\\DebugTreeGrammar.g3:68:9: ^( '%' a= expr b= expr )
- {
- dbg.Location( 68, 8 );
- dbg.Location( 68, 10 );
- Match(input,11,Follow._11_in_expr284);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 68, 15 );
- PushFollow(Follow._expr_in_expr288);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 68, 22 );
- PushFollow(Follow._expr_in_expr292);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 68, 35 );
- value = a.remainder(b);
-
- }
- break;
- case 6:
- dbg.EnterAlt( 6 );
-
- // BuildOptions\\DebugTreeGrammar.g3:69:9: ID
- {
- dbg.Location( 69, 8 );
- ID4=(CommonTree)Match(input,ID,Follow._ID_in_expr311);
- dbg.Location( 69, 35 );
- value = getValue((ID4!=null?ID4.Text:null));
-
- }
- break;
- case 7:
- dbg.EnterAlt( 7 );
-
- // BuildOptions\\DebugTreeGrammar.g3:70:9: INT
- {
- dbg.Location( 70, 8 );
- INT5=(CommonTree)Match(input,INT,Follow._INT_in_expr347);
- dbg.Location( 70, 35 );
- value = new BigInteger((INT5!=null?INT5.Text:null));
-
- }
- break;
- case 8:
- dbg.EnterAlt( 8 );
-
- // BuildOptions\\DebugTreeGrammar.g3:71:9: call
- {
- dbg.Location( 71, 8 );
- PushFollow(Follow._call_in_expr382);
- call6=call();
-
- state._fsp--;
-
- dbg.Location( 71, 35 );
- value = call6;
-
- }
- break;
-
- }
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(72, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "expr" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return value;
- }
- // $ANTLR end "expr"
-
-
- // $ANTLR start "call"
- // BuildOptions\\DebugTreeGrammar.g3:74:0: call returns [BigInteger value] : ^( CALL ID expr ) ;
- private BigInteger call( )
- {
- BigInteger value = default(BigInteger);
-
- CommonTree ID8=null;
- BigInteger expr7 = default(BigInteger);
-
- try
- {
- dbg.EnterRule( GrammarFileName, "call" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 74, -1 );
-
- try
- {
- // BuildOptions\\DebugTreeGrammar.g3:75:9: ( ^( CALL ID expr ) )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\DebugTreeGrammar.g3:75:9: ^( CALL ID expr )
- {
- dbg.Location( 75, 8 );
- dbg.Location( 75, 10 );
- Match(input,CALL,Follow._CALL_in_call430);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 75, 15 );
- ID8=(CommonTree)Match(input,ID,Follow._ID_in_call432);
- dbg.Location( 75, 18 );
- PushFollow(Follow._expr_in_call434);
- expr7=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 75, 35 );
- BigInteger p = expr7;
- CommonTree funcRoot = findFunction((ID8!=null?ID8.Text:null), p);
- if (funcRoot == null) {
- Console.Error.WriteLine("No match found for " + (ID8!=null?ID8.Text:null) + "(" + p + ")");
- } else {
- // Here we set up the local evaluator to run over the
- // function definition with the parameter value.
- // This re-reads a sub-AST of our input AST!
- DebugTreeGrammar e = new DebugTreeGrammar(funcRoot, functionDefinitions, globalMemory, p);
- value = e.expr();
- }
-
-
- }
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(87, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "call" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return value;
- }
- // $ANTLR end "call"
- #endregion Rules
-
-
- #region Follow sets
- private static class Follow
- {
- public static readonly BitSet _stat_in_prog48 = new BitSet(new ulong[]{0x3CCF2UL});
- public static readonly BitSet _expr_in_stat63 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _17_in_stat98 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _ID_in_stat100 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_stat102 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _FUNC_in_stat128 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _16_in_expr172 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr176 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr180 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _10_in_expr200 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr204 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr208 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _14_in_expr228 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr232 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr236 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _15_in_expr256 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr260 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr264 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _11_in_expr284 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr288 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr292 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _ID_in_expr311 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _INT_in_expr347 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _call_in_expr382 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _CALL_in_call430 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _ID_in_call432 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_call434 = new BitSet(new ulong[]{0x8UL});
-
- }
- #endregion Follow sets
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.g3 b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.g3
deleted file mode 100644
index 40ee359..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammar.g3
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-tree grammar DebugTreeGrammar;
-
-options
-{
- language=CSharp3;
- tokenVocab=DebugGrammar;
- ASTLabelType=CommonTree;
-}
-
-// START:members
-@header
-{
-//import java.util.Map;
-//import java.util.HashMap;
-using BigInteger = System.Numerics.BigInteger;
-using Console = System.Console;
-}
-// END:members
-
-@namespace{Antlr3.Runtime.Test.BuildOptions}
-
-// START:rules
-prog: stat*
- ;
-
-stat: expr { string result = $expr.value.ToString();
- Console.Out.WriteLine($expr.value + " (about " + result[0] + "*10^" + (result.Length-1) + ")");
- }
- | ^('=' ID expr) { globalMemory[$ID.text] = $expr.value; }
- | ^(FUNC .+) // ignore FUNCs - we added them to functionDefinitions already in parser.
- ;
-
-expr returns [BigInteger value]
- : ^('+' a=expr b=expr) { $value = $a.value + $b.value; }
- | ^('-' a=expr b=expr) { $value = $a.value - $b.value; }
- | ^('*' a=expr b=expr) { $value = $a.value * $b.value; }
- | ^('/' a=expr b=expr) { $value = $a.value / $b.value; }
- | ^('%' a=expr b=expr) { $value = $a.value \% $b.value; }
- | ID { $value = getValue($ID.text); }
- | INT { $value = BigInteger.Parse($INT.text); }
- | call { $value = $call.value; }
- ;
-
-call returns [BigInteger value]
- : ^(CALL ID expr) { BigInteger p = $expr.value;
- CommonTree funcRoot = findFunction($ID.text, p);
- if (funcRoot == null) {
- Console.Error.WriteLine("No match found for " + $ID.text + "(" + p + ")");
- } else {
- // Here we set up the local evaluator to run over the
- // function definition with the parameter value.
- // This re-reads a sub-AST of our input AST!
- DebugTreeGrammar e = new DebugTreeGrammar(funcRoot, functionDefinitions, globalMemory, p);
- $value = e.expr();
- }
- }
- ;
-// END:rules
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammarHelper.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammarHelper.cs
deleted file mode 100644
index c139aff..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/DebugTreeGrammarHelper.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace Antlr3.Runtime.Test.BuildOptions
-{
- using System.Collections.Generic;
- using Antlr.Runtime.Tree;
-
- using BigInteger = System.Numerics.BigInteger;
- using Console = System.Console;
-
- partial class DebugTreeGrammar
- {
- /** Points to functions tracked by tree builder. */
- private List<CommonTree> functionDefinitions;
-
- /** Remember local variables. Currently, this is only the function parameter.
- */
- private readonly IDictionary<string, BigInteger> localMemory = new Dictionary<string, BigInteger>();
-
- /** Remember global variables set by =. */
- private IDictionary<string, BigInteger> globalMemory = new Dictionary<string, BigInteger>();
-
- /** Set up an evaluator with a node stream; and a set of function definition ASTs. */
- public DebugTreeGrammar(CommonTreeNodeStream nodes, List<CommonTree> functionDefinitions)
- : this(nodes)
- {
- this.functionDefinitions = functionDefinitions;
- }
-
- /** Set up a local evaluator for a nested function call. The evaluator gets the definition
- * tree of the function; the set of all defined functions (to find locally called ones); a
- * pointer to the global variable memory; and the value of the function parameter to be
- * added to the local memory.
- */
- private DebugTreeGrammar(CommonTree function,
- List<CommonTree> functionDefinitions,
- IDictionary<string, BigInteger> globalMemory,
- BigInteger paramValue)
- // Expected tree for function: ^(FUNC ID ( INT | ID ) expr)
- : this(new CommonTreeNodeStream(function.GetChild(2)), functionDefinitions)
- {
- this.globalMemory = globalMemory;
- localMemory[function.GetChild(1).Text] = paramValue;
- }
-
- /** Find matching function definition for a function name and parameter
- * value. The first definition is returned where (a) the name matches
- * and (b) the formal parameter agrees if it is defined as constant.
- */
- private CommonTree findFunction(string name, BigInteger paramValue)
- {
- foreach (CommonTree f in functionDefinitions)
- {
- // Expected tree for f: ^(FUNC ID (ID | INT) expr)
- if (f.GetChild(0).Text.Equals(name))
- {
- // Check whether parameter matches
- CommonTree formalPar = (CommonTree)f.GetChild(1);
- if (formalPar.Token.Type == INT
- && !BigInteger.Parse(formalPar.Token.Text).Equals(paramValue))
- {
- // Constant in formalPar list does not match actual value -> no match.
- continue;
- }
- // Parameter (value for INT formal arg) as well as fct name agrees!
- return f;
- }
- }
- return null;
- }
-
- /** Get value of name up call stack. */
- internal BigInteger getValue(string name)
- {
- BigInteger value;
- if (localMemory.TryGetValue(name, out value) && value != null)
- {
- return value;
- }
- if (globalMemory.TryGetValue(name, out value) && value != null)
- {
- return value;
- }
- // not found in local memory or global memory
- Console.Error.WriteLine("undefined variable " + name);
- return BigInteger.Zero;
- }
- }
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammar.g3 b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammar.g3
deleted file mode 100644
index 9230134..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammar.g3
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-grammar ProfileGrammar;
-
-options
-{
- language=CSharp3;
- output=AST;
- ASTLabelType=CommonTree;
-}
-
-tokens
-{
- // define pseudo-operations
- FUNC;
- CALL;
-}
-
-@lexer::namespace{Antlr3.Runtime.Test.BuildOptions}
-@parser::namespace{Antlr3.Runtime.Test.BuildOptions}
-
-// START:stat
-prog: ( stat )*
- ;
-
-stat: expr NEWLINE -> expr
- | ID '=' expr NEWLINE -> ^('=' ID expr)
- | func NEWLINE -> func
- | NEWLINE -> // ignore
- ;
-
-func: ID '(' formalPar ')' '=' expr -> ^(FUNC ID formalPar expr)
- ;
- finally {
- functionDefinitions.Add($func.tree);
- }
-
-formalPar
- : ID
- | INT
- ;
-
-// END:stat
-
-// START:expr
-expr: multExpr (('+'^|'-'^) multExpr)*
- ;
-
-multExpr
- : atom (('*'|'/'|'%')^ atom)*
- ;
-
-atom: INT
- | ID
- | '(' expr ')' -> expr
- | ID '(' expr ')' -> ^(CALL ID expr)
- ;
-// END:expr
-
-// START:tokens
-ID : ('a'..'z'|'A'..'Z')+
- ;
-
-INT : '0'..'9'+
- ;
-
-NEWLINE
- : '\r'? '\n'
- ;
-
-WS : (' '|'\t')+ { Skip(); }
- ;
-// END:tokens
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexer.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexer.cs
deleted file mode 100644
index dae1ef4..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexer.cs
+++ /dev/null
@@ -1,693 +0,0 @@
-// $ANTLR 3.1.2 BuildOptions\\ProfileGrammar.g3 2009-09-30 13:18:18
-
-// The variable 'variable' is assigned but its value is never used.
-#pragma warning disable 219
-// Unreachable code detected.
-#pragma warning disable 162
-
-
-using System.Collections.Generic;
-using Antlr.Runtime;
-using Stack = System.Collections.Generic.Stack<object>;
-using List = System.Collections.IList;
-using ArrayList = System.Collections.Generic.List<object>;
-
-[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.1.2")]
-[System.CLSCompliant(false)]
-public partial class ProfileGrammarLexer : Lexer
-{
- public const int EOF=-1;
- public const int T__10=10;
- public const int T__11=11;
- public const int T__12=12;
- public const int T__13=13;
- public const int T__14=14;
- public const int T__15=15;
- public const int T__16=16;
- public const int T__17=17;
- public const int CALL=4;
- public const int FUNC=5;
- public const int ID=6;
- public const int INT=7;
- public const int NEWLINE=8;
- public const int WS=9;
-
- // delegates
- // delegators
-
- public ProfileGrammarLexer() {}
- public ProfileGrammarLexer( ICharStream input )
- : this( input, new RecognizerSharedState() )
- {
- }
- public ProfileGrammarLexer( ICharStream input, RecognizerSharedState state )
- : base( input, state )
- {
-
- }
- public override string GrammarFileName { get { return "BuildOptions\\ProfileGrammar.g3"; } }
-
- // $ANTLR start "T__10"
- private void mT__10()
- {
- try
- {
- int _type = T__10;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:7:9: ( '-' )
- // BuildOptions\\ProfileGrammar.g3:7:9: '-'
- {
- Match('-');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__10"
-
- // $ANTLR start "T__11"
- private void mT__11()
- {
- try
- {
- int _type = T__11;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:8:9: ( '%' )
- // BuildOptions\\ProfileGrammar.g3:8:9: '%'
- {
- Match('%');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__11"
-
- // $ANTLR start "T__12"
- private void mT__12()
- {
- try
- {
- int _type = T__12;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:9:9: ( '(' )
- // BuildOptions\\ProfileGrammar.g3:9:9: '('
- {
- Match('(');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__12"
-
- // $ANTLR start "T__13"
- private void mT__13()
- {
- try
- {
- int _type = T__13;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:10:9: ( ')' )
- // BuildOptions\\ProfileGrammar.g3:10:9: ')'
- {
- Match(')');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__13"
-
- // $ANTLR start "T__14"
- private void mT__14()
- {
- try
- {
- int _type = T__14;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:11:9: ( '*' )
- // BuildOptions\\ProfileGrammar.g3:11:9: '*'
- {
- Match('*');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__14"
-
- // $ANTLR start "T__15"
- private void mT__15()
- {
- try
- {
- int _type = T__15;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:12:9: ( '/' )
- // BuildOptions\\ProfileGrammar.g3:12:9: '/'
- {
- Match('/');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__15"
-
- // $ANTLR start "T__16"
- private void mT__16()
- {
- try
- {
- int _type = T__16;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:13:9: ( '+' )
- // BuildOptions\\ProfileGrammar.g3:13:9: '+'
- {
- Match('+');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__16"
-
- // $ANTLR start "T__17"
- private void mT__17()
- {
- try
- {
- int _type = T__17;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:14:9: ( '=' )
- // BuildOptions\\ProfileGrammar.g3:14:9: '='
- {
- Match('=');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "T__17"
-
- // $ANTLR start "ID"
- private void mID()
- {
- try
- {
- int _type = ID;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:88:9: ( ( 'a' .. 'z' | 'A' .. 'Z' )+ )
- // BuildOptions\\ProfileGrammar.g3:88:9: ( 'a' .. 'z' | 'A' .. 'Z' )+
- {
- // BuildOptions\\ProfileGrammar.g3:88:9: ( 'a' .. 'z' | 'A' .. 'Z' )+
- int cnt1=0;
- for ( ; ; )
- {
- int alt1=2;
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>='A' && LA1_0<='Z')||(LA1_0>='a' && LA1_0<='z')) )
- {
- alt1=1;
- }
-
-
- switch ( alt1 )
- {
- case 1:
- // BuildOptions\\ProfileGrammar.g3:
- {
- input.Consume();
-
-
- }
- break;
-
- default:
- if ( cnt1 >= 1 )
- goto loop1;
-
- EarlyExitException eee1 = new EarlyExitException( 1, input );
- throw eee1;
- }
- cnt1++;
- }
- loop1:
- ;
-
-
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "ID"
-
- // $ANTLR start "INT"
- private void mINT()
- {
- try
- {
- int _type = INT;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:91:9: ( ( '0' .. '9' )+ )
- // BuildOptions\\ProfileGrammar.g3:91:9: ( '0' .. '9' )+
- {
- // BuildOptions\\ProfileGrammar.g3:91:9: ( '0' .. '9' )+
- int cnt2=0;
- for ( ; ; )
- {
- int alt2=2;
- int LA2_0 = input.LA(1);
-
- if ( ((LA2_0>='0' && LA2_0<='9')) )
- {
- alt2=1;
- }
-
-
- switch ( alt2 )
- {
- case 1:
- // BuildOptions\\ProfileGrammar.g3:
- {
- input.Consume();
-
-
- }
- break;
-
- default:
- if ( cnt2 >= 1 )
- goto loop2;
-
- EarlyExitException eee2 = new EarlyExitException( 2, input );
- throw eee2;
- }
- cnt2++;
- }
- loop2:
- ;
-
-
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "INT"
-
- // $ANTLR start "NEWLINE"
- private void mNEWLINE()
- {
- try
- {
- int _type = NEWLINE;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:95:7: ( ( '\\r' )? '\\n' )
- // BuildOptions\\ProfileGrammar.g3:95:7: ( '\\r' )? '\\n'
- {
- // BuildOptions\\ProfileGrammar.g3:95:7: ( '\\r' )?
- int alt3=2;
- int LA3_0 = input.LA(1);
-
- if ( (LA3_0=='\r') )
- {
- alt3=1;
- }
- switch ( alt3 )
- {
- case 1:
- // BuildOptions\\ProfileGrammar.g3:95:0: '\\r'
- {
- Match('\r');
-
- }
- break;
-
- }
-
- Match('\n');
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "NEWLINE"
-
- // $ANTLR start "WS"
- private void mWS()
- {
- try
- {
- int _type = WS;
- int _channel = DefaultTokenChannel;
- // BuildOptions\\ProfileGrammar.g3:98:9: ( ( ' ' | '\\t' )+ )
- // BuildOptions\\ProfileGrammar.g3:98:9: ( ' ' | '\\t' )+
- {
- // BuildOptions\\ProfileGrammar.g3:98:9: ( ' ' | '\\t' )+
- int cnt4=0;
- for ( ; ; )
- {
- int alt4=2;
- int LA4_0 = input.LA(1);
-
- if ( (LA4_0=='\t'||LA4_0==' ') )
- {
- alt4=1;
- }
-
-
- switch ( alt4 )
- {
- case 1:
- // BuildOptions\\ProfileGrammar.g3:
- {
- input.Consume();
-
-
- }
- break;
-
- default:
- if ( cnt4 >= 1 )
- goto loop4;
-
- EarlyExitException eee4 = new EarlyExitException( 4, input );
- throw eee4;
- }
- cnt4++;
- }
- loop4:
- ;
-
-
- Skip();
-
- }
-
- state.type = _type;
- state.channel = _channel;
- }
- finally
- {
- }
- }
- // $ANTLR end "WS"
-
- public override void mTokens()
- {
- // BuildOptions\\ProfileGrammar.g3:1:10: ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | ID | INT | NEWLINE | WS )
- int alt5=12;
- switch ( input.LA(1) )
- {
- case '-':
- {
- alt5=1;
- }
- break;
- case '%':
- {
- alt5=2;
- }
- break;
- case '(':
- {
- alt5=3;
- }
- break;
- case ')':
- {
- alt5=4;
- }
- break;
- case '*':
- {
- alt5=5;
- }
- break;
- case '/':
- {
- alt5=6;
- }
- break;
- case '+':
- {
- alt5=7;
- }
- break;
- case '=':
- {
- alt5=8;
- }
- break;
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- case 'G':
- case 'H':
- case 'I':
- case 'J':
- case 'K':
- case 'L':
- case 'M':
- case 'N':
- case 'O':
- case 'P':
- case 'Q':
- case 'R':
- case 'S':
- case 'T':
- case 'U':
- case 'V':
- case 'W':
- case 'X':
- case 'Y':
- case 'Z':
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z':
- {
- alt5=9;
- }
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- alt5=10;
- }
- break;
- case '\n':
- case '\r':
- {
- alt5=11;
- }
- break;
- case '\t':
- case ' ':
- {
- alt5=12;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 5, 0, input);
-
- throw nvae;
- }
- }
-
- switch ( alt5 )
- {
- case 1:
- // BuildOptions\\ProfileGrammar.g3:1:10: T__10
- {
- mT__10();
-
- }
- break;
- case 2:
- // BuildOptions\\ProfileGrammar.g3:1:16: T__11
- {
- mT__11();
-
- }
- break;
- case 3:
- // BuildOptions\\ProfileGrammar.g3:1:22: T__12
- {
- mT__12();
-
- }
- break;
- case 4:
- // BuildOptions\\ProfileGrammar.g3:1:28: T__13
- {
- mT__13();
-
- }
- break;
- case 5:
- // BuildOptions\\ProfileGrammar.g3:1:34: T__14
- {
- mT__14();
-
- }
- break;
- case 6:
- // BuildOptions\\ProfileGrammar.g3:1:40: T__15
- {
- mT__15();
-
- }
- break;
- case 7:
- // BuildOptions\\ProfileGrammar.g3:1:46: T__16
- {
- mT__16();
-
- }
- break;
- case 8:
- // BuildOptions\\ProfileGrammar.g3:1:52: T__17
- {
- mT__17();
-
- }
- break;
- case 9:
- // BuildOptions\\ProfileGrammar.g3:1:58: ID
- {
- mID();
-
- }
- break;
- case 10:
- // BuildOptions\\ProfileGrammar.g3:1:61: INT
- {
- mINT();
-
- }
- break;
- case 11:
- // BuildOptions\\ProfileGrammar.g3:1:65: NEWLINE
- {
- mNEWLINE();
-
- }
- break;
- case 12:
- // BuildOptions\\ProfileGrammar.g3:1:73: WS
- {
- mWS();
-
- }
- break;
-
- }
-
- }
-
-
- #region DFA
-
- protected override void InitDFAs()
- {
- base.InitDFAs();
- }
-
-
- #endregion
-
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexerHelper.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexerHelper.cs
deleted file mode 100644
index 7271295..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarLexerHelper.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * [The "BSD licence"]
- * Copyright (c) 2005-2008 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParser.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParser.cs
deleted file mode 100644
index 5cc9872..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParser.cs
+++ /dev/null
@@ -1,1560 +0,0 @@
-// $ANTLR 3.1.2 BuildOptions\\ProfileGrammar.g3 2009-09-30 13:18:17
-
-// The variable 'variable' is assigned but its value is never used.
-#pragma warning disable 219
-// Unreachable code detected.
-#pragma warning disable 162
-
-
-using System.Collections.Generic;
-using Antlr.Runtime;
-using Stack = System.Collections.Generic.Stack<object>;
-using List = System.Collections.IList;
-using ArrayList = System.Collections.Generic.List<object>;
-
-using Antlr.Runtime.Debug;
-using IOException = System.IO.IOException;
-
-using Antlr.Runtime.Tree;
-using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;
-
-[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.1.2")]
-[System.CLSCompliant(false)]
-public partial class ProfileGrammarParser : DebugParser
-{
- internal static readonly string[] tokenNames = new string[] {
- "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CALL", "FUNC", "ID", "INT", "NEWLINE", "WS", "'-'", "'%'", "'('", "')'", "'*'", "'/'", "'+'", "'='"
- };
- public const int EOF=-1;
- public const int T__10=10;
- public const int T__11=11;
- public const int T__12=12;
- public const int T__13=13;
- public const int T__14=14;
- public const int T__15=15;
- public const int T__16=16;
- public const int T__17=17;
- public const int CALL=4;
- public const int FUNC=5;
- public const int ID=6;
- public const int INT=7;
- public const int NEWLINE=8;
- public const int WS=9;
-
- // delegates
- // delegators
-
- public static readonly string[] ruleNames =
- new string[]
- {
- "invalidRule", "atom", "expr", "formalPar", "func", "multExpr", "prog",
- "stat"
- };
-
- int ruleLevel = 0;
- public virtual int RuleLevel { get { return ruleLevel; } }
- public virtual void IncRuleLevel() { ruleLevel++; }
- public virtual void DecRuleLevel() { ruleLevel--; }
- public ProfileGrammarParser( ITokenStream input )
- : this( input, new Profiler(null), new RecognizerSharedState() )
- {
- }
- public ProfileGrammarParser( ITokenStream input, IDebugEventListener dbg, RecognizerSharedState state )
- : base( input, dbg, state )
- {
- Profiler p = (Profiler)dbg;
- p.setParser(this);
- InitializeTreeAdaptor();
- if ( TreeAdaptor == null )
- TreeAdaptor = new CommonTreeAdaptor();
- ITreeAdaptor adap = new CommonTreeAdaptor();
- TreeAdaptor = adap;
- proxy.TreeAdaptor = adap;
- }
-
- public ProfileGrammarParser( ITokenStream input, IDebugEventListener dbg )
- : base( input, dbg )
- {
- Profiler p = (Profiler)dbg;
- p.setParser(this);InitializeTreeAdaptor();
- if ( TreeAdaptor == null )
- TreeAdaptor = new CommonTreeAdaptor();
-
- ITreeAdaptor adap = new CommonTreeAdaptor();
- TreeAdaptor = adap;
-
- }
- public virtual bool AlreadyParsedRule( IIntStream input, int ruleIndex )
- {
- ((Profiler)dbg).ExamineRuleMemoization(input, ruleIndex, ProfileGrammarParser.ruleNames[ruleIndex]);
- return super.AlreadyParsedRule(input, ruleIndex);
- }
-
- public virtual void Memoize( IIntStream input, int ruleIndex, int ruleStartIndex )
- {
- ((Profiler)dbg).Memoize(input, ruleIndex, ruleStartIndex, ProfileGrammarParser.ruleNames[ruleIndex]);
- super.Memoize(input, ruleIndex, ruleStartIndex);
- }
- protected virtual bool EvalPredicate( bool result, string predicate )
- {
- dbg.SemanticPredicate( result, predicate );
- return result;
- }
-
- // Implement this function in your helper file to use a custom tree adaptor
- partial void InitializeTreeAdaptor();
- protected DebugTreeAdaptor adaptor;
-
- public ITreeAdaptor TreeAdaptor
- {
- get
- {
- return adaptor;
- }
- set
- {
- this.adaptor = new DebugTreeAdaptor(dbg,adaptor);
-
- }
- }
-
-
- public override string[] TokenNames { get { return ProfileGrammarParser.tokenNames; } }
- public override string GrammarFileName { get { return "BuildOptions\\ProfileGrammar.g3"; } }
-
-
- #region Rules
- public class prog_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "prog"
- // BuildOptions\\ProfileGrammar.g3:50:0: prog : ( stat )* ;
- private ProfileGrammarParser.prog_return prog( )
- {
- ProfileGrammarParser.prog_return retval = new ProfileGrammarParser.prog_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- ProfileGrammarParser.stat_return stat1 = default(ProfileGrammarParser.stat_return);
-
-
- try
- {
- dbg.EnterRule( GrammarFileName, "prog" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 50, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:50:7: ( ( stat )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:50:7: ( stat )*
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 50, 6 );
- // BuildOptions\\ProfileGrammar.g3:50:7: ( stat )*
- try
- {
- dbg.EnterSubRule( 1 );
-
- for ( ; ; )
- {
- int alt1=2;
- try
- {
- dbg.EnterDecision( 1 );
-
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>=ID && LA1_0<=NEWLINE)||LA1_0==12) )
- {
- alt1=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 1 );
- }
-
- switch ( alt1 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:50:9: stat
- {
- dbg.Location( 50, 8 );
- PushFollow(Follow._stat_in_prog53);
- stat1=stat();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, stat1.Tree);
-
- }
- break;
-
- default:
- goto loop1;
- }
- }
-
- loop1:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 1 );
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(51, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "prog" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "prog"
-
- public class stat_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "stat"
- // BuildOptions\\ProfileGrammar.g3:53:0: stat : ( expr NEWLINE -> expr | ID '=' expr NEWLINE -> ^( '=' ID expr ) | func NEWLINE -> func | NEWLINE ->);
- private ProfileGrammarParser.stat_return stat( )
- {
- ProfileGrammarParser.stat_return retval = new ProfileGrammarParser.stat_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken NEWLINE3=null;
- IToken ID4=null;
- IToken char_literal5=null;
- IToken NEWLINE7=null;
- IToken NEWLINE9=null;
- IToken NEWLINE10=null;
- ProfileGrammarParser.expr_return expr2 = default(ProfileGrammarParser.expr_return);
- ProfileGrammarParser.expr_return expr6 = default(ProfileGrammarParser.expr_return);
- ProfileGrammarParser.func_return func8 = default(ProfileGrammarParser.func_return);
-
- CommonTree NEWLINE3_tree=null;
- CommonTree ID4_tree=null;
- CommonTree char_literal5_tree=null;
- CommonTree NEWLINE7_tree=null;
- CommonTree NEWLINE9_tree=null;
- CommonTree NEWLINE10_tree=null;
- RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
- RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
- RewriteRuleITokenStream stream_17=new RewriteRuleITokenStream(adaptor,"token 17");
- RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
- RewriteRuleSubtreeStream stream_func=new RewriteRuleSubtreeStream(adaptor,"rule func");
- try
- {
- dbg.EnterRule( GrammarFileName, "stat" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 53, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:53:9: ( expr NEWLINE -> expr | ID '=' expr NEWLINE -> ^( '=' ID expr ) | func NEWLINE -> func | NEWLINE ->)
- int alt2=4;
- try
- {
- dbg.EnterDecision( 2 );
-
- try
- {
- isCyclicDecision = true;
- alt2 = dfa2.Predict(input);
- }
- catch ( NoViableAltException nvae )
- {
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
- finally
- {
- dbg.ExitDecision( 2 );
- }
-
- switch ( alt2 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:53:9: expr NEWLINE
- {
- dbg.Location( 53, 8 );
- PushFollow(Follow._expr_in_stat70);
- expr2=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr2.Tree);
- dbg.Location( 53, 13 );
- NEWLINE3=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat72);
- stream_NEWLINE.Add(NEWLINE3);
-
-
-
- {
- // AST REWRITE
- // elements: expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 53:41: -> expr
- {
- dbg.Location( 53, 43 );
- adaptor.AddChild(root_0, stream_expr.NextTree());
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\ProfileGrammar.g3:54:9: ID '=' expr NEWLINE
- {
- dbg.Location( 54, 8 );
- ID4=(IToken)Match(input,ID,Follow._ID_in_stat105);
- stream_ID.Add(ID4);
-
- dbg.Location( 54, 11 );
- char_literal5=(IToken)Match(input,17,Follow._17_in_stat107);
- stream_17.Add(char_literal5);
-
- dbg.Location( 54, 15 );
- PushFollow(Follow._expr_in_stat109);
- expr6=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr6.Tree);
- dbg.Location( 54, 20 );
- NEWLINE7=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat111);
- stream_NEWLINE.Add(NEWLINE7);
-
-
-
- {
- // AST REWRITE
- // elements: 17, ID, expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 54:41: -> ^( '=' ID expr )
- {
- dbg.Location( 54, 43 );
- // BuildOptions\\ProfileGrammar.g3:54:44: ^( '=' ID expr )
- {
- CommonTree root_1 = (CommonTree)adaptor.Nil();
- dbg.Location( 54, 45 );
- root_1 = (CommonTree)adaptor.BecomeRoot(stream_17.NextNode(), root_1);
-
- dbg.Location( 54, 49 );
- adaptor.AddChild(root_1, stream_ID.NextNode());
- dbg.Location( 54, 52 );
- adaptor.AddChild(root_1, stream_expr.NextTree());
-
- adaptor.AddChild(root_0, root_1);
- }
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\ProfileGrammar.g3:55:9: func NEWLINE
- {
- dbg.Location( 55, 8 );
- PushFollow(Follow._func_in_stat143);
- func8=func();
-
- state._fsp--;
-
- stream_func.Add(func8.Tree);
- dbg.Location( 55, 13 );
- NEWLINE9=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat145);
- stream_NEWLINE.Add(NEWLINE9);
-
-
-
- {
- // AST REWRITE
- // elements: func
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 55:41: -> func
- {
- dbg.Location( 55, 43 );
- adaptor.AddChild(root_0, stream_func.NextTree());
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 4:
- dbg.EnterAlt( 4 );
-
- // BuildOptions\\ProfileGrammar.g3:56:9: NEWLINE
- {
- dbg.Location( 56, 8 );
- NEWLINE10=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_stat178);
- stream_NEWLINE.Add(NEWLINE10);
-
-
-
- {
- // AST REWRITE
- // elements:
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 56:41: ->
- {
- dbg.Location( 57, 4 );
- root_0 = null;
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(57, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "stat" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "stat"
-
- public class func_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "func"
- // BuildOptions\\ProfileGrammar.g3:59:0: func : ID '(' formalPar ')' '=' expr -> ^( FUNC ID formalPar expr ) ;
- private ProfileGrammarParser.func_return func( )
- {
- ProfileGrammarParser.func_return retval = new ProfileGrammarParser.func_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken ID11=null;
- IToken char_literal12=null;
- IToken char_literal14=null;
- IToken char_literal15=null;
- ProfileGrammarParser.formalPar_return formalPar13 = default(ProfileGrammarParser.formalPar_return);
- ProfileGrammarParser.expr_return expr16 = default(ProfileGrammarParser.expr_return);
-
- CommonTree ID11_tree=null;
- CommonTree char_literal12_tree=null;
- CommonTree char_literal14_tree=null;
- CommonTree char_literal15_tree=null;
- RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
- RewriteRuleITokenStream stream_12=new RewriteRuleITokenStream(adaptor,"token 12");
- RewriteRuleITokenStream stream_13=new RewriteRuleITokenStream(adaptor,"token 13");
- RewriteRuleITokenStream stream_17=new RewriteRuleITokenStream(adaptor,"token 17");
- RewriteRuleSubtreeStream stream_formalPar=new RewriteRuleSubtreeStream(adaptor,"rule formalPar");
- RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
- try
- {
- dbg.EnterRule( GrammarFileName, "func" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 59, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:59:9: ( ID '(' formalPar ')' '=' expr -> ^( FUNC ID formalPar expr ) )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:59:9: ID '(' formalPar ')' '=' expr
- {
- dbg.Location( 59, 8 );
- ID11=(IToken)Match(input,ID,Follow._ID_in_func219);
- stream_ID.Add(ID11);
-
- dbg.Location( 59, 12 );
- char_literal12=(IToken)Match(input,12,Follow._12_in_func222);
- stream_12.Add(char_literal12);
-
- dbg.Location( 59, 16 );
- PushFollow(Follow._formalPar_in_func224);
- formalPar13=formalPar();
-
- state._fsp--;
-
- stream_formalPar.Add(formalPar13.Tree);
- dbg.Location( 59, 26 );
- char_literal14=(IToken)Match(input,13,Follow._13_in_func226);
- stream_13.Add(char_literal14);
-
- dbg.Location( 59, 30 );
- char_literal15=(IToken)Match(input,17,Follow._17_in_func228);
- stream_17.Add(char_literal15);
-
- dbg.Location( 59, 34 );
- PushFollow(Follow._expr_in_func230);
- expr16=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr16.Tree);
-
-
- {
- // AST REWRITE
- // elements: ID, formalPar, expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 59:41: -> ^( FUNC ID formalPar expr )
- {
- dbg.Location( 59, 43 );
- // BuildOptions\\ProfileGrammar.g3:59:44: ^( FUNC ID formalPar expr )
- {
- CommonTree root_1 = (CommonTree)adaptor.Nil();
- dbg.Location( 59, 45 );
- root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(FUNC, "FUNC"), root_1);
-
- dbg.Location( 59, 50 );
- adaptor.AddChild(root_1, stream_ID.NextNode());
- dbg.Location( 59, 53 );
- adaptor.AddChild(root_1, stream_formalPar.NextTree());
- dbg.Location( 59, 63 );
- adaptor.AddChild(root_1, stream_expr.NextTree());
-
- adaptor.AddChild(root_0, root_1);
- }
-
- }
-
- retval.tree = root_0;
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
-
- functionDefinitions.Add(((CommonTree)retval.Tree));
-
- }
- dbg.Location(60, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "func" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "func"
-
- public class formalPar_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "formalPar"
- // BuildOptions\\ProfileGrammar.g3:65:0: formalPar : ( ID | INT );
- private ProfileGrammarParser.formalPar_return formalPar( )
- {
- ProfileGrammarParser.formalPar_return retval = new ProfileGrammarParser.formalPar_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken set17=null;
-
- CommonTree set17_tree=null;
-
- try
- {
- dbg.EnterRule( GrammarFileName, "formalPar" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 65, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:66:9: ( ID | INT )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 66, 8 );
- set17=(IToken)input.LT(1);
- if ( (input.LA(1)>=ID && input.LA(1)<=INT) )
- {
- input.Consume();
- adaptor.AddChild(root_0, (CommonTree)adaptor.Create(set17));
- state.errorRecovery=false;
- }
- else
- {
- MismatchedSetException mse = new MismatchedSetException(null,input);
- dbg.RecognitionException( mse );
- throw mse;
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(68, 1);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "formalPar" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "formalPar"
-
- public class expr_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "expr"
- // BuildOptions\\ProfileGrammar.g3:73:0: expr : multExpr ( ( '+' | '-' ) multExpr )* ;
- private ProfileGrammarParser.expr_return expr( )
- {
- ProfileGrammarParser.expr_return retval = new ProfileGrammarParser.expr_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken char_literal19=null;
- IToken char_literal20=null;
- ProfileGrammarParser.multExpr_return multExpr18 = default(ProfileGrammarParser.multExpr_return);
- ProfileGrammarParser.multExpr_return multExpr21 = default(ProfileGrammarParser.multExpr_return);
-
- CommonTree char_literal19_tree=null;
- CommonTree char_literal20_tree=null;
-
- try
- {
- dbg.EnterRule( GrammarFileName, "expr" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 73, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:73:9: ( multExpr ( ( '+' | '-' ) multExpr )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:73:9: multExpr ( ( '+' | '-' ) multExpr )*
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 73, 8 );
- PushFollow(Follow._multExpr_in_expr288);
- multExpr18=multExpr();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, multExpr18.Tree);
- dbg.Location( 73, 17 );
- // BuildOptions\\ProfileGrammar.g3:73:18: ( ( '+' | '-' ) multExpr )*
- try
- {
- dbg.EnterSubRule( 4 );
-
- for ( ; ; )
- {
- int alt4=2;
- try
- {
- dbg.EnterDecision( 4 );
-
- int LA4_0 = input.LA(1);
-
- if ( (LA4_0==10||LA4_0==16) )
- {
- alt4=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 4 );
- }
-
- switch ( alt4 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:73:19: ( '+' | '-' ) multExpr
- {
- dbg.Location( 73, 18 );
- // BuildOptions\\ProfileGrammar.g3:73:19: ( '+' | '-' )
- int alt3=2;
- try
- {
- dbg.EnterSubRule( 3 );
- try
- {
- dbg.EnterDecision( 3 );
-
- int LA3_0 = input.LA(1);
-
- if ( (LA3_0==16) )
- {
- alt3=1;
- }
- else if ( (LA3_0==10) )
- {
- alt3=2;
- }
- else
- {
- NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
- finally
- {
- dbg.ExitDecision( 3 );
- }
-
- switch ( alt3 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:73:20: '+'
- {
- dbg.Location( 73, 22 );
- char_literal19=(IToken)Match(input,16,Follow._16_in_expr292);
- char_literal19_tree = (CommonTree)adaptor.Create(char_literal19);
- root_0 = (CommonTree)adaptor.BecomeRoot(char_literal19_tree, root_0);
-
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\ProfileGrammar.g3:73:25: '-'
- {
- dbg.Location( 73, 27 );
- char_literal20=(IToken)Match(input,10,Follow._10_in_expr295);
- char_literal20_tree = (CommonTree)adaptor.Create(char_literal20);
- root_0 = (CommonTree)adaptor.BecomeRoot(char_literal20_tree, root_0);
-
-
- }
- break;
-
- }
- }
- finally
- {
- dbg.ExitSubRule( 3 );
- }
-
- dbg.Location( 73, 30 );
- PushFollow(Follow._multExpr_in_expr299);
- multExpr21=multExpr();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, multExpr21.Tree);
-
- }
- break;
-
- default:
- goto loop4;
- }
- }
-
- loop4:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 4 );
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(74, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "expr" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "expr"
-
- public class multExpr_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "multExpr"
- // BuildOptions\\ProfileGrammar.g3:76:0: multExpr : atom ( ( '*' | '/' | '%' ) atom )* ;
- private ProfileGrammarParser.multExpr_return multExpr( )
- {
- ProfileGrammarParser.multExpr_return retval = new ProfileGrammarParser.multExpr_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken set23=null;
- ProfileGrammarParser.atom_return atom22 = default(ProfileGrammarParser.atom_return);
- ProfileGrammarParser.atom_return atom24 = default(ProfileGrammarParser.atom_return);
-
- CommonTree set23_tree=null;
-
- try
- {
- dbg.EnterRule( GrammarFileName, "multExpr" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 76, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:77:9: ( atom ( ( '*' | '/' | '%' ) atom )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:77:9: atom ( ( '*' | '/' | '%' ) atom )*
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 77, 8 );
- PushFollow(Follow._atom_in_multExpr320);
- atom22=atom();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, atom22.Tree);
- dbg.Location( 77, 13 );
- // BuildOptions\\ProfileGrammar.g3:77:14: ( ( '*' | '/' | '%' ) atom )*
- try
- {
- dbg.EnterSubRule( 5 );
-
- for ( ; ; )
- {
- int alt5=2;
- try
- {
- dbg.EnterDecision( 5 );
-
- int LA5_0 = input.LA(1);
-
- if ( (LA5_0==11||(LA5_0>=14 && LA5_0<=15)) )
- {
- alt5=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 5 );
- }
-
- switch ( alt5 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:77:15: ( '*' | '/' | '%' ) atom
- {
- dbg.Location( 77, 27 );
- set23=(IToken)input.LT(1);
- set23=(IToken)input.LT(1);
- if ( input.LA(1)==11||(input.LA(1)>=14 && input.LA(1)<=15) )
- {
- input.Consume();
- root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set23), root_0);
- state.errorRecovery=false;
- }
- else
- {
- MismatchedSetException mse = new MismatchedSetException(null,input);
- dbg.RecognitionException( mse );
- throw mse;
- }
-
- dbg.Location( 77, 29 );
- PushFollow(Follow._atom_in_multExpr332);
- atom24=atom();
-
- state._fsp--;
-
- adaptor.AddChild(root_0, atom24.Tree);
-
- }
- break;
-
- default:
- goto loop5;
- }
- }
-
- loop5:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 5 );
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(78, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "multExpr" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "multExpr"
-
- public class atom_return : ParserRuleReturnScope
- {
- internal CommonTree tree;
- public override object Tree { get { return tree; } }
- }
-
- // $ANTLR start "atom"
- // BuildOptions\\ProfileGrammar.g3:80:0: atom : ( INT | ID | '(' expr ')' -> expr | ID '(' expr ')' -> ^( CALL ID expr ) );
- private ProfileGrammarParser.atom_return atom( )
- {
- ProfileGrammarParser.atom_return retval = new ProfileGrammarParser.atom_return();
- retval.start = input.LT(1);
-
- CommonTree root_0 = null;
-
- IToken INT25=null;
- IToken ID26=null;
- IToken char_literal27=null;
- IToken char_literal29=null;
- IToken ID30=null;
- IToken char_literal31=null;
- IToken char_literal33=null;
- ProfileGrammarParser.expr_return expr28 = default(ProfileGrammarParser.expr_return);
- ProfileGrammarParser.expr_return expr32 = default(ProfileGrammarParser.expr_return);
-
- CommonTree INT25_tree=null;
- CommonTree ID26_tree=null;
- CommonTree char_literal27_tree=null;
- CommonTree char_literal29_tree=null;
- CommonTree ID30_tree=null;
- CommonTree char_literal31_tree=null;
- CommonTree char_literal33_tree=null;
- RewriteRuleITokenStream stream_12=new RewriteRuleITokenStream(adaptor,"token 12");
- RewriteRuleITokenStream stream_13=new RewriteRuleITokenStream(adaptor,"token 13");
- RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
- RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
- try
- {
- dbg.EnterRule( GrammarFileName, "atom" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 80, -1 );
-
- try
- {
- // BuildOptions\\ProfileGrammar.g3:80:9: ( INT | ID | '(' expr ')' -> expr | ID '(' expr ')' -> ^( CALL ID expr ) )
- int alt6=4;
- try
- {
- dbg.EnterDecision( 6 );
-
- switch ( input.LA(1) )
- {
- case INT:
- {
- alt6=1;
- }
- break;
- case ID:
- {
- int LA6_2 = input.LA(2);
-
- if ( (LA6_2==12) )
- {
- alt6=4;
- }
- else if ( (LA6_2==NEWLINE||(LA6_2>=10 && LA6_2<=11)||(LA6_2>=13 && LA6_2<=16)) )
- {
- alt6=2;
- }
- else
- {
- NoViableAltException nvae = new NoViableAltException("", 6, 2, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
- break;
- case 12:
- {
- alt6=3;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 6, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
-
- }
- finally
- {
- dbg.ExitDecision( 6 );
- }
-
- switch ( alt6 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileGrammar.g3:80:9: INT
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 80, 8 );
- INT25=(IToken)Match(input,INT,Follow._INT_in_atom348);
- INT25_tree = (CommonTree)adaptor.Create(INT25);
- adaptor.AddChild(root_0, INT25_tree);
-
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\ProfileGrammar.g3:81:9: ID
- {
- root_0 = (CommonTree)adaptor.Nil();
-
- dbg.Location( 81, 8 );
- ID26=(IToken)Match(input,ID,Follow._ID_in_atom358);
- ID26_tree = (CommonTree)adaptor.Create(ID26);
- adaptor.AddChild(root_0, ID26_tree);
-
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\ProfileGrammar.g3:82:9: '(' expr ')'
- {
- dbg.Location( 82, 8 );
- char_literal27=(IToken)Match(input,12,Follow._12_in_atom368);
- stream_12.Add(char_literal27);
-
- dbg.Location( 82, 12 );
- PushFollow(Follow._expr_in_atom370);
- expr28=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr28.Tree);
- dbg.Location( 82, 17 );
- char_literal29=(IToken)Match(input,13,Follow._13_in_atom372);
- stream_13.Add(char_literal29);
-
-
-
- {
- // AST REWRITE
- // elements: expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 82:25: -> expr
- {
- dbg.Location( 82, 27 );
- adaptor.AddChild(root_0, stream_expr.NextTree());
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
- case 4:
- dbg.EnterAlt( 4 );
-
- // BuildOptions\\ProfileGrammar.g3:83:9: ID '(' expr ')'
- {
- dbg.Location( 83, 8 );
- ID30=(IToken)Match(input,ID,Follow._ID_in_atom389);
- stream_ID.Add(ID30);
-
- dbg.Location( 83, 11 );
- char_literal31=(IToken)Match(input,12,Follow._12_in_atom391);
- stream_12.Add(char_literal31);
-
- dbg.Location( 83, 15 );
- PushFollow(Follow._expr_in_atom393);
- expr32=expr();
-
- state._fsp--;
-
- stream_expr.Add(expr32.Tree);
- dbg.Location( 83, 20 );
- char_literal33=(IToken)Match(input,13,Follow._13_in_atom395);
- stream_13.Add(char_literal33);
-
-
-
- {
- // AST REWRITE
- // elements: ID, expr
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- // wildcard labels:
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
-
- root_0 = (CommonTree)adaptor.Nil();
- // 83:25: -> ^( CALL ID expr )
- {
- dbg.Location( 83, 27 );
- // BuildOptions\\ProfileGrammar.g3:83:28: ^( CALL ID expr )
- {
- CommonTree root_1 = (CommonTree)adaptor.Nil();
- dbg.Location( 83, 29 );
- root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(CALL, "CALL"), root_1);
-
- dbg.Location( 83, 34 );
- adaptor.AddChild(root_1, stream_ID.NextNode());
- dbg.Location( 83, 37 );
- adaptor.AddChild(root_1, stream_expr.NextTree());
-
- adaptor.AddChild(root_0, root_1);
- }
-
- }
-
- retval.tree = root_0;
- }
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
- adaptor.SetTokenBoundaries(retval.tree, retval.start, retval.stop);
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- retval.tree = (CommonTree)adaptor.ErrorNode(input, retval.start, input.LT(-1), re);
-
- }
- finally
- {
- }
- dbg.Location(84, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "atom" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return retval;
- }
- // $ANTLR end "atom"
- #endregion Rules
-
-
- #region DFA
- DFA2 dfa2;
-
- protected override void InitDFAs()
- {
- base.InitDFAs();
- dfa2 = new DFA2( this );
- }
-
- class DFA2 : DFA
- {
-
- const string DFA2_eotS =
- "\xA\xFFFF";
- const string DFA2_eofS =
- "\xA\xFFFF";
- const string DFA2_minS =
- "\x1\x6\x1\xFFFF\x1\x8\x1\xFFFF\x1\x6\x1\xFFFF\x2\xA\x1\x8\x1\xFFFF";
- const string DFA2_maxS =
- "\x1\xC\x1\xFFFF\x1\x11\x1\xFFFF\x1\xC\x1\xFFFF\x2\x10\x1\x11\x1\xFFFF";
- const string DFA2_acceptS =
- "\x1\xFFFF\x1\x1\x1\xFFFF\x1\x4\x1\xFFFF\x1\x2\x3\xFFFF\x1\x3";
- const string DFA2_specialS =
- "\xA\xFFFF}>";
- static readonly string[] DFA2_transitionS =
- {
- "\x1\x2\x1\x1\x1\x3\x3\xFFFF\x1\x1",
- "",
- "\x1\x1\x1\xFFFF\x2\x1\x1\x4\x1\xFFFF\x3\x1\x1\x5",
- "",
- "\x1\x7\x1\x6\x4\xFFFF\x1\x1",
- "",
- "\x2\x1\x1\xFFFF\x1\x8\x3\x1",
- "\x3\x1\x1\x8\x3\x1",
- "\x1\x1\x1\xFFFF\x2\x1\x2\xFFFF\x3\x1\x1\x9",
- ""
- };
-
- static readonly short[] DFA2_eot = DFA.UnpackEncodedString(DFA2_eotS);
- static readonly short[] DFA2_eof = DFA.UnpackEncodedString(DFA2_eofS);
- static readonly char[] DFA2_min = DFA.UnpackEncodedStringToUnsignedChars(DFA2_minS);
- static readonly char[] DFA2_max = DFA.UnpackEncodedStringToUnsignedChars(DFA2_maxS);
- static readonly short[] DFA2_accept = DFA.UnpackEncodedString(DFA2_acceptS);
- static readonly short[] DFA2_special = DFA.UnpackEncodedString(DFA2_specialS);
- static readonly short[][] DFA2_transition;
-
- static DFA2()
- {
- int numStates = DFA2_transitionS.Length;
- DFA2_transition = new short[numStates][];
- for ( int i=0; i < numStates; i++ )
- {
- DFA2_transition[i] = DFA.UnpackEncodedString(DFA2_transitionS[i]);
- }
- }
-
- public DFA2( BaseRecognizer recognizer )
- {
- this.recognizer = recognizer;
- this.decisionNumber = 2;
- this.eot = DFA2_eot;
- this.eof = DFA2_eof;
- this.min = DFA2_min;
- this.max = DFA2_max;
- this.accept = DFA2_accept;
- this.special = DFA2_special;
- this.transition = DFA2_transition;
- }
- public override string GetDescription()
- {
- return "53:0: stat : ( expr NEWLINE -> expr | ID '=' expr NEWLINE -> ^( '=' ID expr ) | func NEWLINE -> func | NEWLINE ->);";
- }
- public override void Error( NoViableAltException nvae )
- {
- ((DebugParser)recognizer).dbg.RecognitionException( nvae );
- }
- }
-
-
- #endregion DFA
-
- #region Follow sets
- private static class Follow
- {
- public static readonly BitSet _stat_in_prog53 = new BitSet(new ulong[]{0x11C2UL});
- public static readonly BitSet _expr_in_stat70 = new BitSet(new ulong[]{0x100UL});
- public static readonly BitSet _NEWLINE_in_stat72 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_stat105 = new BitSet(new ulong[]{0x20000UL});
- public static readonly BitSet _17_in_stat107 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_stat109 = new BitSet(new ulong[]{0x100UL});
- public static readonly BitSet _NEWLINE_in_stat111 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _func_in_stat143 = new BitSet(new ulong[]{0x100UL});
- public static readonly BitSet _NEWLINE_in_stat145 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _NEWLINE_in_stat178 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_func219 = new BitSet(new ulong[]{0x1000UL});
- public static readonly BitSet _12_in_func222 = new BitSet(new ulong[]{0xC0UL});
- public static readonly BitSet _formalPar_in_func224 = new BitSet(new ulong[]{0x2000UL});
- public static readonly BitSet _13_in_func226 = new BitSet(new ulong[]{0x20000UL});
- public static readonly BitSet _17_in_func228 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_func230 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _set_in_formalPar267 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _multExpr_in_expr288 = new BitSet(new ulong[]{0x10402UL});
- public static readonly BitSet _16_in_expr292 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _10_in_expr295 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _multExpr_in_expr299 = new BitSet(new ulong[]{0x10402UL});
- public static readonly BitSet _atom_in_multExpr320 = new BitSet(new ulong[]{0xC802UL});
- public static readonly BitSet _set_in_multExpr323 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _atom_in_multExpr332 = new BitSet(new ulong[]{0xC802UL});
- public static readonly BitSet _INT_in_atom348 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_atom358 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _12_in_atom368 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_atom370 = new BitSet(new ulong[]{0x2000UL});
- public static readonly BitSet _13_in_atom372 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _ID_in_atom389 = new BitSet(new ulong[]{0x1000UL});
- public static readonly BitSet _12_in_atom391 = new BitSet(new ulong[]{0x10C0UL});
- public static readonly BitSet _expr_in_atom393 = new BitSet(new ulong[]{0x2000UL});
- public static readonly BitSet _13_in_atom395 = new BitSet(new ulong[]{0x2UL});
-
- }
- #endregion Follow sets
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParserHelper.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParserHelper.cs
deleted file mode 100644
index 205a088..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileGrammarParserHelper.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace Antlr3.Runtime.Test.BuildOptions
-{
- using System.Collections.Generic;
- using Antlr.Runtime.Tree;
-
- partial class ProfileGrammarParser
- {
- /** List of function definitions. Must point at the FUNC nodes. */
- List<CommonTree> functionDefinitions = new List<CommonTree>();
- }
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.cs
deleted file mode 100644
index 3608faf..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.cs
+++ /dev/null
@@ -1,850 +0,0 @@
-// $ANTLR 3.1.2 BuildOptions\\ProfileTreeGrammar.g3 2009-09-30 13:18:19
-
-// The variable 'variable' is assigned but its value is never used.
-#pragma warning disable 219
-// Unreachable code detected.
-#pragma warning disable 162
-
-
-//import java.util.Map;
-//import java.util.HashMap;
-using BigInteger = java.math.BigInteger;
-using Console = System.Console;
-
-
-using System.Collections.Generic;
-using Antlr.Runtime;
-using Antlr.Runtime.Tree;
-using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;using Stack = System.Collections.Generic.Stack<object>;
-using List = System.Collections.IList;
-using ArrayList = System.Collections.Generic.List<object>;
-
-using Antlr.Runtime.Debug;
-using IOException = System.IO.IOException;
-[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.1.2")]
-[System.CLSCompliant(false)]
-public partial class ProfileTreeGrammar : DebugTreeParser
-{
- internal static readonly string[] tokenNames = new string[] {
- "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CALL", "FUNC", "ID", "INT", "NEWLINE", "WS", "'-'", "'%'", "'('", "')'", "'*'", "'/'", "'+'", "'='"
- };
- public const int EOF=-1;
- public const int T__10=10;
- public const int T__11=11;
- public const int T__12=12;
- public const int T__13=13;
- public const int T__14=14;
- public const int T__15=15;
- public const int T__16=16;
- public const int T__17=17;
- public const int CALL=4;
- public const int FUNC=5;
- public const int ID=6;
- public const int INT=7;
- public const int NEWLINE=8;
- public const int WS=9;
-
- // delegates
- // delegators
-
- public static readonly string[] ruleNames =
- new string[]
- {
- "invalidRule", "call", "expr", "prog", "stat"
- };
-
- int ruleLevel = 0;
- public virtual int RuleLevel { get { return ruleLevel; } }
- public virtual void IncRuleLevel() { ruleLevel++; }
- public virtual void DecRuleLevel() { ruleLevel--; }
- public ProfileTreeGrammar( ITreeNodeStream input )
- : this( input, new Profiler(null), new RecognizerSharedState() )
- {
- }
- public ProfileTreeGrammar( ITreeNodeStream input, IDebugEventListener dbg, RecognizerSharedState state )
- : base( input, dbg, state )
- {
- Profiler p = (Profiler)dbg;
- p.setParser(this);
- }
-
- public ProfileTreeGrammar( ITreeNodeStream input, IDebugEventListener dbg )
- : base( input, dbg, new RecognizerSharedState() )
- {
- Profiler p = (Profiler)dbg;
- p.setParser(this);
- }
- public virtual bool AlreadyParsedRule( IIntStream input, int ruleIndex )
- {
- ((Profiler)dbg).ExamineRuleMemoization(input, ruleIndex, ProfileTreeGrammar.ruleNames[ruleIndex]);
- return super.AlreadyParsedRule(input, ruleIndex);
- }
-
- public virtual void Memoize( IIntStream input, int ruleIndex, int ruleStartIndex )
- {
- ((Profiler)dbg).Memoize(input, ruleIndex, ruleStartIndex, ProfileTreeGrammar.ruleNames[ruleIndex]);
- super.Memoize(input, ruleIndex, ruleStartIndex);
- }
- protected virtual bool EvalPredicate( bool result, string predicate )
- {
- dbg.SemanticPredicate( result, predicate );
- return result;
- }
-
-
- public override string[] TokenNames { get { return ProfileTreeGrammar.tokenNames; } }
- public override string GrammarFileName { get { return "BuildOptions\\ProfileTreeGrammar.g3"; } }
-
-
- #region Rules
-
- // $ANTLR start "prog"
- // BuildOptions\\ProfileTreeGrammar.g3:53:0: prog : ( stat )* ;
- private void prog( )
- {
- try
- {
- dbg.EnterRule( GrammarFileName, "prog" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 53, -1 );
-
- try
- {
- // BuildOptions\\ProfileTreeGrammar.g3:53:9: ( ( stat )* )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:53:9: ( stat )*
- {
- dbg.Location( 53, 8 );
- // BuildOptions\\ProfileTreeGrammar.g3:53:9: ( stat )*
- try
- {
- dbg.EnterSubRule( 1 );
-
- for ( ; ; )
- {
- int alt1=2;
- try
- {
- dbg.EnterDecision( 1 );
-
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>=CALL && LA1_0<=INT)||(LA1_0>=10 && LA1_0<=11)||(LA1_0>=14 && LA1_0<=17)) )
- {
- alt1=1;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 1 );
- }
-
- switch ( alt1 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:53:0: stat
- {
- dbg.Location( 53, 8 );
- PushFollow(Follow._stat_in_prog48);
- stat();
-
- state._fsp--;
-
-
- }
- break;
-
- default:
- goto loop1;
- }
- }
-
- loop1:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 1 );
- }
-
-
- }
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(54, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "prog" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return ;
- }
- // $ANTLR end "prog"
-
-
- // $ANTLR start "stat"
- // BuildOptions\\ProfileTreeGrammar.g3:56:0: stat : ( expr | ^( '=' ID expr ) | ^( FUNC ( . )+ ) );
- private void stat( )
- {
- CommonTree ID2=null;
- BigInteger expr1 = default(BigInteger);
- BigInteger expr3 = default(BigInteger);
-
- try
- {
- dbg.EnterRule( GrammarFileName, "stat" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 56, -1 );
-
- try
- {
- // BuildOptions\\ProfileTreeGrammar.g3:56:9: ( expr | ^( '=' ID expr ) | ^( FUNC ( . )+ ) )
- int alt3=3;
- try
- {
- dbg.EnterDecision( 3 );
-
- switch ( input.LA(1) )
- {
- case CALL:
- case ID:
- case INT:
- case 10:
- case 11:
- case 14:
- case 15:
- case 16:
- {
- alt3=1;
- }
- break;
- case 17:
- {
- alt3=2;
- }
- break;
- case FUNC:
- {
- alt3=3;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
-
- }
- finally
- {
- dbg.ExitDecision( 3 );
- }
-
- switch ( alt3 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:56:9: expr
- {
- dbg.Location( 56, 8 );
- PushFollow(Follow._expr_in_stat63);
- expr1=expr();
-
- state._fsp--;
-
- dbg.Location( 56, 35 );
- string result = expr1.ToString();
- Console.Out.WriteLine(expr1 + " (about " + result[0] + "*10^" + (result.Length-1) + ")");
-
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:59:9: ^( '=' ID expr )
- {
- dbg.Location( 59, 8 );
- dbg.Location( 59, 10 );
- Match(input,17,Follow._17_in_stat98);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 59, 14 );
- ID2=(CommonTree)Match(input,ID,Follow._ID_in_stat100);
- dbg.Location( 59, 17 );
- PushFollow(Follow._expr_in_stat102);
- expr3=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 59, 35 );
- globalMemory[(ID2!=null?ID2.Text:null)] = expr3;
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:60:9: ^( FUNC ( . )+ )
- {
- dbg.Location( 60, 8 );
- dbg.Location( 60, 10 );
- Match(input,FUNC,Follow._FUNC_in_stat128);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 60, 15 );
- // BuildOptions\\ProfileTreeGrammar.g3:60:16: ( . )+
- int cnt2=0;
- try
- {
- dbg.EnterSubRule( 2 );
-
- for ( ; ; )
- {
- int alt2=2;
- try
- {
- dbg.EnterDecision( 2 );
-
- int LA2_0 = input.LA(1);
-
- if ( ((LA2_0>=CALL && LA2_0<=17)) )
- {
- alt2=1;
- }
- else if ( (LA2_0==UP) )
- {
- alt2=2;
- }
-
-
- }
- finally
- {
- dbg.ExitDecision( 2 );
- }
-
- switch ( alt2 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:60:0: .
- {
- dbg.Location( 60, 15 );
- MatchAny(input);
-
- }
- break;
-
- default:
- if ( cnt2 >= 1 )
- goto loop2;
-
- EarlyExitException eee2 = new EarlyExitException( 2, input );
- dbg.RecognitionException( eee2 );
-
- throw eee2;
- }
- cnt2++;
- }
- loop2:
- ;
-
- }
- finally
- {
- dbg.ExitSubRule( 2 );
- }
-
-
- Match(input, TokenTypes.Up, null);
-
- }
- break;
-
- }
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(61, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "stat" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return ;
- }
- // $ANTLR end "stat"
-
-
- // $ANTLR start "expr"
- // BuildOptions\\ProfileTreeGrammar.g3:63:0: expr returns [BigInteger value] : ( ^( '+' a= expr b= expr ) | ^( '-' a= expr b= expr ) | ^( '*' a= expr b= expr ) | ^( '/' a= expr b= expr ) | ^( '%' a= expr b= expr ) | ID | INT | call );
- private BigInteger expr( )
- {
- BigInteger value = default(BigInteger);
-
- CommonTree ID4=null;
- CommonTree INT5=null;
- BigInteger a = default(BigInteger);
- BigInteger b = default(BigInteger);
- BigInteger call6 = default(BigInteger);
-
- try
- {
- dbg.EnterRule( GrammarFileName, "expr" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 63, -1 );
-
- try
- {
- // BuildOptions\\ProfileTreeGrammar.g3:64:9: ( ^( '+' a= expr b= expr ) | ^( '-' a= expr b= expr ) | ^( '*' a= expr b= expr ) | ^( '/' a= expr b= expr ) | ^( '%' a= expr b= expr ) | ID | INT | call )
- int alt4=8;
- try
- {
- dbg.EnterDecision( 4 );
-
- switch ( input.LA(1) )
- {
- case 16:
- {
- alt4=1;
- }
- break;
- case 10:
- {
- alt4=2;
- }
- break;
- case 14:
- {
- alt4=3;
- }
- break;
- case 15:
- {
- alt4=4;
- }
- break;
- case 11:
- {
- alt4=5;
- }
- break;
- case ID:
- {
- alt4=6;
- }
- break;
- case INT:
- {
- alt4=7;
- }
- break;
- case CALL:
- {
- alt4=8;
- }
- break;
- default:
- {
- NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
-
- dbg.RecognitionException( nvae );
- throw nvae;
- }
- }
-
- }
- finally
- {
- dbg.ExitDecision( 4 );
- }
-
- switch ( alt4 )
- {
- case 1:
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:64:9: ^( '+' a= expr b= expr )
- {
- dbg.Location( 64, 8 );
- dbg.Location( 64, 10 );
- Match(input,16,Follow._16_in_expr172);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 64, 15 );
- PushFollow(Follow._expr_in_expr176);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 64, 22 );
- PushFollow(Follow._expr_in_expr180);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 64, 35 );
- value = a.add(b);
-
- }
- break;
- case 2:
- dbg.EnterAlt( 2 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:65:9: ^( '-' a= expr b= expr )
- {
- dbg.Location( 65, 8 );
- dbg.Location( 65, 10 );
- Match(input,10,Follow._10_in_expr200);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 65, 15 );
- PushFollow(Follow._expr_in_expr204);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 65, 22 );
- PushFollow(Follow._expr_in_expr208);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 65, 35 );
- value = a.subtract(b);
-
- }
- break;
- case 3:
- dbg.EnterAlt( 3 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:66:9: ^( '*' a= expr b= expr )
- {
- dbg.Location( 66, 8 );
- dbg.Location( 66, 10 );
- Match(input,14,Follow._14_in_expr228);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 66, 15 );
- PushFollow(Follow._expr_in_expr232);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 66, 22 );
- PushFollow(Follow._expr_in_expr236);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 66, 35 );
- value = a.multiply(b);
-
- }
- break;
- case 4:
- dbg.EnterAlt( 4 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:67:9: ^( '/' a= expr b= expr )
- {
- dbg.Location( 67, 8 );
- dbg.Location( 67, 10 );
- Match(input,15,Follow._15_in_expr256);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 67, 15 );
- PushFollow(Follow._expr_in_expr260);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 67, 22 );
- PushFollow(Follow._expr_in_expr264);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 67, 35 );
- value = a.divide(b);
-
- }
- break;
- case 5:
- dbg.EnterAlt( 5 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:68:9: ^( '%' a= expr b= expr )
- {
- dbg.Location( 68, 8 );
- dbg.Location( 68, 10 );
- Match(input,11,Follow._11_in_expr284);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 68, 15 );
- PushFollow(Follow._expr_in_expr288);
- a=expr();
-
- state._fsp--;
-
- dbg.Location( 68, 22 );
- PushFollow(Follow._expr_in_expr292);
- b=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 68, 35 );
- value = a.remainder(b);
-
- }
- break;
- case 6:
- dbg.EnterAlt( 6 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:69:9: ID
- {
- dbg.Location( 69, 8 );
- ID4=(CommonTree)Match(input,ID,Follow._ID_in_expr311);
- dbg.Location( 69, 35 );
- value = getValue((ID4!=null?ID4.Text:null));
-
- }
- break;
- case 7:
- dbg.EnterAlt( 7 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:70:9: INT
- {
- dbg.Location( 70, 8 );
- INT5=(CommonTree)Match(input,INT,Follow._INT_in_expr347);
- dbg.Location( 70, 35 );
- value = new BigInteger((INT5!=null?INT5.Text:null));
-
- }
- break;
- case 8:
- dbg.EnterAlt( 8 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:71:9: call
- {
- dbg.Location( 71, 8 );
- PushFollow(Follow._call_in_expr382);
- call6=call();
-
- state._fsp--;
-
- dbg.Location( 71, 35 );
- value = call6;
-
- }
- break;
-
- }
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(72, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "expr" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return value;
- }
- // $ANTLR end "expr"
-
-
- // $ANTLR start "call"
- // BuildOptions\\ProfileTreeGrammar.g3:74:0: call returns [BigInteger value] : ^( CALL ID expr ) ;
- private BigInteger call( )
- {
- BigInteger value = default(BigInteger);
-
- CommonTree ID8=null;
- BigInteger expr7 = default(BigInteger);
-
- try
- {
- dbg.EnterRule( GrammarFileName, "call" );
- if ( RuleLevel == 0 )
- {
- dbg.Commence();
- }
- IncRuleLevel();
- dbg.Location( 74, -1 );
-
- try
- {
- // BuildOptions\\ProfileTreeGrammar.g3:75:9: ( ^( CALL ID expr ) )
- dbg.EnterAlt( 1 );
-
- // BuildOptions\\ProfileTreeGrammar.g3:75:9: ^( CALL ID expr )
- {
- dbg.Location( 75, 8 );
- dbg.Location( 75, 10 );
- Match(input,CALL,Follow._CALL_in_call430);
-
- Match(input, TokenTypes.Down, null);
- dbg.Location( 75, 15 );
- ID8=(CommonTree)Match(input,ID,Follow._ID_in_call432);
- dbg.Location( 75, 18 );
- PushFollow(Follow._expr_in_call434);
- expr7=expr();
-
- state._fsp--;
-
-
- Match(input, TokenTypes.Up, null);
- dbg.Location( 75, 35 );
- BigInteger p = expr7;
- CommonTree funcRoot = findFunction((ID8!=null?ID8.Text:null), p);
- if (funcRoot == null) {
- Console.Error.WriteLine("No match found for " + (ID8!=null?ID8.Text:null) + "(" + p + ")");
- } else {
- // Here we set up the local evaluator to run over the
- // function definition with the parameter value.
- // This re-reads a sub-AST of our input AST!
- ProfileTreeGrammar e = new ProfileTreeGrammar(funcRoot, functionDefinitions, globalMemory, p);
- value = e.expr();
- }
-
-
- }
-
- }
- catch ( RecognitionException re )
- {
- ReportError(re);
- Recover(input,re);
- }
- finally
- {
- }
- dbg.Location(87, 4);
-
- }
- finally
- {
- dbg.ExitRule( GrammarFileName, "call" );
- DecRuleLevel();
- if ( RuleLevel == 0 )
- {
- dbg.Terminate();
- }
- }
-
- return value;
- }
- // $ANTLR end "call"
- #endregion Rules
-
-
- #region Follow sets
- private static class Follow
- {
- public static readonly BitSet _stat_in_prog48 = new BitSet(new ulong[]{0x3CCF2UL});
- public static readonly BitSet _expr_in_stat63 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _17_in_stat98 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _ID_in_stat100 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_stat102 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _FUNC_in_stat128 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _16_in_expr172 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr176 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr180 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _10_in_expr200 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr204 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr208 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _14_in_expr228 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr232 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr236 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _15_in_expr256 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr260 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr264 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _11_in_expr284 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _expr_in_expr288 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_expr292 = new BitSet(new ulong[]{0x8UL});
- public static readonly BitSet _ID_in_expr311 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _INT_in_expr347 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _call_in_expr382 = new BitSet(new ulong[]{0x2UL});
- public static readonly BitSet _CALL_in_call430 = new BitSet(new ulong[]{0x4UL});
- public static readonly BitSet _ID_in_call432 = new BitSet(new ulong[]{0x1CCD0UL});
- public static readonly BitSet _expr_in_call434 = new BitSet(new ulong[]{0x8UL});
-
- }
- #endregion Follow sets
-}
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.g3 b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.g3
deleted file mode 100644
index 5bf107b..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammar.g3
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-tree grammar ProfileTreeGrammar;
-
-options
-{
- language=CSharp3;
- tokenVocab=ProfileGrammar;
- ASTLabelType=CommonTree;
-}
-
-// START:members
-@header
-{
-//import java.util.Map;
-//import java.util.HashMap;
-using BigInteger = java.math.BigInteger;
-using Console = System.Console;
-}
-// END:members
-
-@namespace{Antlr3.Runtime.Test.BuildOptions}
-
-// START:rules
-prog: stat*
- ;
-
-stat: expr { string result = $expr.value.ToString();
- Console.Out.WriteLine($expr.value + " (about " + result[0] + "*10^" + (result.Length-1) + ")");
- }
- | ^('=' ID expr) { globalMemory[$ID.text] = $expr.value; }
- | ^(FUNC .+) // ignore FUNCs - we added them to functionDefinitions already in parser.
- ;
-
-expr returns [BigInteger value]
- : ^('+' a=expr b=expr) { $value = $a.value.add($b.value); }
- | ^('-' a=expr b=expr) { $value = $a.value.subtract($b.value); }
- | ^('*' a=expr b=expr) { $value = $a.value.multiply($b.value); }
- | ^('/' a=expr b=expr) { $value = $a.value.divide($b.value); }
- | ^('%' a=expr b=expr) { $value = $a.value.remainder($b.value); }
- | ID { $value = getValue($ID.text); }
- | INT { $value = new BigInteger($INT.text); }
- | call { $value = $call.value; }
- ;
-
-call returns [BigInteger value]
- : ^(CALL ID expr) { BigInteger p = $expr.value;
- CommonTree funcRoot = findFunction($ID.text, p);
- if (funcRoot == null) {
- Console.Error.WriteLine("No match found for " + $ID.text + "(" + p + ")");
- } else {
- // Here we set up the local evaluator to run over the
- // function definition with the parameter value.
- // This re-reads a sub-AST of our input AST!
- ProfileTreeGrammar e = new ProfileTreeGrammar(funcRoot, functionDefinitions, globalMemory, p);
- $value = e.expr();
- }
- }
- ;
-// END:rules
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammarHelper.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammarHelper.cs
deleted file mode 100644
index 06d678a..0000000
--- a/runtime/CSharp3/Sources/Antlr3.Runtime.Test/BuildOptions/ProfileTreeGrammarHelper.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2011 Terence Parr
- * All rights reserved.
- *
- * Conversion to C#:
- * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace Antlr3.Runtime.Test.BuildOptions
-{
- using System.Collections.Generic;
- using Antlr.Runtime.Tree;
-
- using BigInteger = java.math.BigInteger;
- using Console = System.Console;
-
- partial class ProfileTreeGrammar
- {
- /** Points to functions tracked by tree builder. */
- private List<CommonTree> functionDefinitions;
-
- /** Remember local variables. Currently, this is only the function parameter.
- */
- private readonly IDictionary<string, BigInteger> localMemory = new Dictionary<string, BigInteger>();
-
- /** Remember global variables set by =. */
- private IDictionary<string, BigInteger> globalMemory = new Dictionary<string, BigInteger>();
-
- /** Set up an evaluator with a node stream; and a set of function definition ASTs. */
- public ProfileTreeGrammar(CommonTreeNodeStream nodes, List<CommonTree> functionDefinitions)
- : this(nodes)
- {
- this.functionDefinitions = functionDefinitions;
- }
-
- /** Set up a local evaluator for a nested function call. The evaluator gets the definition
- * tree of the function; the set of all defined functions (to find locally called ones); a
- * pointer to the global variable memory; and the value of the function parameter to be
- * added to the local memory.
- */
- private ProfileTreeGrammar(CommonTree function,
- List<CommonTree> functionDefinitions,
- IDictionary<string, BigInteger> globalMemory,
- BigInteger paramValue)
- // Expected tree for function: ^(FUNC ID ( INT | ID ) expr)
- : this(new CommonTreeNodeStream(function.GetChild(2)), functionDefinitions)
- {
- this.globalMemory = globalMemory;
- localMemory[function.GetChild(1).Text] = paramValue;
- }
-
- /** Find matching function definition for a function name and parameter
- * value. The first definition is returned where (a) the name matches
- * and (b) the formal parameter agrees if it is defined as constant.
- */
- private CommonTree findFunction(string name, BigInteger paramValue)
- {
- foreach (CommonTree f in functionDefinitions)
- {
- // Expected tree for f: ^(FUNC ID (ID | INT) expr)
- if (f.GetChild(0).Text.Equals(name))
- {
- // Check whether parameter matches
- CommonTree formalPar = (CommonTree)f.GetChild(1);
- if (formalPar.Token.Type == INT
- && !new BigInteger(formalPar.Token.Text).Equals(paramValue))
- {
- // Constant in formalPar list does not match actual value -> no match.
- continue;
- }
- // Parameter (value for INT formal arg) as well as fct name agrees!
- return f;
- }
- }
- return null;
- }
-
- /** Get value of name up call stack. */
- public BigInteger getValue(string name)
- {
- BigInteger value;
- if (localMemory.TryGetValue(name, out value) && value != null)
- {
- return value;
- }
- if (globalMemory.TryGetValue(name, out value) && value != null)
- {
- return value;
- }
- // not found in local memory or global memory
- Console.Error.WriteLine("undefined variable " + name);
- return new BigInteger("0");
- }
- }
-}