Skip to content

Commit

Permalink
feat(ConditionalParser): add support for if-else statements
Browse files Browse the repository at this point in the history
  • Loading branch information
aadhithya committed May 16, 2022
1 parent bcb55aa commit 2a219dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rajinipp/parser/cond_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..ast.control import IfCondition
from ..ast.control import IfCondition, IfElseCondition


class ConditionalParser:
Expand All @@ -10,3 +10,10 @@ def parse(self, pg):
)
def if_stmt(p):
return IfCondition(p[1], p[3])

@pg.production(
"statement : IF_COND logical_expression L_BRACE statements R_BRACE "
+ "ELSE_COND L_BRACE statements R_BRACE END_BLOCK SEMI_COLON"
)
def if_else_stmt(p):
return IfElseCondition(p[1], p[3], p[7])

0 comments on commit 2a219dc

Please sign in to comment.