Skip to content

Commit c6c0769

Browse files
committed
Revert "[Parser] Start to parse instructions (#4789)"
This reverts commit 5aa2e18.
1 parent c00db9e commit c6c0769

File tree

4 files changed

+93
-6796
lines changed

4 files changed

+93
-6796
lines changed

scripts/gen-s-parser.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def insert(self, inst, expr):
693693
self.do_insert(inst, inst, expr)
694694

695695

696-
def instruction_parser(new_parser=False):
696+
def instruction_parser():
697697
"""Build a trie out of all the instructions, then emit it as C++ code."""
698698
trie = Node()
699699
inst_length = 0
@@ -703,23 +703,12 @@ def instruction_parser(new_parser=False):
703703

704704
printer = CodePrinter()
705705

706-
if not new_parser:
707-
printer.print_line("char op[{}] = {{'\\0'}};".format(inst_length + 1))
708-
printer.print_line("strncpy(op, s[0]->c_str(), {});".format(inst_length))
706+
printer.print_line("char op[{}] = {{'\\0'}};".format(inst_length + 1))
707+
printer.print_line("strncpy(op, s[0]->c_str(), {});".format(inst_length))
709708

710709
def print_leaf(expr, inst):
711-
if new_parser:
712-
expr = expr.replace("()", "(ctx)")
713-
expr = expr.replace("(s", "(ctx, in")
714-
printer.print_line("if (op == \"{inst}\"sv) {{".format(inst=inst))
715-
with printer.indent():
716-
printer.print_line("auto ret = {expr};".format(expr=expr))
717-
printer.print_line("CHECK_ERR(ret);")
718-
printer.print_line("return *ret;")
719-
printer.print_line("}")
720-
else:
721-
printer.print_line("if (strcmp(op, \"{inst}\") == 0) {{ return {expr}; }}"
722-
.format(inst=inst, expr=expr))
710+
printer.print_line("if (strcmp(op, \"{inst}\") == 0) {{ return {expr}; }}"
711+
.format(inst=inst, expr=expr))
723712
printer.print_line("goto parse_error;")
724713

725714
def emit(node, idx=0):
@@ -748,10 +737,7 @@ def emit(node, idx=0):
748737
emit(trie)
749738
printer.print_line("parse_error:")
750739
with printer.indent():
751-
if new_parser:
752-
printer.print_line("return in.err(\"unrecognized instruction\");")
753-
else:
754-
printer.print_line("throw ParseException(std::string(op), s.line, s.col);")
740+
printer.print_line("throw ParseException(std::string(op), s.line, s.col);")
755741

756742

757743
def print_header():
@@ -777,8 +763,6 @@ def main():
777763
sys.exit(1)
778764
print_header()
779765
generate_with_guard(instruction_parser, "INSTRUCTION_PARSER")
780-
print()
781-
generate_with_guard(lambda: instruction_parser(True), "NEW_INSTRUCTION_PARSER")
782766
print_footer()
783767

784768

0 commit comments

Comments
 (0)