From c2b091c1d290735563b59070a12e669e34d39f9d Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Mon, 16 Feb 2004 02:38:19 +0000 Subject: [PATCH] - Add source and cursor properties to SyntaxError exceptions. - Rework labeled statements to fix chicken-and-egg problem with BREAK to label completion type targeting. - Unify next-statement non-expression token cases and default: in Expression. git-svn-id: svn://10.0.0.236/trunk@152804 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/narcissus/jsparse.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/mozilla/js/narcissus/jsparse.js b/mozilla/js/narcissus/jsparse.js index 952f1135f02..85c0bb7aa9d 100644 --- a/mozilla/js/narcissus/jsparse.js +++ b/mozilla/js/narcissus/jsparse.js @@ -201,7 +201,10 @@ Tokenizer.prototype = { }, newSyntaxError: function (m) { - return new SyntaxError(m, this.filename, this.lineno); + var e = new SyntaxError(m, this.filename, this.lineno); + e.source = this.source; + e.cursor = this.cursor; + return e; } }; @@ -453,7 +456,6 @@ function Statement(t, x) { if (--i < 0) throw t.newSyntaxError("Label not found"); } while (ss[i].label != n.label); - n.target = ss[i].statement; } else { do { if (--i < 0) { @@ -462,8 +464,8 @@ function Statement(t, x) { : "continue")); } } while (!ss[i].isLoop && (tt != BREAK || ss[i].type != SWITCH)); - n.target = ss[i]; } + n.target = ss[i]; break; case TRY: @@ -954,18 +956,8 @@ loop: // Automatic semicolon insertion means we may scan across a newline // and into the beginning of another statement. If so, break out of // the while loop and let the t.scanOperand logic handle errors. - case FUNCTION: - case IF: case SWITCH: case CASE: case DEFAULT: - case FOR: case WHILE: case DO: case BREAK: case CONTINUE: - case TRY: case CATCH: case FINALLY: - case THROW: case RETURN: - case WITH: - case VAR: case CONST: - case DEBUGGER: - break loop; - default: - throw t.newSyntaxError("Syntax error"); + break loop; } }