Package nz.org.riskscape.rl
Enum Class TokenTypes
- All Implemented Interfaces:
Serializable
,Comparable<TokenTypes>
,Constable
,TokenType
Tokens used by ExpressionParser
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescription -
Field Summary
Modifier and TypeFieldDescriptionstatic final Pattern
The regex used for matchingIDENTIFIER
tokens - used for quoting methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic Token
identToken
(String identifier) boolean
matcher()
static String
quoteIdent
(String token) static String
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.static String
stripQuotes
(String id) static Lexer.Tokens<TokenTypes>
tokens()
static TokenTypes
Returns the enum constant of this class with the specified name.static TokenTypes[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
KEYWORD_OR
-
KEYWORD_AND
-
KEYWORD_TRUE
-
KEYWORD_FALSE
-
KEYWORD_NULL
-
KEYWORD_AS
-
PARAMETER_IDENTIFIER
-
KEY_IDENTIFIER
-
IDENTIFIER
-
QUOTED_IDENTIFIER
-
STRING
-
SCIENTIFIC_NOTATION
-
DECIMAL
-
INTEGER
-
INDEX
-
LPAREN
-
RPAREN
-
LBRACK
-
RBRACK
-
LBRACE
-
RBRACE
-
COMMA
-
DOUBLE_COLON
-
COLON
-
CHAIN
-
SPACE
-
TAB
-
CR_LF
-
CR
-
LF
-
NOT_EQUALS
-
COMMENT_INLINE
-
EQUALS
-
PLUS
-
MINUS
-
POW
-
MULTIPLY
-
DIVIDE
-
OR
-
AND
-
LESS_THAN_EQUAL
-
GREATER_THAN_EQUAL
-
LESS_THAN
-
GREATER_THAN
-
COMMENT
-
EOF
-
-
Field Details
-
KEYWORDS
-
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
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
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 nameNullPointerException
- if the argument is null
-
tokens
-
quoteText
- Returns:
- a source representation of the given text that can be safely lexed as
STRING
-
quoteTextIfNeeded
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
- Returns:
- a source representation of the given identifier that can be safely lexed as either an
IDENTIFIER
or as aQUOTED_IDENTIFIER
-
stripQuotes
- Returns:
- id with any wrapping quotes (either single or double) removed
-
identToken
- Returns:
- an identifier token, one of
QUOTED_IDENTIFIER
orIDENTIFIER
, 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
- Specified by:
matcher
in interfaceTokenType
- 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 interfaceTokenType
- Returns:
- true if this is a whitespace type token
-