Package com.blackrook.expression.struct
Class Lexer.Kernel
- java.lang.Object
-
- com.blackrook.expression.struct.Lexer.Kernel
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE_COMMENT
Reserved token type: Comment.static int
TYPE_DELIM_CLOSE_COMMENT
Reserved token type: Close comment.static int
TYPE_DELIM_COMMENT
Reserved token type: Delimiter Comment (never returned).static int
TYPE_DELIM_LINE_COMMENT
Reserved token type: Line comment.static int
TYPE_DELIM_NEWLINE
Reserved token type: New line character.static int
TYPE_DELIM_OPEN_COMMENT
Reserved token type: Open comment.static int
TYPE_DELIM_SPACE
Reserved token type: Space.static int
TYPE_DELIM_TAB
Reserved token type: Tab.static int
TYPE_DELIMITER
Reserved token type: Delimiter (never returned).static int
TYPE_END_OF_LEXER
Reserved token type: End of lexer.static int
TYPE_END_OF_STREAM
Reserved token type: End of stream.static int
TYPE_EXPONENT
Reserved token type: Exponent state (never returned).static int
TYPE_EXPONENT_POWER
Reserved token type: Exponent power state (never returned).static int
TYPE_FLOAT
Reserved token type: Floating point state (never returned).static int
TYPE_HEX_INTEGER
Reserved token type: hexadecimal integer (never returned).static int
TYPE_HEX_INTEGER0
Reserved token type: hexadecimal integer (never returned).static int
TYPE_HEX_INTEGER1
Reserved token type: hexadecimal integer (never returned).static int
TYPE_IDENTIFIER
Reserved token type: Identifier.static int
TYPE_ILLEGAL
Reserved token type: Illegal token.static int
TYPE_LINE_COMMENT
Reserved token type: Line Comment.static int
TYPE_NUMBER
Reserved token type: Number.static int
TYPE_POINT
Reserved token type: Point state (never returned).static int
TYPE_RAWSTRING
Reserved token type: Raw String (never returned).static int
TYPE_STRING
Reserved token type: String.static int
TYPE_UNKNOWN
Reserved token type: Unknown token.
-
Constructor Summary
Constructors Constructor Description Kernel()
Creates a new, blank LexerKernel with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCaseInsensitiveKeyword(String keyword, int type)
Adds a keyword to the Lexer, case-insensitive.void
addCommentEndDelimiter(String delimiter, int type)
Adds a comment-ending delimiter to this lexer.void
addCommentLineDelimiter(String delimiter, int type)
Adds a line comment delimiter to this lexer.void
addCommentStartDelimiter(String delimiter, int type)
Adds a comment-starting delimiter to this lexer.void
addDelimiter(String delimiter, int type)
Adds a delimiter to this lexer.void
addKeyword(String keyword, int type)
Adds a keyword to the Lexer, case-sensitive.void
addRawStringDelimiter(char delimiterStart, char delimiterEnd)
Adds a raw string delimiter to this lexer along with its ending character.void
addStringDelimiter(char delimiterStart, char delimiterEnd)
Adds a string delimiter to this lexer along with its ending character.char
getDecimalSeparator()
Gets the current decimal separator character.void
setDecimalSeparator(char c)
Sets the current decimal separator character.void
setEmitComments(boolean emitComments)
Sets if this lexer emits comment tokens.void
setEmitNewlines(boolean includeNewlines)
Sets if this lexer emits newline tokens.void
setEmitSpaces(boolean includeSpaces)
Sets if this lexer emits space tokens?void
setEmitStreamBreak(boolean emitStreamBreak)
Sets if this lexer emits stream break tokens.void
setEmitTabs(boolean includeTabs)
Sets if this lexer emits tab tokens.boolean
willEmitComments()
Checks if this lexer emits comment tokens.boolean
willEmitNewlines()
Checks if this lexer emits newline tokens.boolean
willEmitSpaces()
Checks if this lexer emits space tokens.boolean
willEmitStreamBreak()
Checks if this lexer emits stream break tokens.boolean
willEmitTabs()
Checks if this lexer emits tab tokens.
-
-
-
Field Detail
-
TYPE_END_OF_LEXER
public static final int TYPE_END_OF_LEXER
Reserved token type: End of lexer.- See Also:
- Constant Field Values
-
TYPE_END_OF_STREAM
public static final int TYPE_END_OF_STREAM
Reserved token type: End of stream.- See Also:
- Constant Field Values
-
TYPE_NUMBER
public static final int TYPE_NUMBER
Reserved token type: Number.- See Also:
- Constant Field Values
-
TYPE_DELIM_SPACE
public static final int TYPE_DELIM_SPACE
Reserved token type: Space.- See Also:
- Constant Field Values
-
TYPE_DELIM_TAB
public static final int TYPE_DELIM_TAB
Reserved token type: Tab.- See Also:
- Constant Field Values
-
TYPE_DELIM_NEWLINE
public static final int TYPE_DELIM_NEWLINE
Reserved token type: New line character.- See Also:
- Constant Field Values
-
TYPE_DELIM_OPEN_COMMENT
public static final int TYPE_DELIM_OPEN_COMMENT
Reserved token type: Open comment.- See Also:
- Constant Field Values
-
TYPE_DELIM_CLOSE_COMMENT
public static final int TYPE_DELIM_CLOSE_COMMENT
Reserved token type: Close comment.- See Also:
- Constant Field Values
-
TYPE_DELIM_LINE_COMMENT
public static final int TYPE_DELIM_LINE_COMMENT
Reserved token type: Line comment.- See Also:
- Constant Field Values
-
TYPE_IDENTIFIER
public static final int TYPE_IDENTIFIER
Reserved token type: Identifier.- See Also:
- Constant Field Values
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
Reserved token type: Unknown token.- See Also:
- Constant Field Values
-
TYPE_ILLEGAL
public static final int TYPE_ILLEGAL
Reserved token type: Illegal token.- See Also:
- Constant Field Values
-
TYPE_COMMENT
public static final int TYPE_COMMENT
Reserved token type: Comment.- See Also:
- Constant Field Values
-
TYPE_LINE_COMMENT
public static final int TYPE_LINE_COMMENT
Reserved token type: Line Comment.- See Also:
- Constant Field Values
-
TYPE_STRING
public static final int TYPE_STRING
Reserved token type: String.- See Also:
- Constant Field Values
-
TYPE_RAWSTRING
public static final int TYPE_RAWSTRING
Reserved token type: Raw String (never returned).- See Also:
- Constant Field Values
-
TYPE_DELIMITER
public static final int TYPE_DELIMITER
Reserved token type: Delimiter (never returned).- See Also:
- Constant Field Values
-
TYPE_POINT
public static final int TYPE_POINT
Reserved token type: Point state (never returned).- See Also:
- Constant Field Values
-
TYPE_FLOAT
public static final int TYPE_FLOAT
Reserved token type: Floating point state (never returned).- See Also:
- Constant Field Values
-
TYPE_DELIM_COMMENT
public static final int TYPE_DELIM_COMMENT
Reserved token type: Delimiter Comment (never returned).- See Also:
- Constant Field Values
-
TYPE_HEX_INTEGER0
public static final int TYPE_HEX_INTEGER0
Reserved token type: hexadecimal integer (never returned).- See Also:
- Constant Field Values
-
TYPE_HEX_INTEGER1
public static final int TYPE_HEX_INTEGER1
Reserved token type: hexadecimal integer (never returned).- See Also:
- Constant Field Values
-
TYPE_HEX_INTEGER
public static final int TYPE_HEX_INTEGER
Reserved token type: hexadecimal integer (never returned).- See Also:
- Constant Field Values
-
TYPE_EXPONENT
public static final int TYPE_EXPONENT
Reserved token type: Exponent state (never returned).- See Also:
- Constant Field Values
-
TYPE_EXPONENT_POWER
public static final int TYPE_EXPONENT_POWER
Reserved token type: Exponent power state (never returned).- See Also:
- Constant Field Values
-
-
Method Detail
-
addDelimiter
public void addDelimiter(String delimiter, int type)
Adds a delimiter to this lexer.- Parameters:
delimiter
- the delimiter lexeme.type
- the type id.- Throws:
IllegalArgumentException
- if type is < 0 or delimiter is null or empty.
-
addStringDelimiter
public void addStringDelimiter(char delimiterStart, char delimiterEnd)
Adds a string delimiter to this lexer along with its ending character.- Parameters:
delimiterStart
- the starting delimiter.delimiterEnd
- the ending delimiter.
-
addRawStringDelimiter
public void addRawStringDelimiter(char delimiterStart, char delimiterEnd)
Adds a raw string delimiter to this lexer along with its ending character.- Parameters:
delimiterStart
- the starting delimiter.delimiterEnd
- the ending delimiter.
-
addCommentStartDelimiter
public void addCommentStartDelimiter(String delimiter, int type)
Adds a comment-starting delimiter to this lexer.- Parameters:
delimiter
- the delimiter lexeme.type
- the type id.- Throws:
IllegalArgumentException
- if type is < 0 or delimiter is null or empty.
-
addCommentEndDelimiter
public void addCommentEndDelimiter(String delimiter, int type)
Adds a comment-ending delimiter to this lexer.- Parameters:
delimiter
- the delimiter lexeme.type
- the type id.- Throws:
IllegalArgumentException
- if type is < 0 or delimiter is null or empty.
-
addCommentLineDelimiter
public void addCommentLineDelimiter(String delimiter, int type)
Adds a line comment delimiter to this lexer.- Parameters:
delimiter
- the delimiter lexeme.type
- the type id.- Throws:
IllegalArgumentException
- if type is < 0 or delimiter is null or empty.
-
addKeyword
public void addKeyword(String keyword, int type)
Adds a keyword to the Lexer, case-sensitive. When this identifier is read in, its token type is specified type.- Parameters:
keyword
- the keyword identifier.type
- the type id.
-
addCaseInsensitiveKeyword
public void addCaseInsensitiveKeyword(String keyword, int type)
Adds a keyword to the Lexer, case-insensitive. When this identifier is read in, its token type is specified type.- Parameters:
keyword
- the keyword identifier.type
- the type id.
-
willEmitSpaces
public boolean willEmitSpaces()
Checks if this lexer emits space tokens.- Returns:
- true if so, false if not.
-
setEmitSpaces
public void setEmitSpaces(boolean includeSpaces)
Sets if this lexer emits space tokens?- Parameters:
includeSpaces
- true if so, false if not.
-
willEmitTabs
public boolean willEmitTabs()
Checks if this lexer emits tab tokens.- Returns:
- true if so, false if not.
-
setEmitTabs
public void setEmitTabs(boolean includeTabs)
Sets if this lexer emits tab tokens.- Parameters:
includeTabs
- true if so, false if not.
-
willEmitNewlines
public boolean willEmitNewlines()
Checks if this lexer emits newline tokens.- Returns:
- true if so, false if not.
-
setEmitNewlines
public void setEmitNewlines(boolean includeNewlines)
Sets if this lexer emits newline tokens.- Parameters:
includeNewlines
- true if so, false if not.
-
willEmitStreamBreak
public boolean willEmitStreamBreak()
Checks if this lexer emits stream break tokens.- Returns:
- true if so, false if not.
-
setEmitStreamBreak
public void setEmitStreamBreak(boolean emitStreamBreak)
Sets if this lexer emits stream break tokens.- Parameters:
emitStreamBreak
- true if so, false if not.
-
willEmitComments
public boolean willEmitComments()
Checks if this lexer emits comment tokens.- Returns:
- true if so, false if not.
-
setEmitComments
public void setEmitComments(boolean emitComments)
Sets if this lexer emits comment tokens.- Parameters:
emitComments
- true if so, false if not.
-
setDecimalSeparator
public void setDecimalSeparator(char c)
Sets the current decimal separator character. By default, this is the current locale's decimal separator character.- Parameters:
c
- the character to set.
-
getDecimalSeparator
public char getDecimalSeparator()
Gets the current decimal separator character. By default, this is the current locale's decimal separator character.- Returns:
- the separator character.
-
-