%union { bool bool_; }
+%union { CYMember *access_; }
%union { CYArgument *argument_; }
%union { CYAssignment *assignment_; }
%union { CYBoolean *boolean_; }
%union { CYClause *clause_; }
%union { cy::Syntax::Catch *catch_; }
+%union { CYClassTail *classTail_; }
%union { CYComprehension *comprehension_; }
%union { CYDeclaration *declaration_; }
%union { CYDeclarations *declarations_; }
%union { CYIdentifier *identifier_; }
%union { CYInfix *infix_; }
%union { CYLiteral *literal_; }
-%union { CYMember *member_; }
+%union { CYMethod *method_; }
%union { CYModule *module_; }
%union { CYNull *null_; }
%union { CYNumber *number_; }
@end
@begin ObjectiveC
-%union { CYClassName *className_; }
-%union { CYClassField *classField_; }
%union { CYMessage *message_; }
%union { CYMessageParameter *messageParameter_; }
+%union { CYImplementationField *implementationField_; }
%union { CYProtocol *protocol_; }
%union { CYSelectorPart *selector_; }
@end
%token _return_ "return"
%token _return__ "!return"
%token _super_ "super"
+%token _super__ "!super"
%token _switch_ "switch"
%token _this_ "this"
%token _throw_ "throw"
%token _boolean_ "boolean"
%token _byte_ "byte"
%token _char_ "char"
+%token _constructor_ "constructor"
%token _double_ "double"
%token _final_ "final"
%token _float_ "float"
%token _package_ "package"
%token _private_ "private"
%token _protected_ "protected"
+%token _prototype_ "prototype"
%token _public_ "public"
%token _set_ "set"
%token _short_ "short"
%type <identifier_> CatchParameter
%type <statement_> ClassDeclaration
%type <expression_> ClassExpression
+%type <classTail_> ClassHeritage
+%type <classTail_> ClassHeritageOpt
+%type <classTail_> ClassTail
%type <expression_> Comprehension
%type <comprehension_> ComprehensionFor
%type <comprehension_> ComprehensionIf
%type <comprehension_> ComprehensionTail
-%type <expression_> ComputedPropertyName
+%type <propertyName_> ComputedPropertyName
%type <expression_> ConditionalExpression
%type <statement_> ContinueStatement
%type <statement_> ConciseBody
%type <statement_> GeneratorBody
%type <statement_> GeneratorDeclaration
%type <expression_> GeneratorExpression
-%type <property_> GeneratorMethod
+%type <method_> GeneratorMethod
%type <statement_> HoistableDeclaration
%type <identifier_> Identifier
%type <identifier_> IdentifierType
%type <propertyName_> LiteralPropertyName
%type <expression_> LogicalANDExpression
%type <expression_> LogicalORExpression
-%type <member_> MemberAccess
+%type <access_> MemberAccess
%type <expression_> MemberExpression
-%type <property_> MethodDefinition
+%type <method_> MethodDefinition
%type <module_> ModulePath
%type <expression_> MultiplicativeExpression
%type <expression_> NewExpression
%type <statement_> StatementListOpt
%type <statement_> StatementListItem
%type <functionParameter_> StrictFormalParameters
+%type <expression_> SuperCall
+%type <expression_> SuperProperty
%type <statement_> SwitchStatement
%type <expression_> TemplateLiteral
%type <span_> TemplateSpans
@begin ObjectiveC
%type <expression_> BoxableExpression
%type <statement_> CategoryStatement
-%type <classField_> ClassFieldListOpt
-%type <classField_> ClassFields
-%type <statement_> ClassStatement
%type <expression_> ClassSuperOpt
+%type <implementationField_> ImplementationFieldListOpt
+%type <implementationField_> ImplementationFields
%type <message_> ClassMessageDeclaration
%type <message_> ClassMessageDeclarationListOpt
-%type <className_> ClassName
%type <protocol_> ClassProtocolListOpt
%type <protocol_> ClassProtocols
%type <protocol_> ClassProtocolsOpt
+%type <statement_> ImplementationStatement
%type <expression_> MessageExpression
%type <messageParameter_> MessageParameter
%type <messageParameter_> MessageParameters
LexPushReturnOn: { driver.return_.push(true); };
LexPopReturn: { driver.return_.pop(); };
+LexPushSuperOn: { driver.super_.push(true); };
+LexPushSuperOff: { driver.super_.push(false); };
+LexPopSuper: { driver.super_.pop(); };
+
LexPushYieldOn: { driver.yield_.push(true); };
LexPushYieldOff: { driver.yield_.push(false); };
LexPopYield: { driver.yield_.pop(); };
| "return" { $$ = CYNew CYWord("return"); }
| "!return" { $$ = CYNew CYWord("return"); }
| "super" { $$ = CYNew CYWord("super"); }
+ | "!super" { $$ = CYNew CYWord("super"); }
| "switch" { $$ = CYNew CYWord("switch"); }
| "this" { $$ = CYNew CYWord("this"); }
| "throw" { $$ = CYNew CYWord("throw"); }
| "await" { $$ = CYNew CYIdentifier("await"); }
| "boolean" { $$ = CYNew CYIdentifier("boolean"); }
| "byte" { $$ = CYNew CYIdentifier("byte"); }
+ | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
| "double" { $$ = CYNew CYIdentifier("double"); }
| "each" { $$ = CYNew CYIdentifier("each"); }
| "final" { $$ = CYNew CYIdentifier("final"); }
| "float" { $$ = CYNew CYIdentifier("float"); }
+ | "from" { $$ = CYNew CYIdentifier("from"); }
+ | "get" { $$ = CYNew CYIdentifier("get"); }
| "goto" { $$ = CYNew CYIdentifier("goto"); }
| "implements" { $$ = CYNew CYIdentifier("implements"); }
| "interface" { $$ = CYNew CYIdentifier("interface"); }
| "package" { $$ = CYNew CYIdentifier("package"); }
| "private" { $$ = CYNew CYIdentifier("private"); }
| "protected" { $$ = CYNew CYIdentifier("protected"); }
+ | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
| "public" { $$ = CYNew CYIdentifier("public"); }
- | "static" { $$ = CYNew CYIdentifier("static"); }
+ | "set" { $$ = CYNew CYIdentifier("set"); }
| "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
| "throws" { $$ = CYNew CYIdentifier("throws"); }
| "transient" { $$ = CYNew CYIdentifier("transient"); }
+ | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
@begin ObjectiveC
| "bool" { $$ = CYNew CYIdentifier("bool"); }
| "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
Identifier
: IdentifierType
| "char" { $$ = CYNew CYIdentifier("char"); }
- | "from" { $$ = CYNew CYIdentifier("from"); }
- | "get" { $$ = CYNew CYIdentifier("get"); }
| "int" { $$ = CYNew CYIdentifier("int"); }
| "long" { $$ = CYNew CYIdentifier("long"); }
- | "set" { $$ = CYNew CYIdentifier("set"); }
| "short" { $$ = CYNew CYIdentifier("short"); }
- | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
+ | "static" { $$ = CYNew CYIdentifier("static"); }
| "volatile" { $$ = CYNew CYIdentifier("volatile"); }
@begin C
| "extern" { $$ = CYNew CYIdentifier("extern"); }
;
PropertyDefinition
- : IdentifierReference { $$ = CYNew CYProperty($1->name_, $1); }
+ : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
| CoverInitializedName { CYNOT(@$); }
- | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
+ | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
| MethodDefinition { $$ = $1; }
;
PropertyName
: LiteralPropertyName { $$ = $1; }
- | ComputedPropertyName { CYNOT(@$); /* $$ = $1; */ }
+ | ComputedPropertyName { $$ = $1; }
;
LiteralPropertyName
;
ComputedPropertyName
- : "[" AssignmentExpression "]" { $$ = $2; }
+ : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
;
CoverInitializedName
MemberExpression
: LexSetRegExp PrimaryExpression { $$ = $2; }
| MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
- | SuperProperty { CYNOT(@$); }
+ | SuperProperty { $$ = $1; }
| MetaProperty { CYNOT(@$); }
| LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
;
SuperProperty
- : LexSetRegExp "super" "[" Expression "]"
- | LexSetRegExp "super" "." IdentifierName
+ : LexSetRegExp "!super" "[" Expression "]" { $$ = CYNew CYSuperAccess($4); }
+ | LexSetRegExp "!super" "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($4)); }
;
MetaProperty
CallExpression
: CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
- | SuperCall { CYNOT(@$); }
+ | SuperCall { $$ = $1; }
| CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
;
SuperCall
- : LexSetRegExp "super" Arguments
+ : LexSetRegExp "!super" Arguments { $$ = CYNew CYSuperCall($3); }
;
Arguments
/* 14.1 Function Definitions {{{ */
FunctionDeclaration
- : ";function" BindingIdentifier "(" FormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
+ : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
;
FunctionExpression
- : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
+ : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
;
StrictFormalParameters
/* }}} */
/* 14.3 Method Definitions {{{ */
MethodDefinition
- : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { CYNOT(@$); /* $$ = CYNew CYFunctionMethod($1, $3, $6); */ }
+ : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
| GeneratorMethod { $$ = $1; }
- | "get" PropertyName "(" ")" BRACE FunctionBody "}" { CYNOT(@$); /* $$ = CYNew CYMethodGet($2, $6); */ }
- | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { CYNOT(@$); /* $$ = CYNew CYMethodSet($2, $4); */ }
+ | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
+ | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
;
PropertySetParameterList
/* }}} */
/* 14.5 Class Definitions {{{ */
ClassDeclaration
- : ";class" BindingIdentifier ClassTail { CYNOT(@$); }
+ : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
;
ClassExpression
- : "class" BindingIdentifierOpt ClassTail { CYNOT(@$); }
+ : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
;
ClassTail
- : ClassHeritageOpt BRACE ClassBodyOpt "}"
+ : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
;
ClassHeritage
- : "extends" LeftHandSideExpression
+ : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
;
ClassHeritageOpt
- : ClassHeritage
- |
+ : ClassHeritage { $$ = $1; }
+ | { $$ = CYNew CYClassTail(NULL); }
;
ClassBody
;
ClassElement
- : MethodDefinition
- | "static" MethodDefinition
+ : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
+ | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
| ";"
;
/* }}} */
| { $$ = NULL; }
;
-ClassFieldListOpt
- : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYClassField($1, $3); }
+ImplementationFieldListOpt
+ : TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($1, $3); }
| LexSetRegExp { $$ = NULL; }
;
-ClassFields
- : BRACE ClassFieldListOpt "}" { $$ = $2; }
+ImplementationFields
+ : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
;
MessageScope
;
ClassMessageDeclaration
- : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
+ : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
;
ClassMessageDeclarationListOpt
| { $$ = NULL; }
;
-ClassName
- : Identifier { $$ = $1; }
- | "(" AssignmentExpression ")" { $$ = $2; }
- ;
-
// XXX: this should be AssignmentExpressionNoRight
ClassProtocols
: ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
| { $$ = NULL; }
;
-ClassStatement
- : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
+ImplementationStatement
+ : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
;
CategoryName
;
CategoryStatement
- : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
+ : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
;
Statement__
- : ClassStatement { $$ = $1; }
+ : ImplementationStatement { $$ = $1; }
| CategoryStatement { $$ = $1; }
;
/* }}} */
MessageExpression
: "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
- | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
+ | "[" LexPushInOff LexSetRegExp "!super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
;
SelectorExpression_