summaryrefslogtreecommitdiffstats
path: root/parsing/parse.sh
diff options
context:
space:
mode:
Diffstat (limited to 'parsing/parse.sh')
-rw-r--r--parsing/parse.sh23
1 files changed, 21 insertions, 2 deletions
diff --git a/parsing/parse.sh b/parsing/parse.sh
index 444ccc5..577b41e 100644
--- a/parsing/parse.sh
+++ b/parsing/parse.sh
@@ -212,13 +212,29 @@ pattern()
if_clause()
{
- : TODO: Implement
+ if accept T_IF; then
+ if compound_list && expect T_THEN && compound_list; then
+ else_part
+ expect T_FI
+ return 0
+ fi
+ fi
return 1
}
else_part()
{
- : TODO: Implement
+ while accept T_ELIF; do
+ if compound_list && expect T_THEN && compound_list; then
+ continue
+ fi
+ return 1
+ done
+ if accept T_ELSE; then
+ if compound_list; then
+ return 0
+ fi
+ fi
return 1
}
@@ -447,3 +463,6 @@ try()
#try '{ foo; }'
#try '( foo )'
#try 'for i in 1 2 3; do stuff; done'
+try 'if foo; then bar; fi'
+try 'if foo; then bar; elif baz; then qux; else quux; fi'
+try 'if ; then ; fi'