diff --git a/axc/src/parser.rs b/axc/src/parser.rs index fffc1c2..08680d5 100644 --- a/axc/src/parser.rs +++ b/axc/src/parser.rs @@ -3,7 +3,7 @@ use std::{error::Error, fmt::Display}; use chumsky::{ - prelude::{choice, end, just, none_of, one_of, todo, Simple}, + prelude::{choice, end, just, none_of, one_of, Simple}, text::{ident, int, keyword, whitespace}, Parser, }; @@ -303,6 +303,7 @@ fn parse_func_decl<'a>( fn parse_type_alias(m: &ParserMeta) -> impl Parser> { keyword("type") + .then_ignore(whitespace()) .ignore_then(parse_type(m)) .then( just('=') @@ -481,11 +482,24 @@ fn parse_literal(_m: &ParserMeta) -> impl Parser impl Parser> { - todo() +fn parse_type(m: &ParserMeta) -> impl Parser> { + parse_named_type(m).repeated().at_least(1).map(|types| { + types + .into_iter() + .reduce(|l, r| Type::Application { + function: Box::new(l), + expression: Box::new(r), + }) + .unwrap() + }) +} + +fn parse_named_type(_m: &ParserMeta) -> impl Parser> { + ident().then_ignore(whitespace()).map(Type::Named) } fn parse_pattern(m: &ParserMeta) -> impl Parser> { + // TODO: add all the patterns choice((parse_capture_pattern(m),)) }