Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

oracle.javatools.parser
Interface SyntaxToken


public interface SyntaxToken

The SyntaxToken interface encapsulates a single syntax token retrieved by a call to SyntaxTranslator.translate(). This simply provides a convenient way for the translater to return multiple pieces of information (translate code, start offset, end offset) from the SyntaxTranslator to its clients.

It is defined as an interface to allow language-specific Lexer implementations to add additional information pieces to the token object.

The SyntaxToken is allocated using a call to SyntaxRecognizer.createSyntaxToken(), and is passed into SyntaxRecognizer.next() to be filled in.

See Also:
SyntaxRecognizer

Field Summary
static int SYNTAX_UNINITIALIZED
           
 
Method Summary
 int getCode()
          Fetches the (language-specific) token represented by this SyntaxToken.
 java.lang.String getContextString()
          If non-null, this String provides information about the parsing context of this token.
 int getDataValue()
          There is often some numeric integer value that can be associated with specific syntax tokens.
 int getEndOffset()
          Fetches the end offset of the token (offset relative to the original TextBuffer being lexed.
 int getStartOffset()
          Fetches the start offset of the token (offset relative to the original TextBuffer being lexed.
 

Field Detail

SYNTAX_UNINITIALIZED

static final int SYNTAX_UNINITIALIZED
See Also:
Constant Field Values
Method Detail

getCode

int getCode()
Fetches the (language-specific) token represented by this SyntaxToken. You must refer to the language-specific SyntaxTranslator that was responsible for filling this SyntaxToken instance to interpret the token.

Returns:
the syntax translation code

getStartOffset

int getStartOffset()
Fetches the start offset of the token (offset relative to the original TextBuffer being lexed. Note that the start offset is inclusive (compare to end offset which is exclusive), to match the behavior in the String class.

Returns:
the starting offset

getEndOffset

int getEndOffset()
Fetches the end offset of the token (offset relative to the original TextBuffer being lexed. Note that the end offset is exclusive (similar to end offsets in the String class.)

Returns:
the ending offset

getDataValue

int getDataValue()
There is often some numeric integer value that can be associated with specific syntax tokens. You must refer to the language-specific SyntaxTranslator that was responsible for filling this SyntaxToken instance to interpret the token.

Returns:
the data value

getContextString

java.lang.String getContextString()
If non-null, this String provides information about the parsing context of this token. Generally only used for debugging purposes. If getCode() == SyntaxRecognizer.SYNTAX_ERROR, this will return the syntax error message.

Returns:
the context string of this token

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

Copyright © 1997, 2011, Oracle. All rights reserved.