diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 94d4319..ed8b004 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,41 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -230,26 +196,26 @@ - + - - + + - - + + - - + + - + diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/lib/antlr-3.5.2-complete.jar b/CC-Praxis-Antlr Baumgrammatiken-Leer/lib/antlr-3.5.2-complete.jar new file mode 100644 index 0000000..260de76 Binary files /dev/null and b/CC-Praxis-Antlr Baumgrammatiken-Leer/lib/antlr-3.5.2-complete.jar differ diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java new file mode 100644 index 0000000..f722b29 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AntlrXTreeGrammarMain.java @@ -0,0 +1,87 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Main-Klasse + * + * ********************************************** + */ + +package de.dhbw.compiler.antlrxtreegrammar; + +import java.io.ByteArrayInputStream; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import org.antlr.runtime.ANTLRInputStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeNodeStream; +import org.antlr.runtime.tree.DOTTreeGenerator; +import org.antlr.runtime.tree.Tree; +import org.antlr.stringtemplate.StringTemplate; + +public class AntlrXTreeGrammarMain { + + public static void saveToGrapvizDOT(Tree tree, String name) throws FileNotFoundException { + StringTemplate dot = (new DOTTreeGenerator()).toDOT(tree); + PrintWriter out = new PrintWriter(name); + out.println(dot.toString()); + out.close(); + } + + private static final String TEST = + "program test2;\n"+ + " x : int;\n"+ + " y : float;\n"+ + " z : string;\n"+ + "begin\n"+ + " x := 4+5+6.2;\n"+ + " y := 3.56+1.2e3+45.e-67+4e34+3E-1;\n"+ + " z := \"Hello \\\"World\\\"\" + \":\";\n"+ + " z := \"Peter\" + 4;\n"+ + " if 2<3 then abc := 5 else abc := 7;\n"+ + " while (x>y) y := y+1;\n"+ + " begin\n"+ + " for (x:=1; x<6; x:=x+1) y:=y+2;\n"+ + " end;\n"+ + "end."; + + private static final String TEST2 = + "program test2;\n"+ + "begin\n"+ + " x := 4-5*6*7+8/9;\n"+ + "end."; + + private static final String BEISPIELFOLIEN = + "program test5;\n"+ + " read x : int;\n"+ + " print y : float;\n"+ + " z : int;\n"+ + "begin\n"+ + " while (x<4) begin\n"+ + " for (z:=0; z<4; z:=z+1) x:=x+2;\n"+ + " if x=4 then begin\n"+ + " x:=z*(x+2);\n"+ + " x:=x+10;\n"+ + " end else y:=100.e-3;\n"+ + " end;\n"+ + "end.\n"; + + public static void main(String[] args) throws Exception { + + ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(BEISPIELFOLIEN.getBytes())); + XLexer lexer = new XLexer(input); + XParser parser = new XParser(new CommonTokenStream(lexer)); + CommonTree tree = parser.program().getTree(); + + // Tut nichts + XTreeGrammar treeGrammar = new XTreeGrammar(new CommonTreeNodeStream(tree)); + tree = treeGrammar.program().getTree(); + + // Z�hle Zuweisungen + // TODO + + } +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g new file mode 100644 index 0000000..5177348 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.g @@ -0,0 +1,22 @@ +tree grammar AssignCount; + +options { + language = Java; + output = AST; + tokenVocab = X; + ASTLabelType = CommonTree; +} + +@header {package de.dhbw.compiler.antlrxtreegrammar;} + +@members { + + private int count =0; + + public int getCount() { return count; } + +} + + +program: 'todo'; + diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java new file mode 100644 index 0000000..94e8d20 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.java @@ -0,0 +1,159 @@ +// $ANTLR 3.5.2 C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g 2019-05-23 11:52:00 +package de.dhbw.compiler.antlrxtreegrammar; + +import org.antlr.runtime.*; +import org.antlr.runtime.tree.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + + +@SuppressWarnings("all") +public class AssignCount extends TreeParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "COMMENT", "DECL", "DECLLIST", + "DIGIT", "FLOATCONST", "ID", "INTCONST", "INVALID", "LETTER", "OTHER", + "POSDIGIT", "STATLIST", "STRINGCONST", "UMINUS", "WS", "ZERO", "'('", + "')'", "'*'", "'+'", "'-'", "'.'", "'/'", "':'", "':='", "';'", "'<'", + "'='", "'>'", "'begin'", "'else'", "'end'", "'float'", "'for'", "'if'", + "'int'", "'print'", "'program'", "'read'", "'string'", "'then'", "'while'", + "'todo'" + }; + 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; + public static final int T__24=24; + public static final int T__25=25; + public static final int T__26=26; + public static final int T__27=27; + public static final int T__28=28; + public static final int T__29=29; + public static final int T__30=30; + public static final int T__31=31; + public static final int T__32=32; + public static final int T__33=33; + public static final int T__34=34; + public static final int T__35=35; + public static final int T__36=36; + public static final int T__37=37; + public static final int T__38=38; + public static final int T__39=39; + public static final int T__40=40; + public static final int T__41=41; + public static final int T__42=42; + 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 COMMENT=4; + public static final int DECL=5; + public static final int DECLLIST=6; + public static final int DIGIT=7; + public static final int FLOATCONST=8; + public static final int ID=9; + public static final int INTCONST=10; + public static final int INVALID=11; + public static final int LETTER=12; + public static final int OTHER=13; + public static final int POSDIGIT=14; + public static final int STATLIST=15; + public static final int STRINGCONST=16; + public static final int UMINUS=17; + public static final int WS=18; + public static final int ZERO=19; + public static final int T__46=46; + + // delegates + public TreeParser[] getDelegates() { + return new TreeParser[] {}; + } + + // delegators + + + public AssignCount(TreeNodeStream input) { + this(input, new RecognizerSharedState()); + } + public AssignCount(TreeNodeStream input, RecognizerSharedState state) { + super(input, state); + } + + protected TreeAdaptor adaptor = new CommonTreeAdaptor(); + + public void setTreeAdaptor(TreeAdaptor adaptor) { + this.adaptor = adaptor; + } + public TreeAdaptor getTreeAdaptor() { + return adaptor; + } + @Override public String[] getTokenNames() { return AssignCount.tokenNames; } + @Override public String getGrammarFileName() { return "C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g"; } + + + + private int count =0; + + public int getCount() { return count; } + + + + public static class program_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "program" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:1: program : 'todo' ; + public final AssignCount.program_return program() throws RecognitionException { + AssignCount.program_return retval = new AssignCount.program_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree string_literal1=null; + + CommonTree string_literal1_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:8: ( 'todo' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\AssignCount.g:21:15: 'todo' + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + string_literal1=(CommonTree)match(input,46,FOLLOW_46_in_program70); + string_literal1_tree = (CommonTree)adaptor.dupNode(string_literal1); + + + adaptor.addChild(root_0, string_literal1_tree); + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "program" + + // Delegated rules + + + + public static final BitSet FOLLOW_46_in_program70 = new BitSet(new long[]{0x0000000000000002L}); +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens new file mode 100644 index 0000000..7eb8fc1 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/AssignCount.tokens @@ -0,0 +1,70 @@ +T__20=20 +T__21=21 +T__22=22 +T__23=23 +T__24=24 +T__25=25 +T__26=26 +T__27=27 +T__28=28 +T__29=29 +T__30=30 +T__31=31 +T__32=32 +T__33=33 +T__34=34 +T__35=35 +T__36=36 +T__37=37 +T__38=38 +T__39=39 +T__40=40 +T__41=41 +T__42=42 +T__43=43 +T__44=44 +T__45=45 +COMMENT=4 +DECL=5 +DECLLIST=6 +DIGIT=7 +FLOATCONST=8 +ID=9 +INTCONST=10 +INVALID=11 +LETTER=12 +OTHER=13 +POSDIGIT=14 +STATLIST=15 +STRINGCONST=16 +UMINUS=17 +WS=18 +ZERO=19 +T__46=46 +'('=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 +'todo'=46 diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/X.g b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/X.g new file mode 100644 index 0000000..0d9f9eb --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/X.g @@ -0,0 +1,89 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser Baumgrammatiken + * - Grammatik für Scanner und Parser + * + * ********************************************** + */ + +grammar X; + +options { + language = Java; + output = AST; + ASTLabelType = CommonTree; +} + +// AST-Tokens +tokens { + DECL; + STATLIST; + DECLLIST; + UMINUS; +} + +@parser::header {package de.dhbw.compiler.antlrxtreegrammar;} +@lexer::header {package de.dhbw.compiler.antlrxtreegrammar;} + +// Ignore Whitespace +WS: ( '\t' | ' ' | '\r' | '\n' | '\f')+ { skip(); }; +COMMENT: '/*' .* '*/' { skip(); }; + +// Zeichensatz +fragment LETTER: 'a'..'z' | 'A'..'Z'; +fragment POSDIGIT: '1'..'9'; +fragment ZERO: '0'; +fragment DIGIT: '0'..'9'; +fragment OTHER: ' ' | '.' | ':' | '\\"'; + +// Konstanten und Namen +INTCONST: ZERO | (POSDIGIT DIGIT*); + +FLOATCONST: (INTCONST ('.' DIGIT*)? ('e'|'E')('+' |'-' )? INTCONST) => INTCONST ('.' DIGIT*)? ('e'|'E')('+' |'-' )? INTCONST | + INTCONST ('.' DIGIT*)?; + +STRINGCONST: '\"' (LETTER|DIGIT|OTHER)* '\"'; + +ID: LETTER (LETTER|DIGIT)*; + +INVALID: .; + +// Deklarationen +decl: ID ':' (type='int' | type='float' | type='string') ';' -> ^(DECL ID $type) + | 'read' ID ':' (type='int' | type='float' | type='string') ';' -> ^(DECL ID $type 'read') + | 'print' ID ':' (type='int' | type='float' | type='string') ';' -> ^(DECL ID $type 'print') + | 'read' 'print' ID ':' (type='int' | type='float' | type='string') ';' -> ^(DECL ID $type 'read' 'print'); + +decllist: decl* -> ^(DECLLIST decl*); + +// Ausdr�cke +expr: multexpr (('+'^ | '-'^) multexpr)*; +multexpr: simpleexpr (('*'^ | '/'^) simpleexpr)*; +simpleexpr: '('! expr ')'! + | INTCONST | '-' INTCONST -> ^(UMINUS INTCONST) + | FLOATCONST | '-' FLOATCONST -> ^(UMINUS FLOATCONST) + | ID | STRINGCONST; + +// Zuweisung +assignstat: ID ':='^ expr; + +// Bedingungen +cond: expr ('<'^ |'>'^ |'='^ ) expr; + +// Bedingte Zuweisung +condstat: 'if'^ cond 'then'! stat (options {greedy=true;}: 'else'! stat)?; + +// Schleifen +whilestat: 'while' '(' cond ')' stat -> ^('while' cond stat); +forstat: 'for'^ '('! assignstat ';'! cond ';'! assignstat ')'! stat; + +// Anweisungen +stat: assignstat | condstat | whilestat | forstat | statlist; + +statlist: 'begin' (stat ';')* 'end' -> ^(STATLIST stat*); + +// Programme +program: 'program' ID ';' decllist statlist '.' EOF -> ^('program' ID decllist statlist); diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/X.tokens b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/X.tokens new file mode 100644 index 0000000..bdfd911 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/X.tokens @@ -0,0 +1,68 @@ +T__20=20 +T__21=21 +T__22=22 +T__23=23 +T__24=24 +T__25=25 +T__26=26 +T__27=27 +T__28=28 +T__29=29 +T__30=30 +T__31=31 +T__32=32 +T__33=33 +T__34=34 +T__35=35 +T__36=36 +T__37=37 +T__38=38 +T__39=39 +T__40=40 +T__41=41 +T__42=42 +T__43=43 +T__44=44 +T__45=45 +COMMENT=4 +DECL=5 +DECLLIST=6 +DIGIT=7 +FLOATCONST=8 +ID=9 +INTCONST=10 +INVALID=11 +LETTER=12 +OTHER=13 +POSDIGIT=14 +STATLIST=15 +STRINGCONST=16 +UMINUS=17 +WS=18 +ZERO=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 diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XLexer.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XLexer.java new file mode 100644 index 0000000..dc06015 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XLexer.java @@ -0,0 +1,2047 @@ +// $ANTLR 3.5.2 C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g 2019-05-23 11:52:00 +package de.dhbw.compiler.antlrxtreegrammar; + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; + +@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; + public static final int T__24=24; + public static final int T__25=25; + public static final int T__26=26; + public static final int T__27=27; + public static final int T__28=28; + public static final int T__29=29; + public static final int T__30=30; + public static final int T__31=31; + public static final int T__32=32; + public static final int T__33=33; + public static final int T__34=34; + public static final int T__35=35; + public static final int T__36=36; + public static final int T__37=37; + public static final int T__38=38; + public static final int T__39=39; + public static final int T__40=40; + public static final int T__41=41; + public static final int T__42=42; + 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 COMMENT=4; + public static final int DECL=5; + public static final int DECLLIST=6; + public static final int DIGIT=7; + public static final int FLOATCONST=8; + public static final int ID=9; + public static final int INTCONST=10; + public static final int INVALID=11; + public static final int LETTER=12; + public static final int OTHER=13; + public static final int POSDIGIT=14; + public static final int STATLIST=15; + public static final int STRINGCONST=16; + public static final int UMINUS=17; + public static final int WS=18; + public static final int ZERO=19; + + // delegates + // delegators + public Lexer[] getDelegates() { + return new Lexer[] {}; + } + + public XLexer() {} + public XLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public XLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + } + @Override public String getGrammarFileName() { return "C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g"; } + + // $ANTLR start "T__20" + public final void mT__20() throws RecognitionException { + try { + int _type = T__20; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:9:7: ( '(' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:9:9: '(' + { + match('('); if (state.failed) return; + } + + 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:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:10:7: ( ')' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:10:9: ')' + { + match(')'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__21" + + // $ANTLR start "T__22" + public final void mT__22() throws RecognitionException { + try { + int _type = T__22; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:11:7: ( '*' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:11:9: '*' + { + match('*'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__22" + + // $ANTLR start "T__23" + public final void mT__23() throws RecognitionException { + try { + int _type = T__23; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:12:7: ( '+' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:12:9: '+' + { + match('+'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__23" + + // $ANTLR start "T__24" + public final void mT__24() throws RecognitionException { + try { + int _type = T__24; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:13:7: ( '-' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:13:9: '-' + { + match('-'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__24" + + // $ANTLR start "T__25" + public final void mT__25() throws RecognitionException { + try { + int _type = T__25; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:14:7: ( '.' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:14:9: '.' + { + match('.'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__25" + + // $ANTLR start "T__26" + public final void mT__26() throws RecognitionException { + try { + int _type = T__26; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:15:7: ( '/' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:15:9: '/' + { + match('/'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__26" + + // $ANTLR start "T__27" + public final void mT__27() throws RecognitionException { + try { + int _type = T__27; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:16:7: ( ':' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:16:9: ':' + { + match(':'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__27" + + // $ANTLR start "T__28" + public final void mT__28() throws RecognitionException { + try { + int _type = T__28; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:17:7: ( ':=' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:17:9: ':=' + { + match(":="); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__28" + + // $ANTLR start "T__29" + public final void mT__29() throws RecognitionException { + try { + int _type = T__29; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:18:7: ( ';' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:18:9: ';' + { + match(';'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__29" + + // $ANTLR start "T__30" + public final void mT__30() throws RecognitionException { + try { + int _type = T__30; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:19:7: ( '<' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:19:9: '<' + { + match('<'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__30" + + // $ANTLR start "T__31" + public final void mT__31() throws RecognitionException { + try { + int _type = T__31; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:20:7: ( '=' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:20:9: '=' + { + match('='); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__31" + + // $ANTLR start "T__32" + public final void mT__32() throws RecognitionException { + try { + int _type = T__32; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:21:7: ( '>' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:21:9: '>' + { + match('>'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__32" + + // $ANTLR start "T__33" + public final void mT__33() throws RecognitionException { + try { + int _type = T__33; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:22:7: ( 'begin' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:22:9: 'begin' + { + match("begin"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__33" + + // $ANTLR start "T__34" + public final void mT__34() throws RecognitionException { + try { + int _type = T__34; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:23:7: ( 'else' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:23:9: 'else' + { + match("else"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__34" + + // $ANTLR start "T__35" + public final void mT__35() throws RecognitionException { + try { + int _type = T__35; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:24:7: ( 'end' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:24:9: 'end' + { + match("end"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__35" + + // $ANTLR start "T__36" + public final void mT__36() throws RecognitionException { + try { + int _type = T__36; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:25:7: ( 'float' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:25:9: 'float' + { + match("float"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__36" + + // $ANTLR start "T__37" + public final void mT__37() throws RecognitionException { + try { + int _type = T__37; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:26:7: ( 'for' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:26:9: 'for' + { + match("for"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__37" + + // $ANTLR start "T__38" + public final void mT__38() throws RecognitionException { + try { + int _type = T__38; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:27:7: ( 'if' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:27:9: 'if' + { + match("if"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__38" + + // $ANTLR start "T__39" + public final void mT__39() throws RecognitionException { + try { + int _type = T__39; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:28:7: ( 'int' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:28:9: 'int' + { + match("int"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__39" + + // $ANTLR start "T__40" + public final void mT__40() throws RecognitionException { + try { + int _type = T__40; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:29:7: ( 'print' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:29:9: 'print' + { + match("print"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__40" + + // $ANTLR start "T__41" + public final void mT__41() throws RecognitionException { + try { + int _type = T__41; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:30:7: ( 'program' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:30:9: 'program' + { + match("program"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__41" + + // $ANTLR start "T__42" + public final void mT__42() throws RecognitionException { + try { + int _type = T__42; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:31:7: ( 'read' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:31:9: 'read' + { + match("read"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__42" + + // $ANTLR start "T__43" + public final void mT__43() throws RecognitionException { + try { + int _type = T__43; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:32:7: ( 'string' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:32:9: 'string' + { + match("string"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__43" + + // $ANTLR start "T__44" + public final void mT__44() throws RecognitionException { + try { + int _type = T__44; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:33:7: ( 'then' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:33:9: 'then' + { + match("then"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__44" + + // $ANTLR start "T__45" + public final void mT__45() throws RecognitionException { + try { + int _type = T__45; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:34:7: ( 'while' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:34:9: 'while' + { + match("while"); if (state.failed) return; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__45" + + // $ANTLR start "WS" + public final void mWS() throws RecognitionException { + try { + int _type = WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:32:3: ( ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:32:9: ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:32:9: ( '\\t' | ' ' | '\\r' | '\\n' | '\\f' )+ + int cnt1=0; + loop1: + while (true) { + int alt1=2; + int LA1_0 = input.LA(1); + if ( ((LA1_0 >= '\t' && LA1_0 <= '\n')||(LA1_0 >= '\f' && LA1_0 <= '\r')||LA1_0==' ') ) { + alt1=1; + } + + switch (alt1) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '\t' && input.LA(1) <= '\n')||(input.LA(1) >= '\f' && input.LA(1) <= '\r')||input.LA(1)==' ' ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + default : + if ( cnt1 >= 1 ) break loop1; + if (state.backtracking>0) {state.failed=true; return;} + EarlyExitException eee = new EarlyExitException(1, input); + throw eee; + } + cnt1++; + } + + if ( state.backtracking==0 ) { skip(); } + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "WS" + + // $ANTLR start "COMMENT" + public final void mCOMMENT() throws RecognitionException { + try { + int _type = COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:33:8: ( '/*' ( . )* '*/' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:33:10: '/*' ( . )* '*/' + { + match("/*"); if (state.failed) return; + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:33:15: ( . )* + loop2: + while (true) { + int alt2=2; + int LA2_0 = input.LA(1); + if ( (LA2_0=='*') ) { + int LA2_1 = input.LA(2); + if ( (LA2_1=='/') ) { + alt2=2; + } + else if ( ((LA2_1 >= '\u0000' && LA2_1 <= '.')||(LA2_1 >= '0' && LA2_1 <= '\uFFFF')) ) { + alt2=1; + } + + } + else if ( ((LA2_0 >= '\u0000' && LA2_0 <= ')')||(LA2_0 >= '+' && LA2_0 <= '\uFFFF')) ) { + alt2=1; + } + + switch (alt2) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:33:15: . + { + matchAny(); if (state.failed) return; + } + break; + + default : + break loop2; + } + } + + match("*/"); if (state.failed) return; + + if ( state.backtracking==0 ) { skip(); } + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "COMMENT" + + // $ANTLR start "LETTER" + public final void mLETTER() throws RecognitionException { + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:36:16: ( 'a' .. 'z' | 'A' .. 'Z' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "LETTER" + + // $ANTLR start "POSDIGIT" + public final void mPOSDIGIT() throws RecognitionException { + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:37:18: ( '1' .. '9' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '1' && input.LA(1) <= '9') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "POSDIGIT" + + // $ANTLR start "ZERO" + public final void mZERO() throws RecognitionException { + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:38:14: ( '0' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:38:20: '0' + { + match('0'); if (state.failed) return; + } + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "ZERO" + + // $ANTLR start "DIGIT" + public final void mDIGIT() throws RecognitionException { + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:39:15: ( '0' .. '9' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "DIGIT" + + // $ANTLR start "OTHER" + public final void mOTHER() throws RecognitionException { + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:40:15: ( ' ' | '.' | ':' | '\\\\\"' ) + int alt3=4; + switch ( input.LA(1) ) { + case ' ': + { + alt3=1; + } + break; + case '.': + { + alt3=2; + } + break; + case ':': + { + alt3=3; + } + break; + case '\\': + { + alt3=4; + } + break; + default: + if (state.backtracking>0) {state.failed=true; return;} + NoViableAltException nvae = + new NoViableAltException("", 3, 0, input); + throw nvae; + } + switch (alt3) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:40:20: ' ' + { + match(' '); if (state.failed) return; + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:40:26: '.' + { + match('.'); if (state.failed) return; + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:40:32: ':' + { + match(':'); if (state.failed) return; + } + break; + case 4 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:40:38: '\\\\\"' + { + match("\\\""); if (state.failed) return; + + } + break; + + } + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "OTHER" + + // $ANTLR start "INTCONST" + public final void mINTCONST() throws RecognitionException { + try { + int _type = INTCONST; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:43:9: ( ZERO | ( POSDIGIT ( DIGIT )* ) ) + int alt5=2; + int LA5_0 = input.LA(1); + if ( (LA5_0=='0') ) { + alt5=1; + } + else if ( ((LA5_0 >= '1' && LA5_0 <= '9')) ) { + alt5=2; + } + + else { + if (state.backtracking>0) {state.failed=true; return;} + NoViableAltException nvae = + new NoViableAltException("", 5, 0, input); + throw nvae; + } + + switch (alt5) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:43:11: ZERO + { + mZERO(); if (state.failed) return; + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:43:18: ( POSDIGIT ( DIGIT )* ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:43:18: ( POSDIGIT ( DIGIT )* ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:43:19: POSDIGIT ( DIGIT )* + { + mPOSDIGIT(); if (state.failed) return; + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:43:28: ( DIGIT )* + loop4: + while (true) { + int alt4=2; + int LA4_0 = input.LA(1); + if ( ((LA4_0 >= '0' && LA4_0 <= '9')) ) { + alt4=1; + } + + switch (alt4) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + default : + break loop4; + } + } + + } + + } + break; + + } + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "INTCONST" + + // $ANTLR start "FLOATCONST" + public final void mFLOATCONST() throws RecognitionException { + try { + int _type = FLOATCONST; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:11: ( ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST )=> INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST | INTCONST ( '.' ( DIGIT )* )? ) + int alt11=2; + alt11 = dfa11.predict(input); + switch (alt11) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:16: ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST )=> INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST + { + mINTCONST(); if (state.failed) return; + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:84: ( '.' ( DIGIT )* )? + int alt7=2; + int LA7_0 = input.LA(1); + if ( (LA7_0=='.') ) { + alt7=1; + } + switch (alt7) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:85: '.' ( DIGIT )* + { + match('.'); if (state.failed) return; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:89: ( DIGIT )* + loop6: + while (true) { + int alt6=2; + int LA6_0 = input.LA(1); + if ( ((LA6_0 >= '0' && LA6_0 <= '9')) ) { + alt6=1; + } + + switch (alt6) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + default : + break loop6; + } + } + + } + break; + + } + + if ( input.LA(1)=='E'||input.LA(1)=='e' ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:107: ( '+' | '-' )? + int alt8=2; + int LA8_0 = input.LA(1); + if ( (LA8_0=='+'||LA8_0=='-') ) { + alt8=1; + } + switch (alt8) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( input.LA(1)=='+'||input.LA(1)=='-' ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + } + + mINTCONST(); if (state.failed) return; + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:46:16: INTCONST ( '.' ( DIGIT )* )? + { + mINTCONST(); if (state.failed) return; + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:46:25: ( '.' ( DIGIT )* )? + int alt10=2; + int LA10_0 = input.LA(1); + if ( (LA10_0=='.') ) { + alt10=1; + } + switch (alt10) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:46:26: '.' ( DIGIT )* + { + match('.'); if (state.failed) return; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:46:30: ( DIGIT )* + loop9: + while (true) { + int alt9=2; + int LA9_0 = input.LA(1); + if ( ((LA9_0 >= '0' && LA9_0 <= '9')) ) { + alt9=1; + } + + switch (alt9) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + default : + break loop9; + } + } + + } + break; + + } + + } + break; + + } + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "FLOATCONST" + + // $ANTLR start "STRINGCONST" + public final void mSTRINGCONST() throws RecognitionException { + try { + int _type = STRINGCONST; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:48:12: ( '\\\"' ( LETTER | DIGIT | OTHER )* '\\\"' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:48:16: '\\\"' ( LETTER | DIGIT | OTHER )* '\\\"' + { + match('\"'); if (state.failed) return; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:48:21: ( LETTER | DIGIT | OTHER )* + loop12: + while (true) { + int alt12=4; + switch ( input.LA(1) ) { + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': + { + alt12=1; + } + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + alt12=2; + } + break; + case ' ': + case '.': + case ':': + case '\\': + { + alt12=3; + } + break; + } + switch (alt12) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:48:22: LETTER + { + mLETTER(); if (state.failed) return; + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:48:29: DIGIT + { + mDIGIT(); if (state.failed) return; + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:48:35: OTHER + { + mOTHER(); if (state.failed) return; + + } + break; + + default : + break loop12; + } + } + + match('\"'); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "STRINGCONST" + + // $ANTLR start "ID" + public final void mID() throws RecognitionException { + try { + int _type = ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:50:3: ( LETTER ( LETTER | DIGIT )* ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:50:11: LETTER ( LETTER | DIGIT )* + { + mLETTER(); if (state.failed) return; + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:50:18: ( LETTER | DIGIT )* + loop13: + while (true) { + int alt13=2; + int LA13_0 = input.LA(1); + if ( ((LA13_0 >= '0' && LA13_0 <= '9')||(LA13_0 >= 'A' && LA13_0 <= 'Z')||(LA13_0 >= 'a' && LA13_0 <= 'z')) ) { + alt13=1; + } + + switch (alt13) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9')||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + default : + break loop13; + } + } + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "ID" + + // $ANTLR start "INVALID" + public final void mINVALID() throws RecognitionException { + try { + int _type = INVALID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:52:8: ( . ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:52:11: . + { + matchAny(); if (state.failed) return; + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "INVALID" + + @Override + public void mTokens() throws RecognitionException { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\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 | WS | COMMENT | INTCONST | FLOATCONST | STRINGCONST | ID | INVALID ) + int alt14=33; + alt14 = dfa14.predict(input); + switch (alt14) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:10: T__20 + { + mT__20(); if (state.failed) return; + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:16: T__21 + { + mT__21(); if (state.failed) return; + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:22: T__22 + { + mT__22(); if (state.failed) return; + + } + break; + case 4 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:28: T__23 + { + mT__23(); if (state.failed) return; + + } + break; + case 5 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:34: T__24 + { + mT__24(); if (state.failed) return; + + } + break; + case 6 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:40: T__25 + { + mT__25(); if (state.failed) return; + + } + break; + case 7 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:46: T__26 + { + mT__26(); if (state.failed) return; + + } + break; + case 8 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:52: T__27 + { + mT__27(); if (state.failed) return; + + } + break; + case 9 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:58: T__28 + { + mT__28(); if (state.failed) return; + + } + break; + case 10 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:64: T__29 + { + mT__29(); if (state.failed) return; + + } + break; + case 11 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:70: T__30 + { + mT__30(); if (state.failed) return; + + } + break; + case 12 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:76: T__31 + { + mT__31(); if (state.failed) return; + + } + break; + case 13 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:82: T__32 + { + mT__32(); if (state.failed) return; + + } + break; + case 14 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:88: T__33 + { + mT__33(); if (state.failed) return; + + } + break; + case 15 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:94: T__34 + { + mT__34(); if (state.failed) return; + + } + break; + case 16 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:100: T__35 + { + mT__35(); if (state.failed) return; + + } + break; + case 17 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:106: T__36 + { + mT__36(); if (state.failed) return; + + } + break; + case 18 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:112: T__37 + { + mT__37(); if (state.failed) return; + + } + break; + case 19 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:118: T__38 + { + mT__38(); if (state.failed) return; + + } + break; + case 20 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:124: T__39 + { + mT__39(); if (state.failed) return; + + } + break; + case 21 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:130: T__40 + { + mT__40(); if (state.failed) return; + + } + break; + case 22 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:136: T__41 + { + mT__41(); if (state.failed) return; + + } + break; + case 23 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:142: T__42 + { + mT__42(); if (state.failed) return; + + } + break; + case 24 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:148: T__43 + { + mT__43(); if (state.failed) return; + + } + break; + case 25 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:154: T__44 + { + mT__44(); if (state.failed) return; + + } + break; + case 26 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:160: T__45 + { + mT__45(); if (state.failed) return; + + } + break; + case 27 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:166: WS + { + mWS(); if (state.failed) return; + + } + break; + case 28 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:169: COMMENT + { + mCOMMENT(); if (state.failed) return; + + } + break; + case 29 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:177: INTCONST + { + mINTCONST(); if (state.failed) return; + + } + break; + case 30 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:186: FLOATCONST + { + mFLOATCONST(); if (state.failed) return; + + } + break; + case 31 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:197: STRINGCONST + { + mSTRINGCONST(); if (state.failed) return; + + } + break; + case 32 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:209: ID + { + mID(); if (state.failed) return; + + } + break; + case 33 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:1:212: INVALID + { + mINVALID(); if (state.failed) return; + + } + break; + + } + } + + // $ANTLR start synpred1_X + public final void synpred1_X_fragment() throws RecognitionException { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:16: ( INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:17: INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST + { + mINTCONST(); if (state.failed) return; + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:26: ( '.' ( DIGIT )* )? + int alt16=2; + int LA16_0 = input.LA(1); + if ( (LA16_0=='.') ) { + alt16=1; + } + switch (alt16) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:27: '.' ( DIGIT )* + { + match('.'); if (state.failed) return; + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:31: ( DIGIT )* + loop15: + while (true) { + int alt15=2; + int LA15_0 = input.LA(1); + if ( ((LA15_0 >= '0' && LA15_0 <= '9')) ) { + alt15=1; + } + + switch (alt15) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + default : + break loop15; + } + } + + } + break; + + } + + if ( input.LA(1)=='E'||input.LA(1)=='e' ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:45:49: ( '+' | '-' )? + int alt17=2; + int LA17_0 = input.LA(1); + if ( (LA17_0=='+'||LA17_0=='-') ) { + alt17=1; + } + switch (alt17) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g: + { + if ( input.LA(1)=='+'||input.LA(1)=='-' ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + } + break; + + } + + mINTCONST(); if (state.failed) return; + + } + + } + // $ANTLR end synpred1_X + + public final boolean synpred1_X() { + state.backtracking++; + int start = input.mark(); + try { + synpred1_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; + } + + + protected DFA11 dfa11 = new DFA11(this); + protected DFA14 dfa14 = new DFA14(this); + static final String DFA11_eotS = + "\1\uffff\2\3\1\uffff\1\3\1\uffff\2\3"; + static final String DFA11_eofS = + "\10\uffff"; + static final String DFA11_minS = + "\1\60\2\56\1\uffff\1\60\1\uffff\1\56\1\60"; + static final String DFA11_maxS = + "\1\71\2\145\1\uffff\1\145\1\uffff\2\145"; + static final String DFA11_acceptS = + "\3\uffff\1\2\1\uffff\1\1\2\uffff"; + static final String DFA11_specialS = + "\1\uffff\1\4\1\2\1\uffff\1\0\1\uffff\1\1\1\3}>"; + static final String[] DFA11_transitionS = { + "\1\1\11\2", + "\1\4\26\uffff\1\5\37\uffff\1\5", + "\1\4\1\uffff\12\6\13\uffff\1\5\37\uffff\1\5", + "", + "\12\7\13\uffff\1\5\37\uffff\1\5", + "", + "\1\4\1\uffff\12\6\13\uffff\1\5\37\uffff\1\5", + "\12\7\13\uffff\1\5\37\uffff\1\5" + }; + + static final short[] DFA11_eot = DFA.unpackEncodedString(DFA11_eotS); + static final short[] DFA11_eof = DFA.unpackEncodedString(DFA11_eofS); + static final char[] DFA11_min = DFA.unpackEncodedStringToUnsignedChars(DFA11_minS); + static final char[] DFA11_max = DFA.unpackEncodedStringToUnsignedChars(DFA11_maxS); + static final short[] DFA11_accept = DFA.unpackEncodedString(DFA11_acceptS); + static final short[] DFA11_special = DFA.unpackEncodedString(DFA11_specialS); + static final short[][] DFA11_transition; + + static { + int numStates = DFA11_transitionS.length; + DFA11_transition = new short[numStates][]; + for (int i=0; i INTCONST ( '.' ( DIGIT )* )? ( 'e' | 'E' ) ( '+' | '-' )? INTCONST | INTCONST ( '.' ( DIGIT )* )? );"; + } + @Override + public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { + IntStream input = _input; + int _s = s; + switch ( s ) { + case 0 : + int LA11_4 = input.LA(1); + + int index11_4 = input.index(); + input.rewind(); + s = -1; + if ( ((LA11_4 >= '0' && LA11_4 <= '9')) ) {s = 7;} + else if ( (LA11_4=='E'||LA11_4=='e') && (synpred1_X())) {s = 5;} + else s = 3; + + input.seek(index11_4); + if ( s>=0 ) return s; + break; + + case 1 : + int LA11_6 = input.LA(1); + + int index11_6 = input.index(); + input.rewind(); + s = -1; + if ( (LA11_6=='.') ) {s = 4;} + else if ( (LA11_6=='E'||LA11_6=='e') && (synpred1_X())) {s = 5;} + else if ( ((LA11_6 >= '0' && LA11_6 <= '9')) ) {s = 6;} + else s = 3; + + input.seek(index11_6); + if ( s>=0 ) return s; + break; + + case 2 : + int LA11_2 = input.LA(1); + + int index11_2 = input.index(); + input.rewind(); + s = -1; + if ( ((LA11_2 >= '0' && LA11_2 <= '9')) ) {s = 6;} + else if ( (LA11_2=='.') ) {s = 4;} + else if ( (LA11_2=='E'||LA11_2=='e') && (synpred1_X())) {s = 5;} + else s = 3; + + input.seek(index11_2); + if ( s>=0 ) return s; + break; + + case 3 : + int LA11_7 = input.LA(1); + + int index11_7 = input.index(); + input.rewind(); + s = -1; + if ( (LA11_7=='E'||LA11_7=='e') && (synpred1_X())) {s = 5;} + else if ( ((LA11_7 >= '0' && LA11_7 <= '9')) ) {s = 7;} + else s = 3; + + input.seek(index11_7); + if ( s>=0 ) return s; + break; + + case 4 : + int LA11_1 = input.LA(1); + + int index11_1 = input.index(); + input.rewind(); + s = -1; + if ( (LA11_1=='.') ) {s = 4;} + else if ( (LA11_1=='E'||LA11_1=='e') && (synpred1_X())) {s = 5;} + else s = 3; + + input.seek(index11_1); + if ( s>=0 ) return s; + break; + } + if (state.backtracking>0) {state.failed=true; return -1;} + NoViableAltException nvae = + new NoViableAltException(getDescription(), 11, _s, input); + error(nvae); + throw nvae; + } + } + + static final String DFA14_eotS = + "\7\uffff\1\43\1\45\4\uffff\11\53\1\uffff\2\70\1\33\20\uffff\1\53\1\uffff"+ + "\4\53\1\101\6\53\3\uffff\1\70\1\uffff\2\53\1\113\1\53\1\115\1\uffff\1"+ + "\116\7\53\1\126\1\uffff\1\53\2\uffff\2\53\1\132\1\53\1\134\1\53\1\136"+ + "\1\uffff\1\137\1\140\1\53\1\uffff\1\53\1\uffff\1\143\3\uffff\1\53\1\145"+ + "\1\uffff\1\146\2\uffff"; + static final String DFA14_eofS = + "\147\uffff"; + static final String DFA14_minS = + "\1\0\6\uffff\1\52\1\75\4\uffff\1\145\2\154\1\146\1\162\1\145\1\164\2\150"+ + "\1\uffff\2\56\1\40\20\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\3\uffff\1\56\1\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"; + static final String DFA14_maxS = + "\1\uffff\6\uffff\1\52\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\172\20\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\3\uffff\1\145\1\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"; + static final String DFA14_acceptS = + "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\2\uffff\1\12\1\13\1\14\1\15\11\uffff"+ + "\1\33\3\uffff\1\40\1\41\1\1\1\2\1\3\1\4\1\5\1\6\1\34\1\7\1\11\1\10\1\12"+ + "\1\13\1\14\1\15\1\uffff\1\40\13\uffff\1\33\1\35\1\36\1\uffff\1\37\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"; + static final String DFA14_specialS = + "\1\0\146\uffff}>"; + static final String[] DFA14_transitionS = { + "\11\33\2\26\1\33\2\26\22\33\1\26\1\33\1\31\5\33\1\1\1\2\1\3\1\4\1\33"+ + "\1\5\1\6\1\7\1\27\11\30\1\10\1\11\1\12\1\13\1\14\2\33\32\32\6\33\1\32"+ + "\1\15\2\32\1\16\1\17\2\32\1\20\6\32\1\21\1\32\1\22\1\23\1\24\2\32\1\25"+ + "\3\32\uff85\33", + "", + "", + "", + "", + "", + "", + "\1\42", + "\1\44", + "", + "", + "", + "", + "\1\52", + "\1\54\1\uffff\1\55", + "\1\56\2\uffff\1\57", + "\1\60\7\uffff\1\61", + "\1\62", + "\1\63", + "\1\64", + "\1\65", + "\1\66", + "", + "\1\71\26\uffff\1\71\37\uffff\1\71", + "\1\71\1\uffff\12\72\13\uffff\1\71\37\uffff\1\71", + "\1\73\1\uffff\1\73\13\uffff\1\73\1\uffff\13\73\6\uffff\32\73\1\uffff"+ + "\1\73\4\uffff\32\73", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "\1\74", + "", + "\1\75", + "\1\76", + "\1\77", + "\1\100", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "\1\102", + "\1\103\5\uffff\1\104", + "\1\105", + "\1\106", + "\1\107", + "\1\110", + "", + "", + "", + "\1\71\1\uffff\12\72\13\uffff\1\71\37\uffff\1\71", + "", + "\1\111", + "\1\112", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "\1\114", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "\1\117", + "\1\120", + "\1\121", + "\1\122", + "\1\123", + "\1\124", + "\1\125", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "", + "\1\127", + "", + "", + "\1\130", + "\1\131", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "\1\133", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "\1\135", + "\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\141", + "", + "\1\142", + "", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "", + "", + "", + "\1\144", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "", + "\12\53\7\uffff\32\53\6\uffff\32\53", + "", + "" + }; + + static final short[] DFA14_eot = DFA.unpackEncodedString(DFA14_eotS); + static final short[] DFA14_eof = DFA.unpackEncodedString(DFA14_eofS); + static final char[] DFA14_min = DFA.unpackEncodedStringToUnsignedChars(DFA14_minS); + static final char[] DFA14_max = DFA.unpackEncodedStringToUnsignedChars(DFA14_maxS); + static final short[] DFA14_accept = DFA.unpackEncodedString(DFA14_acceptS); + static final short[] DFA14_special = DFA.unpackEncodedString(DFA14_specialS); + static final short[][] DFA14_transition; + + static { + int numStates = DFA14_transitionS.length; + DFA14_transition = new short[numStates][]; + for (int i=0; i') ) {s = 12;} + else if ( (LA14_0=='b') ) {s = 13;} + else if ( (LA14_0=='e') ) {s = 14;} + else if ( (LA14_0=='f') ) {s = 15;} + else if ( (LA14_0=='i') ) {s = 16;} + else if ( (LA14_0=='p') ) {s = 17;} + else if ( (LA14_0=='r') ) {s = 18;} + else if ( (LA14_0=='s') ) {s = 19;} + else if ( (LA14_0=='t') ) {s = 20;} + else if ( (LA14_0=='w') ) {s = 21;} + else if ( ((LA14_0 >= '\t' && LA14_0 <= '\n')||(LA14_0 >= '\f' && LA14_0 <= '\r')||LA14_0==' ') ) {s = 22;} + else if ( (LA14_0=='0') ) {s = 23;} + else if ( ((LA14_0 >= '1' && LA14_0 <= '9')) ) {s = 24;} + else if ( (LA14_0=='\"') ) {s = 25;} + else if ( ((LA14_0 >= 'A' && LA14_0 <= 'Z')||LA14_0=='a'||(LA14_0 >= 'c' && LA14_0 <= 'd')||(LA14_0 >= 'g' && LA14_0 <= 'h')||(LA14_0 >= 'j' && LA14_0 <= 'o')||LA14_0=='q'||(LA14_0 >= 'u' && LA14_0 <= 'v')||(LA14_0 >= 'x' && LA14_0 <= 'z')) ) {s = 26;} + else if ( ((LA14_0 >= '\u0000' && LA14_0 <= '\b')||LA14_0=='\u000B'||(LA14_0 >= '\u000E' && LA14_0 <= '\u001F')||LA14_0=='!'||(LA14_0 >= '#' && LA14_0 <= '\'')||LA14_0==','||(LA14_0 >= '?' && LA14_0 <= '@')||(LA14_0 >= '[' && LA14_0 <= '`')||(LA14_0 >= '{' && LA14_0 <= '\uFFFF')) ) {s = 27;} + if ( s>=0 ) return s; + break; + } + if (state.backtracking>0) {state.failed=true; return -1;} + NoViableAltException nvae = + new NoViableAltException(getDescription(), 14, _s, input); + error(nvae); + throw nvae; + } + } + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XParser.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XParser.java new file mode 100644 index 0000000..aad73ef --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XParser.java @@ -0,0 +1,2153 @@ +// $ANTLR 3.5.2 C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g 2019-05-23 11:51:59 +package de.dhbw.compiler.antlrxtreegrammar; + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +import org.antlr.runtime.tree.*; + + +@SuppressWarnings("all") +public class XParser extends Parser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "COMMENT", "DECL", "DECLLIST", + "DIGIT", "FLOATCONST", "ID", "INTCONST", "INVALID", "LETTER", "OTHER", + "POSDIGIT", "STATLIST", "STRINGCONST", "UMINUS", "WS", "ZERO", "'('", + "')'", "'*'", "'+'", "'-'", "'.'", "'/'", "':'", "':='", "';'", "'<'", + "'='", "'>'", "'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; + public static final int T__24=24; + public static final int T__25=25; + public static final int T__26=26; + public static final int T__27=27; + public static final int T__28=28; + public static final int T__29=29; + public static final int T__30=30; + public static final int T__31=31; + public static final int T__32=32; + public static final int T__33=33; + public static final int T__34=34; + public static final int T__35=35; + public static final int T__36=36; + public static final int T__37=37; + public static final int T__38=38; + public static final int T__39=39; + public static final int T__40=40; + public static final int T__41=41; + public static final int T__42=42; + 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 COMMENT=4; + public static final int DECL=5; + public static final int DECLLIST=6; + public static final int DIGIT=7; + public static final int FLOATCONST=8; + public static final int ID=9; + public static final int INTCONST=10; + public static final int INVALID=11; + public static final int LETTER=12; + public static final int OTHER=13; + public static final int POSDIGIT=14; + public static final int STATLIST=15; + public static final int STRINGCONST=16; + public static final int UMINUS=17; + public static final int WS=18; + public static final int ZERO=19; + + // delegates + public Parser[] getDelegates() { + return new Parser[] {}; + } + + // delegators + + + public XParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public XParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + } + + protected TreeAdaptor adaptor = new CommonTreeAdaptor(); + + public void setTreeAdaptor(TreeAdaptor adaptor) { + this.adaptor = adaptor; + } + public TreeAdaptor getTreeAdaptor() { + return adaptor; + } + @Override public String[] getTokenNames() { return XParser.tokenNames; } + @Override public String getGrammarFileName() { return "C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g"; } + + + public static class decl_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "decl" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:1: decl : ( ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type) | 'read' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type 'read' ) | 'print' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type 'print' ) | 'read' 'print' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type 'read' 'print' ) ); + 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 type=null; + Token ID1=null; + Token char_literal2=null; + Token char_literal3=null; + Token string_literal4=null; + Token ID5=null; + Token char_literal6=null; + Token char_literal7=null; + Token string_literal8=null; + Token ID9=null; + Token char_literal10=null; + Token char_literal11=null; + Token string_literal12=null; + Token string_literal13=null; + Token ID14=null; + Token char_literal15=null; + Token char_literal16=null; + + CommonTree type_tree=null; + CommonTree ID1_tree=null; + CommonTree char_literal2_tree=null; + CommonTree char_literal3_tree=null; + CommonTree string_literal4_tree=null; + CommonTree ID5_tree=null; + CommonTree char_literal6_tree=null; + CommonTree char_literal7_tree=null; + CommonTree string_literal8_tree=null; + CommonTree ID9_tree=null; + CommonTree char_literal10_tree=null; + CommonTree char_literal11_tree=null; + CommonTree string_literal12_tree=null; + CommonTree string_literal13_tree=null; + CommonTree ID14_tree=null; + CommonTree char_literal15_tree=null; + CommonTree char_literal16_tree=null; + RewriteRuleTokenStream stream_36=new RewriteRuleTokenStream(adaptor,"token 36"); + RewriteRuleTokenStream stream_27=new RewriteRuleTokenStream(adaptor,"token 27"); + RewriteRuleTokenStream stream_39=new RewriteRuleTokenStream(adaptor,"token 39"); + RewriteRuleTokenStream stream_29=new RewriteRuleTokenStream(adaptor,"token 29"); + RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID"); + RewriteRuleTokenStream stream_40=new RewriteRuleTokenStream(adaptor,"token 40"); + RewriteRuleTokenStream stream_42=new RewriteRuleTokenStream(adaptor,"token 42"); + RewriteRuleTokenStream stream_43=new RewriteRuleTokenStream(adaptor,"token 43"); + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:5: ( ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type) | 'read' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type 'read' ) | 'print' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type 'print' ) | 'read' 'print' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' -> ^( DECL ID $type 'read' 'print' ) ) + int alt5=4; + switch ( input.LA(1) ) { + case ID: + { + alt5=1; + } + break; + case 42: + { + int LA5_2 = input.LA(2); + if ( (LA5_2==ID) ) { + alt5=2; + } + else if ( (LA5_2==40) ) { + alt5=4; + } + + else { + int nvaeMark = input.mark(); + try { + input.consume(); + NoViableAltException nvae = + new NoViableAltException("", 5, 2, input); + throw nvae; + } finally { + input.rewind(nvaeMark); + } + } + + } + break; + case 40: + { + alt5=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 5, 0, input); + throw nvae; + } + switch (alt5) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:14: ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' + { + ID1=(Token)match(input,ID,FOLLOW_ID_in_decl395); + stream_ID.add(ID1); + + char_literal2=(Token)match(input,27,FOLLOW_27_in_decl397); + stream_27.add(char_literal2); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:21: (type= 'int' |type= 'float' |type= 'string' ) + int alt1=3; + switch ( input.LA(1) ) { + case 39: + { + alt1=1; + } + break; + case 36: + { + alt1=2; + } + break; + case 43: + { + alt1=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 1, 0, input); + throw nvae; + } + switch (alt1) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:22: type= 'int' + { + type=(Token)match(input,39,FOLLOW_39_in_decl402); + stream_39.add(type); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:35: type= 'float' + { + type=(Token)match(input,36,FOLLOW_36_in_decl408); + stream_36.add(type); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:50: type= 'string' + { + type=(Token)match(input,43,FOLLOW_43_in_decl414); + stream_43.add(type); + + } + break; + + } + + char_literal3=(Token)match(input,29,FOLLOW_29_in_decl417); + stream_29.add(char_literal3); + + // AST REWRITE + // elements: ID, type + // token labels: type + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type); + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 55:69: -> ^( DECL ID $type) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:55:72: ^( DECL 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_ID.nextNode()); + adaptor.addChild(root_1, stream_type.nextNode()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:56:14: 'read' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' + { + string_literal4=(Token)match(input,42,FOLLOW_42_in_decl443); + stream_42.add(string_literal4); + + ID5=(Token)match(input,ID,FOLLOW_ID_in_decl445); + stream_ID.add(ID5); + + char_literal6=(Token)match(input,27,FOLLOW_27_in_decl447); + stream_27.add(char_literal6); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:56:28: (type= 'int' |type= 'float' |type= 'string' ) + int alt2=3; + switch ( input.LA(1) ) { + case 39: + { + alt2=1; + } + break; + case 36: + { + alt2=2; + } + break; + case 43: + { + alt2=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 2, 0, input); + throw nvae; + } + switch (alt2) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:56:29: type= 'int' + { + type=(Token)match(input,39,FOLLOW_39_in_decl452); + stream_39.add(type); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:56:42: type= 'float' + { + type=(Token)match(input,36,FOLLOW_36_in_decl458); + stream_36.add(type); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:56:57: type= 'string' + { + type=(Token)match(input,43,FOLLOW_43_in_decl464); + stream_43.add(type); + + } + break; + + } + + char_literal7=(Token)match(input,29,FOLLOW_29_in_decl467); + stream_29.add(char_literal7); + + // AST REWRITE + // elements: 42, type, ID + // token labels: type + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type); + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 56:76: -> ^( DECL ID $type 'read' ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:56:79: ^( DECL ID $type 'read' ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECL, "DECL"), root_1); + adaptor.addChild(root_1, stream_ID.nextNode()); + adaptor.addChild(root_1, stream_type.nextNode()); + adaptor.addChild(root_1, stream_42.nextNode()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:57:14: 'print' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' + { + string_literal8=(Token)match(input,40,FOLLOW_40_in_decl495); + stream_40.add(string_literal8); + + ID9=(Token)match(input,ID,FOLLOW_ID_in_decl497); + stream_ID.add(ID9); + + char_literal10=(Token)match(input,27,FOLLOW_27_in_decl499); + stream_27.add(char_literal10); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:57:29: (type= 'int' |type= 'float' |type= 'string' ) + int alt3=3; + switch ( input.LA(1) ) { + case 39: + { + alt3=1; + } + break; + case 36: + { + alt3=2; + } + break; + case 43: + { + alt3=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 3, 0, input); + throw nvae; + } + switch (alt3) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:57:30: type= 'int' + { + type=(Token)match(input,39,FOLLOW_39_in_decl504); + stream_39.add(type); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:57:43: type= 'float' + { + type=(Token)match(input,36,FOLLOW_36_in_decl510); + stream_36.add(type); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:57:58: type= 'string' + { + type=(Token)match(input,43,FOLLOW_43_in_decl516); + stream_43.add(type); + + } + break; + + } + + char_literal11=(Token)match(input,29,FOLLOW_29_in_decl519); + stream_29.add(char_literal11); + + // AST REWRITE + // elements: ID, 40, type + // token labels: type + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type); + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 57:77: -> ^( DECL ID $type 'print' ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:57:80: ^( DECL ID $type 'print' ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECL, "DECL"), root_1); + adaptor.addChild(root_1, stream_ID.nextNode()); + adaptor.addChild(root_1, stream_type.nextNode()); + adaptor.addChild(root_1, stream_40.nextNode()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + break; + case 4 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:58:14: 'read' 'print' ID ':' (type= 'int' |type= 'float' |type= 'string' ) ';' + { + string_literal12=(Token)match(input,42,FOLLOW_42_in_decl547); + stream_42.add(string_literal12); + + string_literal13=(Token)match(input,40,FOLLOW_40_in_decl549); + stream_40.add(string_literal13); + + ID14=(Token)match(input,ID,FOLLOW_ID_in_decl551); + stream_ID.add(ID14); + + char_literal15=(Token)match(input,27,FOLLOW_27_in_decl553); + stream_27.add(char_literal15); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:58:36: (type= 'int' |type= 'float' |type= 'string' ) + int alt4=3; + switch ( input.LA(1) ) { + case 39: + { + alt4=1; + } + break; + case 36: + { + alt4=2; + } + break; + case 43: + { + alt4=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 4, 0, input); + throw nvae; + } + switch (alt4) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:58:37: type= 'int' + { + type=(Token)match(input,39,FOLLOW_39_in_decl558); + stream_39.add(type); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:58:50: type= 'float' + { + type=(Token)match(input,36,FOLLOW_36_in_decl564); + stream_36.add(type); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:58:65: type= 'string' + { + type=(Token)match(input,43,FOLLOW_43_in_decl570); + stream_43.add(type); + + } + break; + + } + + char_literal16=(Token)match(input,29,FOLLOW_29_in_decl573); + stream_29.add(char_literal16); + + // AST REWRITE + // elements: ID, type, 40, 42 + // token labels: type + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type); + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 58:84: -> ^( DECL ID $type 'read' 'print' ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:58:87: ^( DECL ID $type 'read' 'print' ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECL, "DECL"), root_1); + adaptor.addChild(root_1, stream_ID.nextNode()); + adaptor.addChild(root_1, stream_type.nextNode()); + adaptor.addChild(root_1, stream_42.nextNode()); + adaptor.addChild(root_1, stream_40.nextNode()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + break; + + } + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "decl" + + + public static class decllist_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "decllist" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60: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); + + CommonTree root_0 = null; + + ParserRuleReturnScope decl17 =null; + + RewriteRuleSubtreeStream stream_decl=new RewriteRuleSubtreeStream(adaptor,"rule decl"); + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60:9: ( ( decl )* -> ^( DECLLIST ( decl )* ) ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60:15: ( decl )* + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60:15: ( decl )* + loop6: + while (true) { + int alt6=2; + int LA6_0 = input.LA(1); + if ( (LA6_0==ID||LA6_0==40||LA6_0==42) ) { + alt6=1; + } + + switch (alt6) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60:15: decl + { + pushFollow(FOLLOW_decl_in_decllist599); + decl17=decl(); + state._fsp--; + + stream_decl.add(decl17.getTree()); + } + break; + + default : + break loop6; + } + } + + // AST REWRITE + // elements: decl + // token labels: + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 60:22: -> ^( DECLLIST ( decl )* ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60:25: ^( DECLLIST ( decl )* ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(DECLLIST, "DECLLIST"), root_1); + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:60:36: ( decl )* + while ( stream_decl.hasNext() ) { + adaptor.addChild(root_1, stream_decl.nextTree()); + } + stream_decl.reset(); + + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "decllist" + + + public static class expr_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "expr" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:1: expr : multexpr ( ( '+' ^| '-' ^) multexpr )* ; + 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_literal19=null; + Token char_literal20=null; + ParserRuleReturnScope multexpr18 =null; + ParserRuleReturnScope multexpr21 =null; + + CommonTree char_literal19_tree=null; + CommonTree char_literal20_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:5: ( multexpr ( ( '+' ^| '-' ^) multexpr )* ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:15: multexpr ( ( '+' ^| '-' ^) multexpr )* + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_multexpr_in_expr626); + multexpr18=multexpr(); + state._fsp--; + + adaptor.addChild(root_0, multexpr18.getTree()); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:24: ( ( '+' ^| '-' ^) multexpr )* + loop8: + while (true) { + int alt8=2; + int LA8_0 = input.LA(1); + if ( ((LA8_0 >= 23 && LA8_0 <= 24)) ) { + alt8=1; + } + + switch (alt8) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:25: ( '+' ^| '-' ^) multexpr + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:25: ( '+' ^| '-' ^) + int alt7=2; + int LA7_0 = input.LA(1); + if ( (LA7_0==23) ) { + alt7=1; + } + else if ( (LA7_0==24) ) { + alt7=2; + } + + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 0, input); + throw nvae; + } + + switch (alt7) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:26: '+' ^ + { + char_literal19=(Token)match(input,23,FOLLOW_23_in_expr630); + char_literal19_tree = (CommonTree)adaptor.create(char_literal19); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal19_tree, root_0); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:63:33: '-' ^ + { + char_literal20=(Token)match(input,24,FOLLOW_24_in_expr635); + char_literal20_tree = (CommonTree)adaptor.create(char_literal20); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal20_tree, root_0); + + } + break; + + } + + pushFollow(FOLLOW_multexpr_in_expr639); + multexpr21=multexpr(); + state._fsp--; + + adaptor.addChild(root_0, multexpr21.getTree()); + + } + break; + + default : + break loop8; + } + } + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "expr" + + + public static class multexpr_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "multexpr" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:1: multexpr : simpleexpr ( ( '*' ^| '/' ^) simpleexpr )* ; + public final XParser.multexpr_return multexpr() throws RecognitionException { + XParser.multexpr_return retval = new XParser.multexpr_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + Token char_literal23=null; + Token char_literal24=null; + ParserRuleReturnScope simpleexpr22 =null; + ParserRuleReturnScope simpleexpr25 =null; + + CommonTree char_literal23_tree=null; + CommonTree char_literal24_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:9: ( simpleexpr ( ( '*' ^| '/' ^) simpleexpr )* ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:14: simpleexpr ( ( '*' ^| '/' ^) simpleexpr )* + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_simpleexpr_in_multexpr650); + simpleexpr22=simpleexpr(); + state._fsp--; + + adaptor.addChild(root_0, simpleexpr22.getTree()); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:25: ( ( '*' ^| '/' ^) simpleexpr )* + loop10: + while (true) { + int alt10=2; + int LA10_0 = input.LA(1); + if ( (LA10_0==22||LA10_0==26) ) { + alt10=1; + } + + switch (alt10) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:26: ( '*' ^| '/' ^) simpleexpr + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:26: ( '*' ^| '/' ^) + int alt9=2; + int LA9_0 = input.LA(1); + if ( (LA9_0==22) ) { + alt9=1; + } + else if ( (LA9_0==26) ) { + alt9=2; + } + + else { + NoViableAltException nvae = + new NoViableAltException("", 9, 0, input); + throw nvae; + } + + switch (alt9) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:27: '*' ^ + { + char_literal23=(Token)match(input,22,FOLLOW_22_in_multexpr654); + char_literal23_tree = (CommonTree)adaptor.create(char_literal23); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal23_tree, root_0); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:64:34: '/' ^ + { + char_literal24=(Token)match(input,26,FOLLOW_26_in_multexpr659); + char_literal24_tree = (CommonTree)adaptor.create(char_literal24); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal24_tree, root_0); + + } + break; + + } + + pushFollow(FOLLOW_simpleexpr_in_multexpr663); + simpleexpr25=simpleexpr(); + state._fsp--; + + adaptor.addChild(root_0, simpleexpr25.getTree()); + + } + break; + + default : + break loop10; + } + } + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "multexpr" + + + public static class simpleexpr_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "simpleexpr" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:65:1: simpleexpr : ( '(' ! expr ')' !| INTCONST | '-' INTCONST -> ^( UMINUS INTCONST ) | FLOATCONST | '-' FLOATCONST -> ^( UMINUS FLOATCONST ) | ID | STRINGCONST ); + public final XParser.simpleexpr_return simpleexpr() throws RecognitionException { + XParser.simpleexpr_return retval = new XParser.simpleexpr_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + Token char_literal26=null; + Token char_literal28=null; + Token INTCONST29=null; + Token char_literal30=null; + Token INTCONST31=null; + Token FLOATCONST32=null; + Token char_literal33=null; + Token FLOATCONST34=null; + Token ID35=null; + Token STRINGCONST36=null; + ParserRuleReturnScope expr27 =null; + + CommonTree char_literal26_tree=null; + CommonTree char_literal28_tree=null; + CommonTree INTCONST29_tree=null; + CommonTree char_literal30_tree=null; + CommonTree INTCONST31_tree=null; + CommonTree FLOATCONST32_tree=null; + CommonTree char_literal33_tree=null; + CommonTree FLOATCONST34_tree=null; + CommonTree ID35_tree=null; + CommonTree STRINGCONST36_tree=null; + RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24"); + RewriteRuleTokenStream stream_FLOATCONST=new RewriteRuleTokenStream(adaptor,"token FLOATCONST"); + RewriteRuleTokenStream stream_INTCONST=new RewriteRuleTokenStream(adaptor,"token INTCONST"); + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:65:11: ( '(' ! expr ')' !| INTCONST | '-' INTCONST -> ^( UMINUS INTCONST ) | FLOATCONST | '-' FLOATCONST -> ^( UMINUS FLOATCONST ) | ID | STRINGCONST ) + int alt11=7; + switch ( input.LA(1) ) { + case 20: + { + alt11=1; + } + break; + case INTCONST: + { + alt11=2; + } + break; + case 24: + { + int LA11_3 = input.LA(2); + if ( (LA11_3==INTCONST) ) { + alt11=3; + } + else if ( (LA11_3==FLOATCONST) ) { + alt11=5; + } + + else { + int nvaeMark = input.mark(); + try { + input.consume(); + NoViableAltException nvae = + new NoViableAltException("", 11, 3, input); + throw nvae; + } finally { + input.rewind(nvaeMark); + } + } + + } + break; + case FLOATCONST: + { + alt11=4; + } + break; + case ID: + { + alt11=6; + } + break; + case STRINGCONST: + { + alt11=7; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 11, 0, input); + throw nvae; + } + switch (alt11) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:65:15: '(' ! expr ')' ! + { + root_0 = (CommonTree)adaptor.nil(); + + + char_literal26=(Token)match(input,20,FOLLOW_20_in_simpleexpr673); + pushFollow(FOLLOW_expr_in_simpleexpr676); + expr27=expr(); + state._fsp--; + + adaptor.addChild(root_0, expr27.getTree()); + + char_literal28=(Token)match(input,21,FOLLOW_21_in_simpleexpr678); + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:66:15: INTCONST + { + root_0 = (CommonTree)adaptor.nil(); + + + INTCONST29=(Token)match(input,INTCONST,FOLLOW_INTCONST_in_simpleexpr696); + INTCONST29_tree = (CommonTree)adaptor.create(INTCONST29); + adaptor.addChild(root_0, INTCONST29_tree); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:66:26: '-' INTCONST + { + char_literal30=(Token)match(input,24,FOLLOW_24_in_simpleexpr700); + stream_24.add(char_literal30); + + INTCONST31=(Token)match(input,INTCONST,FOLLOW_INTCONST_in_simpleexpr702); + stream_INTCONST.add(INTCONST31); + + // AST REWRITE + // elements: INTCONST + // token labels: + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 66:39: -> ^( UMINUS INTCONST ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:66:42: ^( UMINUS INTCONST ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(UMINUS, "UMINUS"), root_1); + adaptor.addChild(root_1, stream_INTCONST.nextNode()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + break; + case 4 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:67:15: FLOATCONST + { + root_0 = (CommonTree)adaptor.nil(); + + + FLOATCONST32=(Token)match(input,FLOATCONST,FOLLOW_FLOATCONST_in_simpleexpr726); + FLOATCONST32_tree = (CommonTree)adaptor.create(FLOATCONST32); + adaptor.addChild(root_0, FLOATCONST32_tree); + + } + break; + case 5 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:67:28: '-' FLOATCONST + { + char_literal33=(Token)match(input,24,FOLLOW_24_in_simpleexpr730); + stream_24.add(char_literal33); + + FLOATCONST34=(Token)match(input,FLOATCONST,FOLLOW_FLOATCONST_in_simpleexpr732); + stream_FLOATCONST.add(FLOATCONST34); + + // AST REWRITE + // elements: FLOATCONST + // token labels: + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 67:43: -> ^( UMINUS FLOATCONST ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:67:46: ^( UMINUS FLOATCONST ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(UMINUS, "UMINUS"), root_1); + adaptor.addChild(root_1, stream_FLOATCONST.nextNode()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + break; + case 6 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:68:15: ID + { + root_0 = (CommonTree)adaptor.nil(); + + + ID35=(Token)match(input,ID,FOLLOW_ID_in_simpleexpr756); + ID35_tree = (CommonTree)adaptor.create(ID35); + adaptor.addChild(root_0, ID35_tree); + + } + break; + case 7 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:68:20: STRINGCONST + { + root_0 = (CommonTree)adaptor.nil(); + + + STRINGCONST36=(Token)match(input,STRINGCONST,FOLLOW_STRINGCONST_in_simpleexpr760); + STRINGCONST36_tree = (CommonTree)adaptor.create(STRINGCONST36); + adaptor.addChild(root_0, STRINGCONST36_tree); + + } + break; + + } + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "simpleexpr" + + + public static class assignstat_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "assignstat" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:71:1: assignstat : 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 ID37=null; + Token string_literal38=null; + ParserRuleReturnScope expr39 =null; + + CommonTree ID37_tree=null; + CommonTree string_literal38_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:71:11: ( ID ':=' ^ expr ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:71:15: ID ':=' ^ expr + { + root_0 = (CommonTree)adaptor.nil(); + + + ID37=(Token)match(input,ID,FOLLOW_ID_in_assignstat770); + ID37_tree = (CommonTree)adaptor.create(ID37); + adaptor.addChild(root_0, ID37_tree); + + string_literal38=(Token)match(input,28,FOLLOW_28_in_assignstat772); + string_literal38_tree = (CommonTree)adaptor.create(string_literal38); + root_0 = (CommonTree)adaptor.becomeRoot(string_literal38_tree, root_0); + + pushFollow(FOLLOW_expr_in_assignstat775); + expr39=expr(); + state._fsp--; + + adaptor.addChild(root_0, expr39.getTree()); + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "assignstat" + + + public static class cond_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "cond" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:1: cond : expr ( '<' ^| '>' ^| '=' ^) expr ; + public final XParser.cond_return cond() throws RecognitionException { + XParser.cond_return retval = new XParser.cond_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + Token char_literal41=null; + Token char_literal42=null; + Token char_literal43=null; + ParserRuleReturnScope expr40 =null; + ParserRuleReturnScope expr44 =null; + + CommonTree char_literal41_tree=null; + CommonTree char_literal42_tree=null; + CommonTree char_literal43_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:5: ( expr ( '<' ^| '>' ^| '=' ^) expr ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:15: expr ( '<' ^| '>' ^| '=' ^) expr + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_expr_in_cond791); + expr40=expr(); + state._fsp--; + + adaptor.addChild(root_0, expr40.getTree()); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:20: ( '<' ^| '>' ^| '=' ^) + int alt12=3; + switch ( input.LA(1) ) { + case 30: + { + alt12=1; + } + break; + case 32: + { + alt12=2; + } + break; + case 31: + { + alt12=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 12, 0, input); + throw nvae; + } + switch (alt12) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:21: '<' ^ + { + char_literal41=(Token)match(input,30,FOLLOW_30_in_cond794); + char_literal41_tree = (CommonTree)adaptor.create(char_literal41); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal41_tree, root_0); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:27: '>' ^ + { + char_literal42=(Token)match(input,32,FOLLOW_32_in_cond798); + char_literal42_tree = (CommonTree)adaptor.create(char_literal42); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal42_tree, root_0); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:74:33: '=' ^ + { + char_literal43=(Token)match(input,31,FOLLOW_31_in_cond802); + char_literal43_tree = (CommonTree)adaptor.create(char_literal43); + root_0 = (CommonTree)adaptor.becomeRoot(char_literal43_tree, root_0); + + } + break; + + } + + pushFollow(FOLLOW_expr_in_cond807); + expr44=expr(); + state._fsp--; + + adaptor.addChild(root_0, expr44.getTree()); + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "cond" + + + public static class condstat_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "condstat" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:77:1: condstat : 'if' ^ cond 'then' ! stat ( options {greedy=true; } : 'else' ! stat )? ; + 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_literal45=null; + Token string_literal47=null; + Token string_literal49=null; + ParserRuleReturnScope cond46 =null; + ParserRuleReturnScope stat48 =null; + ParserRuleReturnScope stat50 =null; + + CommonTree string_literal45_tree=null; + CommonTree string_literal47_tree=null; + CommonTree string_literal49_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:77:9: ( 'if' ^ cond 'then' ! stat ( options {greedy=true; } : 'else' ! stat )? ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:77:15: 'if' ^ cond 'then' ! stat ( options {greedy=true; } : 'else' ! stat )? + { + root_0 = (CommonTree)adaptor.nil(); + + + string_literal45=(Token)match(input,38,FOLLOW_38_in_condstat819); + string_literal45_tree = (CommonTree)adaptor.create(string_literal45); + root_0 = (CommonTree)adaptor.becomeRoot(string_literal45_tree, root_0); + + pushFollow(FOLLOW_cond_in_condstat822); + cond46=cond(); + state._fsp--; + + adaptor.addChild(root_0, cond46.getTree()); + + string_literal47=(Token)match(input,44,FOLLOW_44_in_condstat824); + pushFollow(FOLLOW_stat_in_condstat827); + stat48=stat(); + state._fsp--; + + adaptor.addChild(root_0, stat48.getTree()); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:77:40: ( options {greedy=true; } : 'else' ! stat )? + int alt13=2; + int LA13_0 = input.LA(1); + if ( (LA13_0==34) ) { + alt13=1; + } + switch (alt13) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:77:65: 'else' ! stat + { + string_literal49=(Token)match(input,34,FOLLOW_34_in_condstat839); + pushFollow(FOLLOW_stat_in_condstat842); + stat50=stat(); + state._fsp--; + + adaptor.addChild(root_0, stat50.getTree()); + + } + break; + + } + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "condstat" + + + public static class whilestat_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "whilestat" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:80: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_literal51=null; + Token char_literal52=null; + Token char_literal54=null; + ParserRuleReturnScope cond53 =null; + ParserRuleReturnScope stat55 =null; + + CommonTree string_literal51_tree=null; + CommonTree char_literal52_tree=null; + CommonTree char_literal54_tree=null; + RewriteRuleTokenStream stream_45=new RewriteRuleTokenStream(adaptor,"token 45"); + RewriteRuleTokenStream stream_20=new RewriteRuleTokenStream(adaptor,"token 20"); + 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:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:80:10: ( 'while' '(' cond ')' stat -> ^( 'while' cond stat ) ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:80:15: 'while' '(' cond ')' stat + { + string_literal51=(Token)match(input,45,FOLLOW_45_in_whilestat855); + stream_45.add(string_literal51); + + char_literal52=(Token)match(input,20,FOLLOW_20_in_whilestat857); + stream_20.add(char_literal52); + + pushFollow(FOLLOW_cond_in_whilestat859); + cond53=cond(); + state._fsp--; + + stream_cond.add(cond53.getTree()); + char_literal54=(Token)match(input,21,FOLLOW_21_in_whilestat861); + stream_21.add(char_literal54); + + pushFollow(FOLLOW_stat_in_whilestat863); + stat55=stat(); + state._fsp--; + + stream_stat.add(stat55.getTree()); + // AST REWRITE + // elements: cond, 45, stat + // token labels: + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 80:41: -> ^( 'while' cond stat ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:80:44: ^( 'while' cond stat ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot(stream_45.nextNode(), root_1); + adaptor.addChild(root_1, stream_cond.nextTree()); + adaptor.addChild(root_1, stream_stat.nextTree()); + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "whilestat" + + + public static class forstat_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "forstat" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:81:1: forstat : '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_literal56=null; + Token char_literal57=null; + Token char_literal59=null; + Token char_literal61=null; + Token char_literal63=null; + ParserRuleReturnScope assignstat58 =null; + ParserRuleReturnScope cond60 =null; + ParserRuleReturnScope assignstat62 =null; + ParserRuleReturnScope stat64 =null; + + CommonTree string_literal56_tree=null; + CommonTree char_literal57_tree=null; + CommonTree char_literal59_tree=null; + CommonTree char_literal61_tree=null; + CommonTree char_literal63_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:81:8: ( 'for' ^ '(' ! assignstat ';' ! cond ';' ! assignstat ')' ! stat ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:81:15: 'for' ^ '(' ! assignstat ';' ! cond ';' ! assignstat ')' ! stat + { + root_0 = (CommonTree)adaptor.nil(); + + + string_literal56=(Token)match(input,37,FOLLOW_37_in_forstat884); + string_literal56_tree = (CommonTree)adaptor.create(string_literal56); + root_0 = (CommonTree)adaptor.becomeRoot(string_literal56_tree, root_0); + + char_literal57=(Token)match(input,20,FOLLOW_20_in_forstat887); + pushFollow(FOLLOW_assignstat_in_forstat890); + assignstat58=assignstat(); + state._fsp--; + + adaptor.addChild(root_0, assignstat58.getTree()); + + char_literal59=(Token)match(input,29,FOLLOW_29_in_forstat892); + pushFollow(FOLLOW_cond_in_forstat895); + cond60=cond(); + state._fsp--; + + adaptor.addChild(root_0, cond60.getTree()); + + char_literal61=(Token)match(input,29,FOLLOW_29_in_forstat897); + pushFollow(FOLLOW_assignstat_in_forstat900); + assignstat62=assignstat(); + state._fsp--; + + adaptor.addChild(root_0, assignstat62.getTree()); + + char_literal63=(Token)match(input,21,FOLLOW_21_in_forstat902); + pushFollow(FOLLOW_stat_in_forstat905); + stat64=stat(); + state._fsp--; + + adaptor.addChild(root_0, stat64.getTree()); + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "forstat" + + + public static class stat_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "stat" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84: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 assignstat65 =null; + ParserRuleReturnScope condstat66 =null; + ParserRuleReturnScope whilestat67 =null; + ParserRuleReturnScope forstat68 =null; + ParserRuleReturnScope statlist69 =null; + + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84:5: ( assignstat | condstat | whilestat | forstat | statlist ) + int alt14=5; + switch ( input.LA(1) ) { + case ID: + { + alt14=1; + } + break; + case 38: + { + alt14=2; + } + break; + case 45: + { + alt14=3; + } + break; + case 37: + { + alt14=4; + } + break; + case 33: + { + alt14=5; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 14, 0, input); + throw nvae; + } + switch (alt14) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84:15: assignstat + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_assignstat_in_stat921); + assignstat65=assignstat(); + state._fsp--; + + adaptor.addChild(root_0, assignstat65.getTree()); + + } + break; + case 2 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84:28: condstat + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_condstat_in_stat925); + condstat66=condstat(); + state._fsp--; + + adaptor.addChild(root_0, condstat66.getTree()); + + } + break; + case 3 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84:39: whilestat + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_whilestat_in_stat929); + whilestat67=whilestat(); + state._fsp--; + + adaptor.addChild(root_0, whilestat67.getTree()); + + } + break; + case 4 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84:51: forstat + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_forstat_in_stat933); + forstat68=forstat(); + state._fsp--; + + adaptor.addChild(root_0, forstat68.getTree()); + + } + break; + case 5 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:84:61: statlist + { + root_0 = (CommonTree)adaptor.nil(); + + + pushFollow(FOLLOW_statlist_in_stat937); + statlist69=statlist(); + state._fsp--; + + adaptor.addChild(root_0, statlist69.getTree()); + + } + break; + + } + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "stat" + + + public static class statlist_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "statlist" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86: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_literal70=null; + Token char_literal72=null; + Token string_literal73=null; + ParserRuleReturnScope stat71 =null; + + CommonTree string_literal70_tree=null; + CommonTree char_literal72_tree=null; + CommonTree string_literal73_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"); + RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat"); + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86:9: ( 'begin' ( stat ';' )* 'end' -> ^( STATLIST ( stat )* ) ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86:18: 'begin' ( stat ';' )* 'end' + { + string_literal70=(Token)match(input,33,FOLLOW_33_in_statlist951); + stream_33.add(string_literal70); + + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86:26: ( stat ';' )* + loop15: + while (true) { + int alt15=2; + int LA15_0 = input.LA(1); + if ( (LA15_0==ID||LA15_0==33||(LA15_0 >= 37 && LA15_0 <= 38)||LA15_0==45) ) { + alt15=1; + } + + switch (alt15) { + case 1 : + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86:27: stat ';' + { + pushFollow(FOLLOW_stat_in_statlist954); + stat71=stat(); + state._fsp--; + + stream_stat.add(stat71.getTree()); + char_literal72=(Token)match(input,29,FOLLOW_29_in_statlist956); + stream_29.add(char_literal72); + + } + break; + + default : + break loop15; + } + } + + string_literal73=(Token)match(input,35,FOLLOW_35_in_statlist960); + stream_35.add(string_literal73); + + // AST REWRITE + // elements: stat + // token labels: + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 86:45: -> ^( STATLIST ( stat )* ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86:48: ^( STATLIST ( stat )* ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(STATLIST, "STATLIST"), root_1); + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:86:59: ( stat )* + while ( stream_stat.hasNext() ) { + adaptor.addChild(root_1, stream_stat.nextTree()); + } + stream_stat.reset(); + + adaptor.addChild(root_0, root_1); + } + + } + + + retval.tree = root_0; + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "statlist" + + + public static class program_return extends ParserRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "program" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:89:1: program : 'program' ID ';' decllist statlist '.' EOF -> ^( 'program' ID decllist statlist ) ; + public final XParser.program_return program() throws RecognitionException { + XParser.program_return retval = new XParser.program_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + Token string_literal74=null; + Token ID75=null; + Token char_literal76=null; + Token char_literal79=null; + Token EOF80=null; + ParserRuleReturnScope decllist77 =null; + ParserRuleReturnScope statlist78 =null; + + CommonTree string_literal74_tree=null; + CommonTree ID75_tree=null; + CommonTree char_literal76_tree=null; + CommonTree char_literal79_tree=null; + CommonTree EOF80_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:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:89:8: ( 'program' ID ';' decllist statlist '.' EOF -> ^( 'program' ID decllist statlist ) ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:89:15: 'program' ID ';' decllist statlist '.' EOF + { + string_literal74=(Token)match(input,41,FOLLOW_41_in_program983); + stream_41.add(string_literal74); + + ID75=(Token)match(input,ID,FOLLOW_ID_in_program985); + stream_ID.add(ID75); + + char_literal76=(Token)match(input,29,FOLLOW_29_in_program987); + stream_29.add(char_literal76); + + pushFollow(FOLLOW_decllist_in_program989); + decllist77=decllist(); + state._fsp--; + + stream_decllist.add(decllist77.getTree()); + pushFollow(FOLLOW_statlist_in_program991); + statlist78=statlist(); + state._fsp--; + + stream_statlist.add(statlist78.getTree()); + char_literal79=(Token)match(input,25,FOLLOW_25_in_program993); + stream_25.add(char_literal79); + + EOF80=(Token)match(input,EOF,FOLLOW_EOF_in_program995); + stream_EOF.add(EOF80); + + // AST REWRITE + // elements: 41, statlist, ID, decllist + // token labels: + // rule labels: retval + // token list labels: + // rule list labels: + // wildcard labels: + retval.tree = root_0; + RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null); + + root_0 = (CommonTree)adaptor.nil(); + // 89:58: -> ^( 'program' ID decllist statlist ) + { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_cc\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\X.g:89:61: ^( 'program' ID decllist statlist ) + { + CommonTree root_1 = (CommonTree)adaptor.nil(); + root_1 = (CommonTree)adaptor.becomeRoot(stream_41.nextNode(), 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; + + } + + retval.stop = input.LT(-1); + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "program" + + // Delegated rules + + + + public static final BitSet FOLLOW_ID_in_decl395 = new BitSet(new long[]{0x0000000008000000L}); + public static final BitSet FOLLOW_27_in_decl397 = new BitSet(new long[]{0x0000089000000000L}); + public static final BitSet FOLLOW_39_in_decl402 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_36_in_decl408 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_43_in_decl414 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_decl417 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_42_in_decl443 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_ID_in_decl445 = new BitSet(new long[]{0x0000000008000000L}); + public static final BitSet FOLLOW_27_in_decl447 = new BitSet(new long[]{0x0000089000000000L}); + public static final BitSet FOLLOW_39_in_decl452 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_36_in_decl458 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_43_in_decl464 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_decl467 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_40_in_decl495 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_ID_in_decl497 = new BitSet(new long[]{0x0000000008000000L}); + public static final BitSet FOLLOW_27_in_decl499 = new BitSet(new long[]{0x0000089000000000L}); + public static final BitSet FOLLOW_39_in_decl504 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_36_in_decl510 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_43_in_decl516 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_decl519 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_42_in_decl547 = new BitSet(new long[]{0x0000010000000000L}); + public static final BitSet FOLLOW_40_in_decl549 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_ID_in_decl551 = new BitSet(new long[]{0x0000000008000000L}); + public static final BitSet FOLLOW_27_in_decl553 = new BitSet(new long[]{0x0000089000000000L}); + public static final BitSet FOLLOW_39_in_decl558 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_36_in_decl564 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_43_in_decl570 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_decl573 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_decl_in_decllist599 = new BitSet(new long[]{0x0000050000000202L}); + public static final BitSet FOLLOW_multexpr_in_expr626 = new BitSet(new long[]{0x0000000001800002L}); + public static final BitSet FOLLOW_23_in_expr630 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_24_in_expr635 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_multexpr_in_expr639 = new BitSet(new long[]{0x0000000001800002L}); + public static final BitSet FOLLOW_simpleexpr_in_multexpr650 = new BitSet(new long[]{0x0000000004400002L}); + public static final BitSet FOLLOW_22_in_multexpr654 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_26_in_multexpr659 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_simpleexpr_in_multexpr663 = new BitSet(new long[]{0x0000000004400002L}); + public static final BitSet FOLLOW_20_in_simpleexpr673 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_expr_in_simpleexpr676 = new BitSet(new long[]{0x0000000000200000L}); + public static final BitSet FOLLOW_21_in_simpleexpr678 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_INTCONST_in_simpleexpr696 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_24_in_simpleexpr700 = new BitSet(new long[]{0x0000000000000400L}); + public static final BitSet FOLLOW_INTCONST_in_simpleexpr702 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_FLOATCONST_in_simpleexpr726 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_24_in_simpleexpr730 = new BitSet(new long[]{0x0000000000000100L}); + public static final BitSet FOLLOW_FLOATCONST_in_simpleexpr732 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ID_in_simpleexpr756 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRINGCONST_in_simpleexpr760 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ID_in_assignstat770 = new BitSet(new long[]{0x0000000010000000L}); + public static final BitSet FOLLOW_28_in_assignstat772 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_expr_in_assignstat775 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_expr_in_cond791 = new BitSet(new long[]{0x00000001C0000000L}); + public static final BitSet FOLLOW_30_in_cond794 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_32_in_cond798 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_31_in_cond802 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_expr_in_cond807 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_38_in_condstat819 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_cond_in_condstat822 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_44_in_condstat824 = new BitSet(new long[]{0x0000206200000200L}); + public static final BitSet FOLLOW_stat_in_condstat827 = new BitSet(new long[]{0x0000000400000002L}); + public static final BitSet FOLLOW_34_in_condstat839 = new BitSet(new long[]{0x0000206200000200L}); + public static final BitSet FOLLOW_stat_in_condstat842 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_45_in_whilestat855 = new BitSet(new long[]{0x0000000000100000L}); + public static final BitSet FOLLOW_20_in_whilestat857 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_cond_in_whilestat859 = new BitSet(new long[]{0x0000000000200000L}); + public static final BitSet FOLLOW_21_in_whilestat861 = new BitSet(new long[]{0x0000206200000200L}); + public static final BitSet FOLLOW_stat_in_whilestat863 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_37_in_forstat884 = new BitSet(new long[]{0x0000000000100000L}); + public static final BitSet FOLLOW_20_in_forstat887 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_assignstat_in_forstat890 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_forstat892 = new BitSet(new long[]{0x0000000001110700L}); + public static final BitSet FOLLOW_cond_in_forstat895 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_forstat897 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_assignstat_in_forstat900 = new BitSet(new long[]{0x0000000000200000L}); + public static final BitSet FOLLOW_21_in_forstat902 = new BitSet(new long[]{0x0000206200000200L}); + public static final BitSet FOLLOW_stat_in_forstat905 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_assignstat_in_stat921 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_condstat_in_stat925 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_whilestat_in_stat929 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_forstat_in_stat933 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_statlist_in_stat937 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_33_in_statlist951 = new BitSet(new long[]{0x0000206A00000200L}); + public static final BitSet FOLLOW_stat_in_statlist954 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_statlist956 = new BitSet(new long[]{0x0000206A00000200L}); + public static final BitSet FOLLOW_35_in_statlist960 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_41_in_program983 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_ID_in_program985 = new BitSet(new long[]{0x0000000020000000L}); + public static final BitSet FOLLOW_29_in_program987 = new BitSet(new long[]{0x0000050200000200L}); + public static final BitSet FOLLOW_decllist_in_program989 = new BitSet(new long[]{0x0000000200000000L}); + public static final BitSet FOLLOW_statlist_in_program991 = new BitSet(new long[]{0x0000000002000000L}); + public static final BitSet FOLLOW_25_in_program993 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_EOF_in_program995 = new BitSet(new long[]{0x0000000000000002L}); +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.g b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.g new file mode 100644 index 0000000..af309e2 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.g @@ -0,0 +1,26 @@ +/* ********************************************** + * Duale Hochschule Baden-W�rttemberg Karlsruhe + * Prof. Dr. J�rn Eisenbiegler + * + * Vorlesung �bersetzerbau + * Praxis ANTLR-Parser f�r X + * - Grammatik f�r Scanner und Parser + * + * ********************************************** + */ + +tree grammar XTreeGrammar; + +options { + language = Java; + output = AST; + tokenVocab = X; + ASTLabelType = CommonTree; +} + +@header {package de.dhbw.compiler.antlrxtreegrammar;} + + +program: 'todo'; + + diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.java new file mode 100644 index 0000000..d7a6a25 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.java @@ -0,0 +1,152 @@ +// $ANTLR 3.5.2 C:\\Users\\eisenbiegler\\Dropbox\\workspace_üb\\ÜB-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g 2019-02-19 10:21:04 +package de.dhbw.compiler.antlrxtreegrammar; + +import org.antlr.runtime.*; +import org.antlr.runtime.tree.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + + +@SuppressWarnings("all") +public class XTreeGrammar extends TreeParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "COMMENT", "DECL", "DECLLIST", + "DIGIT", "FLOATCONST", "ID", "INTCONST", "INVALID", "LETTER", "OTHER", + "POSDIGIT", "STATLIST", "STRINGCONST", "UMINUS", "WS", "ZERO", "'('", + "')'", "'*'", "'+'", "'-'", "'.'", "'/'", "':'", "':='", "';'", "'<'", + "'='", "'>'", "'begin'", "'else'", "'end'", "'float'", "'for'", "'if'", + "'int'", "'print'", "'program'", "'read'", "'string'", "'then'", "'while'", + "'todo'" + }; + 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; + public static final int T__24=24; + public static final int T__25=25; + public static final int T__26=26; + public static final int T__27=27; + public static final int T__28=28; + public static final int T__29=29; + public static final int T__30=30; + public static final int T__31=31; + public static final int T__32=32; + public static final int T__33=33; + public static final int T__34=34; + public static final int T__35=35; + public static final int T__36=36; + public static final int T__37=37; + public static final int T__38=38; + public static final int T__39=39; + public static final int T__40=40; + public static final int T__41=41; + public static final int T__42=42; + 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 COMMENT=4; + public static final int DECL=5; + public static final int DECLLIST=6; + public static final int DIGIT=7; + public static final int FLOATCONST=8; + public static final int ID=9; + public static final int INTCONST=10; + public static final int INVALID=11; + public static final int LETTER=12; + public static final int OTHER=13; + public static final int POSDIGIT=14; + public static final int STATLIST=15; + public static final int STRINGCONST=16; + public static final int UMINUS=17; + public static final int WS=18; + public static final int ZERO=19; + public static final int T__46=46; + + // delegates + public TreeParser[] getDelegates() { + return new TreeParser[] {}; + } + + // delegators + + + public XTreeGrammar(TreeNodeStream input) { + this(input, new RecognizerSharedState()); + } + public XTreeGrammar(TreeNodeStream input, RecognizerSharedState state) { + super(input, state); + } + + protected TreeAdaptor adaptor = new CommonTreeAdaptor(); + + public void setTreeAdaptor(TreeAdaptor adaptor) { + this.adaptor = adaptor; + } + public TreeAdaptor getTreeAdaptor() { + return adaptor; + } + @Override public String[] getTokenNames() { return XTreeGrammar.tokenNames; } + @Override public String getGrammarFileName() { return "C:\\Users\\eisenbiegler\\Dropbox\\workspace_üb\\ÜB-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g"; } + + + public static class program_return extends TreeRuleReturnScope { + CommonTree tree; + @Override + public CommonTree getTree() { return tree; } + }; + + + // $ANTLR start "program" + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_üb\\ÜB-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:24:1: program : 'todo' ; + public final XTreeGrammar.program_return program() throws RecognitionException { + XTreeGrammar.program_return retval = new XTreeGrammar.program_return(); + retval.start = input.LT(1); + + CommonTree root_0 = null; + + CommonTree _first_0 = null; + CommonTree _last = null; + + + CommonTree string_literal1=null; + + CommonTree string_literal1_tree=null; + + try { + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_üb\\ÜB-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:24:8: ( 'todo' ) + // C:\\Users\\eisenbiegler\\Dropbox\\workspace_üb\\ÜB-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:24:15: 'todo' + { + root_0 = (CommonTree)adaptor.nil(); + + + _last = (CommonTree)input.LT(1); + string_literal1=(CommonTree)match(input,46,FOLLOW_46_in_program67); + string_literal1_tree = (CommonTree)adaptor.dupNode(string_literal1); + + + adaptor.addChild(root_0, string_literal1_tree); + + } + + retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "program" + + // Delegated rules + + + + public static final BitSet FOLLOW_46_in_program67 = new BitSet(new long[]{0x0000000000000002L}); +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.tokens b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.tokens new file mode 100644 index 0000000..7eb8fc1 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/XTreeGrammar.tokens @@ -0,0 +1,70 @@ +T__20=20 +T__21=21 +T__22=22 +T__23=23 +T__24=24 +T__25=25 +T__26=26 +T__27=27 +T__28=28 +T__29=29 +T__30=30 +T__31=31 +T__32=32 +T__33=33 +T__34=34 +T__35=35 +T__36=36 +T__37=37 +T__38=38 +T__39=39 +T__40=40 +T__41=41 +T__42=42 +T__43=43 +T__44=44 +T__45=45 +COMMENT=4 +DECL=5 +DECLLIST=6 +DIGIT=7 +FLOATCONST=8 +ID=9 +INTCONST=10 +INVALID=11 +LETTER=12 +OTHER=13 +POSDIGIT=14 +STATLIST=15 +STRINGCONST=16 +UMINUS=17 +WS=18 +ZERO=19 +T__46=46 +'('=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 +'todo'=46 diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/AssignCountTest.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/AssignCountTest.java new file mode 100644 index 0000000..18f4890 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/AssignCountTest.java @@ -0,0 +1,46 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testfall-Utility für Parser + * + * ********************************************** + */ + + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; + +import org.antlr.runtime.ANTLRInputStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.ParserRuleReturnScope; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeNodeStream; + +import de.dhbw.compiler.antlrxtreegrammar.AssignCount; +import de.dhbw.compiler.antlrxtreegrammar.XLexer; +import de.dhbw.compiler.antlrxtreegrammar.XParser; +import de.dhbw.compiler.antlrxtreegrammar.XTreeGrammar; + +public abstract class AssignCountTest { + + protected void testTreeGrammarTree(String in, int expected) throws Exception { + ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(in.getBytes())); + XLexer scanner = new XLexer(input); + CommonTokenStream tokens = new CommonTokenStream(scanner); + XParser parser = new XParser(tokens); + ParserRuleReturnScope result = parser.program(); + CommonTree out = (CommonTree) result.getTree(); + + AssignCount count = new AssignCount(new CommonTreeNodeStream(out)); + out = count.program().getTree(); + + assertEquals(expected, count.getCount()); + } + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/ParseTreeTest.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/ParseTreeTest.java new file mode 100644 index 0000000..b28a34d --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/ParseTreeTest.java @@ -0,0 +1,43 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testfall-Utility für Parser + * + * ********************************************** + */ + + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; + +import org.antlr.runtime.ANTLRInputStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.ParserRuleReturnScope; +import org.antlr.runtime.tree.CommonTree; +import de.dhbw.compiler.antlrxtreegrammar.XLexer; +import de.dhbw.compiler.antlrxtreegrammar.XParser; + +public abstract class ParseTreeTest { + + protected void testParseTree(String in, String expected) throws Exception { + ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(in.getBytes())); + XLexer scanner = new XLexer(input); + CommonTokenStream tokens = new CommonTokenStream(scanner); + XParser parser = new XParser(tokens); + ParserRuleReturnScope result = parser.program(); + CommonTree out = (CommonTree) result.getTree(); + + if (out==null) { + assertEquals(expected, out); + } else { + assertEquals(expected, out.toStringTree()); + } + } + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXAssignCount.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXAssignCount.java new file mode 100644 index 0000000..498b998 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXAssignCount.java @@ -0,0 +1,23 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testsuite für leere Baum-Grammatik + * + * ********************************************** + */ +package de.dhbw.compiler.antlrxtreegrammar.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ TestAntlrXScanner1.class, TestAntlrXScanner2.class, TestAntlrXScanner3.class, + TestAntlrXParser1.class, TestAntlrXParser2.class, + TestAntlrXAssignCount1.class, TestAntlrXAssignCount2.class}) +public class TestAntlrXAssignCount { + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXAssignCount1.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXAssignCount1.java new file mode 100644 index 0000000..f0eab75 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXAssignCount1.java @@ -0,0 +1,136 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testf�lle für leere Baum-Grammmatik + * + * ********************************************** + */ + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestAntlrXAssignCount1 extends AssignCountTest { + + @Test + public void program00BeginEnd() throws Exception { + String test = "program beginEnd;\n"+ + "begin\n"+ + "end."; + testTreeGrammarTree(test, 0); + } + + @Test + public void program02BeginEnd2() throws Exception { + String test = "program beginEnd2;\n"+ + "begin\n"+ + " begin\n"+ + " end;"+ + "end."; + testTreeGrammarTree(test, 0); + } + + + @Test + public void program10Assign() throws Exception { + String test = "program assign;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0;"+ + "end."; + testTreeGrammarTree(test, 1); + } + + @Test + public void program16ExprPlusMinus() throws Exception { + String test = "program exprPlus;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0+1+-2-3+4;"+ + "end."; + testTreeGrammarTree(test, 1); + } + + @Test + public void program20Cond() throws Exception { + String test = "program cond;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then x:=1;"+ + "end."; + testTreeGrammarTree(test, 1); + } + + @Test + public void program21CondElse() throws Exception { + String test = "program condElse;\n"+ + " x: int;"+ + "begin\n"+ + " if 2>3 then x:=1 else x:=2;"+ + "end."; + testTreeGrammarTree(test, 2); + } + + @Test + public void program22CondElse2() throws Exception { + String test = "program condelse2;\n"+ + " x: int;"+ + "begin\n"+ + " if 2=3 then if 4<5 then x:=1 else x:=2 else x:=3;"+ + "end."; + testTreeGrammarTree(test, 3); + } + + + @Test + public void program23CondElse3() throws Exception { + String test = "program condelse3;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then if 4>5 then x:=1 else if 6=7 then x:=2 else x:=3;"+ + "end."; + testTreeGrammarTree(test, 3); + } + + + @Test + public void program24CondElse4() throws Exception { + String test = "program condelse4;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then if 4>5 then x:=1 else x:=2 else if 6=7 then x:=3 else x:=4;"+ + "end."; + testTreeGrammarTree(test, 4); + } + + + @Test + public void program90Xmin1() throws Exception { + String test = "program xmin1;\n"+ + " read x : int;\n"+ + " print y : int;\n"+ + "begin\n"+ + " y := 25+2*x-6*x;\n"+ + " if x3 then x:=1 else x:=2;"+ + "end."; + String expected = "(program condElse (DECLLIST (DECL x int)) (STATLIST (if (> 2 3) (:= x 1) (:= x 2))))"; + testParseTree(test, expected); + } + + @Test + public void program22CondElse2() throws Exception { + String test = "program condelse2;\n"+ + " x: int;"+ + "begin\n"+ + " if 2=3 then if 4<5 then x:=1 else x:=2 else x:=3;"+ + "end."; + String expected = "(program condelse2 (DECLLIST (DECL x int)) " + + "(STATLIST (if (= 2 3) (if (< 4 5) (:= x 1) (:= x 2)) (:= x 3))))"; + testParseTree(test, expected); + } + + + @Test + public void program23CondElse3() throws Exception { + String test = "program condelse3;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then if 4>5 then x:=1 else if 6=7 then x:=2 else x:=3;"+ + "end."; + String expected = "(program condelse3 (DECLLIST (DECL x int)) " + + "(STATLIST (if (< 2 3) (if (> 4 5) (:= x 1) (if (= 6 7) (:= x 2) (:= x 3))))))"; + testParseTree(test, expected); + } + + + @Test + public void program24CondElse4() throws Exception { + String test = "program condelse4;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then if 4>5 then x:=1 else x:=2 else if 6=7 then x:=3 else x:=4;"+ + "end."; + String expected = "(program condelse4 (DECLLIST (DECL x int)) " + + "(STATLIST (if (< 2 3) (if (> 4 5) (:= x 1) (:= x 2)) (if (= 6 7) (:= x 3) (:= x 4)))))"; + testParseTree(test, expected); + } + + + @Test + public void program90Xmin1() throws Exception { + String test = "program xmin1;\n"+ + " read x : int;\n"+ + " print y : int;\n"+ + "begin\n"+ + " y := 25+2*x-6*x;\n"+ + " if x ", false, new TestToken(getType(">"),">",1,3)); + } + + @Test + public void tokenBEGIN() throws Exception { + testTokenList(" begin ", false, new TestToken(getType("BEGIN"),"begin",1,3)); + } + + @Test + public void tokenELSE() throws Exception { + testTokenList(" else ", false, new TestToken(getType("ELSE"),"else",1,3)); + } + + @Test + public void tokenEND() throws Exception { + testTokenList(" end ", false, new TestToken(getType("END"),"end",1,3)); + } + + @Test + public void tokenFLOAT() throws Exception { + testTokenList(" float ", false, new TestToken(getType("FLOAT"),"float",1,3)); + } + + @Test + public void tokenFOR() throws Exception { + testTokenList(" for ", false, new TestToken(getType("FOR"),"for",1,3)); + } + + @Test + public void tokenIF() throws Exception { + testTokenList(" if ", false, new TestToken(getType("IF"),"if",1,3)); + } + + @Test + public void tokenINT() throws Exception { + testTokenList(" int ", false, new TestToken(getType("INT"),"int",1,3)); + } + + @Test + public void tokenPRINT() throws Exception { + testTokenList(" print ", false, new TestToken(getType("PRINT"),"print",1,3)); + } + + @Test + public void tokenPROGRAM() throws Exception { + testTokenList(" program ", false, new TestToken(getType("PROGRAM"),"program",1,3)); + } + + @Test + public void tokenREAD() throws Exception { + testTokenList(" read ", false, new TestToken(getType("READ"),"read",1,3)); + } + + @Test + public void tokenSTRING() throws Exception { + testTokenList(" string ", false, new TestToken(getType("STRING"),"string",1,3)); + } + + @Test + public void tokenTHEN() throws Exception { + testTokenList(" then ", false, new TestToken(getType("THEN"),"then",1,3)); + } + + @Test + public void tokenWHILE() throws Exception { + testTokenList(" while ", false, new TestToken(getType("WHILE"),"while",1,3)); + } + + @Test + public void tokenEOF() throws Exception { + testTokenList(" ", false); + testTokenList(" ", false, new TestToken(-1,"",1,2)); + testTokenList("", false, new TestToken(-1,"",1,1)); + } + + @Test + public void invalidÄ() throws Exception { + testTokenList(" Ä ", false, new TestToken(getType("INVALID"),"Ä",1,2)); + } + + @Test + public void invalidGatter() throws Exception { + testTokenList(" # ", false, new TestToken(getType("INVALID"),"#",1,2)); + } + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXScanner2.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXScanner2.java new file mode 100644 index 0000000..46d4350 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXScanner2.java @@ -0,0 +1,66 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testf�lle für Scanner 2 + * + * ********************************************** + */ + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import org.junit.Test; + +public class TestAntlrXScanner2 extends TokenStreamTest { + + @Test + public void tokenIntConst() throws Exception { + testTokenList(" 0 ", true, new TestToken(getType("INTCONST"),"0",1,3)); + testTokenList(" 1 ", true, new TestToken(getType("INTCONST"),"1",1,3)); + testTokenList(" 12 ", true, new TestToken(getType("INTCONST"),"12",1,3)); + testTokenList(" 123 ", true, new TestToken(getType("INTCONST"),"123",1,3)); + testTokenList(" 1234567890 ", true, new TestToken(getType("INTCONST"),"1234567890",1,3)); + testTokenList(" 78 ", true, new TestToken(getType("INTCONST"),"78",1,3)); + } + + @Test + public void tokenFloatConst0() throws Exception { + testTokenList(" 0. ", true, new TestToken(getType("FLOATCONST"),"0.",1,3)); + testTokenList(" 0.0 ", true, new TestToken(getType("FLOATCONST"),"0.0",1,3)); + testTokenList(" 0.0e0 ", true, new TestToken(getType("FLOATCONST"),"0.0e0",1,3)); + } + + @Test + public void tokenFloatConst1() throws Exception { + testTokenList(" 1. ", true, new TestToken(getType("FLOATCONST"),"1.",1,3)); + testTokenList(" 1.1 ", true, new TestToken(getType("FLOATCONST"),"1.1",1,3)); + testTokenList(" 1.1e1 ", true, new TestToken(getType("FLOATCONST"),"1.1e1",1,3)); + testTokenList(" 1e1 ", true, new TestToken(getType("FLOATCONST"),"1e1",1,3)); + } + + @Test + public void tokenFloatConst123() throws Exception { + testTokenList(" 0.12e34 ", true, new TestToken(getType("FLOATCONST"),"0.12e34",1,3)); + testTokenList(" 0.045e23 ", true, new TestToken(getType("FLOATCONST"),"0.045e23",1,3)); + testTokenList(" 123.4560e7890 ", true, new TestToken(getType("FLOATCONST"),"123.4560e7890",1,3)); + testTokenList(" 0.12E34 ", true, new TestToken(getType("FLOATCONST"),"0.12E34",1,3)); + testTokenList(" 0.045E23 ", true, new TestToken(getType("FLOATCONST"),"0.045E23",1,3)); + testTokenList(" 123.4560E7890 ", true, new TestToken(getType("FLOATCONST"),"123.4560E7890",1,3)); + } + + @Test + public void tokenStringConst() throws Exception { + testTokenList(" \"hallo .: \" ", true, new TestToken(getType("STRINGCONST"),"\"hallo .: \"",1,3)); + testTokenList(" \" \\\" \" ", true, new TestToken(getType("STRINGCONST"),"\" \\\" \"",1,3)); + /* + testTokenList(" \"hallo , \" ", true, + new TestToken(getType("INVALID"),"\"hallo ",1,3), + new TestToken(getType("INVALID"),"\" ",1,12)); + testTokenList(" \",\"", true, + new TestToken(getType("INVALID"),"\"",1,3), + new TestToken(getType("INVALID"),"\"",1,5)); */ + } + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXScanner3.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXScanner3.java new file mode 100644 index 0000000..88b4d08 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXScanner3.java @@ -0,0 +1,110 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testf�lle für Scanner 3 + * + * ********************************************** + */ + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import org.junit.Test; + +public class TestAntlrXScanner3 extends TokenStreamTest { + + @Test + public void program1() throws Exception { + testTokenList("program test1;\nbegin\nend.",false, + new TestToken(getType("PROGRAM"),"program",1,1), + new TestToken(getType("ID"),"test1",1,9), + new TestToken(getType(";"),";",1,14), + new TestToken(getType("BEGIN"),"begin",2,1), + new TestToken(getType("END"),"end",3,1), + new TestToken(getType("."),".",3,4)); + } + + @Test + public void program2() throws Exception { + testTokenList( "program test2;\n"+ + " x : int;\n"+ + " y : float;\n"+ + " z : string;\n"+ + "begin\n"+ + " x := 4+5+6.2;\n"+ + " y := 3.56+1.2e3+45.e-67+4e34+3E-1;\n"+ + " z := \"Hello \\\"World\\\"\" + \":\";\n"+ + " z := \"Peter\" + 4;\n"+ + " a := 3+4;\n"+ + "end.", false, + // program test2; + new TestToken(getType("PROGRAM"),"program",1,1), + new TestToken(getType("ID"),"test2",1,9), + new TestToken(getType(";"),";",1,14), + // x : int; + new TestToken(getType("ID"),"x",2,2), + new TestToken(getType(":"),":",2,4), + new TestToken(getType("INT"),"int",2,6), + new TestToken(getType(";"),";",2,9), + // y : float; + new TestToken(getType("ID"),"y",3,2), + new TestToken(getType(":"),":",3,4), + new TestToken(getType("FLOAT"),"float",3,6), + new TestToken(getType(";"),";",3,11), + // z : string; + new TestToken(getType("ID"),"z",4,2), + new TestToken(getType(":"),":",4,4), + new TestToken(getType("STRING"),"string",4,6), + new TestToken(getType(";"),";",4,12), + // begin + new TestToken(getType("BEGIN"),"begin",5,1), + // x := 4+5+6.2; + new TestToken(getType("ID"),"x",6,2), + new TestToken(getType(":="),":=",6,4), + new TestToken(getType("INTCONST"),"4",6,7), + new TestToken(getType("+"),"+",6,8), + new TestToken(getType("INTCONST"),"5",6,9), + new TestToken(getType("+"),"+",6,10), + new TestToken(getType("FLOATCONST"),"6.2",6,11), + new TestToken(getType(";"),";",6,14), + // y := 3.56+1.2e3+45.e-67+4e34+3E-1; + new TestToken(getType("ID"),"y",7,2), + new TestToken(getType(":="),":=",7,4), + new TestToken(getType("FLOATCONST"),"3.56",7,7), + new TestToken(getType("+"),"+",7,11), + new TestToken(getType("FLOATCONST"),"1.2e3",7,12), + new TestToken(getType("+"),"+",7,17), + new TestToken(getType("FLOATCONST"),"45.e-67",7,18), + new TestToken(getType("+"),"+",7,25), + new TestToken(getType("FLOATCONST"),"4e34",7,26), + new TestToken(getType("+"),"+",7,30), + new TestToken(getType("FLOATCONST"),"3E-1",7,31), + new TestToken(getType(";"),";",7,35), + // z := \"Hello \\\"World\\\"\" + \":\"; + new TestToken(getType("ID"),"z",8,2), + new TestToken(getType(":="),":=",8,4), + new TestToken(getType("STRINGCONST"),"\"Hello \\\"World\\\"\"",8,7), + new TestToken(getType("+"),"+",8,25), + new TestToken(getType("STRINGCONST"),"\":\"",8,27), + new TestToken(getType(";"),";",8,30), + // z := \"Peter\" + 4; + new TestToken(getType("ID"),"z",9,2), + new TestToken(getType(":="),":=",9,4), + new TestToken(getType("STRINGCONST"),"\"Peter\"",9,7), + new TestToken(getType("+"),"+",9,15), + new TestToken(getType("INTCONST"),"4",9,17), + new TestToken(getType(";"),";",9,18), + // a := 3+4; + new TestToken(getType("ID"),"a",10,2), + new TestToken(getType(":="),":=",10,4), + new TestToken(getType("INTCONST"),"3",10,7), + new TestToken(getType("+"),"+",10,8), + new TestToken(getType("INTCONST"),"4",10,9), + new TestToken(getType(";"),";",10,10), + // end. + new TestToken(getType("END"),"end",11,1), + new TestToken(getType("."),".",11,4)); + } +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXTreeGrammar.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXTreeGrammar.java new file mode 100644 index 0000000..bb833c6 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXTreeGrammar.java @@ -0,0 +1,23 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testsuite für leere Baum-Grammatik + * + * ********************************************** + */ +package de.dhbw.compiler.antlrxtreegrammar.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ TestAntlrXScanner1.class, TestAntlrXScanner2.class, TestAntlrXScanner3.class, + TestAntlrXParser1.class, TestAntlrXParser2.class, + TestAntlrXTreeGrammar1.class, TestAntlrXTreeGrammar2.class}) +public class TestAntlrXTreeGrammar { + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXTreeGrammar1.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXTreeGrammar1.java new file mode 100644 index 0000000..32caf05 --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TestAntlrXTreeGrammar1.java @@ -0,0 +1,247 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testf�lle für leere Baum-Grammmatik + * + * ********************************************** + */ + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestAntlrXTreeGrammar1 extends TreeGrammarTreeTest { + + @Test + public void program00BeginEnd() throws Exception { + String test = "program beginEnd;\n"+ + "begin\n"+ + "end."; + String expected = "(program beginEnd DECLLIST STATLIST)"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program02BeginEnd2() throws Exception { + String test = "program beginEnd2;\n"+ + "begin\n"+ + " begin\n"+ + " end;"+ + "end."; + String expected = "(program beginEnd2 DECLLIST (STATLIST STATLIST))"; + testTreeGrammarTree(test, expected); + } + + + @Test + public void program10Assign() throws Exception { + String test = "program assign;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0;"+ + "end."; + String expected = "(program assign (DECLLIST (DECL x int)) (STATLIST (:= x 0)))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program11ExprPlus() throws Exception { + String test = "program exprPlus;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0+1;"+ + "end."; + String expected = "(program exprPlus (DECLLIST (DECL x int)) (STATLIST (:= x (+ 0 1))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program12ExprMinus() throws Exception { + String test = "program exprMinus;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0-1;"+ + "end."; + String expected = "(program exprMinus (DECLLIST (DECL x int)) (STATLIST (:= x (- 0 1))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program13ExprMul() throws Exception { + String test = "program exprMul;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0*1;"+ + "end."; + String expected = "(program exprMul (DECLLIST (DECL x int)) (STATLIST (:= x (* 0 1))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program14ExprDiv() throws Exception { + String test = "program exprDiv;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0/1;"+ + "end."; + String expected = "(program exprDiv (DECLLIST (DECL x int)) (STATLIST (:= x (/ 0 1))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program15ExprUMinus() throws Exception { + String test = "program exprUMinus;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0--1;"+ + "end."; + String expected = "(program exprUMinus (DECLLIST (DECL x int)) (STATLIST (:= x (- 0 (UMINUS 1)))))"; + testTreeGrammarTree(test, expected); + } + + + @Test + public void program16ExprPlusMinus() throws Exception { + String test = "program exprPlus;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0+1+-2-3+4;"+ + "end."; + String expected = "(program exprPlus (DECLLIST (DECL x int)) " + + "(STATLIST (:= x (+ (- (+ (+ 0 1) (UMINUS 2)) 3) 4))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program17ExprMulDiv() throws Exception { + String test = "program exprMul;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0*1/2*-3*4;"+ + "end."; + String expected = "(program exprMul (DECLLIST (DECL x int)) " + + "(STATLIST (:= x (* (* (/ (* 0 1) 2) (UMINUS 3)) 4))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program18ExprAll() throws Exception { + String test = "program exprAll;\n"+ + " x: int;"+ + "begin\n"+ + " x :=0*1+2/-3*(4-5+6)*7;"+ + "end."; + String expected = "(program exprAll (DECLLIST (DECL x int)) " + + "(STATLIST (:= x (+ (* 0 1) (* (* (/ 2 (UMINUS 3)) (+ (- 4 5) 6)) 7)))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program19ExprVar() throws Exception { + String test = "program exprAll;\n"+ + " x: int;"+ + " y: int;"+ + " z: int;"+ + "begin\n"+ + " x :=0*x+y;"+ + "end."; + String expected = "(program exprAll (DECLLIST (DECL x int) (DECL y int) (DECL z int)) " + + "(STATLIST (:= x (+ (* 0 x) y))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program20Cond() throws Exception { + String test = "program cond;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then x:=1;"+ + "end."; + String expected = "(program cond (DECLLIST (DECL x int)) (STATLIST (if (< 2 3) (:= x 1))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program21CondElse() throws Exception { + String test = "program condElse;\n"+ + " x: int;"+ + "begin\n"+ + " if 2>3 then x:=1 else x:=2;"+ + "end."; + String expected = "(program condElse (DECLLIST (DECL x int)) (STATLIST (if (> 2 3) (:= x 1) (:= x 2))))"; + testTreeGrammarTree(test, expected); + } + + @Test + public void program22CondElse2() throws Exception { + String test = "program condelse2;\n"+ + " x: int;"+ + "begin\n"+ + " if 2=3 then if 4<5 then x:=1 else x:=2 else x:=3;"+ + "end."; + String expected = "(program condelse2 (DECLLIST (DECL x int)) " + + "(STATLIST (if (= 2 3) (if (< 4 5) (:= x 1) (:= x 2)) (:= x 3))))"; + testTreeGrammarTree(test, expected); + } + + + @Test + public void program23CondElse3() throws Exception { + String test = "program condelse3;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then if 4>5 then x:=1 else if 6=7 then x:=2 else x:=3;"+ + "end."; + String expected = "(program condelse3 (DECLLIST (DECL x int)) " + + "(STATLIST (if (< 2 3) (if (> 4 5) (:= x 1) (if (= 6 7) (:= x 2) (:= x 3))))))"; + testTreeGrammarTree(test, expected); + } + + + @Test + public void program24CondElse4() throws Exception { + String test = "program condelse4;\n"+ + " x: int;"+ + "begin\n"+ + " if 2<3 then if 4>5 then x:=1 else x:=2 else if 6=7 then x:=3 else x:=4;"+ + "end."; + String expected = "(program condelse4 (DECLLIST (DECL x int)) " + + "(STATLIST (if (< 2 3) (if (> 4 5) (:= x 1) (:= x 2)) (if (= 6 7) (:= x 3) (:= x 4)))))"; + testTreeGrammarTree(test, expected); + } + + + @Test + public void program90Xmin1() throws Exception { + String test = "program xmin1;\n"+ + " read x : int;\n"+ + " print y : int;\n"+ + "begin\n"+ + " y := 25+2*x-6*x;\n"+ + " if x=XParser.tokenNames.length) { + name = "'"+name.toLowerCase()+"'"; + for(res=0 ; res=XParser.tokenNames.length) { + System.err.println("Unknown Token: "+name); + res=-9; + } + } + return res; + } + + protected void testTokenList(String in, boolean convert, CommonToken... TokenList) throws Exception { + ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(in.getBytes())); + XLexer scanner = new XLexer(input); + Token myToken; + + for (Token expected : TokenList) { + myToken = scanner.nextToken(); + if (expected.getType()!=IMPLICIT) { + assertEquals("Expect Token "+expected.toString()+". Error in type.", + expected.getType(), myToken.getType()); + } + if (myToken.getType()!=XLexer.EOF) { + assertEquals("Expect Token "+expected.toString()+". Error in text.", + expected.getText(), myToken.getText()); + assertEquals("Expect Token "+expected.toString()+". Error in line.", + expected.getLine(), myToken.getLine()); + assertEquals("Expect Token "+expected.toString()+". Error in column.", + expected.getCharPositionInLine(), myToken.getCharPositionInLine()); + } + if (convert) { + // Type-Conversion-Test not implemented yet + /* + switch (myToken.getType()) { + case Token.INTCONST: + int intValue = Integer.parseInt(expected.getText()); + assertEquals("Expected Token value "+intValue, + intValue,((IntConstToken)myToken).getValue()); + break; + case Token.FLOATCONST: + double doubleValue = Double.parseDouble(expected.getText().replace("^", "e")); + assertEquals("Expected Token value "+doubleValue, + doubleValue,((FloatConstToken)myToken).getValue(), doubleValue*0.0000001); + break; + case Token.STRINGCONST: + String stringValue = expected.getText().substring(1, expected.getText().length()-1).replace("\\\"", "\""); + assertEquals("Expected Token value "+stringValue, + stringValue,((StringConstToken)myToken).getValue()); + break; + } + */ + } + } + + myToken = scanner.nextToken(); + assertEquals("Expected End of File (EOF), read " + myToken.toString() + ".", Token.EOF, myToken.getType()); + } + +} diff --git a/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TreeGrammarTreeTest.java b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TreeGrammarTreeTest.java new file mode 100644 index 0000000..da1f19c --- /dev/null +++ b/CC-Praxis-Antlr Baumgrammatiken-Leer/src/de/dhbw/compiler/antlrxtreegrammar/test/TreeGrammarTreeTest.java @@ -0,0 +1,49 @@ +/* ********************************************** + * Duale Hochschule Baden-Württemberg Karlsruhe + * Prof. Dr. Jörn Eisenbiegler + * + * Vorlesung Übersetzerbau + * Praxis ANTLR-Parser für X + * - Testfall-Utility für Parser + * + * ********************************************** + */ + + +package de.dhbw.compiler.antlrxtreegrammar.test; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; + +import org.antlr.runtime.ANTLRInputStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.ParserRuleReturnScope; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeNodeStream; + +import de.dhbw.compiler.antlrxtreegrammar.XLexer; +import de.dhbw.compiler.antlrxtreegrammar.XParser; +import de.dhbw.compiler.antlrxtreegrammar.XTreeGrammar; + +public abstract class TreeGrammarTreeTest { + + protected void testTreeGrammarTree(String in, String expected) throws Exception { + ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(in.getBytes())); + XLexer scanner = new XLexer(input); + CommonTokenStream tokens = new CommonTokenStream(scanner); + XParser parser = new XParser(tokens); + ParserRuleReturnScope result = parser.program(); + CommonTree out = (CommonTree) result.getTree(); + + XTreeGrammar treeGrammar = new XTreeGrammar(new CommonTreeNodeStream(out)); + out = treeGrammar.program().getTree(); + + if (out==null) { + assertEquals(expected, out); + } else { + assertEquals(expected, out.toStringTree()); + } + } + +}