Allow whitespace after line ending backslash (#162)
This commit is contained in:
parent
f07ba88de4
commit
a9fb3bf188
|
@ -364,7 +364,24 @@ impl<'a> Tokenizer<'a> {
|
||||||
let len = if c == 'u' {4} else {8};
|
let len = if c == 'u' {4} else {8};
|
||||||
val.push(me.hex(start, i, len)?);
|
val.push(me.hex(start, i, len)?);
|
||||||
}
|
}
|
||||||
Some((_, '\n')) if multi => {
|
Some((i, c @ ' ')) |
|
||||||
|
Some((i, c @ '\t')) |
|
||||||
|
Some((i, c @ '\n')) if multi => {
|
||||||
|
if c != '\n' {
|
||||||
|
while let Some((_, ch)) = me.chars.clone().next() {
|
||||||
|
match ch {
|
||||||
|
' ' | '\t' => {
|
||||||
|
me.chars.next();
|
||||||
|
continue
|
||||||
|
},
|
||||||
|
'\n' => {
|
||||||
|
me.chars.next();
|
||||||
|
break
|
||||||
|
},
|
||||||
|
_ => return Err(Error::InvalidEscape(i, c)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
while let Some((_, ch)) = me.chars.clone().next() {
|
while let Some((_, ch)) = me.chars.clone().next() {
|
||||||
match ch {
|
match ch {
|
||||||
' ' | '\t' | '\n' => {
|
' ' | '\t' | '\n' => {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
invalid-escape = """\
|
||||||
|
This string has a non whitespace-character after the line ending escape. \ a
|
||||||
|
"""
|
|
@ -15,6 +15,10 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": ""
|
"value": ""
|
||||||
},
|
},
|
||||||
|
"multiline_empty_five": {
|
||||||
|
"type": "string",
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
"equivalent_one": {
|
"equivalent_one": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": "The quick brown fox jumps over the lazy dog."
|
"value": "The quick brown fox jumps over the lazy dog."
|
||||||
|
@ -26,5 +30,9 @@
|
||||||
"equivalent_three": {
|
"equivalent_three": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": "The quick brown fox jumps over the lazy dog."
|
"value": "The quick brown fox jumps over the lazy dog."
|
||||||
|
},
|
||||||
|
"equivalent_four": {
|
||||||
|
"type": "string",
|
||||||
|
"value": "The quick brown fox jumps over the lazy dog."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,11 @@ multiline_empty_four = """\
|
||||||
\
|
\
|
||||||
\
|
\
|
||||||
"""
|
"""
|
||||||
|
multiline_empty_five = """\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
"""
|
||||||
|
|
||||||
equivalent_one = "The quick brown fox jumps over the lazy dog."
|
equivalent_one = "The quick brown fox jumps over the lazy dog."
|
||||||
equivalent_two = """
|
equivalent_two = """
|
||||||
|
@ -21,3 +26,9 @@ equivalent_three = """\
|
||||||
fox jumps over \
|
fox jumps over \
|
||||||
the lazy dog.\
|
the lazy dog.\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
equivalent_four = """\
|
||||||
|
The quick brown \
|
||||||
|
fox jumps over \
|
||||||
|
the lazy dog.\
|
||||||
|
"""
|
||||||
|
|
Loading…
Reference in a new issue