ISO14977 extends BnfWriter { @Override protected void caseInsensitive( String value ) { group( () -> { String sep = ""; int start = 0; for ( int i = 0, end = value.length(), cp; i < end; i += Character.charCount( cp ) ) { cp = value.charAt( i ); if ( Character.isLowerCase( cp ) || Character.isUpperCase( cp ) || Character.isTitleCase( cp ) ) { if ( start < i ) { output.append( sep ); sep = ","; enclose( value.substring( start, i ) ); } output.append( sep ); sep = ","; start = i + Character.charCount( cp ); cp = Character.toUpperCase( cp ); addCaseChar( cp ); appendCaseChar( cp ); } } if ( start < value.length() ) { output.append( sep ); enclose( value.substring( start ) ); } } ); } private  ISO14977( Output output ); 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 ); static void append( Grammar.Term term, Output output ); static Output string( Output str, Production production ); static void html( HtmlTag parent, Production production, HtmlLinker linker );  }
@Test public void shouldRenderCaseInsensitiveLiteral() throws Exception { verify( production( "foo", caseInsensitive( "LIteR@L" ) ), "foo = L,I,T,E,R,'@',L ;", "", "E = 'E' | 'e' ;", "", "I = 'I' | 'i' ;", "", "L = 'L' | 'l' ;", "", "R = 'R' | 'r' ;", "", "T = 'T' | 't' ;"); }