From c52f062b78f9893b5800ed6aeb878bd3df8b4501 Mon Sep 17 00:00:00 2001 From: Bernhard Schmalhofer Date: Tue, 8 Aug 2006 22:06:20 +0000 Subject: [PATCH] [Parrot bc with ANTLR3] Unify lexer rules MUL, DIV, MOD to MUL_OP git-svn-id: https://svn.parrot.org/parrot/trunk@13930 d31e2699-5ff4-0310-a27c-f18f2fbe73fe --- .../bc/grammar/antlr_3/AntlrPast2PirPast.java | 68 ++-- languages/bc/grammar/antlr_3/BcParser.java | 335 +++++++----------- .../bc/grammar/antlr_3/BcParserLexer.java | 271 ++++++-------- .../bc/grammar/antlr_3/antlr_past2pir_past.g | 2 +- languages/bc/grammar/antlr_3/bc.g | 14 +- 5 files changed, 271 insertions(+), 419 deletions(-) diff --git a/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java b/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java index 74142ef731..c377fe43dc 100644 --- a/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java +++ b/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java @@ -1,4 +1,4 @@ -// $ANTLR 3.0b3 grammar/antlr_3/antlr_past2pir_past.g 2006-08-08 23:54:43 +// $ANTLR 3.0b3 grammar/antlr_3/antlr_past2pir_past.g 2006-08-09 00:03:13 import org.antlr.runtime.*; import org.antlr.runtime.tree.*;import java.util.Stack; @@ -7,25 +7,23 @@ public class AntlrPast2PirPast extends TreeParser { public static final String[] tokenNames = new String[] { - "", "", "", "", "PROGRAM", "VAR", "STRING", "LETTER", "PLUS", "MINUS", "MUL", "DIV", "MOD", "INCR", "DECR", "NUMBER", "INTEGER", "ML_COMMENT", "WS", "NEWLINE", "';'", "'('", "')'", "'quit'" + "", "", "", "", "PROGRAM", "VAR", "STRING", "LETTER", "PLUS", "MINUS", "MUL_OP", "INCR", "DECR", "NUMBER", "INTEGER", "ML_COMMENT", "WS", "NEWLINE", "';'", "'('", "')'", "'quit'" }; + public static final int VAR=5; + public static final int INTEGER=14; public static final int MINUS=9; public static final int LETTER=7; - public static final int INCR=13; - public static final int DECR=14; - public static final int NUMBER=15; - public static final int WS=18; - public static final int STRING=6; - public static final int MOD=12; - public static final int PROGRAM=4; - public static final int NEWLINE=19; - public static final int VAR=5; - public static final int MUL=10; - public static final int INTEGER=16; + public static final int INCR=11; + public static final int DECR=12; + public static final int NUMBER=13; + public static final int WS=16; public static final int EOF=-1; - public static final int DIV=11; + public static final int STRING=6; + public static final int MUL_OP=10; public static final int PLUS=8; - public static final int ML_COMMENT=17; + public static final int ML_COMMENT=15; + public static final int PROGRAM=4; + public static final int NEWLINE=17; public AntlrPast2PirPast(TreeNodeStream input) { super(input); @@ -89,7 +87,7 @@ public void gen_pir_past() throws RecognitionException { do { int alt1=2; int LA1_0 = input.LA(1); - if ( ((LA1_0>=VAR && LA1_0<=STRING)||(LA1_0>=PLUS && LA1_0<=MOD)||LA1_0==NUMBER) ) { + if ( ((LA1_0>=VAR && LA1_0<=STRING)||(LA1_0>=PLUS && LA1_0<=MUL_OP)||LA1_0==NUMBER) ) { alt1=1; } @@ -206,7 +204,7 @@ public void expression(String reg_mother) throws RecognitionException { // grammar/antlr_3/antlr_past2pir_past.g:125:5: ( ( adding_expression[\"reg_expression_exp\"] | named_expression[\"reg_expression_exp\"] ) | string[ mother_for_string ] ) int alt3=2; int LA3_0 = input.LA(1); - if ( (LA3_0==VAR||(LA3_0>=PLUS && LA3_0<=MOD)||LA3_0==NUMBER) ) { + if ( (LA3_0==VAR||(LA3_0>=PLUS && LA3_0<=MUL_OP)||LA3_0==NUMBER) ) { alt3=1; } else if ( (LA3_0==STRING) ) { @@ -236,7 +234,7 @@ else if ( (LA3_0==STRING) ) { // grammar/antlr_3/antlr_past2pir_past.g:136:5: ( adding_expression[\"reg_expression_exp\"] | named_expression[\"reg_expression_exp\"] ) int alt2=2; int LA2_0 = input.LA(1); - if ( ((LA2_0>=PLUS && LA2_0<=MOD)||LA2_0==NUMBER) ) { + if ( ((LA2_0>=PLUS && LA2_0<=MUL_OP)||LA2_0==NUMBER) ) { alt2=1; } else if ( (LA2_0==VAR) ) { @@ -415,13 +413,13 @@ public void integer(String reg_mother) throws RecognitionException { // $ANTLR start adding_expression - // grammar/antlr_3/antlr_past2pir_past.g:218:1: adding_expression[String reg_mother] : ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL|DIV|MOD) adding_expression[reg] adding_expression[reg] ) ) ; + // grammar/antlr_3/antlr_past2pir_past.g:218:1: adding_expression[String reg_mother] : ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL_OP) adding_expression[reg] adding_expression[reg] ) ) ; public void adding_expression(String reg_mother) throws RecognitionException { CommonTree infix=null; try { - // grammar/antlr_3/antlr_past2pir_past.g:219:5: ( ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL|DIV|MOD) adding_expression[reg] adding_expression[reg] ) ) ) - // grammar/antlr_3/antlr_past2pir_past.g:219:5: ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL|DIV|MOD) adding_expression[reg] adding_expression[reg] ) ) + // grammar/antlr_3/antlr_past2pir_past.g:219:5: ( ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL_OP) adding_expression[reg] adding_expression[reg] ) ) ) + // grammar/antlr_3/antlr_past2pir_past.g:219:5: ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL_OP) adding_expression[reg] adding_expression[reg] ) ) { System.out.print( @@ -431,18 +429,18 @@ public void adding_expression(String reg_mother) throws RecognitionException { // Why can't I say: integer[ reg_mother ] ??? String mother_for_int = reg_mother; - // grammar/antlr_3/antlr_past2pir_past.g:227:5: ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL|DIV|MOD) adding_expression[reg] adding_expression[reg] ) ) + // grammar/antlr_3/antlr_past2pir_past.g:227:5: ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL_OP) adding_expression[reg] adding_expression[reg] ) ) int alt4=2; int LA4_0 = input.LA(1); if ( (LA4_0==NUMBER) ) { alt4=1; } - else if ( ((LA4_0>=PLUS && LA4_0<=MOD)) ) { + else if ( ((LA4_0>=PLUS && LA4_0<=MUL_OP)) ) { alt4=2; } else { NoViableAltException nvae = - new NoViableAltException("227:5: ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL|DIV|MOD) adding_expression[reg] adding_expression[reg] ) )", 4, 0, input); + new NoViableAltException("227:5: ( integer[ mother_for_int ] | ^(infix= (PLUS|MINUS|MUL_OP) adding_expression[reg] adding_expression[reg] ) )", 4, 0, input); throw nvae; } @@ -458,7 +456,7 @@ else if ( ((LA4_0>=PLUS && LA4_0<=MOD)) ) { } break; case 2 : - // grammar/antlr_3/antlr_past2pir_past.g:229:7: ^(infix= (PLUS|MINUS|MUL|DIV|MOD) adding_expression[reg] adding_expression[reg] ) + // grammar/antlr_3/antlr_past2pir_past.g:229:7: ^(infix= (PLUS|MINUS|MUL_OP) adding_expression[reg] adding_expression[reg] ) { reg_num++; @@ -471,7 +469,7 @@ else if ( ((LA4_0>=PLUS && LA4_0<=MOD)) ) { ); infix=(CommonTree)input.LT(1); - if ( (input.LA(1)>=PLUS && input.LA(1)<=MOD) ) { + if ( (input.LA(1)>=PLUS && input.LA(1)<=MUL_OP) ) { input.consume(); errorRecovery=false; } @@ -483,11 +481,11 @@ else if ( ((LA4_0>=PLUS && LA4_0<=MOD)) ) { match(input, Token.DOWN, null); - pushFollow(FOLLOW_adding_expression_in_adding_expression272); + pushFollow(FOLLOW_adding_expression_in_adding_expression264); adding_expression(reg); _fsp--; - pushFollow(FOLLOW_adding_expression_in_adding_expression275); + pushFollow(FOLLOW_adding_expression_in_adding_expression267); adding_expression(reg); _fsp--; @@ -545,11 +543,11 @@ public void named_expression(String reg_mother) throws RecognitionException { + " # entering 'named_expression' \n" ); - match(input,VAR,FOLLOW_VAR_in_named_expression320); + match(input,VAR,FOLLOW_VAR_in_named_expression312); match(input, Token.DOWN, null); LETTER3=(CommonTree)input.LT(1); - match(input,LETTER,FOLLOW_LETTER_in_named_expression322); + match(input,LETTER,FOLLOW_LETTER_in_named_expression314); match(input, Token.UP, null); @@ -598,7 +596,7 @@ public void named_expression(String reg_mother) throws RecognitionException { public static final BitSet FOLLOW_PROGRAM_in_gen_pir_past65 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_expression_in_gen_pir_past67 = new BitSet(new long[]{0x0000000000009F68L}); + public static final BitSet FOLLOW_expression_in_gen_pir_past67 = new BitSet(new long[]{0x0000000000002768L}); public static final BitSet FOLLOW_adding_expression_in_expression105 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_named_expression_in_expression122 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_string_in_expression153 = new BitSet(new long[]{0x0000000000000002L}); @@ -606,9 +604,9 @@ public void named_expression(String reg_mother) throws RecognitionException { public static final BitSet FOLLOW_NUMBER_in_integer193 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_integer_in_adding_expression221 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_set_in_adding_expression252 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_adding_expression_in_adding_expression272 = new BitSet(new long[]{0x0000000000009F00L}); - public static final BitSet FOLLOW_adding_expression_in_adding_expression275 = new BitSet(new long[]{0x0000000000000008L}); - public static final BitSet FOLLOW_VAR_in_named_expression320 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_LETTER_in_named_expression322 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_adding_expression_in_adding_expression264 = new BitSet(new long[]{0x0000000000002700L}); + public static final BitSet FOLLOW_adding_expression_in_adding_expression267 = new BitSet(new long[]{0x0000000000000008L}); + public static final BitSet FOLLOW_VAR_in_named_expression312 = new BitSet(new long[]{0x0000000000000004L}); + public static final BitSet FOLLOW_LETTER_in_named_expression314 = new BitSet(new long[]{0x0000000000000008L}); } \ No newline at end of file diff --git a/languages/bc/grammar/antlr_3/BcParser.java b/languages/bc/grammar/antlr_3/BcParser.java index dc52a1e89b..70bf3f4ba6 100644 --- a/languages/bc/grammar/antlr_3/BcParser.java +++ b/languages/bc/grammar/antlr_3/BcParser.java @@ -1,4 +1,4 @@ -// $ANTLR 3.0b3 grammar/antlr_3/bc.g 2006-08-08 23:54:41 +// $ANTLR 3.0b3 grammar/antlr_3/bc.g 2006-08-09 00:03:10 import org.antlr.runtime.*; import java.util.Stack; @@ -10,25 +10,23 @@ public class BcParser extends Parser { public static final String[] tokenNames = new String[] { - "", "", "", "", "PROGRAM", "VAR", "STRING", "LETTER", "PLUS", "MINUS", "MUL", "DIV", "MOD", "INCR", "DECR", "NUMBER", "INTEGER", "ML_COMMENT", "WS", "NEWLINE", "';'", "'('", "')'", "'quit'" + "", "", "", "", "PROGRAM", "VAR", "STRING", "LETTER", "PLUS", "MINUS", "MUL_OP", "INCR", "DECR", "NUMBER", "INTEGER", "ML_COMMENT", "WS", "NEWLINE", "';'", "'('", "')'", "'quit'" }; - public static final int LETTER=7; - public static final int MINUS=9; - public static final int INCR=13; - public static final int DECR=14; - public static final int NUMBER=15; - public static final int WS=18; - public static final int STRING=6; - public static final int MOD=12; - public static final int PROGRAM=4; - public static final int NEWLINE=19; public static final int VAR=5; - public static final int MUL=10; - public static final int INTEGER=16; + public static final int INTEGER=14; + public static final int MINUS=9; + public static final int LETTER=7; + public static final int INCR=11; + public static final int WS=16; + public static final int NUMBER=13; + public static final int DECR=12; public static final int EOF=-1; - public static final int DIV=11; + public static final int STRING=6; + public static final int MUL_OP=10; + public static final int ML_COMMENT=15; public static final int PLUS=8; - public static final int ML_COMMENT=17; + public static final int PROGRAM=4; + public static final int NEWLINE=17; public BcParser(TokenStream input) { super(input); @@ -77,7 +75,7 @@ public program_return program() throws RecognitionException { do { int alt1=2; int LA1_0 = input.LA(1); - if ( ((LA1_0>=STRING && LA1_0<=LETTER)||(LA1_0>=INCR && LA1_0<=NUMBER)||LA1_0==21) ) { + if ( ((LA1_0>=STRING && LA1_0<=LETTER)||(LA1_0>=INCR && LA1_0<=NUMBER)||LA1_0==19) ) { alt1=1; } @@ -243,7 +241,7 @@ public semicolon_list_return semicolon_list() throws RecognitionException { do { int alt2=2; int LA2_0 = input.LA(1); - if ( (LA2_0==20) ) { + if ( (LA2_0==18) ) { alt2=1; } @@ -255,7 +253,7 @@ public semicolon_list_return semicolon_list() throws RecognitionException { CommonTree root_1 = (CommonTree)adaptor.nil(); char_literal5=(Token)input.LT(1); - match(input,20,FOLLOW_20_in_semicolon_list117); + match(input,18,FOLLOW_18_in_semicolon_list117); pushFollow(FOLLOW_statement_in_semicolon_list120); statement6=statement(); _fsp--; @@ -314,7 +312,7 @@ public statement_return statement() throws RecognitionException { // grammar/antlr_3/bc.g:42:5: ( expression | STRING ) int alt3=2; int LA3_0 = input.LA(1); - if ( (LA3_0==LETTER||(LA3_0>=INCR && LA3_0<=NUMBER)||LA3_0==21) ) { + if ( (LA3_0==LETTER||(LA3_0>=INCR && LA3_0<=NUMBER)||LA3_0==19) ) { alt3=1; } else if ( (LA3_0==STRING) ) { @@ -397,7 +395,7 @@ public expression_return expression() throws RecognitionException { if ( (LA4_0==LETTER) ) { alt4=1; } - else if ( ((LA4_0>=INCR && LA4_0<=NUMBER)||LA4_0==21) ) { + else if ( ((LA4_0>=INCR && LA4_0<=NUMBER)||LA4_0==19) ) { alt4=2; } else { @@ -655,28 +653,24 @@ public static class multiplying_expression_return extends ParserRuleReturnScope }; // $ANTLR start multiplying_expression - // grammar/antlr_3/bc.g:63:1: multiplying_expression : unary_expression ( ( MUL^^ | DIV^^ | MOD^^ ) unary_expression )* ; + // grammar/antlr_3/bc.g:63:1: multiplying_expression : unary_expression ( MUL_OP^^ unary_expression )* ; public multiplying_expression_return multiplying_expression() throws RecognitionException { multiplying_expression_return retval = new multiplying_expression_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token MUL17=null; - Token DIV18=null; - Token MOD19=null; + Token MUL_OP17=null; unary_expression_return unary_expression16 = null; - unary_expression_return unary_expression20 = null; + unary_expression_return unary_expression18 = null; - CommonTree MUL17_tree=null; - CommonTree DIV18_tree=null; - CommonTree MOD19_tree=null; + CommonTree MUL_OP17_tree=null; try { - // grammar/antlr_3/bc.g:64:5: ( unary_expression ( ( MUL^^ | DIV^^ | MOD^^ ) unary_expression )* ) - // grammar/antlr_3/bc.g:64:5: unary_expression ( ( MUL^^ | DIV^^ | MOD^^ ) unary_expression )* + // grammar/antlr_3/bc.g:64:5: ( unary_expression ( MUL_OP^^ unary_expression )* ) + // grammar/antlr_3/bc.g:64:5: unary_expression ( MUL_OP^^ unary_expression )* { root_0 = (CommonTree)adaptor.nil(); @@ -685,95 +679,32 @@ public multiplying_expression_return multiplying_expression() throws Recognition _fsp--; adaptor.addChild(root_0, unary_expression16.tree); - // grammar/antlr_3/bc.g:64:22: ( ( MUL^^ | DIV^^ | MOD^^ ) unary_expression )* - loop8: + // grammar/antlr_3/bc.g:64:22: ( MUL_OP^^ unary_expression )* + loop7: do { - int alt8=2; - int LA8_0 = input.LA(1); - if ( ((LA8_0>=MUL && LA8_0<=MOD)) ) { - alt8=1; + int alt7=2; + int LA7_0 = input.LA(1); + if ( (LA7_0==MUL_OP) ) { + alt7=1; } - switch (alt8) { + switch (alt7) { case 1 : - // grammar/antlr_3/bc.g:64:24: ( MUL^^ | DIV^^ | MOD^^ ) unary_expression + // grammar/antlr_3/bc.g:64:24: MUL_OP^^ unary_expression { CommonTree root_1 = (CommonTree)adaptor.nil(); - // grammar/antlr_3/bc.g:64:24: ( MUL^^ | DIV^^ | MOD^^ ) - int alt7=3; - switch ( input.LA(1) ) { - case MUL: - alt7=1; - break; - case DIV: - alt7=2; - break; - case MOD: - alt7=3; - break; - default: - NoViableAltException nvae = - new NoViableAltException("64:24: ( MUL^^ | DIV^^ | MOD^^ )", 7, 0, input); - - throw nvae; - } - - switch (alt7) { - case 1 : - // grammar/antlr_3/bc.g:64:26: MUL^^ - { - CommonTree root_2 = (CommonTree)adaptor.nil(); - - MUL17=(Token)input.LT(1); - match(input,MUL,FOLLOW_MUL_in_multiplying_expression251); - MUL17_tree = (CommonTree)adaptor.create(MUL17); - root_0 = (CommonTree)adaptor.becomeRoot(MUL17_tree, root_0); - - - adaptor.addChild(root_1, root_2); - - } - break; - case 2 : - // grammar/antlr_3/bc.g:64:34: DIV^^ - { - CommonTree root_2 = (CommonTree)adaptor.nil(); - - DIV18=(Token)input.LT(1); - match(input,DIV,FOLLOW_DIV_in_multiplying_expression256); - DIV18_tree = (CommonTree)adaptor.create(DIV18); - root_0 = (CommonTree)adaptor.becomeRoot(DIV18_tree, root_0); - + MUL_OP17=(Token)input.LT(1); + match(input,MUL_OP,FOLLOW_MUL_OP_in_multiplying_expression249); + MUL_OP17_tree = (CommonTree)adaptor.create(MUL_OP17); + root_0 = (CommonTree)adaptor.becomeRoot(MUL_OP17_tree, root_0); - adaptor.addChild(root_1, root_2); - - } - break; - case 3 : - // grammar/antlr_3/bc.g:64:42: MOD^^ - { - CommonTree root_2 = (CommonTree)adaptor.nil(); - - MOD19=(Token)input.LT(1); - match(input,MOD,FOLLOW_MOD_in_multiplying_expression261); - MOD19_tree = (CommonTree)adaptor.create(MOD19); - root_0 = (CommonTree)adaptor.becomeRoot(MOD19_tree, root_0); - - - adaptor.addChild(root_1, root_2); - - } - break; - - } - - pushFollow(FOLLOW_unary_expression_in_multiplying_expression266); - unary_expression20=unary_expression(); + pushFollow(FOLLOW_unary_expression_in_multiplying_expression252); + unary_expression18=unary_expression(); _fsp--; - adaptor.addChild(root_1, unary_expression20.tree); + adaptor.addChild(root_1, unary_expression18.tree); adaptor.addChild(root_0, root_1); @@ -781,7 +712,7 @@ public multiplying_expression_return multiplying_expression() throws Recognition break; default : - break loop8; + break loop7; } } while (true); @@ -817,43 +748,43 @@ public unary_expression_return unary_expression() throws RecognitionException { CommonTree root_0 = null; - Token INCR22=null; - Token DECR23=null; - postfix_expression_return postfix_expression21 = null; + Token INCR20=null; + Token DECR21=null; + postfix_expression_return postfix_expression19 = null; - postfix_expression_return postfix_expression24 = null; + postfix_expression_return postfix_expression22 = null; - CommonTree INCR22_tree=null; - CommonTree DECR23_tree=null; + CommonTree INCR20_tree=null; + CommonTree DECR21_tree=null; try { // grammar/antlr_3/bc.g:69:5: ( postfix_expression | ( INCR^^ | DECR^^ ) postfix_expression ) - int alt10=2; - int LA10_0 = input.LA(1); - if ( (LA10_0==NUMBER||LA10_0==21) ) { - alt10=1; + int alt9=2; + int LA9_0 = input.LA(1); + if ( (LA9_0==NUMBER||LA9_0==19) ) { + alt9=1; } - else if ( ((LA10_0>=INCR && LA10_0<=DECR)) ) { - alt10=2; + else if ( ((LA9_0>=INCR && LA9_0<=DECR)) ) { + alt9=2; } else { NoViableAltException nvae = - new NoViableAltException("68:1: unary_expression : ( postfix_expression | ( INCR^^ | DECR^^ ) postfix_expression );", 10, 0, input); + new NoViableAltException("68:1: unary_expression : ( postfix_expression | ( INCR^^ | DECR^^ ) postfix_expression );", 9, 0, input); throw nvae; } - switch (alt10) { + switch (alt9) { case 1 : // grammar/antlr_3/bc.g:69:5: postfix_expression { root_0 = (CommonTree)adaptor.nil(); - pushFollow(FOLLOW_postfix_expression_in_unary_expression283); - postfix_expression21=postfix_expression(); + pushFollow(FOLLOW_postfix_expression_in_unary_expression269); + postfix_expression19=postfix_expression(); _fsp--; - adaptor.addChild(root_0, postfix_expression21.tree); + adaptor.addChild(root_0, postfix_expression19.tree); } break; @@ -863,30 +794,30 @@ else if ( ((LA10_0>=INCR && LA10_0<=DECR)) ) { root_0 = (CommonTree)adaptor.nil(); // grammar/antlr_3/bc.g:71:5: ( INCR^^ | DECR^^ ) - int alt9=2; - int LA9_0 = input.LA(1); - if ( (LA9_0==INCR) ) { - alt9=1; + int alt8=2; + int LA8_0 = input.LA(1); + if ( (LA8_0==INCR) ) { + alt8=1; } - else if ( (LA9_0==DECR) ) { - alt9=2; + else if ( (LA8_0==DECR) ) { + alt8=2; } else { NoViableAltException nvae = - new NoViableAltException("71:5: ( INCR^^ | DECR^^ )", 9, 0, input); + new NoViableAltException("71:5: ( INCR^^ | DECR^^ )", 8, 0, input); throw nvae; } - switch (alt9) { + switch (alt8) { case 1 : // grammar/antlr_3/bc.g:71:7: INCR^^ { CommonTree root_1 = (CommonTree)adaptor.nil(); - INCR22=(Token)input.LT(1); - match(input,INCR,FOLLOW_INCR_in_unary_expression297); - INCR22_tree = (CommonTree)adaptor.create(INCR22); - root_0 = (CommonTree)adaptor.becomeRoot(INCR22_tree, root_0); + INCR20=(Token)input.LT(1); + match(input,INCR,FOLLOW_INCR_in_unary_expression283); + INCR20_tree = (CommonTree)adaptor.create(INCR20); + root_0 = (CommonTree)adaptor.becomeRoot(INCR20_tree, root_0); adaptor.addChild(root_0, root_1); @@ -898,10 +829,10 @@ else if ( (LA9_0==DECR) ) { { CommonTree root_1 = (CommonTree)adaptor.nil(); - DECR23=(Token)input.LT(1); - match(input,DECR,FOLLOW_DECR_in_unary_expression302); - DECR23_tree = (CommonTree)adaptor.create(DECR23); - root_0 = (CommonTree)adaptor.becomeRoot(DECR23_tree, root_0); + DECR21=(Token)input.LT(1); + match(input,DECR,FOLLOW_DECR_in_unary_expression288); + DECR21_tree = (CommonTree)adaptor.create(DECR21); + root_0 = (CommonTree)adaptor.becomeRoot(DECR21_tree, root_0); adaptor.addChild(root_0, root_1); @@ -911,11 +842,11 @@ else if ( (LA9_0==DECR) ) { } - pushFollow(FOLLOW_postfix_expression_in_unary_expression307); - postfix_expression24=postfix_expression(); + pushFollow(FOLLOW_postfix_expression_in_unary_expression293); + postfix_expression22=postfix_expression(); _fsp--; - adaptor.addChild(root_0, postfix_expression24.tree); + adaptor.addChild(root_0, postfix_expression22.tree); } break; @@ -950,44 +881,44 @@ public postfix_expression_return postfix_expression() throws RecognitionExceptio CommonTree root_0 = null; - Token NUMBER25=null; + Token NUMBER23=null; + Token char_literal24=null; Token char_literal26=null; - Token char_literal28=null; - expression_return expression27 = null; + expression_return expression25 = null; List list_expression=new ArrayList(); - List list_21=new ArrayList(); - List list_22=new ArrayList(); - CommonTree NUMBER25_tree=null; + List list_20=new ArrayList(); + List list_19=new ArrayList(); + CommonTree NUMBER23_tree=null; + CommonTree char_literal24_tree=null; CommonTree char_literal26_tree=null; - CommonTree char_literal28_tree=null; try { // grammar/antlr_3/bc.g:75:5: ( NUMBER | '(' expression ')' -> expression ) - int alt11=2; - int LA11_0 = input.LA(1); - if ( (LA11_0==NUMBER) ) { - alt11=1; + int alt10=2; + int LA10_0 = input.LA(1); + if ( (LA10_0==NUMBER) ) { + alt10=1; } - else if ( (LA11_0==21) ) { - alt11=2; + else if ( (LA10_0==19) ) { + alt10=2; } else { NoViableAltException nvae = - new NoViableAltException("74:1: postfix_expression : ( NUMBER | '(' expression ')' -> expression );", 11, 0, input); + new NoViableAltException("74:1: postfix_expression : ( NUMBER | '(' expression ')' -> expression );", 10, 0, input); throw nvae; } - switch (alt11) { + switch (alt10) { case 1 : // grammar/antlr_3/bc.g:75:5: NUMBER { root_0 = (CommonTree)adaptor.nil(); - NUMBER25=(Token)input.LT(1); - match(input,NUMBER,FOLLOW_NUMBER_in_postfix_expression320); - NUMBER25_tree = (CommonTree)adaptor.create(NUMBER25); - adaptor.addChild(root_0, NUMBER25_tree); + NUMBER23=(Token)input.LT(1); + match(input,NUMBER,FOLLOW_NUMBER_in_postfix_expression306); + NUMBER23_tree = (CommonTree)adaptor.create(NUMBER23); + adaptor.addChild(root_0, NUMBER23_tree); } @@ -995,18 +926,18 @@ else if ( (LA11_0==21) ) { case 2 : // grammar/antlr_3/bc.g:77:5: '(' expression ')' { - char_literal26=(Token)input.LT(1); - match(input,21,FOLLOW_21_in_postfix_expression332); - list_21.add(char_literal26); + char_literal24=(Token)input.LT(1); + match(input,19,FOLLOW_19_in_postfix_expression318); + list_19.add(char_literal24); - pushFollow(FOLLOW_expression_in_postfix_expression334); - expression27=expression(); + pushFollow(FOLLOW_expression_in_postfix_expression320); + expression25=expression(); _fsp--; - list_expression.add(expression27.tree); - char_literal28=(Token)input.LT(1); - match(input,22,FOLLOW_22_in_postfix_expression336); - list_22.add(char_literal28); + list_expression.add(expression25.tree); + char_literal26=(Token)input.LT(1); + match(input,20,FOLLOW_20_in_postfix_expression322); + list_20.add(char_literal26); // AST REWRITE @@ -1047,27 +978,27 @@ public static class quit_return extends ParserRuleReturnScope { }; // $ANTLR start quit - // grammar/antlr_3/bc.g:121:1: quit : 'quit' ; + // grammar/antlr_3/bc.g:113:1: quit : 'quit' ; public quit_return quit() throws RecognitionException { quit_return retval = new quit_return(); retval.start = input.LT(1); CommonTree root_0 = null; - Token string_literal29=null; + Token string_literal27=null; - CommonTree string_literal29_tree=null; + CommonTree string_literal27_tree=null; try { - // grammar/antlr_3/bc.g:122:5: ( 'quit' ) - // grammar/antlr_3/bc.g:122:5: 'quit' + // grammar/antlr_3/bc.g:114:5: ( 'quit' ) + // grammar/antlr_3/bc.g:114:5: 'quit' { root_0 = (CommonTree)adaptor.nil(); - string_literal29=(Token)input.LT(1); - match(input,23,FOLLOW_23_in_quit509); - string_literal29_tree = (CommonTree)adaptor.create(string_literal29); - adaptor.addChild(root_0, string_literal29_tree); + string_literal27=(Token)input.LT(1); + match(input,21,FOLLOW_21_in_quit477); + string_literal27_tree = (CommonTree)adaptor.create(string_literal27); + adaptor.addChild(root_0, string_literal27_tree); } @@ -1091,34 +1022,32 @@ public quit_return quit() throws RecognitionException { - public static final BitSet FOLLOW_input_item_in_program71 = new BitSet(new long[]{0x0000000000A0E0C0L}); + public static final BitSet FOLLOW_input_item_in_program71 = new BitSet(new long[]{0x00000000002838C0L}); public static final BitSet FOLLOW_quit_in_program74 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_semicolon_list_in_input_item99 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_statement_in_semicolon_list113 = new BitSet(new long[]{0x0000000000100002L}); - public static final BitSet FOLLOW_20_in_semicolon_list117 = new BitSet(new long[]{0x000000000020E0C0L}); - public static final BitSet FOLLOW_statement_in_semicolon_list120 = new BitSet(new long[]{0x0000000000100002L}); + public static final BitSet FOLLOW_statement_in_semicolon_list113 = new BitSet(new long[]{0x0000000000040002L}); + public static final BitSet FOLLOW_18_in_semicolon_list117 = new BitSet(new long[]{0x00000000000838C0L}); + public static final BitSet FOLLOW_statement_in_semicolon_list120 = new BitSet(new long[]{0x0000000000040002L}); public static final BitSet FOLLOW_expression_in_statement137 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_STRING_in_statement149 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_named_expression_in_expression162 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_adding_expression_in_expression174 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_LETTER_in_named_expression187 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_multiplying_expression_in_adding_expression212 = new BitSet(new long[]{0x0000000000000302L}); - public static final BitSet FOLLOW_PLUS_in_adding_expression218 = new BitSet(new long[]{0x000000000020E000L}); - public static final BitSet FOLLOW_MINUS_in_adding_expression223 = new BitSet(new long[]{0x000000000020E000L}); + public static final BitSet FOLLOW_PLUS_in_adding_expression218 = new BitSet(new long[]{0x0000000000083800L}); + public static final BitSet FOLLOW_MINUS_in_adding_expression223 = new BitSet(new long[]{0x0000000000083800L}); public static final BitSet FOLLOW_multiplying_expression_in_adding_expression228 = new BitSet(new long[]{0x0000000000000302L}); - public static final BitSet FOLLOW_unary_expression_in_multiplying_expression245 = new BitSet(new long[]{0x0000000000001C02L}); - public static final BitSet FOLLOW_MUL_in_multiplying_expression251 = new BitSet(new long[]{0x000000000020E000L}); - public static final BitSet FOLLOW_DIV_in_multiplying_expression256 = new BitSet(new long[]{0x000000000020E000L}); - public static final BitSet FOLLOW_MOD_in_multiplying_expression261 = new BitSet(new long[]{0x000000000020E000L}); - public static final BitSet FOLLOW_unary_expression_in_multiplying_expression266 = new BitSet(new long[]{0x0000000000001C02L}); - public static final BitSet FOLLOW_postfix_expression_in_unary_expression283 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_INCR_in_unary_expression297 = new BitSet(new long[]{0x0000000000208000L}); - public static final BitSet FOLLOW_DECR_in_unary_expression302 = new BitSet(new long[]{0x0000000000208000L}); - public static final BitSet FOLLOW_postfix_expression_in_unary_expression307 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_NUMBER_in_postfix_expression320 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_21_in_postfix_expression332 = new BitSet(new long[]{0x000000000020E080L}); - public static final BitSet FOLLOW_expression_in_postfix_expression334 = new BitSet(new long[]{0x0000000000400000L}); - public static final BitSet FOLLOW_22_in_postfix_expression336 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_23_in_quit509 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_unary_expression_in_multiplying_expression245 = new BitSet(new long[]{0x0000000000000402L}); + public static final BitSet FOLLOW_MUL_OP_in_multiplying_expression249 = new BitSet(new long[]{0x0000000000083800L}); + public static final BitSet FOLLOW_unary_expression_in_multiplying_expression252 = new BitSet(new long[]{0x0000000000000402L}); + public static final BitSet FOLLOW_postfix_expression_in_unary_expression269 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_INCR_in_unary_expression283 = new BitSet(new long[]{0x0000000000082000L}); + public static final BitSet FOLLOW_DECR_in_unary_expression288 = new BitSet(new long[]{0x0000000000082000L}); + public static final BitSet FOLLOW_postfix_expression_in_unary_expression293 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_NUMBER_in_postfix_expression306 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_19_in_postfix_expression318 = new BitSet(new long[]{0x0000000000083880L}); + public static final BitSet FOLLOW_expression_in_postfix_expression320 = new BitSet(new long[]{0x0000000000100000L}); + public static final BitSet FOLLOW_20_in_postfix_expression322 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_21_in_quit477 = new BitSet(new long[]{0x0000000000000002L}); } \ No newline at end of file diff --git a/languages/bc/grammar/antlr_3/BcParserLexer.java b/languages/bc/grammar/antlr_3/BcParserLexer.java index 0a9a7261ae..c4bc785d39 100644 --- a/languages/bc/grammar/antlr_3/BcParserLexer.java +++ b/languages/bc/grammar/antlr_3/BcParserLexer.java @@ -1,4 +1,4 @@ -// $ANTLR 3.0b3 grammar/antlr_3/bc.g 2006-08-08 23:54:41 +// $ANTLR 3.0b3 grammar/antlr_3/bc.g 2006-08-09 00:03:11 import org.antlr.runtime.*; import java.util.Stack; @@ -7,38 +7,36 @@ public class BcParserLexer extends Lexer { public static final int T21=21; - public static final int MINUS=9; public static final int LETTER=7; - public static final int INCR=13; - public static final int T22=22; - public static final int DECR=14; - public static final int NUMBER=15; - public static final int WS=18; + public static final int MINUS=9; + public static final int INCR=11; + public static final int WS=16; + public static final int NUMBER=13; + public static final int DECR=12; public static final int STRING=6; - public static final int T23=23; - public static final int MOD=12; + public static final int MUL_OP=10; public static final int T20=20; public static final int PROGRAM=4; - public static final int NEWLINE=19; + public static final int NEWLINE=17; public static final int VAR=5; - public static final int MUL=10; - public static final int INTEGER=16; + public static final int INTEGER=14; + public static final int T18=18; public static final int EOF=-1; - public static final int Tokens=24; - public static final int DIV=11; + public static final int Tokens=22; + public static final int ML_COMMENT=15; public static final int PLUS=8; - public static final int ML_COMMENT=17; + public static final int T19=19; public BcParserLexer() {;} public BcParserLexer(CharStream input) { super(input); } public String getGrammarFileName() { return "grammar/antlr_3/bc.g"; } - // $ANTLR start T20 - public void mT20() throws RecognitionException { + // $ANTLR start T18 + public void mT18() throws RecognitionException { try { ruleNestingLevel++; - int type = T20; + int type = T18; int start = getCharIndex(); int line = getLine(); int charPosition = getCharPositionInLine(); @@ -61,13 +59,13 @@ public void mT20() throws RecognitionException { ruleNestingLevel--; } } - // $ANTLR end T20 + // $ANTLR end T18 - // $ANTLR start T21 - public void mT21() throws RecognitionException { + // $ANTLR start T19 + public void mT19() throws RecognitionException { try { ruleNestingLevel++; - int type = T21; + int type = T19; int start = getCharIndex(); int line = getLine(); int charPosition = getCharPositionInLine(); @@ -90,13 +88,13 @@ public void mT21() throws RecognitionException { ruleNestingLevel--; } } - // $ANTLR end T21 + // $ANTLR end T19 - // $ANTLR start T22 - public void mT22() throws RecognitionException { + // $ANTLR start T20 + public void mT20() throws RecognitionException { try { ruleNestingLevel++; - int type = T22; + int type = T20; int start = getCharIndex(); int line = getLine(); int charPosition = getCharPositionInLine(); @@ -119,13 +117,13 @@ public void mT22() throws RecognitionException { ruleNestingLevel--; } } - // $ANTLR end T22 + // $ANTLR end T20 - // $ANTLR start T23 - public void mT23() throws RecognitionException { + // $ANTLR start T21 + public void mT21() throws RecognitionException { try { ruleNestingLevel++; - int type = T23; + int type = T21; int start = getCharIndex(); int line = getLine(); int charPosition = getCharPositionInLine(); @@ -149,7 +147,7 @@ public void mT23() throws RecognitionException { ruleNestingLevel--; } } - // $ANTLR end T23 + // $ANTLR end T21 // $ANTLR start NUMBER public void mNUMBER() throws RecognitionException { @@ -337,49 +335,29 @@ public void mPLUS() throws RecognitionException { } // $ANTLR end PLUS - // $ANTLR start MUL - public void mMUL() throws RecognitionException { + // $ANTLR start MUL_OP + public void mMUL_OP() throws RecognitionException { try { ruleNestingLevel++; - int type = MUL; + int type = MUL_OP; int start = getCharIndex(); int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:101:5: ( '*' ) - // grammar/antlr_3/bc.g:101:5: '*' + // grammar/antlr_3/bc.g:101:3: ( ('*'|'/'|'%')) + // grammar/antlr_3/bc.g:101:5: ('*'|'/'|'%') { - match('*'); + if ( input.LA(1)=='%'||input.LA(1)=='*'||input.LA(1)=='/' ) { + input.consume(); } + else { + MismatchedSetException mse = + new MismatchedSetException(null,input); + recover(mse); throw mse; + } - - if ( token==null && ruleNestingLevel==1 ) { - emit(type,line,charPosition,channel,start,getCharIndex()-1); - } - - } - finally { - ruleNestingLevel--; - } - } - // $ANTLR end MUL - - // $ANTLR start DIV - public void mDIV() throws RecognitionException { - try { - ruleNestingLevel++; - int type = DIV; - int start = getCharIndex(); - int line = getLine(); - int charPosition = getCharPositionInLine(); - int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:105:5: ( '/' ) - // grammar/antlr_3/bc.g:105:5: '/' - { - match('/'); - } @@ -393,7 +371,7 @@ public void mDIV() throws RecognitionException { ruleNestingLevel--; } } - // $ANTLR end DIV + // $ANTLR end MUL_OP // $ANTLR start INCR public void mINCR() throws RecognitionException { @@ -404,8 +382,8 @@ public void mINCR() throws RecognitionException { int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:109:5: ( '++' ) - // grammar/antlr_3/bc.g:109:5: '++' + // grammar/antlr_3/bc.g:105:5: ( '++' ) + // grammar/antlr_3/bc.g:105:5: '++' { match("++"); @@ -434,8 +412,8 @@ public void mDECR() throws RecognitionException { int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:113:5: ( '--' ) - // grammar/antlr_3/bc.g:113:5: '--' + // grammar/antlr_3/bc.g:109:5: ( '--' ) + // grammar/antlr_3/bc.g:109:5: '--' { match("--"); @@ -455,35 +433,6 @@ public void mDECR() throws RecognitionException { } // $ANTLR end DECR - // $ANTLR start MOD - public void mMOD() throws RecognitionException { - try { - ruleNestingLevel++; - int type = MOD; - int start = getCharIndex(); - int line = getLine(); - int charPosition = getCharPositionInLine(); - int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:117:5: ( '%' ) - // grammar/antlr_3/bc.g:117:5: '%' - { - match('%'); - - } - - - - if ( token==null && ruleNestingLevel==1 ) { - emit(type,line,charPosition,channel,start,getCharIndex()-1); - } - - } - finally { - ruleNestingLevel--; - } - } - // $ANTLR end MOD - // $ANTLR start ML_COMMENT public void mML_COMMENT() throws RecognitionException { try { @@ -493,12 +442,12 @@ public void mML_COMMENT() throws RecognitionException { int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:128:5: ( '/*' ( options {greedy=false; } : . )* '*/' ) - // grammar/antlr_3/bc.g:128:5: '/*' ( options {greedy=false; } : . )* '*/' + // grammar/antlr_3/bc.g:120:5: ( '/*' ( options {greedy=false; } : . )* '*/' ) + // grammar/antlr_3/bc.g:120:5: '/*' ( options {greedy=false; } : . )* '*/' { match("/*"); - // grammar/antlr_3/bc.g:128:10: ( options {greedy=false; } : . )* + // grammar/antlr_3/bc.g:120:10: ( options {greedy=false; } : . )* loop4: do { int alt4=2; @@ -521,7 +470,7 @@ else if ( ((LA4_0>='\u0000' && LA4_0<=')')||(LA4_0>='+' && LA4_0<='\uFFFE')) ) { switch (alt4) { case 1 : - // grammar/antlr_3/bc.g:128:38: . + // grammar/antlr_3/bc.g:120:38: . { matchAny(); @@ -563,10 +512,10 @@ public void mWS() throws RecognitionException { int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:136:5: ( ( (' '|'\\t'|'\\r'|'\\n'))+ ) - // grammar/antlr_3/bc.g:136:5: ( (' '|'\\t'|'\\r'|'\\n'))+ + // grammar/antlr_3/bc.g:128:5: ( ( (' '|'\\t'|'\\r'|'\\n'))+ ) + // grammar/antlr_3/bc.g:128:5: ( (' '|'\\t'|'\\r'|'\\n'))+ { - // grammar/antlr_3/bc.g:136:5: ( (' '|'\\t'|'\\r'|'\\n'))+ + // grammar/antlr_3/bc.g:128:5: ( (' '|'\\t'|'\\r'|'\\n'))+ int cnt5=0; loop5: do { @@ -579,7 +528,7 @@ public void mWS() throws RecognitionException { switch (alt5) { case 1 : - // grammar/antlr_3/bc.g:136:7: (' '|'\\t'|'\\r'|'\\n') + // grammar/antlr_3/bc.g:128:7: (' '|'\\t'|'\\r'|'\\n') { if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { input.consume(); @@ -627,10 +576,10 @@ public void mWS() throws RecognitionException { public void mNEWLINE() throws RecognitionException { try { ruleNestingLevel++; - // grammar/antlr_3/bc.g:145:5: ( ( '\\r' )? ( '\\n' )+ ) - // grammar/antlr_3/bc.g:145:5: ( '\\r' )? ( '\\n' )+ + // grammar/antlr_3/bc.g:137:5: ( ( '\\r' )? ( '\\n' )+ ) + // grammar/antlr_3/bc.g:137:5: ( '\\r' )? ( '\\n' )+ { - // grammar/antlr_3/bc.g:145:5: ( '\\r' )? + // grammar/antlr_3/bc.g:137:5: ( '\\r' )? int alt6=2; int LA6_0 = input.LA(1); if ( (LA6_0=='\r') ) { @@ -638,7 +587,7 @@ public void mNEWLINE() throws RecognitionException { } switch (alt6) { case 1 : - // grammar/antlr_3/bc.g:145:6: '\\r' + // grammar/antlr_3/bc.g:137:6: '\\r' { match('\r'); @@ -647,7 +596,7 @@ public void mNEWLINE() throws RecognitionException { } - // grammar/antlr_3/bc.g:145:13: ( '\\n' )+ + // grammar/antlr_3/bc.g:137:13: ( '\\n' )+ int cnt7=0; loop7: do { @@ -660,7 +609,7 @@ public void mNEWLINE() throws RecognitionException { switch (alt7) { case 1 : - // grammar/antlr_3/bc.g:145:13: '\\n' + // grammar/antlr_3/bc.g:137:13: '\\n' { match('\n'); @@ -695,11 +644,11 @@ public void mSTRING() throws RecognitionException { int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:151:5: ( '\\\"' (~ '\\\"' )* '\\\"' ) - // grammar/antlr_3/bc.g:151:5: '\\\"' (~ '\\\"' )* '\\\"' + // grammar/antlr_3/bc.g:143:5: ( '\\\"' (~ '\\\"' )* '\\\"' ) + // grammar/antlr_3/bc.g:143:5: '\\\"' (~ '\\\"' )* '\\\"' { match('\"'); - // grammar/antlr_3/bc.g:151:10: (~ '\\\"' )* + // grammar/antlr_3/bc.g:143:10: (~ '\\\"' )* loop8: do { int alt8=2; @@ -711,7 +660,7 @@ public void mSTRING() throws RecognitionException { switch (alt8) { case 1 : - // grammar/antlr_3/bc.g:151:12: ~ '\\\"' + // grammar/antlr_3/bc.g:143:12: ~ '\\\"' { if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='\uFFFE') ) { input.consume(); @@ -758,8 +707,8 @@ public void mLETTER() throws RecognitionException { int line = getLine(); int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; - // grammar/antlr_3/bc.g:155:5: ( 'a' .. 'z' ) - // grammar/antlr_3/bc.g:155:5: 'a' .. 'z' + // grammar/antlr_3/bc.g:147:5: ( 'a' .. 'z' ) + // grammar/antlr_3/bc.g:147:5: 'a' .. 'z' { matchRange('a','z'); @@ -779,8 +728,8 @@ public void mLETTER() throws RecognitionException { // $ANTLR end LETTER public void mTokens() throws RecognitionException { - // grammar/antlr_3/bc.g:1:10: ( T20 | T21 | T22 | T23 | NUMBER | MINUS | PLUS | MUL | DIV | INCR | DECR | MOD | ML_COMMENT | WS | STRING | LETTER ) - int alt9=16; + // grammar/antlr_3/bc.g:1:10: ( T18 | T19 | T20 | T21 | NUMBER | MINUS | PLUS | MUL_OP | INCR | DECR | ML_COMMENT | WS | STRING | LETTER ) + int alt9=14; switch ( input.LA(1) ) { case ';': alt9=1; @@ -797,7 +746,7 @@ public void mTokens() throws RecognitionException { alt9=4; } else { - alt9=16;} + alt9=14;} break; case '.': case '0': @@ -821,7 +770,7 @@ public void mTokens() throws RecognitionException { case '-': int LA9_6 = input.LA(2); if ( (LA9_6=='-') ) { - alt9=11; + alt9=10; } else { alt9=6;} @@ -829,33 +778,31 @@ public void mTokens() throws RecognitionException { case '+': int LA9_7 = input.LA(2); if ( (LA9_7=='+') ) { - alt9=10; + alt9=9; } else { alt9=7;} break; - case '*': - alt9=8; - break; case '/': - int LA9_9 = input.LA(2); - if ( (LA9_9=='*') ) { - alt9=13; + int LA9_8 = input.LA(2); + if ( (LA9_8=='*') ) { + alt9=11; } else { - alt9=9;} + alt9=8;} break; case '%': - alt9=12; + case '*': + alt9=8; break; case '\t': case '\n': case '\r': case ' ': - alt9=14; + alt9=12; break; case '\"': - alt9=15; + alt9=13; break; case 'a': case 'b': @@ -882,41 +829,41 @@ public void mTokens() throws RecognitionException { case 'x': case 'y': case 'z': - alt9=16; + alt9=14; break; default: NoViableAltException nvae = - new NoViableAltException("1:1: Tokens : ( T20 | T21 | T22 | T23 | NUMBER | MINUS | PLUS | MUL | DIV | INCR | DECR | MOD | ML_COMMENT | WS | STRING | LETTER );", 9, 0, input); + new NoViableAltException("1:1: Tokens : ( T18 | T19 | T20 | T21 | NUMBER | MINUS | PLUS | MUL_OP | INCR | DECR | ML_COMMENT | WS | STRING | LETTER );", 9, 0, input); throw nvae; } switch (alt9) { case 1 : - // grammar/antlr_3/bc.g:1:10: T20 + // grammar/antlr_3/bc.g:1:10: T18 { - mT20(); + mT18(); } break; case 2 : - // grammar/antlr_3/bc.g:1:14: T21 + // grammar/antlr_3/bc.g:1:14: T19 { - mT21(); + mT19(); } break; case 3 : - // grammar/antlr_3/bc.g:1:18: T22 + // grammar/antlr_3/bc.g:1:18: T20 { - mT22(); + mT20(); } break; case 4 : - // grammar/antlr_3/bc.g:1:22: T23 + // grammar/antlr_3/bc.g:1:22: T21 { - mT23(); + mT21(); } break; @@ -942,63 +889,49 @@ public void mTokens() throws RecognitionException { } break; case 8 : - // grammar/antlr_3/bc.g:1:44: MUL + // grammar/antlr_3/bc.g:1:44: MUL_OP { - mMUL(); + mMUL_OP(); } break; case 9 : - // grammar/antlr_3/bc.g:1:48: DIV - { - mDIV(); - - } - break; - case 10 : - // grammar/antlr_3/bc.g:1:52: INCR + // grammar/antlr_3/bc.g:1:51: INCR { mINCR(); } break; - case 11 : - // grammar/antlr_3/bc.g:1:57: DECR + case 10 : + // grammar/antlr_3/bc.g:1:56: DECR { mDECR(); } break; - case 12 : - // grammar/antlr_3/bc.g:1:62: MOD - { - mMOD(); - - } - break; - case 13 : - // grammar/antlr_3/bc.g:1:66: ML_COMMENT + case 11 : + // grammar/antlr_3/bc.g:1:61: ML_COMMENT { mML_COMMENT(); } break; - case 14 : - // grammar/antlr_3/bc.g:1:77: WS + case 12 : + // grammar/antlr_3/bc.g:1:72: WS { mWS(); } break; - case 15 : - // grammar/antlr_3/bc.g:1:80: STRING + case 13 : + // grammar/antlr_3/bc.g:1:75: STRING { mSTRING(); } break; - case 16 : - // grammar/antlr_3/bc.g:1:87: LETTER + case 14 : + // grammar/antlr_3/bc.g:1:82: LETTER { mLETTER(); diff --git a/languages/bc/grammar/antlr_3/antlr_past2pir_past.g b/languages/bc/grammar/antlr_3/antlr_past2pir_past.g index 6a3755dcf4..4d9c15597a 100644 --- a/languages/bc/grammar/antlr_3/antlr_past2pir_past.g +++ b/languages/bc/grammar/antlr_3/antlr_past2pir_past.g @@ -236,7 +236,7 @@ adding_expression[String reg_mother] + " " + reg + " = new 'PAST::Op' \n" ); } - ^( infix=( PLUS | MINUS | MUL | DIV | MOD ) adding_expression[reg] adding_expression[reg] ) + ^( infix=( PLUS | MINUS | MUL_OP ) adding_expression[reg] adding_expression[reg] ) { System.out.print( " " + reg + ".'op'( 'infix:" + $infix.text + "' ) \n" diff --git a/languages/bc/grammar/antlr_3/bc.g b/languages/bc/grammar/antlr_3/bc.g index 2d6a488be8..284e18088b 100644 --- a/languages/bc/grammar/antlr_3/bc.g +++ b/languages/bc/grammar/antlr_3/bc.g @@ -61,7 +61,7 @@ adding_expression multiplying_expression - : unary_expression ( ( MUL^^ | DIV^^ | MOD^^ ) unary_expression )* + : unary_expression ( MUL_OP^^ unary_expression )* ; @@ -96,12 +96,8 @@ PLUS : '+' ; -MUL - : '*' - ; - -DIV - : '/' +MUL_OP + : '*' | '/' | '%' ; INCR @@ -112,10 +108,6 @@ DECR : '--' ; -MOD - : '%' - ; - // quit is required, make testing easier // quit is required, make testing easier quit