From c2dd92fec01b7c00b6dd61f27af47c5f060fd729 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke end position.
return statements outside of functions, labels to verify that
break and continue have somewhere to jump to, and strict
indicates whether strict mode is on. var inFunction, labels, strict;This function is used to raise exceptions on parse errors. It
-takes either a {line, column} object or an offset integer (into
-the current input) as pos argument. It attaches the position
-to the end of the error message, and then raises a SyntaxError
-with that message.
function raise(pos, message) {
- if (typeof pos == "number") pos = getLineInfo(input, pos);
- message += " (" + pos.line + ":" + pos.column + ")";
- throw new SyntaxError(message);
+takes an offset integer (into the current input) to indicate
+the location of the error, attaches the position to the end
+of the error message, and then raises a SyntaxError with that
+message. function raise(pos, message) {
+ var loc = getLineInfo(input, pos);
+ message += " (" + loc.line + ":" + loc.column + ")";
+ var err = new SyntaxError(message);
+ err.pos = pos; err.loc = loc;
+ throw err;
}The assignment of fine-grained, information-carrying type objects allows the tokenizer to store the information it has about a token in a way that is very cheap for the parser to look up.
All token type variables start with an underscore, to make them @@ -420,7 +422,7 @@ identifiers, so '\' also dispatches to that.
If we are here, we either found a non-ASCII identifier + if (tok === false) {
If we are here, we either found a non-ASCII identifier character, or something that's entirely disallowed.
var ch = String.fromCharCode(code);
if (ch === "\\" || nonASCIIidentifierStart.test(ch)) return readWord();
raise(tokPos, "Unexpected character '" + ch + "'");