/** the line numbers */
private int[] line = new int[10];
+ /** the first line of this script */
+ private int firstLine = -1;
+
/** the instructions */
private int[] op = new int[10];
this.parentScope = parentScope;
if (sourceCode == null) return;
Parser p = new Parser(sourceCode, sourceName, firstLine);
- try {
- while(true) {
- int s = size();
- p.parseStatement(this, null);
- if (s == size()) break;
- }
- add(-1, Tokens.RETURN);
- } catch (Exception e) {
- if (Log.on) Log.log(Parser.class, e);
+ while(true) {
+ int s = size();
+ p.parseStatement(this, null);
+ if (s == size()) break;
}
+ add(-1, Tokens.RETURN);
}
public Object call(JS.Array args) throws JS.Exn { return call(args, new FunctionScope(sourceName, parentScope)); }
final Vec t = cx.stack;
OUTER: for(pc=0; pc<size; pc++) {
String label = null;
- cx.line = line[op];
+ cx.line = line[pc];
switch(op[pc]) {
case LITERAL: t.push(arg[pc]); break;
case OBJECT: t.push(new JS.Obj()); break;
CompiledFunction currentCompiledFunction = null;
Vec stack = new Vec();
- private int line = -1;
+ int line = -1;
/** binds this thread to the current Java Thread */
public void bindToCurrentJavaThread() { javaThreadToJSThread.put(java.lang.Thread.currentThread(), this); }
consume(COMMA);
}
b.add(parserLine, POP); // pop off the topscope
- if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1) consume(SEMI);
+ if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
break;
}
case IF: {
pushBackToken(NAME, possiblyTheLabel);
startExpr(b, -1);
b.add(parserLine, POP);
- if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1) consume(SEMI);
+ if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
break;
}
}
pushBackToken();
startExpr(b, -1);
b.add(parserLine, POP);
- if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1) consume(SEMI);
+ if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
break;
}
}