mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-16 17:00:53 +00:00
fix minor thing with string literal spans (and add a test)
This commit is contained in:
parent
09f00f7a56
commit
d5b2603bcb
@ -224,8 +224,8 @@ impl<'input> Tokenizer<'input> {
|
||||
match self.take_until(terminate) {
|
||||
Some(idx1) => {
|
||||
self.bump(); // consume the '"'
|
||||
let text = &self.text[idx0+1..idx1]; // do not include the `` in the str
|
||||
Ok((idx0, StringLiteral(text), idx1))
|
||||
let text = &self.text[idx0+1..idx1]; // do not include the "" in the str
|
||||
Ok((idx0, StringLiteral(text), idx1+1))
|
||||
}
|
||||
None => {
|
||||
Err(UnterminatedStringLiteral(idx0))
|
||||
|
@ -78,3 +78,12 @@ fn various_kinds_of_ids() {
|
||||
(" ~", GreaterThan),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn string_literals() {
|
||||
test(r#"foo "bar\"\n" baz"#, vec![
|
||||
(r#"~~~ "#, Id("foo")),
|
||||
(r#" ~~~~~~~~~ "#, StringLiteral(r#"bar\"\n"#)),
|
||||
(r#" ~~~"#, Id("baz")),
|
||||
]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user