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

NullPointerException #82

Open
wizardxz opened this issue Jul 5, 2023 · 2 comments
Open

NullPointerException #82

wizardxz opened this issue Jul 5, 2023 · 2 comments

Comments

@wizardxz
Copy link

wizardxz commented Jul 5, 2023

Hi I am building antlr binary and use it to generate my parser and I saw a NPE in the runtime
Here is what I did

git clone -b rust-target https://github.com/rrevenantt/antlr4
git submodule update --init --recursive --remote
mvn -DskipTests install

Then I get

tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar

Run it to against Expr.g4

grammar Expr;
prog:   (expr NEWLINE)* ;
expr:   expr ('*'|'/') expr
    |   expr ('+'|'-') expr
    |   INT
    |   '(' expr ')'
    ;
NEWLINE : [\r\n]+ ;
INT     : [0-9]+ ;
java -jar antlr4-4.8-2-SNAPSHOT-complete.jar -Dlanguage=Rust Expr.g4 -o generated/expr -visitor
error(31):  ANTLR cannot generate Rust code as of version 4.8
Exception in thread "main" java.lang.NullPointerException
        at org.antlr.v4.analysis.LeftRecursiveRuleAnalyzer.getArtificialOpPrecRule(LeftRecursiveRuleAnalyzer.java:211)
        at org.antlr.v4.analysis.LeftRecursiveRuleTransformer.translateLeftRecursiveRule(LeftRecursiveRuleTransformer.java:116)
        at org.antlr.v4.analysis.LeftRecursiveRuleTransformer.translateLeftRecursiveRules(LeftRecursiveRuleTransformer.java:71)
        at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java:71)
        at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:382)
        at org.antlr.v4.Tool.process(Tool.java:369)
        at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:328)
        at org.antlr.v4.Tool.main(Tool.java:172)
@wizardxz
Copy link
Author

wizardxz commented Jul 5, 2023

I investigated the code a little bit, found the RustTarget does not exist here
https://github.com/rrevenantt/antlr4/blob/rust-target/tool/src/org/antlr/v4/codegen/CodeGenerator.java#L78

Do you have an idea about why the RustTarget is not loaded?
Thanks

@newca12
Copy link
Contributor

newca12 commented Aug 1, 2023

It simply mean that your fat jar was not built with the Rust target. Ensure you did the git submodule update in the antlr4 directory and that your Reactor Summary for your fat jar build is a full green SUCCESS.

git clone -b rust-target https://github.com/rrevenantt/antlr4
cd antlr4
git submodule update --init --recursive --remote
mvn -DskipTests install

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