antlr / antlr/antlr3

I got null pointer exception when I build antlr gramma (C target) with antlr-3.3 version.(and with antlr-3.5 version)

Open
#117 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
253
Forks
178
PR merge metrics
No merged PRs in 30d

Description

I used gramma : https://github.com/porcelli/plsql-parser. For Java target it is compiled and work.
1)
At first I rewrited this gramma for C target. I tried to generate C code using antlr 3.3, but got exception : (lexer is ok, but parser failed)

```
error(10): internal error: PLSQLParser.g : java.lang.NullPointerException
org.antlr.codegen.Target.getTokenTypeAsTargetLabel(Target.java:150)
org.antlr.codegen.CodeGenerator.getTokenTypeAsTargetLabel(CodeGenerator.java:886)
org.antlr.codegen.ACyclicDFACodeGenerator.walkFixedDFAGeneratingStateMachine(ACyclicDFACodeGenerator.java:120)
org.antlr.codegen.ACyclicDFACodeGenerator.genFixedLookaheadDecision(ACyclicDFACodeGenerator.java:48)
org.antlr.codegen.CodeGenerator.genLookaheadDecision(CodeGenerator.java:635)
org.antlr.grammar.v3.CodeGenTreeWalker.block(CodeGenTreeWalker.java:2754)
org.antlr.grammar.v3.CodeGenTreeWalker.ebnf(CodeGenTreeWalker.java:4650)
org.antlr.grammar.v3.CodeGenTreeWalker.element(CodeGenTreeWalker.java:3821)
org.antlr.grammar.v3.CodeGenTreeWalker.alternative(CodeGenTreeWalker.java:3576)
org.antlr.grammar.v3.CodeGenTreeWalker.block(CodeGenTreeWalker.java:2984)
org.antlr.grammar.v3.CodeGenTreeWalker.rule(CodeGenTreeWalker.java:2285)
org.antlr.grammar.v3.CodeGenTreeWalker.rules(CodeGenTreeWalker.java:1488)
org.antlr.grammar.v3.CodeGenTreeWalker.grammarSpec(CodeGenTreeWalker.java:1405)
org.antlr.grammar.v3.CodeGenTreeWalker.grammar_(CodeGenTreeWalker.java:492)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:415)
org.antlr.Tool.generateRecognizer(Tool.java:696)
org.antlr.Tool.process(Tool.java:509)
org.antlr.Tool.main(Tool.java:98)
```

2)
After first fail, I took original gramma for java and changed only option about target language to C target. And got the same exception in antlr.

Maybe someone know what's the problem?

PS: tried this operations with antlr 3.5 and got the same problem.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce generation from PLSQLParser.g with the C target using ANTLR 3.3 and 3.5, then inspect the reported path through org.antlr.codegen.Target.getTokenTypeAsTargetLabel and ACyclicDFACodeGenerator. Done means identifying the grammar or code-generation condition causing the null pointer and either producing C code or a clear diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.