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

nondeterminism warning in grammar, maven plugin does not compile #10

Open
laeubi opened this issue Jul 30, 2019 · 5 comments
Open

nondeterminism warning in grammar, maven plugin does not compile #10

laeubi opened this issue Jul 30, 2019 · 5 comments

Comments

@laeubi
Copy link
Contributor

laeubi commented Jul 30, 2019

Running mvn antlr:generate produce the following output:

[INFO] ------------------------------------------------------------------------
[INFO] Building jcamp-dx 
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- antlr-maven-plugin:2.2:generate (default-cli) @ jcamp-dx ---
[INFO] performing grammar generation [ASDFLexer.g]
ANTLR Parser Generator   Version 2.7.2   1989-2003 jGuru.com
src/main/antlr/ASDFLexer.g: warning:lexical nondeterminism between rules XCHECK and PAC upon
src/main/antlr/ASDFLexer.g:     k==1:'+','-','0'..'9'
src/main/antlr/ASDFLexer.g:     k==2:<end-of-token>,'0'..'9'
src/main/antlr/ASDFLexer.g:39: warning:lexical nondeterminism upon
src/main/antlr/ASDFLexer.g:39:     k==1:'0'..'9'
src/main/antlr/ASDFLexer.g:39:     k==2:'0'..'9'
src/main/antlr/ASDFLexer.g:39:     between alt 1 and exit branch of block

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
@laeubi laeubi changed the title Gramar does not compile Grammar does not compile Jul 30, 2019
@fracpete
Copy link
Owner

fracpete commented Aug 6, 2019

Never had to compile the grammar before. Using the maven plugin didn't work for me at all.
However, using antlr2 directly from command-line worked:

runantlr -o target/generated-sources/antlr/org/jcamp/parser src/main/antlr/ASDFLexer.g
runantlr -o target/generated-sources/antlr/org/jcamp/parser src/main/antlr/ASDFParser.g

NB: You will end up with duplicate classes, namely ASDFLexer, ASDFLexerTokenTypes, ASDFParser, ASDFParserTokenTypes. The original authors must have moved these classes manually into src/main/java.

@laeubi
Copy link
Contributor Author

laeubi commented Aug 6, 2019

Yeah my goal was to configure the plugin so it places the classes into src/main/generated or something and remove them from src/main/java and let them compile on every run.
Do you think it is worth to try upgrading the antlr plugin to antlr4?

@laeubi
Copy link
Contributor Author

laeubi commented Aug 6, 2019

I also noticed that antlr seem to generate the required source into the directory (in fact it is only a warning) but since the build is marked as a failure this does not help much.
Do you get any warnings on the commandline? What version of antlr are you using?

@fracpete
Copy link
Owner

fracpete commented Aug 6, 2019

I get the same warnings like you do. However, I don't consider warnings a failure. ;-)

@laeubi
Copy link
Contributor Author

laeubi commented Aug 6, 2019

For these kind of things I like to treat warnings as errors :-)
Because exactly the ASDF is causing problems here #3 with parsing failed expecting EOL, found '-7' and the parser complains about an nondeterminism of k==1:'+','-','0'..'9' and k==2:<end-of-token>,'0'..'9'

@laeubi laeubi changed the title Grammar does not compile nondeterminism warning in grammar, maven plugin does not compile Aug 6, 2019
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

2 participants