@@ -281,8 +281,12 @@ self_param = {
|
|||||||
"self" ~ mutable? ~ deref_px?
|
"self" ~ mutable? ~ deref_px?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
method_args = _{
|
||||||
|
((self_param ~ ("," ~ param_list)?) | param_list) ~ ","?
|
||||||
|
}
|
||||||
|
|
||||||
method = {
|
method = {
|
||||||
visibility? ~ type_expr ~ identifier ~ generics_decl? ~ "(" ~ self_param? ~ ("," ~ param_list)? ~ ")" ~ block
|
visibility? ~ type_expr ~ identifier ~ generics_decl? ~ "(" ~ method_args ~ ")" ~ (block | semicolon)
|
||||||
}
|
}
|
||||||
|
|
||||||
class_item = _{
|
class_item = _{
|
||||||
@@ -310,13 +314,8 @@ impl_decl = {
|
|||||||
// ======================================================
|
// ======================================================
|
||||||
trait_requirements = { ":" ~ type_expr_param ~ ("+" ~ type_expr_param)* }
|
trait_requirements = { ":" ~ type_expr_param ~ ("+" ~ type_expr_param)* }
|
||||||
|
|
||||||
method_no_body = {
|
|
||||||
visibility? ~ type_expr ~ identifier ~ generics_decl? ~ "(" ~ self_param? ~ ("," ~ param_list)? ~ ")" ~ semicolon
|
|
||||||
}
|
|
||||||
|
|
||||||
trait_item = _{
|
trait_item = _{
|
||||||
method
|
method
|
||||||
| method_no_body
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trait_decl = {
|
trait_decl = {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for FunctionDecl {
|
|||||||
type Error = AstError<'a, Self>;
|
type Error = AstError<'a, Self>;
|
||||||
|
|
||||||
fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result<Self, Self::Error> {
|
fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result<Self, Self::Error> {
|
||||||
ast_ensure!(pair, Rule::function_decl, Rule::method, Rule::method_no_body => {
|
ast_ensure!(pair, Rule::function_decl, Rule::method => {
|
||||||
let mut inner = pair.into_inner();
|
let mut inner = pair.into_inner();
|
||||||
let visibility = Visibility::try_from(&mut inner);
|
let visibility = Visibility::try_from(&mut inner);
|
||||||
let return_type = TypeExpr::try_from(inner.next().unwrap());
|
let return_type = TypeExpr::try_from(inner.next().unwrap());
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
class Bro {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
void idk_man(i32 bro) {}
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test_package::hello();
|
test_package::hello();
|
||||||
|
|
||||||
|
let idk = Bro::new();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user