Add parser (and etc.) support for print statements.

This commit is contained in:
2022-02-16 20:52:23 -08:00
parent 0293eee2d0
commit 6c5ca6b782
4 changed files with 35 additions and 27 deletions

View File

@@ -11,6 +11,9 @@ pub enum Token {
#[token(";")]
Semi,
#[token("print")]
Print,
#[regex(r"[+\-*/]", |v| v.slice().chars().next())]
Operator(char),
@@ -35,6 +38,7 @@ impl fmt::Display for Token {
match self {
Token::Equals => write!(f, "'='"),
Token::Semi => write!(f, "';'"),
Token::Print => write!(f, "'print'"),
Token::Operator(c) => write!(f, "'{}'", c),
Token::Number((None, v)) => write!(f, "'{}'", v),
Token::Number((Some(2), v)) => write!(f, "'0b{:b}'", v),