diff jsparser.js @ 8:0c62f0d3ddf7

parser now ensures that it's done when it thinks it is
author Atul Varma <varmaa@toolness.com>
date Sat, 30 May 2009 15:36:57 -0700
parents e758b89c7c92
children bc6f30e0f948
line wrap: on
line diff
--- a/jsparser.js	Sat May 30 15:26:31 2009 -0700
+++ b/jsparser.js	Sat May 30 15:36:57 2009 -0700
@@ -130,15 +130,16 @@
       throw new Error("I have no idea what this is: " + text);
   }
 
-  tokens.push(new Parsing.Symbol({name: "end",
-                                  charNo: charNo,
-                                  lineNo: lineNo}));
   return tokens;
 };
 
 Parsing.Parser = function Parser(tokens) {
   var self = this;
 
+  tokens = tokens.slice();
+
+  tokens.push(new Parsing.Symbol({name: "end of input"}));
+
   tokens.reverse();
 
   this.advance = function advance(expectedToken) {
@@ -162,7 +163,9 @@
 
   this.parse = function parse() {
     this.advance();
-    return this.expression(0);
+    var value = this.expression(0);
+    this.advance("end of input");
+    return value;
   };
 };