-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ANTLR backend: Spurious escaping of single quotes in character sets #329
Comments
It is not fixed in v2.9.0, at least not completely. Here is how to reproduce it from a Bash shell. I assume that you have Git, downloaded antlr-4.9-complete.jar (see https://www.antlr.org/download/index.html), downloaded Java (I have jdk-11.0.4), and placed the Java executable on
The output of this is:
|
Ok, this seems to be a problem with more recent ANTLR versions, it is still ok with 4.5:
|
Ok, thanks. That kind of sucks. I'll check out Antlr's source and see what got messed up. |
It seems like BNFC is still not implementing the escaping correctly, see the rules at: https://github.com/antlr/antlr4/blob/master/doc/lexer-rules.md
This is wrong. I suppose ANTLR got stricter checking the rules. |
I think it's a regression in the Antlr rules. This stuff was moved into lexer modes, which broke things. My first test using EscAny without modes works fine with |
There are at least two Git issues raised and then closed on escaped characters in Antlr: antlr/antlr4#1537 antlr/antlr4#1871 . For |
I am fixing the spurious escaping of
I left a comment at antlr/antlr4#1537: antlr/antlr4#1537 (comment) I also filed antlr/antlr4#3024. |
Did the fix work for you, @kaby76 ? |
Yes, that fixed the problem. Thank you. It took me a while to get a build working because I work mostly on Windows in a MINGW64 environment. I could not get the build to work via Cabal (https://github.com/BNFC/bnfc#installing-the-development-version), but |
PRs welcome!
I used to do CI on travis, but am migrating to Github Actions because of the new limitations for OSS builds by travis-ci. |
I'm using BNF.cf and bnfc 2.8.4 to generate an Antlr4 grammar which I then strip and use for my extension in a language server. The generated lexer code is syntactically incorrect and not accepted by the Antlr 4.9 tool.
I'm not sure why this isn't accepted by the Antlr grammar, after all, EscAny is in Antlr4's lexer rule. I will investigate further. But I recommend removing the backslashes before the single and double-quotes.
Disregard if this is already fixed.
The text was updated successfully, but these errors were encountered: