aboutsummaryrefslogtreecommitdiff
path: root/Sil/Parse.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Parse.icl')
-rw-r--r--Sil/Parse.icl19
1 files changed, 13 insertions, 6 deletions
diff --git a/Sil/Parse.icl b/Sil/Parse.icl
index 3a11622..2e21d08 100644
--- a/Sil/Parse.icl
+++ b/Sil/Parse.icl
@@ -138,17 +138,18 @@ initialisation =
pure [{init_type=t, init_name=n} \\ n <- ns]
statement :: Parser Token Statement
-statement = ((declaration
- <|> liftM Application application
+statement = declaration
+ <|> liftM Application (application <* item TSemicolon)
<|> return
<|> if`
- /*<|> while*/) <* item TSemicolon) <|> machinecode
+ //<|> while
+ <|> machinecode
where
declaration :: Parser Token Statement
- declaration = liftM2 Declaration name (item TAssign *> application)
+ declaration = liftM2 Declaration name (item TAssign *> application <* item TSemicolon)
return :: Parser Token Statement
- return = liftM Return (item TReturn *> optional application)
+ return = liftM Return (item TReturn *> optional application <* item TSemicolon)
machinecode :: Parser Token Statement
machinecode = (\(TMachineCode s) -> MachineStm s) <$> satisfy isMachineCode
@@ -158,8 +159,14 @@ where
if` = item TIf *>
parenthised application >>= \cond ->
braced codeblock >>= \iftrue ->
+ many elseif >>= \elseifs ->
optional (item TElse *> braced codeblock) >>= \iffalse ->
- pure $ If cond iftrue iffalse
+ pure $ If [(cond,iftrue):elseifs] iffalse
+ where
+ elseif = list [TElse, TIf] *>
+ parenthised application >>= \cond ->
+ braced codeblock >>= \block ->
+ pure (cond, block)
application :: Parser Token Application
application