Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 3730a4577cf6f1e70440637b575f8547d96892a0..6ad9ab3162bf63c42f0fcde5d02265c6a264853a 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -778,7 +778,8 @@ void Parser::ReportMessageAt(Scanner::Location source_location, |
const char* type, |
Vector<const char*> args) { |
MessageLocation location(script_, |
- source_location.beg_pos, source_location.end_pos); |
+ source_location.beg_pos, |
+ source_location.end_pos); |
Handle<JSArray> array = Factory::NewJSArray(args.length()); |
for (int i = 0; i < args.length(); i++) { |
SetElement(array, i, Factory::NewStringFromUtf8(CStrVector(args[i]))); |
@@ -788,6 +789,21 @@ void Parser::ReportMessageAt(Scanner::Location source_location, |
} |
+void Parser::ReportMessageAt(Scanner::Location source_location, |
+ const char* type, |
+ Vector<Handle<String> > args) { |
+ MessageLocation location(script_, |
+ source_location.beg_pos, |
+ source_location.end_pos); |
+ Handle<JSArray> array = Factory::NewJSArray(args.length()); |
+ for (int i = 0; i < args.length(); i++) { |
+ SetElement(array, i, args[i]); |
+ } |
+ Handle<Object> result = Factory::NewSyntaxError(type, array); |
+ Top::Throw(*result, &location); |
+} |
+ |
+ |
// Base class containing common code for the different finder classes used by |
// the parser. |
class ParserFinder { |
@@ -1693,12 +1709,16 @@ Statement* Parser::ParseContinueStatement(bool* ok) { |
IterationStatement* target = NULL; |
target = LookupContinueTarget(label, CHECK_OK); |
if (target == NULL) { |
- // Illegal continue statement. To be consistent with KJS we delay |
- // reporting of the syntax error until runtime. |
- Handle<String> error_type = Factory::illegal_continue_symbol(); |
- if (!label.is_null()) error_type = Factory::unknown_label_symbol(); |
- Expression* throw_error = NewThrowSyntaxError(error_type, label); |
- return new ExpressionStatement(throw_error); |
+ // Illegal continue statement. |
+ const char* message = "illegal_continue"; |
+ Vector<Handle<String> > args; |
+ if (!label.is_null()) { |
+ message = "unknown_label"; |
+ args = Vector<Handle<String> >(&label, 1); |
+ } |
+ ReportMessageAt(scanner().location(), message, args); |
+ *ok = false; |
+ return NULL; |
} |
ExpectSemicolon(CHECK_OK); |
return new ContinueStatement(target); |
@@ -1724,12 +1744,16 @@ Statement* Parser::ParseBreakStatement(ZoneStringList* labels, bool* ok) { |
BreakableStatement* target = NULL; |
target = LookupBreakTarget(label, CHECK_OK); |
if (target == NULL) { |
- // Illegal break statement. To be consistent with KJS we delay |
- // reporting of the syntax error until runtime. |
- Handle<String> error_type = Factory::illegal_break_symbol(); |
- if (!label.is_null()) error_type = Factory::unknown_label_symbol(); |
- Expression* throw_error = NewThrowSyntaxError(error_type, label); |
- return new ExpressionStatement(throw_error); |
+ // Illegal break statement. |
+ const char* message = "illegal_break"; |
+ Vector<Handle<String> > args; |
+ if (!label.is_null()) { |
+ message = "unknown_label"; |
+ args = Vector<Handle<String> >(&label, 1); |
+ } |
+ ReportMessageAt(scanner().location(), message, args); |
+ *ok = false; |
+ return NULL; |
} |
ExpectSemicolon(CHECK_OK); |
return new BreakStatement(target); |