Class SyntaxHighlighter.Parser

java.lang.Object
org.jline.builtins.SyntaxHighlighter.Parser
Enclosing class:
SyntaxHighlighter

static class SyntaxHighlighter.Parser extends Object
  • Field Details

    • escapeChar

      private static final char escapeChar
      See Also:
    • blockCommentTokenName

      private String blockCommentTokenName
    • blockCommentDelimiters

      private SyntaxHighlighter.BlockCommentDelimiters blockCommentDelimiters
    • lineCommentTokenName

      private String lineCommentTokenName
    • lineCommentDelimiters

      private String[] lineCommentDelimiters
    • balancedDelimiterTokenName

      private String balancedDelimiterTokenName
    • balancedDelimiters

      private String[] balancedDelimiters
    • balancedDelimiter

      private String balancedDelimiter
    • tokens

    • startWith

      private CharSequence 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

      public void setBlockCommentDelimiters(String tokenName, String[] args)
    • setLineCommentDelimiters

      public void setLineCommentDelimiters(String tokenName, String[] args)
    • setBalancedDelimiters

      public void setBalancedDelimiters(String tokenName, String[] args)
    • reset

      public void reset()
    • parse

      public void parse(CharSequence line)
    • startWithSubstring

      private CharSequence startWithSubstring(CharSequence line, int pos)
    • getTokens

      public List<SyntaxHighlighter.ParsedToken> getTokens()
    • balancedDelimiter

      private String balancedDelimiter(CharSequence buffer, int pos)
    • isDelimiter

      private boolean isDelimiter(CharSequence buffer, int pos, String delimiter)
    • isLineCommentDelimiter

      private boolean isLineCommentDelimiter(CharSequence buffer, int pos)
    • isEscapeChar

      private boolean isEscapeChar(char ch)
    • isEscapeChar

      private boolean isEscapeChar(CharSequence buffer, int pos)
      Check if this character is a valid escape char (i.e. one that has not been escaped)
      Parameters:
      buffer - the buffer to check in
      pos - 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

      private boolean isEscaped(CharSequence buffer, int pos)
      Check if a character is escaped (i.e. if the previous character is an escape)
      Parameters:
      buffer - the buffer to check in
      pos - 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

      static String fixRegexes(String posix)
      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

      private static String replaceClass(String className)
    • nextAfterClass

      private static int nextAfterClass(String s, int idx)