Lex and parse bool literals
This commit is contained in:
parent
6217b83cd8
commit
732d80dd9a
|
@ -54,6 +54,10 @@ pub enum Token {
|
|||
#[token("==")] OpEq,
|
||||
#[token("!=")] OpNeq,
|
||||
|
||||
// boolean literals
|
||||
#[token("true")] True,
|
||||
#[token("false")] False,
|
||||
|
||||
#[regex(r"[a-zA-Z_][a-zA-Z0-9_]*")]
|
||||
Identifier,
|
||||
|
||||
|
|
|
@ -299,6 +299,8 @@ impl<'a> Expr<'a> {
|
|||
Token::OctalInteger => Self::Literal(Literal::OctalInteger(lexer.slice())),
|
||||
Token::HexInteger => Self::Literal(Literal::HexInteger(lexer.slice())),
|
||||
Token::DecimalInteger => Self::Literal(Literal::DecimalInteger(lexer.slice())),
|
||||
Token::True => Self::Literal(Literal::Boolean(true)),
|
||||
Token::False => Self::Literal(Literal::Boolean(false)),
|
||||
Token::Semicolon | Token::BraceClose | Token::ParanClose => return (None, tok),
|
||||
_ => lexer.panic_message("Unexpected token"),
|
||||
};
|
||||
|
@ -390,6 +392,7 @@ pub enum Literal<'a> {
|
|||
OctalInteger(&'a str),
|
||||
HexInteger(&'a str),
|
||||
DecimalInteger(&'a str),
|
||||
Boolean(bool),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Reference in New Issue