Impl grammar

This commit is contained in:
2026-05-10 16:59:21 +02:00
parent dfa5487031
commit 22b1b377f3
2 changed files with 38 additions and 2 deletions
+18 -2
View File
@@ -239,8 +239,24 @@ method = {
export? ~ type_expr ~ identifier ~ generics? ~ "(" ~ self_param? ~ ("," ~ param_list?)? ~ ")" ~ block
}
class_item = _{
impl_decl
| method
}
class_decl = {
export? ~ "class" ~ identifier ~ generics? ~ "{" ~ class_fields ~ class_constructor ~ method* ~ "}"
export? ~ "class" ~ identifier ~ generics? ~ "{" ~ class_fields ~ class_constructor ~ class_item* ~ "}"
}
// ======================================================
// IMPL
// ======================================================
impl_for_decl = {
"impl" ~ generics? ~ type_expr ~ "for" ~ type_expr ~ "{" ~ method* ~ "}"
}
impl_decl = {
"impl" ~ generics? ~ type_expr ~ "{" ~ method* ~ "}"
}
// ======================================================
@@ -256,7 +272,7 @@ function_decl = {
// ======================================================
top_level = {
(attributes ~ (import | function_decl | struct_decl | enum_decl | class_decl | mod_package))
(attributes ~ (import | impl_for_decl | impl_decl | function_decl | struct_decl | enum_decl | class_decl | mod_package))
| mod_attribute
}