nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
49 stars 31 forks source link

Add escaped backslash to strings #94

Closed bocchino closed 3 years ago

bocchino commented 3 years ago

Otherwise we can't write the character sequence \q, because it's interpreted as a double-quote character.

bocchino commented 3 years ago

Also think about reverting the notation for an escaped quotation mark to \". We switched to \q because it is less awkward at the end of a string. However, in either case we can't avoid \\, and \" is more standard.

bocchino commented 3 years ago

I've decided to keep \q for quotation marks and add \b for backslashes.

bocchino commented 3 years ago

After all that, I switched to a state-based parser for strings, instead of a regex-based parser. So I can now support \" and \\. I think it's better because it's more standard.

The new rule is that \c is interpreted as the literal character c in all cases. Nice and simple. In particular, to get a backslash in the interpreted string, you have to write \\ in all cases. This fosters consistency.

bocchino commented 3 years ago

Done in commit 5b60cf7a65d0bf23f8cf31fa2e8a4cf037057174.