[antlr-interest] Fundamental tree parsing question

Ted Villalba ted.villalba at gmail.com
Tue Jul 10 11:03:39 PDT 2007


Hi,

I'm stuck trying to figure out how to distinguish between multi-term values
in a syntax tree.
For instance, the following rule rewrites to a simple tree:

field    : tag '=' LPAREN value RPAREN -> ^('=' tag value)

Here the root node is '=', and the children are both tag and value. The
problem is, if tag has multiple tokens, and value is multiple tokens, there
is no way (that I know of yet) to determine where 'tag'  stops and 'value'
starts.
So something like :
TAG A=(THE TREE TEST)

Will give you:

^(= TAG A THE TREE TEST)

If I want to reference the value for tag at this point, I don't know how.

This would seem a basic problem, but I haven't found any similar examples in
the literature. Has anyone run into this issue and how did you resolve it?

Thank you,
Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070710/c892211a/attachment.html 


More information about the antlr-interest mailing list