OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 : scanner_(scanner), | 123 : scanner_(scanner), |
124 log_(log), | 124 log_(log), |
125 scope_(NULL), | 125 scope_(NULL), |
126 stack_limit_(stack_limit), | 126 stack_limit_(stack_limit), |
127 strict_mode_violation_location_(i::Scanner::Location::invalid()), | 127 strict_mode_violation_location_(i::Scanner::Location::invalid()), |
128 strict_mode_violation_type_(NULL), | 128 strict_mode_violation_type_(NULL), |
129 stack_overflow_(false), | 129 stack_overflow_(false), |
130 allow_lazy_(false), | 130 allow_lazy_(false), |
131 allow_natives_syntax_(false), | 131 allow_natives_syntax_(false), |
132 allow_generators_(false), | 132 allow_generators_(false), |
| 133 allow_for_of_(false), |
133 parenthesized_function_(false) { } | 134 parenthesized_function_(false) { } |
134 | 135 |
135 ~PreParser() {} | 136 ~PreParser() {} |
136 | 137 |
137 bool allow_natives_syntax() const { return allow_natives_syntax_; } | 138 bool allow_natives_syntax() const { return allow_natives_syntax_; } |
138 bool allow_lazy() const { return allow_lazy_; } | 139 bool allow_lazy() const { return allow_lazy_; } |
139 bool allow_modules() const { return scanner_->HarmonyModules(); } | 140 bool allow_modules() const { return scanner_->HarmonyModules(); } |
140 bool allow_harmony_scoping() const { return scanner_->HarmonyScoping(); } | 141 bool allow_harmony_scoping() const { return scanner_->HarmonyScoping(); } |
141 bool allow_generators() const { return allow_generators_; } | 142 bool allow_generators() const { return allow_generators_; } |
| 143 bool allow_for_of() const { return allow_for_of_; } |
142 | 144 |
143 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } | 145 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } |
144 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } | 146 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
145 void set_allow_modules(bool allow) { scanner_->SetHarmonyModules(allow); } | 147 void set_allow_modules(bool allow) { scanner_->SetHarmonyModules(allow); } |
146 void set_allow_harmony_scoping(bool allow) { | 148 void set_allow_harmony_scoping(bool allow) { |
147 scanner_->SetHarmonyScoping(allow); | 149 scanner_->SetHarmonyScoping(allow); |
148 } | 150 } |
149 void set_allow_generators(bool allow) { allow_generators_ = allow; } | 151 void set_allow_generators(bool allow) { allow_generators_ = allow; } |
| 152 void set_allow_for_of(bool allow) { allow_for_of_ = allow; } |
150 | 153 |
151 // Pre-parse the program from the character stream; returns true on | 154 // Pre-parse the program from the character stream; returns true on |
152 // success (even if parsing failed, the pre-parse data successfully | 155 // success (even if parsing failed, the pre-parse data successfully |
153 // captured the syntax error), and false if a stack-overflow happened | 156 // captured the syntax error), and false if a stack-overflow happened |
154 // during parsing. | 157 // during parsing. |
155 PreParseResult PreParseProgram() { | 158 PreParseResult PreParseProgram() { |
156 Scope top_scope(&scope_, kTopLevelScope); | 159 Scope top_scope(&scope_, kTopLevelScope); |
157 bool ok = true; | 160 bool ok = true; |
158 int start_position = scanner_->peek_location().beg_pos; | 161 int start_position = scanner_->peek_location().beg_pos; |
159 ParseSourceElements(i::Token::EOS, &ok); | 162 ParseSourceElements(i::Token::EOS, &ok); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 bool Check(i::Token::Value token) { | 651 bool Check(i::Token::Value token) { |
649 i::Token::Value next = peek(); | 652 i::Token::Value next = peek(); |
650 if (next == token) { | 653 if (next == token) { |
651 Consume(next); | 654 Consume(next); |
652 return true; | 655 return true; |
653 } | 656 } |
654 return false; | 657 return false; |
655 } | 658 } |
656 void ExpectSemicolon(bool* ok); | 659 void ExpectSemicolon(bool* ok); |
657 | 660 |
| 661 bool CheckInOrOf(); |
| 662 |
658 static int Precedence(i::Token::Value tok, bool accept_IN); | 663 static int Precedence(i::Token::Value tok, bool accept_IN); |
659 | 664 |
660 void SetStrictModeViolation(i::Scanner::Location, | 665 void SetStrictModeViolation(i::Scanner::Location, |
661 const char* type, | 666 const char* type, |
662 bool* ok); | 667 bool* ok); |
663 | 668 |
664 void CheckDelayedStrictModeViolation(int beg_pos, int end_pos, bool* ok); | 669 void CheckDelayedStrictModeViolation(int beg_pos, int end_pos, bool* ok); |
665 | 670 |
666 void StrictModeIdentifierViolation(i::Scanner::Location, | 671 void StrictModeIdentifierViolation(i::Scanner::Location, |
667 const char* eval_args_type, | 672 const char* eval_args_type, |
668 Identifier identifier, | 673 Identifier identifier, |
669 bool* ok); | 674 bool* ok); |
670 | 675 |
671 i::Scanner* scanner_; | 676 i::Scanner* scanner_; |
672 i::ParserRecorder* log_; | 677 i::ParserRecorder* log_; |
673 Scope* scope_; | 678 Scope* scope_; |
674 uintptr_t stack_limit_; | 679 uintptr_t stack_limit_; |
675 i::Scanner::Location strict_mode_violation_location_; | 680 i::Scanner::Location strict_mode_violation_location_; |
676 const char* strict_mode_violation_type_; | 681 const char* strict_mode_violation_type_; |
677 bool stack_overflow_; | 682 bool stack_overflow_; |
678 bool allow_lazy_; | 683 bool allow_lazy_; |
679 bool allow_natives_syntax_; | 684 bool allow_natives_syntax_; |
680 bool allow_generators_; | 685 bool allow_generators_; |
| 686 bool allow_for_of_; |
681 bool parenthesized_function_; | 687 bool parenthesized_function_; |
682 }; | 688 }; |
683 } } // v8::preparser | 689 } } // v8::preparser |
684 | 690 |
685 #endif // V8_PREPARSER_H | 691 #endif // V8_PREPARSER_H |
OLD | NEW |