AST - Represent the "super" keyword as a VariableExpr

This commit is contained in:
Emmanuel BENOîT 2023-01-16 07:31:54 +01:00
parent 1a39e40325
commit 45ffa5cdab
2 changed files with 5 additions and 2 deletions

View file

@ -138,7 +138,7 @@ pub struct VariableExpr {
#[derive(Debug, Clone)]
pub struct SuperExpr {
/// The 'super' token itself
pub keyword: Token,
pub keyword: VariableExpr,
/// The identifier that contains the method name
pub method: Token,
}

View file

@ -753,7 +753,10 @@ impl Parser {
self.consume(&TokenType::Dot, "expected '.' after 'super'")?;
let identifier = self.consume_identifier("expected method name")?;
Ok(ExprNode::Super(SuperExpr {
keyword: super_token,
keyword: VariableExpr {
token: super_token,
id: self.make_id(),
},
method: identifier,
}))
} else if self.expect(&[TokenType::Fun]).is_some() {