Author: bernhard
Date: Wed Feb 22 13:47:05 2006
New Revision: 11707

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: Start to use named regs, and reuse them.
Workaround for '@members' problem in tree grammars.


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   Wed Feb 22 
13:47:05 2006
@@ -1,4 +1,4 @@
-// $ANTLR 3.0ea7 grammar/antlr_3/antlr_past2pir_past.g 2006-02-20 19:18:26
+// $ANTLR 3.0ea7 grammar/antlr_3/antlr_past2pir_past.g 2006-02-22 22:44:03
 
 import org.antlr.runtime.*;
 import org.antlr.runtime.tree.*;import java.util.Stack;
@@ -23,162 +23,195 @@ public class AntlrPast2PirPast extends T
 
 
     // $ANTLR start gen_pir_past
-    // grammar/antlr_3/antlr_past2pir_past.g:19:1: gen_pir_past : ^( PROGRAM 
expr ) ;
+    // grammar/antlr_3/antlr_past2pir_past.g:20:1: gen_pir_past : ^( PROGRAM ( 
expr )+ ) ;
     public void gen_pir_past() throws RecognitionException {   
 
 
 
-        int expr1 = 0;
+        String expr1 = null;
 
 
         try {
-            // grammar/antlr_3/antlr_past2pir_past.g:21:3: ( ^( PROGRAM expr ) 
)
-            // grammar/antlr_3/antlr_past2pir_past.g:21:3: ^( PROGRAM expr )
+            // grammar/antlr_3/antlr_past2pir_past.g:22:3: ( ^( PROGRAM ( expr 
)+ ) )
+            // grammar/antlr_3/antlr_past2pir_past.g:22:3: ^( PROGRAM ( expr 
)+ )
             {
 
 
-                String pirBefore
-                    =   "#!/usr/bin/env parrot\n"
+                String pirBefore = "" 
+                      + "#!/usr/bin/env parrot" + "\n"
                       + "\n"
-                      + "# Do not edit this file.\n"
-                      + "# This file has been generated by Bc.java.\n"
+                      + "# Do not edit this file." + "\n"
+                      + "# This file has been generated by Bc.java." + "\n"
                       + "\n"
-                      + ".sub bc :main\n"
-                      + "  load_bytecode 'languages/punie/lib/PAST.pir'\n"
-                      + "  load_bytecode 'TGE.pbc'\n"
-                      + "  load_bytecode 'languages/punie/lib/POST.pir'\n"
-                      + "\n"
-                      + "  .local pmc stmts_children\n"
-                      + "  stmts_children = new PerlArray\n";
+                      + ".sub bc :main" + "\n"
+                      + "  load_bytecode 'languages/punie/lib/PAST.pir'" + "\n"
+                      + "  load_bytecode 'TGE.pbc'" + "\n"
+                      + "  load_bytecode 'languages/punie/lib/POST.pir'" + "\n"
+                      + "\n"
+                      + "  .local pmc stmts_children" + "\n"
+                      + "  stmts_children = new PerlArray" + "\n"
+                      ;
 
                 System.out.println( pirBefore );    
               
 
 
-            match(input,PROGRAM,FOLLOW_PROGRAM_in_gen_pir_past61);
+            match(input,PROGRAM,FOLLOW_PROGRAM_in_gen_pir_past62);
 
             match(input, Token.DOWN, null);
 
-            following.push(FOLLOW_expr_in_gen_pir_past63);
-            expr1=expr();
-            following.pop();
+            // grammar/antlr_3/antlr_past2pir_past.g:40:15: ( expr )+
+            int cnt1=0;
+            loop1:
+            do {
+                int alt1=2;
+                int LA1_0 = input.LA(1);
+                if ( LA1_0==INT ) {
+                    alt1=1;
+                }
+
+
+                switch (alt1) {
+               case 1 :
+                   // grammar/antlr_3/antlr_past2pir_past.g:40:15: expr
+                   {
+
+                   following.push(FOLLOW_expr_in_gen_pir_past64);
+                   expr1=expr();
+                   following.pop();
+
+
+                   }
+                   break;
+
+               default :
+                   if ( cnt1 >= 1 ) break loop1;
+                        EarlyExitException eee =
+                            new EarlyExitException(1, input);
+                        throw eee;
+                }
+                cnt1++;
+            } while (true);
 
 
             match(input, Token.UP, null);
 
 
-                  String pirAfter
-                    =   "               $P20 = new 'PAST::Exp' \n"
-                      + "               $P21 = new PerlArray \n"
-                      + "               push $P21, $P" + 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"
-                      + "\n"
-                      + "  # Compile the abstract syntax tree down to an 
opcode syntax tree\n"
-                      + "  .local string ost_tg_source\n"
-                      + "  ost_tg_source = 
_slurp_file('languages/punie/lib/past2post.g')\n"
-                      + "  .local pmc ostgrammar\n"
-                      + "  ostgrammar = new 'TGE'\n"
-                      + "  ostgrammar.agcompile(ost_tg_source)\n"
-                      + "  .local pmc ostbuilder\n"
-                      + "  ostbuilder = ostgrammar.apply(stmts)\n"
-                      + "  .local pmc ost\n"
-                      + "  ost = ostbuilder.get('result')\n"
-                      + "  $I0 = defined ost\n"
-                      + "  unless $I0 goto err_no_ost # if OST fails stop\n"
-                      + "\n"
-                      + "  # Compile the OST down to PIR\n"
-                      + "  .local string pir_tg_source\n"
-                      + "  pir_tg_source = 
_slurp_file('languages/punie/lib/post2pir.g')\n"
-                      + "  .local pmc pirgrammar\n"
-                      + "  pirgrammar = new 'TGE'\n"
-                      + "  pirgrammar.agcompile(pir_tg_source)\n"
-                      + "  .local pmc pirbuilder\n"
-                      + "  pirbuilder = pirgrammar.apply(ost)\n"
-                      + "  .local pmc pir\n"
-                      + "  pir = pirbuilder.get('result')\n"
-                      + "  unless pir goto err_no_pir # if PIR not generated, 
stop\n"
-                      + "\n"
-                      + "  # Execute\n"
-                      + "  .local pmc pir_compiler\n"
-                      + "  .local pmc pir_compiled\n"
-                      + "  pir_compiler = compreg \"PIR\"\n"
-                      + "  pir_compiled = pir_compiler( pir )\n"
-                      + "\n"
-                      + "  pir_compiled()\n"
-                      + "\n"
-                      + "  print \"\\n\"\n"
-                      + "\n"
-                      + "  end\n"
-                      + "\n"
-                      + "  err_match_fail:\n"
-                      + "    print \"parse failed\\n\"\n"
-                      + "    goto cleanup\n"
-                      + "\n"
-                      + "  err_no_ast:\n"
-                      + "    print 'Unable to construct AST.'\n"
-                      + "    goto cleanup\n"
-                      + "\n"
-                      + "  err_no_ost:\n"
-                      + "    print 'Unable to construct OST.'\n"
-                      + "    goto cleanup\n"
-                      + "\n"
-                      + "  err_no_pir:\n"
-                      + "    print 'Unable to construct PIR.'\n"
-                      + "    goto cleanup\n"
-                      + "\n"
-                      + "  cleanup:\n"
-                      + ".end\n"
-                      + "\n"
-                      + ".sub _slurp_file\n"
-                      + "  .param string filename\n"
-                      + "  .local pmc filehandle\n"
-                      + "  filehandle = open filename, '<'\n"
-                      + "  unless filehandle goto err_no_file\n"
-                      + "  $S1 = read filehandle, 65535\n"
-                      + "  close filehandle\n"
-                      + "  .return ($S1)\n"
-                      + "  err_no_file:\n"
-                      + "    print 'Unable to open file: '\n"
-                      + "    print filename\n"
-                      + "    end\n"
-                      + ".end\n";
+                  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"
+                      + "\n"
+                      + "  # Compile the abstract syntax tree down to an 
opcode syntax tree" + "\n"
+                      + "  .local string ost_tg_source" + "\n"
+                      + "  ost_tg_source = 
_slurp_file('languages/punie/lib/past2post.g')" + "\n"
+                      + "  .local pmc ostgrammar" + "\n"
+                      + "  ostgrammar = new 'TGE'" + "\n"
+                      + "  ostgrammar.agcompile(ost_tg_source)" + "\n"
+                      + "  .local pmc ostbuilder" + "\n"
+                      + "  ostbuilder = ostgrammar.apply(stmts)" + "\n"
+                      + "  .local pmc ost" + "\n"
+                      + "  ost = ostbuilder.get('result')" + "\n"
+                      + "  $I0 = defined ost" + "\n"
+                      + "  unless $I0 goto err_no_ost # if OST fails stop" + 
"\n"
+                      + "\n"
+                      + "  # Compile the OST down to PIR" + "\n"
+                      + "  .local string pir_tg_source" + "\n"
+                      + "  pir_tg_source = 
_slurp_file('languages/punie/lib/post2pir.g')" + "\n"
+                      + "  .local pmc pirgrammar" + "\n"
+                      + "  pirgrammar = new 'TGE'" + "\n"
+                      + "  pirgrammar.agcompile(pir_tg_source)" + "\n"
+                      + "  .local pmc pirbuilder" + "\n"
+                      + "  pirbuilder = pirgrammar.apply(ost)" + "\n"
+                      + "  .local pmc pir" + "\n"
+                      + "  pir = pirbuilder.get('result')" + "\n"
+                      + "  unless pir goto err_no_pir # if PIR not generated, 
stop" + "\n"
+                      + "\n"
+                      + "  # Execute" + "\n"
+                      + "  .local pmc pir_compiler" + "\n"
+                      + "  .local pmc pir_compiled" + "\n"
+                      + "  pir_compiler = compreg \"PIR\"" + "\n"
+                      + "  pir_compiled = pir_compiler( pir )" + "\n"
+                      + "\n"
+                      + "  pir_compiled()" + "\n"
+                      + "\n"
+                      + "  print \"\\n\"" + "\n"
+                      + "\n"
+                      + "  end" + "\n"
+                      + "\n"
+                      + "  err_match_fail:" + "\n"
+                      + "    print \"parse failed\\n\"" + "\n"
+                      + "    goto cleanup" + "\n"
+                      + "\n"
+                      + "  err_no_ast:" + "\n"
+                      + "    print 'Unable to construct AST.'" + "\n"
+                      + "    goto cleanup" + "\n"
+                      + "\n"
+                      + "  err_no_ost:" + "\n"
+                      + "    print 'Unable to construct OST.'" + "\n"
+                      + "    goto cleanup" + "\n"
+                      + "\n"
+                      + "  err_no_pir:" + "\n"
+                      + "    print 'Unable to construct PIR.'" + "\n"
+                      + "    goto cleanup" + "\n"
+                      + "\n"
+                      + "  cleanup:" + "\n"
+                      + ".end" + "\n"
+                      + "\n"
+                      + ".sub _slurp_file" + "\n"
+                      + "  .param string filename" + "\n"
+                      + "  .local pmc filehandle" + "\n"
+                      + "  filehandle = open filename, '<'" + "\n"
+                      + "  unless filehandle goto err_no_file" + "\n"
+                      + "  $S1 = read filehandle, 65535" + "\n"
+                      + "  close filehandle" + "\n"
+                      + "  .return ($S1)" + "\n"
+                      + "  err_no_file:" + "\n"
+                      + "    print 'Unable to open file: '" + "\n"
+                      + "    print filename" + "\n"
+                      + "    end" + "\n"
+                      + ".end" + "\n"
+                      + "# leaving gen_pir_past" + "\n"
+                      ;
 
                    System.out.print( pirAfter );    
                 
@@ -203,7 +236,7 @@ public class AntlrPast2PirPast extends T
     };
 
     // $ANTLR start expr_int_1
-    // grammar/antlr_3/antlr_past2pir_past.g:157:1: expr_int_1 : INT ;
+    // grammar/antlr_3/antlr_past2pir_past.g:162: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();
@@ -212,11 +245,11 @@ public class AntlrPast2PirPast extends T
 
 
         try {
-            // grammar/antlr_3/antlr_past2pir_past.g:158:5: ( INT )
-            // grammar/antlr_3/antlr_past2pir_past.g:158:5: INT
+            // grammar/antlr_3/antlr_past2pir_past.g:163:5: ( INT )
+            // grammar/antlr_3/antlr_past2pir_past.g:163:5: INT
             {
 
-            match(input,INT,FOLLOW_INT_in_expr_int_183);
+            match(input,INT,FOLLOW_INT_in_expr_int_186);
 
             }
 
@@ -238,32 +271,36 @@ public class AntlrPast2PirPast extends T
 
 
     // $ANTLR start expr
-    // grammar/antlr_3/antlr_past2pir_past.g:162:1: expr returns [int reg] : 
expr_int_1 ;
-    public int expr() throws RecognitionException {   
+    // grammar/antlr_3/antlr_past2pir_past.g:167:1: expr returns [String reg] 
: expr_int_1 ;
+    public String expr() throws RecognitionException {   
 
-        int reg;
+        String reg;
 
         expr_int_1_return expr_int_12 = null;
 
 
 
-            reg = 10;
+            reg = "reg_expr";
           
         try {
-            // grammar/antlr_3/antlr_past2pir_past.g:167:5: ( expr_int_1 )
-            // grammar/antlr_3/antlr_past2pir_past.g:167:5: expr_int_1
+            // grammar/antlr_3/antlr_past2pir_past.g:172:5: ( expr_int_1 )
+            // grammar/antlr_3/antlr_past2pir_past.g:172:5: expr_int_1
             {
 
-            following.push(FOLLOW_expr_int_1_in_expr110);
+            following.push(FOLLOW_expr_int_1_in_expr113);
             expr_int_12=expr_int_1();
             following.pop();
 
 
 
-                  String pir
-                    =   "               $P" + reg + " = new 'PAST::Val' \n"
-                      + "               $P" + reg + ".set_node( '1', 0, " + 
input.toString(expr_int_12.start,expr_int_12.stop) + " ) \n"
-                      + "               $P" + reg + ".valtype( 'num' ) \n";
+                  String pir = "" 
+                      + "# 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 + ".valtype( 'num' )" + "\n"
+                      + "# leaving expr" + "\n"
+                      ;
                   System.out.println( pir );    
                 
 
@@ -287,9 +324,9 @@ public class AntlrPast2PirPast extends T
 
 
 
-    public static final BitSet FOLLOW_PROGRAM_in_gen_pir_past61 = new 
BitSet(new long[]{4L});
-    public static final BitSet FOLLOW_expr_in_gen_pir_past63 = new BitSet(new 
long[]{8L});
-    public static final BitSet FOLLOW_INT_in_expr_int_183 = new BitSet(new 
long[]{2L});
-    public static final BitSet FOLLOW_expr_int_1_in_expr110 = new BitSet(new 
long[]{2L});
+    public static final BitSet FOLLOW_PROGRAM_in_gen_pir_past62 = new 
BitSet(new long[]{4L});
+    public static final BitSet FOLLOW_expr_in_gen_pir_past64 = new BitSet(new 
long[]{40L});
+    public static final BitSet FOLLOW_INT_in_expr_int_186 = new BitSet(new 
long[]{2L});
+    public static final BitSet FOLLOW_expr_int_1_in_expr113 = new BitSet(new 
long[]{2L});
 
 }
\ No newline at end of file

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    Wed Feb 22 13:47:05 2006
@@ -1,4 +1,4 @@
-// $ANTLR 3.0ea7 grammar/antlr_3/bc.g 2006-02-20 19:18:25
+// $ANTLR 3.0ea7 grammar/antlr_3/bc.g 2006-02-22 22:44:02
 
 import org.antlr.runtime.*;
 import java.util.Stack;
@@ -120,7 +120,7 @@ public class BcParser extends Parser {
     };
 
     // $ANTLR start input_item
-    // grammar/antlr_3/bc.g:25:1: input_item : INT ;
+    // grammar/antlr_3/bc.g:25:1: input_item : ( INT )+ ;
     public input_item_return input_item() throws RecognitionException {   
 
         input_item_return retval = new input_item_return();
@@ -133,16 +133,49 @@ public class BcParser extends Parser {
         CommonTree INT3_tree=null;
 
         try {
-            // grammar/antlr_3/bc.g:26:5: ( INT )
-            // grammar/antlr_3/bc.g:26:5: INT
+            // grammar/antlr_3/bc.g:26:5: ( ( INT )+ )
+            // grammar/antlr_3/bc.g:26:5: ( INT )+
             {
             root_0 = (CommonTree)adaptor.nil();
 
 
-            INT3=(Token)input.LT(1);
-            match(input,INT,FOLLOW_INT_in_input_item86);
-            INT3_tree = (CommonTree)adaptor.create(INT3);
-            adaptor.addChild(root_0, INT3_tree);
+            // grammar/antlr_3/bc.g:26:5: ( INT )+
+            int cnt1=0;
+            loop1:
+            do {
+                int alt1=2;
+                int LA1_0 = input.LA(1);
+                if ( LA1_0==INT ) {
+                    alt1=1;
+                }
+
+
+                switch (alt1) {
+               case 1 :
+                   // grammar/antlr_3/bc.g:26:5: INT
+                   {
+                   CommonTree root_1 = (CommonTree)adaptor.nil();
+
+
+                   INT3=(Token)input.LT(1);
+                   match(input,INT,FOLLOW_INT_in_input_item86);
+                   INT3_tree = (CommonTree)adaptor.create(INT3);
+                   adaptor.addChild(root_1, INT3_tree);
+
+                   adaptor.addChild(root_0, root_1);
+
+                   }
+                   break;
+
+               default :
+                   if ( cnt1 >= 1 ) break loop1;
+                        EarlyExitException eee =
+                            new EarlyExitException(1, input);
+                        throw eee;
+                }
+                cnt1++;
+            } while (true);
+
 
             }
 
@@ -190,7 +223,7 @@ public class BcParser extends Parser {
 
 
             string_literal4=(Token)input.LT(1);
-            match(input,7,FOLLOW_7_in_quit116);
+            match(input,7,FOLLOW_7_in_quit118);
             string_literal4_tree = (CommonTree)adaptor.create(string_literal4);
             adaptor.addChild(root_0, string_literal4_tree);
 
@@ -218,7 +251,7 @@ public class BcParser extends Parser {
 
     public static final BitSet FOLLOW_input_item_in_program61 = new BitSet(new 
long[]{128L});
     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[]{2L});
-    public static final BitSet FOLLOW_7_in_quit116 = 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});
 
 }
\ 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       Wed Feb 22 
13:47:05 2006
@@ -1,4 +1,4 @@
-// $ANTLR 3.0ea7 grammar/antlr_3/BcParser.lexer.g 2006-02-20 19:18:25
+// $ANTLR 3.0ea7 grammar/antlr_3/BcParser.lexer.g 2006-02-22 22:44:02
 
 import org.antlr.runtime.*;
 import java.util.Stack;

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    Wed Feb 22 
13:47:05 2006
@@ -20,136 +20,140 @@ options
 gen_pir_past 
   :
   {
-    String pirBefore
-        =   "#!/usr/bin/env parrot\n"
+    String pirBefore = "" 
+          + "#!/usr/bin/env parrot" + "\n"
           + "\n"
-          + "# Do not edit this file.\n"
-          + "# This file has been generated by Bc.java.\n"
+          + "# Do not edit this file." + "\n"
+          + "# This file has been generated by Bc.java." + "\n"
           + "\n"
-          + ".sub bc :main\n"
-          + "  load_bytecode 'languages/punie/lib/PAST.pir'\n"
-          + "  load_bytecode 'TGE.pbc'\n"
-          + "  load_bytecode 'languages/punie/lib/POST.pir'\n"
-          + "\n"
-          + "  .local pmc stmts_children\n"
-          + "  stmts_children = new PerlArray\n";
+          + ".sub bc :main" + "\n"
+          + "  load_bytecode 'languages/punie/lib/PAST.pir'" + "\n"
+          + "  load_bytecode 'TGE.pbc'" + "\n"
+          + "  load_bytecode 'languages/punie/lib/POST.pir'" + "\n"
+          + "\n"
+          + "  .local pmc stmts_children" + "\n"
+          + "  stmts_children = new PerlArray" + "\n"
+          ;
 
     System.out.println( pirBefore );    
   }
-    ^(PROGRAM expr)
+    ^(PROGRAM expr+ )
     {
-      String pirAfter
-        =   "               \$P20 = new 'PAST::Exp' \n"
-          + "               \$P21 = new PerlArray \n"
-          + "               push \$P21, \$P" + $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"
-          + "\n"
-          + "  # Compile the abstract syntax tree down to an opcode syntax 
tree\n"
-          + "  .local string ost_tg_source\n"
-          + "  ost_tg_source = 
_slurp_file('languages/punie/lib/past2post.g')\n"
-          + "  .local pmc ostgrammar\n"
-          + "  ostgrammar = new 'TGE'\n"
-          + "  ostgrammar.agcompile(ost_tg_source)\n"
-          + "  .local pmc ostbuilder\n"
-          + "  ostbuilder = ostgrammar.apply(stmts)\n"
-          + "  .local pmc ost\n"
-          + "  ost = ostbuilder.get('result')\n"
-          + "  \$I0 = defined ost\n"
-          + "  unless \$I0 goto err_no_ost # if OST fails stop\n"
-          + "\n"
-          + "  # Compile the OST down to PIR\n"
-          + "  .local string pir_tg_source\n"
-          + "  pir_tg_source = _slurp_file('languages/punie/lib/post2pir.g')\n"
-          + "  .local pmc pirgrammar\n"
-          + "  pirgrammar = new 'TGE'\n"
-          + "  pirgrammar.agcompile(pir_tg_source)\n"
-          + "  .local pmc pirbuilder\n"
-          + "  pirbuilder = pirgrammar.apply(ost)\n"
-          + "  .local pmc pir\n"
-          + "  pir = pirbuilder.get('result')\n"
-          + "  unless pir goto err_no_pir # if PIR not generated, stop\n"
-          + "\n"
-          + "  # Execute\n"
-          + "  .local pmc pir_compiler\n"
-          + "  .local pmc pir_compiled\n"
-          + "  pir_compiler = compreg \"PIR\"\n"
-          + "  pir_compiled = pir_compiler( pir )\n"
-          + "\n"
-          + "  pir_compiled()\n"
-          + "\n"
-          + "  print \"\\n\"\n"
-          + "\n"
-          + "  end\n"
-          + "\n"
-          + "  err_match_fail:\n"
-          + "    print \"parse failed\\n\"\n"
-          + "    goto cleanup\n"
-          + "\n"
-          + "  err_no_ast:\n"
-          + "    print 'Unable to construct AST.'\n"
-          + "    goto cleanup\n"
-          + "\n"
-          + "  err_no_ost:\n"
-          + "    print 'Unable to construct OST.'\n"
-          + "    goto cleanup\n"
-          + "\n"
-          + "  err_no_pir:\n"
-          + "    print 'Unable to construct PIR.'\n"
-          + "    goto cleanup\n"
-          + "\n"
-          + "  cleanup:\n"
-          + ".end\n"
-          + "\n"
-          + ".sub _slurp_file\n"
-          + "  .param string filename\n"
-          + "  .local pmc filehandle\n"
-          + "  filehandle = open filename, '<'\n"
-          + "  unless filehandle goto err_no_file\n"
-          + "  \$S1 = read filehandle, 65535\n"
-          + "  close filehandle\n"
-          + "  .return (\$S1)\n"
-          + "  err_no_file:\n"
-          + "    print 'Unable to open file: '\n"
-          + "    print filename\n"
-          + "    end\n"
-          + ".end\n";
+      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"
+          + "\n"
+          + "  # Compile the abstract syntax tree down to an opcode syntax 
tree" + "\n"
+          + "  .local string ost_tg_source" + "\n"
+          + "  ost_tg_source = _slurp_file('languages/punie/lib/past2post.g')" 
+ "\n"
+          + "  .local pmc ostgrammar" + "\n"
+          + "  ostgrammar = new 'TGE'" + "\n"
+          + "  ostgrammar.agcompile(ost_tg_source)" + "\n"
+          + "  .local pmc ostbuilder" + "\n"
+          + "  ostbuilder = ostgrammar.apply(stmts)" + "\n"
+          + "  .local pmc ost" + "\n"
+          + "  ost = ostbuilder.get('result')" + "\n"
+          + "  \$I0 = defined ost" + "\n"
+          + "  unless \$I0 goto err_no_ost # if OST fails stop" + "\n"
+          + "\n"
+          + "  # Compile the OST down to PIR" + "\n"
+          + "  .local string pir_tg_source" + "\n"
+          + "  pir_tg_source = _slurp_file('languages/punie/lib/post2pir.g')" 
+ "\n"
+          + "  .local pmc pirgrammar" + "\n"
+          + "  pirgrammar = new 'TGE'" + "\n"
+          + "  pirgrammar.agcompile(pir_tg_source)" + "\n"
+          + "  .local pmc pirbuilder" + "\n"
+          + "  pirbuilder = pirgrammar.apply(ost)" + "\n"
+          + "  .local pmc pir" + "\n"
+          + "  pir = pirbuilder.get('result')" + "\n"
+          + "  unless pir goto err_no_pir # if PIR not generated, stop" + "\n"
+          + "\n"
+          + "  # Execute" + "\n"
+          + "  .local pmc pir_compiler" + "\n"
+          + "  .local pmc pir_compiled" + "\n"
+          + "  pir_compiler = compreg \"PIR\"" + "\n"
+          + "  pir_compiled = pir_compiler( pir )" + "\n"
+          + "\n"
+          + "  pir_compiled()" + "\n"
+          + "\n"
+          + "  print \"\\n\"" + "\n"
+          + "\n"
+          + "  end" + "\n"
+          + "\n"
+          + "  err_match_fail:" + "\n"
+          + "    print \"parse failed\\n\"" + "\n"
+          + "    goto cleanup" + "\n"
+          + "\n"
+          + "  err_no_ast:" + "\n"
+          + "    print 'Unable to construct AST.'" + "\n"
+          + "    goto cleanup" + "\n"
+          + "\n"
+          + "  err_no_ost:" + "\n"
+          + "    print 'Unable to construct OST.'" + "\n"
+          + "    goto cleanup" + "\n"
+          + "\n"
+          + "  err_no_pir:" + "\n"
+          + "    print 'Unable to construct PIR.'" + "\n"
+          + "    goto cleanup" + "\n"
+          + "\n"
+          + "  cleanup:" + "\n"
+          + ".end" + "\n"
+          + "\n"
+          + ".sub _slurp_file" + "\n"
+          + "  .param string filename" + "\n"
+          + "  .local pmc filehandle" + "\n"
+          + "  filehandle = open filename, '<'" + "\n"
+          + "  unless filehandle goto err_no_file" + "\n"
+          + "  \$S1 = read filehandle, 65535" + "\n"
+          + "  close filehandle" + "\n"
+          + "  .return (\$S1)" + "\n"
+          + "  err_no_file:" + "\n"
+          + "    print 'Unable to open file: '" + "\n"
+          + "    print filename" + "\n"
+          + "    end" + "\n"
+          + ".end" + "\n"
+          + "# leaving gen_pir_past" + "\n"
+          ;
 
        System.out.print( pirAfter );    
     }
@@ -160,17 +164,21 @@ expr_int_1
   ;
 
 
-expr returns [int reg]
+expr returns [String reg]
   @init
   {
-    $reg = 10;
+    $reg = "reg_expr";
   }
   : expr_int_1
     {
-      String pir
-        =   "               \$P" + $reg + " = new 'PAST::Val' \n"
-          + "               \$P" + $reg + ".set_node( '1', 0, " + 
$expr_int_1.text + " ) \n"
-          + "               \$P" + $reg + ".valtype( 'num' ) \n";
+      String pir = "" 
+          + "# entering expr" + "\n"
+          + ".local pmc " + $reg + "\n"
+          + $reg + " = new 'PAST::Val'" + "\n"
+          + $reg + ".set_node( '1', 0, " + $expr_int_1.text + " )" + "\n"
+          + $reg + ".valtype( 'num' )" + "\n"
+          + "# leaving expr" + "\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     Wed Feb 22 13:47:05 2006
@@ -23,7 +23,7 @@ program 
   ;
 
 input_item
-  : INT
+  : INT +
   ;
 
 INT

Modified: trunk/languages/bc/t/basic.t
==============================================================================
--- trunk/languages/bc/t/basic.t        (original)
+++ trunk/languages/bc/t/basic.t        Wed Feb 22 13:47:05 2006
@@ -59,7 +59,7 @@ my @tests = (
        [ '12345678', [ 12345678 ], 'another positive int', with_past => 1, 
with_antlr3 => 1  ],
 
        # multiple lines
-       [ "1\n2", [ 1, 2 ], 'two 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  ],
 
        # comments 

Reply via email to