lang: state with confusing error

This commit is contained in:
Schrottkatze 2024-04-08 15:43:42 +02:00
commit bfd4b3765f
No known key found for this signature in database
5 changed files with 74 additions and 24 deletions

View file

@ -14,7 +14,23 @@ pub enum Token<'a> {
Let,
#[token("in")]
In,
#[regex("[a-zA-Z0-9_\\-]+", |lex| lex.slice())]
#[regex("[\\d]+", |lex| lex.slice())]
Int(&'a str),
#[regex("[+-]?([\\d]+\\.[\\d]*|[\\d]*\\.[\\d]+)", |lex| lex.slice())]
Float(&'a str),
// TODO: more bigger better more complex string lexing
// TODO: templating?
#[regex(r#""([^"\\]|\\["\\bnfrt]|u[a-fA-F0-9]{4})*""#, |lex| lex.slice())]
String(&'a str),
#[token("+")]
Plus,
#[token("-")]
Minus,
#[token("*")]
Mult,
#[token("/")]
Div,
#[regex("[a-zA-Z_]+[a-zA-Z0-9_\\-]*", |lex| lex.slice())]
Word(&'a str),
#[regex("\\$[a-zA-Z0-9_\\-]+", |lex| &lex.slice()[1..])]
VarIdent(&'a str),