erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

`\` is not parsed properly #157

Closed GreasySlug closed 2 years ago

GreasySlug commented 2 years ago

Describe the bug

I am concerned about the behavior of \ in lexical analysis

The \ itself is not escaped.

Reproducible code

cargo run -- --mode lex
>>> a = "\""
[Symbol a, Equal =, StrLit "\"", EOF ]

however

>>>a = "\\"
Error[#0000]: File <stdin>, line 1        
1│ a = "\\"
       ^^^^
SyntaxError: the string is not closed by "

The following works well.

>>> a = "\\""
[Symbol a, Equal =, StrLit "\\"", EOF ]
>>> a = "\ "  
[Symbol a, Equal =, StrLit "\ ", EOF ]