Class JavaScriptToken
java.lang.Object
com.jsql.view.swing.sql.lexer.syntax.Token
com.jsql.view.swing.sql.lexer.syntax.JavaScriptToken
A JavaScriptToken is a token that is returned by a lexer that is lexing a javascript
source file. It has several attributes describing the token:
The type of token, the text of the token, the line number on which it
occurred, the number of characters into the input at which it started, and
similarly, the number of characters into the input at which it ended.
The tokens should comply with the Java Script Reference.
The tokens should comply with the Java Script Reference.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Fields inherited from class com.jsql.view.swing.sql.lexer.syntax.Token
INITIAL_STATE, UNDEFINED_STATE
-
Constructor Summary
ConstructorDescriptionJavaScriptToken
(int ID, String contents, int lineNumber, int charBegin, int charEnd) Create a new token.JavaScriptToken
(int ID, String contents, int lineNumber, int charBegin, int charEnd, int state) Create a new token. -
Method Summary
Modifier and TypeMethodDescriptionget a String that explains the error, if this token is an error.int
get the offset into the input in characters at which this token startedint
get the offset into the input in characters at which this token endedget the contents of this tokenA description of this token.int
getID()
get the ID number of this tokenint
get the line number of the input on which this token startedint
getState()
Get an integer representing the state the tokenizer is in after returning this token.boolean
Checks this token to see if it is a comment.boolean
isError()
Checks this token to see if it is an Error.boolean
Checks this token to see if it is an identifier.boolean
Checks this token to see if it is a literal.boolean
Checks this token to see if it is a Operator.boolean
Checks this token to see if it is a reserved word.boolean
Checks this token to see if it is a Separator.boolean
Checks this token to see if it is White Space.toString()
get a representation of this token as a human-readable string.
-
Field Details
-
RESERVED_WORD_ABSTRACT
public static final int RESERVED_WORD_ABSTRACT- See Also:
-
RESERVED_WORD_BOOLEAN
public static final int RESERVED_WORD_BOOLEAN- See Also:
-
RESERVED_WORD_BREAK
public static final int RESERVED_WORD_BREAK- See Also:
-
RESERVED_WORD_BYTE
public static final int RESERVED_WORD_BYTE- See Also:
-
RESERVED_WORD_CASE
public static final int RESERVED_WORD_CASE- See Also:
-
RESERVED_WORD_CATCH
public static final int RESERVED_WORD_CATCH- See Also:
-
RESERVED_WORD_CHAR
public static final int RESERVED_WORD_CHAR- See Also:
-
RESERVED_WORD_CLASS
public static final int RESERVED_WORD_CLASS- See Also:
-
RESERVED_WORD_CONST
public static final int RESERVED_WORD_CONST- See Also:
-
RESERVED_WORD_CONTINUE
public static final int RESERVED_WORD_CONTINUE- See Also:
-
RESERVED_WORD_DEFAULT
public static final int RESERVED_WORD_DEFAULT- See Also:
-
RESERVED_WORD_DO
public static final int RESERVED_WORD_DO- See Also:
-
RESERVED_WORD_DOUBLE
public static final int RESERVED_WORD_DOUBLE- See Also:
-
RESERVED_WORD_ELSE
public static final int RESERVED_WORD_ELSE- See Also:
-
RESERVED_WORD_EXTENDS
public static final int RESERVED_WORD_EXTENDS- See Also:
-
RESERVED_WORD_FALSE
public static final int RESERVED_WORD_FALSE- See Also:
-
RESERVED_WORD_FINAL
public static final int RESERVED_WORD_FINAL- See Also:
-
RESERVED_WORD_FINALLY
public static final int RESERVED_WORD_FINALLY- See Also:
-
RESERVED_WORD_FLOAT
public static final int RESERVED_WORD_FLOAT- See Also:
-
RESERVED_WORD_FOR
public static final int RESERVED_WORD_FOR- See Also:
-
RESERVED_WORD_FUNCTION
public static final int RESERVED_WORD_FUNCTION- See Also:
-
RESERVED_WORD_GOTO
public static final int RESERVED_WORD_GOTO- See Also:
-
RESERVED_WORD_IF
public static final int RESERVED_WORD_IF- See Also:
-
RESERVED_WORD_IMPLEMENTS
public static final int RESERVED_WORD_IMPLEMENTS- See Also:
-
RESERVED_WORD_IMPORT
public static final int RESERVED_WORD_IMPORT- See Also:
-
RESERVED_WORD_IN
public static final int RESERVED_WORD_IN- See Also:
-
RESERVED_WORD_INSTANCEOF
public static final int RESERVED_WORD_INSTANCEOF- See Also:
-
RESERVED_WORD_INT
public static final int RESERVED_WORD_INT- See Also:
-
RESERVED_WORD_INTERFACE
public static final int RESERVED_WORD_INTERFACE- See Also:
-
RESERVED_WORD_LONG
public static final int RESERVED_WORD_LONG- See Also:
-
RESERVED_WORD_NATIVE
public static final int RESERVED_WORD_NATIVE- See Also:
-
RESERVED_WORD_NEW
public static final int RESERVED_WORD_NEW- See Also:
-
RESERVED_WORD_NULL
public static final int RESERVED_WORD_NULL- See Also:
-
RESERVED_WORD_PACKAGE
public static final int RESERVED_WORD_PACKAGE- See Also:
-
RESERVED_WORD_PRIVATE
public static final int RESERVED_WORD_PRIVATE- See Also:
-
RESERVED_WORD_PROTECTED
public static final int RESERVED_WORD_PROTECTED- See Also:
-
RESERVED_WORD_PUBLIC
public static final int RESERVED_WORD_PUBLIC- See Also:
-
RESERVED_WORD_RETURN
public static final int RESERVED_WORD_RETURN- See Also:
-
RESERVED_WORD_SHORT
public static final int RESERVED_WORD_SHORT- See Also:
-
RESERVED_WORD_STATIC
public static final int RESERVED_WORD_STATIC- See Also:
-
RESERVED_WORD_SUPER
public static final int RESERVED_WORD_SUPER- See Also:
-
RESERVED_WORD_SWITCH
public static final int RESERVED_WORD_SWITCH- See Also:
-
RESERVED_WORD_SYNCHRONIZED
public static final int RESERVED_WORD_SYNCHRONIZED- See Also:
-
RESERVED_WORD_THIS
public static final int RESERVED_WORD_THIS- See Also:
-
RESERVED_WORD_THROW
public static final int RESERVED_WORD_THROW- See Also:
-
RESERVED_WORD_THROWS
public static final int RESERVED_WORD_THROWS- See Also:
-
RESERVED_WORD_TRANSIENT
public static final int RESERVED_WORD_TRANSIENT- See Also:
-
RESERVED_WORD_TRUE
public static final int RESERVED_WORD_TRUE- See Also:
-
RESERVED_WORD_TRY
public static final int RESERVED_WORD_TRY- See Also:
-
RESERVED_WORD_VAR
public static final int RESERVED_WORD_VAR- See Also:
-
RESERVED_WORD_VOID
public static final int RESERVED_WORD_VOID- See Also:
-
RESERVED_WORD_WHILE
public static final int RESERVED_WORD_WHILE- See Also:
-
RESERVED_WORD_WITH
public static final int RESERVED_WORD_WITH- See Also:
-
IDENTIFIER
public static final int IDENTIFIER- See Also:
-
LITERAL_BOOLEAN
public static final int LITERAL_BOOLEAN- See Also:
-
LITERAL_INTEGER_DECIMAL
public static final int LITERAL_INTEGER_DECIMAL- See Also:
-
LITERAL_INTEGER_OCTAL
public static final int LITERAL_INTEGER_OCTAL- See Also:
-
LITERAL_INTEGER_HEXIDECIMAL
public static final int LITERAL_INTEGER_HEXIDECIMAL- See Also:
-
LITERAL_LONG_DECIMAL
public static final int LITERAL_LONG_DECIMAL- See Also:
-
LITERAL_LONG_OCTAL
public static final int LITERAL_LONG_OCTAL- See Also:
-
LITERAL_LONG_HEXIDECIMAL
public static final int LITERAL_LONG_HEXIDECIMAL- See Also:
-
LITERAL_FLOATING_POINT
public static final int LITERAL_FLOATING_POINT- See Also:
-
LITERAL_DOUBLE
public static final int LITERAL_DOUBLE- See Also:
-
LITERAL_CHARACTER
public static final int LITERAL_CHARACTER- See Also:
-
LITERAL_STRING
public static final int LITERAL_STRING- See Also:
-
LITERAL_NULL
public static final int LITERAL_NULL- See Also:
-
SEPARATOR_LPAREN
public static final int SEPARATOR_LPAREN- See Also:
-
SEPARATOR_RPAREN
public static final int SEPARATOR_RPAREN- See Also:
-
SEPARATOR_LBRACE
public static final int SEPARATOR_LBRACE- See Also:
-
SEPARATOR_RBRACE
public static final int SEPARATOR_RBRACE- See Also:
-
SEPARATOR_LBRACKET
public static final int SEPARATOR_LBRACKET- See Also:
-
SEPARATOR_RBRACKET
public static final int SEPARATOR_RBRACKET- See Also:
-
SEPARATOR_SEMICOLON
public static final int SEPARATOR_SEMICOLON- See Also:
-
SEPARATOR_COMMA
public static final int SEPARATOR_COMMA- See Also:
-
SEPARATOR_PERIOD
public static final int SEPARATOR_PERIOD- See Also:
-
OPERATOR_GREATER_THAN
public static final int OPERATOR_GREATER_THAN- See Also:
-
OPERATOR_LESS_THAN
public static final int OPERATOR_LESS_THAN- See Also:
-
OPERATOR_LESS_THAN_OR_EQUAL
public static final int OPERATOR_LESS_THAN_OR_EQUAL- See Also:
-
OPERATOR_GREATER_THAN_OR_EQUAL
public static final int OPERATOR_GREATER_THAN_OR_EQUAL- See Also:
-
OPERATOR_EQUAL
public static final int OPERATOR_EQUAL- See Also:
-
OPERATOR_NOT_EQUAL
public static final int OPERATOR_NOT_EQUAL- See Also:
-
OPERATOR_LOGICAL_NOT
public static final int OPERATOR_LOGICAL_NOT- See Also:
-
OPERATOR_LOGICAL_AND
public static final int OPERATOR_LOGICAL_AND- See Also:
-
OPERATOR_LOGICAL_OR
public static final int OPERATOR_LOGICAL_OR- See Also:
-
OPERATOR_ADD
public static final int OPERATOR_ADD- See Also:
-
OPERATOR_SUBTRACT
public static final int OPERATOR_SUBTRACT- See Also:
-
OPERATOR_MULTIPLY
public static final int OPERATOR_MULTIPLY- See Also:
-
OPERATOR_DIVIDE
public static final int OPERATOR_DIVIDE- See Also:
-
OPERATOR_MOD
public static final int OPERATOR_MOD- See Also:
-
OPERATOR_BITWISE_COMPLIMENT
public static final int OPERATOR_BITWISE_COMPLIMENT- See Also:
-
OPERATOR_BITWISE_AND
public static final int OPERATOR_BITWISE_AND- See Also:
-
OPERATOR_BITWISE_OR
public static final int OPERATOR_BITWISE_OR- See Also:
-
OPERATOR_BITWISE_XOR
public static final int OPERATOR_BITWISE_XOR- See Also:
-
OPERATOR_SHIFT_LEFT
public static final int OPERATOR_SHIFT_LEFT- See Also:
-
OPERATOR_SHIFT_RIGHT
public static final int OPERATOR_SHIFT_RIGHT- See Also:
-
OPERATOR_SHIFT_RIGHT_UNSIGNED
public static final int OPERATOR_SHIFT_RIGHT_UNSIGNED- See Also:
-
OPERATOR_ASSIGN
public static final int OPERATOR_ASSIGN- See Also:
-
OPERATOR_ADD_ASSIGN
public static final int OPERATOR_ADD_ASSIGN- See Also:
-
OPERATOR_SUBTRACT_ASSIGN
public static final int OPERATOR_SUBTRACT_ASSIGN- See Also:
-
OPERATOR_MULTIPLY_ASSIGN
public static final int OPERATOR_MULTIPLY_ASSIGN- See Also:
-
OPERATOR_DIVIDE_ASSIGN
public static final int OPERATOR_DIVIDE_ASSIGN- See Also:
-
OPERATOR_MOD_ASSIGN
public static final int OPERATOR_MOD_ASSIGN- See Also:
-
OPERATOR_BITWISE_AND_ASSIGN
public static final int OPERATOR_BITWISE_AND_ASSIGN- See Also:
-
OPERATOR_BITWISE_OR_ASSIGN
public static final int OPERATOR_BITWISE_OR_ASSIGN- See Also:
-
OPERATOR_BITWISE_XOR_ASSIGN
public static final int OPERATOR_BITWISE_XOR_ASSIGN- See Also:
-
OPERATOR_SHIFT_LEFT_ASSIGN
public static final int OPERATOR_SHIFT_LEFT_ASSIGN- See Also:
-
OPERATOR_SHIFT_RIGHT_ASSIGN
public static final int OPERATOR_SHIFT_RIGHT_ASSIGN- See Also:
-
OPERATOR_SHIFT_RIGHT_UNSIGNED_ASSIGN
public static final int OPERATOR_SHIFT_RIGHT_UNSIGNED_ASSIGN- See Also:
-
OPERATOR_INCREMENT
public static final int OPERATOR_INCREMENT- See Also:
-
OPERATOR_DECREMENT
public static final int OPERATOR_DECREMENT- See Also:
-
OPERATOR_QUESTION
public static final int OPERATOR_QUESTION- See Also:
-
OPERATOR_COLON
public static final int OPERATOR_COLON- See Also:
-
COMMENT_TRADITIONAL
public static final int COMMENT_TRADITIONAL- See Also:
-
COMMENT_END_OF_LINE
public static final int COMMENT_END_OF_LINE- See Also:
-
COMMENT_DOCUMENTATION
public static final int COMMENT_DOCUMENTATION- See Also:
-
WHITE_SPACE
public static final int WHITE_SPACE- See Also:
-
ERROR_IDENTIFIER
public static final int ERROR_IDENTIFIER- See Also:
-
ERROR_UNCLOSED_STRING
public static final int ERROR_UNCLOSED_STRING- See Also:
-
ERROR_MALFORMED_STRING
public static final int ERROR_MALFORMED_STRING- See Also:
-
ERROR_MALFORMED_UNCLOSED_STRING
public static final int ERROR_MALFORMED_UNCLOSED_STRING- See Also:
-
ERROR_UNCLOSED_CHARACTER
public static final int ERROR_UNCLOSED_CHARACTER- See Also:
-
ERROR_MALFORMED_CHARACTER
public static final int ERROR_MALFORMED_CHARACTER- See Also:
-
ERROR_MALFORMED_UNCLOSED_CHARACTER
public static final int ERROR_MALFORMED_UNCLOSED_CHARACTER- See Also:
-
ERROR_INTEGER_DECIMIAL_SIZE
public static final int ERROR_INTEGER_DECIMIAL_SIZE- See Also:
-
ERROR_INTEGER_OCTAL_SIZE
public static final int ERROR_INTEGER_OCTAL_SIZE- See Also:
-
ERROR_INTEGER_HEXIDECIMAL_SIZE
public static final int ERROR_INTEGER_HEXIDECIMAL_SIZE- See Also:
-
ERROR_LONG_DECIMIAL_SIZE
public static final int ERROR_LONG_DECIMIAL_SIZE- See Also:
-
ERROR_LONG_OCTAL_SIZE
public static final int ERROR_LONG_OCTAL_SIZE- See Also:
-
ERROR_LONG_HEXIDECIMAL_SIZE
public static final int ERROR_LONG_HEXIDECIMAL_SIZE- See Also:
-
ERROR_FLOAT_SIZE
public static final int ERROR_FLOAT_SIZE- See Also:
-
ERROR_DOUBLE_SIZE
public static final int ERROR_DOUBLE_SIZE- See Also:
-
ERROR_FLOAT
public static final int ERROR_FLOAT- See Also:
-
ERROR_UNCLOSED_COMMENT
public static final int ERROR_UNCLOSED_COMMENT- See Also:
-
-
Constructor Details
-
JavaScriptToken
Create a new token. The constructor is typically called by the lexer- Parameters:
ID
- the id number of the tokencontents
- A string representing the text of the tokenlineNumber
- the line number of the input on which this token startedcharBegin
- the offset into the input in characters at which this token startedcharEnd
- the offset into the input in characters at which this token ended
-
JavaScriptToken
public JavaScriptToken(int ID, String contents, int lineNumber, int charBegin, int charEnd, int state) Create a new token. The constructor is typically called by the lexer- Parameters:
ID
- the id number of the tokencontents
- A string representing the text of the tokenlineNumber
- the line number of the input on which this token startedcharBegin
- the offset into the input in characters at which this token startedcharEnd
- the offset into the input in characters at which this token endedstate
- the state the tokenizer is in after returning this token.
-
-
Method Details
-
getState
public int getState()Get an integer representing the state the tokenizer is in after returning this token. Those who are interested in incremental tokenizing for performance reasons will want to use this method to figure out where the tokenizer may be restarted. The tokenizer starts in Token.INITIAL_STATE, so any time that it reports that it has returned to this state, the tokenizer may be restarted from there. -
getID
public int getID()get the ID number of this token -
getContents
get the contents of this token- Specified by:
getContents
in classToken
- Returns:
- A string representing the text of the token
-
getLineNumber
public int getLineNumber()get the line number of the input on which this token started- Specified by:
getLineNumber
in classToken
- Returns:
- the line number of the input on which this token started
-
getCharBegin
public int getCharBegin()get the offset into the input in characters at which this token started- Specified by:
getCharBegin
in classToken
- Returns:
- the offset into the input in characters at which this token started
-
getCharEnd
public int getCharEnd()get the offset into the input in characters at which this token ended- Specified by:
getCharEnd
in classToken
- Returns:
- the offset into the input in characters at which this token ended
-
isReservedWord
public boolean isReservedWord()Checks this token to see if it is a reserved word. Reserved words are explained in Java Language Specification.- Returns:
- true if this token is a reserved word, false otherwise
-
isIdentifier
public boolean isIdentifier()Checks this token to see if it is an identifier. Identifiers are explained in Java Language Specification.- Returns:
- true if this token is an identifier, false otherwise
-
isLiteral
public boolean isLiteral()Checks this token to see if it is a literal. Literals are explained in Java Language Specification.- Returns:
- true if this token is a literal, false otherwise
-
isSeparator
public boolean isSeparator()Checks this token to see if it is a Separator. Separators are explained in Java Language Specification.- Returns:
- true if this token is a Separator, false otherwise
-
isOperator
public boolean isOperator()Checks this token to see if it is a Operator. Operators are explained in Java Language Specification.- Returns:
- true if this token is a Operator, false otherwise
-
isComment
public boolean isComment()Checks this token to see if it is a comment. -
isWhiteSpace
public boolean isWhiteSpace()Checks this token to see if it is White Space. Usually tabs, line breaks, form feed, spaces, etc.- Specified by:
isWhiteSpace
in classToken
- Returns:
- true if this token is White Space, false otherwise
-
isError
public boolean isError()Checks this token to see if it is an Error. Unfinished comments, numbers that are too big, unclosed strings, etc. -
getDescription
A description of this token. The description should be appropriate for syntax highlighting. For example "comment" is returned for a comment.- Specified by:
getDescription
in classToken
- Returns:
- a description of this token.
-
errorString
get a String that explains the error, if this token is an error.- Specified by:
errorString
in classToken
- Returns:
- a String that explains the error, if this token is an error, null otherwise.
-
toString
get a representation of this token as a human-readable string. The format of this string is subject to change and should only be used for debugging purposes.
-