-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_cli.py
More file actions
30 lines (26 loc) · 883 Bytes
/
simple_cli.py
File metadata and controls
30 lines (26 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Simple Command line Interface."""
import arpeggio
# from . import common
import common
from common_interpreter import CommonInterpreter
def parse(instruction):
"""Parse vim instruction."""
def new_rule():
return (
arpeggio.ZeroOrMore([
common.string,
common.unsigned_float,
common.signed_float,
common.unsigned_integer,
common.signed_integer,]),
arpeggio.EOF)
parser = arpeggio.ParserPython(new_rule, ignore_case=True)
return parser.parse(instruction)
if __name__ == "__main__":
while True:
# pylint: disable = invalid-name
code = input("> ")
# print(code)
parse_tree = parse(code)
interpreted_parse_tree = arpeggio.visit_parse_tree(parse_tree, CommonInterpreter())
print(interpreted_parse_tree)