diff options
author | Camil Staps | 2017-07-20 20:25:25 +0000 |
---|---|---|
committer | Camil Staps | 2017-07-20 20:25:25 +0000 |
commit | bc950badd0655328af7a9886988722809e367d07 (patch) | |
tree | 6411d00c5022b591697c206cc1261dafb8ec8b33 /Sil/Parse.icl | |
parent | Add checks for locals with type Void (diff) |
Type checking
Diffstat (limited to 'Sil/Parse.icl')
-rw-r--r-- | Sil/Parse.icl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Sil/Parse.icl b/Sil/Parse.icl index 806ac69..fb77def 100644 --- a/Sil/Parse.icl +++ b/Sil/Parse.icl @@ -21,6 +21,7 @@ from Text import <+, class Text, instance Text String import GenEq import Sil.Syntax +import Sil.Types import Sil.Util.Parser import Sil.Util.Printer @@ -119,7 +120,7 @@ function = item TParenClose *> item TBraceOpen *> codeblock >>= \cb -> - item TBraceClose *> pure + item TBraceClose $> { f_type = t , f_name = n , f_args = args @@ -135,8 +136,8 @@ initialisation :: Parser Token [Initialisation] initialisation = type >>= \t -> seplist TComma name >>= \ns -> - item TSemicolon >>= \_ -> - pure [{init_type=t, init_name=n} \\ n <- ns] + item TSemicolon $> + [{init_type=t, init_name=n} \\ n <- ns] statement :: Parser Token Statement statement = declaration @@ -192,7 +193,7 @@ expression $ noInfix where op :: Token Op2 -> Parser Token Op2 - op token operator = item token *> pure operator + op token operator = item token $> operator rightAssoc :: (Parser Token Op2) (Parser Token Expression) -> Parser Token Expression rightAssoc opp appp = appp >>= \e1 -> optional (opp >>= \op -> rightAssoc opp appp >>= \e -> pure (op,e)) @@ -231,7 +232,7 @@ type <|> type "Void" TVoid <?> Expected "type" where - type s t = item (TName s) *> pure t + type s t = item (TName s) $> t literal :: Parser Token Literal literal = satisfy isLit >>= \(TLit lit) -> pure lit |