%union { CYSpan *span_; }
%union { CYStatement *statement_; }
%union { CYString *string_; }
+%union { CYTarget *target_; }
%union { CYThis *this_; }
%union { CYTrue *true_; }
%union { CYWord *word_; }
%token _char_ "char"
%token _constructor_ "constructor"
%token _double_ "double"
+%token _eval_ "eval"
%token _final_ "final"
%token _float_ "float"
%token _from_ "from"
%type <argument_> ArgumentList
%type <argument_> ArgumentListOpt
%type <argument_> Arguments
-%type <expression_> ArrayComprehension
+%type <target_> ArrayComprehension
%type <literal_> ArrayLiteral
%type <expression_> ArrowFunction
%type <functionParameter_> ArrowParameters
%type <statement_> BreakStatement
%type <statement_> BreakableStatement
%type <expression_> CallExpression_
-%type <expression_> CallExpression
+%type <target_> CallExpression
%type <clause_> CaseBlock
%type <clause_> CaseClause
%type <clause_> CaseClausesOpt
%type <catch_> Catch
%type <identifier_> CatchParameter
%type <statement_> ClassDeclaration
-%type <expression_> ClassExpression
+%type <target_> ClassExpression
%type <classTail_> ClassHeritage
%type <classTail_> ClassHeritageOpt
%type <classTail_> ClassTail
-%type <expression_> Comprehension
+%type <target_> Comprehension
%type <comprehension_> ComprehensionFor
%type <comprehension_> ComprehensionIf
%type <comprehension_> ComprehensionTail
%type <statement_> ExpressionStatement
%type <finally_> Finally
%type <declaration_> ForBinding
-%type <declaration_> ForDeclaration
+%type <forin_> ForDeclaration
%type <forin_> ForInStatementInitializer
%type <for_> ForStatementInitializer
%type <declaration_> FormalParameter
%type <functionParameter_> FormalParameters
%type <statement_> FunctionBody
%type <statement_> FunctionDeclaration
-%type <expression_> FunctionExpression
+%type <target_> FunctionExpression
%type <statement_> FunctionStatementList
%type <statement_> GeneratorBody
%type <statement_> GeneratorDeclaration
-%type <expression_> GeneratorExpression
+%type <target_> GeneratorExpression
%type <method_> GeneratorMethod
%type <statement_> HoistableDeclaration
%type <identifier_> Identifier
%type <identifier_> LabelIdentifier
%type <statement_> LabelledItem
%type <statement_> LabelledStatement
-%type <expression_> LeftHandSideExpression
+%type <target_> LeftHandSideExpression
+%type <bool_> LetOrConst
%type <declaration_> LexicalBinding
%type <statement_> LexicalDeclaration
%type <literal_> Literal
%type <expression_> LogicalANDExpression
%type <expression_> LogicalORExpression
%type <access_> MemberAccess
-%type <expression_> MemberExpression
+%type <target_> MemberExpression
%type <method_> MethodDefinition
%type <module_> ModulePath
%type <expression_> MultiplicativeExpression
-%type <expression_> NewExpression
+%type <target_> NewExpression
%type <null_> NullLiteral
%type <literal_> ObjectLiteral
%type <expression_> PostfixExpression
-%type <expression_> PrimaryExpression
+%type <target_> PrimaryExpression
%type <propertyName_> PropertyName
%type <property_> PropertyDefinition
%type <property_> PropertyDefinitionList_
%type <statement_> StatementListOpt
%type <statement_> StatementListItem
%type <functionParameter_> StrictFormalParameters
-%type <expression_> SuperCall
-%type <expression_> SuperProperty
+%type <target_> SuperCall
+%type <target_> SuperProperty
%type <statement_> SwitchStatement
-%type <expression_> TemplateLiteral
+%type <target_> TemplateLiteral
%type <span_> TemplateSpans
%type <statement_> ThrowStatement
%type <statement_> TryStatement
%type <protocol_> ClassProtocols
%type <protocol_> ClassProtocolsOpt
%type <statement_> ImplementationStatement
-%type <expression_> MessageExpression
+%type <target_> MessageExpression
%type <messageParameter_> MessageParameter
%type <messageParameter_> MessageParameters
%type <messageParameter_> MessageParameterList
| "constructor" { $$ = CYNew CYIdentifier("constructor"); }
| "double" { $$ = CYNew CYIdentifier("double"); }
| "each" { $$ = CYNew CYIdentifier("each"); }
+ | "eval" { $$ = CYNew CYIdentifier("eval"); }
| "final" { $$ = CYNew CYIdentifier("final"); }
| "float" { $$ = CYNew CYIdentifier("float"); }
| "from" { $$ = CYNew CYIdentifier("from"); }
;
CallExpression_
- : MemberExpression
- | CallExpression
+ : MemberExpression { $$ = $1; }
+ | CallExpression { $$ = $1; }
;
CallExpression
- : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
+ : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
| SuperCall { $$ = $1; }
| CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
;
/* }}} */
/* 13.3 Let and Const Declarations {{{ */
LexicalDeclaration
- : LetOrConst BindingList Terminator { $$ = CYNew CYLet($2); }
+ : LetOrConst BindingList Terminator { $$ = CYNew CYLet($1, $2); }
;
LetOrConst
- : "let"
- | "const"
+ : "let" { $$ = false; }
+ | "const" { $$ = true; }
;
BindingList_
| "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
| "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
| "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
- | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
+ | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
;
ForStatementInitializer
ForInStatementInitializer
: LeftHandSideExpression { $$ = $1; }
- | LexSetRegExp Var_ ForBinding { $$ = $3; }
+ | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
| LexSetRegExp ForDeclaration { $$ = $2; }
;
ForDeclaration
- : LetOrConst ForBinding { $$ = $2; }
+ : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
;
ForBinding