Allowing escape characters in comments and as identifiers #4866
Unanswered
hs-apotell
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_IDENTIFIER
in 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