mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-03 18:29:00 +00:00
feat: implement methods declaration syntax
This commit is contained in:
parent
a694880ff4
commit
b4b02fd0f6
5 changed files with 82 additions and 11 deletions
|
@ -1039,6 +1039,9 @@ impl Parser {
|
|||
Expr::TypeAscription(tasc) => {
|
||||
attrs.push(ClassAttr::Decl(tasc));
|
||||
}
|
||||
Expr::Literal(lit) if lit.is_doc_comment() => {
|
||||
attrs.push(ClassAttr::Doc(lit));
|
||||
}
|
||||
other => {
|
||||
self.errs
|
||||
.push(ParseError::simple_syntax_error(0, other.loc()));
|
||||
|
@ -1054,9 +1057,9 @@ impl Parser {
|
|||
}
|
||||
}
|
||||
let attrs = ClassAttrs::from(attrs);
|
||||
let class = Self::expr_to_type_spec(class).map_err(|e| self.errs.push(e))?;
|
||||
let t_spec = Self::expr_to_type_spec(class.clone()).map_err(|e| self.errs.push(e))?;
|
||||
debug_exit_info!(self);
|
||||
Ok(Methods::new(class, vis, attrs))
|
||||
Ok(Methods::new(t_spec, class, vis, attrs))
|
||||
}
|
||||
|
||||
fn try_reduce_do_block(&mut self) -> ParseResult<Lambda> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue