Commit b2f1c412 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Sync preparser and parser wrt syntax error in switch..case.

R=jkummerow@chromium.org
BUG=v8:2210
TEST=test-parsing/ParserSync

Review URL: https://chromiumcodereview.appspot.com/10701116

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12036 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 299a0ab1
......@@ -602,14 +602,17 @@ PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) {
if (token == i::Token::CASE) {
Expect(i::Token::CASE, CHECK_OK);
ParseExpression(true, CHECK_OK);
Expect(i::Token::COLON, CHECK_OK);
} else if (token == i::Token::DEFAULT) {
Expect(i::Token::DEFAULT, CHECK_OK);
Expect(i::Token::COLON, CHECK_OK);
} else {
ParseStatement(CHECK_OK);
Expect(i::Token::DEFAULT, CHECK_OK);
}
Expect(i::Token::COLON, CHECK_OK);
token = peek();
while (token != i::Token::CASE &&
token != i::Token::DEFAULT &&
token != i::Token::RBRACE) {
ParseStatement(CHECK_OK);
token = peek();
}
}
Expect(i::Token::RBRACE, ok);
return Statement::Default();
......
......@@ -1147,6 +1147,7 @@ TEST(ParserSync) {
{ "with ({})", "" },
{ "switch (12) { case 12: ", "}" },
{ "switch (12) { default: ", "}" },
{ "switch (12) { ", "case 12: }" },
{ "label2: ", "" },
{ NULL, NULL }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment