Type params parsing
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ pub struct Block(pub Vec<Statement>);
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub enum TypeExpr {
|
pub enum TypeExpr {
|
||||||
Path(StaticPath),
|
Path(StaticPath, Vec<TypeExpr>),
|
||||||
Tuple(Vec<TypeExpr>),
|
Tuple(Vec<TypeExpr>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ while_stmt = {
|
|||||||
|
|
||||||
// ================= EXPRESSIONS =================
|
// ================= EXPRESSIONS =================
|
||||||
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
|
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 = {
|
primary = {
|
||||||
integer
|
integer
|
||||||
|
|||||||
+5
-1
@@ -30,8 +30,12 @@ impl From<pest::iterators::Pair<'_, Rule>> for TypeExpr {
|
|||||||
fn from(pair: pest::iterators::Pair<'_, Rule>) -> Self {
|
fn from(pair: pest::iterators::Pair<'_, Rule>) -> Self {
|
||||||
match pair.as_rule() {
|
match pair.as_rule() {
|
||||||
Rule::type_expr => TypeExpr::from(pair.into_inner().next().unwrap()),
|
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::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:#?}"),
|
_ => unimplemented!("{pair:#?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
(i32, i32) main() {
|
Result<void, String> main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user