Author: bernhard
Date: Thu Feb 23 12:57:49 2006
New Revision: 11718
Modified:
trunk/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java
trunk/languages/bc/grammar/antlr_3/BcParser.java
trunk/languages/bc/grammar/antlr_3/BcParserLexer.java
trunk/languages/bc/grammar/antlr_3/antlr_past2pir_past.g
trunk/languages/bc/grammar/antlr_3/bc.g
trunk/languages/bc/t/basic.t
Log:
Parrot bc with ANTRL3:
- Make it work for several ints on seperate lines
- Ignore comments.
Modified: trunk/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java
==============================================================================
--- trunk/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java (original)
+++ trunk/languages/bc/grammar/antlr_3/AntlrPast2PirPast.java Thu Feb 23
12:57:49 2006
@@ -1,4 +1,4 @@
-// $ANTLR 3.0ea7 grammar/antlr_3/antlr_past2pir_past.g 2006-02-22 22:44:03
+// $ANTLR 3.0ea7 grammar/antlr_3/antlr_past2pir_past.g 2006-02-23 21:51:43
import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
@@ -7,10 +7,11 @@ import java.util.ArrayList;
public class AntlrPast2PirPast extends TreeParser {
public static final String[] tokenNames = new String[] {
- "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "INT", "WS"
+ "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "INT",
"ML_COMMENT", "WS"
};
public static final int INT=5;
- public static final int WS=6;
+ public static final int WS=7;
+ public static final int ML_COMMENT=6;
public static final int PROGRAM=4;
public AntlrPast2PirPast(TreeNodeStream input) {
super(input);
@@ -28,8 +29,6 @@ public class AntlrPast2PirPast extends T
- String expr1 = null;
-
try {
// grammar/antlr_3/antlr_past2pir_past.g:22:3: ( ^( PROGRAM ( expr
)+ ) )
@@ -77,7 +76,7 @@ public class AntlrPast2PirPast extends T
{
following.push(FOLLOW_expr_in_gen_pir_past64);
- expr1=expr();
+ expr();
following.pop();
@@ -99,44 +98,6 @@ public class AntlrPast2PirPast extends T
String pirAfter = ""
+ "# entering gen_pir_past" + "\n"
- + " $P20 = new 'PAST::Exp' " + "\n"
- + " $P21 = new PerlArray " + "\n"
- + " push $P21, " + expr1 + " \n"
- + " $P20.set_node('1', 1, $P21) " + "\n"
- + " $P30 = new 'PAST::Op' " + "\n"
- + " $P31 = new PerlArray " + "\n"
- + " push $P31, $P20 " + "\n"
- + " $P30.set_node('1', 1, 'print' ,$P31) " + "\n"
- + " $P40 = new 'PAST::Exp' " + "\n"
- + " $P41 = new PerlArray " + "\n"
- + " push $P41, $P30 " + "\n"
- + " $P40.set_node('1', 1, $P41) " + "\n"
- + " $P50 = new 'PAST::Stmt' " + "\n"
- + " $P51 = new PerlArray " + "\n"
- + " push $P51, $P40 " + "\n"
- + " $P50.set_node('1', 1 ,$P51) " + "\n"
- + " push stmts_children, $P50 " + "\n"
- + " $P60 = new 'PAST::Val' " + "\n"
- + " $P60.set_node( '1', 0, '\\n' ) " + "\n"
- + " $P60.valtype( 'strqq' ) " + "\n"
- + " $P70 = new 'PAST::Exp' " + "\n"
- + " $P71 = new PerlArray " + "\n"
- + " push $P71, $P60 " + "\n"
- + " $P70.set_node('1', 1, $P71) " + "\n"
- + " $P80 = new 'PAST::Op' " + "\n"
- + " $P81 = new PerlArray " + "\n"
- + " push $P81, $P70 " + "\n"
- + " $P80.set_node('1', 1, 'print' ,$P81) " + "\n"
- + " $P90 = new 'PAST::Exp' " + "\n"
- + " $P91 = new PerlArray " + "\n"
- + " push $P91, $P80 " + "\n"
- + " $P90.set_node('1', 1, $P91) " + "\n"
- + " $P100 = new 'PAST::Stmt' " + "\n"
- + " $P101 = new PerlArray " + "\n"
- + " push $P101, $P90 " + "\n"
- + " $P100.set_node('1', 1 ,$P101) " + "\n"
- + " push stmts_children, $P100 " + "\n"
- + "\n"
+ " .local pmc stmts" + "\n"
+ " stmts = new 'PAST::Stmts'" + "\n"
+ " stmts.set_node('1', 1, stmts_children)" + "\n"
@@ -236,7 +197,7 @@ public class AntlrPast2PirPast extends T
};
// $ANTLR start expr_int_1
- // grammar/antlr_3/antlr_past2pir_past.g:162:1: expr_int_1 : INT ;
+ // grammar/antlr_3/antlr_past2pir_past.g:124:1: expr_int_1 : INT ;
public expr_int_1_return expr_int_1() throws RecognitionException {
expr_int_1_return retval = new expr_int_1_return();
@@ -245,8 +206,8 @@ public class AntlrPast2PirPast extends T
try {
- // grammar/antlr_3/antlr_past2pir_past.g:163:5: ( INT )
- // grammar/antlr_3/antlr_past2pir_past.g:163:5: INT
+ // grammar/antlr_3/antlr_past2pir_past.g:125:5: ( INT )
+ // grammar/antlr_3/antlr_past2pir_past.g:125:5: INT
{
match(input,INT,FOLLOW_INT_in_expr_int_186);
@@ -271,24 +232,24 @@ public class AntlrPast2PirPast extends T
// $ANTLR start expr
- // grammar/antlr_3/antlr_past2pir_past.g:167:1: expr returns [String reg]
: expr_int_1 ;
+ // grammar/antlr_3/antlr_past2pir_past.g:129:1: expr returns [String reg]
: expr_int_1 ;
public String expr() throws RecognitionException {
String reg;
- expr_int_1_return expr_int_12 = null;
+ expr_int_1_return expr_int_11 = null;
reg = "reg_expr";
try {
- // grammar/antlr_3/antlr_past2pir_past.g:172:5: ( expr_int_1 )
- // grammar/antlr_3/antlr_past2pir_past.g:172:5: expr_int_1
+ // grammar/antlr_3/antlr_past2pir_past.g:134:5: ( expr_int_1 )
+ // grammar/antlr_3/antlr_past2pir_past.g:134:5: expr_int_1
{
following.push(FOLLOW_expr_int_1_in_expr113);
- expr_int_12=expr_int_1();
+ expr_int_11=expr_int_1();
following.pop();
@@ -297,9 +258,47 @@ public class AntlrPast2PirPast extends T
+ "# entering expr" + "\n"
+ ".local pmc " + reg + "\n"
+ reg + " = new 'PAST::Val'" + "\n"
- + reg + ".set_node( '1', 0, " +
input.toString(expr_int_12.start,expr_int_12.stop) + " )" + "\n"
+ + reg + ".set_node( '1', 0, " +
input.toString(expr_int_11.start,expr_int_11.stop) + " )" + "\n"
+ reg + ".valtype( 'num' )" + "\n"
+ "# leaving expr" + "\n"
+ + " $P20 = new 'PAST::Exp' " + "\n"
+ + " $P21 = new PerlArray " + "\n"
+ + " push $P21, " + reg + " \n"
+ + " $P20.set_node('1', 1, $P21) " + "\n"
+ + " $P30 = new 'PAST::Op' " + "\n"
+ + " $P31 = new PerlArray " + "\n"
+ + " push $P31, $P20 " + "\n"
+ + " $P30.set_node('1', 1, 'print' ,$P31) " + "\n"
+ + " $P40 = new 'PAST::Exp' " + "\n"
+ + " $P41 = new PerlArray " + "\n"
+ + " push $P41, $P30 " + "\n"
+ + " $P40.set_node('1', 1, $P41) " + "\n"
+ + " $P50 = new 'PAST::Stmt' " + "\n"
+ + " $P51 = new PerlArray " + "\n"
+ + " push $P51, $P40 " + "\n"
+ + " $P50.set_node('1', 1 ,$P51) " + "\n"
+ + " push stmts_children, $P50 " + "\n"
+ + " $P60 = new 'PAST::Val' " + "\n"
+ + " $P60.set_node( '1', 0, '\\n' ) " + "\n"
+ + " $P60.valtype( 'strqq' ) " + "\n"
+ + " $P70 = new 'PAST::Exp' " + "\n"
+ + " $P71 = new PerlArray " + "\n"
+ + " push $P71, $P60 " + "\n"
+ + " $P70.set_node('1', 1, $P71) " + "\n"
+ + " $P80 = new 'PAST::Op' " + "\n"
+ + " $P81 = new PerlArray " + "\n"
+ + " push $P81, $P70 " + "\n"
+ + " $P80.set_node('1', 1, 'print' ,$P81) " + "\n"
+ + " $P90 = new 'PAST::Exp' " + "\n"
+ + " $P91 = new PerlArray " + "\n"
+ + " push $P91, $P80 " + "\n"
+ + " $P90.set_node('1', 1, $P91) " + "\n"
+ + " $P100 = new 'PAST::Stmt' " + "\n"
+ + " $P101 = new PerlArray " + "\n"
+ + " push $P101, $P90 " + "\n"
+ + " $P100.set_node('1', 1 ,$P101) " + "\n"
+ + " push stmts_children, $P100 " + "\n"
+ + "\n"
;
System.out.println( pir );
Modified: trunk/languages/bc/grammar/antlr_3/BcParser.java
==============================================================================
--- trunk/languages/bc/grammar/antlr_3/BcParser.java (original)
+++ trunk/languages/bc/grammar/antlr_3/BcParser.java Thu Feb 23 12:57:49 2006
@@ -1,4 +1,4 @@
-// $ANTLR 3.0ea7 grammar/antlr_3/bc.g 2006-02-22 22:44:02
+// $ANTLR 3.0ea7 grammar/antlr_3/bc.g 2006-02-23 21:51:42
import org.antlr.runtime.*;
import java.util.Stack;
@@ -10,10 +10,11 @@ import org.antlr.runtime.tree.*;
public class BcParser extends Parser {
public static final String[] tokenNames = new String[] {
- "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "INT", "WS",
"\'quit\'"
+ "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "INT",
"ML_COMMENT", "WS", "\'quit\'"
};
public static final int INT=5;
- public static final int WS=6;
+ public static final int WS=7;
+ public static final int ML_COMMENT=6;
public static final int PROGRAM=4;
public BcParser(TokenStream input) {
super(input);
@@ -223,7 +224,7 @@ public class BcParser extends Parser {
string_literal4=(Token)input.LT(1);
- match(input,7,FOLLOW_7_in_quit118);
+ match(input,8,FOLLOW_8_in_quit118);
string_literal4_tree = (CommonTree)adaptor.create(string_literal4);
adaptor.addChild(root_0, string_literal4_tree);
@@ -249,9 +250,9 @@ public class BcParser extends Parser {
- public static final BitSet FOLLOW_input_item_in_program61 = new BitSet(new
long[]{128L});
+ public static final BitSet FOLLOW_input_item_in_program61 = new BitSet(new
long[]{256L});
public static final BitSet FOLLOW_quit_in_program63 = new BitSet(new
long[]{2L});
public static final BitSet FOLLOW_INT_in_input_item86 = new BitSet(new
long[]{34L});
- public static final BitSet FOLLOW_7_in_quit118 = new BitSet(new
long[]{2L});
+ public static final BitSet FOLLOW_8_in_quit118 = new BitSet(new
long[]{2L});
}
\ No newline at end of file
Modified: trunk/languages/bc/grammar/antlr_3/BcParserLexer.java
==============================================================================
--- trunk/languages/bc/grammar/antlr_3/BcParserLexer.java (original)
+++ trunk/languages/bc/grammar/antlr_3/BcParserLexer.java Thu Feb 23
12:57:49 2006
@@ -1,4 +1,4 @@
-// $ANTLR 3.0ea7 grammar/antlr_3/BcParser.lexer.g 2006-02-22 22:44:02
+// $ANTLR 3.0ea7 grammar/antlr_3/BcParser.lexer.g 2006-02-23 21:51:42
import org.antlr.runtime.*;
import java.util.Stack;
@@ -7,9 +7,10 @@ import java.util.ArrayList;
public class BcParserLexer extends Lexer {
public static final int INT=5;
- public static final int WS=6;
+ public static final int WS=7;
+ public static final int ML_COMMENT=6;
+ public static final int T8=8;
public static final int PROGRAM=4;
- public static final int T7=7;
public BcParserLexer(CharStream input) {
super(input);
}
@@ -32,8 +33,8 @@ retry:
return token;
}
- public void mT7() throws RecognitionException {
- int type = T7;
+ public void mT8() throws RecognitionException {
+ int type = T8;
int start = getCharIndex();
int line = getLine();
int charPosition = getCharPositionInLine();
@@ -96,30 +97,92 @@ retry:
if ( token==null )
{emit(type,line,charPosition,channel,start,getCharIndex()-1);}
}
- public void mWS() throws RecognitionException {
- int type = WS;
+ public void mML_COMMENT() throws RecognitionException {
+ int type = ML_COMMENT;
int start = getCharIndex();
int line = getLine();
int charPosition = getCharPositionInLine();
int channel = Token.DEFAULT_CHANNEL;
- // grammar/antlr_3/BcParser.lexer.g:7:6: ( ( (' '|'\t'|'\r'|'\n'))+ )
- // grammar/antlr_3/BcParser.lexer.g:7:6: ( (' '|'\t'|'\r'|'\n'))+
+ // grammar/antlr_3/BcParser.lexer.g:7:14: ( '/*' ( options
{greedy=false; } : . )* '*/' )
+ // grammar/antlr_3/BcParser.lexer.g:7:14: '/*' ( options
{greedy=false; } : . )* '*/'
{
- // grammar/antlr_3/BcParser.lexer.g:7:6: ( (' '|'\t'|'\r'|'\n'))+
- int cnt2=0;
+ match("/*");
+
+
+ // grammar/antlr_3/BcParser.lexer.g:7:19: ( options {greedy=false; } :
. )*
loop2:
do {
int alt2=2;
int LA2_0 = input.LA(1);
- if ( (LA2_0>='\t' && LA2_0<='\n')||LA2_0=='\r'||LA2_0==' ' ) {
+ if ( LA2_0=='*' ) {
+ int LA2_1 = input.LA(2);
+ if ( LA2_1=='/' ) {
+ alt2=2;
+ }
+ else if ( (LA2_1>='\u0000' && LA2_1<='.')||(LA2_1>='0' &&
LA2_1<='\uFFFE') ) {
+ alt2=1;
+ }
+
+
+ }
+ else if ( (LA2_0>='\u0000' && LA2_0<=')')||(LA2_0>='+' &&
LA2_0<='\uFFFE') ) {
alt2=1;
}
switch (alt2) {
case 1 :
- // grammar/antlr_3/BcParser.lexer.g:7:8: ('
'|'\t'|'\r'|'\n')
+ // grammar/antlr_3/BcParser.lexer.g:7:48: .
+ {
+
+ matchAny();
+
+ }
+ break;
+
+ default :
+ break loop2;
+ }
+ } while (true);
+
+
+ match("*/");
+
+
+
+ channel = 99; // send into nirwana
+
+
+ }
+
+ if ( token==null )
{emit(type,line,charPosition,channel,start,getCharIndex()-1);}
+ }
+
+ public void mWS() throws RecognitionException {
+ int type = WS;
+ int start = getCharIndex();
+ int line = getLine();
+ int charPosition = getCharPositionInLine();
+ int channel = Token.DEFAULT_CHANNEL;
+ // grammar/antlr_3/BcParser.lexer.g:11:6: ( ( (' '|'\t'|'\r'|'\n'))+ )
+ // grammar/antlr_3/BcParser.lexer.g:11:6: ( (' '|'\t'|'\r'|'\n'))+
+ {
+
+ // grammar/antlr_3/BcParser.lexer.g:11:6: ( (' '|'\t'|'\r'|'\n'))+
+ int cnt3=0;
+ loop3:
+ do {
+ int alt3=2;
+ int LA3_0 = input.LA(1);
+ if ( (LA3_0>='\t' && LA3_0<='\n')||LA3_0=='\r'||LA3_0==' ' ) {
+ alt3=1;
+ }
+
+
+ switch (alt3) {
+ case 1 :
+ // grammar/antlr_3/BcParser.lexer.g:11:8: ('
'|'\t'|'\r'|'\n')
{
if ( (input.LA(1)>='\t' &&
input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) {
@@ -137,17 +200,17 @@ retry:
break;
default :
- if ( cnt2 >= 1 ) break loop2;
+ if ( cnt3 >= 1 ) break loop3;
EarlyExitException eee =
- new EarlyExitException(2, input);
+ new EarlyExitException(3, input);
throw eee;
}
- cnt2++;
+ cnt3++;
} while (true);
- channel = 99;
+ channel = 99; // send into nirwana
}
@@ -156,11 +219,11 @@ retry:
}
public void mTokens() throws RecognitionException {
- // grammar/antlr_3/BcParser.lexer.g:1:10: ( T7 | INT | WS )
- int alt3=3;
+ // grammar/antlr_3/BcParser.lexer.g:1:10: ( T8 | INT | ML_COMMENT | WS
)
+ int alt4=4;
switch ( input.LA(1) ) {
case 'q':
- alt3=1;
+ alt4=1;
break;
case '0':
case '1':
@@ -172,28 +235,31 @@ retry:
case '7':
case '8':
case '9':
- alt3=2;
+ alt4=2;
+ break;
+ case '/':
+ alt4=3;
break;
case '\t':
case '\n':
case '\r':
case ' ':
- alt3=3;
+ alt4=4;
break;
default:
NoViableAltException nvae =
- new NoViableAltException("1:1: Tokens : ( T7 | INT | WS );",
3, 0, input);
+ new NoViableAltException("1:1: Tokens : ( T8 | INT |
ML_COMMENT | WS );", 4, 0, input);
throw nvae;
}
- switch (alt3) {
+ switch (alt4) {
case 1 :
- // grammar/antlr_3/BcParser.lexer.g:1:10: T7
+ // grammar/antlr_3/BcParser.lexer.g:1:10: T8
{
- mT7();
+ mT8();
}
break;
@@ -206,7 +272,15 @@ retry:
}
break;
case 3 :
- // grammar/antlr_3/BcParser.lexer.g:1:17: WS
+ // grammar/antlr_3/BcParser.lexer.g:1:17: ML_COMMENT
+ {
+
+ mML_COMMENT();
+
+ }
+ break;
+ case 4 :
+ // grammar/antlr_3/BcParser.lexer.g:1:28: WS
{
mWS();
Modified: trunk/languages/bc/grammar/antlr_3/antlr_past2pir_past.g
==============================================================================
--- trunk/languages/bc/grammar/antlr_3/antlr_past2pir_past.g (original)
+++ trunk/languages/bc/grammar/antlr_3/antlr_past2pir_past.g Thu Feb 23
12:57:49 2006
@@ -41,44 +41,6 @@ gen_pir_past
{
String pirAfter = ""
+ "# entering gen_pir_past" + "\n"
- + " \$P20 = new 'PAST::Exp' " + "\n"
- + " \$P21 = new PerlArray " + "\n"
- + " push \$P21, " + $expr.reg + " \n"
- + " \$P20.set_node('1', 1, \$P21) " + "\n"
- + " \$P30 = new 'PAST::Op' " + "\n"
- + " \$P31 = new PerlArray " + "\n"
- + " push \$P31, \$P20 " + "\n"
- + " \$P30.set_node('1', 1, 'print' ,\$P31) " + "\n"
- + " \$P40 = new 'PAST::Exp' " + "\n"
- + " \$P41 = new PerlArray " + "\n"
- + " push \$P41, \$P30 " + "\n"
- + " \$P40.set_node('1', 1, \$P41) " + "\n"
- + " \$P50 = new 'PAST::Stmt' " + "\n"
- + " \$P51 = new PerlArray " + "\n"
- + " push \$P51, \$P40 " + "\n"
- + " \$P50.set_node('1', 1 ,\$P51) " + "\n"
- + " push stmts_children, \$P50 " + "\n"
- + " \$P60 = new 'PAST::Val' " + "\n"
- + " \$P60.set_node( '1', 0, '\\n' ) " + "\n"
- + " \$P60.valtype( 'strqq' ) " + "\n"
- + " \$P70 = new 'PAST::Exp' " + "\n"
- + " \$P71 = new PerlArray " + "\n"
- + " push \$P71, \$P60 " + "\n"
- + " \$P70.set_node('1', 1, \$P71) " + "\n"
- + " \$P80 = new 'PAST::Op' " + "\n"
- + " \$P81 = new PerlArray " + "\n"
- + " push \$P81, \$P70 " + "\n"
- + " \$P80.set_node('1', 1, 'print' ,\$P81) " + "\n"
- + " \$P90 = new 'PAST::Exp' " + "\n"
- + " \$P91 = new PerlArray " + "\n"
- + " push \$P91, \$P80 " + "\n"
- + " \$P90.set_node('1', 1, \$P91) " + "\n"
- + " \$P100 = new 'PAST::Stmt' " + "\n"
- + " \$P101 = new PerlArray " + "\n"
- + " push \$P101, \$P90 " + "\n"
- + " \$P100.set_node('1', 1 ,\$P101) " + "\n"
- + " push stmts_children, \$P100 " + "\n"
- + "\n"
+ " .local pmc stmts" + "\n"
+ " stmts = new 'PAST::Stmts'" + "\n"
+ " stmts.set_node('1', 1, stmts_children)" + "\n"
@@ -178,6 +140,44 @@ expr returns [String reg]
+ $reg + ".set_node( '1', 0, " + $expr_int_1.text + " )" + "\n"
+ $reg + ".valtype( 'num' )" + "\n"
+ "# leaving expr" + "\n"
+ + " \$P20 = new 'PAST::Exp' " + "\n"
+ + " \$P21 = new PerlArray " + "\n"
+ + " push \$P21, " + $reg + " \n"
+ + " \$P20.set_node('1', 1, \$P21) " + "\n"
+ + " \$P30 = new 'PAST::Op' " + "\n"
+ + " \$P31 = new PerlArray " + "\n"
+ + " push \$P31, \$P20 " + "\n"
+ + " \$P30.set_node('1', 1, 'print' ,\$P31) " + "\n"
+ + " \$P40 = new 'PAST::Exp' " + "\n"
+ + " \$P41 = new PerlArray " + "\n"
+ + " push \$P41, \$P30 " + "\n"
+ + " \$P40.set_node('1', 1, \$P41) " + "\n"
+ + " \$P50 = new 'PAST::Stmt' " + "\n"
+ + " \$P51 = new PerlArray " + "\n"
+ + " push \$P51, \$P40 " + "\n"
+ + " \$P50.set_node('1', 1 ,\$P51) " + "\n"
+ + " push stmts_children, \$P50 " + "\n"
+ + " \$P60 = new 'PAST::Val' " + "\n"
+ + " \$P60.set_node( '1', 0, '\\n' ) " + "\n"
+ + " \$P60.valtype( 'strqq' ) " + "\n"
+ + " \$P70 = new 'PAST::Exp' " + "\n"
+ + " \$P71 = new PerlArray " + "\n"
+ + " push \$P71, \$P60 " + "\n"
+ + " \$P70.set_node('1', 1, \$P71) " + "\n"
+ + " \$P80 = new 'PAST::Op' " + "\n"
+ + " \$P81 = new PerlArray " + "\n"
+ + " push \$P81, \$P70 " + "\n"
+ + " \$P80.set_node('1', 1, 'print' ,\$P81) " + "\n"
+ + " \$P90 = new 'PAST::Exp' " + "\n"
+ + " \$P91 = new PerlArray " + "\n"
+ + " push \$P91, \$P80 " + "\n"
+ + " \$P90.set_node('1', 1, \$P91) " + "\n"
+ + " \$P100 = new 'PAST::Stmt' " + "\n"
+ + " \$P101 = new PerlArray " + "\n"
+ + " push \$P101, \$P90 " + "\n"
+ + " \$P100.set_node('1', 1 ,\$P101) " + "\n"
+ + " push stmts_children, \$P100 " + "\n"
+ + "\n"
;
System.out.println( pir );
}
Modified: trunk/languages/bc/grammar/antlr_3/bc.g
==============================================================================
--- trunk/languages/bc/grammar/antlr_3/bc.g (original)
+++ trunk/languages/bc/grammar/antlr_3/bc.g Thu Feb 23 12:57:49 2006
@@ -35,6 +35,18 @@ quit
: 'quit'
;
+// ignore multiple-line comments
+
+
+ML_COMMENT
+ : '/*'
+ ( options {greedy=false;} : . )*
+ '*/'
+ {
+ channel = 99; // send into nirwana
+ }
+ ;
+
WS
: ( ' '
| '\t'
@@ -42,6 +54,6 @@ WS
| '\n'
)+
{
- channel = 99;
+ channel = 99; // send into nirwana
}
;
Modified: trunk/languages/bc/t/basic.t
==============================================================================
--- trunk/languages/bc/t/basic.t (original)
+++ trunk/languages/bc/t/basic.t Thu Feb 23 12:57:49 2006
@@ -53,17 +53,17 @@ sub run_tests {
my @tests = (
# single non-negative integer
- [ '1', [ 1 ], 'positive int 1', with_past => 1, with_antlr3 => 1 ],
- [ '0', [ 0 ], 'zero', with_past => 1, with_antlr3 => 1 ],
- [ '2', [ 2 ], 'positive int', with_past => 1, with_antlr3 => 1 ],
+ [ '1', [ 1 ], 'positive int 1', with_past => 1,
with_antlr3 => 1 ],
+ [ '0', [ 0 ], 'zero', with_past => 1,
with_antlr3 => 1 ],
+ [ '2', [ 2 ], 'positive int', with_past => 1,
with_antlr3 => 1 ],
[ '12345678', [ 12345678 ], 'another positive int', with_past => 1,
with_antlr3 => 1 ],
# multiple lines
- [ "1\n2", [ 1, 2 ], 'two lines', with_past => 1, with_antlr3 => 1 ],
- [ "1\n2\n3\n4\n\n5\n6\n7", [ 1, 2, 3, 4, 5, 6, 7 ], 'seven lines',
with_past => 1 ],
+ [ "1\n2", [ 1, 2 ], 'two lines', with_past => 1,
with_antlr3 => 1 ],
+ [ "1\n2\n3\n4\n\n5\n6\n7", [ 1, 2, 3, 4, 5, 6, 7 ], 'seven lines',
with_past => 1, with_antlr3 => 1 ],
# comments
- [ '/* */7', 7, 'one line comment', with_past => 1 ],
+ [ '/* */7', 7, 'one line comment', with_past => 1,
with_antlr3 => 1 ],
[ "/* line1 \n line2 \n line 3 */ -2 ", -2, 'multi line comment',
with_past => 1 ],
# Strings