Antlr4 extends BnfWriter { @Override protected void literal(String value) { escapeAndEnclose(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 shouldProduceLiteral() throws TransformerException { assertGenerates( grammar( "foo" ) .production( "bar", literal( "LIteR@L" ) ) .build( Grammar.Builder.Option.ALLOW_ROOTLESS ), "grammar foo;", "", "oC_bar", " : 'LIteR@L' ;", "" ); }
@Test public void shouldEncloseOptionalSequence() throws Exception { assertGenerates( grammar( "FooBar" ) .production( "FooBar", optional( literal( "foo" ), literal( "bar" ) ) ), "grammar FooBar;", "", "oC_FooBar", " : ( 'foo' 'bar' )? ;", "" ); }