Preserve escape sequence after formatting
Bumped into this randomly. We do correctly parse escape sequence, but the format would simply but the unescaped string back on save. Now it properly re-escapes strings before flushing them back. I also removed the escape sequence for 'backspace' and 'new page' form feed as I don't see any use case for those in an Aiken program really...
This commit is contained in:
@@ -28,4 +28,9 @@ mod tests {
|
||||
fn bytearray_utf8_encoded() {
|
||||
assert_expr!("\"aiken\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bytearray_utf8_escaped() {
|
||||
assert_expr!("\"\\\"aiken\\\"\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/parser/expr/bytearray.rs
|
||||
description: "Code:\n\n\"\\\"aiken\\\"\""
|
||||
---
|
||||
ByteArray {
|
||||
location: 0..11,
|
||||
bytes: [
|
||||
34,
|
||||
97,
|
||||
105,
|
||||
107,
|
||||
101,
|
||||
110,
|
||||
34,
|
||||
],
|
||||
preferred_format: Utf8String,
|
||||
}
|
||||
@@ -196,10 +196,7 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
|
||||
|
||||
let escape = just('\\').ignore_then(
|
||||
just('\\')
|
||||
.or(just('/'))
|
||||
.or(just('"'))
|
||||
.or(just('b').to('\x08'))
|
||||
.or(just('f').to('\x0C'))
|
||||
.or(just('n').to('\n'))
|
||||
.or(just('r').to('\r'))
|
||||
.or(just('t').to('\t')),
|
||||
|
||||
Reference in New Issue
Block a user