Impl grammar
This commit is contained in:
+18
-2
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user