/** Convert from an ANTLR string literal found in a grammar file to * an equivalent string literal in the target language. For Java, this * is the identify translation; i.e., "\"\n" -> "\"\n". Most languages * will be able to use this 1-to-1 mapping. Expect double quotes * around the incoming literal. * Depending on the charvocabulary the string should be prefixed with a 'L' */ public String getTargetStringLiteralFromANTLRStringLiteral( CodeGenerator codegen, String literal) { StringBuffer buf = Grammar.getUnescapedStringFromGrammarStringLiteral(literal); String prefix = "\""; if( codegen.grammar.getMaxCharValue() > 255 ) prefix = "L\""; return prefix+escapeString(buf.toString())+"\""; } /** Character constants get truncated to this value.
/** Convert from an ANTLR string literal found in a grammar file to * an equivalent string literal in the target language. For Java, this * is the identify translation; i.e., "\"\n" -> "\"\n". Most languages * will be able to use this 1-to-1 mapping. Expect double quotes * around the incoming literal. * Depending on the charvocabulary the string should be prefixed with a 'L' */ public String getTargetStringLiteralFromANTLRStringLiteral( CodeGenerator codegen, String literal) { StringBuffer buf = Grammar.getUnescapedStringFromGrammarStringLiteral(literal); String prefix = "\""; if( codegen.grammar.getMaxCharValue() > 255 ) prefix = "L\""; return prefix+escapeString(buf.toString())+"\""; } /** Character constants get truncated to this value.