rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Handle escaped "" and ``. #65

Closed schungx closed 2 years ago

schungx commented 2 years ago

A double "" inside a string is an escaped " character.

Similarly, a double back-tick `` is an escaped ` character.

This PR handles these double escapes.

tamasfe commented 2 years ago

Thanks, I added tests as well, lgtm.

schungx commented 2 years ago

There is still some slight differences, for example, Rhai will throw syntax error on any non-recognized escapes (e.g. \w), and only allows recognized ones. This parsing allows anything following \.

Do you think we should make it consistent?

tamasfe commented 2 years ago

Do you think we should make it consistent?

In the future, definitely, the two implementations should be as close as possible.

I wouldn't consider this a high priority right now. Also escapes that aren't required for the tokenization have to be validated at later stages, in the parser or I'd even push it all the way to the HIR.