checkpoint

This commit is contained in:
2023-09-24 08:12:35 -07:00
parent bd3b9af469
commit 4c53419fc0
2 changed files with 57 additions and 2 deletions

View File

@@ -34,6 +34,9 @@ pub enum Token {
#[token(";")]
Semi,
#[token(",")]
Comma,
#[token("(")]
LeftParen,
@@ -46,6 +49,16 @@ pub enum Token {
#[token(">")]
GreaterThan,
#[token("{")]
OpenBrace,
#[token("}")]
CloseBrace,
#[token("lambda")]
#[token("function")]
Function,
// Next we take of any reserved words; I always like to put
// these before we start recognizing more complicated regular
// expressions. I don't think it matters, but it works for me.
@@ -93,10 +106,14 @@ impl fmt::Display for Token {
match self {
Token::Equals => write!(f, "'='"),
Token::Semi => write!(f, "';'"),
Token::Comma => write!(f, "','"),
Token::LeftParen => write!(f, "'('"),
Token::RightParen => write!(f, "')'"),
Token::LessThan => write!(f, "<"),
Token::GreaterThan => write!(f, ">"),
Token::OpenBrace => write!(f, "{{"),
Token::CloseBrace => write!(f, "}}"),
Token::Function => write!(f, "function"),
Token::Print => write!(f, "'print'"),
Token::Operator(c) => write!(f, "'{}'", c),
Token::Number((None, otype, v)) => write!(f, "'{}{}'", v, display_optional_type(otype)),