2003/06/16 07:58:57
[org.ibex.core.git] / src / org / xwt / js / Parser.java
index 76f223b..68cb87c 100644 (file)
@@ -5,7 +5,7 @@ import org.xwt.util.*;
 import java.io.*;
 
 /**
- *  Parses a stream of lexed tokens into a tree of CompiledFunction's.
+ *  Parses a stream of lexed tokens into a tree of CompiledFunctionImpl's.
  *
  *  There are three kinds of things we parse: blocks, statements, and
  *  expressions.
@@ -73,7 +73,7 @@ class Parser extends Lexer implements ByteCodes {
 
     /** for debugging */
     public static void main(String[] s) throws Exception {
-        CompiledFunction block = new CompiledFunction("stdin", 0, new InputStreamReader(System.in), null);
+        CompiledFunctionImpl block = new JS.CompiledFunction("stdin", 0, new InputStreamReader(System.in), null);
         if (block == null) return;
         System.out.println(block);
     }
@@ -142,14 +142,14 @@ class Parser extends Lexer implements ByteCodes {
      *  bytecodes for that expression to <tt>appendTo</tt>; the
      *  appended bytecodes MUST grow the stack by exactly one element.
      */ 
-    private void startExpr(CompiledFunction appendTo, int minPrecedence) throws IOException {
+    private void startExpr(CompiledFunctionImpl appendTo, int minPrecedence) throws IOException {
        int saveParserLine = parserLine;
        _startExpr(appendTo, minPrecedence);
        parserLine = saveParserLine;
     }
-    private void _startExpr(CompiledFunction appendTo, int minPrecedence) throws IOException {
+    private void _startExpr(CompiledFunctionImpl appendTo, int minPrecedence) throws IOException {
         int tok = getToken();
-        CompiledFunction b = appendTo;
+        CompiledFunctionImpl b = appendTo;
 
         switch (tok) {
         case -1: throw new ParserException("expected expression");
@@ -232,7 +232,7 @@ class Parser extends Lexer implements ByteCodes {
         case FUNCTION: {
             consume(LP);
             int numArgs = 0;
-            CompiledFunction b2 = new CompiledFunction(sourceName, parserLine, null);
+            CompiledFunctionImpl b2 = new JS.CompiledFunction(sourceName, parserLine, null, null);
             b.add(parserLine, NEWFUNCTION, b2);
 
             // function prelude; arguments array is already on the stack
@@ -299,12 +299,12 @@ class Parser extends Lexer implements ByteCodes {
      *  expression that modifies the assignable.  This method always
      *  decreases the stack depth by exactly one element.
      */
-    private void continueExprAfterAssignable(CompiledFunction b) throws IOException {
+    private void continueExprAfterAssignable(CompiledFunctionImpl b) throws IOException {
        int saveParserLine = parserLine;
        _continueExprAfterAssignable(b);
        parserLine = saveParserLine;
     }
-    private void _continueExprAfterAssignable(CompiledFunction b) throws IOException {
+    private void _continueExprAfterAssignable(CompiledFunctionImpl b) throws IOException {
         if (b == null) throw new Error("got null b; this should never happen");
         int tok = getToken();
        switch(tok) {
@@ -356,12 +356,12 @@ class Parser extends Lexer implements ByteCodes {
      *  If any bytecodes are appended, they will not alter the stack
      *  depth.
      */
-    private void continueExpr(CompiledFunction b, int minPrecedence) throws IOException {
+    private void continueExpr(CompiledFunctionImpl b, int minPrecedence) throws IOException {
        int saveParserLine = parserLine;
        _continueExpr(b, minPrecedence);
        parserLine = saveParserLine;
     }
-    private void _continueExpr(CompiledFunction b, int minPrecedence) throws IOException {
+    private void _continueExpr(CompiledFunctionImpl b, int minPrecedence) throws IOException {
         if (b == null) throw new Error("got null b; this should never happen");
         int tok = getToken();
         if (tok == -1) return;
@@ -436,13 +436,13 @@ class Parser extends Lexer implements ByteCodes {
     }
     
     /** Parse a block of statements which must be surrounded by LC..RC. */
-    void parseBlock(CompiledFunction b) throws IOException { parseBlock(b, null); }
-    void parseBlock(CompiledFunction b, String label) throws IOException {
+    void parseBlock(CompiledFunctionImpl b) throws IOException { parseBlock(b, null); }
+    void parseBlock(CompiledFunctionImpl b, String label) throws IOException {
        int saveParserLine = parserLine;
        _parseBlock(b, label);
        parserLine = saveParserLine;
     }
-    void _parseBlock(CompiledFunction b, String label) throws IOException {
+    void _parseBlock(CompiledFunctionImpl b, String label) throws IOException {
         if (peekToken() == -1) return;
         else if (peekToken() != LC) parseStatement(b, null);
         else {
@@ -453,12 +453,12 @@ class Parser extends Lexer implements ByteCodes {
     }
 
     /** Parse a single statement, consuming the RC or SEMI which terminates it. */
-    void parseStatement(CompiledFunction b, String label) throws IOException {
+    void parseStatement(CompiledFunctionImpl b, String label) throws IOException {
        int saveParserLine = parserLine;
        _parseStatement(b, label);
        parserLine = saveParserLine;
     }
-    void _parseStatement(CompiledFunction b, String label) throws IOException {
+    void _parseStatement(CompiledFunctionImpl b, String label) throws IOException {
         int tok = peekToken();
         if (tok == -1) return;
         switch(tok = getToken()) {
@@ -666,8 +666,8 @@ class Parser extends Lexer implements ByteCodes {
                 b.add(parserLine, NEWSCOPE);                             // grab a fresh scope
                     
                 parseStatement(b, null);                                 // initializer
-                CompiledFunction e2 =                                    // we need to put the incrementor before the test
-                    new CompiledFunction(sourceName, parserLine, null);  // so we save the test here
+                CompiledFunctionImpl e2 =                                    // we need to put the incrementor before the test
+                    new JS.CompiledFunction(sourceName, parserLine, null, null);  // so we save the test here
                 if (peekToken() != SEMI)
                     startExpr(e2, -1);
                 else