Allow for comments in simplexpr

This commit is contained in:
elkowar 2021-07-28 17:16:01 +02:00
parent fcd54abf91
commit 8fea52bda9
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
2 changed files with 18 additions and 0 deletions

View file

@ -49,6 +49,7 @@ pub enum Token {
#[error] #[error]
#[regex(r"[ \t\n\f]+", logos::skip)] #[regex(r"[ \t\n\f]+", logos::skip)]
#[regex(r";.*", logos::skip)]
Error, Error,
} }
@ -101,4 +102,5 @@ fn test_simplexpr_lexer() {
use itertools::Itertools; use itertools::Itertools;
insta::assert_debug_snapshot!(Lexer::new(0, 0, r#"(foo + - "()" "a\"b" true false [] 12.2)"#).collect_vec()); insta::assert_debug_snapshot!(Lexer::new(0, 0, r#"(foo + - "()" "a\"b" true false [] 12.2)"#).collect_vec());
insta::assert_debug_snapshot!(Lexer::new(0, 0, r#"" " + music"#).collect_vec()); insta::assert_debug_snapshot!(Lexer::new(0, 0, r#"" " + music"#).collect_vec());
insta::assert_debug_snapshot!(Lexer::new(0, 0, r#"foo ; bar"#).collect_vec());
} }

View file

@ -0,0 +1,16 @@
---
source: crates/simplexpr/src/parser/lexer.rs
expression: "Lexer::new(0, 0, r#\"foo ; bar\"#).collect_vec()"
---
[
Ok(
(
0,
Ident(
"foo",
),
3,
),
),
]