diff --git a/src/ast.rs b/src/ast.rs index f8e96dc..0c6b40a 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,4 +1,4 @@ -use crate::{map::Map, symbol::Symbol, val::Val}; +use crate::{symbol::Symbol, val::Val}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Ident { @@ -21,8 +21,8 @@ pub enum Ast { outputs: Vec, body: Vec, }, - /// `{x, y: z}` - Map(Map), + /// `{^x; ^y := z}` + Map(Vec), /// `f x` App(Box, Box), /// `x + y` (only builtins, sorry) diff --git a/src/parser.rs b/src/parser.rs index af07122..27cfa87 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -133,7 +133,22 @@ where .delimited_by(just(Token::OpenParen), just(Token::CloseParen)) .labelled("block"); - let non_app = choice((set, num, ident.map(Ast::Var).labelled("variable"), block)); + let map = expr + .clone() + .separated_by(semicolon.clone()) + .allow_trailing() + .collect() + .map(Ast::Map) + .delimited_by(just(Token::OpenBrace), just(Token::CloseBrace)) + .labelled("map"); + + let non_app = choice(( + set, + num, + ident.map(Ast::Var).labelled("variable"), + map, + block, + )); let app = non_app .clone()