From 448d7ac32afb0f194d24dfb671bd7f83f3ae41eb Mon Sep 17 00:00:00 2001 From: Humenius Date: Fri, 12 Jun 2020 16:06:34 +0200 Subject: [PATCH] [12 - Tree Grammar] Add AssignCount grammar and adjust ANTLR build config --- .idea/modules.xml | 2 + .idea/runConfigurations/Run_Antlr_builder.xml | 2 +- .idea/workspace.xml | 212 ++- .../AntlrXTreeGrammarMain.java | 10 +- .../compiler/antlrxtreegrammar/AssignCount.g | 20 +- .../antlrxtreegrammar/AssignCount.java | 1303 ++++++++++++++++- .../antlrxtreegrammar/AssignCount.tokens | 2 - 7 files changed, 1416 insertions(+), 135 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 0e18337..90cc49c 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,10 @@ + + diff --git a/.idea/runConfigurations/Run_Antlr_builder.xml b/.idea/runConfigurations/Run_Antlr_builder.xml index b4bf6d7..66839b7 100644 --- a/.idea/runConfigurations/Run_Antlr_builder.xml +++ b/.idea/runConfigurations/Run_Antlr_builder.xml @@ -2,7 +2,7 @@ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4516622..8b3c4ff 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,18 +1,23 @@ - + + - - - - - - - - - + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + @@ -58,22 +106,6 @@ - - - - - - - @@ -112,22 +144,6 @@ - - - - - - - @@ -146,26 +162,21 @@ - + - + - + + -<<<<<<< Updated upstream + + + - -======= - - - - ->>>>>>> Stashed changes - @@ -181,14 +192,12 @@ 1591172713288 -<<<<<<< Updated upstream -======= - - - ->>>>>>> Stashed changes + + + + @@ -204,88 +213,63 @@ -<<<<<<< Updated upstream - - + + + - + + + + + + - + - + + + + + - + + - + + - + + - + + - + -======= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->>>>>>> Stashed changes - + @@ -296,5 +280,9 @@ + + + + \ No newline at end of file diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java index f722b29..35e213c 100644 --- a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java @@ -71,7 +71,7 @@ public class AntlrXTreeGrammarMain { public static void main(String[] args) throws Exception { - ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(BEISPIELFOLIEN.getBytes())); + ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(TEST.getBytes())); XLexer lexer = new XLexer(input); XParser parser = new XParser(new CommonTokenStream(lexer)); CommonTree tree = parser.program().getTree(); @@ -79,9 +79,9 @@ public class AntlrXTreeGrammarMain { // Tut nichts XTreeGrammar treeGrammar = new XTreeGrammar(new CommonTreeNodeStream(tree)); tree = treeGrammar.program().getTree(); - - // Z�hle Zuweisungen - // TODO - + + // Zuweisungen + AssignCount count = new AssignCount(new CommonTreeNodeStream(tree)); + System.out.printf("Assign count: %d%n", count.getCount()); } } diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g index 5177348..66f1fdb 100644 --- a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g @@ -17,6 +17,24 @@ options { } +decl: ^(DECL ID ('int' | 'float' | 'string') 'read'? 'print'?); +decllist: ^(DECLLIST decl*); -program: 'todo'; +expr: ^(('+' | '-' | '*' | '/') expr expr) + | ^(UMINUS (INTCONST | FLOATCONST)) + | INTCONST | FLOATCONST | STRINGCONST | ID; + +assignstat: ^(':=' ID expr) { count++; }; // FIXME Zählt nicht in AntlrXTreeGrammarMain, aber in Tests?? + +cond: ^(('<' | '>' | '=') expr expr); +condstat: ^('if' cond stat stat?); + +whilestat: ^('while' cond stat); +forstat: ^('for' assignstat cond assignstat stat); + +stat: assignstat | condstat | whilestat | forstat | statlist; + +statlist: ^(STATLIST stat*); + +program: ^('program' ID decllist statlist); diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java index 94e8d20..a58dac9 100644 --- a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java @@ -1,4 +1,4 @@ -// $ANTLR 3.5.2 C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g 2019-05-23 11:52:00 +// $ANTLR 3.5.2 C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g 2020-06-12 16:02:52 package de.dhbw.compiler.antlrxtreegrammar; import org.antlr.runtime.*; @@ -16,8 +16,7 @@ public class AssignCount extends TreeParser { "POSDIGIT", "STATLIST", "STRINGCONST", "UMINUS", "WS", "ZERO", "'('", "')'", "'*'", "'+'", "'-'", "'.'", "'/'", "':'", "':='", "';'", "'<'", "'='", "'>'", "'begin'", "'else'", "'end'", "'float'", "'for'", "'if'", - "'int'", "'print'", "'program'", "'read'", "'string'", "'then'", "'while'", - "'todo'" + "'int'", "'print'", "'program'", "'read'", "'string'", "'then'", "'while'" }; public static final int EOF=-1; public static final int T__20=20; @@ -62,7 +61,6 @@ public class AssignCount extends TreeParser { public static final int UMINUS=17; public static final int WS=18; public static final int ZERO=19; - public static final int T__46=46; // delegates public TreeParser[] getDelegates() { @@ -88,7 +86,7 @@ public class AssignCount extends TreeParser { return adaptor; } @Override public String[] getTokenNames() { return AssignCount.tokenNames; } - @Override public String getGrammarFileName() { return "C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g"; } + @Override public String getGrammarFileName() { return "C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g"; } @@ -98,6 +96,1202 @@ public class AssignCount extends TreeParser { + public static class decl_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "decl" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:1: decl : ^( DECL ID ( 'int' | 'float' | 'string' ) ( 'read' )? ( 'print' )? ) ; + public final AssignCount.decl_return decl() throws RecognitionException { + AssignCount.decl_return retval = new AssignCount.decl_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree DECL1=null; + CommonTree ID2=null; + CommonTree set3=null; + CommonTree string_literal4=null; + CommonTree string_literal5=null; + + CommonTree DECL1_tree=null; + CommonTree ID2_tree=null; + CommonTree set3_tree=null; + CommonTree string_literal4_tree=null; + CommonTree string_literal5_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:5: ( ^( DECL ID ( 'int' | 'float' | 'string' ) ( 'read' )? ( 'print' )? ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:13: ^( DECL ID ( 'int' | 'float' | 'string' ) ( 'read' )? ( 'print' )? ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + DECL1=(CommonTree)match(input,DECL,FOLLOW_DECL_in_decl71); + DECL1_tree = (CommonTree)adaptor.dupNode(DECL1); + + + root_1 = (CommonTree)adaptor.becomeRoot(DECL1_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + ID2=(CommonTree)match(input,ID,FOLLOW_ID_in_decl73); + ID2_tree = (CommonTree)adaptor.dupNode(ID2); + + + adaptor.addChild(root_1, ID2_tree); + + _last = (CommonTree)input.LT(1); + set3=(CommonTree)input.LT(1); + if ( input.LA(1)==36||input.LA(1)==39||input.LA(1)==43 ) { + input.consume(); + set3_tree = (CommonTree)adaptor.dupNode(set3); + + + adaptor.addChild(root_1, set3_tree); + + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:52: ( 'read' )? + int alt1=2; + int LA1_0 = input.LA(1); + if ( (LA1_0==42) ) { + alt1=1; + } + switch (alt1) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:52: 'read' + { + _last = (CommonTree)input.LT(1); + string_literal4=(CommonTree)match(input,42,FOLLOW_42_in_decl87); + string_literal4_tree = (CommonTree)adaptor.dupNode(string_literal4); + + + adaptor.addChild(root_1, string_literal4_tree); + + } + break; + + } + + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:60: ( 'print' )? + int alt2=2; + int LA2_0 = input.LA(1); + if ( (LA2_0==40) ) { + alt2=1; + } + switch (alt2) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:20:60: 'print' + { + _last = (CommonTree)input.LT(1); + string_literal5=(CommonTree)match(input,40,FOLLOW_40_in_decl90); + string_literal5_tree = (CommonTree)adaptor.dupNode(string_literal5); + + + adaptor.addChild(root_1, string_literal5_tree); + + } + break; + + } + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "decl" + + + public static class decllist_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "decllist" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:1: decllist : ^( DECLLIST ( decl )* ) ; + public final AssignCount.decllist_return decllist() throws RecognitionException { + AssignCount.decllist_return retval = new AssignCount.decllist_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree DECLLIST6=null; + TreeRuleReturnScope decl7 =null; + + CommonTree DECLLIST6_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:9: ( ^( DECLLIST ( decl )* ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:13: ^( DECLLIST ( decl )* ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + DECLLIST6=(CommonTree)match(input,DECLLIST,FOLLOW_DECLLIST_in_decllist101); + DECLLIST6_tree = (CommonTree)adaptor.dupNode(DECLLIST6); + + + root_1 = (CommonTree)adaptor.becomeRoot(DECLLIST6_tree, root_1); + + if ( input.LA(1)==Token.DOWN ) { + match(input, Token.DOWN, null); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:24: ( decl )* + loop3: + while (true) { + int alt3=2; + int LA3_0 = input.LA(1); + if ( (LA3_0==DECL) ) { + alt3=1; + } + + switch (alt3) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:24: decl + { + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_decl_in_decllist103); + decl7=decl(); + state._fsp--; + + adaptor.addChild(root_1, decl7.getTree()); + + } + break; + + default : + break loop3; + } + } + + match(input, Token.UP, null); + } + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "decllist" + + + public static class expr_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "expr" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:23:1: expr : ( ^( ( '+' | '-' | '*' | '/' ) expr expr ) | ^( UMINUS ( INTCONST | FLOATCONST ) ) | INTCONST | FLOATCONST | STRINGCONST | ID ); + public final AssignCount.expr_return expr() throws RecognitionException { + AssignCount.expr_return retval = new AssignCount.expr_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree set8=null; + CommonTree UMINUS11=null; + CommonTree set12=null; + CommonTree INTCONST13=null; + CommonTree FLOATCONST14=null; + CommonTree STRINGCONST15=null; + CommonTree ID16=null; + TreeRuleReturnScope expr9 =null; + TreeRuleReturnScope expr10 =null; + + CommonTree set8_tree=null; + CommonTree UMINUS11_tree=null; + CommonTree set12_tree=null; + CommonTree INTCONST13_tree=null; + CommonTree FLOATCONST14_tree=null; + CommonTree STRINGCONST15_tree=null; + CommonTree ID16_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:23:5: ( ^( ( '+' | '-' | '*' | '/' ) expr expr ) | ^( UMINUS ( INTCONST | FLOATCONST ) ) | INTCONST | FLOATCONST | STRINGCONST | ID ) + int alt4=6; + switch ( input.LA(1) ) { + case 22: + case 23: + case 24: + case 26: + { + alt4=1; + } + break; + case UMINUS: + { + alt4=2; + } + break; + case INTCONST: + { + alt4=3; + } + break; + case FLOATCONST: + { + alt4=4; + } + break; + case STRINGCONST: + { + alt4=5; + } + break; + case ID: + { + alt4=6; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 4, 0, input); + throw nvae; + } + switch (alt4) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:23:13: ^( ( '+' | '-' | '*' | '/' ) expr expr ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + set8=(CommonTree)input.LT(1); + if ( (input.LA(1) >= 22 && input.LA(1) <= 24)||input.LA(1)==26 ) { + input.consume(); + set8_tree = (CommonTree)adaptor.dupNode(set8); + + + root_1 = (CommonTree)adaptor.becomeRoot(set8_tree, root_1); + + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_expr_in_expr135); + expr9=expr(); + state._fsp--; + + adaptor.addChild(root_1, expr9.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_expr_in_expr137); + expr10=expr(); + state._fsp--; + + adaptor.addChild(root_1, expr10.getTree()); + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + break; + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:24:15: ^( UMINUS ( INTCONST | FLOATCONST ) ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + UMINUS11=(CommonTree)match(input,UMINUS,FOLLOW_UMINUS_in_expr155); + UMINUS11_tree = (CommonTree)adaptor.dupNode(UMINUS11); + + + root_1 = (CommonTree)adaptor.becomeRoot(UMINUS11_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + set12=(CommonTree)input.LT(1); + if ( input.LA(1)==FLOATCONST||input.LA(1)==INTCONST ) { + input.consume(); + set12_tree = (CommonTree)adaptor.dupNode(set12); + + + adaptor.addChild(root_1, set12_tree); + + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + break; + case 3 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:25:15: INTCONST + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + INTCONST13=(CommonTree)match(input,INTCONST,FOLLOW_INTCONST_in_expr180); + INTCONST13_tree = (CommonTree)adaptor.dupNode(INTCONST13); + + + adaptor.addChild(root_0, INTCONST13_tree); + + } + break; + case 4 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:25:26: FLOATCONST + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + FLOATCONST14=(CommonTree)match(input,FLOATCONST,FOLLOW_FLOATCONST_in_expr184); + FLOATCONST14_tree = (CommonTree)adaptor.dupNode(FLOATCONST14); + + + adaptor.addChild(root_0, FLOATCONST14_tree); + + } + break; + case 5 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:25:39: STRINGCONST + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + STRINGCONST15=(CommonTree)match(input,STRINGCONST,FOLLOW_STRINGCONST_in_expr188); + STRINGCONST15_tree = (CommonTree)adaptor.dupNode(STRINGCONST15); + + + adaptor.addChild(root_0, STRINGCONST15_tree); + + } + break; + case 6 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:25:53: ID + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + ID16=(CommonTree)match(input,ID,FOLLOW_ID_in_expr192); + ID16_tree = (CommonTree)adaptor.dupNode(ID16); + + + adaptor.addChild(root_0, ID16_tree); + + } + break; + + } + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "expr" + + + public static class assignstat_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "assignstat" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:27:1: assignstat : ^( ':=' ID expr ) ; + public final AssignCount.assignstat_return assignstat() throws RecognitionException { + AssignCount.assignstat_return retval = new AssignCount.assignstat_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree string_literal17=null; + CommonTree ID18=null; + TreeRuleReturnScope expr19 =null; + + CommonTree string_literal17_tree=null; + CommonTree ID18_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:27:11: ( ^( ':=' ID expr ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:27:13: ^( ':=' ID expr ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + string_literal17=(CommonTree)match(input,28,FOLLOW_28_in_assignstat200); + string_literal17_tree = (CommonTree)adaptor.dupNode(string_literal17); + + + root_1 = (CommonTree)adaptor.becomeRoot(string_literal17_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + ID18=(CommonTree)match(input,ID,FOLLOW_ID_in_assignstat202); + ID18_tree = (CommonTree)adaptor.dupNode(ID18); + + + adaptor.addChild(root_1, ID18_tree); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_expr_in_assignstat204); + expr19=expr(); + state._fsp--; + + adaptor.addChild(root_1, expr19.getTree()); + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + count++; + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "assignstat" + + + public static class cond_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "cond" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:29:1: cond : ^( ( '<' | '>' | '=' ) expr expr ) ; + public final AssignCount.cond_return cond() throws RecognitionException { + AssignCount.cond_return retval = new AssignCount.cond_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree set20=null; + TreeRuleReturnScope expr21 =null; + TreeRuleReturnScope expr22 =null; + + CommonTree set20_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:29:5: ( ^( ( '<' | '>' | '=' ) expr expr ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:29:13: ^( ( '<' | '>' | '=' ) expr expr ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + set20=(CommonTree)input.LT(1); + if ( (input.LA(1) >= 30 && input.LA(1) <= 32) ) { + input.consume(); + set20_tree = (CommonTree)adaptor.dupNode(set20); + + + root_1 = (CommonTree)adaptor.becomeRoot(set20_tree, root_1); + + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_expr_in_cond233); + expr21=expr(); + state._fsp--; + + adaptor.addChild(root_1, expr21.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_expr_in_cond235); + expr22=expr(); + state._fsp--; + + adaptor.addChild(root_1, expr22.getTree()); + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "cond" + + + public static class condstat_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "condstat" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:30:1: condstat : ^( 'if' cond stat ( stat )? ) ; + public final AssignCount.condstat_return condstat() throws RecognitionException { + AssignCount.condstat_return retval = new AssignCount.condstat_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree string_literal23=null; + TreeRuleReturnScope cond24 =null; + TreeRuleReturnScope stat25 =null; + TreeRuleReturnScope stat26 =null; + + CommonTree string_literal23_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:30:9: ( ^( 'if' cond stat ( stat )? ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:30:13: ^( 'if' cond stat ( stat )? ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + string_literal23=(CommonTree)match(input,38,FOLLOW_38_in_condstat245); + string_literal23_tree = (CommonTree)adaptor.dupNode(string_literal23); + + + root_1 = (CommonTree)adaptor.becomeRoot(string_literal23_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_cond_in_condstat247); + cond24=cond(); + state._fsp--; + + adaptor.addChild(root_1, cond24.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_stat_in_condstat249); + stat25=stat(); + state._fsp--; + + adaptor.addChild(root_1, stat25.getTree()); + + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:30:30: ( stat )? + int alt5=2; + int LA5_0 = input.LA(1); + if ( (LA5_0==STATLIST||LA5_0==28||(LA5_0 >= 37 && LA5_0 <= 38)||LA5_0==45) ) { + alt5=1; + } + switch (alt5) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:30:30: stat + { + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_stat_in_condstat251); + stat26=stat(); + state._fsp--; + + adaptor.addChild(root_1, stat26.getTree()); + + } + break; + + } + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "condstat" + + + public static class whilestat_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "whilestat" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:32:1: whilestat : ^( 'while' cond stat ) ; + public final AssignCount.whilestat_return whilestat() throws RecognitionException { + AssignCount.whilestat_return retval = new AssignCount.whilestat_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree string_literal27=null; + TreeRuleReturnScope cond28 =null; + TreeRuleReturnScope stat29 =null; + + CommonTree string_literal27_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:32:10: ( ^( 'while' cond stat ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:32:13: ^( 'while' cond stat ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + string_literal27=(CommonTree)match(input,45,FOLLOW_45_in_whilestat262); + string_literal27_tree = (CommonTree)adaptor.dupNode(string_literal27); + + + root_1 = (CommonTree)adaptor.becomeRoot(string_literal27_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_cond_in_whilestat264); + cond28=cond(); + state._fsp--; + + adaptor.addChild(root_1, cond28.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_stat_in_whilestat266); + stat29=stat(); + state._fsp--; + + adaptor.addChild(root_1, stat29.getTree()); + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "whilestat" + + + public static class forstat_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "forstat" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:33:1: forstat : ^( 'for' assignstat cond assignstat stat ) ; + public final AssignCount.forstat_return forstat() throws RecognitionException { + AssignCount.forstat_return retval = new AssignCount.forstat_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree string_literal30=null; + TreeRuleReturnScope assignstat31 =null; + TreeRuleReturnScope cond32 =null; + TreeRuleReturnScope assignstat33 =null; + TreeRuleReturnScope stat34 =null; + + CommonTree string_literal30_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:33:8: ( ^( 'for' assignstat cond assignstat stat ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:33:13: ^( 'for' assignstat cond assignstat stat ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + string_literal30=(CommonTree)match(input,37,FOLLOW_37_in_forstat277); + string_literal30_tree = (CommonTree)adaptor.dupNode(string_literal30); + + + root_1 = (CommonTree)adaptor.becomeRoot(string_literal30_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_assignstat_in_forstat279); + assignstat31=assignstat(); + state._fsp--; + + adaptor.addChild(root_1, assignstat31.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_cond_in_forstat281); + cond32=cond(); + state._fsp--; + + adaptor.addChild(root_1, cond32.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_assignstat_in_forstat283); + assignstat33=assignstat(); + state._fsp--; + + adaptor.addChild(root_1, assignstat33.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_stat_in_forstat285); + stat34=stat(); + state._fsp--; + + adaptor.addChild(root_1, stat34.getTree()); + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "forstat" + + + public static class stat_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "stat" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:1: stat : ( assignstat | condstat | whilestat | forstat | statlist ); + public final AssignCount.stat_return stat() throws RecognitionException { + AssignCount.stat_return retval = new AssignCount.stat_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + TreeRuleReturnScope assignstat35 =null; + TreeRuleReturnScope condstat36 =null; + TreeRuleReturnScope whilestat37 =null; + TreeRuleReturnScope forstat38 =null; + TreeRuleReturnScope statlist39 =null; + + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:5: ( assignstat | condstat | whilestat | forstat | statlist ) + int alt6=5; + switch ( input.LA(1) ) { + case 28: + { + alt6=1; + } + break; + case 38: + { + alt6=2; + } + break; + case 45: + { + alt6=3; + } + break; + case 37: + { + alt6=4; + } + break; + case STATLIST: + { + alt6=5; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 6, 0, input); + throw nvae; + } + switch (alt6) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:13: assignstat + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_assignstat_in_stat299); + assignstat35=assignstat(); + state._fsp--; + + adaptor.addChild(root_0, assignstat35.getTree()); + + } + break; + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:26: condstat + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_condstat_in_stat303); + condstat36=condstat(); + state._fsp--; + + adaptor.addChild(root_0, condstat36.getTree()); + + } + break; + case 3 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:37: whilestat + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_whilestat_in_stat307); + whilestat37=whilestat(); + state._fsp--; + + adaptor.addChild(root_0, whilestat37.getTree()); + + } + break; + case 4 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:49: forstat + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_forstat_in_stat311); + forstat38=forstat(); + state._fsp--; + + adaptor.addChild(root_0, forstat38.getTree()); + + } + break; + case 5 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:35:59: statlist + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_statlist_in_stat315); + statlist39=statlist(); + state._fsp--; + + adaptor.addChild(root_0, statlist39.getTree()); + + } + break; + + } + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "stat" + + + public static class statlist_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "statlist" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:37:1: statlist : ^( STATLIST ( stat )* ) ; + public final AssignCount.statlist_return statlist() throws RecognitionException { + AssignCount.statlist_return retval = new AssignCount.statlist_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree STATLIST40=null; + TreeRuleReturnScope stat41 =null; + + CommonTree STATLIST40_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:37:9: ( ^( STATLIST ( stat )* ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:37:13: ^( STATLIST ( stat )* ) + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + STATLIST40=(CommonTree)match(input,STATLIST,FOLLOW_STATLIST_in_statlist325); + STATLIST40_tree = (CommonTree)adaptor.dupNode(STATLIST40); + + + root_1 = (CommonTree)adaptor.becomeRoot(STATLIST40_tree, root_1); + + if ( input.LA(1)==Token.DOWN ) { + match(input, Token.DOWN, null); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:37:24: ( stat )* + loop7: + while (true) { + int alt7=2; + int LA7_0 = input.LA(1); + if ( (LA7_0==STATLIST||LA7_0==28||(LA7_0 >= 37 && LA7_0 <= 38)||LA7_0==45) ) { + alt7=1; + } + + switch (alt7) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:37:24: stat + { + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_stat_in_statlist327); + stat41=stat(); + state._fsp--; + + adaptor.addChild(root_1, stat41.getTree()); + + } + break; + + default : + break loop7; + } + } + + match(input, Token.UP, null); + } + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "statlist" + + public static class program_return extends TreeRuleReturnScope { CommonTree tree; @Override @@ -106,7 +1300,7 @@ public class AssignCount extends TreeParser { // $ANTLR start "program" - // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:1: program : 'todo' ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:39:1: program : ^( 'program' ID decllist statlist ) ; public final AssignCount.program_return program() throws RecognitionException { AssignCount.program_return retval = new AssignCount.program_return(); retval.start = input.LT(1); @@ -117,23 +1311,60 @@ public class AssignCount extends TreeParser { CommonTree _last = null; - CommonTree string_literal1=null; + CommonTree string_literal42=null; + CommonTree ID43=null; + TreeRuleReturnScope decllist44 =null; + TreeRuleReturnScope statlist45 =null; - CommonTree string_literal1_tree=null; + CommonTree string_literal42_tree=null; + CommonTree ID43_tree=null; try { - // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:8: ( 'todo' ) - // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:15: 'todo' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:39:8: ( ^( 'program' ID decllist statlist ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:39:13: ^( 'program' ID decllist statlist ) { root_0 = (CommonTree)adaptor.nil(); _last = (CommonTree)input.LT(1); - string_literal1=(CommonTree)match(input,46,FOLLOW_46_in_program70); - string_literal1_tree = (CommonTree)adaptor.dupNode(string_literal1); + { + CommonTree _save_last_1 = _last; + CommonTree _first_1 = null; + CommonTree root_1 = (CommonTree)adaptor.nil(); + _last = (CommonTree)input.LT(1); + string_literal42=(CommonTree)match(input,41,FOLLOW_41_in_program340); + string_literal42_tree = (CommonTree)adaptor.dupNode(string_literal42); - adaptor.addChild(root_0, string_literal1_tree); + root_1 = (CommonTree)adaptor.becomeRoot(string_literal42_tree, root_1); + + match(input, Token.DOWN, null); + _last = (CommonTree)input.LT(1); + ID43=(CommonTree)match(input,ID,FOLLOW_ID_in_program342); + ID43_tree = (CommonTree)adaptor.dupNode(ID43); + + + adaptor.addChild(root_1, ID43_tree); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_decllist_in_program344); + decllist44=decllist(); + state._fsp--; + + adaptor.addChild(root_1, decllist44.getTree()); + + _last = (CommonTree)input.LT(1); + pushFollow(FOLLOW_statlist_in_program346); + statlist45=statlist(); + state._fsp--; + + adaptor.addChild(root_1, statlist45.getTree()); + + match(input, Token.UP, null); + adaptor.addChild(root_0, root_1); + _last = _save_last_1; + } + } @@ -155,5 +1386,49 @@ public class AssignCount extends TreeParser { - public static final BitSet FOLLOW_46_in_program70 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_DECL_in_decl71 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_ID_in_decl73 = new BitSet(new long[]{0x0000089000000000L}); + public static final BitSet FOLLOW_set_in_decl75 = new BitSet(new long[]{0x0000050000000008L}); + public static final BitSet FOLLOW_42_in_decl87 = new BitSet(new long[]{0x0000010000000008L}); + public static final BitSet FOLLOW_40_in_decl90 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_DECLLIST_in_decllist101 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_decl_in_decllist103 = new BitSet(new long[]{0x0000000000000028L}); + public static final BitSet FOLLOW_set_in_expr119 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_expr_in_expr135 = new BitSet(new long[]{0x0000000005C30700L}); + public static final BitSet FOLLOW_expr_in_expr137 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_UMINUS_in_expr155 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_set_in_expr157 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_INTCONST_in_expr180 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_FLOATCONST_in_expr184 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRINGCONST_in_expr188 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ID_in_expr192 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_28_in_assignstat200 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_ID_in_assignstat202 = new BitSet(new long[]{0x0000000005C30700L}); + public static final BitSet FOLLOW_expr_in_assignstat204 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_set_in_cond221 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_expr_in_cond233 = new BitSet(new long[]{0x0000000005C30700L}); + public static final BitSet FOLLOW_expr_in_cond235 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_38_in_condstat245 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_cond_in_condstat247 = new BitSet(new long[]{0x0000206010008000L}); + public static final BitSet FOLLOW_stat_in_condstat249 = new BitSet(new long[]{0x0000206010008008L}); + public static final BitSet FOLLOW_stat_in_condstat251 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_45_in_whilestat262 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_cond_in_whilestat264 = new BitSet(new long[]{0x0000206010008000L}); + public static final BitSet FOLLOW_stat_in_whilestat266 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_37_in_forstat277 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_assignstat_in_forstat279 = new BitSet(new long[]{0x00000001C0000000L}); + public static final BitSet FOLLOW_cond_in_forstat281 = new BitSet(new long[]{0x0000000010000000L}); + public static final BitSet FOLLOW_assignstat_in_forstat283 = new BitSet(new long[]{0x0000206010008000L}); + public static final BitSet FOLLOW_stat_in_forstat285 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_assignstat_in_stat299 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_condstat_in_stat303 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_whilestat_in_stat307 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_forstat_in_stat311 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_statlist_in_stat315 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STATLIST_in_statlist325 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_stat_in_statlist327 = new BitSet(new long[]{0x0000206010008008L}); + public static final BitSet FOLLOW_41_in_program340 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_ID_in_program342 = new BitSet(new long[]{0x0000000000000040L}); + public static final BitSet FOLLOW_decllist_in_program344 = new BitSet(new long[]{0x0000000000008000L}); + public static final BitSet FOLLOW_statlist_in_program346 = new BitSet(new long[]{0x0000000000000008L}); } diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens index 7eb8fc1..bdfd911 100644 --- a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens @@ -40,7 +40,6 @@ STRINGCONST=16 UMINUS=17 WS=18 ZERO=19 -T__46=46 '('=20 ')'=21 '*'=22 @@ -67,4 +66,3 @@ T__46=46 'string'=43 'then'=44 'while'=45 -'todo'=46