Allow digits in identifiers in simplexpr
This commit is contained in:
parent
142894c3ce
commit
ec8b12d206
5 changed files with 17 additions and 2 deletions
|
@ -99,7 +99,7 @@ regex_rules! {
|
|||
r"[ \n\n\f]+" => |_| Token::Skip,
|
||||
r";.*"=> |_| Token::Comment,
|
||||
|
||||
r"[a-zA-Z_-]+" => |x| Token::Ident(x.to_string()),
|
||||
r"[a-zA-Z_][a-zA-Z0-9_-]*" => |x| Token::Ident(x.to_string()),
|
||||
r"[+-]?(?:[0-9]+[.])?[0-9]+" => |x| Token::NumLit(x.to_string())
|
||||
}
|
||||
|
||||
|
@ -278,6 +278,8 @@ mod test {
|
|||
|
||||
snapshot_string! {
|
||||
basic => v!(r#"bar "foo""#),
|
||||
digit => v!(r#"12"#),
|
||||
number_in_ident => v!(r#"foo_1_bar"#),
|
||||
interpolation_1 => v!(r#" "foo ${2 * 2} bar" "#),
|
||||
interpolation_nested => v!(r#" "foo ${(2 * 2) + "${5 + 5}"} bar" "#),
|
||||
escaping => v!(r#" "a\"b\{}" "#),
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
source: crates/simplexpr/src/parser/lexer.rs
|
||||
expression: "v!(r#\"12\"#)"
|
||||
|
||||
---
|
||||
(0, NumLit("12"), 2)
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
source: crates/simplexpr/src/parser/lexer.rs
|
||||
expression: "v!(r#\"foo_1_bar\"#)"
|
||||
|
||||
---
|
||||
(0, Ident("foo_1_bar"), 9)
|
|
@ -4,6 +4,7 @@
|
|||
//};
|
||||
|
||||
fn main() {
|
||||
println!("hi");
|
||||
// let mut files = codespan_reporting::files::SimpleFiles::new();
|
||||
|
||||
// let input = r#"
|
||||
|
|
|
@ -69,7 +69,7 @@ impl YuckFiles {
|
|||
}
|
||||
|
||||
impl YuckFiles {
|
||||
fn get_file(&self, id: usize) -> Result<&YuckFile, codespan_reporting::files::Error> {
|
||||
pub fn get_file(&self, id: usize) -> Result<&YuckFile, codespan_reporting::files::Error> {
|
||||
self.files.get(&id).ok_or(codespan_reporting::files::Error::FileMissing)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue