[antlr-interest] AST Tree question
Gibson, Andrea
AGibson at carrieraccess.com
Thu Jan 18 08:13:58 PST 2007
Yeah sure,
port: (DIGIT)+;
Where DIGIT is just 0-9
And
host : hostName
| ipv6Reference;
hostName
:(domainLabel(PERIOD)? )*;
ipv6Reference
: OPEN_BRACKET ipv6Address CLOSE_BRACKET;
-Gabbie
_____
From: Jose Ventura [mailto:jose.ventura.roda at gmail.com]
Sent: Wednesday, January 17, 2007 4:25 AM
To: Gibson, Andrea
Cc: ANTLR Interest
Subject: Re: [antlr-interest] AST Tree question
Can you put the 'host' and 'port' rules?
2007/1/16, Gibson, Andrea <AGibson at carrieraccess.com
<mailto:AGibson at carrieraccess.com> >:
Hello,
I am having some trouble with setting up a tree structure so that I can
easily get the text below, and I was wondering if someone could give me some
help.
Here is the code I am working on
hostPort returns[HostPort hp = null]
{ Integer p=null;}
: (h:host (c:COLON^ p1:port)?)
{ hp= new HostPort(#h.getText());
if(#p1!=null) p=Integer.parseInt(#p1.getText());
if(p!=null)hp = new HostPort(#h.getText(),p);};
And what I want is the text from the host and port. But with how I have it
set up now, #h.getText() is just the first character in the host, and if I
traverse the AST tree using getRight() it continues though all the
characters including into the port. Is there a way to separate these out? Is
there a way to make the host be a root of another tree and not have it based
around a token from the lexer?
Any help is appreciated.
-Gabbie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070118/7dd9fe30/attachment-0001.html
More information about the antlr-interest
mailing list