Skip to content

Commit

Permalink
Add the LET keyword to lexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
metatoaster committed Aug 7, 2018
1 parent 38f03c6 commit 5fdeefd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/calmjs/parse/lexers/es2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
)


es2015_keywords = (
'LET',
)


class Lexer(ES5Lexer):
"""
ES2015 lexer.
Expand All @@ -32,7 +37,10 @@ class Lexer(ES5Lexer):
t_ARROW = r'=>'
t_SPREAD = r'\.\.\.'

tokens = ES5Lexer.tokens + (
keywords = ES5Lexer.keywords + es2015_keywords
keywords_dict = dict((key.lower(), key) for key in keywords)

tokens = ES5Lexer.tokens + es2015_keywords + (
# ES2015 punctuators
'ARROW', 'SPREAD', # => ...

Expand Down
4 changes: 4 additions & 0 deletions src/calmjs/parse/tests/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@
'const_keyword',
('const c',
['CONST const', 'ID c']),
), (
'let_keyword',
('let c',
['LET let', 'ID c']),
), (
'punctuators',
('=> ...',
Expand Down

0 comments on commit 5fdeefd

Please sign in to comment.