- public static class Script extends Function {
- Vector e = null;
- private Script(Vector e) { this.e = e; }
- public String getSourceName() throws JS.Exn { return ((ByteCodeBlock)e.elementAt(0)).getSourceName(); }
- public Object _call(JS.Array args) throws JS.Exn, ByteCodeBlock.ControlTransferException {
- Scope rootScope = (Scope)args.elementAt(0);
- for(int i=0; i<e.size(); i++) ((ByteCodeBlock)e.elementAt(i)).eval(rootScope, new Vec());
- return null;
- }
- public static Script parse(Reader r, String sourceName, int line) throws IOException {
- Parser p = new Parser(r, sourceName, line);
- try {
- Vector exprs = new Vector();
- while(true) {
- ByteCodeBlock ret = p.parseStatement();
- if (ret == null) break;
- exprs.addElement(ret);
- }
- return new Script(exprs);
- } catch (Exception e) {
- if (Log.on) Log.log(Parser.class, e);
- return null;
+ public static Function parse(Reader r, String sourceName, int line) throws IOException {
+ ByteCodeBlock b = new ByteCodeBlock(line, sourceName);
+ Parser p = new Parser(r, sourceName, line);
+ try {
+ while(true) {
+ int size = b.size();
+ p.parseStatement(false, b);
+ if (size == b.size()) break;