[antlr-interest] Re: linear list from tree
Marc
mschellens at gmail.com
Thu Aug 11 01:54:17 PDT 2005
On 8/10/05, Marc <mschellens at gmail.com> wrote:
> I would like to build a linear list made from the 'expr' which are
> spread over a tree.
> The following grammer fragment does not work.
> So how to do it?
>
> Thanks,
> marc
>
> output should be:
> #( ARRAYIN e1_1 e1_2 e1_3 ...)
> // _1, _2 ... loop number
Sorry, that should read iteration number.
Inspired by Bryan's reply I got it working, but a general question remains:
How to append something to the actual list, within a loop?
ie.
rule!
: (#(A e:expr (ee:expr)?)
)+
output should be something like:
(e1 ee1 e2 e3 ee3 e4 ...)
the numbers are again denote the interation number
Thanks,
marc
>
>
> arrayindex_list!
> : ( #(ARRAYIX
> ( ALL
> | ( e1:expr // 0 or 2
> {
> #arrayindex_list = #( NULL,
> (arrayindex_list),e1);
> // also not working: #arrayindex_list = #( arrayindex_list,e1);
> // #arrayindex_list = #(
> (arrayindex_list),e1);
>
>
> }
> )
> )
> )+
> {
> // #arrayindex_list = #([ARRAYIX,"[...]"], arrayindex_list);
> // #arrayindex_list->SetArrayIndexList( ixList.release());
> }
> ;
>
More information about the antlr-interest
mailing list