[antlr-interest] Fixed width field
Gavin Lambert
antlr at mirality.co.nz
Wed Aug 1 01:26:20 PDT 2007
At 20:10 1/08/2007, Joel Shellman wrote:
>Is there a way to specify a number of matches of something?
[...]
>rule4: CHAR CHAR CHAR;
>
>I know this would do 3 times, but it's rather unwieldy
especially
>if I had 36 or 150 or something like that. Is there some syntax
>to specify to match n times?
Nope. But you can composite them if you really need to:
char5: CHAR CHAR CHAR CHAR CHAR;
char10: char5 char5;
char50: char10 char10 char10 char10 char10;
char150: char50 char50 char50;
Although for really fixed-width input you'd probably want to do it
in the lexer. Or not use ANTLR at all, since fixed-width is easy
:)
More information about the antlr-interest
mailing list