Let\'s say that I want to match \"beer\", but don\'t care about case sensitivity.
Currently I am defining a token to be (\'b\'|\'B\' \'e\'|\'E\' \'e\'|\'E\' \'r\'|
A solution I used in C#: use ASCII code to shift character to smaller case.
class CaseInsensitiveStream : Antlr4.Runtime.AntlrInputStream {
public CaseInsensitiveStream(string sExpr)
: base(sExpr) {
}
public override int La(int index) {
if(index == 0) return 0;
if(index < 0) index++;
int pdx = p + index - 1;
if(pdx < 0 || pdx >= n) return TokenConstants.Eof;
var x1 = data[pdx];
return (x1 >= 65 && x1 <= 90) ? (97 + x1 - 65) : x1;
}
}