[antlr-interest] found more bugs in ANTLRv3.g + howto add separator when parallel iterating 2 lists in stringtemplate
Jens Boeykens
jens.boeykens at gmail.com
Tue Jul 8 05:51:59 PDT 2008
Another error in ANTLRv3.g:
*rewrite_tree_element
: rewrite_tree_atom
| rewrite_tree_atom ebnfSuffix
-> ^( ebnfSuffix ^(BLOCK["BLOCK"] ^(ALT["ALT"] rewrite_tree_atom
EOA["EOA"]) EOB["EOB"]))
| rewrite_tree
( ebnfSuffix
-> ^(ebnfSuffix ^(BLOCK["BLOCK"] ^(ALT["ALT"] rewrite_tree
EOA["EOA"]) EOB["EOB"]))
| -> rewrite_tree
)
| rewrite_tree_ebnf
;*
The 3rd alternative did not include the ebnfSuffix in the tree. It seems
nothing needs to be changed in ANTLRv3Tree.g but I don't fully understand
the transition of rewrite_tree_element from ANTLRv3.g to ANTLRv3Tree.g so I
could be mistaken here.
Jens
2008/7/8 Jens Boeykens <jens.boeykens at gmail.com>:
> Another detail for rule rewrite_tree_atom that I am not sure if it is
> correct:
>
> In ANTLRv3.g : ^(TOKEN_REF ARG_ACTION?)
> In ANTLRv3Tree.g: ^(TOKEN_REF ARG_ACTION)
>
> The question mark dissapeared. I added it in my code, but not sure if
> it is necessary...
>
> Another thing I did not understand very well (probably my own fault ;) ) :
> There is a rule called "rewrite_template_block" which is defined, but no
> other rule seems to be using it. Does this make the rule obsolete? I noticed
> this because I have not yet encountered a testcase where the rule was used,
> so I am not sure wether I should write more tests or the rule is indeed
> obsolete.
>
> Kind regards
>
> 2008/7/8 Jens Boeykens <jens.boeykens at gmail.com>:
>
> Thanks it worked!!
>>
>> I've encounterd another issue with ANTLRv3.g but it's not a very important
>> one. When you end your grammar with a single line comment like
>>
>> // this is my comment<eof>
>>
>> thus no '\n' at the end but directly end of file, the parser will complain
>> it is looking for a '\n'.
>>
>> Jens
>>
>> 2008/7/7 Terence Parr <parrt at cs.usfca.edu>:
>>
>>
>>> On Jul 7, 2008, at 2:23 PM, Jens Boeykens wrote:
>>>
>>>> block(blok, optionsSpec, alternative, rewrite, eob) ::= <<
>>>>>> <alternative,rewrite: {alt,rw | <alt> <rw> | }>
>>>>>> >>
>>>>>>
>>>>>> I have one '|' too many in my output:
>>>>>> r: a -> int | b -> char |;
>>>>>>
>>>>>
>>>>> Use <...; separator="|">
>>>>>
>>>>
>>>> Sorry I can't find the exact syntax to use here. Remember I need 2 lists
>>>> here.
>>>> <alternative,rewrite; separator=" | "> and <alternative rewrite;
>>>> separator=" | "> give errors...
>>>>
>>>
>>> Oh, sorry.
>>>
>>> <alternative,rewrite: {alt,rw | <alt> <rw>}; separator="|">
>>>>>>
>>>>>
>>> Should work
>>> Ter
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080708/b28e6099/attachment.html
More information about the antlr-interest
mailing list