|
enum | TokenType {
KEY_ALIGNOF
, KEY_BOOL
, KEY_BREAK
, KEY_CASE
,
KEY_CAST
, KEY_CHAR
, KEY_CONST
, KEY_CONTINUE
,
KEY_DEFAULT
, KEY_DO
, KEY_DOUBLE
, KEY_ELSE
,
KEY_ENUM
, KEY_FLOAT
, KEY_FOR
, KEY_IF
,
KEY_INCLUDE
, KEY_INT
, KEY_LONG
, KEY_NAMESPACE
,
KEY_NATIVE
, KEY_RETURN
, KEY_SHORT
, KEY_SIZEOF
,
KEY_STRUCT
, KEY_SWITCH
, KEY_THIS
, KEY_UCHAR
,
KEY_UINT
, KEY_ULONG
, KEY_USHORT
, KEY_VOID
,
KEY_WHILE
, IDENTIFIER
, OP_PLUS
, OP_MINUS
,
OP_STAR
, OP_DIV
, OP_MOD
, OP_INC
,
OP_DEC
, OP_LT
, OP_LTE
, OP_GT
,
OP_GTE
, OP_LEFT
, OP_RIGHT
, OP_EQUAL
,
OP_NOT_EQUAL
, OP_NOT
, OP_AND
, OP_OR
,
OP_AMP
, OP_BIT_OR
, OP_BIT_XOR
, OP_BIT_NOT
,
OP_TERNARY
, OP_ARROW
, ASSIGN
, ASSIGN_LEFT
,
ASSIGN_RIGHT
, ASSIGN_PLUS
, ASSIGN_MINUS
, ASSIGN_MULT
,
ASSIGN_DIV
, ASSIGN_MOD
, ASSIGN_AND
, ASSIGN_OR
,
ASSIGN_XOR
, OPAREN
, CPAREN
, OBRACE
,
CBRACE
, OBRACKET
, CBRACKET
, PERIOD
,
SEMICOLON
, COLON
, SCOPE
, COMMA
,
CONST_BOOL
, CONST_CHAR
, CONST_INT
, CONST_UINT
,
CONST_LONG
, CONST_ULONG
, CONST_FLOAT
, CONST_DOUBLE
,
CONST_STRING
, CONST_NULL
, INVALID
, END
,
NUM_TOKEN_TYPES
} |
| An enumeration describing the various types of Tokens. More...
|
|
enum | Annotation { OCTAL = 1
, HEX = 2
} |
| An enumeration describing a characteristic of the token as it appears in the Bond source. Currently only used to qualify integer literals as being expressed as hex or octal. More...
|
|
|
| Token () |
| Default constructs an empty Token object. More...
|
|
| Token (const char *text, TokenType tokenType) |
| Constructs a Token object with the given text and type. More...
|
|
| Token (const StreamPos &startPos, const StreamPos &endPos, const Value &value, const char *text, const char *fileName, TokenType tokenType, short annotations=0) |
| Constructs a fully described token. More...
|
|
const StringView & | GetText () const |
| Returns the text that forms the token as it appears in the Bond source. More...
|
|
const char * | GetRawText () const |
| Like GetText, but returns the text as a C-style string. The text may be truncated if it contains a null character. More...
|
|
void | SetText (const char *text) |
| Assigns the text that forms the token. The text is assumed to be null terminated. More...
|
|
void | SetText (const char *text, size_t length) |
| Assigns the text that forms the token. The text may contain null characters.. More...
|
|
const char * | GetFileName () const |
| Returns the name of the Bond source file from which the Token was generated. More...
|
|
void | SetFileName (const char *fileName) |
| Assigns the name of the Bond source file from which the Token was generated. More...
|
|
const StreamPos & | GetStartPos () const |
| Returns the starting position of the Token in the Bond source file. More...
|
|
void | SetStartPos (const StreamPos &pos) |
| Assigns the starting position of the Token in the Bond source file. More...
|
|
size_t | GetEndIndex () const |
| Returns the offset into the Bond source of the end of the token. To save space, the entire position information is not available. More...
|
|
void | SetEndIndex (size_t index) |
| Assigns the offset into the Bond source of the end of the token. More...
|
|
TokenType | GetTokenType () const |
| Returns the type of the token. More...
|
|
void | SetTokenType (const TokenType &type) |
| Assigns the type of the Token. More...
|
|
void | AddAnnotation (const Annotation &annotation) |
| Adds an annotation to the token. More...
|
|
bool | HasAnnotation (const Annotation &annotation) const |
| Returns whether the Token as a specified annotation. More...
|
|
const Value & | GetValue () const |
| Returns the value of the token. Valid only for constant literal tokens. More...
|
|
bool | GetBoolValue () const |
| Returns the boolean value of the Token. Valid only for Tokens of type CONST_BOOL . More...
|
|
void | SetBoolValue (bool value) |
| Assigns the boolean value of the Token. Valid only for Tokens of type CONST_BOOL . More...
|
|
int32_t | GetIntValue () const |
| Returns the integral value of the Token. Valid only for Tokens of type CONST_INT . More...
|
|
void | SetIntValue (int32_t value) |
| Assigns the integral value of the Token. Valid only for Tokens of type CONST_INT . More...
|
|
uint32_t | GetUIntValue () const |
| Returns the integral value of the Token. Valid only for Tokens of type CONST_UINT . More...
|
|
void | SetUIntValue (uint32_t value) |
| Assigns the integral value of the Token. Valid only for Tokens of type CONST_UINT . More...
|
|
int64_t | GetLongValue () const |
| Returns the integral value of the Token. Valid only for Tokens of type CONST_LONG . More...
|
|
void | SetLongValue (int64_t value) |
| Assigns the integral value of the Token. Valid only for Tokens of type CONST_LONG . More...
|
|
uint64_t | GetULongValue () const |
| Returns the integral value of the Token. Valid only for Tokens of type CONST_ULONG . More...
|
|
void | SetULongValue (uint64_t value) |
| Assigns the integral value of the Token. Valid only for Tokens of type CONST_ULONG . More...
|
|
float | GetFloatValue () const |
| Returns the floating point value of the Token. Valid only for Tokens of type CONST_FLOAT . More...
|
|
void | SetFloatValue (float value) |
| Assigns the floating point value of the Token. Valid only for Tokens of type CONST_FLOAT . More...
|
|
double | GetDoubleValue () const |
| Returns the floating point value of the Token. Valid only for Tokens of type CONST_DOUBLE . More...
|
|
void | SetDoubleValue (double value) |
| Assigns the floating point value of the Token. Valid only for Tokens of type CONST_DOUBLE . More...
|
|
const StringView | GetStringValue () const |
| Returns the string value of the Token. Valid only for Tokens of type CONST_STRING . More...
|
|
size_t | GetStringLength () const |
| A short-hand for GetStringValue().length(). More...
|
|
void | SetStringValue (const StringView &str) |
| Assigns the string value of the Token. Valid only for Tokens of type CONST_STRING . More...
|
|
const char * | GetTokenName () const |
| Returns a descriptive name for the token's type. More...
|
|
A token describing a syntactic unit of the Bond scripting language (e.g. keywords, identifiers, literal constants and operators).
A Token is typically created by a Lexer as it scans Bond source code. It contains the text from which the token is formed as it appears in the Bond source, the position at which it appears in the Bond source, a type and a value for tokens which are literal constants.
- See also
- Lexer