mirror of https://github.com/lark-parser/lark.git
Fixed calc example
This commit is contained in:
parent
df80933884
commit
63c8e58e42
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
from lark import Lark, InlineTransformer
|
from lark import Lark, InlineTransformer
|
||||||
|
|
||||||
|
try:
|
||||||
|
input = raw_input
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
calc_grammar = """
|
calc_grammar = """
|
||||||
?start: sum
|
?start: sum
|
||||||
| NAME "=" sum -> assign_var
|
| NAME "=" sum -> assign_var
|
||||||
|
@ -47,7 +53,7 @@ calc = calc_parser.parse
|
||||||
def main():
|
def main():
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
s = raw_input('> ')
|
s = input('> ')
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
print(calc(s))
|
print(calc(s))
|
||||||
|
@ -58,6 +64,6 @@ def test():
|
||||||
print(calc("1+a*-3"))
|
print(calc("1+a*-3"))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
# test()
|
||||||
# main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue