account for comment delimiters in strings
This commit is contained in:
parent
0a01f9178c
commit
7d2fe51709
2 changed files with 10 additions and 0 deletions
|
|
@ -143,6 +143,10 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
|
||||||
}
|
}
|
||||||
// eat the whole line
|
// eat the whole line
|
||||||
'#' | ';' => {
|
'#' | ';' => {
|
||||||
|
if is_str {
|
||||||
|
token.push(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ign = true;
|
ign = true;
|
||||||
delim_stack.push('\n');
|
delim_stack.push('\n');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ mod lex_tests {
|
||||||
assert_eq!(lex(&document).unwrap().to_string(), document);
|
assert_eq!(lex(&document).unwrap().to_string(), document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_comment_delim_in_str() {
|
||||||
|
let document = String::from("('#')");
|
||||||
|
assert_eq!(lex(&document).unwrap().to_string(), document);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_empty_string() {
|
fn test_empty_string() {
|
||||||
let document = String::from("('')");
|
let document = String::from("('')");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue