diff --git a/compiler/erg_parser/lex.rs b/compiler/erg_parser/lex.rs index 6acdfba4f..4201b12c7 100644 --- a/compiler/erg_parser/lex.rs +++ b/compiler/erg_parser/lex.rs @@ -562,6 +562,7 @@ impl Lexer /*<'a>*/ { 'r' => s.push('\r'), 'n' => s.push('\n'), '\'' => s.push('\''), + '"' => s.push('"'), 't' => s.push_str(" "), // tab is invalid, so changed into 4 whitespace '\\' => s.push('\\'), _ => { diff --git a/compiler/erg_parser/tests/test1_basic_syntax.er b/compiler/erg_parser/tests/test1_basic_syntax.er index ffd77c3fc..8b8d5a9b9 100644 --- a/compiler/erg_parser/tests/test1_basic_syntax.er +++ b/compiler/erg_parser/tests/test1_basic_syntax.er @@ -6,7 +6,7 @@ a, _, ...b = five_elem_tuple f x, y = x + y if! True, do!: - print! "\\hello, world\"" + print! "\"\\hello, world\\\"" 10.times! do!: if! x.y.z, do!: print! "" diff --git a/compiler/erg_parser/tests/test3_literal_syntax.er b/compiler/erg_parser/tests/test3_literal_syntax.er index 2bbae6203..d9eb12d5b 100644 --- a/compiler/erg_parser/tests/test3_literal_syntax.er +++ b/compiler/erg_parser/tests/test3_literal_syntax.er @@ -9,7 +9,7 @@ 0.00, -0.0, .1, 400. # Str Literal -"", "a", "こんにちは", "\" \\ " +"", "a", "こんにちは", "\"\\", "\"\'\\\0\r\n\t" # Boolean Litteral True, False diff --git a/compiler/erg_parser/tests/tokenize_test.rs b/compiler/erg_parser/tests/tokenize_test.rs index 47744926a..6371de344 100644 --- a/compiler/erg_parser/tests/tokenize_test.rs +++ b/compiler/erg_parser/tests/tokenize_test.rs @@ -37,7 +37,7 @@ fn test_lexer_for_basic() -> ParseResult<()> { (Comma, ","), (UBar, "_"), (Comma, ","), - (Spread, "..."), // EllipsisLit + (EllipsisLit, "..."), (Symbol, "b"), (Equal, "="), (Symbol, "five_elem_tuple"), @@ -62,7 +62,7 @@ fn test_lexer_for_basic() -> ParseResult<()> { (Newline, newline), (Indent, " "), (Symbol, "print!"), - (StrLit, "\"\\\\hello, world\\\"\""), + (StrLit, "\"\"\\hello, world\\\"\""), (Newline, newline), (NatLit, "10"), (Dot, "."), @@ -264,7 +264,9 @@ fn test_lexer_for_literals() -> ParseResult<()> { (Comma, ","), (StrLit, "\"こんにちは\""), (Comma, ","), - (StrLit, "\"\\\" \\\\ \""), + (StrLit, "\"\"\\\""), + (Comma, ","), + (StrLit, "\"\"\'\\\0\r\n \""), (Newline, newline), (Newline, newline), (Newline, newline),