I am trying to build a compiler using antlr and for now I want to limit the length of the identifiers in my language to less than 9.
My code now look like this:
IDENTIFIER: CHAR(CHAR|INT)*;
where CHAR
and INT
are both fragments. I am wondering if there is any convenient way for me to achieve my goal instead of using this:
IDENTIFIER: CHAR(CHAR|INT)(CHAR|INT)...(CHAR|INT);//repeate (CHAR|INT) 8 times.
Thanks for help.