[antlr-interest] AST Tree question

Jose Ventura jose.ventura.roda at gmail.com
Wed Jan 17 03:25:07 PST 2007


Can you put the 'host' and 'port' rules?



2007/1/16, Gibson, Andrea <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/20070117/e45d98a4/attachment-0001.html 


More information about the antlr-interest mailing list