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

Unified Diff: src/preparser.h

Issue 953563002: Implement experimental exponentiation operator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use Number() instead of OrderedNumber() to include NaN Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 41b3a31f0e1169068eaf2968fe55b67fc3904ee4..195676084cfec785ce388e960c25722342b74c23 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -117,7 +117,9 @@ class ParserBase : public Traits {
bool allow_harmony_rest_params() const {
return allow_harmony_rest_params_;
}
-
+ bool allow_harmony_exponentiation() const {
+ return scanner()->HarmonyExponentiation();
+ }
bool allow_strong_mode() const { return allow_strong_mode_; }
// Setters that determine whether certain syntactical constructs are
@@ -157,6 +159,9 @@ class ParserBase : public Traits {
void set_allow_harmony_rest_params(bool allow) {
allow_harmony_rest_params_ = allow;
}
+ void set_allow_harmony_exponentiation(bool allow) {
+ scanner()->SetHarmonyExponentiation(allow);
+ }
void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; }
protected:
@@ -2465,7 +2470,15 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) {
Token::Value op = Next();
Scanner::Location op_location = scanner()->location();
int pos = position();
- ExpressionT y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
+ ExpressionT y = Traits::EmptyExpression();
+
+ if (op != Token::EXP) {
+ // Left-to-right associativity
+ y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
+ } else {
+ // Right-to-left associativity
+ y = ParseBinaryExpression(prec1, accept_IN, CHECK_OK);
+ }
if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
factory())) {
« no previous file with comments | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698