coli-saar / alto

Alto, the Algebraic Language Toolkit
Other
17 stars 2 forks source link

Decide on string escape handling for backslashes #50

Open akoehn opened 5 years ago

akoehn commented 5 years ago

I implemented double quote escape in commit c61a99f, but this is still incomplete: It is currently impossible to have a single backslash at the end of the string:

"foo\" can't be written as the \ escapes the ". "foo\\" is okay but the result would be foo\\, not foo\.

I prefer to have Java escape semantics (backslash needs to be always escaped) but don't know whether this will break anything.

The alternative would be to interpret \\ as \ and also interpret \ as \, unless it is in front of either \ or ". I have the code for that and could implement it, but this rule is kind of non-standard and could confuse people.

Java enforces backslashes to be escaped an will throw an error otherwise. Should we do the same or be more lenient?