[antlr-interest] Composite Grammar issues

Pedro Francisco pedrogfrancisco at gmail.com
Sun Jul 22 04:31:58 PDT 2012


Hello!
I won't debug this further for the time being but here are my
findings, may be of use to someone.

Context: I was trying to split Java.g (OpenJDK's Java.g, not
examples-v3's) into JavaLexer.g and JavaParser.g and import them from
a Main.g. I'd change rules originally from Java.g and then paste them
on Main.g, with the purpose of rewriting the parsed text (on this
phase I found the first bug, already discussed here on the ML, in
which the lexer is not created unless some lexer rules are present on
Main.g).
I am using "((TokenRewriteStream)input.delete($a,$b)" every now and then.

Having no errors compiling, I got a different output than expected. I
then tried to copy all the rules from JavaParser.g and JavaLexer.g
(minus duplicate rules) and the parser would work as expected.

Besides not working as expected, I'd have on the output text the
following symptoms:
"/**" became "**"
"/*" became "*"
"array's element" became "arrayelement"
(comments are $channel=hidden, not skip())

This was with ANTLR3.4-SNAPSHOT ( 20120712 ). I also tried ANTLR3.4
and ANTLR3.3 but on those versions I just noticed the parser was
misbehaving and did not check if the above errors ocurred as well. ST4
doesn't like ANTLR3.2 (ClassNotFoundException) and I didn't try
stripping ST code to test on ANTLR3.2.

I'm sorry I can't help for now with more debugging. If I have the
chance I'll test again with ANTLR4 in the future but that will take a
while. As such the above text is only to be taken as a "me too" in
case anyone else finds a similar issue.
-- 
Pedro


More information about the antlr-interest mailing list