Skip to content
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

Error with books source examples in chapter 4 #4609

Open
2 of 4 tasks
netskink opened this issue May 2, 2024 · 0 comments
Open
2 of 4 tasks

Error with books source examples in chapter 4 #4609

netskink opened this issue May 2, 2024 · 0 comments

Comments

@netskink
Copy link

netskink commented May 2, 2024

  • I have reproduced my issue using the latest version of ANTLR
    • I am using the latest binary. I did not build from source. I just downloaded the jar file as book suggested.
  • I have asked at stackoverflow
  • Responses from the above seem to indicate that my issue could be an ANTLR bug
  • I have done a search of the existing issues to make sure I'm not sending in a duplicate
    • I searched issues and did not find it.

Please include the following information:

  • target information (Java, C++ ...)
    • java --version says
      • openjdk 19.0.2 2023-01-17
      • OpenJDK Runtime Environment (build 19.0.2+7-44)
  • smallest possible grammar and code that reproduces the behavior
  • description of the expected behavior and actual behavior
    Pointers to suspicious code regions are also very welcome.

Trying to build the .g4 file from the books source examples fails

$ java -jar /Users/davis/progs/github/antlrtesty/jars/antlr-4.13.1-complete.jar -o out  antlr/Java.g4
FAILED: out/antlr 
java -jar /Users/davis/progs/github/antlrtesty/jars/antlr-4.13.1-complete.jar -o out  antlr/Java.g4
error(156): Java.g4:653:35: invalid escape sequence \"

This is the section of Java.g4 which fails with line numbers:

651 fragment
652 EscapeSequence
653     :   '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
654     |   UnicodeEscape
655     |   OctalEscape
656     ;

It appears the '\" is breaking.

Rebuilding with this line does work but emits multiple warnings.

Mod:

    :   '\\' ('b'|'t'|'n'|'f'|'r'|'\''|'\\')

Warnings:

warning(157): Java.g4:547:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:548:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:549:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:550:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:551:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:552:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:553:14: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:554:13: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:555:21: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:556:25: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:557:21: rule expression contains an assoc terminal option in an unrecognized location
warning(157): Java.g4:558:14: rule expression contains an assoc terminal option in an unrecognized location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant