Adding support for compound assignment to indented implicit objects.

This commit is contained in:
Jeremy Ashkenas 2010-08-11 23:14:50 -04:00
parent 8c45aa480b
commit fd6e9a1e66
4 changed files with 24 additions and 7 deletions

View File

@ -573,6 +573,8 @@
return new OpNode($2, $1, $3);
}), o("Expression COMPOUND_ASSIGN Expression", function() {
return new OpNode($2, $1, $3);
}), o("Expression COMPOUND_ASSIGN INDENT Expression OUTDENT", function() {
return new OpNode($2, $1, $4);
}), o("Expression INSTANCEOF Expression", function() {
return new OpNode('instanceof', $1, $3);
}), o("Expression IN Expression", function() {

File diff suppressed because one or more lines are too long

View File

@ -539,6 +539,7 @@ grammar =
o "Expression COMPARE Expression", -> new OpNode $2, $1, $3
o "Expression LOGIC Expression", -> new OpNode $2, $1, $3
o "Expression COMPOUND_ASSIGN Expression", -> new OpNode $2, $1, $3
o "Expression COMPOUND_ASSIGN INDENT Expression OUTDENT", -> new OpNode $2, $1, $4
o "Expression INSTANCEOF Expression", -> new OpNode 'instanceof', $1, $3
o "Expression IN Expression", -> new InNode $1, $3

View File

@ -118,3 +118,15 @@ num = 10; ok (num ^= 3) is 9
num = 10; ok (num |= 3) is 11
# Compound assignment with implicit objects.
obj = undefined
obj ?=
one: 1
ok obj.one is 1
obj and=
two: 2
ok not obj.one
ok obj.two is 2