[antlr-interest] [C Target] How to skip a whole sub-tree (not just a token)

Mohamed Yousef harrrrpo at gmail.com
Fri Nov 13 13:36:47 PST 2009

Sorry , it seems i jumped to a wrong result
indices are calculated correctly and UP&Down are taken into consideration
the real problem that i discovered now
is that during tree parsing nodes have no info about the real start and end
positions till respective childs are parsed , so here :

      ^(EIF ^(EIF_COND c =expr_g)  { // examine c and selectively jump to e
}  )

EIF would think and respond as c is the end of the world , it has no
knowledge of EIF_THEN

so we have either two solutions :
1) go parse it by hand : tedious , inefficient , probably won't be generic
2) another idea i have now is to store node indices (e.g. for COND , THEN,
ELSE in EIF ) either during parsing or in a separate walk to "flow control"

i will try both and see
any better ideas ?

2009/11/13 Mohamed Yousef <harrrrpo at gmail.com>

> Hello all,
> i sent before regarding a bug in Control flow  in which a e=. won't define
> e , i was suggested by jim to walk tree my self using LT
> now i have a problem , consider following
> if_expr
>     :
>       ^(EIF ^(EIF_COND c =expr_g) ^(EIF_THEN e=expr_g)  ) { // examine c
> and selectively jump to e }
> must be changed to something like
> if_expr
>     :
>       ^(EIF ^(EIF_COND c =expr_g)  { // examine c and selectively jump to e
> }  )
> and we have a problem
> how can we skip the whole EIF_THEN tree (when c is false ) ? , if we try to
> use the stopIndex of EIF to jump to it's end
> we have the problem that all returned indices ,by all means , don't take UP
> & DOWN nodes into accout , where the SEEK macro
> takes them into accout
> any ideas ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091113/17183473/attachment.html 

More information about the antlr-interest mailing list