mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'lemu/src/lexer.rs')
-rw-r--r--lemu/src/lexer.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/lemu/src/lexer.rs b/lemu/src/lexer.rs
index 63d5eda..01a75b4 100644
--- a/lemu/src/lexer.rs
+++ b/lemu/src/lexer.rs
@@ -8,19 +8,19 @@ macro_rules! instrs {
pub enum Token<'strings> {
#[token("\n")]
Newline,
- #[regex("#[^\n]+")]
+ #[regex("#[^\n]+", priority = 8)]
Comment(&'strings str),
#[regex(r"[0-9]+(\.[0-9]+)?", |lex| lex.slice().parse().ok())]
#[regex(r"(true)|(false)", |lex| lex.slice().parse::<bool>().ok().map(f64::from), priority = 10)]
#[regex(r#"0[xX][0-9a-fA-F]+"#, |lex| u64::from_str_radix(&lex.slice()[2..], 16).map(|v| v as f64).ok())]
#[regex(r#"0[bB][01]+"#, |lex| u64::from_str_radix(&lex.slice()[2..], 2).map(|v| v as f64).ok())]
#[regex(r#""[0-9]+(\.[0-9]+)?""#, callback = |lex| lex.slice()[1..lex.slice().len()-1].parse().ok(), priority = 13)]
- Num(f64),
+ Num(f64), // TODO have bool and integer tokens, and parser converts
#[regex(r#""([^\\"\n])*""#, callback = |lex| Cow::from(&lex.slice()[1..lex.slice().len()-1]), priority = 12)]
- #[regex(r#"@[^ "\n]*"#, |lex| Cow::from(&lex.slice()[1..]))]
+ #[regex(r#"@[^ "\n]*"#, |lex| Cow::from(lex.slice()))]
#[regex(r#""[^"]*""#, callback = |lex| Cow::from(lex.slice()[1..lex.slice().len()-1].replace(r"\n", "\n")), priority = 8)]
String(Cow<'strings, str>),
- #[regex("[^0-9 \t\n]+", priority = 7)]
+ #[regex("[^@0-9 \t\n][^ \t\n]*", priority = 7)]
Ident(&'strings str),
$(#[token($z, priority = 8)] $v,)+
@@ -41,7 +41,7 @@ macro_rules! instrs {
}
instrs! {
- "getlink" => GetLink,
+ "null" => Null,
"read" => Read,
"write" => Write,
"set" => Set,
@@ -50,7 +50,6 @@ instrs! {
"drawflush" => DrawFlush,
"draw" => Draw,
"print" => Print,
- "packcolor" => PackColor,
"jump" => Jump,
"stop" => Stop,
"@counter" => Counter,
@@ -118,7 +117,7 @@ impl<'s> Lexer<'s> {
}
#[allow(dead_code)]
-pub fn print_stream<'s>(mut stream: Lexer) {
+pub fn print_stream(mut stream: Lexer) {
print!("[");
let Some(tok) = stream.next() else {
println!("]");