summaryrefslogtreecommitdiff
path: root/src/grammar.lalrpop
diff options
context:
space:
mode:
authorNanoTech2016-12-06 04:08:50 -0600
committerNanoTech2017-03-10 23:48:27 -0600
commit10577fc72af7260255493999294eda8e4413b6a5 (patch)
treea8b7130567fa9460c8126fa8e41da21c027ff37d /src/grammar.lalrpop
parent0c3f365c15156c19f194f0c33500649649fc4ab9 (diff)
Add more ExprB rules
Diffstat (limited to '')
-rw-r--r--src/grammar.lalrpop13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/grammar.lalrpop b/src/grammar.lalrpop
index e940da9..3d4603d 100644
--- a/src/grammar.lalrpop
+++ b/src/grammar.lalrpop
@@ -19,6 +19,11 @@ extern {
Nat => Tok::Natural(<usize>),
Bool => Tok::Bool(<bool>),
Label => Tok::Identifier(<String>),
+ Let => Tok::Reserved(Keyword::Let),
+ In => Tok::Reserved(Keyword::In),
+ If => Tok::Reserved(Keyword::If),
+ Then => Tok::Reserved(Keyword::Then),
+ Else => Tok::Reserved(Keyword::Else),
Reserved => Tok::Reserved(<Keyword>),
"(" => Tok::ParenL,
@@ -43,7 +48,11 @@ pub Expr: BoxExpr = { // exprA
ExprB: BoxExpr = {
Lambda "(" <Label> ":" <Expr> ")" "->" <ExprB> => bx(Lam(<>)),
- ExprC0,
+ Pi "(" <Label> ":" <Expr> ")" "->" <ExprB> => bx(Pi(<>)),
+ If <Expr> Then <ExprB> Else <ExprC> => bx(BoolIf(<>)),
+ <ExprC> "->" <ExprB> => bx(Pi("_".to_owned(), <>)),
+ Let <Label> <(":" <Expr>)?> "=" <Expr> In <ExprB> => bx(Let(<>)),
+ ExprC,
};
BoolOr: ExprOpFn = { "||" => BoolOr };
@@ -61,7 +70,7 @@ Tier<NextTier, Op>: BoxExpr = {
NextTier,
};
-ExprC0 = Tier<ExprC1, BoolOr>;
+ExprC = Tier<ExprC1, BoolOr>;
ExprC1 = Tier<ExprC2, NaturalPlus>;
ExprC2 = Tier<ExprC3, TextAppend>;
ExprC3 = Tier<ExprC4, BoolAnd>;