diff --git a/crates/parser/src/grammar.pest b/crates/parser/src/grammar.pest index 549e5dc..4e5bfa5 100644 --- a/crates/parser/src/grammar.pest +++ b/crates/parser/src/grammar.pest @@ -285,13 +285,9 @@ method_args = _{ ((self_param ~ ("," ~ param_list)?) | param_list) ~ ","? } -method = { - visibility? ~ type_expr ~ identifier ~ generics_decl? ~ "(" ~ method_args ~ ")" ~ (block | semicolon) -} - class_item = _{ impl_decl - | method + | function_decl } class_decl = { @@ -302,11 +298,11 @@ class_decl = { // IMPL // ====================================================== impl_for_decl = { - "impl" ~ generics_decl? ~ type_expr ~ "for" ~ type_expr ~ "{" ~ method* ~ "}" + "impl" ~ generics_decl? ~ type_expr ~ "for" ~ type_expr ~ "{" ~ function_decl* ~ "}" } impl_decl = { - "impl" ~ generics_decl? ~ type_expr ~ "{" ~ method* ~ "}" + "impl" ~ generics_decl? ~ type_expr ~ "{" ~ function_decl* ~ "}" } // ====================================================== @@ -315,7 +311,7 @@ impl_decl = { trait_requirements = { ":" ~ type_expr_param ~ ("+" ~ type_expr_param)* } trait_item = _{ - method + function_decl } trait_decl = { @@ -327,7 +323,7 @@ trait_decl = { // ====================================================== function_decl = { - visibility? ~ type_expr ~ identifier ~ "(" ~ param_list ~ ")" ~ block + visibility? ~ type_expr ~ identifier ~ generics_decl? ~ "(" ~ method_args ~ ")" ~ (block | semicolon) } // ====================================================== diff --git a/crates/parser/src/parser/items/class.rs b/crates/parser/src/parser/items/class.rs index 4512d59..cab69ec 100644 --- a/crates/parser/src/parser/items/class.rs +++ b/crates/parser/src/parser/items/class.rs @@ -42,7 +42,7 @@ impl<'a> TryFrom> for ClassItem { Ok(ClassItem::ImplDecl(pair.try_into().get()?)) } - Rule::method => Ok(ClassItem::Method(pair.try_into().get()?)), + Rule::function_decl => Ok(ClassItem::Method(pair.try_into().get()?)), _ => AstError::bug_unimplemented(pair), } diff --git a/crates/parser/src/parser/items/function.rs b/crates/parser/src/parser/items/function.rs index 65da84f..1b2ff6c 100644 --- a/crates/parser/src/parser/items/function.rs +++ b/crates/parser/src/parser/items/function.rs @@ -10,7 +10,7 @@ impl<'a> TryFrom> for FunctionDecl { type Error = AstError<'a, Self>; fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result { - ast_ensure!(pair, Rule::function_decl, Rule::method => { + ast_ensure!(pair, Rule::function_decl => { let mut inner = pair.into_inner(); let visibility = Visibility::try_from(&mut inner); let return_type = TypeExpr::try_from(inner.next().unwrap()); diff --git a/mist-test/src/main.mist b/mist-test/src/main.mist index 759a8fe..73abdcb 100644 --- a/mist-test/src/main.mist +++ b/mist-test/src/main.mist @@ -1,9 +1,3 @@ -class Bro { - constructor() {} - - void idk_man(i32 bro) {} -} - void main() { test_package::hello();