Package org.antlr.v4.misc
Class CharSupport
- java.lang.Object
-
- org.antlr.v4.misc.CharSupport
-
public class CharSupport extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String[]
ANTLRLiteralCharValueEscape
Given a char, we need to be able to show as an ANTLR literal.static int[]
ANTLRLiteralEscapedCharValue
When converting ANTLR char and string literals, here is the value set of escape chars.
-
Constructor Summary
Constructors Constructor Description CharSupport()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
capitalize(String s)
static String
getANTLRCharLiteralForChar(int c)
Return a string representing the escaped char for code c.static int
getCharValueFromCharInGrammarLiteral(String cstr)
Given char x or \t or ሴ return the char value; Unnecessary escapes like '\{' yield -1.static int
getCharValueFromGrammarCharLiteral(String literal)
Given a literal like (the 3 char sequence with single quotes) 'a', return the int value of 'a'.static String
getStringFromGrammarStringLiteral(String literal)
-
-
-
Field Detail
-
ANTLRLiteralEscapedCharValue
public static int[] ANTLRLiteralEscapedCharValue
When converting ANTLR char and string literals, here is the value set of escape chars.
-
ANTLRLiteralCharValueEscape
public static String[] ANTLRLiteralCharValueEscape
Given a char, we need to be able to show as an ANTLR literal.
-
-
Method Detail
-
getANTLRCharLiteralForChar
public static String getANTLRCharLiteralForChar(int c)
Return a string representing the escaped char for code c. E.g., If c has value 0x100, you will get "Ā". ASCII gets the usual char (non-hex) representation. Control characters are spit out as unicode. While this is specially set up for returning Java strings, it can be used by any language target that has the same syntax. :)
-
getCharValueFromGrammarCharLiteral
public static int getCharValueFromGrammarCharLiteral(String literal)
Given a literal like (the 3 char sequence with single quotes) 'a', return the int value of 'a'. Convert escape sequences here also. Return -1 if not single char.
-
getStringFromGrammarStringLiteral
public static String getStringFromGrammarStringLiteral(String literal)
-
getCharValueFromCharInGrammarLiteral
public static int getCharValueFromCharInGrammarLiteral(String cstr)
Given char x or \t or ሴ return the char value; Unnecessary escapes like '\{' yield -1.
-
-