[antlr-interest] match any token in line
Nukiti Romanova
nukiti at yahoo.de
Thu May 7 11:54:02 PDT 2009
maybe is this what you want?
in : cname*;
cname : '@' CHAR* ':' NL param*;
param : (CHAR|':')+ NL+;
CHAR : ~(NewLineChars|'@'|':')+ ;
NL : NewLineChars+;
fragment NewLineChars
: '\n'
| '\r'
;
Nukiti
>> 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
More information about the antlr-interest
mailing list