Author: bernhard
Date: Sun Jan  7 09:50:53 2007
New Revision: 16470

Modified:
   trunk/languages/plumhead/src/antlr3/GenPastPir.g
   trunk/languages/plumhead/src/antlr3/GenPastPirTreeParser.java
   trunk/languages/plumhead/src/antlr3/Plumhead.g
   trunk/languages/plumhead/src/antlr3/PlumheadLexer.java
   trunk/languages/plumhead/src/antlr3/PlumheadParser.java
   trunk/languages/plumhead/t/arithmetics.t

Log:
[Plumhead antlr3]
Support for MUL, DIV, MOD and grouping with '(' and ')'


Modified: trunk/languages/plumhead/src/antlr3/GenPastPir.g
==============================================================================
--- trunk/languages/plumhead/src/antlr3/GenPastPir.g    (original)
+++ trunk/languages/plumhead/src/antlr3/GenPastPir.g    Sun Jan  7 09:50:53 2007
@@ -173,10 +173,11 @@
     {
       // Todo. This is not nice, handl pirops in Plumhead.g
       String pirop = $infix.text;
-      if ( pirop.equals( "+" ) )
-      {
-        pirop = "n_add";
-      }
+      if      ( pirop.equals( "+" ) )  { pirop = "n_add"; }
+      else if ( pirop.equals( "-" ) )  { pirop = "n_sub"; }
+      else if ( pirop.equals( "*" ) )  { pirop = "n_mul"; }
+      else if ( pirop.equals( "/" ) )  { pirop = "n_div"; }
+      else if ( pirop.equals( "\%" ) ) { pirop = "n_mod"; }
       
       System.out.print( 
           "  " + reg + ".'attr'( 'pirop', '" + pirop + "' , 1 )               
\n"

Modified: trunk/languages/plumhead/src/antlr3/GenPastPirTreeParser.java
==============================================================================
--- trunk/languages/plumhead/src/antlr3/GenPastPirTreeParser.java       
(original)
+++ trunk/languages/plumhead/src/antlr3/GenPastPirTreeParser.java       Sun Jan 
 7 09:50:53 2007
@@ -1,4 +1,4 @@
-// $ANTLR 3.0b5 src/antlr3/GenPastPir.g 2007-01-07 15:27:01
+// $ANTLR 3.0b5 src/antlr3/GenPastPir.g 2007-01-07 17:47:29
 
   import java.util.regex.*;
 
@@ -10,26 +10,26 @@
 
 public class GenPastPirTreeParser extends TreeParser {
     public static final String[] tokenNames = new String[] {
-        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "SEA", 
"CODE_START", "CODE_END", "WS", "STRING", "ECHO", "INTEGER", "MINUS", "PLUS", 
"MUL_OP", "REL_OP", "';'", "FUNCTION", "LETTER", "ASSIGN_OP", "VAR", "NUMBER", 
"NEWLINE", "If", "STMTS"
+        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "SEA", 
"CODE_START", "CODE_END", "WS", "STRING", "ECHO", "INTEGER", "MINUS", "PLUS", 
"MUL_OP", "REL_OP", "';'", "'('", "')'", "FUNCTION", "LETTER", "ASSIGN_OP", 
"VAR", "NUMBER", "NEWLINE", "If", "STMTS"
     };
     public static final int CODE_START=6;
     public static final int MINUS=12;
-    public static final int LETTER=18;
-    public static final int If=23;
-    public static final int NUMBER=21;
+    public static final int LETTER=20;
+    public static final int If=25;
+    public static final int NUMBER=23;
     public static final int WS=8;
     public static final int STRING=9;
     public static final int MUL_OP=14;
     public static final int SEA=5;
     public static final int CODE_END=7;
-    public static final int STMTS=24;
+    public static final int STMTS=26;
     public static final int PROGRAM=4;
-    public static final int NEWLINE=22;
-    public static final int VAR=20;
+    public static final int NEWLINE=24;
+    public static final int VAR=22;
     public static final int INTEGER=11;
-    public static final int ASSIGN_OP=19;
+    public static final int ASSIGN_OP=21;
     public static final int ECHO=10;
-    public static final int FUNCTION=17;
+    public static final int FUNCTION=19;
     public static final int EOF=-1;
     public static final int REL_OP=15;
     public static final int PLUS=13;
@@ -358,10 +358,11 @@
 
                           // Todo. This is not nice, handl pirops in Plumhead.g
                           String pirop = infix.getText();
-                          if ( pirop.equals( "+" ) )
-                          {
-                            pirop = "n_add";
-                          }
+                          if      ( pirop.equals( "+" ) )  { pirop = "n_add"; }
+                          else if ( pirop.equals( "-" ) )  { pirop = "n_sub"; }
+                          else if ( pirop.equals( "*" ) )  { pirop = "n_mul"; }
+                          else if ( pirop.equals( "/" ) )  { pirop = "n_div"; }
+                          else if ( pirop.equals( "%" ) ) { pirop = "n_mod"; }
                           
                           System.out.print( 
                               "  " + reg + ".'attr'( 'pirop', '" + pirop + "' 
, 1 )               \n"
@@ -374,7 +375,7 @@
                     }
                     break;
                 case 5 :
-                    // src/antlr3/GenPastPir.g:188:5: ^( FUNCTION LETTER )
+                    // src/antlr3/GenPastPir.g:189:5: ^( FUNCTION LETTER )
                     {
                     match(input,FUNCTION,FOLLOW_FUNCTION_in_node198); 
 
@@ -389,7 +390,7 @@
                     }
                     break;
                 case 6 :
-                    // src/antlr3/GenPastPir.g:192:5: ^( ASSIGN_OP ^( VAR 
LETTER ) node[\"reg_assign_lhs\"] )
+                    // src/antlr3/GenPastPir.g:193:5: ^( ASSIGN_OP ^( VAR 
LETTER ) node[\"reg_assign_lhs\"] )
                     {
 
                           System.out.print( 
@@ -437,7 +438,7 @@
                     }
                     break;
                 case 7 :
-                    // src/antlr3/GenPastPir.g:219:5: NUMBER
+                    // src/antlr3/GenPastPir.g:220:5: NUMBER
                     {
                     NUMBER4=(CommonTree)input.LT(1);
                     match(input,NUMBER,FOLLOW_NUMBER_in_node245); 
@@ -457,7 +458,7 @@
                     }
                     break;
                 case 8 :
-                    // src/antlr3/GenPastPir.g:232:5: ^( VAR LETTER )
+                    // src/antlr3/GenPastPir.g:233:5: ^( VAR LETTER )
                     {
                     match(input,VAR,FOLLOW_VAR_in_node259); 
 
@@ -483,7 +484,7 @@
                     }
                     break;
                 case 9 :
-                    // src/antlr3/GenPastPir.g:246:5: NEWLINE
+                    // src/antlr3/GenPastPir.g:247:5: NEWLINE
                     {
                     match(input,NEWLINE,FOLLOW_NEWLINE_in_node275); 
                      
@@ -502,7 +503,7 @@
                     }
                     break;
                 case 10 :
-                    // src/antlr3/GenPastPir.g:259:5: ^( If 
node[\"reg_if_op\"] node[\"reg_if_op\"] )
+                    // src/antlr3/GenPastPir.g:260:5: ^( If 
node[\"reg_if_op\"] node[\"reg_if_op\"] )
                     {
 
                           reg_num++;
@@ -541,7 +542,7 @@
                     }
                     break;
                 case 11 :
-                    // src/antlr3/GenPastPir.g:280:5: ^( STMTS ( 
node[reg_stmts] )* )
+                    // src/antlr3/GenPastPir.g:281:5: ^( STMTS ( 
node[reg_stmts] )* )
                     {
 
                           reg_num++;
@@ -555,7 +556,7 @@
 
                     if ( input.LA(1)==Token.DOWN ) {
                         match(input, Token.DOWN, null); 
-                        // src/antlr3/GenPastPir.g:288:14: ( node[reg_stmts] )*
+                        // src/antlr3/GenPastPir.g:289:14: ( node[reg_stmts] )*
                         loop2:
                         do {
                             int alt2=2;
@@ -567,7 +568,7 @@
 
                             switch (alt2) {
                                case 1 :
-                                   // src/antlr3/GenPastPir.g:288:14: 
node[reg_stmts]
+                                   // src/antlr3/GenPastPir.g:289:14: 
node[reg_stmts]
                                    {
                                    pushFollow(FOLLOW_node_in_node325);
                                    node(reg_stmts);
@@ -612,13 +613,13 @@
  
 
     public static final BitSet FOLLOW_PROGRAM_in_gen_pir_past75 = new 
BitSet(new long[]{0x0000000000000004L});
-    public static final BitSet FOLLOW_node_in_gen_pir_past77 = new BitSet(new 
long[]{0x0000000001FAFE08L});
+    public static final BitSet FOLLOW_node_in_gen_pir_past77 = new BitSet(new 
long[]{0x0000000007E8FE08L});
     public static final BitSet FOLLOW_ECHO_in_node109 = new BitSet(new 
long[]{0x0000000000000004L});
     public static final BitSet FOLLOW_node_in_node111 = new BitSet(new 
long[]{0x0000000000000008L});
     public static final BitSet FOLLOW_STRING_in_node126 = new BitSet(new 
long[]{0x0000000000000002L});
     public static final BitSet FOLLOW_INTEGER_in_node138 = new BitSet(new 
long[]{0x0000000000000002L});
     public static final BitSet FOLLOW_set_in_node162 = new BitSet(new 
long[]{0x0000000000000004L});
-    public static final BitSet FOLLOW_node_in_node178 = new BitSet(new 
long[]{0x0000000001FAFE00L});
+    public static final BitSet FOLLOW_node_in_node178 = new BitSet(new 
long[]{0x0000000007E8FE00L});
     public static final BitSet FOLLOW_node_in_node181 = new BitSet(new 
long[]{0x0000000000000008L});
     public static final BitSet FOLLOW_FUNCTION_in_node198 = new BitSet(new 
long[]{0x0000000000000004L});
     public static final BitSet FOLLOW_LETTER_in_node200 = new BitSet(new 
long[]{0x0000000000000008L});
@@ -631,9 +632,9 @@
     public static final BitSet FOLLOW_LETTER_in_node261 = new BitSet(new 
long[]{0x0000000000000008L});
     public static final BitSet FOLLOW_NEWLINE_in_node275 = new BitSet(new 
long[]{0x0000000000000002L});
     public static final BitSet FOLLOW_If_in_node295 = new BitSet(new 
long[]{0x0000000000000004L});
-    public static final BitSet FOLLOW_node_in_node297 = new BitSet(new 
long[]{0x0000000001FAFE00L});
+    public static final BitSet FOLLOW_node_in_node297 = new BitSet(new 
long[]{0x0000000007E8FE00L});
     public static final BitSet FOLLOW_node_in_node300 = new BitSet(new 
long[]{0x0000000000000008L});
     public static final BitSet FOLLOW_STMTS_in_node323 = new BitSet(new 
long[]{0x0000000000000004L});
-    public static final BitSet FOLLOW_node_in_node325 = new BitSet(new 
long[]{0x0000000001FAFE08L});
+    public static final BitSet FOLLOW_node_in_node325 = new BitSet(new 
long[]{0x0000000007E8FE08L});
 
 }
\ No newline at end of file

Modified: trunk/languages/plumhead/src/antlr3/Plumhead.g
==============================================================================
--- trunk/languages/plumhead/src/antlr3/Plumhead.g      (original)
+++ trunk/languages/plumhead/src/antlr3/Plumhead.g      Sun Jan  7 09:50:53 2007
@@ -68,7 +68,7 @@
   ;
 
 multiplying_expression
-  : unary_expression
+  : unary_expression ( MUL_OP^^ unary_expression )*
   ;
 
 unary_expression
@@ -78,4 +78,5 @@
 
 postfix_expression
   : INTEGER
+  | '(' expression ')' -> expression
   ;

Modified: trunk/languages/plumhead/src/antlr3/PlumheadLexer.java
==============================================================================
--- trunk/languages/plumhead/src/antlr3/PlumheadLexer.java      (original)
+++ trunk/languages/plumhead/src/antlr3/PlumheadLexer.java      Sun Jan  7 
09:50:53 2007
@@ -1,4 +1,4 @@
-// $ANTLR 3.0b5 src/antlr3/Plumhead.g 2007-01-07 15:26:59
+// $ANTLR 3.0b5 src/antlr3/Plumhead.g 2007-01-07 17:47:28
 
 import org.antlr.runtime.*;
 import java.util.Stack;
@@ -7,20 +7,22 @@
 
 public class PlumheadLexer extends Lexer {
     public static final int CODE_START=6;
-    public static final int INTEGER=11;
     public static final int MINUS=12;
-    public static final int ECHO=10;
     public static final int WS=8;
-    public static final int EOF=-1;
     public static final int STRING=9;
-    public static final int Tokens=17;
-    public static final int REL_OP=15;
     public static final int MUL_OP=14;
-    public static final int T16=16;
-    public static final int PLUS=13;
     public static final int SEA=5;
     public static final int CODE_END=7;
     public static final int PROGRAM=4;
+    public static final int INTEGER=11;
+    public static final int ECHO=10;
+    public static final int T18=18;
+    public static final int EOF=-1;
+    public static final int T17=17;
+    public static final int Tokens=19;
+    public static final int REL_OP=15;
+    public static final int PLUS=13;
+    public static final int T16=16;
     public PlumheadLexer() {;} 
     public PlumheadLexer(CharStream input) {
         super(input);
@@ -56,6 +58,64 @@
     }
     // $ANTLR end T16
 
+    // $ANTLR start T17
+    public void mT17() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = T17;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // src/antlr3/Plumhead.g:4:7: ( '(' )
+            // src/antlr3/Plumhead.g:4:7: '('
+            {
+            match('('); 
+
+            }
+
+
+
+                    if ( token==null && ruleNestingLevel==1 ) {
+                        
emit(_type,_line,_charPosition,_channel,_start,getCharIndex()-1);
+                    }
+
+                        }
+        finally {
+            ruleNestingLevel--;
+        }
+    }
+    // $ANTLR end T17
+
+    // $ANTLR start T18
+    public void mT18() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = T18;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // src/antlr3/Plumhead.g:5:7: ( ')' )
+            // src/antlr3/Plumhead.g:5:7: ')'
+            {
+            match(')'); 
+
+            }
+
+
+
+                    if ( token==null && ruleNestingLevel==1 ) {
+                        
emit(_type,_line,_charPosition,_channel,_start,getCharIndex()-1);
+                    }
+
+                        }
+        finally {
+            ruleNestingLevel--;
+        }
+    }
+    // $ANTLR end T18
+
     // $ANTLR start SEA
     public void mSEA() throws RecognitionException {
         try {
@@ -87,12 +147,12 @@
                                     int LA1_6 = input.LA(6);
                                     if ( (LA1_6=='e') ) {
                                         int LA1_7 = input.LA(7);
-                                        if ( ((LA1_7>='\u0000' && 
LA1_7<='`')||(LA1_7>='b' && LA1_7<='\uFFFE')) ) {
-                                            alt1=1;
-                                        }
-                                        else if ( (LA1_7=='a') ) {
+                                        if ( (LA1_7=='a') ) {
                                             alt1=2;
                                         }
+                                        else if ( ((LA1_7>='\u0000' && 
LA1_7<='`')||(LA1_7>='b' && LA1_7<='\uFFFE')) ) {
+                                            alt1=1;
+                                        }
 
 
                                     }
@@ -642,37 +702,43 @@
     // $ANTLR end REL_OP
 
     public void mTokens() throws RecognitionException {
-        // src/antlr3/Plumhead.g:1:10: ( T16 | SEA | CODE_START | CODE_END | 
WS | STRING | ECHO | INTEGER | MINUS | PLUS | MUL_OP | REL_OP )
-        int alt6=12;
+        // src/antlr3/Plumhead.g:1:10: ( T16 | T17 | T18 | SEA | CODE_START | 
CODE_END | WS | STRING | ECHO | INTEGER | MINUS | PLUS | MUL_OP | REL_OP )
+        int alt6=14;
         switch ( input.LA(1) ) {
         case ';':
             alt6=1;
             break;
-        case 's':
+        case '(':
             alt6=2;
             break;
+        case ')':
+            alt6=3;
+            break;
+        case 's':
+            alt6=4;
+            break;
         case '<':
-            int LA6_3 = input.LA(2);
-            if ( (LA6_3=='?') ) {
-                alt6=3;
+            int LA6_5 = input.LA(2);
+            if ( (LA6_5=='?') ) {
+                alt6=5;
             }
             else {
-                alt6=12;}
+                alt6=14;}
             break;
         case '?':
-            alt6=4;
+            alt6=6;
             break;
         case '\t':
         case '\n':
         case '\r':
         case ' ':
-            alt6=5;
+            alt6=7;
             break;
         case '\"':
-            alt6=6;
+            alt6=8;
             break;
         case 'e':
-            alt6=7;
+            alt6=9;
             break;
         case '0':
         case '1':
@@ -684,27 +750,27 @@
         case '7':
         case '8':
         case '9':
-            alt6=8;
+            alt6=10;
             break;
         case '-':
-            alt6=9;
+            alt6=11;
             break;
         case '+':
-            alt6=10;
+            alt6=12;
             break;
         case '%':
         case '*':
         case '/':
-            alt6=11;
+            alt6=13;
             break;
         case '!':
         case '=':
         case '>':
-            alt6=12;
+            alt6=14;
             break;
         default:
             NoViableAltException nvae =
-                new NoViableAltException("1:1: Tokens : ( T16 | SEA | 
CODE_START | CODE_END | WS | STRING | ECHO | INTEGER | MINUS | PLUS | MUL_OP | 
REL_OP );", 6, 0, input);
+                new NoViableAltException("1:1: Tokens : ( T16 | T17 | T18 | 
SEA | CODE_START | CODE_END | WS | STRING | ECHO | INTEGER | MINUS | PLUS | 
MUL_OP | REL_OP );", 6, 0, input);
 
             throw nvae;
         }
@@ -718,77 +784,91 @@
                 }
                 break;
             case 2 :
-                // src/antlr3/Plumhead.g:1:14: SEA
+                // src/antlr3/Plumhead.g:1:14: T17
                 {
-                mSEA(); 
+                mT17(); 
 
                 }
                 break;
             case 3 :
-                // src/antlr3/Plumhead.g:1:18: CODE_START
+                // src/antlr3/Plumhead.g:1:18: T18
                 {
-                mCODE_START(); 
+                mT18(); 
 
                 }
                 break;
             case 4 :
-                // src/antlr3/Plumhead.g:1:29: CODE_END
+                // src/antlr3/Plumhead.g:1:22: SEA
                 {
-                mCODE_END(); 
+                mSEA(); 
 
                 }
                 break;
             case 5 :
-                // src/antlr3/Plumhead.g:1:38: WS
+                // src/antlr3/Plumhead.g:1:26: CODE_START
                 {
-                mWS(); 
+                mCODE_START(); 
 
                 }
                 break;
             case 6 :
-                // src/antlr3/Plumhead.g:1:41: STRING
+                // src/antlr3/Plumhead.g:1:37: CODE_END
                 {
-                mSTRING(); 
+                mCODE_END(); 
 
                 }
                 break;
             case 7 :
-                // src/antlr3/Plumhead.g:1:48: ECHO
+                // src/antlr3/Plumhead.g:1:46: WS
                 {
-                mECHO(); 
+                mWS(); 
 
                 }
                 break;
             case 8 :
-                // src/antlr3/Plumhead.g:1:53: INTEGER
+                // src/antlr3/Plumhead.g:1:49: STRING
                 {
-                mINTEGER(); 
+                mSTRING(); 
 
                 }
                 break;
             case 9 :
-                // src/antlr3/Plumhead.g:1:61: MINUS
+                // src/antlr3/Plumhead.g:1:56: ECHO
                 {
-                mMINUS(); 
+                mECHO(); 
 
                 }
                 break;
             case 10 :
-                // src/antlr3/Plumhead.g:1:67: PLUS
+                // src/antlr3/Plumhead.g:1:61: INTEGER
                 {
-                mPLUS(); 
+                mINTEGER(); 
 
                 }
                 break;
             case 11 :
-                // src/antlr3/Plumhead.g:1:72: MUL_OP
+                // src/antlr3/Plumhead.g:1:69: MINUS
                 {
-                mMUL_OP(); 
+                mMINUS(); 
 
                 }
                 break;
             case 12 :
-                // src/antlr3/Plumhead.g:1:79: REL_OP
+                // src/antlr3/Plumhead.g:1:75: PLUS
+                {
+                mPLUS(); 
+
+                }
+                break;
+            case 13 :
+                // src/antlr3/Plumhead.g:1:80: MUL_OP
+                {
+                mMUL_OP(); 
+
+                }
+                break;
+            case 14 :
+                // src/antlr3/Plumhead.g:1:87: REL_OP
                 {
                 mREL_OP(); 
 

Modified: trunk/languages/plumhead/src/antlr3/PlumheadParser.java
==============================================================================
--- trunk/languages/plumhead/src/antlr3/PlumheadParser.java     (original)
+++ trunk/languages/plumhead/src/antlr3/PlumheadParser.java     Sun Jan  7 
09:50:53 2007
@@ -1,4 +1,4 @@
-// $ANTLR 3.0b5 src/antlr3/Plumhead.g 2007-01-07 15:26:58
+// $ANTLR 3.0b5 src/antlr3/Plumhead.g 2007-01-07 17:47:27
 
 import org.antlr.runtime.*;
 import java.util.Stack;
@@ -10,7 +10,7 @@
 
 public class PlumheadParser extends Parser {
     public static final String[] tokenNames = new String[] {
-        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "SEA", 
"CODE_START", "CODE_END", "WS", "STRING", "ECHO", "INTEGER", "MINUS", "PLUS", 
"MUL_OP", "REL_OP", "';'"
+        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PROGRAM", "SEA", 
"CODE_START", "CODE_END", "WS", "STRING", "ECHO", "INTEGER", "MINUS", "PLUS", 
"MUL_OP", "REL_OP", "';'", "'('", "')'"
     };
     public static final int CODE_START=6;
     public static final int INTEGER=11;
@@ -444,7 +444,7 @@
             if ( (LA2_0==STRING) ) {
                 alt2=1;
             }
-            else if ( ((LA2_0>=INTEGER && LA2_0<=MINUS)) ) {
+            else if ( ((LA2_0>=INTEGER && LA2_0<=MINUS)||LA2_0==17) ) {
                 alt2=2;
             }
             else {
@@ -638,20 +638,24 @@
     };
 
     // $ANTLR start multiplying_expression
-    // src/antlr3/Plumhead.g:70:1: multiplying_expression : unary_expression ;
+    // src/antlr3/Plumhead.g:70: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 MUL_OP17=null;
         unary_expression_return unary_expression16 = null;
 
+        unary_expression_return unary_expression18 = null;
 
 
+        CommonTree MUL_OP17_tree=null;
+
         try {
-            // src/antlr3/Plumhead.g:71:5: ( unary_expression )
-            // src/antlr3/Plumhead.g:71:5: unary_expression
+            // src/antlr3/Plumhead.g:71:5: ( unary_expression ( MUL_OP^^ 
unary_expression )* )
+            // src/antlr3/Plumhead.g:71:5: unary_expression ( MUL_OP^^ 
unary_expression )*
             {
             root_0 = (CommonTree)adaptor.nil();
 
@@ -660,6 +664,43 @@
             _fsp--;
 
             adaptor.addChild(root_0, unary_expression16.tree);
+            // src/antlr3/Plumhead.g:71:22: ( MUL_OP^^ unary_expression )*
+            loop5:
+            do {
+                int alt5=2;
+                int LA5_0 = input.LA(1);
+                if ( (LA5_0==MUL_OP) ) {
+                    alt5=1;
+                }
+
+
+                switch (alt5) {
+               case 1 :
+                   // src/antlr3/Plumhead.g:71:24: MUL_OP^^ unary_expression
+                   {
+                   CommonTree root_1 = (CommonTree)adaptor.nil();
+
+                   MUL_OP17=(Token)input.LT(1);
+                   
match(input,MUL_OP,FOLLOW_MUL_OP_in_multiplying_expression470); 
+                   MUL_OP17_tree = (CommonTree)adaptor.create(MUL_OP17);
+                   root_0 = (CommonTree)adaptor.becomeRoot(MUL_OP17_tree, 
root_0);
+
+                   
pushFollow(FOLLOW_unary_expression_in_multiplying_expression473);
+                   unary_expression18=unary_expression();
+                   _fsp--;
+
+                   adaptor.addChild(root_1, unary_expression18.tree);
+
+                   adaptor.addChild(root_0, root_1);
+
+                   }
+                   break;
+
+               default :
+                   break loop5;
+                }
+            } while (true);
+
 
             }
 
@@ -692,57 +733,57 @@
 
         CommonTree root_0 = null;
 
-        Token MINUS18=null;
-        postfix_expression_return postfix_expression17 = null;
-
+        Token MINUS20=null;
         postfix_expression_return postfix_expression19 = null;
 
+        postfix_expression_return postfix_expression21 = null;
+
         List list_postfix_expression=new ArrayList();
         List list_MINUS=new ArrayList();
-        CommonTree MINUS18_tree=null;
+        CommonTree MINUS20_tree=null;
 
         try {
             // src/antlr3/Plumhead.g:75:5: ( postfix_expression | MINUS 
postfix_expression -> ^( MUL_OP[\"n_mul\"] INTEGER[\"-1\"] postfix_expression ) 
)
-            int alt5=2;
-            int LA5_0 = input.LA(1);
-            if ( (LA5_0==INTEGER) ) {
-                alt5=1;
+            int alt6=2;
+            int LA6_0 = input.LA(1);
+            if ( (LA6_0==INTEGER||LA6_0==17) ) {
+                alt6=1;
             }
-            else if ( (LA5_0==MINUS) ) {
-                alt5=2;
+            else if ( (LA6_0==MINUS) ) {
+                alt6=2;
             }
             else {
                 NoViableAltException nvae =
-                    new NoViableAltException("74:1: unary_expression : ( 
postfix_expression | MINUS postfix_expression -> ^( MUL_OP[\"n_mul\"] 
INTEGER[\"-1\"] postfix_expression ) );", 5, 0, input);
+                    new NoViableAltException("74:1: unary_expression : ( 
postfix_expression | MINUS postfix_expression -> ^( MUL_OP[\"n_mul\"] 
INTEGER[\"-1\"] postfix_expression ) );", 6, 0, input);
 
                 throw nvae;
             }
-            switch (alt5) {
+            switch (alt6) {
                 case 1 :
                     // src/antlr3/Plumhead.g:75:5: postfix_expression
                     {
                     root_0 = (CommonTree)adaptor.nil();
 
-                    
pushFollow(FOLLOW_postfix_expression_in_unary_expression479);
-                    postfix_expression17=postfix_expression();
+                    
pushFollow(FOLLOW_postfix_expression_in_unary_expression489);
+                    postfix_expression19=postfix_expression();
                     _fsp--;
 
-                    adaptor.addChild(root_0, postfix_expression17.tree);
+                    adaptor.addChild(root_0, postfix_expression19.tree);
 
                     }
                     break;
                 case 2 :
                     // src/antlr3/Plumhead.g:76:5: MINUS postfix_expression
                     {
-                    MINUS18=(Token)input.LT(1);
-                    match(input,MINUS,FOLLOW_MINUS_in_unary_expression485); 
-                    list_MINUS.add(MINUS18);
+                    MINUS20=(Token)input.LT(1);
+                    match(input,MINUS,FOLLOW_MINUS_in_unary_expression495); 
+                    list_MINUS.add(MINUS20);
 
-                    
pushFollow(FOLLOW_postfix_expression_in_unary_expression487);
-                    postfix_expression19=postfix_expression();
+                    
pushFollow(FOLLOW_postfix_expression_in_unary_expression497);
+                    postfix_expression21=postfix_expression();
                     _fsp--;
 
-                    list_postfix_expression.add(postfix_expression19.tree);
+                    list_postfix_expression.add(postfix_expression21.tree);
 
                     // AST REWRITE
                     int i_0 = 0;
@@ -791,31 +832,88 @@
     };
 
     // $ANTLR start postfix_expression
-    // src/antlr3/Plumhead.g:79:1: postfix_expression : INTEGER ;
+    // src/antlr3/Plumhead.g:79:1: postfix_expression : ( INTEGER | '(' 
expression ')' -> expression );
     public postfix_expression_return postfix_expression() throws 
RecognitionException {   
         postfix_expression_return retval = new postfix_expression_return();
         retval.start = input.LT(1);
 
         CommonTree root_0 = null;
 
-        Token INTEGER20=null;
+        Token INTEGER22=null;
+        Token char_literal23=null;
+        Token char_literal25=null;
+        expression_return expression24 = null;
 
-        CommonTree INTEGER20_tree=null;
+        List list_expression=new ArrayList();
+        List list_18=new ArrayList();
+        List list_17=new ArrayList();
+        CommonTree INTEGER22_tree=null;
+        CommonTree char_literal23_tree=null;
+        CommonTree char_literal25_tree=null;
 
         try {
-            // src/antlr3/Plumhead.g:80:5: ( INTEGER )
-            // src/antlr3/Plumhead.g:80:5: INTEGER
-            {
-            root_0 = (CommonTree)adaptor.nil();
+            // src/antlr3/Plumhead.g:80:5: ( INTEGER | '(' expression ')' -> 
expression )
+            int alt7=2;
+            int LA7_0 = input.LA(1);
+            if ( (LA7_0==INTEGER) ) {
+                alt7=1;
+            }
+            else if ( (LA7_0==17) ) {
+                alt7=2;
+            }
+            else {
+                NoViableAltException nvae =
+                    new NoViableAltException("79:1: postfix_expression : ( 
INTEGER | '(' expression ')' -> expression );", 7, 0, input);
 
-            INTEGER20=(Token)input.LT(1);
-            match(input,INTEGER,FOLLOW_INTEGER_in_postfix_expression514); 
-            INTEGER20_tree = (CommonTree)adaptor.create(INTEGER20);
-            adaptor.addChild(root_0, INTEGER20_tree);
+                throw nvae;
+            }
+            switch (alt7) {
+                case 1 :
+                    // src/antlr3/Plumhead.g:80:5: INTEGER
+                    {
+                    root_0 = (CommonTree)adaptor.nil();
 
+                    INTEGER22=(Token)input.LT(1);
+                    
match(input,INTEGER,FOLLOW_INTEGER_in_postfix_expression524); 
+                    INTEGER22_tree = (CommonTree)adaptor.create(INTEGER22);
+                    adaptor.addChild(root_0, INTEGER22_tree);
 
-            }
 
+                    }
+                    break;
+                case 2 :
+                    // src/antlr3/Plumhead.g:81:5: '(' expression ')'
+                    {
+                    char_literal23=(Token)input.LT(1);
+                    match(input,17,FOLLOW_17_in_postfix_expression530); 
+                    list_17.add(char_literal23);
+
+                    pushFollow(FOLLOW_expression_in_postfix_expression532);
+                    expression24=expression();
+                    _fsp--;
+
+                    list_expression.add(expression24.tree);
+                    char_literal25=(Token)input.LT(1);
+                    match(input,18,FOLLOW_18_in_postfix_expression534); 
+                    list_18.add(char_literal25);
+
+
+                    // AST REWRITE
+                    int i_0 = 0;
+                    retval.tree = root_0;
+                    root_0 = (CommonTree)adaptor.nil();
+                    // 81:24: -> expression
+                    {
+                        adaptor.addChild(root_0, list_expression.get(i_0));
+
+                    }
+
+
+
+                    }
+                    break;
+
+            }
         }
         catch (RecognitionException re) {
             reportError(re);
@@ -843,19 +941,24 @@
     public static final BitSet FOLLOW_statements_in_code350 = new BitSet(new 
long[]{0x0000000000000080L});
     public static final BitSet FOLLOW_CODE_END_in_code352 = new BitSet(new 
long[]{0x0000000000000002L});
     public static final BitSet FOLLOW_statement_in_statements371 = new 
BitSet(new long[]{0x0000000000000402L});
-    public static final BitSet FOLLOW_ECHO_in_statement387 = new BitSet(new 
long[]{0x0000000000001A00L});
+    public static final BitSet FOLLOW_ECHO_in_statement387 = new BitSet(new 
long[]{0x0000000000021A00L});
     public static final BitSet FOLLOW_expression_in_statement389 = new 
BitSet(new long[]{0x0000000000010000L});
     public static final BitSet FOLLOW_16_in_statement391 = new BitSet(new 
long[]{0x0000000000000002L});
     public static final BitSet FOLLOW_STRING_in_expression414 = new BitSet(new 
long[]{0x0000000000000002L});
     public static final BitSet FOLLOW_adding_expression_in_expression420 = new 
BitSet(new long[]{0x0000000000000002L});
     public static final BitSet 
FOLLOW_multiplying_expression_in_adding_expression433 = new BitSet(new 
long[]{0x0000000000003002L});
-    public static final BitSet FOLLOW_PLUS_in_adding_expression439 = new 
BitSet(new long[]{0x0000000000001800L});
-    public static final BitSet FOLLOW_MINUS_in_adding_expression444 = new 
BitSet(new long[]{0x0000000000001800L});
+    public static final BitSet FOLLOW_PLUS_in_adding_expression439 = new 
BitSet(new long[]{0x0000000000021800L});
+    public static final BitSet FOLLOW_MINUS_in_adding_expression444 = new 
BitSet(new long[]{0x0000000000021800L});
     public static final BitSet 
FOLLOW_multiplying_expression_in_adding_expression449 = new BitSet(new 
long[]{0x0000000000003002L});
-    public static final BitSet 
FOLLOW_unary_expression_in_multiplying_expression466 = new BitSet(new 
long[]{0x0000000000000002L});
-    public static final BitSet 
FOLLOW_postfix_expression_in_unary_expression479 = new BitSet(new 
long[]{0x0000000000000002L});
-    public static final BitSet FOLLOW_MINUS_in_unary_expression485 = new 
BitSet(new long[]{0x0000000000000800L});
-    public static final BitSet 
FOLLOW_postfix_expression_in_unary_expression487 = new BitSet(new 
long[]{0x0000000000000002L});
-    public static final BitSet FOLLOW_INTEGER_in_postfix_expression514 = new 
BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet 
FOLLOW_unary_expression_in_multiplying_expression466 = new BitSet(new 
long[]{0x0000000000004002L});
+    public static final BitSet FOLLOW_MUL_OP_in_multiplying_expression470 = 
new BitSet(new long[]{0x0000000000021800L});
+    public static final BitSet 
FOLLOW_unary_expression_in_multiplying_expression473 = new BitSet(new 
long[]{0x0000000000004002L});
+    public static final BitSet 
FOLLOW_postfix_expression_in_unary_expression489 = new BitSet(new 
long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_MINUS_in_unary_expression495 = new 
BitSet(new long[]{0x0000000000020800L});
+    public static final BitSet 
FOLLOW_postfix_expression_in_unary_expression497 = new BitSet(new 
long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_INTEGER_in_postfix_expression524 = new 
BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_17_in_postfix_expression530 = new 
BitSet(new long[]{0x0000000000021A00L});
+    public static final BitSet FOLLOW_expression_in_postfix_expression532 = 
new BitSet(new long[]{0x0000000000040000L});
+    public static final BitSet FOLLOW_18_in_postfix_expression534 = new 
BitSet(new long[]{0x0000000000000002L});
 
 }
\ No newline at end of file

Modified: trunk/languages/plumhead/t/arithmetics.t
==============================================================================
--- trunk/languages/plumhead/t/arithmetics.t    (original)
+++ trunk/languages/plumhead/t/arithmetics.t    Sun Jan  7 09:50:53 2007
@@ -68,7 +68,7 @@
     [ '1 + 0 + 3', '4', 'three summands including 0', ],
     [ '1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14', '105', 
'Gauss was right', ],
     [ '-1 + 10', '9', 'negative int in expression', ],
-    [ '2 - 1', '1', ],
+    [ '2 - 1', '1', 'subtraction' ],
     [ '1 - 1', '0', ],
     [ '1 - 2', '-1', ],
     [ '-1 - -2', '1', ],
@@ -78,9 +78,9 @@
     [ '2 / 2', '1', ],
     [ '2 % 2', '0', ],
     [ '3 % 2', '1', ],
-    [ '2 / 2 + .1', '1.1', ],
-    [ '2 * 2 + .4', '4.4', ],
-    [ '.1 - 6 / 2', '-2.9', ],
+    [ '2 / 2 + 1000', '1001', ],
+    [ '2 * 2 + 4000', '4004', ],
+    [ '1 - 6 / 2', '-2', ],
     [ '2 % 2 + 4', '4', ],
     [ '  ( 1 ) ', '1', 'one in parenthesis', ],
     [ '  ( 1 + 2 ) - 3 ', '0', ],
@@ -96,13 +96,18 @@
     [ '  ( 1 * 2 ) + ( ( ( ( 3 + 4 ) + 5 ) * 6 ) * 7 ) ', '506', ],
     [ '.1', '0.1', 'Parrot says 0.1', ],
     [ '-.1', '-0.1', 'Parrot bc says -0.1',],
+    [ '2 / 2 + .1', '1.1', ],
+    [ '2 * 2 + .4', '4.4', ],
+    [ '.1 - 6 / 2', '-2.9', ],
     [ '-1.0000001', '-1.0000001', 'probably limited precission of Float PMC', 
],
     [ '1 & 3', '1', 'bitwise and', ],
     [ '1 | 2', '3', 'bitwise or', ],
 );
 
 # Not all tests are working yet
-$#tests = 13;
+$#tests = 40;
+
+# @tests = ( [ '2 / 2', '1', ], );
 
 plan( tests => scalar(@tests) );
 run_tests([EMAIL PROTECTED]);

Reply via email to