Skip to content

Commit

Permalink
Disallow literal regex parsing with last token ]
Browse files Browse the repository at this point in the history
This fixes one of the examples brought up in #54
  • Loading branch information
ezrosent committed Mar 31, 2021
1 parent ae22202 commit 7961110
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,11 @@ print w,z;
"5 3\n"
);

test_program!(
division_parse, r#"BEGIN { a[0] = 4; t = 2; print "test/test\t" (a[0] / t)}"#,
"test/test\t2\n"
);

test_program!(
identity_function,
r#"function id(x) { return x; }
Expand Down
4 changes: 3 additions & 1 deletion src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ impl<'a> Tokenizer<'a> {
fn potential_re(&self) -> bool {
match &self.prev_tok {
Some(Tok::Ident(_)) | Some(Tok::StrLit(_)) | Some(Tok::PatLit(_))
| Some(Tok::ILit(_)) | Some(Tok::FLit(_)) | Some(Tok::RParen) => false,
| Some(Tok::ILit(_)) | Some(Tok::FLit(_)) | Some(Tok::RParen) | Some(Tok::RBrack) => {
false
}
_ => true,
}
}
Expand Down

0 comments on commit 7961110

Please sign in to comment.