aboutsummaryrefslogtreecommitdiff
path: root/Sjit/Syntax.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sjit/Syntax.icl')
-rw-r--r--Sjit/Syntax.icl7
1 files changed, 6 insertions, 1 deletions
diff --git a/Sjit/Syntax.icl b/Sjit/Syntax.icl
index 7412d7c..90aeb39 100644
--- a/Sjit/Syntax.icl
+++ b/Sjit/Syntax.icl
@@ -16,6 +16,8 @@ import Text.Parsers.Simple.Core
| TTrue
| TFalse
+ | TIf
+
| TEq
| TComma
@@ -32,6 +34,7 @@ where
TInt n -> toString n
TTrue -> "True"
TFalse -> "False"
+ TIf -> "if"
TEq -> "="
TComma -> ","
TParenOpen -> "("
@@ -51,6 +54,7 @@ where
# tk = case n of
"True" -> TTrue
"False" -> TFalse
+ "if" -> TIf
n -> TIdent n
-> lex [tk:tks] i e s
@@ -112,7 +116,8 @@ where
noInfix :: Parser Token Expr
noInfix =
- liftM2 App ident (pToken TParenOpen *> pSepBy expr (pToken TComma) <* pToken TParenClose)
+ liftM2 App ident (pToken TParenOpen *> pSepBy expr (pToken TComma) <* pToken TParenClose)
+ <|> liftM3 If (pToken TIf *> expr) expr expr
<|> Var <$> ident
<|> Int <$> int
<|> Bool <$> bool