NanoGoat
[org.ibex.core.git] / src / org / ibex / js / Parser.java
index f36eda4..09f50db 100644 (file)
@@ -72,7 +72,7 @@ class Parser extends Lexer implements ByteCodes {
     public Parser(Reader r, String sourceName, int line) throws IOException { super(r, sourceName, line); }
 
     /** for debugging */
-    public static void main(String[] s) throws Exception {
+    public static void main(String[] s) throws IOException {
         JS block = JS.fromReader("stdin", 0, new InputStreamReader(System.in));
         if (block == null) return;
         System.out.println(block);
@@ -192,7 +192,6 @@ class Parser extends Lexer implements ByteCodes {
             int i = 0;
             if (peekToken() != RB)
                 while(true) {                                               // iterate over the initialization values
-                    int size = b.size;
                     b.add(parserLine, LITERAL, JS.N(i++));           // push the index in the array to place it into
                     if (peekToken() == COMMA || peekToken() == RB)
                         b.add(parserLine, LITERAL, null);                   // for stuff like [1,,2,]
@@ -318,7 +317,7 @@ class Parser extends Lexer implements ByteCodes {
         // attempt to continue the expression
         continueExpr(b, minPrecedence);
     }
-
+    /*
     private Grammar parseGrammar(Grammar g) throws IOException {
         int tok = getToken();
         if (g != null)
@@ -349,7 +348,7 @@ class Parser extends Lexer implements ByteCodes {
         if (g == null) return parseGrammar(g0);
         return parseGrammar(new Grammar.Juxtaposition(g, g0));
     }
-
+    */
     /**
      *  Assuming that a complete assignable (lvalue) has just been
      *  parsed and the object and key are on the stack,
@@ -369,7 +368,7 @@ class Parser extends Lexer implements ByteCodes {
             // force the default case
             tok = -1;
         switch(tok) {
-
+            /*
         case GRAMMAR: {
             b.add(parserLine, GET_PRESERVE);
             Grammar g = parseGrammar(null);
@@ -383,15 +382,13 @@ class Parser extends Lexer implements ByteCodes {
             b.add(parserLine, PUT);
             break;
         }
-
+            */
         case ASSIGN_BITOR: case ASSIGN_BITXOR: case ASSIGN_BITAND: case ASSIGN_LSH: case ASSIGN_RSH: case ASSIGN_URSH:
         case ASSIGN_MUL: case ASSIGN_DIV: case ASSIGN_MOD: case ASSIGN_ADD: case ASSIGN_SUB: case ADD_TRAP: case DEL_TRAP: {
             if (tok != ADD_TRAP && tok != DEL_TRAP) b.add(parserLine, GET_PRESERVE);
             
             startExpr(b,  precedence[tok]);
             
-            int size = b.size;
-            
             if (tok != ADD_TRAP && tok != DEL_TRAP) {
                 // tok-1 is always s/^ASSIGN_// (0 is BITOR, 1 is ASSIGN_BITOR, etc) 
                 b.add(parserLine, tok - 1, tok-1==ADD ? JS.N(2) : null);
@@ -494,7 +491,7 @@ class Parser extends Lexer implements ByteCodes {
             break;
         }
         case OR: case AND: {
-            b.add(parserLine, tok == AND ? b.JF : b.JT, JS.ZERO);       // test to see if we can short-circuit
+            b.add(parserLine, tok == AND ? JSFunction.JF : JSFunction.JT, JS.ZERO);       // test to see if we can short-circuit
             int size = b.size;
             startExpr(b, precedence[tok]);                                     // otherwise check the second value
             b.add(parserLine, JMP, JS.N(2));                            // leave the second value on the stack and jump to the end
@@ -743,7 +740,6 @@ class Parser extends Lexer implements ByteCodes {
                     if (peekToken() != RP) {
                         // extended Ibex catch block: catch(e faultCode "foo.bar.baz")
                         consume(NAME);
-                        String propName = string;
                         b.add(parserLine, DUP);
                         b.add(parserLine, LITERAL, string);
                         b.add(parserLine, GET);
@@ -880,7 +876,7 @@ class Parser extends Lexer implements ByteCodes {
                 if (peekToken() != SEMI)
                     startExpr(e2, -1);
                 else
-                    e2.add(parserLine, b.LITERAL, Boolean.TRUE);         // handle the for(foo;;foo) case
+                    e2.add(parserLine, JSFunction.LITERAL, Boolean.TRUE);         // handle the for(foo;;foo) case
                 consume(SEMI);
                 if (label != null) b.add(parserLine, LABEL, label);
                 b.add(parserLine, LOOP);