Fixed bug that printed the output twice after a rewrite operation.

parent 7ecb7c78
...@@ -259,6 +259,7 @@ class Parser(BisonParser): ...@@ -259,6 +259,7 @@ class Parser(BisonParser):
""" """
input : input :
| input line | input line
| input REWRITE NEWLINE
""" """
if option == 1: if option == 1:
# Interactive mode is enabled if the term rewriting system is used # Interactive mode is enabled if the term rewriting system is used
...@@ -269,6 +270,10 @@ class Parser(BisonParser): ...@@ -269,6 +270,10 @@ class Parser(BisonParser):
return values[1] return values[1]
if option == 2: # rule: input REWRITE NEWLINE
self.root_node = self.rewrite()
return self.root_node
def on_line(self, target, option, names, values): def on_line(self, target, option, names, values):
""" """
line : NEWLINE line : NEWLINE
...@@ -276,7 +281,6 @@ class Parser(BisonParser): ...@@ -276,7 +281,6 @@ class Parser(BisonParser):
| debug NEWLINE | debug NEWLINE
| HINT NEWLINE | HINT NEWLINE
| POSSIBILITIES NEWLINE | POSSIBILITIES NEWLINE
| REWRITE NEWLINE
| RAISE NEWLINE | RAISE NEWLINE
""" """
if option == 1: # rule: EXP NEWLINE if option == 1: # rule: EXP NEWLINE
...@@ -295,11 +299,7 @@ class Parser(BisonParser): ...@@ -295,11 +299,7 @@ class Parser(BisonParser):
self.display_possibilities() self.display_possibilities()
return return
if option == 5: # rule: REWRITE NEWLINE if option == 5:
self.root_node = self.rewrite()
return self.root_node
if option == 6:
raise RuntimeError('on_line: exception raised') raise RuntimeError('on_line: exception raised')
def on_debug(self, target, option, names, values): def on_debug(self, target, option, names, values):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment