aboutsummaryrefslogtreecommitdiff
path: root/Sil/Parse.icl
diff options
context:
space:
mode:
authorCamil Staps2017-07-27 13:05:23 +0200
committerCamil Staps2017-07-27 13:05:39 +0200
commitea4794ccdc9d0d8709ba22e43494e392b48be768 (patch)
tree26cdfda5d554beeecb08983f3d4d38219a779f6c /Sil/Parse.icl
parentAdd test file for #10 (lazy logical operators) (diff)
Resolve #4: mandatory initial values for basic locals
Diffstat (limited to 'Sil/Parse.icl')
-rw-r--r--Sil/Parse.icl9
1 files changed, 7 insertions, 2 deletions
diff --git a/Sil/Parse.icl b/Sil/Parse.icl
index 4d4b5eb..d5c97ef 100644
--- a/Sil/Parse.icl
+++ b/Sil/Parse.icl
@@ -137,9 +137,14 @@ codeblock = many initialisation >>= \is ->
initialisation :: Parser Token [Initialisation]
initialisation =
type >>= \t ->
- seplist TComma name >>= \ns ->
+ seplist TComma init >>= \nvs ->
item TSemicolon $>
- [{init_type=t, init_name=n} \\ n <- ns]
+ [{init_type=t, init_name=n, init_value=v} \\ (n,v) <- nvs]
+where
+ init =
+ name >>= \n ->
+ optional (item TAssign *> expression) >>= \v ->
+ pure (n,v)
statement :: Parser Token Statement
statement = declaration