Package com.blackrook.json.struct
Class Lexer.Kernel
java.lang.Object
com.blackrook.json.struct.Lexer.Kernel
- Enclosing class:
- Lexer
This is a info kernel that tells a
Lexer
how to interpret certain characters and identifiers.- Author:
- Matthew Tropiano
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Reserved token type: Comment.static final int
Reserved token type: Close comment.static final int
Reserved token type: Delimiter Comment (never returned).static final int
Reserved token type: Line comment.static final int
Reserved token type: New line character.static final int
Reserved token type: Open comment.static final int
Reserved token type: Space.static final int
Reserved token type: Tab.static final int
Reserved token type: Delimiter (never returned).static final int
Reserved token type: End of lexer.static final int
Reserved token type: End of stream.static final int
Reserved token type: Exponent state (never returned).static final int
Reserved token type: Exponent power state (never returned).static final int
Reserved token type: Floating point state (never returned).static final int
Reserved token type: hexadecimal integer (never returned).static final int
Reserved token type: hexadecimal integer (never returned).static final int
Reserved token type: hexadecimal integer (never returned).static final int
Reserved token type: Identifier.static final int
Reserved token type: Illegal token.static final int
Reserved token type: Line Comment.static final int
Reserved token type: Number.static final int
Reserved token type: Point state (never returned).static final int
Reserved token type: Raw String (never returned).static final int
Reserved token type: String.static final int
Reserved token type: Unknown token. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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
Checks if this lexer emits comment tokens.boolean
Checks if this lexer emits newline tokens.boolean
Checks if this lexer emits space tokens.boolean
Checks if this lexer emits stream break tokens.boolean
Checks if this lexer emits tab tokens.
-
Field Details
-
TYPE_END_OF_LEXER
public static final int TYPE_END_OF_LEXERReserved token type: End of lexer.- See Also:
-
TYPE_END_OF_STREAM
public static final int TYPE_END_OF_STREAMReserved token type: End of stream.- See Also:
-
TYPE_NUMBER
public static final int TYPE_NUMBERReserved token type: Number.- See Also:
-
TYPE_DELIM_SPACE
public static final int TYPE_DELIM_SPACEReserved token type: Space.- See Also:
-
TYPE_DELIM_TAB
public static final int TYPE_DELIM_TABReserved token type: Tab.- See Also:
-
TYPE_DELIM_NEWLINE
public static final int TYPE_DELIM_NEWLINEReserved token type: New line character.- See Also:
-
TYPE_DELIM_OPEN_COMMENT
public static final int TYPE_DELIM_OPEN_COMMENTReserved token type: Open comment.- See Also:
-
TYPE_DELIM_CLOSE_COMMENT
public static final int TYPE_DELIM_CLOSE_COMMENTReserved token type: Close comment.- See Also:
-
TYPE_DELIM_LINE_COMMENT
public static final int TYPE_DELIM_LINE_COMMENTReserved token type: Line comment.- See Also:
-
TYPE_IDENTIFIER
public static final int TYPE_IDENTIFIERReserved token type: Identifier.- See Also:
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWNReserved token type: Unknown token.- See Also:
-
TYPE_ILLEGAL
public static final int TYPE_ILLEGALReserved token type: Illegal token.- See Also:
-
TYPE_COMMENT
public static final int TYPE_COMMENTReserved token type: Comment.- See Also:
-
TYPE_LINE_COMMENT
public static final int TYPE_LINE_COMMENTReserved token type: Line Comment.- See Also:
-
TYPE_STRING
public static final int TYPE_STRINGReserved token type: String.- See Also:
-
TYPE_RAWSTRING
public static final int TYPE_RAWSTRINGReserved token type: Raw String (never returned).- See Also:
-
TYPE_DELIMITER
public static final int TYPE_DELIMITERReserved token type: Delimiter (never returned).- See Also:
-
TYPE_POINT
public static final int TYPE_POINTReserved token type: Point state (never returned).- See Also:
-
TYPE_FLOAT
public static final int TYPE_FLOATReserved token type: Floating point state (never returned).- See Also:
-
TYPE_DELIM_COMMENT
public static final int TYPE_DELIM_COMMENTReserved token type: Delimiter Comment (never returned).- See Also:
-
TYPE_HEX_INTEGER0
public static final int TYPE_HEX_INTEGER0Reserved token type: hexadecimal integer (never returned).- See Also:
-
TYPE_HEX_INTEGER1
public static final int TYPE_HEX_INTEGER1Reserved token type: hexadecimal integer (never returned).- See Also:
-
TYPE_HEX_INTEGER
public static final int TYPE_HEX_INTEGERReserved token type: hexadecimal integer (never returned).- See Also:
-
TYPE_EXPONENT
public static final int TYPE_EXPONENTReserved token type: Exponent state (never returned).- See Also:
-
TYPE_EXPONENT_POWER
public static final int TYPE_EXPONENT_POWERReserved token type: Exponent power state (never returned).- See Also:
-
-
Constructor Details
-
Kernel
public Kernel()Creates a new, blank LexerKernel with default settings.
-
-
Method Details
-
addDelimiter
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
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
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
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
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
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.
-