Permalink
Browse files

allow literals as keys in object patterns

  • Loading branch information...
1 parent c2ccb48 commit 9821a6c2804b835a3725be1df869eeaf4c071648 @zaach zaach committed Jul 7, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/grammar.y
View
@@ -47,6 +47,10 @@ Field
{ $$ = {key:yy.Node('Identifier', $1,yy.loc(@1)),value:yy.Node('Identifier', $1,yy.loc(@1)),kind: "init"}; }
| IDENT ':' Element
{ yy.locComb(@$,@3);$$ = {key:yy.Node('Identifier', $1,yy.loc(@1)),value:$3,kind: "init"}; }
+ | STRING ':' Element
+ { yy.locComb(@$,@3);$$ = {key:yy.Node('Literal', String($1),yy.loc(@1)),value:$3,kind: "init"}; }
+ | NUMBER ':' Element
+ { yy.locComb(@$,@3);$$ = {key:yy.Node('Literal', Number($1),yy.loc(@1)),value:$3,kind: "init"}; }
;
Element

0 comments on commit 9821a6c

Please sign in to comment.