Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: src/parsing/parser-base.h

Issue 1758663002: Change syntax error message for illegal token. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.h ('k') | test/mjsunit/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 ParserBase<Traits>::FunctionState::~FunctionState() { 985 ParserBase<Traits>::FunctionState::~FunctionState() {
986 *scope_stack_ = outer_scope_; 986 *scope_stack_ = outer_scope_;
987 *function_state_stack_ = outer_function_state_; 987 *function_state_stack_ = outer_function_state_;
988 } 988 }
989 989
990 990
991 template <class Traits> 991 template <class Traits>
992 void ParserBase<Traits>::GetUnexpectedTokenMessage( 992 void ParserBase<Traits>::GetUnexpectedTokenMessage(
993 Token::Value token, MessageTemplate::Template* message, const char** arg, 993 Token::Value token, MessageTemplate::Template* message, const char** arg,
994 MessageTemplate::Template default_) { 994 MessageTemplate::Template default_) {
995 *arg = nullptr;
995 switch (token) { 996 switch (token) {
996 case Token::EOS: 997 case Token::EOS:
997 *message = MessageTemplate::kUnexpectedEOS; 998 *message = MessageTemplate::kUnexpectedEOS;
998 *arg = nullptr;
999 break; 999 break;
1000 case Token::SMI: 1000 case Token::SMI:
1001 case Token::NUMBER: 1001 case Token::NUMBER:
1002 *message = MessageTemplate::kUnexpectedTokenNumber; 1002 *message = MessageTemplate::kUnexpectedTokenNumber;
1003 *arg = nullptr;
1004 break; 1003 break;
1005 case Token::STRING: 1004 case Token::STRING:
1006 *message = MessageTemplate::kUnexpectedTokenString; 1005 *message = MessageTemplate::kUnexpectedTokenString;
1007 *arg = nullptr;
1008 break; 1006 break;
1009 case Token::IDENTIFIER: 1007 case Token::IDENTIFIER:
1010 *message = MessageTemplate::kUnexpectedTokenIdentifier; 1008 *message = MessageTemplate::kUnexpectedTokenIdentifier;
1011 *arg = nullptr;
1012 break; 1009 break;
1013 case Token::FUTURE_RESERVED_WORD: 1010 case Token::FUTURE_RESERVED_WORD:
1014 *message = MessageTemplate::kUnexpectedReserved; 1011 *message = MessageTemplate::kUnexpectedReserved;
1015 *arg = nullptr;
1016 break; 1012 break;
1017 case Token::LET: 1013 case Token::LET:
1018 case Token::STATIC: 1014 case Token::STATIC:
1019 case Token::YIELD: 1015 case Token::YIELD:
1020 case Token::FUTURE_STRICT_RESERVED_WORD: 1016 case Token::FUTURE_STRICT_RESERVED_WORD:
1021 *message = is_strict(language_mode()) 1017 *message = is_strict(language_mode())
1022 ? MessageTemplate::kUnexpectedStrictReserved 1018 ? MessageTemplate::kUnexpectedStrictReserved
1023 : MessageTemplate::kUnexpectedTokenIdentifier; 1019 : MessageTemplate::kUnexpectedTokenIdentifier;
1024 *arg = nullptr;
1025 break; 1020 break;
1026 case Token::TEMPLATE_SPAN: 1021 case Token::TEMPLATE_SPAN:
1027 case Token::TEMPLATE_TAIL: 1022 case Token::TEMPLATE_TAIL:
1028 *message = MessageTemplate::kUnexpectedTemplateString; 1023 *message = MessageTemplate::kUnexpectedTemplateString;
1029 *arg = nullptr;
1030 break; 1024 break;
1031 case Token::ESCAPED_STRICT_RESERVED_WORD: 1025 case Token::ESCAPED_STRICT_RESERVED_WORD:
1032 case Token::ESCAPED_KEYWORD: 1026 case Token::ESCAPED_KEYWORD:
1033 *message = MessageTemplate::kInvalidEscapedReservedWord; 1027 *message = MessageTemplate::kInvalidEscapedReservedWord;
1034 *arg = nullptr; 1028 break;
1029 case Token::ILLEGAL:
1030 *message = MessageTemplate::kInvalidOrUnexpectedToken;
1035 break; 1031 break;
1036 default: 1032 default:
1037 const char* name = Token::String(token); 1033 const char* name = Token::String(token);
1038 DCHECK(name != NULL); 1034 DCHECK(name != NULL);
1039 *arg = name; 1035 *arg = name;
1040 break; 1036 break;
1041 } 1037 }
1042 } 1038 }
1043 1039
1044 1040
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after
3369 has_seen_constructor_ = true; 3365 has_seen_constructor_ = true;
3370 return; 3366 return;
3371 } 3367 }
3372 } 3368 }
3373 3369
3374 3370
3375 } // namespace internal 3371 } // namespace internal
3376 } // namespace v8 3372 } // namespace v8
3377 3373
3378 #endif // V8_PARSING_PARSER_BASE_H 3374 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/messages.h ('k') | test/mjsunit/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698