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

internal error: NullPointerException #162

Closed
166MMX opened this issue Aug 31, 2014 · 3 comments
Closed

internal error: NullPointerException #162

166MMX opened this issue Aug 31, 2014 · 3 comments

Comments

@166MMX
Copy link

166MMX commented Aug 31, 2014

Getting this NPE while trying to generate a Lexer - syntax of the grammar might be broken

error(100): jconfig/src/main/antlr3/com/initvoid/jconfig/zconf/ZConfHelpLexer.g:17:1: syntax error: antlr: org.antlr.runtime.EarlyExitException
context [anonymous] 1:10 attribute rules isn't defined
error(100): jconfig/src/main/antlr3/com/initvoid/jconfig/zconf/ZConfHelpLexer.g:0:1: syntax error: assign.types: org.antlr.runtime.EarlyExitException
org/antlr/grammar/v3/DefineGrammarItemsWalker.g: node from line 109:4 required (...)+ loop did not match anything at input ';'
error(10):  internal error: jconfig/src/main/antlr3/com/initvoid/jconfig/zconf/ZConfHelpLexer.g : java.lang.NullPointerException
org.antlr.grammar.v3.CodeGenTreeWalker.rules(CodeGenTreeWalker.java:901)
org.antlr.grammar.v3.CodeGenTreeWalker.grammarSpec(CodeGenTreeWalker.java:877)
org.antlr.grammar.v3.CodeGenTreeWalker.grammar_(CodeGenTreeWalker.java:479)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:415)
org.antlr.Tool.generateRecognizer(Tool.java:674)
org.antlr.Tool.process(Tool.java:487)
org.antlr.Tool.main(Tool.java:98)

cmd args

-o jconfig/build/generated-src/main/java
jconfig/src/main/antlr3/com/initvoid/jconfig/zconf/ZConfHelpLexer.g

'org.antlr:antlr:3.5.2'

$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

Grammar file: https://gist.github.com/166MMX/2f4fb04313794e3572ae

@robstoll
Copy link
Contributor

@lexer::header {package com.initvoid.jconfig.zconf;}

has to be after the tokens section

@166MMX
Copy link
Author

166MMX commented Oct 4, 2014

Yep I figured that one out too. Was just reporting it since it throws an NPE and the other messages aren't really descriptive either. So you end up being stuck in the woods and have to start digging around whats wrong. Eventually users might find this bug report after spending some time to try to figure out whats wrong. Maybe the best solution would be to catch this case and report the user about the wrong order or pointing the user to the manual in order to make it less frustrating to work with antlr.

@sharwell
Copy link
Member

sharwell commented Oct 4, 2014

@166MMX The processing for these headers was rewritten for ANTLR 4 to prevent the confusion (and allow the headers to appear in any order). Since ANTLR 3 is essentially in maintenance mode and this issue does not have any impact on overall correctness of valid grammars, it's unlikely to get fixed unless someone sends a pull request with a very low-risk implementation of the feature.

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

3 participants