From 09fc3efbc1e9a22b345b6e542737fc682a1f4332 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 17 Dec 2015 20:58:30 -0800 Subject: [PATCH] Rename everything now that we are on Bison >= 2.5. --- ObjectiveC/Output.cpp | 6 +- ObjectiveC/Replace.cpp | 16 +- ObjectiveC/Syntax.hpp | 22 +- Output.cpp | 58 +-- Parser.ypp.in | 784 ++++++++++++++++++++--------------------- Replace.cpp | 136 +++---- Replace.hpp | 24 +- Syntax.hpp | 123 ++++--- 8 files changed, 582 insertions(+), 587 deletions(-) diff --git a/ObjectiveC/Output.cpp b/ObjectiveC/Output.cpp index 76838d8..a1101ec 100644 --- a/ObjectiveC/Output.cpp +++ b/ObjectiveC/Output.cpp @@ -60,8 +60,8 @@ void CYMessage::Output(CYOutput &out) const { out << (instance_ ? '-' : '+'); CYForEach (parameter, parameters_) - if (parameter->tag_ != NULL) { - out << ' ' << *parameter->tag_; + if (parameter->name_ != NULL) { + out << ' ' << *parameter->name_; if (parameter->type_ != NULL) out << ':' << *parameter->type_->identifier_; } @@ -89,7 +89,7 @@ void CYProtocol::Output(CYOutput &out) const { } void CYSelector::Output(CYOutput &out, CYFlags flags) const { - out << "@selector" << '(' << name_ << ')'; + out << "@selector" << '(' << parts_ << ')'; } void CYSelectorPart::Output(CYOutput &out) const { diff --git a/ObjectiveC/Replace.cpp b/ObjectiveC/Replace.cpp index 2bd5c92..04ed11c 100644 --- a/ObjectiveC/Replace.cpp +++ b/ObjectiveC/Replace.cpp @@ -43,7 +43,7 @@ static CYExpression *MessageType(CYContext &context, CYTypedIdentifier *type, CY CYStatement *CYCategory::Replace(CYContext &context) { CYVariable *cyc($V("$cyc")), *cys($V("$cys")); - return $E($C1($F(NULL, $P6($L($I("$cys")), $L($I("$cyp")), $L($I("$cyc")), $L($I("$cyn")), $L($I("$cyt")), $L($I("$cym"))), $$->* + return $E($C1($F(NULL, $P6($B($I("$cys")), $B($I("$cyp")), $B($I("$cyc")), $B($I("$cyn")), $B($I("$cyt")), $B($I("$cym"))), $$->* $E($ CYAssign($V("$cyp"), $C1($V("object_getClass"), cys)))->* $E($ CYAssign(cyc, cys))->* $E($ CYAssign($V("$cym"), $C1($V("object_getClass"), cyc)))->* @@ -54,7 +54,7 @@ CYStatement *CYCategory::Replace(CYContext &context) { CYStatement *CYImplementation::Replace(CYContext &context) { CYVariable *cyc($V("$cyc")), *cys($V("$cys")); - return $E($C1($F(NULL, $P6($L($I("$cys")), $L($I("$cyp")), $L($I("$cyc")), $L($I("$cyn")), $L($I("$cyt")), $L($I("$cym"))), $$->* + return $E($C1($F(NULL, $P6($B($I("$cys")), $B($I("$cyp")), $B($I("$cyc")), $B($I("$cyn")), $B($I("$cyt")), $B($I("$cym"))), $$->* $E($ CYAssign($V("$cyp"), $C1($V("object_getClass"), cys)))->* $E($ CYAssign(cyc, $C3($V("objc_allocateClassPair"), cys, $S(name_), $D(0))))->* $E($ CYAssign($V("$cym"), $C1($V("object_getClass"), cyc)))->* @@ -63,7 +63,7 @@ CYStatement *CYImplementation::Replace(CYContext &context) { messages_->Replace(context, false)->* $E($C1($V("objc_registerClassPair"), cyc))->* $ CYReturn(cyc) - ), super_ == NULL ? $ CYNull() : super_)); + ), extends_ == NULL ? $ CYNull() : extends_)); } CYStatement *CYImplementationField::Replace(CYContext &context) const { $T(NULL) @@ -97,8 +97,8 @@ CYStatement *CYMessage::Replace(CYContext &context, bool replace) const { $T(NUL $E($C4($V(replace ? "class_replaceMethod" : "class_addMethod"), $V(instance_ ? "$cyc" : "$cym"), cyn, - $N2($V("Functor"), $F(NULL, $P2($L($I("self")), $L($I("_cmd")), parameters_->Parameters(context)), $$->* - $ CYVar($L1($L($I("$cyr"), $N2($V("objc_super"), self, _class))))->* + $N2($V("Functor"), $F(NULL, $P2($B($I("self")), $B($I("_cmd")), parameters_->Parameters(context)), $$->* + $ CYVar($B1($B($I("$cyr"), $N2($V("objc_super"), self, _class))))->* $ CYReturn($C1($M($F(NULL, NULL, code_.code_), $S("call")), self)) ), cyt), cyt @@ -112,7 +112,7 @@ CYExpression *CYMessage::TypeSignature(CYContext &context) const { CYFunctionParameter *CYMessageParameter::Parameters(CYContext &context) const { $T(NULL) CYFunctionParameter *next(next_->Parameters(context)); - return type_ == NULL ? next : $ CYFunctionParameter($ CYDeclaration(type_->identifier_), next); + return type_ == NULL ? next : $ CYFunctionParameter($B(type_->identifier_), next); } CYSelector *CYMessageParameter::Selector(CYContext &context) const { @@ -121,7 +121,7 @@ CYSelector *CYMessageParameter::Selector(CYContext &context) const { CYSelectorPart *CYMessageParameter::SelectorPart(CYContext &context) const { $T(NULL) CYSelectorPart *next(next_->SelectorPart(context)); - return tag_ == NULL ? next : $ CYSelectorPart(tag_, type_ != NULL, next); + return name_ == NULL ? next : $ CYSelectorPart(name_, type_ != NULL, next); } CYExpression *CYMessageParameter::TypeSignature(CYContext &context) const { @@ -146,7 +146,7 @@ CYStatement *CYProtocol::Replace(CYContext &context) const { $T(NULL) } CYTarget *CYSelector::Replace(CYContext &context) { - return $C1($V("sel_registerName"), name_->Replace(context)); + return $C1($V("sel_registerName"), parts_->Replace(context)); } CYString *CYSelectorPart::Replace(CYContext &context) { diff --git a/ObjectiveC/Syntax.hpp b/ObjectiveC/Syntax.hpp index aa55a42..16927ac 100644 --- a/ObjectiveC/Syntax.hpp +++ b/ObjectiveC/Syntax.hpp @@ -97,10 +97,10 @@ struct CYSelectorPart : struct CYSelector : CYLiteral { - CYSelectorPart *name_; + CYSelectorPart *parts_; - CYSelector(CYSelectorPart *name) : - name_(name) + CYSelector(CYSelectorPart *parts) : + parts_(parts) { } @@ -128,11 +128,11 @@ struct CYImplementationField : struct CYMessageParameter : CYNext { - CYWord *tag_; + CYWord *name_; CYTypedIdentifier *type_; - CYMessageParameter(CYWord *tag, CYTypedIdentifier *type) : - tag_(tag), + CYMessageParameter(CYWord *name, CYTypedIdentifier *type) : + name_(name), type_(type) { } @@ -151,10 +151,10 @@ struct CYMessage : CYMessageParameter *parameters_; CYBlock code_; - CYMessage(bool instance, CYTypedIdentifier *type, CYMessageParameter *parameter, CYStatement *code) : + CYMessage(bool instance, CYTypedIdentifier *type, CYMessageParameter *parameters, CYStatement *code) : instance_(instance), type_(type), - parameters_(parameter), + parameters_(parameters), code_(code) { } @@ -185,14 +185,14 @@ struct CYImplementation : CYStatement { CYIdentifier *name_; - CYExpression *super_; + CYExpression *extends_; CYProtocol *protocols_; CYImplementationField *fields_; CYMessage *messages_; - CYImplementation(CYIdentifier *name, CYExpression *super, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) : + CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) : name_(name), - super_(super), + extends_(extends), protocols_(protocols), fields_(fields), messages_(messages) diff --git a/Output.cpp b/Output.cpp index 22e2149..2125d75 100644 --- a/Output.cpp +++ b/Output.cpp @@ -253,8 +253,8 @@ void CYContinue::Output(CYOutput &out, CYFlags flags) const { void CYClause::Output(CYOutput &out) const { out << '\t'; - if (case_ != NULL) - out << "case" << ' ' << *case_; + if (value_ != NULL) + out << "case" << ' ' << *value_; else out << "default"; out << ':' << '\n'; @@ -268,35 +268,35 @@ void CYDebugger::Output(CYOutput &out, CYFlags flags) const { out << "debugger" << ';'; } -void CYDeclaration::Output(CYOutput &out, CYFlags flags) const { +void CYBinding::Output(CYOutput &out, CYFlags flags) const { out << *identifier_; //out.out_ << ':' << identifier_->usage_ << '#' << identifier_->offset_; - if (initialiser_ != NULL) { + if (initializer_ != NULL) { out << ' ' << '=' << ' '; - initialiser_->Output(out, CYAssign::Precedence_, CYRight(flags)); + initializer_->Output(out, CYAssign::Precedence_, CYRight(flags)); } } -void CYDeclarations::Output(CYOutput &out) const { +void CYBindings::Output(CYOutput &out) const { Output(out, CYNoFlags); } -void CYDeclarations::Output(CYOutput &out, CYFlags flags) const { - const CYDeclarations *declaration(this); +void CYBindings::Output(CYOutput &out, CYFlags flags) const { + const CYBindings *binding(this); bool first(true); for (;;) { - CYDeclarations *next(declaration->next_); + CYBindings *next(binding->next_); CYFlags jacks(first ? CYLeft(flags) : next == NULL ? CYRight(flags) : CYCenter(flags)); first = false; - declaration->declaration_->Output(out, jacks); + binding->binding_->Output(out, jacks); if (next == NULL) break; out << ',' << ' '; - declaration = next; + binding = next; } } @@ -382,8 +382,8 @@ void CYFinally::Output(CYOutput &out) const { void CYFor::Output(CYOutput &out, CYFlags flags) const { out << "for" << ' ' << '('; - if (initialiser_ != NULL) - initialiser_->Output(out, CYNoIn); + if (initializer_ != NULL) + initializer_->Output(out, CYNoIn); out.Terminate(); if (test_ != NULL) out << ' '; @@ -398,45 +398,45 @@ void CYFor::Output(CYOutput &out, CYFlags flags) const { void CYForLexical::Output(CYOutput &out, CYFlags flags) const { out << (constant_ ? "const" : "let") << ' '; - declaration_->Output(out, CYRight(flags)); + binding_->Output(out, CYRight(flags)); } void CYForIn::Output(CYOutput &out, CYFlags flags) const { out << "for" << ' ' << '('; - initialiser_->Output(out, CYNoIn | CYNoRightHand); - out << ' ' << "in" << ' ' << *set_ << ')'; + initializer_->Output(out, CYNoIn | CYNoRightHand); + out << ' ' << "in" << ' ' << *iterable_ << ')'; code_->Single(out, CYRight(flags), CYCompactShort); } void CYForInitialized::Output(CYOutput &out, CYFlags flags) const { out << "for" << ' ' << '(' << "var" << ' '; - declaration_->Output(out, CYNoIn | CYNoRightHand); - out << ' ' << "in" << ' ' << *set_ << ')'; + binding_->Output(out, CYNoIn | CYNoRightHand); + out << ' ' << "in" << ' ' << *iterable_ << ')'; code_->Single(out, CYRight(flags), CYCompactShort); } void CYForInComprehension::Output(CYOutput &out) const { out << "for" << ' ' << '('; - declaration_->Output(out, CYNoIn | CYNoRightHand); - out << ' ' << "in" << ' ' << *set_ << ')'; + binding_->Output(out, CYNoIn | CYNoRightHand); + out << ' ' << "in" << ' ' << *iterable_ << ')'; } void CYForOf::Output(CYOutput &out, CYFlags flags) const { out << "for" << ' ' << '('; - initialiser_->Output(out, CYNoRightHand); - out << ' ' << "of" << ' ' << *set_ << ')'; + initializer_->Output(out, CYNoRightHand); + out << ' ' << "of" << ' ' << *iterable_ << ')'; code_->Single(out, CYRight(flags), CYCompactShort); } void CYForOfComprehension::Output(CYOutput &out) const { out << "for" << ' ' << '('; - declaration_->Output(out, CYNoRightHand); - out << ' ' << "of" << ' ' << *set_ << ')' << next_; + binding_->Output(out, CYNoRightHand); + out << ' ' << "of" << ' ' << *iterable_ << ')' << next_; } void CYForVariable::Output(CYOutput &out, CYFlags flags) const { out << "var" << ' '; - declaration_->Output(out, CYRight(flags)); + binding_->Output(out, CYRight(flags)); } void CYFunction::Output(CYOutput &out) const { @@ -467,7 +467,7 @@ void CYFunctionStatement::Output(CYOutput &out, CYFlags flags) const { } void CYFunctionParameter::Output(CYOutput &out) const { - initialiser_->Output(out, CYNoFlags); + binding_->Output(out, CYNoFlags); if (next_ != NULL) out << ',' << ' ' << *next_; } @@ -640,9 +640,9 @@ void CYTypeDefinition::Output(CYOutput &out, CYFlags flags) const { out << "typedef" << ' ' << *typed_; } -void CYLet::Output(CYOutput &out, CYFlags flags) const { +void CYLexical::Output(CYOutput &out, CYFlags flags) const { out << "let" << ' '; - declarations_->Output(out, flags); // XXX: flags + bindings_->Output(out, flags); // XXX: flags out << ';'; } @@ -930,7 +930,7 @@ void CYTypeVoid::Output(CYOutput &out) const { void CYVar::Output(CYOutput &out, CYFlags flags) const { out << "var" << ' '; - declarations_->Output(out, flags); // XXX: flags + bindings_->Output(out, flags); // XXX: flags out << ';'; } diff --git a/Parser.ypp.in b/Parser.ypp.in index 0c7b505..594dd52 100644 --- a/Parser.ypp.in +++ b/Parser.ypp.in @@ -45,13 +45,13 @@ %union { CYMember *access_; } %union { CYArgument *argument_; } %union { CYAssignment *assignment_; } +%union { CYBinding *binding_; } +%union { CYBindings *bindings_; } %union { CYBoolean *boolean_; } %union { CYClause *clause_; } %union { cy::Syntax::Catch *catch_; } %union { CYClassTail *classTail_; } %union { CYComprehension *comprehension_; } -%union { CYDeclaration *declaration_; } -%union { CYDeclarations *declarations_; } %union { CYElement *element_; } %union { CYExpression *expression_; } %union { CYFalse *false_; } @@ -481,13 +481,13 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type AssignmentExpressionOpt %type BindingIdentifier %type BindingIdentifierOpt -%type BindingList_ -%type BindingList +%type BindingList_ +%type BindingList %type BitwiseANDExpression %type Block %type BlockStatement %type BooleanLiteral -%type BindingElement +%type BindingElement %type BitwiseORExpression %type BitwiseXORExpression %type BreakStatement @@ -528,11 +528,11 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type ExpressionStatement_ %type ExpressionStatement %type Finally -%type ForBinding +%type ForBinding %type ForDeclaration %type ForInStatementInitializer %type ForStatementInitializer -%type FormalParameter +%type FormalParameter %type FormalParameterList_ %type FormalParameterList %type FormalParameters @@ -562,7 +562,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type LeftHandSideAssignment %type LeftHandSideExpression %type LetOrConst -%type LexicalBinding +%type LexicalBinding %type LexicalDeclaration_ %type LexicalDeclaration %type Literal @@ -584,7 +584,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type PropertyDefinitionList_ %type PropertyDefinitionList %type PropertyDefinitionListOpt -%type PropertySetParameterList +%type PropertySetParameterList %type RegularExpressionLiteral %type RegularExpressionSlash %type RelationalExpression @@ -598,7 +598,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type ScriptBody %type ScriptBodyOpt %type ShiftExpression -%type SingleNameBinding +%type SingleNameBinding %type Statement__ %type Statement_ %type Statement @@ -615,9 +615,9 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type TryStatement %type UnaryExpression_ %type UnaryExpression -%type VariableDeclaration -%type VariableDeclarationList_ -%type VariableDeclarationList +%type VariableDeclaration +%type VariableDeclarationList_ +%type VariableDeclarationList %type VariableStatement_ %type VariableStatement %type WithStatement @@ -690,8 +690,8 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type AttributeIdentifier /* XXX: %type DefaultXMLNamespaceStatement */ %type PropertyIdentifier -%type XMLListInitialiser -%type XMLInitialiser +%type XMLListInitilizer +%type XMLInitilizer @end /* }}} */ /* Token Priorities {{{ */ @@ -767,7 +767,7 @@ Var_ /* 11.6 Names and Keywords {{{ */ IdentifierName - : Word { $$ = $1; } + : Word[pass] { $$ = $pass; } | "for" { $$ = CYNew CYWord("for"); } | "in" { $$ = CYNew CYWord("in"); } | "instanceof" { $$ = CYNew CYWord("instanceof"); } @@ -779,7 +779,7 @@ NewLineOpt ; Word - : IdentifierNoOf { $$ = $1; } + : IdentifierNoOf[pass] { $$ = $pass; } | "auto" { $$ = CYNew CYWord("auto"); } | "break" { $$ = CYNew CYWord("break"); } | "case" { $$ = CYNew CYWord("case"); } @@ -824,7 +824,7 @@ Word @begin ObjectiveC WordOpt - : Word { $$ = $1; } + : Word[pass] { $$ = $pass; } | { $$ = NULL; } ; @end @@ -847,7 +847,7 @@ RegularExpressionSlash ; RegularExpressionLiteral - : RegularExpressionSlash { CYMPT(@$); driver.SetRegEx($1); } RegularExpressionLiteral_ { $$ = $3; } + : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; } ; /* }}} */ @@ -863,7 +863,7 @@ TerminatorSoft Terminator : ";" - | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) CYERR(@1, "required semi-colon"); else CYEOK(); } StrictSemi + | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi ; TerminatorOpt @@ -874,28 +874,28 @@ TerminatorOpt /* 12.1 Identifiers {{{ */ IdentifierReference - : Identifier { $$ = CYNew CYVariable($1); } + : Identifier[pass] { $$ = CYNew CYVariable($pass); } | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); } ; BindingIdentifier - : IdentifierNoOf { $$ = $1; } + : IdentifierNoOf[pass] { $$ = $pass; } | "!of" { $$ = CYNew CYIdentifier("of"); } | "yield" { $$ = CYNew CYIdentifier("yield"); } ; BindingIdentifierOpt - : BindingIdentifier { $$ = $1; } + : BindingIdentifier[pass] { $$ = $pass; } | { $$ = NULL; } ; LabelIdentifier - : Identifier { $$ = $1; } + : Identifier[pass] { $$ = $pass; } | "yield" { $$ = CYNew CYIdentifier("yield"); } ; IdentifierTypeNoOf - : Identifier_ { $$ = $1; } + : Identifier_[pass] { $$ = $pass; } | "abstract" { $$ = CYNew CYIdentifier("abstract"); } | "await" { $$ = CYNew CYIdentifier("await"); } | "boolean" { $$ = CYNew CYIdentifier("boolean"); } @@ -935,7 +935,7 @@ IdentifierTypeNoOf ; IdentifierType - : IdentifierTypeNoOf { $$ = $1; } + : IdentifierTypeNoOf[pass] { $$ = $pass; } | "of" { $$ = CYNew CYIdentifier("of"); } ; @@ -962,28 +962,28 @@ IdentifierNoOf ; Identifier - : IdentifierNoOf { $$ = $1; } + : IdentifierNoOf[pass] { $$ = $pass; } | "of" { $$ = CYNew CYIdentifier("of"); } ; /* }}} */ /* 12.2 Primary Expression {{{ */ PrimaryExpression : "this" { $$ = CYNew CYThis(); } - | IdentifierReference { $$ = $1; } - | Literal { $$ = $1; } - | ArrayLiteral { $$ = $1; } - | ObjectLiteral { $$ = $1; } - | FunctionExpression { $$ = $1; } - | ClassExpression { $$ = $1; } - | GeneratorExpression { $$ = $1; } - | RegularExpressionLiteral { $$ = $1; } - | TemplateLiteral { $$ = $1; } - | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; } + | IdentifierReference[pass] { $$ = $pass; } + | Literal[pass] { $$ = $pass; } + | ArrayLiteral[pass] { $$ = $pass; } + | ObjectLiteral[pass] { $$ = $pass; } + | FunctionExpression[pass] { $$ = $pass; } + | ClassExpression[pass] { $$ = $pass; } + | GeneratorExpression[pass] { $$ = $pass; } + | RegularExpressionLiteral[pass] { $$ = $pass; } + | TemplateLiteral[pass] { $$ = $pass; } + | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; } | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; } ; CoverParenthesizedExpressionAndArrowParameterList - : "(" Expression ")" { $$ = CYNew CYParenthetical($2); } + : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); } | "(" LexSetRegExp ")" { $$ = NULL; } | "(" LexSetRegExp "..." BindingIdentifier ")" { CYNOT(@$); } | "(" Expression "," LexSetRegExp "..." BindingIdentifier ")" { CYNOT(@$); } @@ -991,67 +991,67 @@ CoverParenthesizedExpressionAndArrowParameterList /* }}} */ /* 12.2.4 Literals {{{ */ Literal - : NullLiteral { $$ = $1; } - | BooleanLiteral { $$ = $1; } - | NumericLiteral { $$ = $1; } - | StringLiteral { $$ = $1; } + : NullLiteral[pass] { $$ = $pass; } + | BooleanLiteral[pass] { $$ = $pass; } + | NumericLiteral[pass] { $$ = $pass; } + | StringLiteral[pass] { $$ = $pass; } ; /* }}} */ /* 12.2.5 Array Initializer {{{ */ ArrayLiteral - : "[" ElementListOpt "]" { $$ = CYNew CYArray($2); } + : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); } ; ElementList - : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); } - | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); } - | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); } + : AssignmentExpressionOpt[value] "," ElementListOpt[next] { $$ = CYNew CYElementValue($value, $next); } + | LexSetRegExp "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); } + | AssignmentExpression[value] { $$ = CYNew CYElementValue($value, NULL); } ; ElementListOpt - : ElementList { $$ = $1; } + : ElementList[pass] { $$ = $pass; } | LexSetRegExp { $$ = NULL; } ; /* }}} */ /* 12.2.6 Object Initializer {{{ */ ObjectLiteral - : BRACE PropertyDefinitionListOpt "}" { $$ = CYNew CYObject($2); } + : BRACE PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); } ; PropertyDefinitionList_ - : "," PropertyDefinitionListOpt { $$ = $2; } + : "," PropertyDefinitionListOpt[properties] { $$ = $properties; } | { $$ = NULL; } ; PropertyDefinitionList - : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; } + : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; } ; PropertyDefinitionListOpt - : LexSetRegExp PropertyDefinitionList { $$ = $2; } + : LexSetRegExp PropertyDefinitionList[properties] { $$ = $properties; } | LexSetRegExp { $$ = NULL; } ; PropertyDefinition - : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); } - | CoverInitializedName { CYNOT(@$); } - | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); } - | MethodDefinition { $$ = $1; } + : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); } + | CoverInitializedName[name] { CYNOT(@$); } + | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); } + | MethodDefinition[pass] { $$ = $pass; } ; PropertyName - : LiteralPropertyName { $$ = $1; } - | ComputedPropertyName { $$ = $1; } + : LiteralPropertyName[pass] { $$ = $pass; } + | ComputedPropertyName[pass] { $$ = $pass; } ; LiteralPropertyName - : IdentifierName { $$ = $1; } - | StringLiteral { $$ = $1; } - | NumericLiteral { $$ = $1; } + : IdentifierName[pass] { $$ = $pass; } + | StringLiteral[pass] { $$ = $pass; } + | NumericLiteral[pass] { $$ = $pass; } ; ComputedPropertyName - : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); } + : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); } ; CoverInitializedName @@ -1059,45 +1059,45 @@ CoverInitializedName ; Initializer - : "=" AssignmentExpression { $$ = $2; } + : "=" AssignmentExpression[initializer] { $$ = $initializer; } ; InitializerOpt - : Initializer { $$ = $1; } + : Initializer[pass] { $$ = $pass; } | { $$ = NULL; } ; /* }}} */ /* 12.2.9 Template Literals {{{ */ TemplateLiteral - : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); } - | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); } + : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); } + | TemplateHead[string] TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); } ; TemplateSpans - : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); } - | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); } + : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); } + | Expression[value] TemplateTail[string] { $$ = CYNew CYSpan($value, $string, NULL); } ; /* }}} */ /* 12.3 Left-Hand-Side Expressions {{{ */ MemberAccess - : "[" Expression "]" { $$ = CYNew CYDirectMember(NULL, $2); } - | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); } + : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); } + | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); } | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; } | TemplateLiteral { CYNOT(@$); } ; MemberExpression - : LexSetRegExp PrimaryExpression { $$ = $2; } - | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; } - | SuperProperty { $$ = $1; } + : LexSetRegExp PrimaryExpression[pass] { $$ = $pass; } + | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; } + | SuperProperty[pass] { $$ = $pass; } | MetaProperty { CYNOT(@$); } - | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); } + | LexSetRegExp "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); } ; SuperProperty - : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); } - | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); } + : LexSetRegExp "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); } + | LexSetRegExp "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); } ; MetaProperty @@ -1109,52 +1109,52 @@ NewTarget ; NewExpression - : MemberExpression { $$ = $1; } - | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); } + : MemberExpression[pass] { $$ = $pass; } + | LexSetRegExp "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); } ; CallExpression_ - : MemberExpression { $$ = $1; } - | CallExpression { $$ = $1; } + : MemberExpression[pass] { $$ = $pass; } + | CallExpression[pass] { $$ = $pass; } ; CallExpression - : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); } - | SuperCall { $$ = $1; } - | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; } + : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); } + | SuperCall[pass] { $$ = $pass; } + | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; } ; SuperCall - : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); } + : LexSetRegExp "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); } ; Arguments - : "(" ArgumentListOpt ")" { $$ = $2; } + : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; } ; ArgumentList_ - : "," ArgumentList { $$ = $2; } + : "," ArgumentList[arguments] { $$ = $arguments; } | { $$ = NULL; } ; ArgumentList - : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); } + : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); } | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); } ; ArgumentListOpt - : ArgumentList { $$ = $1; } + : ArgumentList[pass] { $$ = $pass; } | LexSetRegExp { $$ = NULL; } ; AccessExpression - : NewExpression { $$ = $1; } - | CallExpression { $$ = $1; } + : NewExpression[pass] { $$ = $pass; } + | CallExpression[pass] { $$ = $pass; } ; LeftHandSideExpression - : AccessExpression LexCrement { $$ = $1; } - | LexSetRegExp IndirectExpression { $$ = $2; } + : AccessExpression[pass] LexCrement { $$ = $pass; } + | LexSetRegExp IndirectExpression[pass] { $$ = $pass; } ; /* }}} */ /* 12.4 Postfix Expressions {{{ */ @@ -1163,241 +1163,241 @@ LexCrement ; PostfixExpression - : AccessExpression LexCrement { $$ = $1; } - | AccessExpression LexCrement "++" { $$ = CYNew CYPostIncrement($1); } - | AccessExpression LexCrement "--" { $$ = CYNew CYPostDecrement($1); } + : AccessExpression[lhs] LexCrement { $$ = $lhs; } + | AccessExpression[lhs] LexCrement "++" { $$ = CYNew CYPostIncrement($lhs); } + | AccessExpression[lhs] LexCrement "--" { $$ = CYNew CYPostDecrement($lhs); } ; /* }}} */ /* 12.5 Unary Operators {{{ */ UnaryExpression_ - : "delete" UnaryExpression { $$ = CYNew CYDelete($2); } - | "void" UnaryExpression { $$ = CYNew CYVoid($2); } - | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); } - | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); } - | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); } - | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); } - | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); } - | "+" UnaryExpression { $$ = CYNew CYAffirm($2); } - | "-" UnaryExpression { $$ = CYNew CYNegate($2); } - | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); } - | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); } + : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); } + | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); } + | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); } + | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); } + | "\n++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); } + | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); } + | "\n--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); } + | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); } + | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); } + | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); } + | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); } ; UnaryExpression - : PostfixExpression LexOpenBrace { $$ = $1; } - | LexSetRegExp UnaryExpression_ { $$ = $2; } + : PostfixExpression[expression] LexOpenBrace { $$ = $expression; } + | LexSetRegExp UnaryExpression_[pass] { $$ = $pass; } ; /* }}} */ /* 12.6 Multiplicative Operators {{{ */ MultiplicativeExpression - : UnaryExpression { $$ = $1; } - | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); } - | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); } - | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); } + : UnaryExpression[pass] { $$ = $pass; } + | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); } + | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); } + | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); } ; /* }}} */ /* 12.7 Additive Operators {{{ */ AdditiveExpression - : MultiplicativeExpression { $$ = $1; } - | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); } - | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); } + : MultiplicativeExpression[pass] { $$ = $pass; } + | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); } + | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); } ; /* }}} */ /* 12.8 Bitwise Shift Operators {{{ */ ShiftExpression - : AdditiveExpression { $$ = $1; } - | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); } - | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); } - | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); } + : AdditiveExpression[pass] { $$ = $pass; } + | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); } + | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); } + | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); } ; /* }}} */ /* 12.9 Relational Operators {{{ */ RelationalExpression - : ShiftExpression { $$ = $1; } - | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); } - | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); } - | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); } - | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); } - | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); } - | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); } + : ShiftExpression[pass] { $$ = $pass; } + | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); } + | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); } + | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); } + | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); } + | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); } + | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); } ; /* }}} */ /* 12.10 Equality Operators {{{ */ EqualityExpression - : RelationalExpression { $$ = $1; } - | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); } - | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); } - | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); } - | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); } + : RelationalExpression[pass] { $$ = $pass; } + | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); } + | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); } + | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); } + | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); } ; /* }}} */ /* 12.11 Binary Bitwise Operators {{{ */ BitwiseANDExpression - : EqualityExpression { $$ = $1; } - | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); } + : EqualityExpression[pass] { $$ = $pass; } + | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); } ; BitwiseXORExpression - : BitwiseANDExpression { $$ = $1; } - | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); } + : BitwiseANDExpression[pass] { $$ = $pass; } + | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); } ; BitwiseORExpression - : BitwiseXORExpression { $$ = $1; } - | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); } + : BitwiseXORExpression[pass] { $$ = $pass; } + | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); } ; /* }}} */ /* 12.12 Binary Logical Operators {{{ */ LogicalANDExpression - : BitwiseORExpression { $$ = $1; } - | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); } + : BitwiseORExpression[pass] { $$ = $pass; } + | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); } ; LogicalORExpression - : LogicalANDExpression { $$ = $1; } - | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); } + : LogicalANDExpression[pass] { $$ = $pass; } + | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); } ; /* }}} */ /* 12.13 Conditional Operator ( ? : ) {{{ */ @begin ObjectiveC ConditionalExpressionClassic - : LogicalORExpression { $$ = $1; } - | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); } + : LogicalORExpression[pass] { $$ = $pass; } + | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); } ; @end ConditionalExpression - : LogicalORExpression { $$ = $1; } - | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); } + : LogicalORExpression[pass] { $$ = $pass; } + | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); } ; /* }}} */ /* 12.14 Assignment Operators {{{ */ LeftHandSideAssignment - : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); } - | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); } - | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); } - | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); } - | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); } - | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); } - | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); } - | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); } - | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); } - | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); } - | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); } - | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); } + : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); } + | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); } ; @begin ObjectiveC AssignmentExpressionClassic - : ConditionalExpressionClassic { $$ = $1; } - | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; } + : ConditionalExpressionClassic[pass] { $$ = $pass; } + | LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; } ; @end AssignmentExpression - : ConditionalExpression { $$ = $1; } - | LexSetRegExp YieldExpression { $$ = $2; } - | ArrowFunction { $$ = $1; } - | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; } + : ConditionalExpression[pass] { $$ = $pass; } + | LexSetRegExp YieldExpression[pass] { $$ = $pass; } + | ArrowFunction[pass] { $$ = $pass; } + | LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; } ; AssignmentExpressionOpt - : AssignmentExpression { $$ = $1; } + : AssignmentExpression[pass] { $$ = $pass; } | LexSetRegExp { $$ = NULL; } ; /* }}} */ /* 12.15 Comma Operator ( , ) {{{ */ Expression - : AssignmentExpression { $$ = $1; } - | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); } + : AssignmentExpression[pass] { $$ = $pass; } + | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); } ; ExpressionOpt - : Expression { $$ = $1; } + : Expression[pass] { $$ = $pass; } | LexSetRegExp { $$ = NULL; } ; /* }}} */ /* 13 Statements and Declarations {{{ */ Statement__ - : BlockStatement { $$ = $1; } - | VariableStatement { $$ = $1; } - | EmptyStatement { $$ = $1; } - | IfStatement { $$ = $1; } - | BreakableStatement { $$ = $1; } - | ContinueStatement { $$ = $1; } - | BreakStatement { $$ = $1; } - | ReturnStatement { $$ = $1; } - | WithStatement { $$ = $1; } - | LabelledStatement { $$ = $1; } - | ThrowStatement { $$ = $1; } - | TryStatement { $$ = $1; } - | DebuggerStatement { $$ = $1; } + : BlockStatement[pass] { $$ = $pass; } + | VariableStatement[pass] { $$ = $pass; } + | EmptyStatement[pass] { $$ = $pass; } + | IfStatement[pass] { $$ = $pass; } + | BreakableStatement[pass] { $$ = $pass; } + | ContinueStatement[pass] { $$ = $pass; } + | BreakStatement[pass] { $$ = $pass; } + | ReturnStatement[pass] { $$ = $pass; } + | WithStatement[pass] { $$ = $pass; } + | LabelledStatement[pass] { $$ = $pass; } + | ThrowStatement[pass] { $$ = $pass; } + | TryStatement[pass] { $$ = $pass; } + | DebuggerStatement[pass] { $$ = $pass; } ; Statement_ - : LexSetRegExp Statement__ { $$ = $2; } - | ExpressionStatement { $$ = $1; } + : LexSetRegExp Statement__[pass] { $$ = $pass; } + | ExpressionStatement[pass] { $$ = $pass; } ; Statement - : LexSetStatement LexLet Statement_ { $$ = $3; } + : LexSetStatement LexLet Statement_[pass] { $$ = $pass; } ; Declaration__ - : HoistableDeclaration { $$ = $1; } - | ClassDeclaration { $$ = $1; } + : HoistableDeclaration[pass] { $$ = $pass; } + | ClassDeclaration[pass] { $$ = $pass; } ; Declaration_ - : LexLet LexSetRegExp Declaration__ { $$ = $3; } - | LexicalDeclaration { $$ = $1; } + : LexLet LexSetRegExp Declaration__[pass] { $$ = $pass; } + | LexicalDeclaration[pass] { $$ = $pass; } ; Declaration - : LexSetStatement Declaration_ { $$ = $2; } + : LexSetStatement Declaration_[pass] { $$ = $pass; } ; HoistableDeclaration - : FunctionDeclaration { $$ = $1; } - | GeneratorDeclaration { $$ = $1; } + : FunctionDeclaration[pass] { $$ = $pass; } + | GeneratorDeclaration[pass] { $$ = $pass; } ; BreakableStatement - : IterationStatement { $$ = $1; } - | SwitchStatement { $$ = $1; } + : IterationStatement[pass] { $$ = $pass; } + | SwitchStatement[pass] { $$ = $pass; } ; /* }}} */ /* 13.2 Block {{{ */ BlockStatement - : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); } + : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); } ; Block - : BRACE StatementListOpt "}" { $$ = $2; } + : BRACE StatementListOpt[code] "}" { $$ = $code; } ; StatementList - : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; } + : StatementListItem[statement] StatementListOpt[next] { $statement->SetNext($next); $$ = $statement; } ; StatementListOpt - : StatementList { $$ = $1; } + : StatementList[pass] { $$ = $pass; } | LexSetStatement LexLet LexSetRegExp { $$ = NULL; } ; StatementListItem - : Statement { $$ = $1; } - | Declaration { $$ = $1; } + : Statement[pass] { $$ = $pass; } + | Declaration[pass] { $$ = $pass; } ; /* }}} */ /* 13.3 Let and Const Declarations {{{ */ LexicalDeclaration_ - : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); } + : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); } ; LexicalDeclaration - : LexicalDeclaration_ Terminator { $$ = $1; } + : LexicalDeclaration_[statement] Terminator { $$ = $statement; } ; LexLet @@ -1418,40 +1418,40 @@ LetOrConst ; BindingList_ - : "," LexBind BindingList { $$ = $3; } + : "," LexBind BindingList[bindings] { $$ = $bindings; } | { $$ = NULL; } ; BindingList - : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); } + : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); } ; LexicalBinding - : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); } - | BindingPattern Initializer { CYNOT(@1); } + : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); } + | BindingPattern Initializer { CYNOT(@$); } ; /* }}} */ /* 13.3.2 Variable Statement {{{ */ VariableStatement_ - : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); } + : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); } ; VariableStatement - : VariableStatement_ Terminator { $$ = $1; } + : VariableStatement_[statement] Terminator { $$ = $statement; } ; VariableDeclarationList_ - : "," VariableDeclarationList { $$ = $2; } + : "," VariableDeclarationList[bindings] { $$ = $bindings; } | { $$ = NULL; } ; VariableDeclarationList - : LexBind VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($2, $3); } + : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); } ; VariableDeclaration - : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); } - | BindingPattern Initializer { CYNOT(@1); } + : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); } + | BindingPattern Initializer { CYNOT(@$); } ; /* }}} */ /* 13.3.3 Destructuring Binding Patterns {{{ */ @@ -1488,12 +1488,12 @@ BindingProperty ; BindingElement - : LexBind SingleNameBinding { $$ = $2; } - | LexBind BindingPattern InitializerOpt { CYNOT(@$); } + : LexBind SingleNameBinding[pass] { $$ = $pass; } + | LexBind BindingPattern InitializerOpt[initializer] { CYNOT(@$); } ; SingleNameBinding - : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); } + : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); } ; BindingRestElement @@ -1507,53 +1507,53 @@ EmptyStatement /* }}} */ /* 13.5 Expression Statement {{{ */ ExpressionStatement_ - : Expression { $$ = CYNew CYExpress($1); } + : Expression[expression] { $$ = CYNew CYExpress($[expression]); } ExpressionStatement - : ExpressionStatement_ Terminator { $$ = $1; } + : ExpressionStatement_[statement] Terminator { $$ = $statement; } ; /* }}} */ /* 13.6 The if Statement {{{ */ ElseStatementOpt - : "else" Statement { $$ = $2; } + : "else" Statement[false] { $$ = $false; } | %prec "if" { $$ = NULL; } ; IfStatement - : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); } + : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); } ; /* }}} */ /* 13.7 Iteration Statements {{{ */ IterationStatement - : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); } - | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); } - | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); } - | "for" "(" LexPushInOn LexLet LexSetRegExp Var_ LexBind BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($8, $9), $12, $14); } - | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); } - | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); } + : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); } + | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); } + | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); } + | "for" "(" LexPushInOn LexLet LexSetRegExp Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); } + | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); } + | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); } ; ForStatementInitializer - : LexLet LexSetRegExp EmptyStatement { $$ = $3; } - | LexLet ExpressionStatement_ ";" { $$ = $2; } - | LexLet LexSetRegExp VariableStatement_ ";" { $$ = $3; } - | LexicalDeclaration_ ";" { $$ = $1; } + : LexLet LexSetRegExp EmptyStatement[pass] { $$ = $pass; } + | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; } + | LexLet LexSetRegExp VariableStatement_[initializer] ";" { $$ = $initializer; } + | LexicalDeclaration_[initializer] ";" { $$ = $initializer; } ; ForInStatementInitializer - : LexLet AccessExpression LexCrement { $$ = $2; } - | LexLet LexSetRegExp IndirectExpression { $$ = $3; } - | LexLet LexSetRegExp Var_ LexBind ForBinding { $$ = CYNew CYForVariable($5); } - | ForDeclaration { $$ = $1; } + : LexLet AccessExpression[pass] LexCrement { $$ = $pass; } + | LexLet LexSetRegExp IndirectExpression[pass] { $$ = $pass; } + | LexLet LexSetRegExp Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); } + | ForDeclaration[pass] { $$ = $pass; } ; ForDeclaration - : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); } + : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); } ; ForBinding - : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); } - | BindingPattern { CYNOT(@1); } + : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); } + | BindingPattern { CYNOT(@$); } ; /* }}} */ /* 13.8 The continue Statement {{{ */ @@ -1563,7 +1563,7 @@ Continue ContinueStatement : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); } - | Continue Identifier Terminator { $$ = CYNew CYContinue($2); } + | Continue Identifier[label] Terminator { $$ = CYNew CYContinue($label); } ; /* }}} */ /* 13.9 The break Statement {{{ */ @@ -1573,56 +1573,56 @@ Break BreakStatement : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); } - | Break Identifier Terminator { $$ = CYNew CYBreak($2); } + | Break Identifier[label] Terminator { $$ = CYNew CYBreak($label); } ; /* }}} */ /* 13.10 The return Statement {{{ */ Return - : "return" { if (!driver.return_.top()) CYERR(@1, "invalid return"); } LexNewLine + : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); } LexNewLine ; ReturnStatement : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); } - | Return Expression Terminator { $$ = CYNew CYReturn($2); } + | Return Expression[value] Terminator { $$ = CYNew CYReturn($value); } ; /* }}} */ /* 13.11 The with Statement {{{ */ WithStatement - : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); } + : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); } ; /* }}} */ /* 13.12 The switch Statement {{{ */ SwitchStatement - : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); } + : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); } ; CaseBlock - : BRACE CaseClausesOpt "}" { $$ = $2; } + : BRACE CaseClausesOpt[clauses] "}" { $$ = $clauses; } ; CaseClause - : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); } + : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); } ; CaseClausesOpt - : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } - | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } + : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; } + | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; } | { $$ = NULL; } ; // XXX: the standard makes certain you can only have one of these DefaultClause - : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); } + : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); } ; /* }}} */ /* 13.13 Labelled Statements {{{ */ LabelledStatement - : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); } + : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); } ; LabelledItem - : Statement { $$ = $1; } - | LexSetStatement LexLet LexSetRegExp FunctionDeclaration { $$ = $4; } + : Statement[pass] { $$ = $pass; } + | LexSetStatement LexLet LexSetRegExp FunctionDeclaration[pass] { $$ = $pass; } ; /* }}} */ /* 13.14 The throw Statement {{{ */ @@ -1631,27 +1631,27 @@ Throw ; ThrowStatement - : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); } - | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); } + : Throw[throw] LexSetRegExp TerminatorSoft { CYERR(@throw, "throw without exception"); } + | Throw Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); } ; /* }}} */ /* 13.15 The try Statement {{{ */ TryStatement - : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); } - | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); } - | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); } + : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); } + | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); } + | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); } ; Catch - : "catch" "(" LexBind CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($4, $6); } + : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); } ; Finally - : "finally" Block { $$ = CYNew CYFinally($2); } + : "finally" Block[code] { $$ = CYNew CYFinally($code); } ; CatchParameter - : BindingIdentifier { $$ = $1; } + : BindingIdentifier[pass] { $$ = $pass; } | BindingPattern { CYNOT(@$); } ; /* }}} */ @@ -1663,15 +1663,15 @@ DebuggerStatement /* 14.1 Function Definitions {{{ */ FunctionDeclaration - : ";function" LexOf BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($3, $5, $9); } + : ";function" LexOf BindingIdentifier[name] "(" FormalParameters[parameters] ")" BRACE LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); } ; FunctionExpression - : "function" LexOf BindingIdentifierOpt "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionExpression($3, $5, $9); } + : "function" LexOf BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" BRACE LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); } ; StrictFormalParameters - : FormalParameters { $$ = $1; } + : FormalParameters[pass] { $$ = $pass; } ; FormalParameters @@ -1680,13 +1680,13 @@ FormalParameters ; FormalParameterList_ - : "," FormalParameterList { $$ = $2; } + : "," FormalParameterList[parameters] { $$ = $parameters; } | { $$ = NULL; } ; FormalParameterList : LexBind FunctionRestParameter { CYNOT(@$); } - | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); } + | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); } ; FunctionRestParameter @@ -1694,15 +1694,15 @@ FunctionRestParameter ; FormalParameter - : BindingElement { $$ = $1; } + : BindingElement[pass] { $$ = $pass; } ; FunctionBody - : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; } + : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; } ; FunctionStatementList - : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; } + : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; } ; /* }}} */ /* 14.2 Arrow Function Definitions {{{ */ @@ -1711,46 +1711,46 @@ LexEqualRight ; ArrowFunction - : LexSetRegExp ArrowParameters LexEqualRight "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $6); } + : LexSetRegExp ArrowParameters[parameters] LexEqualRight "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); } ; ArrowParameters - : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); } - | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } } + : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); } + | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } } ; ConciseBody - : AssignmentExpression { $$ = CYNew CYReturn($1); } - | LexSetRegExp ";{" FunctionBody "}" { $$ = $3; } + : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); } + | LexSetRegExp ";{" FunctionBody[code] "}" { $$ = $code; } ; /* }}} */ /* 14.3 Method Definitions {{{ */ MethodDefinition - : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); } - | GeneratorMethod { $$ = $1; } - | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); } - | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); } + : PropertyName[name] "(" StrictFormalParameters[parameters] ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); } + | GeneratorMethod[pass] { $$ = $pass; } + | "get" PropertyName[name] "(" ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); } + | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); } ; PropertySetParameterList - : FormalParameter { $$ = $1; } + : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); } ; /* }}} */ /* 14.4 Generator Function Definitions {{{ */ GeneratorMethod - : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ } + : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ } ; GeneratorDeclaration - : ";function" LexOf "*" LexOf BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ } + : ";function" LexOf "*" LexOf BindingIdentifier[name] "(" FormalParameters[code] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ } ; GeneratorExpression - : "function" LexOf "*" LexOf BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ } + : "function" LexOf "*" LexOf BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ } ; GeneratorBody - : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; } + : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; } ; Yield @@ -1759,29 +1759,29 @@ Yield YieldExpression : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } - | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ } - | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ } + | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ } + | Yield LexSetRegExp YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ } ; /* }}} */ /* 14.5 Class Definitions {{{ */ ClassDeclaration - : ";class" LexOf BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($3, $4); } + : ";class" LexOf BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); } ; ClassExpression - : "class" LexOf BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($3, $4); } + : "class" LexOf BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); } ; ClassTail - : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; } + : ClassHeritageOpt[tail] { driver.class_.push($tail); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; } ; ClassHeritage - : "extends" AccessExpression { $$ = CYNew CYClassTail($2); } + : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); } ; ClassHeritageOpt - : ClassHeritage { $$ = $1; } + : ClassHeritage[pass] { $$ = $pass; } | { $$ = CYNew CYClassTail(NULL); } ; @@ -1804,23 +1804,23 @@ ClassElementListOpt ; ClassElement - : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; } - | "static" MethodDefinition { driver.class_.top()->static_->*$2; } + : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; } + | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; } | ";" ; /* }}} */ /* 15.1 Scripts {{{ */ Script - : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); } + : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); } ; ScriptBody - : StatementList { $$ = $1; } + : StatementList[pass] { $$ = $pass; } ; ScriptBodyOpt - : ScriptBody { $$ = $1; } + : ScriptBody[pass] { $$ = $pass; } | LexSetStatement LexLet LexSetRegExp { $$ = NULL; } ; /* }}} */ @@ -1953,52 +1953,52 @@ ExportSpecifier @begin C /* Cycript (C): Type Encoding {{{ */ TypeSignifier - : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); } - | "(" "*" TypeQualifierRight ")" { $$ = $3; } + : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); } + | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; } ; SuffixedType - : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); } - | "(" "^" TypeQualifierRight ")" "(" TypedParameterListOpt ")" { $$ = $3; $$->modifier_ = CYNew CYTypeBlockWith($6, $$->modifier_); } - | TypeSignifier "(" TypedParameterListOpt ")" { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); } - | "(" TypedParameterListOpt ")" { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($2, $$->modifier_); } - | TypeSignifier { $$ = $1; } + : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); } + | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); } + | TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); } + | "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); } + | TypeSignifier[pass] { $$ = $pass; } | { $$ = CYNew CYTypedIdentifier(@$); } ; PrefixedType - : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); } + : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); } ; TypeQualifierLeft : { $$ = NULL; } - | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); } - | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); } + | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); } + | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); } ; TypeQualifierRight - : PrefixedType { $$ = $1; } - | SuffixedType { $$ = $1; } - | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); } - | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); } + : PrefixedType[pass] { $$ = $pass; } + | SuffixedType[pass] { $$ = $pass; } + | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); } + | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); } ; IntegerType : "int" { $$ = CYNew CYTypeVariable("int"); } - | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); } - | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); } - | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); } - | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); } + | "unsigned" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeUnsigned($specifier); } + | "signed" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeSigned($specifier); } + | "long" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeLong($specifier); } + | "short" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeShort($specifier); } ; IntegerTypeOpt - : IntegerType { $$ = $1; } + : IntegerType[pass] { $$ = $pass; } | { $$ = CYNew CYTypeVariable("int"); } ; PrimitiveType - : IdentifierType { $$ = CYNew CYTypeVariable($1); } - | IntegerType { $$ = $1; } + : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); } + | IntegerType[pass] { $$ = $pass; } | "void" { $$ = CYNew CYTypeVoid(); } | "char" { $$ = CYNew CYTypeVariable("char"); } | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); } @@ -2006,11 +2006,11 @@ PrimitiveType ; TypedIdentifier - : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; } + : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } ; PrimaryExpression - : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); } + : "@encode" "(" TypedIdentifier[typed] ")" { $$ = CYNew CYEncodedType($typed); } ; /* }}} */ @end @@ -2019,17 +2019,17 @@ PrimaryExpression /* Cycript (Objective-C): @class Declaration {{{ */ ClassSuperOpt /* XXX: why the hell did I choose MemberExpression? */ - : ":" LexSetRegExp MemberExpression { $$ = $3; } + : ":" LexSetRegExp MemberExpression[extends] { $$ = $extends; } | { $$ = NULL; } ; ImplementationFieldListOpt - : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); } + : LexSetRegExp TypedIdentifier[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); } | LexSetRegExp { $$ = NULL; } ; ImplementationFields - : BRACE ImplementationFieldListOpt "}" { $$ = $2; } + : BRACE ImplementationFieldListOpt[fields] "}" { $$ = $fields; } ; MessageScope @@ -2038,54 +2038,54 @@ MessageScope ; TypeOpt - : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; } + : "(" LexSetRegExp TypedIdentifier[type] ")" { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); $$ = $type; } | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); } ; MessageParameter - : Word ":" TypeOpt BindingIdentifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); } + : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); } ; MessageParameterList - : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; } + : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; } ; MessageParameterListOpt - : MessageParameterList { $$ = $1; } + : MessageParameterList[pass] { $$ = $pass; } | { $$ = NULL; } ; MessageParameters - : MessageParameterList { $$ = $1; } - | Word { $$ = CYNew CYMessageParameter($1, NULL); } + : MessageParameterList[pass] { $$ = $pass; } + | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); } ; ClassMessageDeclaration - : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); } + : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] BRACE LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); } ; ClassMessageDeclarationListOpt - : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; } + : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; } | { $$ = NULL; } ; // XXX: this should be AssignmentExpressionNoRight ClassProtocols - : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); } + : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); } ; ClassProtocolsOpt - : "," ClassProtocols { $$ = $2; } + : "," ClassProtocols[protocols] { $$ = $protocols; } | { $$ = NULL; } ; ClassProtocolListOpt - : "<" ClassProtocols ">" { $$ = $2; } + : "<" ClassProtocols[protocols] ">" { $$ = $protocols; } | { $$ = NULL; } ; ImplementationStatement - : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); } + : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] ImplementationFields[fields] ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); } ; CategoryName @@ -2093,92 +2093,92 @@ CategoryName ; CategoryStatement - : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); } + : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); } ; Statement__ - : ImplementationStatement { $$ = $1; } - | CategoryStatement { $$ = $1; } + : ImplementationStatement[pass] { $$ = $pass; } + | CategoryStatement[pass] { $$ = $pass; } ; /* }}} */ /* Cycript (Objective-C): Send Message {{{ */ VariadicCall - : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); } + : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); } | { $$ = NULL; } ; SelectorWordOpt - : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; } + : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; } | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; } ; SelectorCall_ - : SelectorCall { $$ = $1; } - | VariadicCall { $$ = $1; } + : SelectorCall[pass] { $$ = $pass; } + | VariadicCall[pass] { $$ = $pass; } ; SelectorCall - : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); } + : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); } ; SelectorList - : SelectorCall { $$ = $1; } - | Word { $$ = CYNew CYArgument($1, NULL); } + : SelectorCall[pass] { $$ = $pass; } + | Word[name] { $$ = CYNew CYArgument($name, NULL); } ; MessageExpression - : "[" AssignmentExpressionClassic { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($2, $4); } - | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = CYNew CYSendSuper($5); } + : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); } + | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); } ; SelectorExpression_ - : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); } + : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); } ; SelectorExpression - : SelectorExpression_ { $$ = $1; } - | Word { $$ = CYNew CYSelectorPart($1, false, NULL); } + : SelectorExpression_[pass] { $$ = $pass; } + | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); } ; SelectorExpressionOpt - : SelectorExpression_ { $$ = $1; } + : SelectorExpression_[pass] { $$ = $pass; } | { $$ = NULL; } ; PrimaryExpression - : MessageExpression { $$ = $1; } - | "@selector" "(" SelectorExpression ")" { $$ = CYNew CYSelector($3); } + : MessageExpression[pass] { $$ = $pass; } + | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); } ; /* }}} */ @end /* Cycript: @import Directive {{{ */ ModulePath - : ModulePath "." Word { $$ = CYNew CYModule($3, $1); } - | Word { $$ = CYNew CYModule($1); } + : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); } + | Word[part] { $$ = CYNew CYModule($part); } ; Declaration__ - : "@import" ModulePath { $$ = CYNew CYImport($2); } + : "@import" ModulePath[path] { $$ = CYNew CYImport($path); } ; /* }}} */ @begin ObjectiveC /* Cycript (Objective-C): Boxed Expressions {{{ */ BoxableExpression - : NullLiteral { $$ = $1; } - | BooleanLiteral { $$ = $1; } - | NumericLiteral { $$ = $1; } - | StringLiteral { $$ = $1; } - | ArrayLiteral { $$ = $1; } - | ObjectLiteral { $$ = $1; } - | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; } + : NullLiteral[pass] { $$ = $pass; } + | BooleanLiteral[pass] { $$ = $pass; } + | NumericLiteral[pass] { $$ = $pass; } + | StringLiteral[pass] { $$ = $pass; } + | ArrayLiteral[pass] { $$ = $pass; } + | ObjectLiteral[pass] { $$ = $pass; } + | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; } | "YES" { $$ = CYNew CYTrue(); } | "NO" { $$ = CYNew CYFalse(); } ; PrimaryExpression - : "@" BoxableExpression { $$ = CYNew CYBox($2); } + : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); } | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); } | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); } | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); } @@ -2188,12 +2188,12 @@ PrimaryExpression /* }}} */ /* Cycript (Objective-C): Block Expressions {{{ */ PrimaryExpression - : "^" TypedIdentifier { if ($2->identifier_ != NULL) CYERR($2->location_, "unexpected identifier"); } BRACE FunctionBody "}" { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $5); else CYERR($2->location_, "expected parameters"); } + : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } BRACE FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); } ; /* }}} */ /* Cycript (Objective-C): Instance Literals {{{ */ PrimaryExpression - : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); } + : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); } ; /* }}} */ @end @@ -2201,20 +2201,20 @@ PrimaryExpression @begin C /* Cycript (C): Pointer Indirection/Addressing {{{ */ UnaryExpression_ - : IndirectExpression { $$ = $1; } + : IndirectExpression[pass] { $$ = $pass; } ; IndirectExpression - : "*" UnaryExpression { $$ = CYNew CYIndirect($2); } + : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); } ; UnaryExpression_ - : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); } + : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); } ; MemberAccess - : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); } - | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); } + : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); } + | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); } | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; } ; /* }}} */ @@ -2225,31 +2225,31 @@ Var_ /* }}} */ /* Cycript (C): Lambda Expressions {{{ */ TypedParameterList_ - : "," TypedParameterList { $$ = $2; } + : "," TypedParameterList[parameters] { $$ = $parameters; } | { $$ = NULL; } ; TypedParameterList - : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); } + : TypedIdentifier[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); } ; TypedParameterListOpt - : TypedParameterList { $$ = $1; } + : TypedParameterList[pass] { $$ = $pass; } | { $$ = NULL; } ; PrimaryExpression - : "[" LexSetRegExp "&" LexSetRegExp "]" "(" TypedParameterListOpt ")" "->" TypedIdentifier BRACE FunctionBody "}" { $$ = CYNew CYLambda($10, $7, $12); } + : "[" LexSetRegExp "&" LexSetRegExp "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] BRACE FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); } ; /* }}} */ /* Cycript (C): Type Definitions {{{ */ Statement__ - : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); } + : "typedef" TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($typed); } ; /* }}} */ /* Cycript (C): extern "C" {{{ */ Statement__ - : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) CYERR(@2, "unknown extern binding"); } TypedIdentifier { if ($4->identifier_ == NULL) CYERR($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); } + : "extern" StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($abi, $typed); } ; /* }}} */ @@ -2305,8 +2305,8 @@ XMLMarkup /* 11.1 Primary Expressions {{{ */ PrimaryExpression : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); } - | XMLInitialiser { $$ = $1; } - | XMLListInitialiser { $$ = $1; } + | XMLInitilizer { $$ = $1; } + | XMLListInitilizer { $$ = $1; } ; PropertyIdentifier @@ -2346,7 +2346,7 @@ WildcardIdentifier ; /* }}} */ /* 11.1.4 XML Initializer {{{ */ -XMLInitialiser +XMLInitilizer : XMLMarkup { $$ = $1; } | XMLElement { $$ = $1; } ; @@ -2401,7 +2401,7 @@ XMLElementContentOpt ; /* }}} */ /* 11.1.5 XMLList Initializer {{{ */ -XMLListInitialiser +XMLListInitilizer : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "" LexPopIn { $$ = CYNew CYXMLList($4); } ; /* }}} */ @@ -2431,16 +2431,16 @@ Statement__ /* JavaScript FTL: Array Comprehensions {{{ */ Comprehension - : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); } + : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); } ; ComprehensionFor - : "for" "each" "(" LexPushInOn LexBind ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($6, $9); } + : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); } ; /* }}} */ /* JavaScript FTL: for each {{{ */ IterationStatement - : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); } + : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); } ; /* }}} */ @@ -2450,56 +2450,56 @@ PrimaryExpression ; ArrayComprehension - : "[" Comprehension "]" { $$ = $2; } + : "[" Comprehension[comprehension] "]" { $$ = $comprehension; } ; Comprehension - : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); } + : LexSetRegExp ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); } ; ComprehensionTail : { $$ = NULL; } - | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); } - | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); } + | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; } + | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; } ; ComprehensionFor - : "for" "(" LexPushInOn LexBind ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($5, $8); } - | "for" "(" LexPushInOn LexBind ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); } + : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); } + | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); } ; ComprehensionIf - : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); } + : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); } ; /* }}} */ /* JavaScript FTW: Coalesce Operator {{{ */ ConditionalExpression - : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); } + : LogicalORExpression[test] "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); } ; /* }}} */ /* JavaScript FTW: Named Arguments {{{ */ ArgumentList - : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); } + : LexSetRegExp Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); } ; /* }}} */ /* JavaScript FTW: Ruby Blocks {{{ */ RubyProcParameterList_ - : "," RubyProcParameterList { $$ = $2; } + : "," RubyProcParameterList[parameters] { $$ = $parameters; } | { $$ = NULL; } ; RubyProcParameterList - : BindingIdentifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); } + : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); } | { $$ = NULL; } ; RubyProcParameters - : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; } + : LexSetRegExp "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; } | LexSetRegExp "||" { $$ = NULL; } ; RubyProcParametersOpt - : RubyProcParameters { $$ = $1; } + : RubyProcParameters[pass] { $$ = $pass; } | LexSetRegExp { $$ = NULL; } ; @@ -2508,15 +2508,15 @@ LexOpenBrace ; RubyProcExpression - : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); } + : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); } ; PrimaryExpression - : BRACE RubyProcParameters StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); } + : BRACE RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); } ; PostfixExpression - : PostfixExpression LexOpenBrace RubyProcExpression { $$ = CYNew CYRubyBlock($1, $3); } + : PostfixExpression[lhs] LexOpenBrace RubyProcExpression[rhs] { $$ = CYNew CYRubyBlock($lhs, $rhs); } ; /* }}} */ diff --git a/Replace.cpp b/Replace.cpp index 2cb4474..d2704cb 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -109,7 +109,7 @@ CYTarget *CYArray::Replace(CYContext &context) { CYTarget *CYArrayComprehension::Replace(CYContext &context) { CYIdentifier *cyv(context.Unique()); - return $C0($F(NULL, $P1($L(cyv), comprehensions_->Parameters(context)), $$ + return $C0($F(NULL, $P1($B(cyv), comprehensions_->Parameters(context)), $$ ->* $E($ CYAssign($V(cyv), $ CYArray())) ->* comprehensions_->Replace(context, $E($C1($M($V(cyv), $S("push")), expression_))) ->* $ CYReturn($V(cyv)) @@ -183,13 +183,13 @@ CYTarget *CYClassExpression::Replace(CYContext &context) { context.super_ = old; - return $C1($ CYFunctionExpression(NULL, $P($L(super)), $$ - ->* $ CYVar($L1($L(constructor, tail_->constructor_))) - ->* $ CYVar($L1($L(prototype, $ CYFunctionExpression(NULL, NULL, NULL)))) + return $C1($ CYFunctionExpression(NULL, $P($B(super)), $$ + ->* $ CYVar($B1($B(constructor, tail_->constructor_))) + ->* $ CYVar($B1($B(prototype, $ CYFunctionExpression(NULL, NULL, NULL)))) ->* $E($ CYAssign($M($V(prototype), $S("prototype")), $M($V(super), $S("prototype")))) ->* $E($ CYAssign($V(prototype), $N($V(prototype)))) ->* CYDefineProperty($V(prototype), $S("constructor"), false, false, $ CYPropertyValue($S("value"), $V(constructor))) - ->* $ CYVar(builder.declarations_) + ->* $ CYVar(builder.bindings_) ->* builder.statements_ ->* CYDefineProperty($V(constructor), $S("prototype"), false, false, $ CYPropertyValue($S("value"), $V(prototype))) ->* $ CYReturn($V(constructor)) @@ -197,11 +197,11 @@ CYTarget *CYClassExpression::Replace(CYContext &context) { } CYStatement *CYClassStatement::Replace(CYContext &context) { - return $ CYVar($L1($L(name_, $ CYClassExpression(name_, tail_)))); + return $ CYVar($B1($B(name_, $ CYClassExpression(name_, tail_)))); } void CYClause::Replace(CYContext &context) { $T() - context.Replace(case_); + context.Replace(value_); context.ReplaceAll(code_); next_->Replace(context); } @@ -265,7 +265,7 @@ void CYContext::NonLocal(CYStatement *&statements) { CYIdentifier *unique(nextlocal_->identifier_->Replace(context, CYIdentifierGlobal)); CYStatement *declare( - $ CYVar($L1($L(unique, $ CYObject())))); + $ CYVar($B1($B(unique, $ CYObject())))); cy::Syntax::Catch *rescue( $ cy::Syntax::Catch(cye, $$ @@ -294,23 +294,23 @@ CYStatement *CYDebugger::Replace(CYContext &context) { return this; } -CYTarget *CYDeclaration::Target(CYContext &context) { +CYTarget *CYBinding::Target(CYContext &context) { return $V(identifier_); } -CYAssignment *CYDeclaration::Replace(CYContext &context, CYIdentifierKind kind) { +CYAssignment *CYBinding::Replace(CYContext &context, CYIdentifierKind kind) { identifier_ = identifier_->Replace(context, kind); - if (initialiser_ == NULL) + if (initializer_ == NULL) return NULL; - CYAssignment *value($ CYAssign(Target(context), initialiser_)); - initialiser_ = NULL; + CYAssignment *value($ CYAssign(Target(context), initializer_)); + initializer_ = NULL; return value; } -CYExpression *CYDeclarations::Replace(CYContext &context, CYIdentifierKind kind) { $T(NULL) - CYAssignment *assignment(declaration_->Replace(context, kind)); +CYExpression *CYBindings::Replace(CYContext &context, CYIdentifierKind kind) { $T(NULL) + CYAssignment *assignment(binding_->Replace(context, kind)); CYExpression *compound(next_->Replace(context, kind)); if (assignment != NULL) @@ -321,12 +321,12 @@ CYExpression *CYDeclarations::Replace(CYContext &context, CYIdentifierKind kind) return compound; } -CYFunctionParameter *CYDeclarations::Parameter(CYContext &context) { $T(NULL) - return $ CYFunctionParameter($ CYDeclaration(declaration_->identifier_), next_->Parameter(context)); +CYFunctionParameter *CYBindings::Parameter(CYContext &context) { $T(NULL) + return $ CYFunctionParameter($ CYBinding(binding_->identifier_), next_->Parameter(context)); } -CYArgument *CYDeclarations::Argument(CYContext &context) { $T(NULL) - return $ CYArgument(declaration_->initialiser_, next_->Argument(context)); +CYArgument *CYBindings::Argument(CYContext &context) { $T(NULL) + return $ CYArgument(binding_->initializer_, next_->Argument(context)); } CYTarget *CYDirectMember::Replace(CYContext &context) { @@ -409,7 +409,7 @@ void CYFinally::Replace(CYContext &context) { $T() CYStatement *CYFor::Replace(CYContext &context) { CYScope outer(true, context); - context.Replace(initialiser_); + context.Replace(initializer_); context.Replace(test_); @@ -427,83 +427,83 @@ CYStatement *CYFor::Replace(CYContext &context) { CYStatement *CYForLexical::Initialize(CYContext &context, CYExpression *value) { if (value == NULL) { - if (declaration_->initialiser_ == NULL) + if (binding_->initializer_ == NULL) return NULL; - value = declaration_->initialiser_; + value = binding_->initializer_; } - return $ CYLet(constant_, $L1($ CYDeclaration(declaration_->identifier_, value))); + return $ CYLexical(constant_, $B1($ CYBinding(binding_->identifier_, value))); } CYTarget *CYForLexical::Replace(CYContext &context) { - _assert(declaration_->Replace(context, CYIdentifierLexical) == NULL); - return declaration_->Target(context); + _assert(binding_->Replace(context, CYIdentifierLexical) == NULL); + return binding_->Target(context); } CYStatement *CYForIn::Replace(CYContext &context) { CYScope scope(true, context); - context.Replace(initialiser_); - context.Replace(set_); + context.Replace(initializer_); + context.Replace(iterable_); context.ReplaceAll(code_); scope.Close(context); return this; } CYStatement *CYForInitialized::Replace(CYContext &context) { - CYAssignment *assignment(declaration_->Replace(context, CYIdentifierVariable)); + CYAssignment *assignment(binding_->Replace(context, CYIdentifierVariable)); return $ CYBlock($$ ->* (assignment == NULL ? NULL : $ CYExpress(assignment)) - ->* $ CYForIn(declaration_->Target(context), set_, code_)); + ->* $ CYForIn(binding_->Target(context), iterable_, code_)); } CYFunctionParameter *CYForInComprehension::Parameter(CYContext &context) const { - return $ CYFunctionParameter(declaration_); + return $ CYFunctionParameter(binding_); } CYStatement *CYForInComprehension::Replace(CYContext &context, CYStatement *statement) const { - return $ CYForIn(declaration_->Target(context), set_, CYComprehension::Replace(context, statement)); + return $ CYForIn(binding_->Target(context), iterable_, CYComprehension::Replace(context, statement)); } CYStatement *CYForOf::Replace(CYContext &context) { CYIdentifier *item(context.Unique()), *list(context.Unique()); return $ CYBlock($$ - ->* initialiser_->Initialize(context, NULL) - ->* $ CYLet(false, $L2($L(list, set_), $L(item))) + ->* initializer_->Initialize(context, NULL) + ->* $ CYLexical(false, $B2($B(list, iterable_), $B(item))) ->* $ CYForIn($V(item), $V(list), $ CYBlock($$ - ->* initialiser_->Initialize(context, $M($V(list), $V(item))) + ->* initializer_->Initialize(context, $M($V(list), $V(item))) ->* code_ ))); } CYFunctionParameter *CYForOfComprehension::Parameter(CYContext &context) const { - return $ CYFunctionParameter(declaration_); + return $ CYFunctionParameter(binding_); } CYStatement *CYForOfComprehension::Replace(CYContext &context, CYStatement *statement) const { CYIdentifier *cys(context.Unique()); return $ CYBlock($$ - ->* $ CYLet(false, $L1($L(cys, set_))) - ->* $ CYForIn(declaration_->Target(context), $V(cys), $ CYBlock($$ - ->* $E($ CYAssign(declaration_->Target(context), $M($V(cys), declaration_->Target(context)))) + ->* $ CYLexical(false, $B1($B(cys, iterable_))) + ->* $ CYForIn(binding_->Target(context), $V(cys), $ CYBlock($$ + ->* $E($ CYAssign(binding_->Target(context), $M($V(cys), binding_->Target(context)))) ->* CYComprehension::Replace(context, statement) ))); } CYStatement *CYForVariable::Initialize(CYContext &context, CYExpression *value) { if (value == NULL) { - if (declaration_->initialiser_ == NULL) + if (binding_->initializer_ == NULL) return NULL; - value = declaration_->initialiser_; + value = binding_->initializer_; } - return $ CYVar($L1($ CYDeclaration(declaration_->identifier_, value))); + return $ CYVar($B1($ CYBinding(binding_->identifier_, value))); } CYTarget *CYForVariable::Replace(CYContext &context) { - _assert(declaration_->Replace(context, CYIdentifierVariable) == NULL); - return declaration_->Target(context); + _assert(binding_->Replace(context, CYIdentifierVariable) == NULL); + return binding_->Target(context); } // XXX: this is evil evil black magic. don't ask, don't tell... don't believe! @@ -572,13 +572,13 @@ CYTarget *CYFunctionExpression::Replace(CYContext &context) { } void CYFunctionParameter::Replace(CYContext &context, CYStatement *&statements) { $T() - CYAssignment *assignment(initialiser_->Replace(context, CYIdentifierArgument)); + CYAssignment *assignment(binding_->Replace(context, CYIdentifierArgument)); next_->Replace(context, statements); if (assignment != NULL) statements = $$ - ->* $ CYIf($ CYIdentical($ CYTypeOf(initialiser_->Target(context)), $S("undefined")), $$ + ->* $ CYIf($ CYIdentical($ CYTypeOf(binding_->Target(context)), $S("undefined")), $$ ->* $E(assignment)) ->* statements; } @@ -620,7 +620,7 @@ CYStatement *CYIfComprehension::Replace(CYContext &context, CYStatement *stateme } CYStatement *CYImport::Replace(CYContext &context) { - return $ CYVar($L1($L($I(module_->part_->Word()), $C1($V("require"), module_->Replace(context, "/"))))); + return $ CYVar($B1($B($I(module_->part_->Word()), $C1($V("require"), module_->Replace(context, "/"))))); } CYTarget *CYIndirect::Replace(CYContext &context) { @@ -646,8 +646,8 @@ CYTarget *CYLambda::Replace(CYContext &context) { return $N2($V("Functor"), $ CYFunctionExpression(NULL, parameters_->Parameters(context), code_), parameters_->TypeSignature(context, typed_->Replace(context))); } -CYForInitializer *CYLet::Replace(CYContext &context) { - if (CYExpression *expression = declarations_->Replace(context, CYIdentifierLexical)) +CYForInitializer *CYLexical::Replace(CYContext &context) { + if (CYExpression *expression = bindings_->Replace(context, CYIdentifierLexical)) return $E(expression); return $ CYEmpty(); } @@ -719,10 +719,10 @@ CYTarget *CYObject::Replace(CYContext &context) { properties_ = properties_->ReplaceAll(context, builder, $ CYThis(), false); if (builder) { - return $C1($M($ CYFunctionExpression(NULL, builder.declarations_->Parameter(context), + return $C1($M($ CYFunctionExpression(NULL, builder.bindings_->Parameter(context), builder.statements_ ->* $ CYReturn($ CYThis()) - ), $S("call")), this, builder.declarations_->Argument(context)); + ), $S("call")), this, builder.bindings_->Argument(context)); } CYForEach (property, properties_) @@ -759,8 +759,8 @@ void CYProperty::Replace(CYContext &context, CYBuilder &builder, CYExpression *s CYExpression *name(name_->PropertyName(context)); if (name_->Computed()) { CYIdentifier *unique(context.Unique()); - builder.declarations_ - ->* $L1($L(unique, name)); + builder.bindings_ + ->* $B1($B(unique, name)); name = $V(unique); } @@ -773,8 +773,8 @@ bool CYProperty::Update() const { void CYPropertyGetter::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) { CYIdentifier *unique(context.Unique()); - builder.declarations_ - ->* $L1($L(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_)))); + builder.bindings_ + ->* $B1($B(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_)))); builder.statements_ ->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("get"), $V(unique))); } @@ -785,8 +785,8 @@ CYFunctionExpression *CYPropertyMethod::Constructor() { void CYPropertyMethod::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) { CYIdentifier *unique(context.Unique()); - builder.declarations_ - ->* $L1($L(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_)))); + builder.bindings_ + ->* $B1($B(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_)))); builder.statements_ ->* (!protect ? $E($ CYAssign($M(self, name), $V(unique))) : CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("value"), $V(unique), $ CYPropertyValue($S("writable"), $ CYTrue())))); @@ -798,8 +798,8 @@ bool CYPropertyMethod::Update() const { void CYPropertySetter::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) { CYIdentifier *unique(context.Unique()); - builder.declarations_ - ->* $L1($L(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_)))); + builder.bindings_ + ->* $B1($B(unique, CYSuperize(context, $ CYFunctionExpression(NULL, parameters_, code_)))); builder.statements_ ->* CYDefineProperty(self, name, true, !protect, $ CYPropertyValue($S("set"), $V(unique))); } @@ -807,8 +807,8 @@ void CYPropertySetter::Replace(CYContext &context, CYBuilder &builder, CYExpress void CYPropertyValue::Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) { _assert(!protect); CYIdentifier *unique(context.Unique()); - builder.declarations_ - ->* $L1($L(unique, value_)); + builder.bindings_ + ->* $B1($B(unique, value_)); builder.statements_ ->* $E($ CYAssign($M(self, name), $V(unique))); } @@ -946,15 +946,15 @@ void CYScope::Merge(CYContext &context, const CYIdentifierFlags *flags) { void CYScope::Close(CYContext &context, CYStatement *&statements) { Close(context); - CYList declarations; + CYList bindings; CYForEach (i, internal_) if (i->kind_ == CYIdentifierVariable) - declarations - ->* $ CYDeclarations($ CYDeclaration(i->identifier_)); + bindings + ->* $ CYBindings($ CYBinding(i->identifier_)); - if (declarations) { - CYVar *var($ CYVar(declarations)); + if (bindings) { + CYVar *var($ CYVar(bindings)); var->SetNext(statements); statements = var; } @@ -1219,7 +1219,7 @@ CYArgument *CYTypedParameter::Argument(CYContext &context) { $T(NULL) } CYFunctionParameter *CYTypedParameter::Parameters(CYContext &context) { $T(NULL) - return $ CYFunctionParameter($ CYDeclaration(typed_->identifier_ ?: context.Unique()), next_->Parameters(context)); + return $ CYFunctionParameter($ CYBinding(typed_->identifier_ ?: context.Unique()), next_->Parameters(context)); } CYExpression *CYTypedParameter::TypeSignature(CYContext &context, CYExpression *prefix) { $T(prefix) @@ -1227,7 +1227,7 @@ CYExpression *CYTypedParameter::TypeSignature(CYContext &context, CYExpression * } CYForInitializer *CYVar::Replace(CYContext &context) { - if (CYExpression *expression = declarations_->Replace(context, CYIdentifierVariable)) + if (CYExpression *expression = bindings_->Replace(context, CYIdentifierVariable)) return $E(expression); return $ CYEmpty(); } @@ -1238,7 +1238,7 @@ CYTarget *CYVariable::Replace(CYContext &context) { } CYFunctionParameter *CYVariable::Parameter() const { - return $ CYFunctionParameter($ CYDeclaration(name_)); + return $ CYFunctionParameter($ CYBinding(name_)); } CYStatement *CYWhile::Replace(CYContext &context) { diff --git a/Replace.hpp b/Replace.hpp index 82eed60..ce94063 100644 --- a/Replace.hpp +++ b/Replace.hpp @@ -110,17 +110,17 @@ #define $N5(func, args...) \ $N(func, $C5_(args)) -#define $L(args...) \ - $ CYDeclaration(args) -#define $L1(arg0) \ - $ CYDeclarations(arg0) -#define $L2(arg0, args...) \ - $ CYDeclarations(arg0, $L1(args)) -#define $L3(arg0, args...) \ - $ CYDeclarations(arg0, $L2(args)) -#define $L4(arg0, args...) \ - $ CYDeclarations(arg0, $L3(args)) -#define $L5(arg0, args...) \ - $ CYDeclarations(arg0, $L4(args)) +#define $B(args...) \ + $ CYBinding(args) +#define $B1(arg0) \ + $ CYBindings(arg0) +#define $B2(arg0, args...) \ + $ CYBindings(arg0, $B1(args)) +#define $B3(arg0, args...) \ + $ CYBindings(arg0, $B2(args)) +#define $B4(arg0, args...) \ + $ CYBindings(arg0, $B3(args)) +#define $B5(arg0, args...) \ + $ CYBindings(arg0, $B4(args)) #endif/*CYCRIPT_REPLACE_HPP*/ diff --git a/Syntax.hpp b/Syntax.hpp index f11c2f2..d7d783b 100644 --- a/Syntax.hpp +++ b/Syntax.hpp @@ -577,17 +577,17 @@ struct CYParenthetical : void Output(CYOutput &out, CYFlags flags) const; }; -struct CYDeclaration; +struct CYBinding; struct CYFunctionParameter : CYNext, CYThing { - CYDeclaration *initialiser_; + CYBinding *binding_; - CYFunctionParameter(CYDeclaration *initialiser, CYFunctionParameter *next = NULL) : + CYFunctionParameter(CYBinding *binding, CYFunctionParameter *next = NULL) : CYNext(next), - initialiser_(initialiser) + binding_(binding) { } @@ -604,11 +604,6 @@ struct CYComprehension : { } - CYComprehension *Modify(CYComprehension *next) { - next_ = next; - return this; - } - virtual CYFunctionParameter *Parameter(CYContext &context) const = 0; CYFunctionParameter *Parameters(CYContext &context) const; virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const; @@ -618,13 +613,13 @@ struct CYComprehension : struct CYForInComprehension : CYComprehension { - CYDeclaration *declaration_; - CYExpression *set_; + CYBinding *binding_; + CYExpression *iterable_; - CYForInComprehension(CYDeclaration *declaration, CYExpression *set, CYComprehension *next = NULL) : + CYForInComprehension(CYBinding *binding, CYExpression *iterable, CYComprehension *next = NULL) : CYComprehension(next), - declaration_(declaration), - set_(set) + binding_(binding), + iterable_(iterable) { } @@ -636,13 +631,13 @@ struct CYForInComprehension : struct CYForOfComprehension : CYComprehension { - CYDeclaration *declaration_; - CYExpression *set_; + CYBinding *binding_; + CYExpression *iterable_; - CYForOfComprehension(CYDeclaration *declaration, CYExpression *set, CYComprehension *next = NULL) : + CYForOfComprehension(CYBinding *binding, CYExpression *iterable, CYComprehension *next = NULL) : CYComprehension(next), - declaration_(declaration), - set_(set) + binding_(binding), + iterable_(iterable) { } @@ -1068,11 +1063,11 @@ struct CYClause : CYThing, CYNext { - CYExpression *case_; + CYExpression *value_; CYStatement *code_; - CYClause(CYExpression *_case, CYStatement *code) : - case_(_case), + CYClause(CYExpression *value, CYStatement *code) : + value_(value), code_(code) { } @@ -1141,13 +1136,13 @@ struct CYArray : virtual void Output(CYOutput &out, CYFlags flags) const; }; -struct CYDeclaration { +struct CYBinding { CYIdentifier *identifier_; - CYExpression *initialiser_; + CYExpression *initializer_; - CYDeclaration(CYIdentifier *identifier, CYExpression *initialiser = NULL) : + CYBinding(CYIdentifier *identifier, CYExpression *initializer = NULL) : identifier_(identifier), - initialiser_(initialiser) + initializer_(initializer) { } @@ -1161,11 +1156,11 @@ struct CYForLexical : CYForInInitializer { bool constant_; - CYDeclaration *declaration_; + CYBinding *binding_; - CYForLexical(bool constant, CYDeclaration *declaration) : + CYForLexical(bool constant, CYBinding *binding) : constant_(constant), - declaration_(declaration) + binding_(binding) { } @@ -1178,10 +1173,10 @@ struct CYForLexical : struct CYForVariable : CYForInInitializer { - CYDeclaration *declaration_; + CYBinding *binding_; - CYForVariable(CYDeclaration *declaration) : - declaration_(declaration) + CYForVariable(CYBinding *binding) : + binding_(binding) { } @@ -1191,15 +1186,15 @@ struct CYForVariable : virtual void Output(CYOutput &out, CYFlags flags) const; }; -struct CYDeclarations : - CYNext, +struct CYBindings : + CYNext, CYThing { - CYDeclaration *declaration_; + CYBinding *binding_; - CYDeclarations(CYDeclaration *declaration, CYDeclarations *next = NULL) : - CYNext(next), - declaration_(declaration) + CYBindings(CYBinding *binding, CYBindings *next = NULL) : + CYNext(next), + binding_(binding) { } @@ -1215,10 +1210,10 @@ struct CYDeclarations : struct CYVar : CYForInitializer { - CYDeclarations *declarations_; + CYBindings *bindings_; - CYVar(CYDeclarations *declarations) : - declarations_(declarations) + CYVar(CYBindings *bindings) : + bindings_(bindings) { } @@ -1228,15 +1223,15 @@ struct CYVar : virtual void Output(CYOutput &out, CYFlags flags) const; }; -struct CYLet : +struct CYLexical : CYForInitializer { bool constant_; - CYDeclarations *declarations_; + CYBindings *bindings_; - CYLet(bool constant, CYDeclarations *declarations) : + CYLexical(bool constant, CYBindings *bindings) : constant_(constant), - declarations_(declarations) + bindings_(bindings) { } @@ -1247,7 +1242,7 @@ struct CYLet : }; struct CYBuilder { - CYList declarations_; + CYList bindings_; CYList statements_; operator bool() const { @@ -1297,13 +1292,13 @@ struct CYPropertyValue : struct CYFor : CYStatement { - CYForInitializer *initialiser_; + CYForInitializer *initializer_; CYExpression *test_; CYExpression *increment_; CYStatement *code_; - CYFor(CYForInitializer *initialiser, CYExpression *test, CYExpression *increment, CYStatement *code) : - initialiser_(initialiser), + CYFor(CYForInitializer *initializer, CYExpression *test, CYExpression *increment, CYStatement *code) : + initializer_(initializer), test_(test), increment_(increment), code_(code) @@ -1319,13 +1314,13 @@ struct CYFor : struct CYForIn : CYStatement { - CYForInInitializer *initialiser_; - CYExpression *set_; + CYForInInitializer *initializer_; + CYExpression *iterable_; CYStatement *code_; - CYForIn(CYForInInitializer *initialiser, CYExpression *set, CYStatement *code) : - initialiser_(initialiser), - set_(set), + CYForIn(CYForInInitializer *initializer, CYExpression *iterable, CYStatement *code) : + initializer_(initializer), + iterable_(iterable), code_(code) { } @@ -1339,13 +1334,13 @@ struct CYForIn : struct CYForInitialized : CYStatement { - CYDeclaration *declaration_; - CYExpression *set_; + CYBinding *binding_; + CYExpression *iterable_; CYStatement *code_; - CYForInitialized(CYDeclaration *declaration, CYExpression *set, CYStatement *code) : - declaration_(declaration), - set_(set), + CYForInitialized(CYBinding *binding, CYExpression *iterable, CYStatement *code) : + binding_(binding), + iterable_(iterable), code_(code) { } @@ -1359,13 +1354,13 @@ struct CYForInitialized : struct CYForOf : CYStatement { - CYForInInitializer *initialiser_; - CYExpression *set_; + CYForInInitializer *initializer_; + CYExpression *iterable_; CYStatement *code_; - CYForOf(CYForInInitializer *initialiser, CYExpression *set, CYStatement *code) : - initialiser_(initialiser), - set_(set), + CYForOf(CYForInInitializer *initializer, CYExpression *iterable, CYStatement *code) : + initializer_(initializer), + iterable_(iterable), code_(code) { } -- 2.47.2