Package antlr
Class JavaCharFormatter
java.lang.Object
antlr.JavaCharFormatter
- All Implemented Interfaces:
CharFormatter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionescapeChar
(int c, boolean forCharLiteral) Given a character value, return a string representing the character that can be embedded inside a string literal or character literal This works for Java/C/C++ code-generation and languages with compatible special-character-escapment.Converts a String into a representation that can be use as a literal when surrounded by double-quotes.literalChar
(int c) Given a character value, return a string representing the character literal that can be recognized by the target language compiler.Converts a String into a string literal This works for languages that use double-quotes for string literals.
-
Constructor Details
-
JavaCharFormatter
JavaCharFormatter()
-
-
Method Details
-
escapeChar
Given a character value, return a string representing the character that can be embedded inside a string literal or character literal This works for Java/C/C++ code-generation and languages with compatible special-character-escapment. Code-generators for languages should override this method.- Specified by:
escapeChar
in interfaceCharFormatter
- Parameters:
c
- The character of interest.forCharLiteral
- true to escape for char literal, false for string literal
-
escapeString
Converts a String into a representation that can be use as a literal when surrounded by double-quotes.- Specified by:
escapeString
in interfaceCharFormatter
- Parameters:
s
- The String to be changed into a literal
-
literalChar
Given a character value, return a string representing the character literal that can be recognized by the target language compiler. This works for languages that use single-quotes for character literals. Code-generators for languages should override this method.- Specified by:
literalChar
in interfaceCharFormatter
- Parameters:
c
- The character of interest.
-
literalString
Converts a String into a string literal This works for languages that use double-quotes for string literals. Code-generators for languages should override this method.- Specified by:
literalString
in interfaceCharFormatter
- Parameters:
s
- The String to be changed into a literal
-