2003/07/05 03:23:31
[org.ibex.core.git] / src / org / xwt / js / Parser.java
index 10159b7..3a3dcd9 100644 (file)
@@ -111,13 +111,13 @@ class Parser extends Lexer implements ByteCodes {
             precedence[ASSIGN_MOD] = 1;
         precedence[HOOK] = 2;
         precedence[COMMA] = 3;
-        precedence[OR] = precedence[AND] = 4;
+        precedence[OR] = precedence[AND] = precedence[BANG] = 4;
         precedence[GT] = precedence[GE] = 5;
         precedence[BITOR] = 6;
         precedence[BITXOR] = 7;
         precedence[BITAND] = 8;
         precedence[EQ] = precedence[NE] = 9;
-        precedence[LT] = precedence[LE] = 10;
+        precedence[LT] = precedence[LE] = precedence[TYPEOF] = 10;
         precedence[SHEQ] = precedence[SHNE] = 11;
         precedence[LSH] = precedence[RSH] = precedence[URSH] = 12;
         precedence[ADD] = precedence[SUB] = 13;
@@ -336,6 +336,11 @@ class Parser extends Lexer implements ByteCodes {
             b.add(parserLine, POP);
             break;
         }
+        case LP: {
+            int n = parseArgs(b);
+            b.add(parserLine,CALLMETHOD,new Integer(n));
+            break;
+        }
         default: {
             pushBackToken();
             b.add(parserLine, GET);
@@ -372,17 +377,8 @@ class Parser extends Lexer implements ByteCodes {
 
         switch (tok) {
         case LP: {  // invocation (not grouping)
-            int i = 0;
-            while(peekToken() != RP) {
-                i++;
-                if (peekToken() != COMMA) {
-                    startExpr(b, -1);
-                    if (peekToken() == RP) break;
-                }
-                consume(COMMA);
-            }
-            consume(RP);
-            b.add(parserLine, CALL, new Integer(i));
+            int n = parseArgs(b);
+            b.add(parserLine, CALL, new Integer(n));
             break;
         }
         case BITOR: case BITXOR: case BITAND: case SHEQ: case SHNE: case LSH:
@@ -435,6 +431,21 @@ class Parser extends Lexer implements ByteCodes {
         continueExpr(b, minPrecedence);                           // try to continue the expression
     }
     
+    // parse a set of comma separated function arguments, assume LP has already been consumed
+    private int parseArgs(CompiledFunctionImpl b) throws IOException {
+        int i = 0;
+        while(peekToken() != RP) {
+            i++;
+            if (peekToken() != COMMA) {
+                startExpr(b, -1);
+                if (peekToken() == RP) break;
+            }
+            consume(COMMA);
+        }
+        consume(RP);
+        return i;
+    }
+    
     /** Parse a block of statements which must be surrounded by LC..RC. */
     void parseBlock(CompiledFunctionImpl b) throws IOException { parseBlock(b, null); }
     void parseBlock(CompiledFunctionImpl b, String label) throws IOException {