[antlr-interest] antlr3-maven-plugin tries to generate the xxxLexer.java when using a combined lexer/parser grammar

Ruben Laguna ruben.laguna at gmail.com
Mon Jan 2 03:52:16 PST 2012


Hi,

I'm experiencing the following exception.

[INFO] ANTLR: Processing source directory
C:\Users\ecerulm\IdeaProjects\BodyMethodParser\src\main\antlr3
ANTLR Parser Generator  Version 3.4
com\rubenlaguna\cppbody\CppBody.g
error(1):  cannot write file : java.io.FileNotFoundException:
C:\Users\ecerulm\IdeaProjects\BodyMethodParser\target\generated-sources\antlr3\C:\Users\ecerulm\IdeaProjects\BodyMethodParser\src\main\antlr3\CppBodyLexer.java
(The filename, directory name, or volume label syntax is incorrect)
java.io.FileOutputStream.open(Native Method)
java.io.FileOutputStream.<init>(FileOutputStream.java:179)
java.io.FileOutputStream.<init>(FileOutputStream.java:131)
java.io.FileWriter.<init>(FileWriter.java:73)
org.antlr.Tool.getOutputFile(Tool.java:871)
org.antlr.codegen.CodeGenerator.write(CodeGenerator.java:1262)
org.antlr.codegen.Target.genRecognizerFile(Target.java:94)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:460)
org.antlr.Tool.generateRecognizer(Tool.java:655)
org.antlr.Tool.process(Tool.java:524)
org.antlr.mojo.antlr3.Antlr3Mojo.execute(Antlr3Mojo.java:378)


It seems like the filename for the implicitly generated lexer.java is
faulty, it appends the absolute path to the output dir so there are
two "c:\" in the filename. I look into the source code and the problem
(IMHO) seems to be in Tool.java although I'm surprised that nobody has
experienced the same problem yet. So I'm wondering if I'm doing
something wrong. Anyway, I just did a quick fix in
org.antlr.Tool.process() that I'm attaching a patch here. I don't
claim that it's the way to go but it gets the Lexer.java file in the
proper directory (at least when using maven) but I didn't test it in
standalon (not maven) and don't know if it will break anything else.
So

Does anybody has the same problem when using maven and combined
grammars? Should I try to report this bug in other way or the antlr
developers usually read this mailing list?

Best regards,

--
/Rubén
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug_fix__lexer_file_is_generated_in_proper_directory1.patch
Type: application/octet-stream
Size: 1048 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120102/fc760bc1/attachment.obj 


More information about the antlr-interest mailing list