[antlr-interest] shorthand for sequence of same tokens, e.g., A A A A A A

Bart Kiers bkiers at gmail.com
Thu Dec 15 14:02:50 PST 2011


No, that is not possible.

The closest you can come is create a fragment:

fragment HEX_DIGIT_BLOCK : HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT;

and then do:

Unicode_escape_sequence:
 | '\\u' HEX_DIGIT_BLOCK
 ;

Bart.

On Thu, Dec 15, 2011 at 11:00 PM, Christian <chwchw at gmx.de> wrote:

> Hi again,
>
> is there a way to abbreviate the definition of rule like the following?
>
> Unicode_escape_sequence:
>  | '\\u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT;
>
> It would be great to say something like that:
>
> Unicode_escape_sequence:
>  | '\\u' HEX_DIGIT{4};
>
> Regards,
> Christian
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list