-
I'm attempting to build a parser for the COOL language. (Not for any class, but just as a personal project) To handle strings in cool there are not really any escape sequences. Sequences such as \t and \n are retained as part of the string literal. Strings may also contain doublequotes, provided they are preceded with a backslash:
This string should be printed to the screen as:
Unlike escape sequences, the backslash is not consumed. I simply cannot figure out how to approach this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The easiest way is to simply use a backslash escape sequence, where the value of |
Beta Was this translation helpful? Give feedback.
The easiest way is to simply use a backslash escape sequence, where the value of
"
is `"``: https://godbolt.org/z/197PoK54v