Skip to content

Commit

Permalink
Remove "else" for now
Browse files Browse the repository at this point in the history
  • Loading branch information
healeycodes committed Dec 28, 2023
1 parent 2836b41 commit d33ca73
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,26 +363,11 @@ def visit_if_stmt(node: Tree, context: Context):
"""(if
(then\n"""
)
else_idx = None
for i in range(3, len(node.children)):
if node.children[i] == "else":
else_idx = i
break
if isinstance(node.children[i], Token):
continue
visit_declaration(node.children[i], context)
context.write(")\n")

if else_idx:
context.write("(else\n")
for i in range(else_idx + 1, len(node.children)):
if node.children[i] == "fi":
break
if isinstance(node.children[i], Token):
continue
visit_declaration(node.children[i], context)
context.write(")\n")
context.write(")\n")
context.write(")\n)\n")


def compile(source: str, context: Context):
Expand Down

0 comments on commit d33ca73

Please sign in to comment.