Fwd: [antlr-interest] Hi, is there anybody tell me how to get parse tree?

=?GB2312?B?0MLC8g==?= inshua at gmail.com
Sun Feb 5 18:20:23 PST 2006


---------- Forwarded message ----------
From: 新买 <inshua at gmail.com>
Date: 2006-2-6 上午10:19
Subject: Re: [antlr-interest] Hi, is there anybody tell me how to get parse
tree?
To: Jeff Barnes <jbarnesweb at yahoo.com>


Hello,

Thank your help.

Thus my problem is,  "(" SHOULD be included in the tree,(In  classic book,
this kind of tree named parse tree, not AST). Thanks for your hint, I'v
remove the "!" symbol from rule, now "(" and ")" are included in the tree.

But, only when there isn't space in the  expression, it can works ok.
Repeat my goal :
An expression before parse:
 ( 1 + 2 ) - 3
when parse complete,user get a visible tree:
-
   +  1
      2
   3

now user click "+" node, the text  "(1+2)" will be highlighted as:

( 1 + 2 ) - 3

:) interesting?

thanks.

Shimin

2006/2/6, Jeff Barnes <jbarnesweb at yahoo.com>:
>
> You should probably read the fine manual again. It
> took me several readings to begin to wrap my head
> around the subject matter.
>
> To get the AST to ignore '(' your parser should have
> something along the lines of
>
> expr:
>    ((LPAREN)?)! multexpr (PLUS^ multexpr)?
> ((RPAREN)?)!
> ;
>
> Tweak until it fits...
>
> Regards,
> Jeff
>
> --- ÐÂÂò <inshua at gmail.com> wrote:
>
> > as (1+2) + 3
> > parse tree will include the "(" token, which will be
> > ignore in AST.
> > so the expression (1+2) has 5 leaf : ( , 1, + , 2,
> > ).
> >
> > for I wanna make an IDE, so locating source code is
> > necessary, is there
> > anybody tell me about it?
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060206/29382995/attachment.html


More information about the antlr-interest mailing list