use std::collections::BTreeMap; use std::iter; use std::iter::FromIterator; use crate::core; use crate::core::bx; use crate::core::Expr::*; use crate::core::BuiltinType::*; use crate::grammar_util::*; use crate::lexer::*; grammar<'input>; extern { type Location = usize; type Error = LexicalError; enum Tok<'input> { Pi => Tok::Pi, Lambda => Tok::Lambda, Combine => Tok::Combine, "->" => Tok::Arrow, Int => Tok::Integer(), Nat => Tok::Natural(), Text => Tok::Text(), Bool => Tok::Bool(), Label => Tok::Identifier(<&'input str>), Const => Tok::Const(), Let => Tok::Keyword(Keyword::Let), In => Tok::Keyword(Keyword::In), If => Tok::Keyword(Keyword::If), Then => Tok::Keyword(Keyword::Then), Else => Tok::Keyword(Keyword::Else), List => Tok::ListLike(ListLike::List), Optional => Tok::ListLike(ListLike::Optional), Builtin => Tok::Builtin(), "{" => Tok::BraceL, "}" => Tok::BraceR, "[" => Tok::BracketL, "]" => Tok::BracketR, "(" => Tok::ParenL, ")" => Tok::ParenR, "&&" => Tok::BoolAnd, "||" => Tok::BoolOr, "==" => Tok::CompareEQ, "!=" => Tok::CompareNE, "++" => Tok::Append, "*" => Tok::Times, "+" => Tok::Plus, "," => Tok::Comma, "." => Tok::Dot, ":" => Tok::Ascription, "=" => Tok::Equals, } } pub Expr: BoxExpr<'input> = { // exprA ":" => bx(Annot(<>)), ExprB, }; ExprB: BoxExpr<'input> = { Lambda "("