aboutsummaryrefslogtreecommitdiff
path: root/Sil/Parse.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Parse.icl')
-rw-r--r--Sil/Parse.icl22
1 files changed, 10 insertions, 12 deletions
diff --git a/Sil/Parse.icl b/Sil/Parse.icl
index 80bca2b..4a345fe 100644
--- a/Sil/Parse.icl
+++ b/Sil/Parse.icl
@@ -145,18 +145,18 @@ program =
eof $>
{p_globals=flatten globss, p_funs=fs}
-function :: Parser Token (Positioned Function)
+function :: Parser Token Function
function =
type >>= \t ->
- getPositioner >>= \pos ->
+ getPosition >>= \pos ->
name >>= \n ->
parenthised (seplist TComma arg) >>= \args ->
- braced codeblock >>= \cb ->
- pure $ pos
+ braced codeblock >>= \cb -> pure
{ f_type = t
, f_name = n
, f_args = args
, f_code = cb
+ , f_pos = pos
}
codeblock :: Parser Token CodeBlock
@@ -164,25 +164,23 @@ codeblock = many initialisation >>= \is ->
many statement >>= \s ->
pure {cb_init=flatten is, cb_content=s}
-initialisation :: Parser Token [Positioned Initialisation]
+initialisation :: Parser Token [Initialisation]
initialisation = type >>= \t -> seplist TComma (init t) <* item TSemicolon
where
init t =
- getPositioner >>= \pos ->
+ getPosition >>= \pos ->
name >>= \n ->
- optional (item TAssign *> expression) >>= \v ->
- pure $ pos $ {init_type=t, init_name=n, init_value=v}
+ optional (item TAssign *> expression) >>= \v -> pure
+ {init_type=t, init_name=n, init_value=v, init_pos=pos}
-statement :: Parser Token (Positioned Statement)
+statement :: Parser Token Statement
statement =
- getPositioner >>= \pos ->
- ( declaration
+ declaration
<|> liftM Application (expression <* item TSemicolon)
<|> return
<|> if`
<|> while
<|> machinecode
- ) >>= pure o pos
where
declaration :: Parser Token Statement
declaration = liftM2 Declaration name (item TAssign *> expression <* item TSemicolon)