From d6240a4b184cac1fbf61ab35f9f3813efb780d31 Mon Sep 17 00:00:00 2001 From: NanoTech Date: Tue, 6 Dec 2016 09:10:15 +0000 Subject: Initial commit --- src/grammar.lalrpop | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/grammar.lalrpop (limited to 'src/grammar.lalrpop') diff --git a/src/grammar.lalrpop b/src/grammar.lalrpop new file mode 100644 index 0000000..e940da9 --- /dev/null +++ b/src/grammar.lalrpop @@ -0,0 +1,94 @@ +use core; +use core::Expr::*; +use grammar_util::*; +use lexer::{Keyword, LexicalError, Tok}; + +grammar; + +extern { + type Location = usize; + type Error = LexicalError; + + enum Tok { + Pi => Tok::Pi, + Lambda => Tok::Lambda, + Combine => Tok::Combine, + "->" => Tok::Arrow, + + Int => Tok::Integer(), + Nat => Tok::Natural(), + Bool => Tok::Bool(), + Label => Tok::Identifier(), + Reserved => Tok::Reserved(), + + "(" => Tok::ParenL, + ")" => Tok::ParenR, + "&&" => Tok::BoolAnd, + "||" => Tok::BoolOr, + "==" => Tok::CompareEQ, + "!=" => Tok::CompareNE, + "++" => Tok::Append, + "*" => Tok::Times, + "+" => Tok::Plus, + "." => Tok::Dot, + ":" => Tok::Ascription, + "=" => Tok::Equals, + } +} + +pub Expr: BoxExpr = { // exprA + ":" => bx(Annot(<>)), + ExprB, +}; + +ExprB: BoxExpr = { + Lambda "("