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

Unified Diff: src/preparser.h

Issue 953563002: Implement experimental exponentiation operator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add more tests and fix some bugs 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
« src/compiler/typer.cc ('K') | « 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 8171f9433a4627c9b8fe5f1c5ac6a72d73a9ae4a..fa0fa90511338f38deb49067917f6ce6a45b9f41 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:
@@ -2460,7 +2465,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())) {
« src/compiler/typer.cc ('K') | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698