Macro calls

This commit is contained in:
2026-05-04 19:43:49 +02:00
parent c717a57f99
commit c083a547d7
5 changed files with 17 additions and 1 deletions
+1
View File
@@ -66,6 +66,7 @@ pub enum TopLevel {
pub enum Postfix {
FieldAccess(String),
Call(Vec<Expression>),
MacroCall(String),
StructCall(HashMap<String, Expression>),
Index(Expression),
Binary(BinaryOp, Expression),
+7
View File
@@ -79,6 +79,11 @@ path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? }
ref_type = { mutable? ~ "*" }
type_expr = { (path_type | tuple_type) ~ ref_type* }
macro_inner_v = {
"(" ~ macro_inner_v* ~ ")"
| (!("(" | ")") ~ ANY)
}
primary = {
integer
| float
@@ -90,6 +95,7 @@ primary = {
postfix = {
field_px
| call_px
| macro_call_px
| struct_px
| index_px
| binary_px
@@ -97,6 +103,7 @@ postfix = {
field_px = { "." ~ identifier }
call_px = { "(" ~ (expr ~ ("," ~ expr)*)? ~ ")" }
macro_call_px = { "!" ~ "(" ~ macro_inner_v* ~ ")" }
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ "}" }
index_px = { "[" ~ expr ~ "]" }
binary_px = { bin_op ~ expr }
+2
View File
@@ -362,6 +362,8 @@ impl From<pest::iterators::Pair<'_, Rule>> for Postfix {
Postfix::Binary(op, Expression::from(inner.next().unwrap()))
}
Rule::macro_call_px => Postfix::MacroCall(pair.into_inner().as_str().to_string()),
_ => unimplemented!("Postfix parsing not implemented yet {:?}", pair.as_rule()),
}
}