Allowing escape characters in comments and as identifiers #4866
Replies: 1 comment 2 replies
-
@hs-apotell Did you solve this? let me know, because I might have an idea. This rule All you need to do is: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello -
Looking for some assistance with getting the rules correct for my use case. My language supports naming identifiers with all printable characters as long as it starts with a backslash and ends with a space (
ESCAPED_IDENTIFIERin the lexer rules below). Comments are much like most high level languages like C++ and Java (starting with two forward slashes and ending with a new line).The problem is when comments include escape characters like in the following input -
In the above example, comment line has embedded escaped quotes. This comments terminates prematurely right before the first escape backslash. On the second line, however, the escaped identifier is parsed correctly as long as the first line succeeds.
How do I update these rules to cover both these use cases? When in comment, continue parsing till the end of the line (accepting backslashes) but treat backslashes as start of escaped identifier when not parsing a comment?
Appreciate your time and valued input.
Beta Was this translation helpful? Give feedback.
All reactions