[antlr-interest] Can Antlr use a variable in a lexer pattern?
Douglas Godfrey
douglasgodfrey at gmail.com
Fri Feb 25 08:33:36 PST 2011
in the snippet below, can "escape_character" be a variable?
it seems that this would not work because the "escape_character" is not
known until it is too late.
the alternate form below might work if the Antlr Lexer can use a variable in
the pattern match.
can the lexer apply the escape character as a post processing validation
step?
i.e. accept anything within the quotes and then validate the sequence
after the ESCAPE clause?
Unicode_Identifier =
U Ampersand
Double_Quote ( Unicode_Identifier_Part )+ Double_Quote
( ESCAPE escape_character )?
;
Alternate form:
Unicode_Identifier =
U Ampersand
( ESCAPE escape_character )?
Double_Quote ( Unicode_Identifier_Part )+ Double_Quote
;
fragment
Unicode_Identifier_Part = Unicode_Permitted_Identifier_Character |
Unicode_Escape_Value ;
fragment
Unicode_Escape_Value = Unicode_4_Digit_Escape_Value |
Unicode_6_Digit_Escape_Value ;
fragment
Unicode_4_Digit_Escape_Value = escape_character Hexit Hexit Hexit Hexit
;
fragment
Unicode_6_Digit_Escape_Value = escape_character Plus_Sign Hexit Hexit
Hexit Hexit Hexit Hexit ;
escape_character = Back_Slash /*!! See the Syntax Rules*/; ;
More information about the antlr-interest
mailing list