Well, you are asking for the contents of a parse construct, not a lexer
rule you understand? This says ANY token 0 or more times, then a ';'. For
a start, that is about as ambiguous as you can get of course. IF you are
looking for any token (not character) sequence followed by ';' then you
likely want:
s_t_s : ~';'* ';' ;
Then to get the text of the tokens:
s_t_s : (a=~';' {System.out.println($a.text); } )* ';' ;
But instead of println, accumulate in a StringBuilder or similar.
Jim
> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Douglas Godfrey
> Sent: Wednesday, September 07, 2011 9:24 PM
> To: Dejas Ninethousand; Antlr-Interest Antlr.Org
> Subject: Re: [antlr-interest] How can I get the string contents of a
> Kleene Closure?
>
> rich_newick_string : semicolon_terminated_string {
> stack.pushRichNewickString($semicolon_terminated_string.text); };
>
> semicolon_terminated_string
>
> : (.*';') ;
>
>
>
>
> On 9/6/11 5:44 PM, "Dejas Ninethousand" <[email protected]> wrote:
>
> >I have the following production in my ANTLR grammar:
> >
> >rich_newick_string
> >: str=(.*';') { stack.pushRichNewickString($str.text); };
> >
> >I expected some string match to be passed to my pushRichNewickString
> >method, but instead I'm getting null. What am I doing wrong?
> >
> >Thanks.
> >
> >List: http://www.antlr.org/mailman/listinfo/antlr-interest
> >Unsubscribe:
> >http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.