Skip to content

Commit 457f3e9

Browse files
committed
allowed {-true} etc.
1 parent 55bda98 commit 457f3e9

File tree

4 files changed

+44
-37
lines changed

4 files changed

+44
-37
lines changed

lib/grammar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ bnf = {
199199
}), o('KeyValue'), o('KeyValue LOGIC Expression', function(){
200200
return Binary($2, $1, $3);
201201
}), o('+- Key', function(){
202-
return Prop($2.maybeKey(), Literal($1 === '+'));
202+
return Prop($2.maybeKey(), L(Literal($1 === '+')));
203+
}), o('+- LITERAL', function(){
204+
return Prop(L(Key($2, true)), L(Literal($1 === '+')));
203205
}), o('... Expression', function(){
204206
return Splat($2);
205207
}), o('COMMENT', function(){

lib/parser.js

Lines changed: 32 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/grammar.co

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ bnf =
231231
o \KeyValue
232232
o 'KeyValue LOGIC Expression' -> Binary $2, $1, $3
233233

234-
o '+- Key' -> Prop $2.maybeKey(), Literal $1 is \+
234+
o '+- Key' -> Prop $2.maybeKey! , L Literal $1 is \+
235+
o '+- LITERAL' -> Prop L(Key $2, true), L Literal $1 is \+
235236

236237
o '... Expression' -> Splat $2
237238

test/literal.co

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,28 @@ eq obj.class + obj.function, 'hotdog'
152152

153153

154154
# Property shorthands.
155-
class extends Object
156-
a = 0; @b = 1; x = {a, @b, 2, \3}
155+
new
156+
a = 0; @b = 1; x = {a, @b, 2, \3, +4, -5}
157157
eq x.a, 0
158158
eq x.b, 1
159159
eq x.2, 2
160160
eq x.3, \3
161+
eq x.4, true
162+
eq x.5, false
161163
c = null; d = 0; y = {a || 1, @b && 2, c ? 3, d !? 4}
162164
eq y.a, 1
163165
eq y.b, 2
164166
eq y.c, 3
165167
eq y.d, 4
166-
z = {true, false, null, void, this, arguments, eval, super}
168+
z = {true, false, null, void, this, arguments, +eval, -super}
167169
eq z.true , true
168170
eq z.false , false
169171
eq z.null , null
170172
eq z.void , void
171173
eq z.this , this
172174
eq z.arguments , arguments
173-
eq z.eval , eval
174-
eq z.super , super
175+
eq z.eval , true
176+
eq z.super , false
175177

176178

177179
# [coffee#542](https://github.com/jashkenas/coffee-script/issues/542):

0 commit comments

Comments
 (0)