- 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
This commit is contained in:
brendan%mozilla.org
2004-02-16 02:38:19 +00:00
parent 4431c4eff8
commit c2b091c1d2

View File

@@ -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;
}
}