[antlr-interest] [C target] [3.1.3] several bugs in the generated parser
Tomas Potrusil
potrto at centrum.cz
Wed Jun 10 04:56:03 PDT 2009
Hello,
I've found the following bugs in the generated parser (C target):
1. This is the most annoying problem because I cannot solve it any
other way. My tree grammar is:
function: ^(Function ^(DatabaseObject Nil COUNT) countArgument) ->
^(Function[$COUNT.text] countArgument);
The excerpt from generated code for this is:
pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR,
(pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, Function,
(pANTLR3_UINT8)(COUNT162->getText(COUNT162))), root_1));
The COUNT162->getText(COUNT162) function returns pANTLR3_STRING which
is casted to pANTLR3_UINT8??? When I manually change the code to:
root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR,
(pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, Function,
(pANTLR3_UINT8)(COUNT162->getText(COUNT162)->chars)), root_1));
it works as expected.
2. My tree grammar doesn't do a lot. Because of that I wanted to
switch on rewriting (options {rewrite = true;}). But the generated
parser was not able to be compiled. Some variables were not defined,
getParent() function was called on ADAPTOR which doesn't contain
anything similar etc. (when I generated Java parser from that grammar
it was compiled correctly)
3. The wildcard is not working for the C target! I reported that here
already that there was no response. So once more. My tree grammar is
similar to:
func: ^(FUNC arg=.) -> ^(Function $arg);
When I try to generate a parser a crazy error message appears that a
template rewriteWildcardLabelRef.st cannot be found. (again, for Java
everything works as expected)
Best regards,
Tomas
More information about the antlr-interest
mailing list