Antlr4 extends BnfWriter { @Override protected void caseInsensitive(String value) { if (value.length() == 1) { inline(value); } else { String lexerRule = value.toUpperCase(); if (!Character.isLetter(value.codePointAt(0)) || reserved(lexerRule)) { lexerRule = "L_" + lexerRule; } output.append(lexerRule); keywordsInProduction.put(lexerRule, value); } } private  Antlr4(Output output); static void setPrefix(String newPrefix); static void resetPrefix(); static void write(Grammar grammar, Writer writer); static void write(Grammar grammar, OutputStream stream); static void write(Grammar grammar, Output output); static void main(String... args); @Override void close();  }
@Test public void shouldProduceCaseInsensitive() throws TransformerException { assertGenerates( grammar( "foo" ) .production( "bar", caseInsensitive( "LIteR@L" ) ) .build( Grammar.Builder.Option.ALLOW_ROOTLESS ), "grammar foo;", "", "oC_bar", " : LITER@L ;", "", "LITER@L : ( 'L' | 'l' ) ( 'I' | 'i' ) ( 'T' | 't' ) ( 'E' | 'e' ) ( 'R' | 'r' ) ( '@' | '@' ) ( 'L' | 'l' ) ;", "" ); }