diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 514751e..94d4319 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,21 +2,39 @@ - - - - - + - + + + - + + + + + + + + + + + + + + + + + + + + + + - @@ -212,26 +230,26 @@ - + - - + + - - + + - - + + - + diff --git a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.g b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.g index d6cb0b7..d892806 100644 --- a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.g +++ b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.g @@ -25,7 +25,8 @@ tokens { FLOATCONST; WS; MODIFIER; - DECLIST; + DECLLIST; + UMINUS; PROGRAM; DECL; TYPE; @@ -54,17 +55,15 @@ ESCAPE: '\\' ('\"' |'\'' | '\\'); WS: ('\t' | ' ' | '\r' | '\n' | '\f')+ { skip(); }; -INVALID: .; - fragment DIGIT: ('0'..'9'); // -- Parser stuff -program: 'program' ID ';' decllist statlist '.' EOF -> ^(PROGRAM ID decllist statlist); +program: 'program'^ ID ';'! decllist statlist '.'! EOF!; // Declaration -decllist: decl decllist -> ^(DECLIST decl decllist); -decl: modifier ID ':' type ';' -> ^(DECL modifier ID type); +decllist: decl* -> ^(DECLLIST decl*); +decl: modifier? ID ':' type ';' -> ^(DECL modifier? ID type); modifier: 'read' 'print'? | 'read' | 'print'; type: 'int' | 'float' | 'string'; @@ -78,23 +77,16 @@ whilestat: 'while' '(' cond ')' stat -> ^('while' cond stat); forstat: 'for' '(' assignstat ';' cond ';' assignstat ')' stat -> ^('for' assignstat cond assignstat stat); -expr: expr2 '+' expr -> ^('+' expr2 expr) - | expr2 '-' expr -> ^('-' expr2 expr) - | expr2 -> ^(expr2); -expr2: expr3 '*' expr2 -> ^('*' expr3 expr2) - | expr3 '/' expr2 -> ^('/' expr3 expr2) - | expr3 -> ^(expr3); -expr3: number | '-' number | STRINGCONST | '('! expr^ ')'; +// Expressions number: INTCONST | FLOATCONST; +expr: expr2 (op='+' | op='-') expr -> ^($op expr2 expr) + | expr2; +expr2: expr3 (op='*' | op='/') expr -> ^($op expr3 expr) + | expr3; +expr3: op='-' num=number -> ^(UMINUS[op,"UMINUS"] $num) + | number | STRINGCONST | '('! expr^ ')'!; +// Conditions and comparison compOp: '<' | '>' | '='; cond: expr cond2; cond2: compOp expr; - -// -- Dummy rules -// Das sollte dafür sorgen, dass implizite Tokens auch ihre Tokens bekommen -// TODO: Remove this -minus: '-'; -div: '/'; -multiply: '*'; -plus: '+'; diff --git a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.tokens b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.tokens index f7075a8..e3113d8 100644 --- a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.tokens +++ b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/X.tokens @@ -1,4 +1,3 @@ -T__20=20 T__21=21 T__22=22 T__23=23 @@ -24,8 +23,9 @@ T__42=42 T__43=43 T__44=44 T__45=45 +T__46=46 DECL=4 -DECLIST=5 +DECLLIST=5 DIGIT=6 ESCAPE=7 EXPR=8 @@ -39,30 +39,31 @@ STAT=15 STATLIST=16 STRINGCONST=17 TYPE=18 -WS=19 -'('=20 -')'=21 -'*'=22 -'+'=23 -'-'=24 -'.'=25 -'/'=26 -':'=27 -':='=28 -';'=29 -'<'=30 -'='=31 -'>'=32 -'begin'=33 -'else'=34 -'end'=35 -'float'=36 -'for'=37 -'if'=38 -'int'=39 -'print'=40 -'program'=41 -'read'=42 -'string'=43 -'then'=44 -'while'=45 +UMINUS=19 +WS=20 +'('=21 +')'=22 +'*'=23 +'+'=24 +'-'=25 +'.'=26 +'/'=27 +':'=28 +':='=29 +';'=30 +'<'=31 +'='=32 +'>'=33 +'begin'=34 +'else'=35 +'end'=36 +'float'=37 +'for'=38 +'if'=39 +'int'=40 +'print'=41 +'program'=42 +'read'=43 +'string'=44 +'then'=45 +'while'=46 diff --git a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XLexer.java b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XLexer.java index b3cf828..cdace7e 100644 --- a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XLexer.java +++ b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XLexer.java @@ -1,4 +1,4 @@ -// $ANTLR 3.5.2 C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g 2020-06-03 14:02:36 +// $ANTLR 3.5.2 C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g 2020-06-03 14:37:29 package de.dhbw.compiler.antlrxparser; import org.antlr.runtime.*; @@ -9,7 +9,6 @@ import java.util.ArrayList; @SuppressWarnings("all") public class XLexer extends Lexer { public static final int EOF=-1; - public static final int T__20=20; public static final int T__21=21; public static final int T__22=22; public static final int T__23=23; @@ -35,8 +34,9 @@ public class XLexer extends Lexer { public static final int T__43=43; public static final int T__44=44; public static final int T__45=45; + public static final int T__46=46; public static final int DECL=4; - public static final int DECLIST=5; + public static final int DECLLIST=5; public static final int DIGIT=6; public static final int ESCAPE=7; public static final int EXPR=8; @@ -50,7 +50,8 @@ public class XLexer extends Lexer { public static final int STATLIST=16; public static final int STRINGCONST=17; public static final int TYPE=18; - public static final int WS=19; + public static final int UMINUS=19; + public static final int WS=20; // delegates // delegators @@ -67,35 +68,15 @@ public class XLexer extends Lexer { } @Override public String getGrammarFileName() { return "C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g"; } - // $ANTLR start "T__20" - public final void mT__20() throws RecognitionException { - try { - int _type = T__20; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:9:7: ( '(' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:9:9: '(' - { - match('('); - } - - state.type = _type; - state.channel = _channel; - } - finally { - // do for sure before leaving - } - } - // $ANTLR end "T__20" - // $ANTLR start "T__21" public final void mT__21() throws RecognitionException { try { int _type = T__21; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:10:7: ( ')' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:10:9: ')' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:9:7: ( '(' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:9:9: '(' { - match(')'); + match('('); } state.type = _type; @@ -112,10 +93,10 @@ public class XLexer extends Lexer { try { int _type = T__22; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:11:7: ( '*' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:11:9: '*' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:10:7: ( ')' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:10:9: ')' { - match('*'); + match(')'); } state.type = _type; @@ -132,10 +113,10 @@ public class XLexer extends Lexer { try { int _type = T__23; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:12:7: ( '+' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:12:9: '+' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:11:7: ( '*' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:11:9: '*' { - match('+'); + match('*'); } state.type = _type; @@ -152,10 +133,10 @@ public class XLexer extends Lexer { try { int _type = T__24; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:13:7: ( '-' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:13:9: '-' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:12:7: ( '+' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:12:9: '+' { - match('-'); + match('+'); } state.type = _type; @@ -172,10 +153,10 @@ public class XLexer extends Lexer { try { int _type = T__25; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:14:7: ( '.' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:14:9: '.' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:13:7: ( '-' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:13:9: '-' { - match('.'); + match('-'); } state.type = _type; @@ -192,10 +173,10 @@ public class XLexer extends Lexer { try { int _type = T__26; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:15:7: ( '/' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:15:9: '/' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:14:7: ( '.' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:14:9: '.' { - match('/'); + match('.'); } state.type = _type; @@ -212,10 +193,10 @@ public class XLexer extends Lexer { try { int _type = T__27; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:16:7: ( ':' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:16:9: ':' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:15:7: ( '/' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:15:9: '/' { - match(':'); + match('/'); } state.type = _type; @@ -232,11 +213,10 @@ public class XLexer extends Lexer { try { int _type = T__28; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:17:7: ( ':=' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:17:9: ':=' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:16:7: ( ':' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:16:9: ':' { - match(":="); - + match(':'); } state.type = _type; @@ -253,10 +233,11 @@ public class XLexer extends Lexer { try { int _type = T__29; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:18:7: ( ';' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:18:9: ';' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:17:7: ( ':=' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:17:9: ':=' { - match(';'); + match(":="); + } state.type = _type; @@ -273,10 +254,10 @@ public class XLexer extends Lexer { try { int _type = T__30; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:19:7: ( '<' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:19:9: '<' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:18:7: ( ';' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:18:9: ';' { - match('<'); + match(';'); } state.type = _type; @@ -293,10 +274,10 @@ public class XLexer extends Lexer { try { int _type = T__31; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:20:7: ( '=' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:20:9: '=' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:19:7: ( '<' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:19:9: '<' { - match('='); + match('<'); } state.type = _type; @@ -313,10 +294,10 @@ public class XLexer extends Lexer { try { int _type = T__32; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:21:7: ( '>' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:21:9: '>' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:20:7: ( '=' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:20:9: '=' { - match('>'); + match('='); } state.type = _type; @@ -333,11 +314,10 @@ public class XLexer extends Lexer { try { int _type = T__33; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:22:7: ( 'begin' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:22:9: 'begin' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:21:7: ( '>' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:21:9: '>' { - match("begin"); - + match('>'); } state.type = _type; @@ -354,10 +334,10 @@ public class XLexer extends Lexer { try { int _type = T__34; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:23:7: ( 'else' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:23:9: 'else' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:22:7: ( 'begin' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:22:9: 'begin' { - match("else"); + match("begin"); } @@ -375,10 +355,10 @@ public class XLexer extends Lexer { try { int _type = T__35; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:24:7: ( 'end' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:24:9: 'end' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:23:7: ( 'else' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:23:9: 'else' { - match("end"); + match("else"); } @@ -396,10 +376,10 @@ public class XLexer extends Lexer { try { int _type = T__36; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:25:7: ( 'float' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:25:9: 'float' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:24:7: ( 'end' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:24:9: 'end' { - match("float"); + match("end"); } @@ -417,10 +397,10 @@ public class XLexer extends Lexer { try { int _type = T__37; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:26:7: ( 'for' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:26:9: 'for' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:25:7: ( 'float' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:25:9: 'float' { - match("for"); + match("float"); } @@ -438,10 +418,10 @@ public class XLexer extends Lexer { try { int _type = T__38; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:27:7: ( 'if' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:27:9: 'if' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:26:7: ( 'for' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:26:9: 'for' { - match("if"); + match("for"); } @@ -459,10 +439,10 @@ public class XLexer extends Lexer { try { int _type = T__39; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:28:7: ( 'int' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:28:9: 'int' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:27:7: ( 'if' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:27:9: 'if' { - match("int"); + match("if"); } @@ -480,10 +460,10 @@ public class XLexer extends Lexer { try { int _type = T__40; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:29:7: ( 'print' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:29:9: 'print' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:28:7: ( 'int' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:28:9: 'int' { - match("print"); + match("int"); } @@ -501,10 +481,10 @@ public class XLexer extends Lexer { try { int _type = T__41; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:30:7: ( 'program' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:30:9: 'program' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:29:7: ( 'print' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:29:9: 'print' { - match("program"); + match("print"); } @@ -522,10 +502,10 @@ public class XLexer extends Lexer { try { int _type = T__42; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:31:7: ( 'read' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:31:9: 'read' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:30:7: ( 'program' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:30:9: 'program' { - match("read"); + match("program"); } @@ -543,10 +523,10 @@ public class XLexer extends Lexer { try { int _type = T__43; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:32:7: ( 'string' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:32:9: 'string' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:31:7: ( 'read' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:31:9: 'read' { - match("string"); + match("read"); } @@ -564,10 +544,10 @@ public class XLexer extends Lexer { try { int _type = T__44; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:33:7: ( 'then' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:33:9: 'then' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:32:7: ( 'string' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:32:9: 'string' { - match("then"); + match("string"); } @@ -585,6 +565,27 @@ public class XLexer extends Lexer { try { int _type = T__45; int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:33:7: ( 'then' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:33:9: 'then' + { + match("then"); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__45" + + // $ANTLR start "T__46" + public final void mT__46() throws RecognitionException { + try { + int _type = T__46; + int _channel = DEFAULT_TOKEN_CHANNEL; // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:34:7: ( 'while' ) // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:34:9: 'while' { @@ -599,15 +600,15 @@ public class XLexer extends Lexer { // do for sure before leaving } } - // $ANTLR end "T__45" + // $ANTLR end "T__46" // $ANTLR start "ID" public final void mID() throws RecognitionException { try { int _type = ID; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:43:3: ( ( 'a' .. 'z' | 'A' .. 'Z' ) ( options {greedy=true; } : 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:43:13: ( 'a' .. 'z' | 'A' .. 'Z' ) ( options {greedy=true; } : 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:44:3: ( ( 'a' .. 'z' | 'A' .. 'Z' ) ( options {greedy=true; } : 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:44:13: ( 'a' .. 'z' | 'A' .. 'Z' ) ( options {greedy=true; } : 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* { if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { input.consume(); @@ -617,7 +618,7 @@ public class XLexer extends Lexer { recover(mse); throw mse; } - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:44:13: ( options {greedy=true; } : 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:45:13: ( options {greedy=true; } : 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* loop1: while (true) { int alt1=4; @@ -699,19 +700,19 @@ public class XLexer extends Lexer { } switch (alt1) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:46:16: 'a' .. 'z' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:47:16: 'a' .. 'z' { matchRange('a','z'); } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:46:27: 'A' .. 'Z' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:47:27: 'A' .. 'Z' { matchRange('A','Z'); } break; case 3 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:46:38: '0' .. '9' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:47:38: '0' .. '9' { matchRange('0','9'); } @@ -738,7 +739,7 @@ public class XLexer extends Lexer { try { int _type = INTCONST; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:48:9: ( '0' | ( '1' .. '9' ) ( '0' .. '9' )* ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:9: ( '0' | ( '1' .. '9' ) ( '0' .. '9' )* ) int alt3=2; int LA3_0 = input.LA(1); if ( (LA3_0=='0') ) { @@ -756,13 +757,13 @@ public class XLexer extends Lexer { switch (alt3) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:48:17: '0' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:17: '0' { match('0'); } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:48:23: ( '1' .. '9' ) ( '0' .. '9' )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:23: ( '1' .. '9' ) ( '0' .. '9' )* { if ( (input.LA(1) >= '1' && input.LA(1) <= '9') ) { input.consume(); @@ -772,7 +773,7 @@ public class XLexer extends Lexer { recover(mse); throw mse; } - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:48:34: ( '0' .. '9' )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:34: ( '0' .. '9' )* loop2: while (true) { int alt2=2; @@ -819,16 +820,16 @@ public class XLexer extends Lexer { try { int _type = FLOATCONST; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:11: ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST | INTCONST ( '.' ( DIGIT )* )? ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:11: ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST | INTCONST ( '.' ( DIGIT )* )? ) int alt9=2; alt9 = dfa9.predict(input); switch (alt9) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:17: INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:17: INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST { mINTCONST(); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:26: ( '.' ( DIGIT )* )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:26: ( '.' ( DIGIT )* )? int alt5=2; int LA5_0 = input.LA(1); if ( (LA5_0=='.') ) { @@ -836,10 +837,10 @@ public class XLexer extends Lexer { } switch (alt5) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:27: '.' ( DIGIT )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:27: '.' ( DIGIT )* { match('.'); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:31: ( DIGIT )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:31: ( DIGIT )* loop4: while (true) { int alt4=2; @@ -881,7 +882,7 @@ public class XLexer extends Lexer { recover(mse); throw mse; } - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:49:49: ( '+' | '-' )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:49: ( '+' | '-' )? int alt6=2; int LA6_0 = input.LA(1); if ( (LA6_0=='+'||LA6_0=='-') ) { @@ -909,11 +910,11 @@ public class XLexer extends Lexer { } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:19: INTCONST ( '.' ( DIGIT )* )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:51:19: INTCONST ( '.' ( DIGIT )* )? { mINTCONST(); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:28: ( '.' ( DIGIT )* )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:51:28: ( '.' ( DIGIT )* )? int alt8=2; int LA8_0 = input.LA(1); if ( (LA8_0=='.') ) { @@ -921,10 +922,10 @@ public class XLexer extends Lexer { } switch (alt8) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:29: '.' ( DIGIT )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:51:29: '.' ( DIGIT )* { match('.'); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:50:33: ( DIGIT )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:51:33: ( DIGIT )* loop7: while (true) { int alt7=2; @@ -976,11 +977,11 @@ public class XLexer extends Lexer { try { int _type = STRINGCONST; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:52:12: ( '\"' ( ESCAPE |~ ( '\\\\' | '\"' ) )* '\"' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:52:17: '\"' ( ESCAPE |~ ( '\\\\' | '\"' ) )* '\"' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:12: ( '\"' ( ESCAPE |~ ( '\\\\' | '\"' ) )* '\"' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:17: '\"' ( ESCAPE |~ ( '\\\\' | '\"' ) )* '\"' { match('\"'); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:52:21: ( ESCAPE |~ ( '\\\\' | '\"' ) )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:21: ( ESCAPE |~ ( '\\\\' | '\"' ) )* loop10: while (true) { int alt10=3; @@ -994,14 +995,14 @@ public class XLexer extends Lexer { switch (alt10) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:52:22: ESCAPE + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:22: ESCAPE { mESCAPE(); } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:52:31: ~ ( '\\\\' | '\"' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:31: ~ ( '\\\\' | '\"' ) { if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '!')||(input.LA(1) >= '#' && input.LA(1) <= '[')||(input.LA(1) >= ']' && input.LA(1) <= '\uFFFF') ) { input.consume(); @@ -1036,8 +1037,8 @@ public class XLexer extends Lexer { try { int _type = ESCAPE; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:7: ( '\\\\' ( '\\\"' | '\\'' | '\\\\' ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:53:17: '\\\\' ( '\\\"' | '\\'' | '\\\\' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:54:7: ( '\\\\' ( '\\\"' | '\\'' | '\\\\' ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:54:17: '\\\\' ( '\\\"' | '\\'' | '\\\\' ) { match('\\'); if ( input.LA(1)=='\"'||input.LA(1)=='\''||input.LA(1)=='\\' ) { @@ -1064,10 +1065,10 @@ public class XLexer extends Lexer { try { int _type = WS; int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:55:3: ( ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:55:17: ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:56:3: ( ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:56:17: ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:55:17: ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:56:17: ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ int cnt11=0; loop11: while (true) { @@ -1112,30 +1113,10 @@ public class XLexer extends Lexer { } // $ANTLR end "WS" - // $ANTLR start "INVALID" - public final void mINVALID() throws RecognitionException { - try { - int _type = INVALID; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:57:8: ( . ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:57:17: . - { - matchAny(); - } - - state.type = _type; - state.channel = _channel; - } - finally { - // do for sure before leaving - } - } - // $ANTLR end "INVALID" - // $ANTLR start "DIGIT" public final void mDIGIT() throws RecognitionException { try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:59:15: ( ( '0' .. '9' ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:58:15: ( ( '0' .. '9' ) ) // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g: { if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { @@ -1157,190 +1138,190 @@ public class XLexer extends Lexer { @Override public void mTokens() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:8: ( T__20 | T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | ID | INTCONST | FLOATCONST | STRINGCONST | ESCAPE | WS | INVALID ) - int alt12=33; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:8: ( T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | ID | INTCONST | FLOATCONST | STRINGCONST | ESCAPE | WS ) + int alt12=32; alt12 = dfa12.predict(input); switch (alt12) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:10: T__20 - { - mT__20(); - - } - break; - case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:16: T__21 + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:10: T__21 { mT__21(); } break; - case 3 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:22: T__22 + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:16: T__22 { mT__22(); } break; - case 4 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:28: T__23 + case 3 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:22: T__23 { mT__23(); } break; - case 5 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:34: T__24 + case 4 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:28: T__24 { mT__24(); } break; - case 6 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:40: T__25 + case 5 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:34: T__25 { mT__25(); } break; - case 7 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:46: T__26 + case 6 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:40: T__26 { mT__26(); } break; - case 8 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:52: T__27 + case 7 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:46: T__27 { mT__27(); } break; - case 9 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:58: T__28 + case 8 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:52: T__28 { mT__28(); } break; - case 10 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:64: T__29 + case 9 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:58: T__29 { mT__29(); } break; - case 11 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:70: T__30 + case 10 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:64: T__30 { mT__30(); } break; - case 12 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:76: T__31 + case 11 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:70: T__31 { mT__31(); } break; - case 13 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:82: T__32 + case 12 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:76: T__32 { mT__32(); } break; - case 14 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:88: T__33 + case 13 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:82: T__33 { mT__33(); } break; - case 15 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:94: T__34 + case 14 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:88: T__34 { mT__34(); } break; - case 16 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:100: T__35 + case 15 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:94: T__35 { mT__35(); } break; - case 17 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:106: T__36 + case 16 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:100: T__36 { mT__36(); } break; - case 18 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:112: T__37 + case 17 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:106: T__37 { mT__37(); } break; - case 19 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:118: T__38 + case 18 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:112: T__38 { mT__38(); } break; - case 20 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:124: T__39 + case 19 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:118: T__39 { mT__39(); } break; - case 21 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:130: T__40 + case 20 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:124: T__40 { mT__40(); } break; - case 22 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:136: T__41 + case 21 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:130: T__41 { mT__41(); } break; - case 23 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:142: T__42 + case 22 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:136: T__42 { mT__42(); } break; - case 24 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:148: T__43 + case 23 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:142: T__43 { mT__43(); } break; - case 25 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:154: T__44 + case 24 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:148: T__44 { mT__44(); } break; - case 26 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:160: T__45 + case 25 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:154: T__45 { mT__45(); + } + break; + case 26 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:160: T__46 + { + mT__46(); + } break; case 27 : @@ -1383,13 +1364,6 @@ public class XLexer extends Lexer { { mWS(); - } - break; - case 33 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:1:211: INVALID - { - mINVALID(); - } break; @@ -1453,47 +1427,44 @@ public class XLexer extends Lexer { } @Override public String getDescription() { - return "49:1: FLOATCONST : ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST | INTCONST ( '.' ( DIGIT )* )? );"; + return "50:1: FLOATCONST : ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST | INTCONST ( '.' ( DIGIT )* )? );"; } } static final String DFA12_eotS = - "\10\uffff\1\45\4\uffff\11\53\1\uffff\2\67\2\34\17\uffff\1\53\1\uffff\4"+ - "\53\1\102\6\53\2\uffff\1\67\3\uffff\2\53\1\114\1\53\1\116\1\uffff\1\117"+ - "\7\53\1\127\1\uffff\1\53\2\uffff\2\53\1\133\1\53\1\135\1\53\1\137\1\uffff"+ - "\1\140\1\141\1\53\1\uffff\1\53\1\uffff\1\144\3\uffff\1\53\1\146\1\uffff"+ - "\1\147\2\uffff"; + "\10\uffff\1\35\4\uffff\11\26\1\uffff\2\52\5\uffff\5\26\1\62\6\26\2\uffff"+ + "\1\52\2\26\1\74\1\26\1\76\1\uffff\1\77\7\26\1\107\1\uffff\1\26\2\uffff"+ + "\2\26\1\113\1\26\1\115\1\26\1\117\1\uffff\1\120\1\121\1\26\1\uffff\1\26"+ + "\1\uffff\1\124\3\uffff\1\26\1\126\1\uffff\1\127\2\uffff"; static final String DFA12_eofS = - "\150\uffff"; + "\130\uffff"; static final String DFA12_minS = - "\1\0\7\uffff\1\75\4\uffff\1\145\2\154\1\146\1\162\1\145\1\164\2\150\1"+ - "\uffff\2\56\1\0\1\42\17\uffff\1\147\1\uffff\1\163\1\144\1\157\1\162\1"+ - "\60\1\164\1\151\1\141\1\162\1\145\1\151\2\uffff\1\56\3\uffff\1\151\1\145"+ - "\1\60\1\141\1\60\1\uffff\1\60\1\156\1\147\1\144\1\151\1\156\1\154\1\156"+ - "\1\60\1\uffff\1\164\2\uffff\1\164\1\162\1\60\1\156\1\60\1\145\1\60\1\uffff"+ - "\2\60\1\141\1\uffff\1\147\1\uffff\1\60\3\uffff\1\155\1\60\1\uffff\1\60"+ - "\2\uffff"; + "\1\11\7\uffff\1\75\4\uffff\1\145\2\154\1\146\1\162\1\145\1\164\2\150\1"+ + "\uffff\2\56\5\uffff\1\147\1\163\1\144\1\157\1\162\1\60\1\164\1\151\1\141"+ + "\1\162\1\145\1\151\2\uffff\1\56\1\151\1\145\1\60\1\141\1\60\1\uffff\1"+ + "\60\1\156\1\147\1\144\1\151\1\156\1\154\1\156\1\60\1\uffff\1\164\2\uffff"+ + "\1\164\1\162\1\60\1\156\1\60\1\145\1\60\1\uffff\2\60\1\141\1\uffff\1\147"+ + "\1\uffff\1\60\3\uffff\1\155\1\60\1\uffff\1\60\2\uffff"; static final String DFA12_maxS = - "\1\uffff\7\uffff\1\75\4\uffff\1\145\1\156\1\157\1\156\1\162\1\145\1\164"+ - "\2\150\1\uffff\2\145\1\uffff\1\134\17\uffff\1\147\1\uffff\1\163\1\144"+ - "\1\157\1\162\1\172\1\164\1\157\1\141\1\162\1\145\1\151\2\uffff\1\145\3"+ - "\uffff\1\151\1\145\1\172\1\141\1\172\1\uffff\1\172\1\156\1\147\1\144\1"+ - "\151\1\156\1\154\1\156\1\172\1\uffff\1\164\2\uffff\1\164\1\162\1\172\1"+ - "\156\1\172\1\145\1\172\1\uffff\2\172\1\141\1\uffff\1\147\1\uffff\1\172"+ - "\3\uffff\1\155\1\172\1\uffff\1\172\2\uffff"; + "\1\172\7\uffff\1\75\4\uffff\1\145\1\156\1\157\1\156\1\162\1\145\1\164"+ + "\2\150\1\uffff\2\145\5\uffff\1\147\1\163\1\144\1\157\1\162\1\172\1\164"+ + "\1\157\1\141\1\162\1\145\1\151\2\uffff\1\145\1\151\1\145\1\172\1\141\1"+ + "\172\1\uffff\1\172\1\156\1\147\1\144\1\151\1\156\1\154\1\156\1\172\1\uffff"+ + "\1\164\2\uffff\1\164\1\162\1\172\1\156\1\172\1\145\1\172\1\uffff\2\172"+ + "\1\141\1\uffff\1\147\1\uffff\1\172\3\uffff\1\155\1\172\1\uffff\1\172\2"+ + "\uffff"; static final String DFA12_acceptS = "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\uffff\1\12\1\13\1\14\1\15\11\uffff"+ - "\1\33\4\uffff\1\40\1\41\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\11\1\10\1\12\1\13"+ - "\1\14\1\15\1\uffff\1\33\13\uffff\1\34\1\35\1\uffff\1\36\1\37\1\40\5\uffff"+ - "\1\23\11\uffff\1\20\1\uffff\1\22\1\24\7\uffff\1\17\3\uffff\1\27\1\uffff"+ - "\1\31\1\uffff\1\16\1\21\1\25\2\uffff\1\32\1\uffff\1\30\1\26"; + "\1\33\2\uffff\1\36\1\37\1\40\1\11\1\10\14\uffff\1\34\1\35\6\uffff\1\23"+ + "\11\uffff\1\20\1\uffff\1\22\1\24\7\uffff\1\17\3\uffff\1\27\1\uffff\1\31"+ + "\1\uffff\1\16\1\21\1\25\2\uffff\1\32\1\uffff\1\30\1\26"; static final String DFA12_specialS = - "\1\1\30\uffff\1\0\116\uffff}>"; + "\130\uffff}>"; static final String[] DFA12_transitionS = { - "\11\34\2\33\1\34\2\33\22\34\1\33\1\34\1\31\5\34\1\1\1\2\1\3\1\4\1\34"+ - "\1\5\1\6\1\7\1\27\11\30\1\10\1\11\1\12\1\13\1\14\2\34\32\26\1\34\1\32"+ - "\4\34\1\26\1\15\2\26\1\16\1\17\2\26\1\20\6\26\1\21\1\26\1\22\1\23\1\24"+ - "\2\26\1\25\3\26\uff85\34", + "\2\33\1\uffff\2\33\22\uffff\1\33\1\uffff\1\31\5\uffff\1\1\1\2\1\3\1\4"+ + "\1\uffff\1\5\1\6\1\7\1\27\11\30\1\10\1\11\1\12\1\13\1\14\2\uffff\32\26"+ + "\1\uffff\1\32\4\uffff\1\26\1\15\2\26\1\16\1\17\2\26\1\20\6\26\1\21\1"+ + "\26\1\22\1\23\1\24\2\26\1\25\3\26", "", "", "", @@ -1501,100 +1472,84 @@ public class XLexer extends Lexer { "", "", "", - "\1\44", + "\1\34", "", "", "", "", - "\1\52", - "\1\54\1\uffff\1\55", - "\1\56\2\uffff\1\57", - "\1\60\7\uffff\1\61", - "\1\62", + "\1\36", + "\1\37\1\uffff\1\40", + "\1\41\2\uffff\1\42", + "\1\43\7\uffff\1\44", + "\1\45", + "\1\46", + "\1\47", + "\1\50", + "\1\51", + "", + "\1\53\26\uffff\1\53\37\uffff\1\53", + "\1\53\1\uffff\12\54\13\uffff\1\53\37\uffff\1\53", + "", + "", + "", + "", + "", + "\1\55", + "\1\56", + "\1\57", + "\1\60", + "\1\61", + "\12\26\7\uffff\32\26\6\uffff\32\26", "\1\63", - "\1\64", - "\1\65", + "\1\64\5\uffff\1\65", "\1\66", - "", - "\1\70\26\uffff\1\70\37\uffff\1\70", - "\1\70\1\uffff\12\71\13\uffff\1\70\37\uffff\1\70", - "\0\72", - "\1\73\4\uffff\1\73\64\uffff\1\73", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", + "\1\67", + "\1\70", + "\1\71", "", "", + "\1\53\1\uffff\12\54\13\uffff\1\53\37\uffff\1\53", + "\1\72", + "\1\73", + "\12\26\7\uffff\32\26\6\uffff\32\26", "\1\75", + "\12\26\7\uffff\32\26\6\uffff\32\26", "", - "\1\76", - "\1\77", + "\12\26\7\uffff\32\26\6\uffff\32\26", "\1\100", "\1\101", - "\12\53\7\uffff\32\53\6\uffff\32\53", + "\1\102", "\1\103", - "\1\104\5\uffff\1\105", + "\1\104", + "\1\105", "\1\106", - "\1\107", + "\12\26\7\uffff\32\26\6\uffff\32\26", + "", "\1\110", + "", + "", "\1\111", - "", - "", - "\1\70\1\uffff\12\71\13\uffff\1\70\37\uffff\1\70", - "", - "", - "", "\1\112", - "\1\113", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "\1\115", - "\12\53\7\uffff\32\53\6\uffff\32\53", + "\12\26\7\uffff\32\26\6\uffff\32\26", + "\1\114", + "\12\26\7\uffff\32\26\6\uffff\32\26", + "\1\116", + "\12\26\7\uffff\32\26\6\uffff\32\26", "", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "\1\120", - "\1\121", + "\12\26\7\uffff\32\26\6\uffff\32\26", + "\12\26\7\uffff\32\26\6\uffff\32\26", "\1\122", + "", "\1\123", - "\1\124", + "", + "\12\26\7\uffff\32\26\6\uffff\32\26", + "", + "", + "", "\1\125", - "\1\126", - "\12\53\7\uffff\32\53\6\uffff\32\53", + "\12\26\7\uffff\32\26\6\uffff\32\26", "", - "\1\130", - "", - "", - "\1\131", - "\1\132", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "\1\134", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "\1\136", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "\1\142", - "", - "\1\143", - "", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "", - "", - "", - "\1\145", - "\12\53\7\uffff\32\53\6\uffff\32\53", - "", - "\12\53\7\uffff\32\53\6\uffff\32\53", + "\12\26\7\uffff\32\26\6\uffff\32\26", "", "" }; @@ -1630,59 +1585,7 @@ public class XLexer extends Lexer { } @Override public String getDescription() { - return "1:1: Tokens : ( T__20 | T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | ID | INTCONST | FLOATCONST | STRINGCONST | ESCAPE | WS | INVALID );"; - } - @Override - public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { - IntStream input = _input; - int _s = s; - switch ( s ) { - case 0 : - int LA12_25 = input.LA(1); - s = -1; - if ( ((LA12_25 >= '\u0000' && LA12_25 <= '\uFFFF')) ) {s = 58;} - else s = 28; - if ( s>=0 ) return s; - break; - - case 1 : - int LA12_0 = input.LA(1); - s = -1; - if ( (LA12_0=='(') ) {s = 1;} - else if ( (LA12_0==')') ) {s = 2;} - else if ( (LA12_0=='*') ) {s = 3;} - else if ( (LA12_0=='+') ) {s = 4;} - else if ( (LA12_0=='-') ) {s = 5;} - else if ( (LA12_0=='.') ) {s = 6;} - else if ( (LA12_0=='/') ) {s = 7;} - else if ( (LA12_0==':') ) {s = 8;} - else if ( (LA12_0==';') ) {s = 9;} - else if ( (LA12_0=='<') ) {s = 10;} - else if ( (LA12_0=='=') ) {s = 11;} - else if ( (LA12_0=='>') ) {s = 12;} - else if ( (LA12_0=='b') ) {s = 13;} - else if ( (LA12_0=='e') ) {s = 14;} - else if ( (LA12_0=='f') ) {s = 15;} - else if ( (LA12_0=='i') ) {s = 16;} - else if ( (LA12_0=='p') ) {s = 17;} - else if ( (LA12_0=='r') ) {s = 18;} - else if ( (LA12_0=='s') ) {s = 19;} - else if ( (LA12_0=='t') ) {s = 20;} - else if ( (LA12_0=='w') ) {s = 21;} - else if ( ((LA12_0 >= 'A' && LA12_0 <= 'Z')||LA12_0=='a'||(LA12_0 >= 'c' && LA12_0 <= 'd')||(LA12_0 >= 'g' && LA12_0 <= 'h')||(LA12_0 >= 'j' && LA12_0 <= 'o')||LA12_0=='q'||(LA12_0 >= 'u' && LA12_0 <= 'v')||(LA12_0 >= 'x' && LA12_0 <= 'z')) ) {s = 22;} - else if ( (LA12_0=='0') ) {s = 23;} - else if ( ((LA12_0 >= '1' && LA12_0 <= '9')) ) {s = 24;} - else if ( (LA12_0=='\"') ) {s = 25;} - else if ( (LA12_0=='\\') ) {s = 26;} - else if ( ((LA12_0 >= '\t' && LA12_0 <= '\n')||(LA12_0 >= '\f' && LA12_0 <= '\r')||LA12_0==' ') ) {s = 27;} - else if ( ((LA12_0 >= '\u0000' && LA12_0 <= '\b')||LA12_0=='\u000B'||(LA12_0 >= '\u000E' && LA12_0 <= '\u001F')||LA12_0=='!'||(LA12_0 >= '#' && LA12_0 <= '\'')||LA12_0==','||(LA12_0 >= '?' && LA12_0 <= '@')||LA12_0=='['||(LA12_0 >= ']' && LA12_0 <= '`')||(LA12_0 >= '{' && LA12_0 <= '\uFFFF')) ) {s = 28;} - if ( s>=0 ) return s; - break; - } - NoViableAltException nvae = - new NoViableAltException(getDescription(), 12, _s, input); - error(nvae); - throw nvae; + return "1:1: Tokens : ( T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | ID | INTCONST | FLOATCONST | STRINGCONST | ESCAPE | WS );"; } } diff --git a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XParser.java b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XParser.java index adbdfb2..f141665 100644 --- a/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XParser.java +++ b/CC-Praxis-Antlr Parser fuer X-Leer/src/de/dhbw/compiler/antlrxparser/XParser.java @@ -1,4 +1,4 @@ -// $ANTLR 3.5.2 C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g 2020-06-03 14:02:36 +// $ANTLR 3.5.2 C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g 2020-06-03 14:37:29 package de.dhbw.compiler.antlrxparser; import org.antlr.runtime.*; @@ -14,15 +14,14 @@ import org.antlr.runtime.tree.*; @SuppressWarnings("all") public class XParser extends Parser { public static final String[] tokenNames = new String[] { - "", "", "", "", "DECL", "DECLIST", "DIGIT", "ESCAPE", + "", "", "", "", "DECL", "DECLLIST", "DIGIT", "ESCAPE", "EXPR", "FLOATCONST", "ID", "INTCONST", "INVALID", "MODIFIER", "PROGRAM", - "STAT", "STATLIST", "STRINGCONST", "TYPE", "WS", "'('", "')'", "'*'", - "'+'", "'-'", "'.'", "'/'", "':'", "':='", "';'", "'<'", "'='", "'>'", - "'begin'", "'else'", "'end'", "'float'", "'for'", "'if'", "'int'", "'print'", - "'program'", "'read'", "'string'", "'then'", "'while'" + "STAT", "STATLIST", "STRINGCONST", "TYPE", "UMINUS", "WS", "'('", "')'", + "'*'", "'+'", "'-'", "'.'", "'/'", "':'", "':='", "';'", "'<'", "'='", + "'>'", "'begin'", "'else'", "'end'", "'float'", "'for'", "'if'", "'int'", + "'print'", "'program'", "'read'", "'string'", "'then'", "'while'" }; public static final int EOF=-1; - public static final int T__20=20; public static final int T__21=21; public static final int T__22=22; public static final int T__23=23; @@ -48,8 +47,9 @@ public class XParser extends Parser { public static final int T__43=43; public static final int T__44=44; public static final int T__45=45; + public static final int T__46=46; public static final int DECL=4; - public static final int DECLIST=5; + public static final int DECLLIST=5; public static final int DIGIT=6; public static final int ESCAPE=7; public static final int EXPR=8; @@ -63,7 +63,8 @@ public class XParser extends Parser { public static final int STATLIST=16; public static final int STRINGCONST=17; public static final int TYPE=18; - public static final int WS=19; + public static final int UMINUS=19; + public static final int WS=20; // delegates public Parser[] getDelegates() { @@ -100,7 +101,7 @@ public class XParser extends Parser { // $ANTLR start "program" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:63:1: program : 'program' ID ';' decllist statlist '.' EOF -> ^( PROGRAM ID decllist statlist ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:62:1: program : 'program' ^ ID ';' ! decllist statlist '.' ! EOF !; public final XParser.program_return program() throws RecognitionException { XParser.program_return retval = new XParser.program_return(); retval.start = input.LT(1); @@ -120,73 +121,41 @@ public class XParser extends Parser { CommonTree char_literal3_tree=null; CommonTree char_literal6_tree=null; CommonTree EOF7_tree=null; - RewriteRuleTokenStream stream_25=new RewriteRuleTokenStream(adaptor,"token 25"); - RewriteRuleTokenStream stream_29=new RewriteRuleTokenStream(adaptor,"token 29"); - RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID"); - RewriteRuleTokenStream stream_41=new RewriteRuleTokenStream(adaptor,"token 41"); - RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF"); - RewriteRuleSubtreeStream stream_decllist=new RewriteRuleSubtreeStream(adaptor,"rule decllist"); - RewriteRuleSubtreeStream stream_statlist=new RewriteRuleSubtreeStream(adaptor,"rule statlist"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:63:8: ( 'program' ID ';' decllist statlist '.' EOF -> ^( PROGRAM ID decllist statlist ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:63:17: 'program' ID ';' decllist statlist '.' EOF + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:62:8: ( 'program' ^ ID ';' ! decllist statlist '.' ! EOF !) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:62:17: 'program' ^ ID ';' ! decllist statlist '.' ! EOF ! { - string_literal1=(Token)match(input,41,FOLLOW_41_in_program473); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_41.add(string_literal1); + root_0 = (CommonTree)adaptor.nil(); - ID2=(Token)match(input,ID,FOLLOW_ID_in_program475); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_ID.add(ID2); - char_literal3=(Token)match(input,29,FOLLOW_29_in_program477); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_29.add(char_literal3); + string_literal1=(Token)match(input,42,FOLLOW_42_in_program464); if (state.failed) return retval; + if ( state.backtracking==0 ) { + string_literal1_tree = (CommonTree)adaptor.create(string_literal1); + root_0 = (CommonTree)adaptor.becomeRoot(string_literal1_tree, root_0); + } - pushFollow(FOLLOW_decllist_in_program479); + ID2=(Token)match(input,ID,FOLLOW_ID_in_program467); if (state.failed) return retval; + if ( state.backtracking==0 ) { + ID2_tree = (CommonTree)adaptor.create(ID2); + adaptor.addChild(root_0, ID2_tree); + } + + char_literal3=(Token)match(input,30,FOLLOW_30_in_program469); if (state.failed) return retval; + pushFollow(FOLLOW_decllist_in_program472); decllist4=decllist(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_decllist.add(decllist4.getTree()); - pushFollow(FOLLOW_statlist_in_program481); + if ( state.backtracking==0 ) adaptor.addChild(root_0, decllist4.getTree()); + + pushFollow(FOLLOW_statlist_in_program474); statlist5=statlist(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_statlist.add(statlist5.getTree()); - char_literal6=(Token)match(input,25,FOLLOW_25_in_program483); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_25.add(char_literal6); - - EOF7=(Token)match(input,EOF,FOLLOW_EOF_in_program485); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_EOF.add(EOF7); - - // AST REWRITE - // elements: ID, statlist, decllist - // token labels: - // rule labels: retval - // token list labels: - // rule list labels: - // wildcard labels: - if ( state.backtracking==0 ) { - retval.tree = root_0; - RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); - - root_0 = (CommonTree)adaptor.nil(); - // 63:60: -> ^( PROGRAM ID decllist statlist ) - { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:63:63: ^( PROGRAM ID decllist statlist ) - { - CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(PROGRAM, "PROGRAM"), root_1); - adaptor.addChild(root_1, stream_ID.nextNode()); - adaptor.addChild(root_1, stream_decllist.nextTree()); - adaptor.addChild(root_1, stream_statlist.nextTree()); - adaptor.addChild(root_0, root_1); - } - - } - - - retval.tree = root_0; - } + if ( state.backtracking==0 ) adaptor.addChild(root_0, statlist5.getTree()); + char_literal6=(Token)match(input,26,FOLLOW_26_in_program476); if (state.failed) return retval; + EOF7=(Token)match(input,EOF,FOLLOW_EOF_in_program479); if (state.failed) return retval; } retval.stop = input.LT(-1); @@ -217,7 +186,7 @@ public class XParser extends Parser { // $ANTLR start "decllist" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:1: decllist : decl decllist -> ^( DECLIST decl decllist ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:1: decllist : ( decl )* -> ^( DECLLIST ( decl )* ) ; public final XParser.decllist_return decllist() throws RecognitionException { XParser.decllist_return retval = new XParser.decllist_return(); retval.start = input.LT(1); @@ -225,27 +194,41 @@ public class XParser extends Parser { CommonTree root_0 = null; ParserRuleReturnScope decl8 =null; - ParserRuleReturnScope decllist9 =null; RewriteRuleSubtreeStream stream_decl=new RewriteRuleSubtreeStream(adaptor,"rule decl"); - RewriteRuleSubtreeStream stream_decllist=new RewriteRuleSubtreeStream(adaptor,"rule decllist"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:9: ( decl decllist -> ^( DECLIST decl decllist ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:17: decl decllist + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:9: ( ( decl )* -> ^( DECLLIST ( decl )* ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:17: ( decl )* { - pushFollow(FOLLOW_decl_in_decllist511); - decl8=decl(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_decl.add(decl8.getTree()); - pushFollow(FOLLOW_decllist_in_decllist513); - decllist9=decllist(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_decllist.add(decllist9.getTree()); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:17: ( decl )* + loop1: + while (true) { + int alt1=2; + int LA1_0 = input.LA(1); + if ( (LA1_0==ID||LA1_0==41||LA1_0==43) ) { + alt1=1; + } + + switch (alt1) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:17: decl + { + pushFollow(FOLLOW_decl_in_decllist494); + decl8=decl(); + state._fsp--; + if (state.failed) return retval; + if ( state.backtracking==0 ) stream_decl.add(decl8.getTree()); + } + break; + + default : + break loop1; + } + } + // AST REWRITE - // elements: decl, decllist + // elements: decl // token labels: // rule labels: retval // token list labels: @@ -256,14 +239,18 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 66:31: -> ^( DECLIST decl decllist ) + // 65:23: -> ^( DECLLIST ( decl )* ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:34: ^( DECLIST decl decllist ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:26: ^( DECLLIST ( decl )* ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECLIST, "DECLIST"), root_1); - adaptor.addChild(root_1, stream_decl.nextTree()); - adaptor.addChild(root_1, stream_decllist.nextTree()); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECLLIST, "DECLLIST"), root_1); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:65:37: ( decl )* + while ( stream_decl.hasNext() ) { + adaptor.addChild(root_1, stream_decl.nextTree()); + } + stream_decl.reset(); + adaptor.addChild(root_0, root_1); } @@ -303,53 +290,68 @@ public class XParser extends Parser { // $ANTLR start "decl" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:1: decl : modifier ID ':' type ';' -> ^( DECL modifier ID type ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:1: decl : ( modifier )? ID ':' type ';' -> ^( DECL ( modifier )? ID type ) ; public final XParser.decl_return decl() throws RecognitionException { XParser.decl_return retval = new XParser.decl_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token ID11=null; - Token char_literal12=null; - Token char_literal14=null; - ParserRuleReturnScope modifier10 =null; - ParserRuleReturnScope type13 =null; + Token ID10=null; + Token char_literal11=null; + Token char_literal13=null; + ParserRuleReturnScope modifier9 =null; + ParserRuleReturnScope type12 =null; - CommonTree ID11_tree=null; - CommonTree char_literal12_tree=null; - CommonTree char_literal14_tree=null; - RewriteRuleTokenStream stream_27=new RewriteRuleTokenStream(adaptor,"token 27"); - RewriteRuleTokenStream stream_29=new RewriteRuleTokenStream(adaptor,"token 29"); + CommonTree ID10_tree=null; + CommonTree char_literal11_tree=null; + CommonTree char_literal13_tree=null; + RewriteRuleTokenStream stream_28=new RewriteRuleTokenStream(adaptor,"token 28"); RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID"); + RewriteRuleTokenStream stream_30=new RewriteRuleTokenStream(adaptor,"token 30"); RewriteRuleSubtreeStream stream_modifier=new RewriteRuleSubtreeStream(adaptor,"rule modifier"); RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:5: ( modifier ID ':' type ';' -> ^( DECL modifier ID type ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:17: modifier ID ':' type ';' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:5: ( ( modifier )? ID ':' type ';' -> ^( DECL ( modifier )? ID type ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:17: ( modifier )? ID ':' type ';' { - pushFollow(FOLLOW_modifier_in_decl539); - modifier10=modifier(); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:17: ( modifier )? + int alt2=2; + int LA2_0 = input.LA(1); + if ( (LA2_0==41||LA2_0==43) ) { + alt2=1; + } + switch (alt2) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:17: modifier + { + pushFollow(FOLLOW_modifier_in_decl520); + modifier9=modifier(); + state._fsp--; + if (state.failed) return retval; + if ( state.backtracking==0 ) stream_modifier.add(modifier9.getTree()); + } + break; + + } + + ID10=(Token)match(input,ID,FOLLOW_ID_in_decl523); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_ID.add(ID10); + + char_literal11=(Token)match(input,28,FOLLOW_28_in_decl525); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_28.add(char_literal11); + + pushFollow(FOLLOW_type_in_decl527); + type12=type(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_modifier.add(modifier10.getTree()); - ID11=(Token)match(input,ID,FOLLOW_ID_in_decl541); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_ID.add(ID11); - - char_literal12=(Token)match(input,27,FOLLOW_27_in_decl543); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_27.add(char_literal12); - - pushFollow(FOLLOW_type_in_decl545); - type13=type(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_type.add(type13.getTree()); - char_literal14=(Token)match(input,29,FOLLOW_29_in_decl547); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_29.add(char_literal14); + if ( state.backtracking==0 ) stream_type.add(type12.getTree()); + char_literal13=(Token)match(input,30,FOLLOW_30_in_decl529); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_30.add(char_literal13); // AST REWRITE - // elements: modifier, type, ID + // elements: ID, type, modifier // token labels: // rule labels: retval // token list labels: @@ -360,13 +362,18 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 67:42: -> ^( DECL modifier ID type ) + // 66:43: -> ^( DECL ( modifier )? ID type ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:45: ^( DECL modifier ID type ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:46: ^( DECL ( modifier )? ID type ) { CommonTree root_1 = (CommonTree)adaptor.nil(); root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECL, "DECL"), root_1); - adaptor.addChild(root_1, stream_modifier.nextTree()); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:66:53: ( modifier )? + if ( stream_modifier.hasNext() ) { + adaptor.addChild(root_1, stream_modifier.nextTree()); + } + stream_modifier.reset(); + adaptor.addChild(root_1, stream_ID.nextNode()); adaptor.addChild(root_1, stream_type.nextTree()); adaptor.addChild(root_0, root_1); @@ -408,34 +415,34 @@ public class XParser extends Parser { // $ANTLR start "modifier" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:1: modifier : ( 'read' ( 'print' )? | 'read' | 'print' ); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:1: modifier : ( 'read' ( 'print' )? | 'read' | 'print' ); public final XParser.modifier_return modifier() throws RecognitionException { XParser.modifier_return retval = new XParser.modifier_return(); retval.start = input.LT(1); CommonTree root_0 = null; + Token string_literal14=null; Token string_literal15=null; Token string_literal16=null; Token string_literal17=null; - Token string_literal18=null; + CommonTree string_literal14_tree=null; CommonTree string_literal15_tree=null; CommonTree string_literal16_tree=null; CommonTree string_literal17_tree=null; - CommonTree string_literal18_tree=null; try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:9: ( 'read' ( 'print' )? | 'read' | 'print' ) - int alt2=3; - int LA2_0 = input.LA(1); - if ( (LA2_0==42) ) { - int LA2_1 = input.LA(2); - if ( (synpred2_X()) ) { - alt2=1; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:9: ( 'read' ( 'print' )? | 'read' | 'print' ) + int alt4=3; + int LA4_0 = input.LA(1); + if ( (LA4_0==43) ) { + int LA4_1 = input.LA(2); + if ( (synpred4_X()) ) { + alt4=1; } - else if ( (synpred3_X()) ) { - alt2=2; + else if ( (synpred5_X()) ) { + alt4=2; } else { @@ -444,7 +451,7 @@ public class XParser extends Parser { try { input.consume(); NoViableAltException nvae = - new NoViableAltException("", 2, 1, input); + new NoViableAltException("", 4, 1, input); throw nvae; } finally { input.rewind(nvaeMark); @@ -452,44 +459,44 @@ public class XParser extends Parser { } } - else if ( (LA2_0==40) ) { - alt2=3; + else if ( (LA4_0==41) ) { + alt4=3; } else { if (state.backtracking>0) {state.failed=true; return retval;} NoViableAltException nvae = - new NoViableAltException("", 2, 0, input); + new NoViableAltException("", 4, 0, input); throw nvae; } - switch (alt2) { + switch (alt4) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:17: 'read' ( 'print' )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:17: 'read' ( 'print' )? { root_0 = (CommonTree)adaptor.nil(); - string_literal15=(Token)match(input,42,FOLLOW_42_in_modifier571); if (state.failed) return retval; + string_literal14=(Token)match(input,43,FOLLOW_43_in_modifier554); if (state.failed) return retval; if ( state.backtracking==0 ) { - string_literal15_tree = (CommonTree)adaptor.create(string_literal15); - adaptor.addChild(root_0, string_literal15_tree); + string_literal14_tree = (CommonTree)adaptor.create(string_literal14); + adaptor.addChild(root_0, string_literal14_tree); } - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:24: ( 'print' )? - int alt1=2; - int LA1_0 = input.LA(1); - if ( (LA1_0==40) ) { - alt1=1; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:24: ( 'print' )? + int alt3=2; + int LA3_0 = input.LA(1); + if ( (LA3_0==41) ) { + alt3=1; } - switch (alt1) { + switch (alt3) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:24: 'print' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:24: 'print' { - string_literal16=(Token)match(input,40,FOLLOW_40_in_modifier573); if (state.failed) return retval; + string_literal15=(Token)match(input,41,FOLLOW_41_in_modifier556); if (state.failed) return retval; if ( state.backtracking==0 ) { - string_literal16_tree = (CommonTree)adaptor.create(string_literal16); - adaptor.addChild(root_0, string_literal16_tree); + string_literal15_tree = (CommonTree)adaptor.create(string_literal15); + adaptor.addChild(root_0, string_literal15_tree); } } @@ -500,29 +507,29 @@ public class XParser extends Parser { } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:35: 'read' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:35: 'read' { root_0 = (CommonTree)adaptor.nil(); - string_literal17=(Token)match(input,42,FOLLOW_42_in_modifier578); if (state.failed) return retval; + string_literal16=(Token)match(input,43,FOLLOW_43_in_modifier561); if (state.failed) return retval; if ( state.backtracking==0 ) { - string_literal17_tree = (CommonTree)adaptor.create(string_literal17); - adaptor.addChild(root_0, string_literal17_tree); + string_literal16_tree = (CommonTree)adaptor.create(string_literal16); + adaptor.addChild(root_0, string_literal16_tree); } } break; case 3 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:44: 'print' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:44: 'print' { root_0 = (CommonTree)adaptor.nil(); - string_literal18=(Token)match(input,40,FOLLOW_40_in_modifier582); if (state.failed) return retval; + string_literal17=(Token)match(input,41,FOLLOW_41_in_modifier565); if (state.failed) return retval; if ( state.backtracking==0 ) { - string_literal18_tree = (CommonTree)adaptor.create(string_literal18); - adaptor.addChild(root_0, string_literal18_tree); + string_literal17_tree = (CommonTree)adaptor.create(string_literal17); + adaptor.addChild(root_0, string_literal17_tree); } } @@ -557,28 +564,28 @@ public class XParser extends Parser { // $ANTLR start "type" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:69:1: type : ( 'int' | 'float' | 'string' ); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:1: type : ( 'int' | 'float' | 'string' ); public final XParser.type_return type() throws RecognitionException { XParser.type_return retval = new XParser.type_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token set19=null; + Token set18=null; - CommonTree set19_tree=null; + CommonTree set18_tree=null; try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:69:5: ( 'int' | 'float' | 'string' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:5: ( 'int' | 'float' | 'string' ) // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g: { root_0 = (CommonTree)adaptor.nil(); - set19=input.LT(1); - if ( input.LA(1)==36||input.LA(1)==39||input.LA(1)==43 ) { + set18=input.LT(1); + if ( input.LA(1)==37||input.LA(1)==40||input.LA(1)==44 ) { input.consume(); - if ( state.backtracking==0 ) adaptor.addChild(root_0, (CommonTree)adaptor.create(set19)); + if ( state.backtracking==0 ) adaptor.addChild(root_0, (CommonTree)adaptor.create(set18)); state.errorRecovery=false; state.failed=false; } @@ -617,64 +624,64 @@ public class XParser extends Parser { // $ANTLR start "statlist" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:1: statlist : 'begin' ( stat ';' )* 'end' -> ^( STATLIST ( stat )* ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:1: statlist : 'begin' ( stat ';' )* 'end' -> ^( STATLIST ( stat )* ) ; public final XParser.statlist_return statlist() throws RecognitionException { XParser.statlist_return retval = new XParser.statlist_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token string_literal20=null; - Token char_literal22=null; - Token string_literal23=null; - ParserRuleReturnScope stat21 =null; + Token string_literal19=null; + Token char_literal21=null; + Token string_literal22=null; + ParserRuleReturnScope stat20 =null; - CommonTree string_literal20_tree=null; - CommonTree char_literal22_tree=null; - CommonTree string_literal23_tree=null; - RewriteRuleTokenStream stream_33=new RewriteRuleTokenStream(adaptor,"token 33"); - RewriteRuleTokenStream stream_35=new RewriteRuleTokenStream(adaptor,"token 35"); - RewriteRuleTokenStream stream_29=new RewriteRuleTokenStream(adaptor,"token 29"); + CommonTree string_literal19_tree=null; + CommonTree char_literal21_tree=null; + CommonTree string_literal22_tree=null; + RewriteRuleTokenStream stream_34=new RewriteRuleTokenStream(adaptor,"token 34"); + RewriteRuleTokenStream stream_36=new RewriteRuleTokenStream(adaptor,"token 36"); + RewriteRuleTokenStream stream_30=new RewriteRuleTokenStream(adaptor,"token 30"); RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:9: ( 'begin' ( stat ';' )* 'end' -> ^( STATLIST ( stat )* ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:17: 'begin' ( stat ';' )* 'end' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:9: ( 'begin' ( stat ';' )* 'end' -> ^( STATLIST ( stat )* ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:17: 'begin' ( stat ';' )* 'end' { - string_literal20=(Token)match(input,33,FOLLOW_33_in_statlist620); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_33.add(string_literal20); + string_literal19=(Token)match(input,34,FOLLOW_34_in_statlist603); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_34.add(string_literal19); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:25: ( stat ';' )* - loop3: + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:25: ( stat ';' )* + loop5: while (true) { - int alt3=2; - int LA3_0 = input.LA(1); - if ( (LA3_0==ID||LA3_0==33||(LA3_0 >= 37 && LA3_0 <= 38)||LA3_0==45) ) { - alt3=1; + int alt5=2; + int LA5_0 = input.LA(1); + if ( (LA5_0==ID||LA5_0==34||(LA5_0 >= 38 && LA5_0 <= 39)||LA5_0==46) ) { + alt5=1; } - switch (alt3) { + switch (alt5) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:26: stat ';' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:26: stat ';' { - pushFollow(FOLLOW_stat_in_statlist623); - stat21=stat(); + pushFollow(FOLLOW_stat_in_statlist606); + stat20=stat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_stat.add(stat21.getTree()); - char_literal22=(Token)match(input,29,FOLLOW_29_in_statlist625); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_29.add(char_literal22); + if ( state.backtracking==0 ) stream_stat.add(stat20.getTree()); + char_literal21=(Token)match(input,30,FOLLOW_30_in_statlist608); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_30.add(char_literal21); } break; default : - break loop3; + break loop5; } } - string_literal23=(Token)match(input,35,FOLLOW_35_in_statlist629); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_35.add(string_literal23); + string_literal22=(Token)match(input,36,FOLLOW_36_in_statlist612); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_36.add(string_literal22); // AST REWRITE // elements: stat @@ -688,13 +695,13 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 72:43: -> ^( STATLIST ( stat )* ) + // 71:43: -> ^( STATLIST ( stat )* ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:46: ^( STATLIST ( stat )* ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:46: ^( STATLIST ( stat )* ) { CommonTree root_1 = (CommonTree)adaptor.nil(); root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(STATLIST, "STATLIST"), root_1); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:57: ( stat )* + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:71:57: ( stat )* while ( stream_stat.hasNext() ) { adaptor.addChild(root_1, stream_stat.nextTree()); } @@ -739,123 +746,123 @@ public class XParser extends Parser { // $ANTLR start "stat" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:1: stat : ( assignstat | condstat | whilestat | forstat | statlist ); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:1: stat : ( assignstat | condstat | whilestat | forstat | statlist ); public final XParser.stat_return stat() throws RecognitionException { XParser.stat_return retval = new XParser.stat_return(); retval.start = input.LT(1); CommonTree root_0 = null; - ParserRuleReturnScope assignstat24 =null; - ParserRuleReturnScope condstat25 =null; - ParserRuleReturnScope whilestat26 =null; - ParserRuleReturnScope forstat27 =null; - ParserRuleReturnScope statlist28 =null; + ParserRuleReturnScope assignstat23 =null; + ParserRuleReturnScope condstat24 =null; + ParserRuleReturnScope whilestat25 =null; + ParserRuleReturnScope forstat26 =null; + ParserRuleReturnScope statlist27 =null; try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:5: ( assignstat | condstat | whilestat | forstat | statlist ) - int alt4=5; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:5: ( assignstat | condstat | whilestat | forstat | statlist ) + int alt6=5; switch ( input.LA(1) ) { case ID: { - alt4=1; + alt6=1; + } + break; + case 39: + { + alt6=2; + } + break; + case 46: + { + alt6=3; } break; case 38: { - alt4=2; + alt6=4; } break; - case 45: + case 34: { - alt4=3; - } - break; - case 37: - { - alt4=4; - } - break; - case 33: - { - alt4=5; + alt6=5; } break; default: if (state.backtracking>0) {state.failed=true; return retval;} NoViableAltException nvae = - new NoViableAltException("", 4, 0, input); + new NoViableAltException("", 6, 0, input); throw nvae; } - switch (alt4) { + switch (alt6) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:17: assignstat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:17: assignstat { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_assignstat_in_stat654); - assignstat24=assignstat(); + pushFollow(FOLLOW_assignstat_in_stat637); + assignstat23=assignstat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, assignstat24.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, assignstat23.getTree()); } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:30: condstat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:30: condstat { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_condstat_in_stat658); - condstat25=condstat(); + pushFollow(FOLLOW_condstat_in_stat641); + condstat24=condstat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, condstat25.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, condstat24.getTree()); } break; case 3 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:41: whilestat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:41: whilestat { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_whilestat_in_stat662); - whilestat26=whilestat(); + pushFollow(FOLLOW_whilestat_in_stat645); + whilestat25=whilestat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, whilestat26.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, whilestat25.getTree()); } break; case 4 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:53: forstat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:53: forstat { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_forstat_in_stat666); - forstat27=forstat(); + pushFollow(FOLLOW_forstat_in_stat649); + forstat26=forstat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, forstat27.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, forstat26.getTree()); } break; case 5 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:63: statlist + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:72:63: statlist { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_statlist_in_stat670); - statlist28=statlist(); + pushFollow(FOLLOW_statlist_in_stat653); + statlist27=statlist(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, statlist28.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, statlist27.getTree()); } break; @@ -889,40 +896,40 @@ public class XParser extends Parser { // $ANTLR start "assignstat" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:1: assignstat : ID ':=' expr -> ^( ':=' ID expr ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:1: assignstat : ID ':=' expr -> ^( ':=' ID expr ) ; public final XParser.assignstat_return assignstat() throws RecognitionException { XParser.assignstat_return retval = new XParser.assignstat_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token ID29=null; - Token string_literal30=null; - ParserRuleReturnScope expr31 =null; + Token ID28=null; + Token string_literal29=null; + ParserRuleReturnScope expr30 =null; - CommonTree ID29_tree=null; - CommonTree string_literal30_tree=null; - RewriteRuleTokenStream stream_28=new RewriteRuleTokenStream(adaptor,"token 28"); + CommonTree ID28_tree=null; + CommonTree string_literal29_tree=null; + RewriteRuleTokenStream stream_29=new RewriteRuleTokenStream(adaptor,"token 29"); RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID"); RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:11: ( ID ':=' expr -> ^( ':=' ID expr ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:17: ID ':=' expr + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:11: ( ID ':=' expr -> ^( ':=' ID expr ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:17: ID ':=' expr { - ID29=(Token)match(input,ID,FOLLOW_ID_in_assignstat680); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_ID.add(ID29); + ID28=(Token)match(input,ID,FOLLOW_ID_in_assignstat663); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_ID.add(ID28); - string_literal30=(Token)match(input,28,FOLLOW_28_in_assignstat682); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_28.add(string_literal30); + string_literal29=(Token)match(input,29,FOLLOW_29_in_assignstat665); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_29.add(string_literal29); - pushFollow(FOLLOW_expr_in_assignstat684); - expr31=expr(); + pushFollow(FOLLOW_expr_in_assignstat667); + expr30=expr(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr.add(expr31.getTree()); + if ( state.backtracking==0 ) stream_expr.add(expr30.getTree()); // AST REWRITE - // elements: 28, expr, ID + // elements: ID, expr, 29 // token labels: // rule labels: retval // token list labels: @@ -933,12 +940,12 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 74:30: -> ^( ':=' ID expr ) + // 73:30: -> ^( ':=' ID expr ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:33: ^( ':=' ID expr ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:73:33: ^( ':=' ID expr ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_28.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_29.nextNode(), root_1); adaptor.addChild(root_1, stream_ID.nextNode()); adaptor.addChild(root_1, stream_expr.nextTree()); adaptor.addChild(root_0, root_1); @@ -980,72 +987,72 @@ public class XParser extends Parser { // $ANTLR start "condstat" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:1: condstat : 'if' cond 'then' stat ( condElseStat )? -> ^( 'if' cond stat ( condElseStat )? ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:1: condstat : 'if' cond 'then' stat ( condElseStat )? -> ^( 'if' cond stat ( condElseStat )? ) ; public final XParser.condstat_return condstat() throws RecognitionException { XParser.condstat_return retval = new XParser.condstat_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token string_literal32=null; - Token string_literal34=null; - ParserRuleReturnScope cond33 =null; - ParserRuleReturnScope stat35 =null; - ParserRuleReturnScope condElseStat36 =null; + Token string_literal31=null; + Token string_literal33=null; + ParserRuleReturnScope cond32 =null; + ParserRuleReturnScope stat34 =null; + ParserRuleReturnScope condElseStat35 =null; - CommonTree string_literal32_tree=null; - CommonTree string_literal34_tree=null; - RewriteRuleTokenStream stream_44=new RewriteRuleTokenStream(adaptor,"token 44"); - RewriteRuleTokenStream stream_38=new RewriteRuleTokenStream(adaptor,"token 38"); + CommonTree string_literal31_tree=null; + CommonTree string_literal33_tree=null; + RewriteRuleTokenStream stream_45=new RewriteRuleTokenStream(adaptor,"token 45"); + RewriteRuleTokenStream stream_39=new RewriteRuleTokenStream(adaptor,"token 39"); RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat"); RewriteRuleSubtreeStream stream_condElseStat=new RewriteRuleSubtreeStream(adaptor,"rule condElseStat"); RewriteRuleSubtreeStream stream_cond=new RewriteRuleSubtreeStream(adaptor,"rule cond"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:9: ( 'if' cond 'then' stat ( condElseStat )? -> ^( 'if' cond stat ( condElseStat )? ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:17: 'if' cond 'then' stat ( condElseStat )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:9: ( 'if' cond 'then' stat ( condElseStat )? -> ^( 'if' cond stat ( condElseStat )? ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:17: 'if' cond 'then' stat ( condElseStat )? { - string_literal32=(Token)match(input,38,FOLLOW_38_in_condstat706); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_38.add(string_literal32); + string_literal31=(Token)match(input,39,FOLLOW_39_in_condstat689); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_39.add(string_literal31); - pushFollow(FOLLOW_cond_in_condstat708); - cond33=cond(); + pushFollow(FOLLOW_cond_in_condstat691); + cond32=cond(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_cond.add(cond33.getTree()); - string_literal34=(Token)match(input,44,FOLLOW_44_in_condstat710); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_44.add(string_literal34); + if ( state.backtracking==0 ) stream_cond.add(cond32.getTree()); + string_literal33=(Token)match(input,45,FOLLOW_45_in_condstat693); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_45.add(string_literal33); - pushFollow(FOLLOW_stat_in_condstat712); - stat35=stat(); + pushFollow(FOLLOW_stat_in_condstat695); + stat34=stat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_stat.add(stat35.getTree()); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:39: ( condElseStat )? - int alt5=2; - int LA5_0 = input.LA(1); - if ( (LA5_0==34) ) { - int LA5_1 = input.LA(2); - if ( (synpred11_X()) ) { - alt5=1; + if ( state.backtracking==0 ) stream_stat.add(stat34.getTree()); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:39: ( condElseStat )? + int alt7=2; + int LA7_0 = input.LA(1); + if ( (LA7_0==35) ) { + int LA7_1 = input.LA(2); + if ( (synpred13_X()) ) { + alt7=1; } } - switch (alt5) { + switch (alt7) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:39: condElseStat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:39: condElseStat { - pushFollow(FOLLOW_condElseStat_in_condstat714); - condElseStat36=condElseStat(); + pushFollow(FOLLOW_condElseStat_in_condstat697); + condElseStat35=condElseStat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_condElseStat.add(condElseStat36.getTree()); + if ( state.backtracking==0 ) stream_condElseStat.add(condElseStat35.getTree()); } break; } // AST REWRITE - // elements: stat, 38, cond, condElseStat + // elements: cond, 39, stat, condElseStat // token labels: // rule labels: retval // token list labels: @@ -1056,15 +1063,15 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 75:53: -> ^( 'if' cond stat ( condElseStat )? ) + // 74:53: -> ^( 'if' cond stat ( condElseStat )? ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:56: ^( 'if' cond stat ( condElseStat )? ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:56: ^( 'if' cond stat ( condElseStat )? ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_38.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_39.nextNode(), root_1); adaptor.addChild(root_1, stream_cond.nextTree()); adaptor.addChild(root_1, stream_stat.nextTree()); - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:73: ( condElseStat )? + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:73: ( condElseStat )? if ( stream_condElseStat.hasNext() ) { adaptor.addChild(root_1, stream_condElseStat.nextTree()); } @@ -1109,34 +1116,34 @@ public class XParser extends Parser { // $ANTLR start "condElseStat" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:1: condElseStat : 'else' stat -> ^( 'else' stat ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:1: condElseStat : 'else' stat -> ^( 'else' stat ) ; public final XParser.condElseStat_return condElseStat() throws RecognitionException { XParser.condElseStat_return retval = new XParser.condElseStat_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token string_literal37=null; - ParserRuleReturnScope stat38 =null; + Token string_literal36=null; + ParserRuleReturnScope stat37 =null; - CommonTree string_literal37_tree=null; - RewriteRuleTokenStream stream_34=new RewriteRuleTokenStream(adaptor,"token 34"); + CommonTree string_literal36_tree=null; + RewriteRuleTokenStream stream_35=new RewriteRuleTokenStream(adaptor,"token 35"); RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:13: ( 'else' stat -> ^( 'else' stat ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:17: 'else' stat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:13: ( 'else' stat -> ^( 'else' stat ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:17: 'else' stat { - string_literal37=(Token)match(input,34,FOLLOW_34_in_condElseStat737); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_34.add(string_literal37); + string_literal36=(Token)match(input,35,FOLLOW_35_in_condElseStat720); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_35.add(string_literal36); - pushFollow(FOLLOW_stat_in_condElseStat739); - stat38=stat(); + pushFollow(FOLLOW_stat_in_condElseStat722); + stat37=stat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_stat.add(stat38.getTree()); + if ( state.backtracking==0 ) stream_stat.add(stat37.getTree()); // AST REWRITE - // elements: 34, stat + // elements: 35, stat // token labels: // rule labels: retval // token list labels: @@ -1147,12 +1154,12 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 76:29: -> ^( 'else' stat ) + // 75:29: -> ^( 'else' stat ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:32: ^( 'else' stat ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:32: ^( 'else' stat ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_34.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_35.nextNode(), root_1); adaptor.addChild(root_1, stream_stat.nextTree()); adaptor.addChild(root_0, root_1); } @@ -1193,53 +1200,53 @@ public class XParser extends Parser { // $ANTLR start "whilestat" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:1: whilestat : 'while' '(' cond ')' stat -> ^( 'while' cond stat ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:1: whilestat : 'while' '(' cond ')' stat -> ^( 'while' cond stat ) ; public final XParser.whilestat_return whilestat() throws RecognitionException { XParser.whilestat_return retval = new XParser.whilestat_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token string_literal39=null; - Token char_literal40=null; - Token char_literal42=null; - ParserRuleReturnScope cond41 =null; - ParserRuleReturnScope stat43 =null; + Token string_literal38=null; + Token char_literal39=null; + Token char_literal41=null; + ParserRuleReturnScope cond40 =null; + ParserRuleReturnScope stat42 =null; - CommonTree string_literal39_tree=null; - CommonTree char_literal40_tree=null; - CommonTree char_literal42_tree=null; - RewriteRuleTokenStream stream_45=new RewriteRuleTokenStream(adaptor,"token 45"); - RewriteRuleTokenStream stream_20=new RewriteRuleTokenStream(adaptor,"token 20"); + CommonTree string_literal38_tree=null; + CommonTree char_literal39_tree=null; + CommonTree char_literal41_tree=null; + RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22"); + RewriteRuleTokenStream stream_46=new RewriteRuleTokenStream(adaptor,"token 46"); RewriteRuleTokenStream stream_21=new RewriteRuleTokenStream(adaptor,"token 21"); RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat"); RewriteRuleSubtreeStream stream_cond=new RewriteRuleSubtreeStream(adaptor,"rule cond"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:10: ( 'while' '(' cond ')' stat -> ^( 'while' cond stat ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:17: 'while' '(' cond ')' stat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:10: ( 'while' '(' cond ')' stat -> ^( 'while' cond stat ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:17: 'while' '(' cond ')' stat { - string_literal39=(Token)match(input,45,FOLLOW_45_in_whilestat758); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_45.add(string_literal39); + string_literal38=(Token)match(input,46,FOLLOW_46_in_whilestat741); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_46.add(string_literal38); - char_literal40=(Token)match(input,20,FOLLOW_20_in_whilestat760); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_20.add(char_literal40); + char_literal39=(Token)match(input,21,FOLLOW_21_in_whilestat743); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_21.add(char_literal39); - pushFollow(FOLLOW_cond_in_whilestat762); - cond41=cond(); + pushFollow(FOLLOW_cond_in_whilestat745); + cond40=cond(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_cond.add(cond41.getTree()); - char_literal42=(Token)match(input,21,FOLLOW_21_in_whilestat764); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_21.add(char_literal42); + if ( state.backtracking==0 ) stream_cond.add(cond40.getTree()); + char_literal41=(Token)match(input,22,FOLLOW_22_in_whilestat747); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_22.add(char_literal41); - pushFollow(FOLLOW_stat_in_whilestat766); - stat43=stat(); + pushFollow(FOLLOW_stat_in_whilestat749); + stat42=stat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_stat.add(stat43.getTree()); + if ( state.backtracking==0 ) stream_stat.add(stat42.getTree()); // AST REWRITE - // elements: stat, 45, cond + // elements: cond, stat, 46 // token labels: // rule labels: retval // token list labels: @@ -1250,12 +1257,12 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 77:43: -> ^( 'while' cond stat ) + // 76:43: -> ^( 'while' cond stat ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:46: ^( 'while' cond stat ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:76:46: ^( 'while' cond stat ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_45.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_46.nextNode(), root_1); adaptor.addChild(root_1, stream_cond.nextTree()); adaptor.addChild(root_1, stream_stat.nextTree()); adaptor.addChild(root_0, root_1); @@ -1297,77 +1304,77 @@ public class XParser extends Parser { // $ANTLR start "forstat" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:78:1: forstat : 'for' '(' assignstat ';' cond ';' assignstat ')' stat -> ^( 'for' assignstat cond assignstat stat ) ; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:1: forstat : 'for' '(' assignstat ';' cond ';' assignstat ')' stat -> ^( 'for' assignstat cond assignstat stat ) ; public final XParser.forstat_return forstat() throws RecognitionException { XParser.forstat_return retval = new XParser.forstat_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token string_literal44=null; - Token char_literal45=null; - Token char_literal47=null; - Token char_literal49=null; - Token char_literal51=null; - ParserRuleReturnScope assignstat46 =null; - ParserRuleReturnScope cond48 =null; - ParserRuleReturnScope assignstat50 =null; - ParserRuleReturnScope stat52 =null; + Token string_literal43=null; + Token char_literal44=null; + Token char_literal46=null; + Token char_literal48=null; + Token char_literal50=null; + ParserRuleReturnScope assignstat45 =null; + ParserRuleReturnScope cond47 =null; + ParserRuleReturnScope assignstat49 =null; + ParserRuleReturnScope stat51 =null; - CommonTree string_literal44_tree=null; - CommonTree char_literal45_tree=null; - CommonTree char_literal47_tree=null; - CommonTree char_literal49_tree=null; - CommonTree char_literal51_tree=null; - RewriteRuleTokenStream stream_37=new RewriteRuleTokenStream(adaptor,"token 37"); - RewriteRuleTokenStream stream_29=new RewriteRuleTokenStream(adaptor,"token 29"); - RewriteRuleTokenStream stream_20=new RewriteRuleTokenStream(adaptor,"token 20"); + CommonTree string_literal43_tree=null; + CommonTree char_literal44_tree=null; + CommonTree char_literal46_tree=null; + CommonTree char_literal48_tree=null; + CommonTree char_literal50_tree=null; + RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22"); + RewriteRuleTokenStream stream_38=new RewriteRuleTokenStream(adaptor,"token 38"); + RewriteRuleTokenStream stream_30=new RewriteRuleTokenStream(adaptor,"token 30"); RewriteRuleTokenStream stream_21=new RewriteRuleTokenStream(adaptor,"token 21"); RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat"); RewriteRuleSubtreeStream stream_cond=new RewriteRuleSubtreeStream(adaptor,"rule cond"); RewriteRuleSubtreeStream stream_assignstat=new RewriteRuleSubtreeStream(adaptor,"rule assignstat"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:78:8: ( 'for' '(' assignstat ';' cond ';' assignstat ')' stat -> ^( 'for' assignstat cond assignstat stat ) ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:78:17: 'for' '(' assignstat ';' cond ';' assignstat ')' stat + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:8: ( 'for' '(' assignstat ';' cond ';' assignstat ')' stat -> ^( 'for' assignstat cond assignstat stat ) ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:77:17: 'for' '(' assignstat ';' cond ';' assignstat ')' stat { - string_literal44=(Token)match(input,37,FOLLOW_37_in_forstat789); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_37.add(string_literal44); + string_literal43=(Token)match(input,38,FOLLOW_38_in_forstat772); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_38.add(string_literal43); - char_literal45=(Token)match(input,20,FOLLOW_20_in_forstat791); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_20.add(char_literal45); + char_literal44=(Token)match(input,21,FOLLOW_21_in_forstat774); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_21.add(char_literal44); - pushFollow(FOLLOW_assignstat_in_forstat793); - assignstat46=assignstat(); + pushFollow(FOLLOW_assignstat_in_forstat776); + assignstat45=assignstat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_assignstat.add(assignstat46.getTree()); - char_literal47=(Token)match(input,29,FOLLOW_29_in_forstat795); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_29.add(char_literal47); + if ( state.backtracking==0 ) stream_assignstat.add(assignstat45.getTree()); + char_literal46=(Token)match(input,30,FOLLOW_30_in_forstat778); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_30.add(char_literal46); - pushFollow(FOLLOW_cond_in_forstat797); - cond48=cond(); + pushFollow(FOLLOW_cond_in_forstat780); + cond47=cond(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_cond.add(cond48.getTree()); - char_literal49=(Token)match(input,29,FOLLOW_29_in_forstat799); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_29.add(char_literal49); + if ( state.backtracking==0 ) stream_cond.add(cond47.getTree()); + char_literal48=(Token)match(input,30,FOLLOW_30_in_forstat782); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_30.add(char_literal48); - pushFollow(FOLLOW_assignstat_in_forstat801); - assignstat50=assignstat(); + pushFollow(FOLLOW_assignstat_in_forstat784); + assignstat49=assignstat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_assignstat.add(assignstat50.getTree()); - char_literal51=(Token)match(input,21,FOLLOW_21_in_forstat803); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_21.add(char_literal51); + if ( state.backtracking==0 ) stream_assignstat.add(assignstat49.getTree()); + char_literal50=(Token)match(input,22,FOLLOW_22_in_forstat786); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_22.add(char_literal50); - pushFollow(FOLLOW_stat_in_forstat805); - stat52=stat(); + pushFollow(FOLLOW_stat_in_forstat788); + stat51=stat(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_stat.add(stat52.getTree()); + if ( state.backtracking==0 ) stream_stat.add(stat51.getTree()); // AST REWRITE - // elements: assignstat, 37, stat, assignstat, cond + // elements: cond, stat, assignstat, 38, assignstat // token labels: // rule labels: retval // token list labels: @@ -1378,12 +1385,12 @@ public class XParser extends Parser { RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 79:17: -> ^( 'for' assignstat cond assignstat stat ) + // 78:17: -> ^( 'for' assignstat cond assignstat stat ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:79:20: ^( 'for' assignstat cond assignstat stat ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:78:20: ^( 'for' assignstat cond assignstat stat ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_37.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_38.nextNode(), root_1); adaptor.addChild(root_1, stream_assignstat.nextTree()); adaptor.addChild(root_1, stream_cond.nextTree()); adaptor.addChild(root_1, stream_assignstat.nextTree()); @@ -1419,6 +1426,66 @@ public class XParser extends Parser { // $ANTLR end "forstat" + public static class number_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "number" + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:1: number : ( INTCONST | FLOATCONST ); + public final XParser.number_return number() throws RecognitionException { + XParser.number_return retval = new XParser.number_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + Token set52=null; + + CommonTree set52_tree=null; + + try { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:7: ( INTCONST | FLOATCONST ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g: + { + root_0 = (CommonTree)adaptor.nil(); + + + set52=input.LT(1); + if ( input.LA(1)==FLOATCONST||input.LA(1)==INTCONST ) { + input.consume(); + if ( state.backtracking==0 ) adaptor.addChild(root_0, (CommonTree)adaptor.create(set52)); + state.errorRecovery=false; + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return retval;} + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + } + + retval.stop = input.LT(-1); + + if ( state.backtracking==0 ) { + 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 { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "number" + + public static class expr_return extends ParserRuleReturnScope { CommonTree tree; @Override @@ -1427,89 +1494,73 @@ public class XParser extends Parser { // $ANTLR start "expr" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:1: expr : ( expr2 '+' expr -> ^( '+' expr2 expr ) | expr2 '-' expr -> ^( '-' expr2 expr ) | expr2 -> ^( expr2 ) ); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:1: expr : ( expr2 (op= '+' |op= '-' ) expr -> ^( $op expr2 expr ) | expr2 ); public final XParser.expr_return expr() throws RecognitionException { XParser.expr_return retval = new XParser.expr_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token char_literal54=null; - Token char_literal57=null; + Token op=null; ParserRuleReturnScope expr253 =null; - ParserRuleReturnScope expr55 =null; - ParserRuleReturnScope expr256 =null; - ParserRuleReturnScope expr58 =null; - ParserRuleReturnScope expr259 =null; + ParserRuleReturnScope expr54 =null; + ParserRuleReturnScope expr255 =null; - CommonTree char_literal54_tree=null; - CommonTree char_literal57_tree=null; - RewriteRuleTokenStream stream_23=new RewriteRuleTokenStream(adaptor,"token 23"); + CommonTree op_tree=null; RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24"); + RewriteRuleTokenStream stream_25=new RewriteRuleTokenStream(adaptor,"token 25"); RewriteRuleSubtreeStream stream_expr2=new RewriteRuleSubtreeStream(adaptor,"rule expr2"); RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:5: ( expr2 '+' expr -> ^( '+' expr2 expr ) | expr2 '-' expr -> ^( '-' expr2 expr ) | expr2 -> ^( expr2 ) ) - int alt6=3; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:5: ( expr2 (op= '+' |op= '-' ) expr -> ^( $op expr2 expr ) | expr2 ) + int alt9=2; switch ( input.LA(1) ) { - case FLOATCONST: - case INTCONST: + case 25: { - int LA6_1 = input.LA(2); - if ( (synpred12_X()) ) { - alt6=1; - } - else if ( (synpred13_X()) ) { - alt6=2; + int LA9_1 = input.LA(2); + if ( (synpred16_X()) ) { + alt9=1; } else if ( (true) ) { - alt6=3; + alt9=2; } } break; - case 24: + case FLOATCONST: + case INTCONST: { - int LA6_2 = input.LA(2); - if ( (synpred12_X()) ) { - alt6=1; - } - else if ( (synpred13_X()) ) { - alt6=2; + int LA9_2 = input.LA(2); + if ( (synpred16_X()) ) { + alt9=1; } else if ( (true) ) { - alt6=3; + alt9=2; } } break; case STRINGCONST: { - int LA6_3 = input.LA(2); - if ( (synpred12_X()) ) { - alt6=1; - } - else if ( (synpred13_X()) ) { - alt6=2; + int LA9_3 = input.LA(2); + if ( (synpred16_X()) ) { + alt9=1; } else if ( (true) ) { - alt6=3; + alt9=2; } } break; - case 20: + case 21: { - int LA6_4 = input.LA(2); - if ( (synpred12_X()) ) { - alt6=1; - } - else if ( (synpred13_X()) ) { - alt6=2; + int LA9_4 = input.LA(2); + if ( (synpred16_X()) ) { + alt9=1; } else if ( (true) ) { - alt6=3; + alt9=2; } } @@ -1517,44 +1568,79 @@ public class XParser extends Parser { default: if (state.backtracking>0) {state.failed=true; return retval;} NoViableAltException nvae = - new NoViableAltException("", 6, 0, input); + new NoViableAltException("", 9, 0, input); throw nvae; } - switch (alt6) { + switch (alt9) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:13: expr2 '+' expr + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:13: expr2 (op= '+' |op= '-' ) expr { - pushFollow(FOLLOW_expr2_in_expr848); + pushFollow(FOLLOW_expr2_in_expr846); expr253=expr2(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_expr2.add(expr253.getTree()); - char_literal54=(Token)match(input,23,FOLLOW_23_in_expr850); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_23.add(char_literal54); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:19: (op= '+' |op= '-' ) + int alt8=2; + int LA8_0 = input.LA(1); + if ( (LA8_0==24) ) { + alt8=1; + } + else if ( (LA8_0==25) ) { + alt8=2; + } - pushFollow(FOLLOW_expr_in_expr852); - expr55=expr(); + else { + if (state.backtracking>0) {state.failed=true; return retval;} + NoViableAltException nvae = + new NoViableAltException("", 8, 0, input); + throw nvae; + } + + switch (alt8) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:20: op= '+' + { + op=(Token)match(input,24,FOLLOW_24_in_expr851); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_24.add(op); + + } + break; + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:29: op= '-' + { + op=(Token)match(input,25,FOLLOW_25_in_expr857); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_25.add(op); + + } + break; + + } + + pushFollow(FOLLOW_expr_in_expr860); + expr54=expr(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr.add(expr55.getTree()); + if ( state.backtracking==0 ) stream_expr.add(expr54.getTree()); // AST REWRITE - // elements: expr, 23, expr2 - // token labels: + // elements: op, expr, expr2 + // token labels: op // rule labels: retval // token list labels: // rule list labels: // wildcard labels: if ( state.backtracking==0 ) { retval.tree = root_0; + RewriteRuleTokenStream stream_op=new RewriteRuleTokenStream(adaptor,"token op",op); RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 81:35: -> ^( '+' expr2 expr ) + // 82:45: -> ^( $op expr2 expr ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:38: ^( '+' expr2 expr ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:48: ^( $op expr2 expr ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_23.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_op.nextNode(), root_1); adaptor.addChild(root_1, stream_expr2.nextTree()); adaptor.addChild(root_1, stream_expr.nextTree()); adaptor.addChild(root_0, root_1); @@ -1569,86 +1655,16 @@ public class XParser extends Parser { } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:15: expr2 '-' expr - { - pushFollow(FOLLOW_expr2_in_expr885); - expr256=expr2(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr2.add(expr256.getTree()); - char_literal57=(Token)match(input,24,FOLLOW_24_in_expr887); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_24.add(char_literal57); - - pushFollow(FOLLOW_expr_in_expr889); - expr58=expr(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr.add(expr58.getTree()); - // AST REWRITE - // elements: 24, expr, expr2 - // token labels: - // rule labels: retval - // token list labels: - // rule list labels: - // wildcard labels: - if ( state.backtracking==0 ) { - retval.tree = root_0; - RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); - - root_0 = (CommonTree)adaptor.nil(); - // 82:34: -> ^( '-' expr2 expr ) - { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:37: ^( '-' expr2 expr ) - { - CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_24.nextNode(), root_1); - adaptor.addChild(root_1, stream_expr2.nextTree()); - adaptor.addChild(root_1, stream_expr.nextTree()); - adaptor.addChild(root_0, root_1); - } - - } - - - retval.tree = root_0; - } - - } - break; - case 3 : // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:83:15: expr2 { - pushFollow(FOLLOW_expr2_in_expr919); - expr259=expr2(); + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_expr2_in_expr890); + expr255=expr2(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr2.add(expr259.getTree()); - // AST REWRITE - // elements: expr2 - // token labels: - // rule labels: retval - // token list labels: - // rule list labels: - // wildcard labels: - if ( state.backtracking==0 ) { - retval.tree = root_0; - RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); - - root_0 = (CommonTree)adaptor.nil(); - // 83:37: -> ^( expr2 ) - { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:83:40: ^( expr2 ) - { - CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_expr2.nextNode(), root_1); - adaptor.addChild(root_0, root_1); - } - - } - - - retval.tree = root_0; - } + if ( state.backtracking==0 ) adaptor.addChild(root_0, expr255.getTree()); } break; @@ -1682,89 +1698,73 @@ public class XParser extends Parser { // $ANTLR start "expr2" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:1: expr2 : ( expr3 '*' expr2 -> ^( '*' expr3 expr2 ) | expr3 '/' expr2 -> ^( '/' expr3 expr2 ) | expr3 -> ^( expr3 ) ); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:1: expr2 : ( expr3 (op= '*' |op= '/' ) expr -> ^( $op expr3 expr ) | expr3 ); public final XParser.expr2_return expr2() throws RecognitionException { XParser.expr2_return retval = new XParser.expr2_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token char_literal61=null; - Token char_literal64=null; - ParserRuleReturnScope expr360 =null; - ParserRuleReturnScope expr262 =null; - ParserRuleReturnScope expr363 =null; - ParserRuleReturnScope expr265 =null; - ParserRuleReturnScope expr366 =null; + Token op=null; + ParserRuleReturnScope expr356 =null; + ParserRuleReturnScope expr57 =null; + ParserRuleReturnScope expr358 =null; - CommonTree char_literal61_tree=null; - CommonTree char_literal64_tree=null; - RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22"); - RewriteRuleTokenStream stream_26=new RewriteRuleTokenStream(adaptor,"token 26"); + CommonTree op_tree=null; + RewriteRuleTokenStream stream_23=new RewriteRuleTokenStream(adaptor,"token 23"); + RewriteRuleTokenStream stream_27=new RewriteRuleTokenStream(adaptor,"token 27"); RewriteRuleSubtreeStream stream_expr3=new RewriteRuleSubtreeStream(adaptor,"rule expr3"); - RewriteRuleSubtreeStream stream_expr2=new RewriteRuleSubtreeStream(adaptor,"rule expr2"); + RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:6: ( expr3 '*' expr2 -> ^( '*' expr3 expr2 ) | expr3 '/' expr2 -> ^( '/' expr3 expr2 ) | expr3 -> ^( expr3 ) ) - int alt7=3; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:6: ( expr3 (op= '*' |op= '/' ) expr -> ^( $op expr3 expr ) | expr3 ) + int alt11=2; switch ( input.LA(1) ) { - case FLOATCONST: - case INTCONST: + case 25: { - int LA7_1 = input.LA(2); - if ( (synpred14_X()) ) { - alt7=1; - } - else if ( (synpred15_X()) ) { - alt7=2; + int LA11_1 = input.LA(2); + if ( (synpred18_X()) ) { + alt11=1; } else if ( (true) ) { - alt7=3; + alt11=2; } } break; - case 24: + case FLOATCONST: + case INTCONST: { - int LA7_2 = input.LA(2); - if ( (synpred14_X()) ) { - alt7=1; - } - else if ( (synpred15_X()) ) { - alt7=2; + int LA11_2 = input.LA(2); + if ( (synpred18_X()) ) { + alt11=1; } else if ( (true) ) { - alt7=3; + alt11=2; } } break; case STRINGCONST: { - int LA7_3 = input.LA(2); - if ( (synpred14_X()) ) { - alt7=1; - } - else if ( (synpred15_X()) ) { - alt7=2; + int LA11_3 = input.LA(2); + if ( (synpred18_X()) ) { + alt11=1; } else if ( (true) ) { - alt7=3; + alt11=2; } } break; - case 20: + case 21: { - int LA7_4 = input.LA(2); - if ( (synpred14_X()) ) { - alt7=1; - } - else if ( (synpred15_X()) ) { - alt7=2; + int LA11_4 = input.LA(2); + if ( (synpred18_X()) ) { + alt11=1; } else if ( (true) ) { - alt7=3; + alt11=2; } } @@ -1772,46 +1772,81 @@ public class XParser extends Parser { default: if (state.backtracking>0) {state.failed=true; return retval;} NoViableAltException nvae = - new NoViableAltException("", 7, 0, input); + new NoViableAltException("", 11, 0, input); throw nvae; } - switch (alt7) { + switch (alt11) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:13: expr3 '*' expr2 + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:13: expr3 (op= '*' |op= '/' ) expr { - pushFollow(FOLLOW_expr3_in_expr2952); - expr360=expr3(); + pushFollow(FOLLOW_expr3_in_expr2901); + expr356=expr3(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr3.add(expr360.getTree()); - char_literal61=(Token)match(input,22,FOLLOW_22_in_expr2954); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_22.add(char_literal61); + if ( state.backtracking==0 ) stream_expr3.add(expr356.getTree()); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:19: (op= '*' |op= '/' ) + int alt10=2; + int LA10_0 = input.LA(1); + if ( (LA10_0==23) ) { + alt10=1; + } + else if ( (LA10_0==27) ) { + alt10=2; + } - pushFollow(FOLLOW_expr2_in_expr2956); - expr262=expr2(); + else { + if (state.backtracking>0) {state.failed=true; return retval;} + NoViableAltException nvae = + new NoViableAltException("", 10, 0, input); + throw nvae; + } + + switch (alt10) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:20: op= '*' + { + op=(Token)match(input,23,FOLLOW_23_in_expr2906); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_23.add(op); + + } + break; + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:29: op= '/' + { + op=(Token)match(input,27,FOLLOW_27_in_expr2912); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_27.add(op); + + } + break; + + } + + pushFollow(FOLLOW_expr_in_expr2915); + expr57=expr(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr2.add(expr262.getTree()); + if ( state.backtracking==0 ) stream_expr.add(expr57.getTree()); // AST REWRITE - // elements: 22, expr2, expr3 - // token labels: + // elements: expr3, op, expr + // token labels: op // rule labels: retval // token list labels: // rule list labels: // wildcard labels: if ( state.backtracking==0 ) { retval.tree = root_0; + RewriteRuleTokenStream stream_op=new RewriteRuleTokenStream(adaptor,"token op",op); RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); root_0 = (CommonTree)adaptor.nil(); - // 84:31: -> ^( '*' expr3 expr2 ) + // 84:45: -> ^( $op expr3 expr ) { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:34: ^( '*' expr3 expr2 ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:48: ^( $op expr3 expr ) { CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_22.nextNode(), root_1); + root_1 = (CommonTree)adaptor.becomeRoot(stream_op.nextNode(), root_1); adaptor.addChild(root_1, stream_expr3.nextTree()); - adaptor.addChild(root_1, stream_expr2.nextTree()); + adaptor.addChild(root_1, stream_expr.nextTree()); adaptor.addChild(root_0, root_1); } @@ -1824,86 +1859,16 @@ public class XParser extends Parser { } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:85:15: expr3 '/' expr2 + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:85:15: expr3 { - pushFollow(FOLLOW_expr3_in_expr2984); - expr363=expr3(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr3.add(expr363.getTree()); - char_literal64=(Token)match(input,26,FOLLOW_26_in_expr2986); if (state.failed) return retval; - if ( state.backtracking==0 ) stream_26.add(char_literal64); - - pushFollow(FOLLOW_expr2_in_expr2988); - expr265=expr2(); - state._fsp--; - if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr2.add(expr265.getTree()); - // AST REWRITE - // elements: expr3, expr2, 26 - // token labels: - // rule labels: retval - // token list labels: - // rule list labels: - // wildcard labels: - if ( state.backtracking==0 ) { - retval.tree = root_0; - RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); - root_0 = (CommonTree)adaptor.nil(); - // 85:33: -> ^( '/' expr3 expr2 ) - { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:85:36: ^( '/' expr3 expr2 ) - { - CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_26.nextNode(), root_1); - adaptor.addChild(root_1, stream_expr3.nextTree()); - adaptor.addChild(root_1, stream_expr2.nextTree()); - adaptor.addChild(root_0, root_1); - } - - } - retval.tree = root_0; - } - - } - break; - case 3 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:86:15: expr3 - { - pushFollow(FOLLOW_expr3_in_expr21016); - expr366=expr3(); + pushFollow(FOLLOW_expr3_in_expr2945); + expr358=expr3(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) stream_expr3.add(expr366.getTree()); - // AST REWRITE - // elements: expr3 - // token labels: - // rule labels: retval - // token list labels: - // rule list labels: - // wildcard labels: - if ( state.backtracking==0 ) { - retval.tree = root_0; - RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); - - root_0 = (CommonTree)adaptor.nil(); - // 86:37: -> ^( expr3 ) - { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:86:40: ^( expr3 ) - { - CommonTree root_1 = (CommonTree)adaptor.nil(); - root_1 = (CommonTree)adaptor.becomeRoot(stream_expr3.nextNode(), root_1); - adaptor.addChild(root_0, root_1); - } - - } - - - retval.tree = root_0; - } + if ( state.backtracking==0 ) adaptor.addChild(root_0, expr358.getTree()); } break; @@ -1937,124 +1902,143 @@ public class XParser extends Parser { // $ANTLR start "expr3" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:1: expr3 : ( number | '-' number | STRINGCONST | '(' ! expr ^ ')' ); + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:86:1: expr3 : (op= '-' num= number -> ^( UMINUS[op,\"UMINUS\"] $num) | number | STRINGCONST | '(' ! expr ^ ')' !); public final XParser.expr3_return expr3() throws RecognitionException { XParser.expr3_return retval = new XParser.expr3_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token char_literal68=null; - Token STRINGCONST70=null; - Token char_literal71=null; - Token char_literal73=null; - ParserRuleReturnScope number67 =null; - ParserRuleReturnScope number69 =null; - ParserRuleReturnScope expr72 =null; + Token op=null; + Token STRINGCONST60=null; + Token char_literal61=null; + Token char_literal63=null; + ParserRuleReturnScope num =null; + ParserRuleReturnScope number59 =null; + ParserRuleReturnScope expr62 =null; - CommonTree char_literal68_tree=null; - CommonTree STRINGCONST70_tree=null; - CommonTree char_literal71_tree=null; - CommonTree char_literal73_tree=null; + CommonTree op_tree=null; + CommonTree STRINGCONST60_tree=null; + CommonTree char_literal61_tree=null; + CommonTree char_literal63_tree=null; + RewriteRuleTokenStream stream_25=new RewriteRuleTokenStream(adaptor,"token 25"); + RewriteRuleSubtreeStream stream_number=new RewriteRuleSubtreeStream(adaptor,"rule number"); try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:6: ( number | '-' number | STRINGCONST | '(' ! expr ^ ')' ) - int alt8=4; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:86:6: (op= '-' num= number -> ^( UMINUS[op,\"UMINUS\"] $num) | number | STRINGCONST | '(' ! expr ^ ')' !) + int alt12=4; switch ( input.LA(1) ) { + case 25: + { + alt12=1; + } + break; case FLOATCONST: case INTCONST: { - alt8=1; - } - break; - case 24: - { - alt8=2; + alt12=2; } break; case STRINGCONST: { - alt8=3; + alt12=3; } break; - case 20: + case 21: { - alt8=4; + alt12=4; } break; default: if (state.backtracking>0) {state.failed=true; return retval;} NoViableAltException nvae = - new NoViableAltException("", 8, 0, input); + new NoViableAltException("", 12, 0, input); throw nvae; } - switch (alt8) { + switch (alt12) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:13: number + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:86:13: op= '-' num= number { - root_0 = (CommonTree)adaptor.nil(); + op=(Token)match(input,25,FOLLOW_25_in_expr3958); if (state.failed) return retval; + if ( state.backtracking==0 ) stream_25.add(op); - - pushFollow(FOLLOW_number_in_expr31049); - number67=number(); + pushFollow(FOLLOW_number_in_expr3962); + num=number(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, number67.getTree()); + if ( state.backtracking==0 ) stream_number.add(num.getTree()); + // AST REWRITE + // elements: num + // token labels: + // rule labels: num, retval + // token list labels: + // rule list labels: + // wildcard labels: + if ( state.backtracking==0 ) { + retval.tree = root_0; + RewriteRuleSubtreeStream stream_num=new RewriteRuleSubtreeStream(adaptor,"rule num",num!=null?num.getTree():null); + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 86:45: -> ^( UMINUS[op,\"UMINUS\"] $num) + { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:86:48: ^( UMINUS[op,\"UMINUS\"] $num) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(UMINUS, op, "UMINUS"), root_1); + adaptor.addChild(root_1, stream_num.nextTree()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + } } break; case 2 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:22: '-' number + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:15: number { root_0 = (CommonTree)adaptor.nil(); - char_literal68=(Token)match(input,24,FOLLOW_24_in_expr31053); if (state.failed) return retval; - if ( state.backtracking==0 ) { - char_literal68_tree = (CommonTree)adaptor.create(char_literal68); - adaptor.addChild(root_0, char_literal68_tree); - } - - pushFollow(FOLLOW_number_in_expr31055); - number69=number(); + pushFollow(FOLLOW_number_in_expr31002); + number59=number(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, number69.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, number59.getTree()); } break; case 3 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:35: STRINGCONST + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:24: STRINGCONST { root_0 = (CommonTree)adaptor.nil(); - STRINGCONST70=(Token)match(input,STRINGCONST,FOLLOW_STRINGCONST_in_expr31059); if (state.failed) return retval; + STRINGCONST60=(Token)match(input,STRINGCONST,FOLLOW_STRINGCONST_in_expr31006); if (state.failed) return retval; if ( state.backtracking==0 ) { - STRINGCONST70_tree = (CommonTree)adaptor.create(STRINGCONST70); - adaptor.addChild(root_0, STRINGCONST70_tree); + STRINGCONST60_tree = (CommonTree)adaptor.create(STRINGCONST60); + adaptor.addChild(root_0, STRINGCONST60_tree); } } break; case 4 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:49: '(' ! expr ^ ')' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:87:38: '(' ! expr ^ ')' ! { root_0 = (CommonTree)adaptor.nil(); - char_literal71=(Token)match(input,20,FOLLOW_20_in_expr31063); if (state.failed) return retval; - pushFollow(FOLLOW_expr_in_expr31066); - expr72=expr(); + char_literal61=(Token)match(input,21,FOLLOW_21_in_expr31010); if (state.failed) return retval; + pushFollow(FOLLOW_expr_in_expr31013); + expr62=expr(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) root_0 = (CommonTree)adaptor.becomeRoot(expr72.getTree(), root_0); - char_literal73=(Token)match(input,21,FOLLOW_21_in_expr31069); if (state.failed) return retval; - if ( state.backtracking==0 ) { - char_literal73_tree = (CommonTree)adaptor.create(char_literal73); - adaptor.addChild(root_0, char_literal73_tree); - } - + if ( state.backtracking==0 ) root_0 = (CommonTree)adaptor.becomeRoot(expr62.getTree(), root_0); + char_literal63=(Token)match(input,22,FOLLOW_22_in_expr31016); if (state.failed) return retval; } break; @@ -2079,66 +2063,6 @@ public class XParser extends Parser { // $ANTLR end "expr3" - public static class number_return extends ParserRuleReturnScope { - CommonTree tree; - @Override - public CommonTree getTree() { return tree; } - }; - - - // $ANTLR start "number" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:88:1: number : ( INTCONST | FLOATCONST ); - public final XParser.number_return number() throws RecognitionException { - XParser.number_return retval = new XParser.number_return(); - retval.start = input.LT(1); - - CommonTree root_0 = null; - - Token set74=null; - - CommonTree set74_tree=null; - - try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:88:7: ( INTCONST | FLOATCONST ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g: - { - root_0 = (CommonTree)adaptor.nil(); - - - set74=input.LT(1); - if ( input.LA(1)==FLOATCONST||input.LA(1)==INTCONST ) { - input.consume(); - if ( state.backtracking==0 ) adaptor.addChild(root_0, (CommonTree)adaptor.create(set74)); - state.errorRecovery=false; - state.failed=false; - } - else { - if (state.backtracking>0) {state.failed=true; return retval;} - MismatchedSetException mse = new MismatchedSetException(null,input); - throw mse; - } - } - - retval.stop = input.LT(-1); - - if ( state.backtracking==0 ) { - 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 { - // do for sure before leaving - } - return retval; - } - // $ANTLR end "number" - - public static class compOp_return extends ParserRuleReturnScope { CommonTree tree; @Override @@ -2154,9 +2078,9 @@ public class XParser extends Parser { CommonTree root_0 = null; - Token set75=null; + Token set64=null; - CommonTree set75_tree=null; + CommonTree set64_tree=null; try { // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:90:7: ( '<' | '>' | '=' ) @@ -2165,10 +2089,10 @@ public class XParser extends Parser { root_0 = (CommonTree)adaptor.nil(); - set75=input.LT(1); - if ( (input.LA(1) >= 30 && input.LA(1) <= 32) ) { + set64=input.LT(1); + if ( (input.LA(1) >= 31 && input.LA(1) <= 33) ) { input.consume(); - if ( state.backtracking==0 ) adaptor.addChild(root_0, (CommonTree)adaptor.create(set75)); + if ( state.backtracking==0 ) adaptor.addChild(root_0, (CommonTree)adaptor.create(set64)); state.errorRecovery=false; state.failed=false; } @@ -2214,8 +2138,8 @@ public class XParser extends Parser { CommonTree root_0 = null; - ParserRuleReturnScope expr76 =null; - ParserRuleReturnScope cond277 =null; + ParserRuleReturnScope expr65 =null; + ParserRuleReturnScope cond266 =null; try { @@ -2225,17 +2149,17 @@ public class XParser extends Parser { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_expr_in_cond1114); - expr76=expr(); + pushFollow(FOLLOW_expr_in_cond1049); + expr65=expr(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, expr76.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, expr65.getTree()); - pushFollow(FOLLOW_cond2_in_cond1116); - cond277=cond2(); + pushFollow(FOLLOW_cond2_in_cond1051); + cond266=cond2(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, cond277.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, cond266.getTree()); } @@ -2274,8 +2198,8 @@ public class XParser extends Parser { CommonTree root_0 = null; - ParserRuleReturnScope compOp78 =null; - ParserRuleReturnScope expr79 =null; + ParserRuleReturnScope compOp67 =null; + ParserRuleReturnScope expr68 =null; try { @@ -2285,17 +2209,17 @@ public class XParser extends Parser { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_compOp_in_cond21127); - compOp78=compOp(); + pushFollow(FOLLOW_compOp_in_cond21062); + compOp67=compOp(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, compOp78.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, compOp67.getTree()); - pushFollow(FOLLOW_expr_in_cond21129); - expr79=expr(); + pushFollow(FOLLOW_expr_in_cond21064); + expr68=expr(); state._fsp--; if (state.failed) return retval; - if ( state.backtracking==0 ) adaptor.addChild(root_0, expr79.getTree()); + if ( state.backtracking==0 ) adaptor.addChild(root_0, expr68.getTree()); } @@ -2318,240 +2242,24 @@ public class XParser extends Parser { } // $ANTLR end "cond2" - - public static class minus_return extends ParserRuleReturnScope { - CommonTree tree; - @Override - public CommonTree getTree() { return tree; } - }; - - - // $ANTLR start "minus" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:97:1: minus : '-' ; - public final XParser.minus_return minus() throws RecognitionException { - XParser.minus_return retval = new XParser.minus_return(); - retval.start = input.LT(1); - - CommonTree root_0 = null; - - Token char_literal80=null; - - CommonTree char_literal80_tree=null; - - try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:97:6: ( '-' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:97:13: '-' - { - root_0 = (CommonTree)adaptor.nil(); - - - char_literal80=(Token)match(input,24,FOLLOW_24_in_minus1144); if (state.failed) return retval; - if ( state.backtracking==0 ) { - char_literal80_tree = (CommonTree)adaptor.create(char_literal80); - adaptor.addChild(root_0, char_literal80_tree); - } - - } - - retval.stop = input.LT(-1); - - if ( state.backtracking==0 ) { - 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 { - // do for sure before leaving - } - return retval; - } - // $ANTLR end "minus" - - - public static class div_return extends ParserRuleReturnScope { - CommonTree tree; - @Override - public CommonTree getTree() { return tree; } - }; - - - // $ANTLR start "div" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:98:1: div : '/' ; - public final XParser.div_return div() throws RecognitionException { - XParser.div_return retval = new XParser.div_return(); - retval.start = input.LT(1); - - CommonTree root_0 = null; - - Token char_literal81=null; - - CommonTree char_literal81_tree=null; - - try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:98:4: ( '/' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:98:11: '/' - { - root_0 = (CommonTree)adaptor.nil(); - - - char_literal81=(Token)match(input,26,FOLLOW_26_in_div1155); if (state.failed) return retval; - if ( state.backtracking==0 ) { - char_literal81_tree = (CommonTree)adaptor.create(char_literal81); - adaptor.addChild(root_0, char_literal81_tree); - } - - } - - retval.stop = input.LT(-1); - - if ( state.backtracking==0 ) { - 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 { - // do for sure before leaving - } - return retval; - } - // $ANTLR end "div" - - - public static class multiply_return extends ParserRuleReturnScope { - CommonTree tree; - @Override - public CommonTree getTree() { return tree; } - }; - - - // $ANTLR start "multiply" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:99:1: multiply : '*' ; - public final XParser.multiply_return multiply() throws RecognitionException { - XParser.multiply_return retval = new XParser.multiply_return(); - retval.start = input.LT(1); - - CommonTree root_0 = null; - - Token char_literal82=null; - - CommonTree char_literal82_tree=null; - - try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:99:9: ( '*' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:99:16: '*' - { - root_0 = (CommonTree)adaptor.nil(); - - - char_literal82=(Token)match(input,22,FOLLOW_22_in_multiply1166); if (state.failed) return retval; - if ( state.backtracking==0 ) { - char_literal82_tree = (CommonTree)adaptor.create(char_literal82); - adaptor.addChild(root_0, char_literal82_tree); - } - - } - - retval.stop = input.LT(-1); - - if ( state.backtracking==0 ) { - 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 { - // do for sure before leaving - } - return retval; - } - // $ANTLR end "multiply" - - - public static class plus_return extends ParserRuleReturnScope { - CommonTree tree; - @Override - public CommonTree getTree() { return tree; } - }; - - - // $ANTLR start "plus" - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:100:1: plus : '+' ; - public final XParser.plus_return plus() throws RecognitionException { - XParser.plus_return retval = new XParser.plus_return(); - retval.start = input.LT(1); - - CommonTree root_0 = null; - - Token char_literal83=null; - - CommonTree char_literal83_tree=null; - - try { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:100:5: ( '+' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:100:13: '+' - { - root_0 = (CommonTree)adaptor.nil(); - - - char_literal83=(Token)match(input,23,FOLLOW_23_in_plus1178); if (state.failed) return retval; - if ( state.backtracking==0 ) { - char_literal83_tree = (CommonTree)adaptor.create(char_literal83); - adaptor.addChild(root_0, char_literal83_tree); - } - - } - - retval.stop = input.LT(-1); - - if ( state.backtracking==0 ) { - 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 { - // do for sure before leaving - } - return retval; - } - // $ANTLR end "plus" - - // $ANTLR start synpred2_X - public final void synpred2_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:17: ( 'read' ( 'print' )? ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:17: 'read' ( 'print' )? + // $ANTLR start synpred4_X + public final void synpred4_X_fragment() throws RecognitionException { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:17: ( 'read' ( 'print' )? ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:17: 'read' ( 'print' )? { - match(input,42,FOLLOW_42_in_synpred2_X571); if (state.failed) return; + match(input,43,FOLLOW_43_in_synpred4_X554); if (state.failed) return; - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:24: ( 'print' )? - int alt9=2; - int LA9_0 = input.LA(1); - if ( (LA9_0==40) ) { - alt9=1; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:24: ( 'print' )? + int alt13=2; + int LA13_0 = input.LA(1); + if ( (LA13_0==41) ) { + alt13=1; } - switch (alt9) { + switch (alt13) { case 1 : - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:24: 'print' + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:24: 'print' { - match(input,40,FOLLOW_40_in_synpred2_X573); if (state.failed) return; + match(input,41,FOLLOW_41_in_synpred4_X556); if (state.failed) return; } break; @@ -2561,71 +2269,27 @@ public class XParser extends Parser { } } - // $ANTLR end synpred2_X + // $ANTLR end synpred4_X - // $ANTLR start synpred3_X - public final void synpred3_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:35: ( 'read' ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:68:35: 'read' + // $ANTLR start synpred5_X + public final void synpred5_X_fragment() throws RecognitionException { + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:35: ( 'read' ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:67:35: 'read' { - match(input,42,FOLLOW_42_in_synpred3_X578); if (state.failed) return; + match(input,43,FOLLOW_43_in_synpred5_X561); if (state.failed) return; } } - // $ANTLR end synpred3_X - - // $ANTLR start synpred11_X - public final void synpred11_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:39: ( condElseStat ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:75:39: condElseStat - { - pushFollow(FOLLOW_condElseStat_in_synpred11_X714); - condElseStat(); - state._fsp--; - if (state.failed) return; - - } - - } - // $ANTLR end synpred11_X - - // $ANTLR start synpred12_X - public final void synpred12_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:13: ( expr2 '+' expr ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:81:13: expr2 '+' expr - { - pushFollow(FOLLOW_expr2_in_synpred12_X848); - expr2(); - state._fsp--; - if (state.failed) return; - - match(input,23,FOLLOW_23_in_synpred12_X850); if (state.failed) return; - - pushFollow(FOLLOW_expr_in_synpred12_X852); - expr(); - state._fsp--; - if (state.failed) return; - - } - - } - // $ANTLR end synpred12_X + // $ANTLR end synpred5_X // $ANTLR start synpred13_X public final void synpred13_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:15: ( expr2 '-' expr ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:15: expr2 '-' expr + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:39: ( condElseStat ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:74:39: condElseStat { - pushFollow(FOLLOW_expr2_in_synpred13_X885); - expr2(); - state._fsp--; - if (state.failed) return; - - match(input,24,FOLLOW_24_in_synpred13_X887); if (state.failed) return; - - pushFollow(FOLLOW_expr_in_synpred13_X889); - expr(); + pushFollow(FOLLOW_condElseStat_in_synpred13_X697); + condElseStat(); state._fsp--; if (state.failed) return; @@ -2634,57 +2298,143 @@ public class XParser extends Parser { } // $ANTLR end synpred13_X - // $ANTLR start synpred14_X - public final void synpred14_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:13: ( expr3 '*' expr2 ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:13: expr3 '*' expr2 + // $ANTLR start synpred16_X + public final void synpred16_X_fragment() throws RecognitionException { + Token op=null; + + + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:13: ( expr2 (op= '+' |op= '-' ) expr ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:13: expr2 (op= '+' |op= '-' ) expr { - pushFollow(FOLLOW_expr3_in_synpred14_X952); - expr3(); + pushFollow(FOLLOW_expr2_in_synpred16_X846); + expr2(); state._fsp--; if (state.failed) return; - match(input,22,FOLLOW_22_in_synpred14_X954); if (state.failed) return; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:19: (op= '+' |op= '-' ) + int alt14=2; + int LA14_0 = input.LA(1); + if ( (LA14_0==24) ) { + alt14=1; + } + else if ( (LA14_0==25) ) { + alt14=2; + } - pushFollow(FOLLOW_expr2_in_synpred14_X956); - expr2(); + else { + if (state.backtracking>0) {state.failed=true; return;} + NoViableAltException nvae = + new NoViableAltException("", 14, 0, input); + throw nvae; + } + + switch (alt14) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:20: op= '+' + { + op=(Token)match(input,24,FOLLOW_24_in_synpred16_X851); if (state.failed) return; + + } + break; + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:82:29: op= '-' + { + op=(Token)match(input,25,FOLLOW_25_in_synpred16_X857); if (state.failed) return; + + } + break; + + } + + pushFollow(FOLLOW_expr_in_synpred16_X860); + expr(); state._fsp--; if (state.failed) return; } } - // $ANTLR end synpred14_X + // $ANTLR end synpred16_X - // $ANTLR start synpred15_X - public final void synpred15_X_fragment() throws RecognitionException { - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:85:15: ( expr3 '/' expr2 ) - // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:85:15: expr3 '/' expr2 + // $ANTLR start synpred18_X + public final void synpred18_X_fragment() throws RecognitionException { + Token op=null; + + + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:13: ( expr3 (op= '*' |op= '/' ) expr ) + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:13: expr3 (op= '*' |op= '/' ) expr { - pushFollow(FOLLOW_expr3_in_synpred15_X984); + pushFollow(FOLLOW_expr3_in_synpred18_X901); expr3(); state._fsp--; if (state.failed) return; - match(input,26,FOLLOW_26_in_synpred15_X986); if (state.failed) return; + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:19: (op= '*' |op= '/' ) + int alt15=2; + int LA15_0 = input.LA(1); + if ( (LA15_0==23) ) { + alt15=1; + } + else if ( (LA15_0==27) ) { + alt15=2; + } - pushFollow(FOLLOW_expr2_in_synpred15_X988); - expr2(); + else { + if (state.backtracking>0) {state.failed=true; return;} + NoViableAltException nvae = + new NoViableAltException("", 15, 0, input); + throw nvae; + } + + switch (alt15) { + case 1 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:20: op= '*' + { + op=(Token)match(input,23,FOLLOW_23_in_synpred18_X906); if (state.failed) return; + + } + break; + case 2 : + // C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Parser fuer X-Leer\\src/de/dhbw/compiler/antlrxparser/X.g:84:29: op= '/' + { + op=(Token)match(input,27,FOLLOW_27_in_synpred18_X912); if (state.failed) return; + + } + break; + + } + + pushFollow(FOLLOW_expr_in_synpred18_X915); + expr(); state._fsp--; if (state.failed) return; } } - // $ANTLR end synpred15_X + // $ANTLR end synpred18_X // Delegated rules - public final boolean synpred15_X() { + public final boolean synpred16_X() { state.backtracking++; int start = input.mark(); try { - synpred15_X_fragment(); // can never throw exception + synpred16_X_fragment(); // can never throw exception + } catch (RecognitionException re) { + System.err.println("impossible: "+re); + } + boolean success = !state.failed; + input.rewind(start); + state.backtracking--; + state.failed=false; + return success; + } + public final boolean synpred5_X() { + state.backtracking++; + int start = input.mark(); + try { + synpred5_X_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2708,11 +2458,11 @@ public class XParser extends Parser { state.failed=false; return success; } - public final boolean synpred14_X() { + public final boolean synpred4_X() { state.backtracking++; int start = input.mark(); try { - synpred14_X_fragment(); // can never throw exception + synpred4_X_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2722,53 +2472,11 @@ public class XParser extends Parser { state.failed=false; return success; } - public final boolean synpred3_X() { + public final boolean synpred18_X() { state.backtracking++; int start = input.mark(); try { - synpred3_X_fragment(); // can never throw exception - } catch (RecognitionException re) { - System.err.println("impossible: "+re); - } - boolean success = !state.failed; - input.rewind(start); - state.backtracking--; - state.failed=false; - return success; - } - public final boolean synpred11_X() { - state.backtracking++; - int start = input.mark(); - try { - synpred11_X_fragment(); // can never throw exception - } catch (RecognitionException re) { - System.err.println("impossible: "+re); - } - boolean success = !state.failed; - input.rewind(start); - state.backtracking--; - state.failed=false; - return success; - } - public final boolean synpred2_X() { - state.backtracking++; - int start = input.mark(); - try { - synpred2_X_fragment(); // can never throw exception - } catch (RecognitionException re) { - System.err.println("impossible: "+re); - } - boolean success = !state.failed; - input.rewind(start); - state.backtracking--; - state.failed=false; - return success; - } - public final boolean synpred12_X() { - state.backtracking++; - int start = input.mark(); - try { - synpred12_X_fragment(); // can never throw exception + synpred18_X_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2781,100 +2489,87 @@ public class XParser extends Parser { - public static final BitSet FOLLOW_41_in_program473 = new BitSet(new long[]{0x0000000000000400L}); - public static final BitSet FOLLOW_ID_in_program475 = new BitSet(new long[]{0x0000000020000000L}); - public static final BitSet FOLLOW_29_in_program477 = new BitSet(new long[]{0x0000050000000000L}); - public static final BitSet FOLLOW_decllist_in_program479 = new BitSet(new long[]{0x0000000200000000L}); - public static final BitSet FOLLOW_statlist_in_program481 = new BitSet(new long[]{0x0000000002000000L}); - public static final BitSet FOLLOW_25_in_program483 = new BitSet(new long[]{0x0000000000000000L}); - public static final BitSet FOLLOW_EOF_in_program485 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_decl_in_decllist511 = new BitSet(new long[]{0x0000050000000000L}); - public static final BitSet FOLLOW_decllist_in_decllist513 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_modifier_in_decl539 = new BitSet(new long[]{0x0000000000000400L}); - public static final BitSet FOLLOW_ID_in_decl541 = new BitSet(new long[]{0x0000000008000000L}); - public static final BitSet FOLLOW_27_in_decl543 = new BitSet(new long[]{0x0000089000000000L}); - public static final BitSet FOLLOW_type_in_decl545 = new BitSet(new long[]{0x0000000020000000L}); - public static final BitSet FOLLOW_29_in_decl547 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_42_in_modifier571 = new BitSet(new long[]{0x0000010000000002L}); - public static final BitSet FOLLOW_40_in_modifier573 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_42_in_modifier578 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_40_in_modifier582 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_33_in_statlist620 = new BitSet(new long[]{0x0000206A00000400L}); - public static final BitSet FOLLOW_stat_in_statlist623 = new BitSet(new long[]{0x0000000020000000L}); - public static final BitSet FOLLOW_29_in_statlist625 = new BitSet(new long[]{0x0000206A00000400L}); - public static final BitSet FOLLOW_35_in_statlist629 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_assignstat_in_stat654 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_condstat_in_stat658 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_whilestat_in_stat662 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_forstat_in_stat666 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_statlist_in_stat670 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ID_in_assignstat680 = new BitSet(new long[]{0x0000000010000000L}); - public static final BitSet FOLLOW_28_in_assignstat682 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_assignstat684 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_38_in_condstat706 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_cond_in_condstat708 = new BitSet(new long[]{0x0000100000000000L}); - public static final BitSet FOLLOW_44_in_condstat710 = new BitSet(new long[]{0x0000206200000400L}); - public static final BitSet FOLLOW_stat_in_condstat712 = new BitSet(new long[]{0x0000000400000002L}); - public static final BitSet FOLLOW_condElseStat_in_condstat714 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_34_in_condElseStat737 = new BitSet(new long[]{0x0000206200000400L}); - public static final BitSet FOLLOW_stat_in_condElseStat739 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_45_in_whilestat758 = new BitSet(new long[]{0x0000000000100000L}); - public static final BitSet FOLLOW_20_in_whilestat760 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_cond_in_whilestat762 = new BitSet(new long[]{0x0000000000200000L}); - public static final BitSet FOLLOW_21_in_whilestat764 = new BitSet(new long[]{0x0000206200000400L}); - public static final BitSet FOLLOW_stat_in_whilestat766 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_37_in_forstat789 = new BitSet(new long[]{0x0000000000100000L}); - public static final BitSet FOLLOW_20_in_forstat791 = new BitSet(new long[]{0x0000000000000400L}); - public static final BitSet FOLLOW_assignstat_in_forstat793 = new BitSet(new long[]{0x0000000020000000L}); - public static final BitSet FOLLOW_29_in_forstat795 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_cond_in_forstat797 = new BitSet(new long[]{0x0000000020000000L}); - public static final BitSet FOLLOW_29_in_forstat799 = new BitSet(new long[]{0x0000000000000400L}); - public static final BitSet FOLLOW_assignstat_in_forstat801 = new BitSet(new long[]{0x0000000000200000L}); - public static final BitSet FOLLOW_21_in_forstat803 = new BitSet(new long[]{0x0000206200000400L}); - public static final BitSet FOLLOW_stat_in_forstat805 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr2_in_expr848 = new BitSet(new long[]{0x0000000000800000L}); - public static final BitSet FOLLOW_23_in_expr850 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_expr852 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr2_in_expr885 = new BitSet(new long[]{0x0000000001000000L}); - public static final BitSet FOLLOW_24_in_expr887 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_expr889 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr2_in_expr919 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr3_in_expr2952 = new BitSet(new long[]{0x0000000000400000L}); - public static final BitSet FOLLOW_22_in_expr2954 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr2_in_expr2956 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr3_in_expr2984 = new BitSet(new long[]{0x0000000004000000L}); - public static final BitSet FOLLOW_26_in_expr2986 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr2_in_expr2988 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr3_in_expr21016 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_number_in_expr31049 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_24_in_expr31053 = new BitSet(new long[]{0x0000000000000A00L}); - public static final BitSet FOLLOW_number_in_expr31055 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_STRINGCONST_in_expr31059 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_20_in_expr31063 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_expr31066 = new BitSet(new long[]{0x0000000000200000L}); - public static final BitSet FOLLOW_21_in_expr31069 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr_in_cond1114 = new BitSet(new long[]{0x00000001C0000000L}); - public static final BitSet FOLLOW_cond2_in_cond1116 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_compOp_in_cond21127 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_cond21129 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_24_in_minus1144 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_26_in_div1155 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_22_in_multiply1166 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_23_in_plus1178 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_42_in_synpred2_X571 = new BitSet(new long[]{0x0000010000000002L}); - public static final BitSet FOLLOW_40_in_synpred2_X573 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_42_in_synpred3_X578 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_condElseStat_in_synpred11_X714 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr2_in_synpred12_X848 = new BitSet(new long[]{0x0000000000800000L}); - public static final BitSet FOLLOW_23_in_synpred12_X850 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_synpred12_X852 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr2_in_synpred13_X885 = new BitSet(new long[]{0x0000000001000000L}); - public static final BitSet FOLLOW_24_in_synpred13_X887 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr_in_synpred13_X889 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr3_in_synpred14_X952 = new BitSet(new long[]{0x0000000000400000L}); - public static final BitSet FOLLOW_22_in_synpred14_X954 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr2_in_synpred14_X956 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_expr3_in_synpred15_X984 = new BitSet(new long[]{0x0000000004000000L}); - public static final BitSet FOLLOW_26_in_synpred15_X986 = new BitSet(new long[]{0x0000000001120A00L}); - public static final BitSet FOLLOW_expr2_in_synpred15_X988 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_42_in_program464 = new BitSet(new long[]{0x0000000000000400L}); + public static final BitSet FOLLOW_ID_in_program467 = new BitSet(new long[]{0x0000000040000000L}); + public static final BitSet FOLLOW_30_in_program469 = new BitSet(new long[]{0x00000A0400000400L}); + public static final BitSet FOLLOW_decllist_in_program472 = new BitSet(new long[]{0x0000000400000000L}); + public static final BitSet FOLLOW_statlist_in_program474 = new BitSet(new long[]{0x0000000004000000L}); + public static final BitSet FOLLOW_26_in_program476 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_EOF_in_program479 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_decl_in_decllist494 = new BitSet(new long[]{0x00000A0000000402L}); + public static final BitSet FOLLOW_modifier_in_decl520 = new BitSet(new long[]{0x0000000000000400L}); + public static final BitSet FOLLOW_ID_in_decl523 = new BitSet(new long[]{0x0000000010000000L}); + public static final BitSet FOLLOW_28_in_decl525 = new BitSet(new long[]{0x0000112000000000L}); + public static final BitSet FOLLOW_type_in_decl527 = new BitSet(new long[]{0x0000000040000000L}); + public static final BitSet FOLLOW_30_in_decl529 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_43_in_modifier554 = new BitSet(new long[]{0x0000020000000002L}); + public static final BitSet FOLLOW_41_in_modifier556 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_43_in_modifier561 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_41_in_modifier565 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_34_in_statlist603 = new BitSet(new long[]{0x000040D400000400L}); + public static final BitSet FOLLOW_stat_in_statlist606 = new BitSet(new long[]{0x0000000040000000L}); + public static final BitSet FOLLOW_30_in_statlist608 = new BitSet(new long[]{0x000040D400000400L}); + public static final BitSet FOLLOW_36_in_statlist612 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_assignstat_in_stat637 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_condstat_in_stat641 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_whilestat_in_stat645 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_forstat_in_stat649 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_statlist_in_stat653 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ID_in_assignstat663 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_assignstat665 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_assignstat667 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_39_in_condstat689 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_cond_in_condstat691 = new BitSet(new long[]{0x0000200000000000L}); + public static final BitSet FOLLOW_45_in_condstat693 = new BitSet(new long[]{0x000040C400000400L}); + public static final BitSet FOLLOW_stat_in_condstat695 = new BitSet(new long[]{0x0000000800000002L}); + public static final BitSet FOLLOW_condElseStat_in_condstat697 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_35_in_condElseStat720 = new BitSet(new long[]{0x000040C400000400L}); + public static final BitSet FOLLOW_stat_in_condElseStat722 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_46_in_whilestat741 = new BitSet(new long[]{0x0000000000200000L}); + public static final BitSet FOLLOW_21_in_whilestat743 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_cond_in_whilestat745 = new BitSet(new long[]{0x0000000000400000L}); + public static final BitSet FOLLOW_22_in_whilestat747 = new BitSet(new long[]{0x000040C400000400L}); + public static final BitSet FOLLOW_stat_in_whilestat749 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_38_in_forstat772 = new BitSet(new long[]{0x0000000000200000L}); + public static final BitSet FOLLOW_21_in_forstat774 = new BitSet(new long[]{0x0000000000000400L}); + public static final BitSet FOLLOW_assignstat_in_forstat776 = new BitSet(new long[]{0x0000000040000000L}); + public static final BitSet FOLLOW_30_in_forstat778 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_cond_in_forstat780 = new BitSet(new long[]{0x0000000040000000L}); + public static final BitSet FOLLOW_30_in_forstat782 = new BitSet(new long[]{0x0000000000000400L}); + public static final BitSet FOLLOW_assignstat_in_forstat784 = new BitSet(new long[]{0x0000000000400000L}); + public static final BitSet FOLLOW_22_in_forstat786 = new BitSet(new long[]{0x000040C400000400L}); + public static final BitSet FOLLOW_stat_in_forstat788 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr2_in_expr846 = new BitSet(new long[]{0x0000000003000000L}); + public static final BitSet FOLLOW_24_in_expr851 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_25_in_expr857 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_expr860 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr2_in_expr890 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr3_in_expr2901 = new BitSet(new long[]{0x0000000008800000L}); + public static final BitSet FOLLOW_23_in_expr2906 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_27_in_expr2912 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_expr2915 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr3_in_expr2945 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_25_in_expr3958 = new BitSet(new long[]{0x0000000000000A00L}); + public static final BitSet FOLLOW_number_in_expr3962 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_number_in_expr31002 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRINGCONST_in_expr31006 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_21_in_expr31010 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_expr31013 = new BitSet(new long[]{0x0000000000400000L}); + public static final BitSet FOLLOW_22_in_expr31016 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr_in_cond1049 = new BitSet(new long[]{0x0000000380000000L}); + public static final BitSet FOLLOW_cond2_in_cond1051 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_compOp_in_cond21062 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_cond21064 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_43_in_synpred4_X554 = new BitSet(new long[]{0x0000020000000002L}); + public static final BitSet FOLLOW_41_in_synpred4_X556 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_43_in_synpred5_X561 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_condElseStat_in_synpred13_X697 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr2_in_synpred16_X846 = new BitSet(new long[]{0x0000000003000000L}); + public static final BitSet FOLLOW_24_in_synpred16_X851 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_25_in_synpred16_X857 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_synpred16_X860 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr3_in_synpred18_X901 = new BitSet(new long[]{0x0000000008800000L}); + public static final BitSet FOLLOW_23_in_synpred18_X906 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_27_in_synpred18_X912 = new BitSet(new long[]{0x0000000002220A00L}); + public static final BitSet FOLLOW_expr_in_synpred18_X915 = new BitSet(new long[]{0x0000000000000002L}); } diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.g b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.g index d6cb0b7..d892806 100644 --- a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.g +++ b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.g @@ -25,7 +25,8 @@ tokens { FLOATCONST; WS; MODIFIER; - DECLIST; + DECLLIST; + UMINUS; PROGRAM; DECL; TYPE; @@ -54,17 +55,15 @@ ESCAPE: '\\' ('\"' |'\'' | '\\'); WS: ('\t' | ' ' | '\r' | '\n' | '\f')+ { skip(); }; -INVALID: .; - fragment DIGIT: ('0'..'9'); // -- Parser stuff -program: 'program' ID ';' decllist statlist '.' EOF -> ^(PROGRAM ID decllist statlist); +program: 'program'^ ID ';'! decllist statlist '.'! EOF!; // Declaration -decllist: decl decllist -> ^(DECLIST decl decllist); -decl: modifier ID ':' type ';' -> ^(DECL modifier ID type); +decllist: decl* -> ^(DECLLIST decl*); +decl: modifier? ID ':' type ';' -> ^(DECL modifier? ID type); modifier: 'read' 'print'? | 'read' | 'print'; type: 'int' | 'float' | 'string'; @@ -78,23 +77,16 @@ whilestat: 'while' '(' cond ')' stat -> ^('while' cond stat); forstat: 'for' '(' assignstat ';' cond ';' assignstat ')' stat -> ^('for' assignstat cond assignstat stat); -expr: expr2 '+' expr -> ^('+' expr2 expr) - | expr2 '-' expr -> ^('-' expr2 expr) - | expr2 -> ^(expr2); -expr2: expr3 '*' expr2 -> ^('*' expr3 expr2) - | expr3 '/' expr2 -> ^('/' expr3 expr2) - | expr3 -> ^(expr3); -expr3: number | '-' number | STRINGCONST | '('! expr^ ')'; +// Expressions number: INTCONST | FLOATCONST; +expr: expr2 (op='+' | op='-') expr -> ^($op expr2 expr) + | expr2; +expr2: expr3 (op='*' | op='/') expr -> ^($op expr3 expr) + | expr3; +expr3: op='-' num=number -> ^(UMINUS[op,"UMINUS"] $num) + | number | STRINGCONST | '('! expr^ ')'!; +// Conditions and comparison compOp: '<' | '>' | '='; cond: expr cond2; cond2: compOp expr; - -// -- Dummy rules -// Das sollte dafür sorgen, dass implizite Tokens auch ihre Tokens bekommen -// TODO: Remove this -minus: '-'; -div: '/'; -multiply: '*'; -plus: '+'; diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.tokens b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.tokens index f7075a8..e3113d8 100644 --- a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.tokens +++ b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/X.tokens @@ -1,4 +1,3 @@ -T__20=20 T__21=21 T__22=22 T__23=23 @@ -24,8 +23,9 @@ T__42=42 T__43=43 T__44=44 T__45=45 +T__46=46 DECL=4 -DECLIST=5 +DECLLIST=5 DIGIT=6 ESCAPE=7 EXPR=8 @@ -39,30 +39,31 @@ STAT=15 STATLIST=16 STRINGCONST=17 TYPE=18 -WS=19 -'('=20 -')'=21 -'*'=22 -'+'=23 -'-'=24 -'.'=25 -'/'=26 -':'=27 -':='=28 -';'=29 -'<'=30 -'='=31 -'>'=32 -'begin'=33 -'else'=34 -'end'=35 -'float'=36 -'for'=37 -'if'=38 -'int'=39 -'print'=40 -'program'=41 -'read'=42 -'string'=43 -'then'=44 -'while'=45 +UMINUS=19 +WS=20 +'('=21 +')'=22 +'*'=23 +'+'=24 +'-'=25 +'.'=26 +'/'=27 +':'=28 +':='=29 +';'=30 +'<'=31 +'='=32 +'>'=33 +'begin'=34 +'else'=35 +'end'=36 +'float'=37 +'for'=38 +'if'=39 +'int'=40 +'print'=41 +'program'=42 +'read'=43 +'string'=44 +'then'=45 +'while'=46 diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA12.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA12.class index cb15dbf..0867e6d 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA12.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA12.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA9.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA9.class index 226d08d..fcf7a54 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA9.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer$DFA9.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer.class index 24cf2b6..91d65e0 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XLexer.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$assignstat_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$assignstat_return.class index c14b0e9..d82a3e9 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$assignstat_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$assignstat_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$compOp_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$compOp_return.class index 5b4e7dd..3a37e60 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$compOp_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$compOp_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond2_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond2_return.class index 203dadc..70d8f2c 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond2_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond2_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condElseStat_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condElseStat_return.class index c94606f..1f2c1ee 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condElseStat_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condElseStat_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond_return.class index 3b00a06..6152dec 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$cond_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condstat_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condstat_return.class index 01f4fcf..a112f0e 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condstat_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$condstat_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decl_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decl_return.class index 0e627a8..5dc301f 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decl_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decl_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decllist_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decllist_return.class index 4ff9fcb..33f687a 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decllist_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$decllist_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$div_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$div_return.class deleted file mode 100644 index 3bc8f93..0000000 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$div_return.class and /dev/null differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr2_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr2_return.class index 2567897..28f8e11 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr2_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr2_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr3_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr3_return.class index a3da040..cd9c5bc 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr3_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr3_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr_return.class index 4240979..e802c5b 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$expr_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$forstat_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$forstat_return.class index 2db82ca..5d2606a 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$forstat_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$forstat_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$minus_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$minus_return.class deleted file mode 100644 index 6cde354..0000000 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$minus_return.class and /dev/null differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$modifier_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$modifier_return.class index ebacce9..e946719 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$modifier_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$modifier_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$multiply_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$multiply_return.class deleted file mode 100644 index c873502..0000000 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$multiply_return.class and /dev/null differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$number_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$number_return.class index ee6ef79..505a258 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$number_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$number_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$plus_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$plus_return.class deleted file mode 100644 index 3db831a..0000000 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$plus_return.class and /dev/null differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$program_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$program_return.class index f1fff25..8c9ba4f 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$program_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$program_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$stat_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$stat_return.class index 336315f..78e11b3 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$stat_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$stat_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$statlist_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$statlist_return.class index 8ef0fb4..683cf5f 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$statlist_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$statlist_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$type_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$type_return.class index f929342..7c88abe 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$type_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$type_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$whilestat_return.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$whilestat_return.class index 7c794da..5bea62c 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$whilestat_return.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser$whilestat_return.class differ diff --git a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser.class b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser.class index 4ca04bf..8dc7cfa 100644 Binary files a/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser.class and b/out/production/CC-Praxis-Antlr Parser fuer X-Leer/de/dhbw/compiler/antlrxparser/XParser.class differ