Changes to token specification. More metamagic

This commit is contained in:
David Beazley
2018-01-27 15:27:15 -06:00
parent b74e7223ce
commit b088d9b2ce
10 changed files with 302 additions and 142 deletions

View File

@@ -8,9 +8,7 @@ sys.path.insert(0, "../..")
from sly import Lexer, Parser
class CalcLexer(Lexer):
tokens = {
'NAME', 'NUMBER',
}
tokens = { NAME, NUMBER }
ignore = ' \t'
literals = { '=', '+', '-', '*', '/', '(', ')' }
@@ -36,7 +34,7 @@ class CalcParser(Parser):
precedence = (
('left', '+', '-'),
('left', '*', '/'),
('right', 'UMINUS'),
('right', UMINUS),
)
def __init__(self):