Created
January 21, 2013 02:42
-
-
Save heath/4583287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static JSBool | |
MatchOrInsertSemicolon(JSContext *cx, TokenStream *ts) | |
{ | |
TokenKind tt = ts->peekTokenSameLine(TSF_OPERAND); | |
if (tt == TOK_ERROR) | |
return JS_FALSE; | |
if (tt != TOK_EOF && tt != TOK_EOL && tt != TOK_SEMI && tt != TOK_RC) { | |
/* Advance the scanner for proper error location reporting. */ | |
ts->getToken(TSF_OPERAND); | |
ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, JSMSG_SEMI_BEFORE_STMNT); | |
return JS_FALSE; | |
} | |
(void) ts->matchToken(TOK_SEMI); | |
return JS_TRUE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Parser::ExpectSemicolon(bool* ok) { | |
// Check for automatic semicolon insertion according to | |
// the rules given in ECMA-262, section 7.9, page 21. | |
Token::Value tok = peek(); | |
if (tok == Token::SEMICOLON) { | |
Next(); | |
return; | |
} | |
if (scanner().HasAnyLineTerminatorBeforeNext() || | |
tok == Token::RBRACE || | |
tok == Token::EOS) { | |
return; | |
} | |
Expect(Token::SEMICOLON, ok); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment