Enum Class TokenTypes

java.lang.Object
java.lang.Enum<TokenTypes>
nz.org.riskscape.rl.TokenTypes
All Implemented Interfaces:
Serializable, Comparable<TokenTypes>, Constable, TokenType

public enum TokenTypes extends Enum<TokenTypes> implements TokenType

Tokens used by ExpressionParser

  • Enum Constant Details

    • KEYWORD_OR

      public static final TokenTypes KEYWORD_OR
    • KEYWORD_AND

      public static final TokenTypes KEYWORD_AND
    • KEYWORD_TRUE

      public static final TokenTypes KEYWORD_TRUE
    • KEYWORD_FALSE

      public static final TokenTypes KEYWORD_FALSE
    • KEYWORD_NULL

      public static final TokenTypes KEYWORD_NULL
    • KEYWORD_AS

      public static final TokenTypes KEYWORD_AS
    • PARAMETER_IDENTIFIER

      public static final TokenTypes PARAMETER_IDENTIFIER
    • KEY_IDENTIFIER

      public static final TokenTypes KEY_IDENTIFIER
    • IDENTIFIER

      public static final TokenTypes IDENTIFIER
    • QUOTED_IDENTIFIER

      public static final TokenTypes QUOTED_IDENTIFIER
    • STRING

      public static final TokenTypes STRING
    • SCIENTIFIC_NOTATION

      public static final TokenTypes SCIENTIFIC_NOTATION
    • DECIMAL

      public static final TokenTypes DECIMAL
    • INTEGER

      public static final TokenTypes INTEGER
    • INDEX

      public static final TokenTypes INDEX
    • LPAREN

      public static final TokenTypes LPAREN
    • RPAREN

      public static final TokenTypes RPAREN
    • LBRACK

      public static final TokenTypes LBRACK
    • RBRACK

      public static final TokenTypes RBRACK
    • LBRACE

      public static final TokenTypes LBRACE
    • RBRACE

      public static final TokenTypes RBRACE
    • COMMA

      public static final TokenTypes COMMA
    • DOUBLE_COLON

      public static final TokenTypes DOUBLE_COLON
    • COLON

      public static final TokenTypes COLON
    • CHAIN

      public static final TokenTypes CHAIN
    • SPACE

      public static final TokenTypes SPACE
    • TAB

      public static final TokenTypes TAB
    • CR_LF

      public static final TokenTypes CR_LF
    • CR

      public static final TokenTypes CR
    • LF

      public static final TokenTypes LF
    • NOT_EQUALS

      public static final TokenTypes NOT_EQUALS
    • COMMENT_INLINE

      public static final TokenTypes COMMENT_INLINE
    • EQUALS

      public static final TokenTypes EQUALS
    • PLUS

      public static final TokenTypes PLUS
    • MINUS

      public static final TokenTypes MINUS
    • POW

      public static final TokenTypes POW
    • MULTIPLY

      public static final TokenTypes MULTIPLY
    • DIVIDE

      public static final TokenTypes DIVIDE
    • OR

      public static final TokenTypes OR
    • AND

      public static final TokenTypes AND
    • LESS_THAN_EQUAL

      public static final TokenTypes LESS_THAN_EQUAL
    • GREATER_THAN_EQUAL

      public static final TokenTypes GREATER_THAN_EQUAL
    • LESS_THAN

      public static final TokenTypes LESS_THAN
    • GREATER_THAN

      public static final TokenTypes GREATER_THAN
    • COMMENT

      public static final TokenTypes COMMENT
    • EOF

      public static final TokenTypes EOF
  • Field Details

    • KEYWORDS

      public static final Set<String> KEYWORDS
    • IDENTIFIER_PATTERN

      public static final Pattern IDENTIFIER_PATTERN

      The regex used for matching IDENTIFIER tokens - used for quoting methods. NB has to be reiterated because it can't precede the emum members

  • Method Details

    • values

      public static TokenTypes[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TokenTypes valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • tokens

      public static Lexer.Tokens<TokenTypes> tokens()
    • quoteText

      public static String quoteText(String text)
      Returns:
      a source representation of the given text that can be safely lexed as STRING
    • quoteTextIfNeeded

      public static String quoteTextIfNeeded(String text)

      Will wrap text in single quotes if it is not already so that it could be parsed as a Riskscape string literal expression. Useful for cases where the user isn't sure if they need to enter quotes or not, and we don't want to double-quote

    • quoteIdent

      public static String quoteIdent(String token)
      Returns:
      a source representation of the given identifier that can be safely lexed as either an IDENTIFIER or as a QUOTED_IDENTIFIER
    • stripQuotes

      public static String stripQuotes(String id)
      Returns:
      id with any wrapping quotes (either single or double) removed
    • identToken

      public static Token identToken(String identifier)
      Returns:
      an identifier token, one of QUOTED_IDENTIFIER or IDENTIFIER, depending on whether the given identifier needs quoting or not. Takes care to construct the token with the correct source representation (quoted) as well as the correct unquoted value.
    • matcher

      public TokenMatcher matcher()
      Specified by:
      matcher in interface TokenType
      Returns:
      a TokenMatcher that is used to match tokens of this type. Note that matchers might actually match other tokens as well - the enum should declare the tokens in order of precedence so that the most specific are first
    • isWhitespace

      public boolean isWhitespace()
      Specified by:
      isWhitespace in interface TokenType
      Returns:
      true if this is a whitespace type token