[antlr-interest] Question about the cost of implementing case insensitivity in an Antlr Lexer

Douglas Godfrey douglasgodfrey at gmail.com
Sat Mar 5 09:51:49 PST 2011


What is the relative cost for implementing case insensitive lexer tokens [as
shown below] versus case sensitive tokens?

// case sensitive keywords

GRAPH: 'GRAPH';
DIGRAPH: 'DIGRAPH';
STRICT: 'STRICT';
NODE: 'NODE';
EDGE: 'EDGE';
SUBGRAPH: 'SUBGRAPH';

// case-insensitive keywords

GRAPH: G R A P H;
DIGRAPH: D I G R A P H;
STRICT: S T R I C T;
NODE: N O D E;
EDGE: E D G E;
SUBGRAPH: S U B G R A P H;


fragment A:('a'|'A');
fragment B:('b'|'B');
fragment C:('c'|'C');
fragment D:('d'|'D');
fragment E:('e'|'E');
fragment F:('f'|'F');
fragment G:('g'|'G');
fragment H:('h'|'H');
fragment I:('i'|'I');
fragment J:('j'|'J');
fragment K:('k'|'K');
fragment L:('l'|'L');
fragment M:('m'|'M');
fragment N:('n'|'N');
fragment O:('o'|'O');
fragment P:('p'|'P');
fragment Q:('q'|'Q');
fragment R:('r'|'R');
fragment S:('s'|'S');
fragment T:('t'|'T');
fragment U:('u'|'U');
fragment V:('v'|'V');
fragment W:('w'|'W');
fragment X:('x'|'X');
fragment Y:('y'|'Y');
fragment Z:('z'|'Z');


More information about the antlr-interest mailing list