aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2017-07-18 12:05:16 +0000
committerCamil Staps2017-07-18 12:05:16 +0000
commit7d8baccc8abde6eb547dca7fa519ddac380c90c8 (patch)
tree8a643f9e8398ff44238f2c1187d659519121b71c
parentEasier interface (diff)
Allow for multiple initialisations on one line
-rw-r--r--Sil/Parse.icl10
-rw-r--r--test.sil6
2 files changed, 8 insertions, 8 deletions
diff --git a/Sil/Parse.icl b/Sil/Parse.icl
index a9d733d..5c13c48 100644
--- a/Sil/Parse.icl
+++ b/Sil/Parse.icl
@@ -104,16 +104,16 @@ function =
}
codeblock :: Parser Token CodeBlock
-codeblock = many initialisation >>= \i ->
+codeblock = many initialisation >>= \is ->
many statement >>= \s ->
- pure {cb_init=i, cb_content=s}
+ pure {cb_init=flatten is, cb_content=s}
-initialisation :: Parser Token Initialisation
+initialisation :: Parser Token [Initialisation]
initialisation =
type >>= \t ->
- name >>= \n ->
+ seplist TComma name >>= \ns ->
item TSemicolon >>= \_ ->
- pure {init_type=t, init_name=n}
+ pure [{init_type=t, init_name=n} \\ n <- ns]
statement :: Parser Token Statement
statement = (declaration
diff --git a/test.sil b/test.sil
index ebbfdda..6493308 100644
--- a/test.sil
+++ b/test.sil
@@ -1,8 +1,8 @@
Int second(Int x, Int y) {
- Int z;
- z := x;
+ Int a, b;
+ a := x;
x := y;
- y := z;
+ y := a;
return y;
}