[antlr-interest] [C target] [3.1.3] several bugs in the generated parser

Tomas Potrusil potrto at centrum.cz
Thu Jun 11 04:56:36 PDT 2009


All those problems remain there also for the latest builds (from May
21, version 3.1.4-SNAPSHOT)

add 1) Is there any hope that it will be fixed soon? Or can I write
that grammar any other way in order to achieve the similar
functionality?
add 2) The sample grammar is attached.

Tom

2009/6/10 Jim Idle <jimi at temporal-wave.com>:
> Tomas Potrusil wrote:
>> 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));
>>
> I think that all of that is fixed in the 3.1.4 beta if you want to try
> that, but there is a fundamental problem in that the Java target is
> using overloaded functions to do this and I have no way at template
> generation time to know what the intent was. Realistically, we need to
> make the code generator call a different template or set a flag to say
> which behavior it is expecting.
>> 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)
>>
> You probably need to send me an example please. Also, please verify that
> this is the same with 3.1.4-beta as that sounds familiar.
>> 3. The wildcard is not working for the C target! I reported that here
>> already that there was no response.
> Sorry, but I have been busy earning a living lately. I am aware of this,
> and am just not quite in sync with Java on that one. But, you can easily
> do the same thing with an action code.
>> 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)
>>
>>
> I don't think that I am quite in sync with the Java target on rewrite of
> wildcards. However, again, you can achieve this with a bit of action
> code.  I will make sure that I have these bugs logged,
>
> Jim
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SqlOrig.g
Type: application/octet-stream
Size: 351 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090611/424727d2/attachment.obj 


More information about the antlr-interest mailing list