Fwd: [antlr-interest] Tree parsing problem

Bryan Ewbank ewbank at gmail.com
Thu May 19 09:18:52 PDT 2005


The "!" after DOT in your grammar rules discards the DOTs from the
generated list of nodes.  If you want them in the list, remove the "!"
- but do you /really/ want them there, since you know what they are?

Another way is to use
   IDENT ( DOT^ IDENT )*
which builds a left-desending tree of binary nodes with the DOTs as
the intermediate nodes.

As a different way, you might consider allowing "." to be part of an
identifier, and then blow if apart later if needed...

On 5/19/05, Serafettin Senturk <serafettin_sentuerk at intergral.com> wrote:
>   I am trying to display variables with dots like (a.b.c.d) in my AST
> generated by tree parser. For this reason, I have written the following rule
> in my parser:
>
>   identifier
>         :
>                 IDENT (DOT! IDENT)*
>                 {#identifier = #(#[ILIST,"ILIST"], identifier);}
>         ;
>
>    The following is the one that i have written in my tree parser grammar:
>
>         ilist
>         :       #(ILIST (IDENT)*)
>         ;
>
>    In this case, i cannot see the DOTs(.) in my AST. But i want to include
> DOTs in the AST and see them. When i write (DOT^) or only DOT in my parser,
> it does not work. Does anybody have an idea how i can include this DOTs in
> my AST?
>
>   Regards,
>  Serafettin
>
>
>
>
>
>


More information about the antlr-interest mailing list