From aea76473fa673adddb206e34d675e59c298e3581 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 7 Jun 2012 13:49:46 -0700 Subject: [PATCH] Rename NameAndValue and add trailing-, per ECMA6. --- Cycript.yy.in | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Cycript.yy.in b/Cycript.yy.in index ec7c221..9b9a05c 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -412,9 +412,10 @@ int cylex(YYSTYPE *, cy::location *, void *); %type ProgramBodyOpt %type PropertyName_ %type PropertyName -%type PropertyNameAndValueList_ -%type PropertyNameAndValueList -%type PropertyNameAndValueListOpt +%type PropertyDefinition +%type PropertyDefinitionList_ +%type PropertyDefinitionList +%type PropertyDefinitionListOpt %type RelationalExpression %type ReturnStatement %type RubyProcExpression @@ -736,23 +737,30 @@ ElementListOpt /* }}} */ /* 11.1.5 Object Initialiser {{{ */ ObjectLiteral - : BRACE LexPushInOff PropertyNameAndValueListOpt LexPopIn "}" { $$ = CYNew CYObject($3); } + : BRACE LexPushInOff PropertyDefinitionListOpt LexPopIn "}" { $$ = CYNew CYObject($3); } ; -PropertyNameAndValueList_ - : "," PropertyNameAndValueList { $$ = $2; } +PropertyDefinitionList_ + : "," PropertyDefinitionList { $$ = $2; } + | "," { $$ = NULL; } | { $$ = NULL; } ; -PropertyNameAndValueList - : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = CYNew CYProperty($1, $3, $4); } +PropertyDefinitionList + : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; } ; -PropertyNameAndValueListOpt - : PropertyNameAndValueList { $$ = $1; } +PropertyDefinitionListOpt + : PropertyDefinitionList { $$ = $1; } | { $$ = NULL; } ; +PropertyDefinition + //: IdentifierName { $$ = CYNew CYProperty($1, CYNew CYVariable($1)); } + : PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); } + //| MethodDefinition + ; + PropertyName_ : IdentifierName { $$ = $1; } | StringLiteral { $$ = $1; } @@ -1651,12 +1659,6 @@ Statement__ /* }}} */ @end -/* ECMAScript5: Object Literal Trailing Comma {{{ */ -PropertyNameAndValueList_ - : "," { $$ = NULL; } - ; -/* }}} */ - /* JavaScript 1.7: Array Comprehensions {{{ */ IfComprehension : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); } -- 2.45.2