slimit icon indicating copy to clipboard operation
slimit copied to clipboard

keywords incorrectly disallowed as object property names

Open jason-s opened this issue 8 years ago • 1 comments

This works just fine in Javascript:

> keywordobj = {for: 3, if: 7, while: 99, in: 66, function: 33}
Object {for: 3, if: 7, while: 99, in: 66, function: 33}
> keywordobj.for
3
> keywordobj.while
99

but the use of keywords causes slimit to puke:

from slimit import ast
from slimit.parser import Parser
from slimit.visitors import nodevisitor

parser = Parser()
tree = parser.parse("x={a: 3, b: 7, c: 99, d: 66, e: 33}")
print "x read"
tree = parser.parse("y={for: 3, if: 7, while: 99, in: 66, function: 33}")
print "y read"

which reports x read and then

SyntaxError: Unexpected token (FOR, 'for') at 1:3 between LexToken(LBRACE,'{',1,2) and LexToken(COLON,':',1,6)

jason-s avatar Jan 13 '17 04:01 jason-s

This is related to #59

metatoaster avatar Jun 08 '17 04:06 metatoaster