-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrepl.py
More file actions
17 lines (16 loc) · 604 Bytes
/
Copy pathrepl.py
File metadata and controls
17 lines (16 loc) · 604 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Repl(object):
def __init__(self, prompt_message, lexer, parser):
self.lexer = lexer
self.parser = parser
self.message = prompt_message
self.create_repl()
def create_repl(self):
is_repl_launched = True
while is_repl_launched:
try:
repl_input = input(self.message)
tokens = self.lexer.lex(repl_input)
parser = self.parser.parse(tokens)
except KeyboardInterrupt:
print("Your keyboard interrupted")
is_repl_launched = False