[antlr-interest] Fundamental tree parsing question

Ted Villalba ted.villalba at gmail.com
Tue Jul 10 11:57:21 PDT 2007


Thanks guys, for the tips. I've been trying to introduce imaginary nodes
into my grammar, but ANTLRWorks keeps flipping out on me when I walk through
the debugger.
I've tried a couple configurations similar to what ya'll sent, but when
stepping through, my CPU and RAM get pegged and I start getting a bunch of
these:

java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source)
    at sun.nio.cs.StreamDecoder$CharsetSD.implRead(Unknown Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at java.io.BufferedReader.fill(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at org.antlr.runtime.debug.DebugEventSocketProxy.ack(
DebugEventSocketProxy.java:95)
    at org.antlr.runtime.debug.DebugEventSocketProxy.transmit(
DebugEventSocketProxy.java:106)
    at org.antlr.runtime.debug.DebugEventSocketProxy.becomeRoot(
DebugEventSocketProxy.java:260)
    at org.antlr.runtime.debug.DebugTreeAdaptor.becomeRoot(
DebugTreeAdaptor.java:60)
    at WQLParser.tag(WQLParser.java:1316)
    at WQLParser.field(WQLParser.java:663)
    at WQLParser.query(WQLParser.java:252)
    at WQLParser.start(WQLParser.java:126)
    at __Test__.main(__Test__.java:16)

On 7/10/07, Benjamin Niemann <pink at odahoda.de> wrote:
>
> Hello,
>
> Ted Villalba wrote:
>
> > 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?
>
> You could introduce imaginary token types TAGS and VALUES (one of those
> would be sufficient, but for symmetry...). Then use
>
> field: tag '=' LPAREN value RPAREN -> ^('=' ^(TAGS tag) ^(VALUES value))
>
> (or make tag and value return trees rooted by TAGS/VALUES).
>
>
> HTH
>
> --
> Benjamin Niemann
> Email: pink at odahoda dot de
> WWW: http://pink.odahoda.de/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070710/9ea2cfb9/attachment.html 


More information about the antlr-interest mailing list