Skip to content

Commit

Permalink
feat(flow_parser.py): add parser to support loops, rename cond_parser…
Browse files Browse the repository at this point in the history
… to flow_parser
  • Loading branch information
aadhithya committed May 16, 2022
1 parent ab91aad commit 78cc1da
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from ..ast.control import IfCondition, IfElseCondition
import pdb

from ..ast.control import ForLoop, IfCondition, IfElseCondition


class ConditionalParser:
Expand All @@ -17,3 +19,15 @@ def if_stmt(p):
)
def if_else_stmt(p):
return IfElseCondition(p[1], p[3], p[7])


class LoopParser:
"""parse loops"""

def parse(self, pg):
@pg.production(
"statement : FOR_START forvar FOR_RANGE_START forvar FOR_RANGE_END"
+ " L_BRACE statements R_BRACE END_BLOCK SEMI_COLON"
)
def for_loop(p):
return ForLoop(p[1], p[3], p[6])

0 comments on commit 78cc1da

Please sign in to comment.