diff --git a/src/parser.rs b/src/parser.rs index 76e5cca..5c71870 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -214,6 +214,7 @@ impl Parser { /// ``` /// primary := "(" expression ")" /// primary := FALSE | TRUE | NIL | STRING | NUMBER + /// primary := IDENTIFIER /// ``` fn parse_primary(&mut self) -> Result { if self.expect(&[TokenType::LeftParen]).is_some() { @@ -231,6 +232,9 @@ impl Parser { TokenType::Number(_) | &TokenType::String(_) => Ok(ast::ExprNode::Litteral { value: self.advance().clone(), }), + TokenType::Identifier(_) => Ok(ast::ExprNode::Variable { + name: self.advance().clone(), + }), _ => Err(ParserError::new(self.peek(), "expected expression")), } }