This is possible, but only if you have such a basic grammar that the reason for using ANTlr is in any case denied.
If you have a grammar:
text : ANY_CHAR* ; ANY_CHAR : . ;
he will do what you (it seems) need.
However, as many have pointed out, this would be rather strange. The goal of a lexer is to identify the different tokens that can be combined into a parser to form a grammar, so your lexer can either identify a particular “JSTL / EL” string as a token, or [AZ] / EL, [AZ] ' / '[AZ] [AZ] etc. - depending on what you need.
Then the parser is used to determine the grammar, therefore:
phrase : CHAR* jstl CHAR* ; jstl : JSTL SLASH QUALIFIER ; JSTL : 'JSTL' ; SLASH : '/' QUALIFIER : [AZ][AZ] ; CHAR : . ;
will accept the entry "blah blah JSTL / EL ..." but not "blah blah ELST / JSTL ...".
I would advise taking a look at The Definitive ANTlr 4 Reference, in particular the Islands in the Stream section and Grammar Reference (Ch 15), which specifically deals with Unicode.
source share