Skip to content

Commit

Permalink
word token regex was wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Oct 23, 2024
1 parent 0786cd1 commit 081b237
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion v0.5/fastn-p1/src/parser_v3/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Scanner {
Scanner {
tokens: fastn_p1::Token::lexer(source)
.spanned()
.map(|(r, span)| (r.unwrap(), span))
.map(|(r, span)| (dbg!(r.unwrap()), span))
.collect(),
index: 0,
output: fastn_p1::ParseOutput {
Expand Down
1 change: 1 addition & 0 deletions v0.5/fastn-p1/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn test_all() {
fn p1(file: impl AsRef<std::path::Path> + std::fmt::Debug, fix: bool) {
let json = file.as_ref().with_extension("json");
let s = std::fs::read_to_string(&file).unwrap();
println!("testing {file:?}");
let output = fastn_p1::ParseOutput::new("foo", &s);
let expected_json =
fastn_p1::test::sorted_json::to_json(&serde_json::to_value(&output).unwrap());
Expand Down
4 changes: 2 additions & 2 deletions v0.5/fastn-p1/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum Token {
#[regex("--")]
DashDash,

#[regex(r"[\w]+")]
#[regex(r"[^\s]+", priority = 0)]
Word,

#[regex("[\t ]+")]
Expand Down Expand Up @@ -81,7 +81,7 @@ mod test {
let source = include_str!("../t/002-tutorial.ftd");
assert_eq!(
dbg!(super::Token::lexer(source).spanned().collect::<Vec<_>>()).len(),
585
434
);
}
}

0 comments on commit 081b237

Please sign in to comment.