Package org.jline.builtins
Class SyntaxHighlighter.Parser
java.lang.Object
org.jline.builtins.SyntaxHighlighter.Parser
- Enclosing class:
SyntaxHighlighter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate String[]private Stringprivate booleanprivate booleanprivate Stringprivate static final charprivate booleanprivate String[]private Stringprivate CharSequenceprivate List<SyntaxHighlighter.ParsedToken> private int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringbalancedDelimiter(CharSequence buffer, int pos) (package private) static StringfixRegexes(String posix) Perform Posix/Java regex fixups.private booleanisDelimiter(CharSequence buffer, int pos, String delimiter) private booleanisEscapeChar(char ch) private booleanisEscapeChar(CharSequence buffer, int pos) Check if this character is a valid escape char (i.e.private booleanisEscaped(CharSequence buffer, int pos) Check if a character is escaped (i.e.private booleanisLineCommentDelimiter(CharSequence buffer, int pos) private static intnextAfterClass(String s, int idx) voidparse(CharSequence line) private static StringreplaceClass(String className) voidreset()voidsetBalancedDelimiters(String tokenName, String[] args) voidsetBlockCommentDelimiters(String tokenName, String[] args) voidsetLineCommentDelimiters(String tokenName, String[] args) private CharSequencestartWithSubstring(CharSequence line, int pos)
-
Field Details
-
escapeChar
private static final char escapeChar- See Also:
-
blockCommentTokenName
-
blockCommentDelimiters
-
lineCommentTokenName
-
lineCommentDelimiters
-
balancedDelimiterTokenName
-
balancedDelimiters
-
balancedDelimiter
-
tokens
-
startWith
-
tokenStart
private int tokenStart -
blockComment
private boolean blockComment -
lineComment
private boolean lineComment -
balancedQuoted
private boolean balancedQuoted
-
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
setBlockCommentDelimiters
-
setLineCommentDelimiters
-
setBalancedDelimiters
-
reset
public void reset() -
parse
-
startWithSubstring
-
getTokens
-
balancedDelimiter
-
isDelimiter
-
isLineCommentDelimiter
-
isEscapeChar
private boolean isEscapeChar(char ch) -
isEscapeChar
Check if this character is a valid escape char (i.e. one that has not been escaped)- Parameters:
buffer- the buffer to check inpos- the position of the character to check- Returns:
- true if the character at the specified position in the given buffer is an escape character and the character immediately preceding it is not an escape character.
-
isEscaped
Check if a character is escaped (i.e. if the previous character is an escape)- Parameters:
buffer- the buffer to check inpos- the position of the character to check- Returns:
- true if the character at the specified position in the given buffer is an escape character and the character immediately preceding it is an escape character.
-
fixRegexes
Perform Posix/Java regex fixups. This function parses the given regex and escapes according to these rules:The first
]in a bracket expression does not need to be escaped in Posix,translate to\].Same as above for a negating bracket expression like
[^][], translate to[^\]\[].Any
[in a bracket expression does not need to be escaped in Posix, translate to\[.Any
]not in a bracket expression is valid in both Posix and Java, no translation.A backslash before the closing bracket like
[.f\]is not an escape of the closing bracket, the backslash needs to be escaped for Java, translate to[.f\\].Do not perform the above translations within an escape via
\, except for\<and\>to\b.Replace the Posix classes like
[:space:]or[:digit:]to Java classes, inside and outside a bracket expression.- Parameters:
posix- Posix regex- Returns:
- Java regex
-
replaceClass
-
nextAfterClass
-