[antlr-interest] match any token in line

Tobias Wunner tobias.wunner at gmail.com
Thu May 7 01:43:44 PDT 2009


Hello,

new to ANTLR I wondered if it is possible to match ".*" expressions.  
So I do not have to explicitly define the tokens to be matched and  
capture all kinds of tokens including UTF-8 characters. My input  
format I would like to process looks like:

@<CLASS-IDENTIFIER1>:
record1
record2
...
recordn
@<CLASS-IDENTIFIER2>
...

as for instance

@class1:
.*cat
@class3:
bob
jack
@class6:
df2
dfe4

Now wrote the following grammar

in		:	cname*;
cname	:	'@' CHAR* '\n' (param '\n')*;
param	:	CHAR*;
CHAR	:	'a'..'z';

The problem her is that I could only detect records with 'a'..'b'.  
Could I replace this with ".*" to match any token?

Another idea was to match any token but '@' with [^'@']* as known from  
regular expressions - somehow I did not get this work with ANTLR?

Regards,
Toby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090507/9443a4c8/attachment.html 


More information about the antlr-interest mailing list