1427 lines
43 KiB
Java
1427 lines
43 KiB
Java
// $ANTLR 3.5.2 C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g 2020-06-12 16:02:49
|
|
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[] {
|
|
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "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 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:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g"; }
|
|
|
|
|
|
public static class decl_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "decl"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:1: decl : ^( DECL ID ( 'int' | 'float' | 'string' ) ( 'read' )? ( 'print' )? ) ;
|
|
public final XTreeGrammar.decl_return decl() throws RecognitionException {
|
|
XTreeGrammar.decl_return retval = new XTreeGrammar.decl_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree DECL1=null;
|
|
CommonTree ID2=null;
|
|
CommonTree set3=null;
|
|
CommonTree string_literal4=null;
|
|
CommonTree string_literal5=null;
|
|
|
|
CommonTree DECL1_tree=null;
|
|
CommonTree ID2_tree=null;
|
|
CommonTree set3_tree=null;
|
|
CommonTree string_literal4_tree=null;
|
|
CommonTree string_literal5_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:5: ( ^( DECL ID ( 'int' | 'float' | 'string' ) ( 'read' )? ( 'print' )? ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:13: ^( DECL ID ( 'int' | 'float' | 'string' ) ( 'read' )? ( 'print' )? )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
DECL1=(CommonTree)match(input,DECL,FOLLOW_DECL_in_decl65);
|
|
DECL1_tree = (CommonTree)adaptor.dupNode(DECL1);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(DECL1_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
ID2=(CommonTree)match(input,ID,FOLLOW_ID_in_decl67);
|
|
ID2_tree = (CommonTree)adaptor.dupNode(ID2);
|
|
|
|
|
|
adaptor.addChild(root_1, ID2_tree);
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
set3=(CommonTree)input.LT(1);
|
|
if ( input.LA(1)==36||input.LA(1)==39||input.LA(1)==43 ) {
|
|
input.consume();
|
|
set3_tree = (CommonTree)adaptor.dupNode(set3);
|
|
|
|
|
|
adaptor.addChild(root_1, set3_tree);
|
|
|
|
state.errorRecovery=false;
|
|
}
|
|
else {
|
|
MismatchedSetException mse = new MismatchedSetException(null,input);
|
|
throw mse;
|
|
}
|
|
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:52: ( 'read' )?
|
|
int alt1=2;
|
|
int LA1_0 = input.LA(1);
|
|
if ( (LA1_0==42) ) {
|
|
alt1=1;
|
|
}
|
|
switch (alt1) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:52: 'read'
|
|
{
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal4=(CommonTree)match(input,42,FOLLOW_42_in_decl81);
|
|
string_literal4_tree = (CommonTree)adaptor.dupNode(string_literal4);
|
|
|
|
|
|
adaptor.addChild(root_1, string_literal4_tree);
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:60: ( 'print' )?
|
|
int alt2=2;
|
|
int LA2_0 = input.LA(1);
|
|
if ( (LA2_0==40) ) {
|
|
alt2=1;
|
|
}
|
|
switch (alt2) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:12:60: 'print'
|
|
{
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal5=(CommonTree)match(input,40,FOLLOW_40_in_decl84);
|
|
string_literal5_tree = (CommonTree)adaptor.dupNode(string_literal5);
|
|
|
|
|
|
adaptor.addChild(root_1, string_literal5_tree);
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "decl"
|
|
|
|
|
|
public static class decllist_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "decllist"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:13:1: decllist : ^( DECLLIST ( decl )* ) ;
|
|
public final XTreeGrammar.decllist_return decllist() throws RecognitionException {
|
|
XTreeGrammar.decllist_return retval = new XTreeGrammar.decllist_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree DECLLIST6=null;
|
|
TreeRuleReturnScope decl7 =null;
|
|
|
|
CommonTree DECLLIST6_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:13:9: ( ^( DECLLIST ( decl )* ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:13:13: ^( DECLLIST ( decl )* )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
DECLLIST6=(CommonTree)match(input,DECLLIST,FOLLOW_DECLLIST_in_decllist95);
|
|
DECLLIST6_tree = (CommonTree)adaptor.dupNode(DECLLIST6);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(DECLLIST6_tree, root_1);
|
|
|
|
if ( input.LA(1)==Token.DOWN ) {
|
|
match(input, Token.DOWN, null);
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:13:24: ( decl )*
|
|
loop3:
|
|
while (true) {
|
|
int alt3=2;
|
|
int LA3_0 = input.LA(1);
|
|
if ( (LA3_0==DECL) ) {
|
|
alt3=1;
|
|
}
|
|
|
|
switch (alt3) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:13:24: decl
|
|
{
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_decl_in_decllist97);
|
|
decl7=decl();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, decl7.getTree());
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
break loop3;
|
|
}
|
|
}
|
|
|
|
match(input, Token.UP, null);
|
|
}
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "decllist"
|
|
|
|
|
|
public static class expr_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "expr"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:15:1: expr : ( ^( ( '+' | '-' | '*' | '/' ) expr expr ) | ^( UMINUS ( INTCONST | FLOATCONST ) ) | INTCONST | FLOATCONST | STRINGCONST | ID );
|
|
public final XTreeGrammar.expr_return expr() throws RecognitionException {
|
|
XTreeGrammar.expr_return retval = new XTreeGrammar.expr_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree set8=null;
|
|
CommonTree UMINUS11=null;
|
|
CommonTree set12=null;
|
|
CommonTree INTCONST13=null;
|
|
CommonTree FLOATCONST14=null;
|
|
CommonTree STRINGCONST15=null;
|
|
CommonTree ID16=null;
|
|
TreeRuleReturnScope expr9 =null;
|
|
TreeRuleReturnScope expr10 =null;
|
|
|
|
CommonTree set8_tree=null;
|
|
CommonTree UMINUS11_tree=null;
|
|
CommonTree set12_tree=null;
|
|
CommonTree INTCONST13_tree=null;
|
|
CommonTree FLOATCONST14_tree=null;
|
|
CommonTree STRINGCONST15_tree=null;
|
|
CommonTree ID16_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:15:5: ( ^( ( '+' | '-' | '*' | '/' ) expr expr ) | ^( UMINUS ( INTCONST | FLOATCONST ) ) | INTCONST | FLOATCONST | STRINGCONST | ID )
|
|
int alt4=6;
|
|
switch ( input.LA(1) ) {
|
|
case 22:
|
|
case 23:
|
|
case 24:
|
|
case 26:
|
|
{
|
|
alt4=1;
|
|
}
|
|
break;
|
|
case UMINUS:
|
|
{
|
|
alt4=2;
|
|
}
|
|
break;
|
|
case INTCONST:
|
|
{
|
|
alt4=3;
|
|
}
|
|
break;
|
|
case FLOATCONST:
|
|
{
|
|
alt4=4;
|
|
}
|
|
break;
|
|
case STRINGCONST:
|
|
{
|
|
alt4=5;
|
|
}
|
|
break;
|
|
case ID:
|
|
{
|
|
alt4=6;
|
|
}
|
|
break;
|
|
default:
|
|
NoViableAltException nvae =
|
|
new NoViableAltException("", 4, 0, input);
|
|
throw nvae;
|
|
}
|
|
switch (alt4) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:15:13: ^( ( '+' | '-' | '*' | '/' ) expr expr )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
set8=(CommonTree)input.LT(1);
|
|
if ( (input.LA(1) >= 22 && input.LA(1) <= 24)||input.LA(1)==26 ) {
|
|
input.consume();
|
|
set8_tree = (CommonTree)adaptor.dupNode(set8);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(set8_tree, root_1);
|
|
|
|
state.errorRecovery=false;
|
|
}
|
|
else {
|
|
MismatchedSetException mse = new MismatchedSetException(null,input);
|
|
throw mse;
|
|
}
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_expr_in_expr129);
|
|
expr9=expr();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, expr9.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_expr_in_expr131);
|
|
expr10=expr();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, expr10.getTree());
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
break;
|
|
case 2 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:16:15: ^( UMINUS ( INTCONST | FLOATCONST ) )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
UMINUS11=(CommonTree)match(input,UMINUS,FOLLOW_UMINUS_in_expr149);
|
|
UMINUS11_tree = (CommonTree)adaptor.dupNode(UMINUS11);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(UMINUS11_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
set12=(CommonTree)input.LT(1);
|
|
if ( input.LA(1)==FLOATCONST||input.LA(1)==INTCONST ) {
|
|
input.consume();
|
|
set12_tree = (CommonTree)adaptor.dupNode(set12);
|
|
|
|
|
|
adaptor.addChild(root_1, set12_tree);
|
|
|
|
state.errorRecovery=false;
|
|
}
|
|
else {
|
|
MismatchedSetException mse = new MismatchedSetException(null,input);
|
|
throw mse;
|
|
}
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
break;
|
|
case 3 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:17:15: INTCONST
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
INTCONST13=(CommonTree)match(input,INTCONST,FOLLOW_INTCONST_in_expr174);
|
|
INTCONST13_tree = (CommonTree)adaptor.dupNode(INTCONST13);
|
|
|
|
|
|
adaptor.addChild(root_0, INTCONST13_tree);
|
|
|
|
}
|
|
break;
|
|
case 4 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:17:26: FLOATCONST
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
FLOATCONST14=(CommonTree)match(input,FLOATCONST,FOLLOW_FLOATCONST_in_expr178);
|
|
FLOATCONST14_tree = (CommonTree)adaptor.dupNode(FLOATCONST14);
|
|
|
|
|
|
adaptor.addChild(root_0, FLOATCONST14_tree);
|
|
|
|
}
|
|
break;
|
|
case 5 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:17:39: STRINGCONST
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
STRINGCONST15=(CommonTree)match(input,STRINGCONST,FOLLOW_STRINGCONST_in_expr182);
|
|
STRINGCONST15_tree = (CommonTree)adaptor.dupNode(STRINGCONST15);
|
|
|
|
|
|
adaptor.addChild(root_0, STRINGCONST15_tree);
|
|
|
|
}
|
|
break;
|
|
case 6 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:17:53: ID
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
ID16=(CommonTree)match(input,ID,FOLLOW_ID_in_expr186);
|
|
ID16_tree = (CommonTree)adaptor.dupNode(ID16);
|
|
|
|
|
|
adaptor.addChild(root_0, ID16_tree);
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "expr"
|
|
|
|
|
|
public static class assignstat_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "assignstat"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:19:1: assignstat : ^( ':=' ID expr ) ;
|
|
public final XTreeGrammar.assignstat_return assignstat() throws RecognitionException {
|
|
XTreeGrammar.assignstat_return retval = new XTreeGrammar.assignstat_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree string_literal17=null;
|
|
CommonTree ID18=null;
|
|
TreeRuleReturnScope expr19 =null;
|
|
|
|
CommonTree string_literal17_tree=null;
|
|
CommonTree ID18_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:19:11: ( ^( ':=' ID expr ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:19:13: ^( ':=' ID expr )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal17=(CommonTree)match(input,28,FOLLOW_28_in_assignstat194);
|
|
string_literal17_tree = (CommonTree)adaptor.dupNode(string_literal17);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(string_literal17_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
ID18=(CommonTree)match(input,ID,FOLLOW_ID_in_assignstat196);
|
|
ID18_tree = (CommonTree)adaptor.dupNode(ID18);
|
|
|
|
|
|
adaptor.addChild(root_1, ID18_tree);
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_expr_in_assignstat198);
|
|
expr19=expr();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, expr19.getTree());
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "assignstat"
|
|
|
|
|
|
public static class cond_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "cond"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:21:1: cond : ^( ( '<' | '>' | '=' ) expr expr ) ;
|
|
public final XTreeGrammar.cond_return cond() throws RecognitionException {
|
|
XTreeGrammar.cond_return retval = new XTreeGrammar.cond_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree set20=null;
|
|
TreeRuleReturnScope expr21 =null;
|
|
TreeRuleReturnScope expr22 =null;
|
|
|
|
CommonTree set20_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:21:5: ( ^( ( '<' | '>' | '=' ) expr expr ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:21:13: ^( ( '<' | '>' | '=' ) expr expr )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
set20=(CommonTree)input.LT(1);
|
|
if ( (input.LA(1) >= 30 && input.LA(1) <= 32) ) {
|
|
input.consume();
|
|
set20_tree = (CommonTree)adaptor.dupNode(set20);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(set20_tree, root_1);
|
|
|
|
state.errorRecovery=false;
|
|
}
|
|
else {
|
|
MismatchedSetException mse = new MismatchedSetException(null,input);
|
|
throw mse;
|
|
}
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_expr_in_cond225);
|
|
expr21=expr();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, expr21.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_expr_in_cond227);
|
|
expr22=expr();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, expr22.getTree());
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "cond"
|
|
|
|
|
|
public static class condstat_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "condstat"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:22:1: condstat : ^( 'if' cond stat ( stat )? ) ;
|
|
public final XTreeGrammar.condstat_return condstat() throws RecognitionException {
|
|
XTreeGrammar.condstat_return retval = new XTreeGrammar.condstat_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree string_literal23=null;
|
|
TreeRuleReturnScope cond24 =null;
|
|
TreeRuleReturnScope stat25 =null;
|
|
TreeRuleReturnScope stat26 =null;
|
|
|
|
CommonTree string_literal23_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:22:9: ( ^( 'if' cond stat ( stat )? ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:22:13: ^( 'if' cond stat ( stat )? )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal23=(CommonTree)match(input,38,FOLLOW_38_in_condstat237);
|
|
string_literal23_tree = (CommonTree)adaptor.dupNode(string_literal23);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(string_literal23_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_cond_in_condstat239);
|
|
cond24=cond();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, cond24.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_stat_in_condstat241);
|
|
stat25=stat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, stat25.getTree());
|
|
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:22:30: ( stat )?
|
|
int alt5=2;
|
|
int LA5_0 = input.LA(1);
|
|
if ( (LA5_0==STATLIST||LA5_0==28||(LA5_0 >= 37 && LA5_0 <= 38)||LA5_0==45) ) {
|
|
alt5=1;
|
|
}
|
|
switch (alt5) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:22:30: stat
|
|
{
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_stat_in_condstat243);
|
|
stat26=stat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, stat26.getTree());
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "condstat"
|
|
|
|
|
|
public static class whilestat_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "whilestat"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:24:1: whilestat : ^( 'while' cond stat ) ;
|
|
public final XTreeGrammar.whilestat_return whilestat() throws RecognitionException {
|
|
XTreeGrammar.whilestat_return retval = new XTreeGrammar.whilestat_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree string_literal27=null;
|
|
TreeRuleReturnScope cond28 =null;
|
|
TreeRuleReturnScope stat29 =null;
|
|
|
|
CommonTree string_literal27_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:24:10: ( ^( 'while' cond stat ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:24:13: ^( 'while' cond stat )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal27=(CommonTree)match(input,45,FOLLOW_45_in_whilestat254);
|
|
string_literal27_tree = (CommonTree)adaptor.dupNode(string_literal27);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(string_literal27_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_cond_in_whilestat256);
|
|
cond28=cond();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, cond28.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_stat_in_whilestat258);
|
|
stat29=stat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, stat29.getTree());
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "whilestat"
|
|
|
|
|
|
public static class forstat_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "forstat"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:25:1: forstat : ^( 'for' assignstat cond assignstat stat ) ;
|
|
public final XTreeGrammar.forstat_return forstat() throws RecognitionException {
|
|
XTreeGrammar.forstat_return retval = new XTreeGrammar.forstat_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree string_literal30=null;
|
|
TreeRuleReturnScope assignstat31 =null;
|
|
TreeRuleReturnScope cond32 =null;
|
|
TreeRuleReturnScope assignstat33 =null;
|
|
TreeRuleReturnScope stat34 =null;
|
|
|
|
CommonTree string_literal30_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:25:8: ( ^( 'for' assignstat cond assignstat stat ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:25:13: ^( 'for' assignstat cond assignstat stat )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal30=(CommonTree)match(input,37,FOLLOW_37_in_forstat269);
|
|
string_literal30_tree = (CommonTree)adaptor.dupNode(string_literal30);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(string_literal30_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_assignstat_in_forstat271);
|
|
assignstat31=assignstat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, assignstat31.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_cond_in_forstat273);
|
|
cond32=cond();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, cond32.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_assignstat_in_forstat275);
|
|
assignstat33=assignstat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, assignstat33.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_stat_in_forstat277);
|
|
stat34=stat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, stat34.getTree());
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "forstat"
|
|
|
|
|
|
public static class stat_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "stat"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:1: stat : ( assignstat | condstat | whilestat | forstat | statlist );
|
|
public final XTreeGrammar.stat_return stat() throws RecognitionException {
|
|
XTreeGrammar.stat_return retval = new XTreeGrammar.stat_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
TreeRuleReturnScope assignstat35 =null;
|
|
TreeRuleReturnScope condstat36 =null;
|
|
TreeRuleReturnScope whilestat37 =null;
|
|
TreeRuleReturnScope forstat38 =null;
|
|
TreeRuleReturnScope statlist39 =null;
|
|
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:5: ( assignstat | condstat | whilestat | forstat | statlist )
|
|
int alt6=5;
|
|
switch ( input.LA(1) ) {
|
|
case 28:
|
|
{
|
|
alt6=1;
|
|
}
|
|
break;
|
|
case 38:
|
|
{
|
|
alt6=2;
|
|
}
|
|
break;
|
|
case 45:
|
|
{
|
|
alt6=3;
|
|
}
|
|
break;
|
|
case 37:
|
|
{
|
|
alt6=4;
|
|
}
|
|
break;
|
|
case STATLIST:
|
|
{
|
|
alt6=5;
|
|
}
|
|
break;
|
|
default:
|
|
NoViableAltException nvae =
|
|
new NoViableAltException("", 6, 0, input);
|
|
throw nvae;
|
|
}
|
|
switch (alt6) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:13: assignstat
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_assignstat_in_stat291);
|
|
assignstat35=assignstat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_0, assignstat35.getTree());
|
|
|
|
}
|
|
break;
|
|
case 2 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:26: condstat
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_condstat_in_stat295);
|
|
condstat36=condstat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_0, condstat36.getTree());
|
|
|
|
}
|
|
break;
|
|
case 3 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:37: whilestat
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_whilestat_in_stat299);
|
|
whilestat37=whilestat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_0, whilestat37.getTree());
|
|
|
|
}
|
|
break;
|
|
case 4 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:49: forstat
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_forstat_in_stat303);
|
|
forstat38=forstat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_0, forstat38.getTree());
|
|
|
|
}
|
|
break;
|
|
case 5 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:27:59: statlist
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_statlist_in_stat307);
|
|
statlist39=statlist();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_0, statlist39.getTree());
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "stat"
|
|
|
|
|
|
public static class statlist_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "statlist"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:29:1: statlist : ^( STATLIST ( stat )* ) ;
|
|
public final XTreeGrammar.statlist_return statlist() throws RecognitionException {
|
|
XTreeGrammar.statlist_return retval = new XTreeGrammar.statlist_return();
|
|
retval.start = input.LT(1);
|
|
|
|
CommonTree root_0 = null;
|
|
|
|
CommonTree _first_0 = null;
|
|
CommonTree _last = null;
|
|
|
|
|
|
CommonTree STATLIST40=null;
|
|
TreeRuleReturnScope stat41 =null;
|
|
|
|
CommonTree STATLIST40_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:29:9: ( ^( STATLIST ( stat )* ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:29:13: ^( STATLIST ( stat )* )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
STATLIST40=(CommonTree)match(input,STATLIST,FOLLOW_STATLIST_in_statlist317);
|
|
STATLIST40_tree = (CommonTree)adaptor.dupNode(STATLIST40);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(STATLIST40_tree, root_1);
|
|
|
|
if ( input.LA(1)==Token.DOWN ) {
|
|
match(input, Token.DOWN, null);
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:29:24: ( stat )*
|
|
loop7:
|
|
while (true) {
|
|
int alt7=2;
|
|
int LA7_0 = input.LA(1);
|
|
if ( (LA7_0==STATLIST||LA7_0==28||(LA7_0 >= 37 && LA7_0 <= 38)||LA7_0==45) ) {
|
|
alt7=1;
|
|
}
|
|
|
|
switch (alt7) {
|
|
case 1 :
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:29:24: stat
|
|
{
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_stat_in_statlist319);
|
|
stat41=stat();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, stat41.getTree());
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
break loop7;
|
|
}
|
|
}
|
|
|
|
match(input, Token.UP, null);
|
|
}
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
|
|
|
|
}
|
|
catch (RecognitionException re) {
|
|
reportError(re);
|
|
recover(input,re);
|
|
}
|
|
finally {
|
|
// do for sure before leaving
|
|
}
|
|
return retval;
|
|
}
|
|
// $ANTLR end "statlist"
|
|
|
|
|
|
public static class program_return extends TreeRuleReturnScope {
|
|
CommonTree tree;
|
|
@Override
|
|
public CommonTree getTree() { return tree; }
|
|
};
|
|
|
|
|
|
// $ANTLR start "program"
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:31:1: program : ^( 'program' ID decllist statlist ) ;
|
|
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_literal42=null;
|
|
CommonTree ID43=null;
|
|
TreeRuleReturnScope decllist44 =null;
|
|
TreeRuleReturnScope statlist45 =null;
|
|
|
|
CommonTree string_literal42_tree=null;
|
|
CommonTree ID43_tree=null;
|
|
|
|
try {
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:31:8: ( ^( 'program' ID decllist statlist ) )
|
|
// C:\\Development\\Schule\\Compilerbau\\CC-Praxis-Antlr Baumgrammatiken-Leer\\src\\de\\dhbw\\compiler\\antlrxtreegrammar\\XTreeGrammar.g:31:13: ^( 'program' ID decllist statlist )
|
|
{
|
|
root_0 = (CommonTree)adaptor.nil();
|
|
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
{
|
|
CommonTree _save_last_1 = _last;
|
|
CommonTree _first_1 = null;
|
|
CommonTree root_1 = (CommonTree)adaptor.nil();
|
|
_last = (CommonTree)input.LT(1);
|
|
string_literal42=(CommonTree)match(input,41,FOLLOW_41_in_program332);
|
|
string_literal42_tree = (CommonTree)adaptor.dupNode(string_literal42);
|
|
|
|
|
|
root_1 = (CommonTree)adaptor.becomeRoot(string_literal42_tree, root_1);
|
|
|
|
match(input, Token.DOWN, null);
|
|
_last = (CommonTree)input.LT(1);
|
|
ID43=(CommonTree)match(input,ID,FOLLOW_ID_in_program334);
|
|
ID43_tree = (CommonTree)adaptor.dupNode(ID43);
|
|
|
|
|
|
adaptor.addChild(root_1, ID43_tree);
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_decllist_in_program336);
|
|
decllist44=decllist();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, decllist44.getTree());
|
|
|
|
_last = (CommonTree)input.LT(1);
|
|
pushFollow(FOLLOW_statlist_in_program338);
|
|
statlist45=statlist();
|
|
state._fsp--;
|
|
|
|
adaptor.addChild(root_1, statlist45.getTree());
|
|
|
|
match(input, Token.UP, null);
|
|
adaptor.addChild(root_0, root_1);
|
|
_last = _save_last_1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
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_DECL_in_decl65 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_ID_in_decl67 = new BitSet(new long[]{0x0000089000000000L});
|
|
public static final BitSet FOLLOW_set_in_decl69 = new BitSet(new long[]{0x0000050000000008L});
|
|
public static final BitSet FOLLOW_42_in_decl81 = new BitSet(new long[]{0x0000010000000008L});
|
|
public static final BitSet FOLLOW_40_in_decl84 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_DECLLIST_in_decllist95 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_decl_in_decllist97 = new BitSet(new long[]{0x0000000000000028L});
|
|
public static final BitSet FOLLOW_set_in_expr113 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_expr_in_expr129 = new BitSet(new long[]{0x0000000005C30700L});
|
|
public static final BitSet FOLLOW_expr_in_expr131 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_UMINUS_in_expr149 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_set_in_expr151 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_INTCONST_in_expr174 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_FLOATCONST_in_expr178 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_STRINGCONST_in_expr182 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_ID_in_expr186 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_28_in_assignstat194 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_ID_in_assignstat196 = new BitSet(new long[]{0x0000000005C30700L});
|
|
public static final BitSet FOLLOW_expr_in_assignstat198 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_set_in_cond213 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_expr_in_cond225 = new BitSet(new long[]{0x0000000005C30700L});
|
|
public static final BitSet FOLLOW_expr_in_cond227 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_38_in_condstat237 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_cond_in_condstat239 = new BitSet(new long[]{0x0000206010008000L});
|
|
public static final BitSet FOLLOW_stat_in_condstat241 = new BitSet(new long[]{0x0000206010008008L});
|
|
public static final BitSet FOLLOW_stat_in_condstat243 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_45_in_whilestat254 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_cond_in_whilestat256 = new BitSet(new long[]{0x0000206010008000L});
|
|
public static final BitSet FOLLOW_stat_in_whilestat258 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_37_in_forstat269 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_assignstat_in_forstat271 = new BitSet(new long[]{0x00000001C0000000L});
|
|
public static final BitSet FOLLOW_cond_in_forstat273 = new BitSet(new long[]{0x0000000010000000L});
|
|
public static final BitSet FOLLOW_assignstat_in_forstat275 = new BitSet(new long[]{0x0000206010008000L});
|
|
public static final BitSet FOLLOW_stat_in_forstat277 = new BitSet(new long[]{0x0000000000000008L});
|
|
public static final BitSet FOLLOW_assignstat_in_stat291 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_condstat_in_stat295 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_whilestat_in_stat299 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_forstat_in_stat303 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_statlist_in_stat307 = new BitSet(new long[]{0x0000000000000002L});
|
|
public static final BitSet FOLLOW_STATLIST_in_statlist317 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_stat_in_statlist319 = new BitSet(new long[]{0x0000206010008008L});
|
|
public static final BitSet FOLLOW_41_in_program332 = new BitSet(new long[]{0x0000000000000004L});
|
|
public static final BitSet FOLLOW_ID_in_program334 = new BitSet(new long[]{0x0000000000000040L});
|
|
public static final BitSet FOLLOW_decllist_in_program336 = new BitSet(new long[]{0x0000000000008000L});
|
|
public static final BitSet FOLLOW_statlist_in_program338 = new BitSet(new long[]{0x0000000000000008L});
|
|
}
|