| OLD | NEW |
| 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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
| 6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 bool allow_harmony_templates() const { return scanner()->HarmonyTemplates(); } | 111 bool allow_harmony_templates() const { return scanner()->HarmonyTemplates(); } |
| 112 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } | 112 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } |
| 113 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } | 113 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } |
| 114 bool allow_harmony_computed_property_names() const { | 114 bool allow_harmony_computed_property_names() const { |
| 115 return allow_harmony_computed_property_names_; | 115 return allow_harmony_computed_property_names_; |
| 116 } | 116 } |
| 117 bool allow_harmony_rest_params() const { | 117 bool allow_harmony_rest_params() const { |
| 118 return allow_harmony_rest_params_; | 118 return allow_harmony_rest_params_; |
| 119 } | 119 } |
| 120 | 120 bool allow_harmony_exponentiation() const { |
| 121 return scanner()->HarmonyExponentiation(); |
| 122 } |
| 121 bool allow_strong_mode() const { return allow_strong_mode_; } | 123 bool allow_strong_mode() const { return allow_strong_mode_; } |
| 122 | 124 |
| 123 // Setters that determine whether certain syntactical constructs are | 125 // Setters that determine whether certain syntactical constructs are |
| 124 // allowed to be parsed by this instance of the parser. | 126 // allowed to be parsed by this instance of the parser. |
| 125 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } | 127 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
| 126 void set_allow_natives(bool allow) { allow_natives_ = allow; } | 128 void set_allow_natives(bool allow) { allow_natives_ = allow; } |
| 127 void set_allow_harmony_arrow_functions(bool allow) { | 129 void set_allow_harmony_arrow_functions(bool allow) { |
| 128 allow_harmony_arrow_functions_ = allow; | 130 allow_harmony_arrow_functions_ = allow; |
| 129 } | 131 } |
| 130 void set_allow_harmony_modules(bool allow) { | 132 void set_allow_harmony_modules(bool allow) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 150 } | 152 } |
| 151 void set_allow_harmony_unicode(bool allow) { | 153 void set_allow_harmony_unicode(bool allow) { |
| 152 scanner()->SetHarmonyUnicode(allow); | 154 scanner()->SetHarmonyUnicode(allow); |
| 153 } | 155 } |
| 154 void set_allow_harmony_computed_property_names(bool allow) { | 156 void set_allow_harmony_computed_property_names(bool allow) { |
| 155 allow_harmony_computed_property_names_ = allow; | 157 allow_harmony_computed_property_names_ = allow; |
| 156 } | 158 } |
| 157 void set_allow_harmony_rest_params(bool allow) { | 159 void set_allow_harmony_rest_params(bool allow) { |
| 158 allow_harmony_rest_params_ = allow; | 160 allow_harmony_rest_params_ = allow; |
| 159 } | 161 } |
| 162 void set_allow_harmony_exponentiation(bool allow) { |
| 163 scanner()->SetHarmonyExponentiation(allow); |
| 164 } |
| 160 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } | 165 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } |
| 161 | 166 |
| 162 protected: | 167 protected: |
| 163 enum AllowEvalOrArgumentsAsIdentifier { | 168 enum AllowEvalOrArgumentsAsIdentifier { |
| 164 kAllowEvalOrArguments, | 169 kAllowEvalOrArguments, |
| 165 kDontAllowEvalOrArguments | 170 kDontAllowEvalOrArguments |
| 166 }; | 171 }; |
| 167 | 172 |
| 168 enum Mode { | 173 enum Mode { |
| 169 PARSE_LAZILY, | 174 PARSE_LAZILY, |
| (...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 typename ParserBase<Traits>::ExpressionT | 2463 typename ParserBase<Traits>::ExpressionT |
| 2459 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) { | 2464 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) { |
| 2460 DCHECK(prec >= 4); | 2465 DCHECK(prec >= 4); |
| 2461 ExpressionT x = this->ParseUnaryExpression(CHECK_OK); | 2466 ExpressionT x = this->ParseUnaryExpression(CHECK_OK); |
| 2462 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { | 2467 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { |
| 2463 // prec1 >= 4 | 2468 // prec1 >= 4 |
| 2464 while (Precedence(peek(), accept_IN) == prec1) { | 2469 while (Precedence(peek(), accept_IN) == prec1) { |
| 2465 Token::Value op = Next(); | 2470 Token::Value op = Next(); |
| 2466 Scanner::Location op_location = scanner()->location(); | 2471 Scanner::Location op_location = scanner()->location(); |
| 2467 int pos = position(); | 2472 int pos = position(); |
| 2468 ExpressionT y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); | 2473 ExpressionT y = Traits::EmptyExpression(); |
| 2474 |
| 2475 if (op != Token::EXP) { |
| 2476 // Left-to-right associativity |
| 2477 y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); |
| 2478 } else { |
| 2479 // Right-to-left associativity |
| 2480 y = ParseBinaryExpression(prec1, accept_IN, CHECK_OK); |
| 2481 } |
| 2469 | 2482 |
| 2470 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos, | 2483 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos, |
| 2471 factory())) { | 2484 factory())) { |
| 2472 continue; | 2485 continue; |
| 2473 } | 2486 } |
| 2474 | 2487 |
| 2475 // For now we distinguish between comparisons and other binary | 2488 // For now we distinguish between comparisons and other binary |
| 2476 // operations. (We could combine the two and get rid of this | 2489 // operations. (We could combine the two and get rid of this |
| 2477 // code and AST node eventually.) | 2490 // code and AST node eventually.) |
| 2478 if (Token::IsCompareOp(op)) { | 2491 if (Token::IsCompareOp(op)) { |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3109 *ok = false; | 3122 *ok = false; |
| 3110 return; | 3123 return; |
| 3111 } | 3124 } |
| 3112 has_seen_constructor_ = true; | 3125 has_seen_constructor_ = true; |
| 3113 return; | 3126 return; |
| 3114 } | 3127 } |
| 3115 } | 3128 } |
| 3116 } } // v8::internal | 3129 } } // v8::internal |
| 3117 | 3130 |
| 3118 #endif // V8_PREPARSER_H | 3131 #endif // V8_PREPARSER_H |
| OLD | NEW |