Bool, Abool and Nil values are no longer tokens
This commit is contained in:
parent
567665a314
commit
b975bc52d0
|
@ -30,6 +30,12 @@ pub fn ablescript_consts() -> HashMap<String, Variable> {
|
|||
),
|
||||
("OCTOTHORPE", Str("#".to_owned())), // It's an octothorpe
|
||||
("ANSWER", Int(ANSWER)),
|
||||
("nul", Nul),
|
||||
("true", Bool(true)),
|
||||
("false", Bool(false)),
|
||||
("always", Abool(crate::variables::Abool::Always)),
|
||||
("sometimes", Abool(crate::variables::Abool::Sometimes)),
|
||||
("never", Abool(crate::variables::Abool::Never)),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(name, value)| (name.to_owned(), Variable::from_value(value)))
|
||||
|
|
|
@ -113,14 +113,6 @@ pub enum Token {
|
|||
Rickroll,
|
||||
|
||||
// Literals
|
||||
/// True, False
|
||||
#[regex("true|false", get_value)]
|
||||
Bool(bool),
|
||||
|
||||
/// Always, Sometimes, Never
|
||||
#[regex("always|sometimes|never", get_abool)]
|
||||
Abool(Abool),
|
||||
|
||||
/// String
|
||||
#[regex(r"/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*]*\*/)", get_string)]
|
||||
String(String),
|
||||
|
@ -136,9 +128,6 @@ pub enum Token {
|
|||
#[regex(r"owo .*")]
|
||||
Comment,
|
||||
|
||||
#[regex("nul")]
|
||||
Nul,
|
||||
|
||||
#[regex(r"[ \t\n\f]+", logos::skip)]
|
||||
#[error]
|
||||
Error,
|
||||
|
@ -156,15 +145,6 @@ fn get_string(lexer: &mut Lexer<Token>) -> String {
|
|||
.to_owned()
|
||||
}
|
||||
|
||||
fn get_abool(lexer: &mut Lexer<Token>) -> Option<Abool> {
|
||||
match lexer.slice() {
|
||||
"always" => Some(Abool::Always),
|
||||
"sometimes" => Some(Abool::Sometimes),
|
||||
"never" => Some(Abool::Never),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_ident(lexer: &mut Lexer<Token>) -> String {
|
||||
lexer.slice().to_owned()
|
||||
}
|
||||
|
|
|
@ -97,9 +97,6 @@ impl<'source> Parser<'source> {
|
|||
Token::Identifier(_)
|
||||
| Token::String(_)
|
||||
| Token::Integer(_)
|
||||
| Token::Abool(_)
|
||||
| Token::Bool(_)
|
||||
| Token::Nul
|
||||
| Token::Not
|
||||
| Token::LeftBracket
|
||||
| Token::LeftParen => Ok(Stmt::new(
|
||||
|
@ -167,14 +164,6 @@ impl<'source> Parser<'source> {
|
|||
}),
|
||||
start..self.lexer.span().end,
|
||||
)),
|
||||
Token::Abool(a) => Ok(Expr::new(
|
||||
ExprKind::Literal(Value::Abool(a)),
|
||||
start..self.lexer.span().end,
|
||||
)),
|
||||
Token::Bool(b) => Ok(Expr::new(
|
||||
ExprKind::Literal(Value::Bool(b)),
|
||||
start..self.lexer.span().end,
|
||||
)),
|
||||
Token::Integer(i) => Ok(Expr::new(
|
||||
ExprKind::Literal(Value::Int(i)),
|
||||
start..self.lexer.span().end,
|
||||
|
@ -187,11 +176,7 @@ impl<'source> Parser<'source> {
|
|||
})),
|
||||
start..self.lexer.span().end,
|
||||
)),
|
||||
Token::Nul => Ok(Expr::new(
|
||||
ExprKind::Literal(Value::Nul),
|
||||
start..self.lexer.span().end,
|
||||
)),
|
||||
|
||||
|
||||
Token::LeftBracket => match buf.take() {
|
||||
Some(buf) => Ok(Expr::new(
|
||||
self.index_flow(buf)?,
|
||||
|
|
Loading…
Reference in a new issue