[antlr-interest] Question with greedy

Andreas Volz lists at brachttal.net
Thu Sep 24 15:19:11 PDT 2009


Am Wed, 23 Sep 2009 15:29:32 -0700 schrieb Jim Idle:

> > Could anyone explain this error and how to prevent it?
> >    
> 
> Well, you have not specified to the lexer what it should do with
> those chars (I assume that this is C from your code above):
> 
> NL : ('\r' | '\n')+ { $channel=HIDDEN; } ;
> ANY : . { SKIP(); } ; // Always make this the very last lexer rule

Thanks for your answers. I tried it and it works. Now I've the next
problem that I tried to solve with a greedy=false rule, but failed.

Input Data:

key:value
key:value
key:value
key:value
key:value

For key are all chars allowed until the first ':' arrives. For value
all chars are allowed. Also another ':' which should no be handled
special. My example works, but it fails e.g. is value is an URL
(http://...).

Could you help me again?

regards
	Andreas


More information about the antlr-interest mailing list