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

Side by Side Diff: src/preparser.h

Issue 153743006: Merge Parser::ReportUnexpectedToken and PreParser::ReportUnexpectedToken. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 kAllowEvalOrArguments, 80 kAllowEvalOrArguments,
81 kDontAllowEvalOrArguments 81 kDontAllowEvalOrArguments
82 }; 82 };
83 83
84 Scanner* scanner() const { return scanner_; } 84 Scanner* scanner() const { return scanner_; }
85 int position() { return scanner_->location().beg_pos; } 85 int position() { return scanner_->location().beg_pos; }
86 int peek_position() { return scanner_->peek_location().beg_pos; } 86 int peek_position() { return scanner_->peek_location().beg_pos; }
87 bool stack_overflow() const { return stack_overflow_; } 87 bool stack_overflow() const { return stack_overflow_; }
88 void set_stack_overflow() { stack_overflow_ = true; } 88 void set_stack_overflow() { stack_overflow_ = true; }
89 89
90 virtual bool is_classic_mode() = 0;
91
90 INLINE(Token::Value peek()) { 92 INLINE(Token::Value peek()) {
91 if (stack_overflow_) return Token::ILLEGAL; 93 if (stack_overflow_) return Token::ILLEGAL;
92 return scanner()->peek(); 94 return scanner()->peek();
93 } 95 }
94 96
95 INLINE(Token::Value Next()) { 97 INLINE(Token::Value Next()) {
96 if (stack_overflow_) return Token::ILLEGAL; 98 if (stack_overflow_) return Token::ILLEGAL;
97 { 99 {
98 int marker; 100 int marker;
99 if (reinterpret_cast<uintptr_t>(&marker) < stack_limit_) { 101 if (reinterpret_cast<uintptr_t>(&marker) < stack_limit_) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool CheckContextualKeyword(Vector<const char> keyword); 137 bool CheckContextualKeyword(Vector<const char> keyword);
136 void ExpectContextualKeyword(Vector<const char> keyword, bool* ok); 138 void ExpectContextualKeyword(Vector<const char> keyword, bool* ok);
137 139
138 // Strict mode octal literal validation. 140 // Strict mode octal literal validation.
139 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok); 141 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok);
140 142
141 // Determine precedence of given token. 143 // Determine precedence of given token.
142 static int Precedence(Token::Value token, bool accept_IN); 144 static int Precedence(Token::Value token, bool accept_IN);
143 145
144 // Report syntax errors. 146 // Report syntax errors.
145 virtual void ReportUnexpectedToken(Token::Value token) = 0; 147 void ReportUnexpectedToken(Token::Value token);
146 virtual void ReportMessageAt(Scanner::Location loc, const char* type) = 0; 148 void ReportMessageAt(Scanner::Location location, const char* type) {
149 ReportMessageAt(location, type, Vector<const char*>::empty());
150 }
151 virtual void ReportMessageAt(Scanner::Location source_location,
152 const char* message,
153 Vector<const char*> args) = 0;
147 154
148 // Used to detect duplicates in object literals. Each of the values 155 // Used to detect duplicates in object literals. Each of the values
149 // kGetterProperty, kSetterProperty and kValueProperty represents 156 // kGetterProperty, kSetterProperty and kValueProperty represents
150 // a type of object literal property. When parsing a property, its 157 // a type of object literal property. When parsing a property, its
151 // type value is stored in the DuplicateFinder for the property name. 158 // type value is stored in the DuplicateFinder for the property name.
152 // Values are chosen so that having intersection bits means the there is 159 // Values are chosen so that having intersection bits means the there is
153 // an incompatibility. 160 // an incompatibility.
154 // I.e., you can add a getter to a property that already has a setter, since 161 // I.e., you can add a getter to a property that already has a setter, since
155 // kGetterProperty and kSetterProperty doesn't intersect, but not if it 162 // kGetterProperty and kSetterProperty doesn't intersect, but not if it
156 // already has a getter or a value. Adding the getter to an existing 163 // already has a getter or a value. Adding the getter to an existing
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 Scope* const prev_; 542 Scope* const prev_;
536 const ScopeType type_; 543 const ScopeType type_;
537 int materialized_literal_count_; 544 int materialized_literal_count_;
538 int expected_properties_; 545 int expected_properties_;
539 int with_nesting_count_; 546 int with_nesting_count_;
540 LanguageMode language_mode_; 547 LanguageMode language_mode_;
541 bool is_generator_; 548 bool is_generator_;
542 }; 549 };
543 550
544 // Report syntax error 551 // Report syntax error
545 void ReportUnexpectedToken(Token::Value token); 552 void ReportMessageAt(Scanner::Location location,
546 void ReportMessageAt(Scanner::Location location, const char* type) { 553 const char* message,
547 ReportMessageAt(location, type, NULL); 554 Vector<const char*> args) {
555 ReportMessageAt(location.beg_pos,
556 location.end_pos,
557 message,
558 args.length() > 0 ? args[0] : NULL);
548 } 559 }
549 void ReportMessageAt(Scanner::Location location, 560 void ReportMessageAt(Scanner::Location location,
550 const char* type, 561 const char* type,
551 const char* name_opt) { 562 const char* name_opt) {
552 log_->LogMessage(location.beg_pos, location.end_pos, type, name_opt); 563 log_->LogMessage(location.beg_pos, location.end_pos, type, name_opt);
553 } 564 }
554 void ReportMessageAt(int start_pos, 565 void ReportMessageAt(int start_pos,
555 int end_pos, 566 int end_pos,
556 const char* type, 567 const char* type,
557 const char* name_opt) { 568 const char* name_opt) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 void LogSymbol(); 629 void LogSymbol();
619 // Log the currently parsed identifier. 630 // Log the currently parsed identifier.
620 Identifier GetIdentifierSymbol(); 631 Identifier GetIdentifierSymbol();
621 // Log the currently parsed string literal. 632 // Log the currently parsed string literal.
622 Expression GetStringSymbol(); 633 Expression GetStringSymbol();
623 634
624 void set_language_mode(LanguageMode language_mode) { 635 void set_language_mode(LanguageMode language_mode) {
625 scope_->set_language_mode(language_mode); 636 scope_->set_language_mode(language_mode);
626 } 637 }
627 638
628 bool is_classic_mode() { 639 virtual bool is_classic_mode() {
629 return scope_->language_mode() == CLASSIC_MODE; 640 return scope_->language_mode() == CLASSIC_MODE;
630 } 641 }
631 642
632 bool is_extended_mode() { 643 bool is_extended_mode() {
633 return scope_->language_mode() == EXTENDED_MODE; 644 return scope_->language_mode() == EXTENDED_MODE;
634 } 645 }
635 646
636 LanguageMode language_mode() { return scope_->language_mode(); } 647 LanguageMode language_mode() { return scope_->language_mode(); }
637 648
638 bool CheckInOrOf(bool accept_OF); 649 bool CheckInOrOf(bool accept_OF);
(...skipping 11 matching lines...) Expand all
650 ParserRecorder* log_; 661 ParserRecorder* log_;
651 Scope* scope_; 662 Scope* scope_;
652 Scanner::Location strict_mode_violation_location_; 663 Scanner::Location strict_mode_violation_location_;
653 const char* strict_mode_violation_type_; 664 const char* strict_mode_violation_type_;
654 bool parenthesized_function_; 665 bool parenthesized_function_;
655 }; 666 };
656 667
657 } } // v8::internal 668 } } // v8::internal
658 669
659 #endif // V8_PREPARSER_H 670 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698