Fix undeclared lifetime and simplifed grammar #50
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
|
||||
@@ -42,7 +42,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> 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),
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for FunctionDecl {
|
||||
type Error = AstError<'a, Self>;
|
||||
|
||||
fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result<Self, Self::Error> {
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user