[antlr-interest] AST Tree question
Gibson, Andrea
AGibson at carrieraccess.com
Tue Jan 16 13:31:43 PST 2007
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/20070116/f16105ee/attachment.html
More information about the antlr-interest
mailing list