[antlr-interest] Greedy matching to end of line

Jim Idle jimi at temporal-wave.com
Fri Jan 28 09:18:29 PST 2011


Just use code in an action.


xxx: TOKEN
	{ while (input.LA(1) != NL) { /* process input.LT(1).toString() */
}
    NL
;

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Robert J. Hansen
> Sent: Friday, January 28, 2011 6:33 AM
> To: Pop Qvarnström
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Greedy matching to end of line
>
> > Just a thought: depending on what you do with the things after a
> 'Comment:', you could just match .+ :
>
> Well, I need to pull data out of what comes after the 'Comment:'.  If I
> can find some way to match .+ out to the first newline, and then
> extract the contents into $value, I'd be a happy camper.
>
> (The grammar I posted has no return values.  The actual grammar I use
> does, since I hook up actions to various rules.)
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list