diff --git a/parser/src/ast.rs b/parser/src/ast.rs index deec78a..4909378 100644 --- a/parser/src/ast.rs +++ b/parser/src/ast.rs @@ -13,7 +13,7 @@ pub struct Block(pub Vec); #[derive(Debug, Clone, Serialize)] pub enum TypeExpr { - Path(StaticPath), + Path(StaticPath, Vec), Tuple(Vec), } diff --git a/parser/src/grammar.pest b/parser/src/grammar.pest index a8e5d0a..2b1384b 100644 --- a/parser/src/grammar.pest +++ b/parser/src/grammar.pest @@ -74,7 +74,8 @@ while_stmt = { // ================= EXPRESSIONS ================= tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" } -type_expr = { (static_path ~ ("<" ~ type_expr ~ ">")?) | tuple_type } +path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? } +type_expr = { path_type | tuple_type } primary = { integer diff --git a/parser/src/lib.rs b/parser/src/lib.rs index 8666c30..27b25ab 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -30,8 +30,12 @@ impl From> for TypeExpr { fn from(pair: pest::iterators::Pair<'_, Rule>) -> Self { match pair.as_rule() { Rule::type_expr => TypeExpr::from(pair.into_inner().next().unwrap()), - Rule::static_path => TypeExpr::Path(StaticPath::from(pair)), Rule::tuple_type => TypeExpr::Tuple(pair.into_inner().map(TypeExpr::from).collect()), + Rule::path_type => { + let mut inner = pair.into_inner(); + + TypeExpr::Path(StaticPath::from(inner.next().unwrap()), inner.map(TypeExpr::from).collect()) + } _ => unimplemented!("{pair:#?}"), } } diff --git a/test/src/main.mist b/test/src/main.mist index 46e4b04..b81268b 100644 --- a/test/src/main.mist +++ b/test/src/main.mist @@ -1,3 +1,3 @@ -(i32, i32) main() { +Result main() { } \ No newline at end of file