|
Ocean
|
This class implements a token for the scanner. More...
#include <Scanner.h>
Public Types | |
| enum | Type : uint32_t { TOKEN_INVALID = 0u , TOKEN_CHARACTER , TOKEN_END_OF_FILE , TOKEN_IDENTIFIER , TOKEN_LINE , TOKEN_NUMBER , TOKEN_INTEGER , TOKEN_KEYWORD , TOKEN_STRING , TOKEN_SYMBOL } |
| Definition of different token types. More... | |
Public Member Functions | |
| Token ()=default | |
| Creates an invalid token. | |
| Token (std::string &&data, const Type type) | |
| Creates a new token with given data and type. | |
| Token (const std::string &data, const Type type) | |
| Creates a new token with given data and type. | |
| Token (std::string &&data, const uint32_t id, const Type type) | |
| Creates a new token with given keyword or symbol id. | |
| Token (const std::string &data, const uint32_t id, const Type type) | |
| Creates a new token with given keyword or symbol id. | |
| Type | type () const |
| Returns the type of the token. | |
| bool | isType (const Type type) const |
| Returns whether this token is of a specific type. | |
| bool | isCharacter () const |
| Returns whether this token holds a character. | |
| bool | isIdentifier () const |
| Returns whether this token holds an identifier. | |
| bool | isInteger () const |
| Returns whether this token holds an integer. | |
| bool | isLine () const |
| Returns whether this token holds a remaining line. | |
| bool | isNumber () const |
| Returns whether this token holds a number. | |
| bool | isIntegerOrNumber () const |
| Returns whether this token holds an integer or a number. | |
| bool | isKeyword () const |
| Returns whether this token holds a keyword. | |
| bool | isKeyword (const uint32_t keyword) const |
| Returns whether this token holds a special keyword. | |
| bool | isString () const |
| Returns whether this token holds a string. | |
| bool | isSymbol () const |
| Returns whether this token holds a symbol. | |
| bool | isSymbol (const uint32_t symbol) const |
| Returns whether this token holds a special symbol. | |
| bool | isEndOfFile () const |
| Returns whether this token holds a end of file. | |
| uint8_t | character () const |
| Returns the character value of this token. | |
| const std::string & | identifier () const |
| Returns the identifier value of this token. | |
| int | integer () const |
| Returns the integer value of this token. | |
| Scalar | number () const |
| Returns the float value of this token. | |
| Scalar | integerOrNumber () const |
| Returns the integer or float value of this token. | |
| const std::string & | line () const |
| Returns the remaining line of this token. | |
| uint32_t | keyword () const |
| Returns the id of the keyword of this token. | |
| uint32_t | symbol () const |
| Returns the id of the symbol of this token. | |
| const std::string & | string () const |
| Returns the string value of this token. | |
| std::string | moveString () |
| Returns the string value of this token and invalidates the token. | |
| const std::string & | raw () const |
| Returns the raw data of the token. | |
| operator bool () const | |
| Returns whether the token is valid. | |
Protected Attributes | |
| Type | type_ = TOKEN_INVALID |
| Holds the type of the token. | |
| uint32_t | id_ = invalidId |
| Holds the id of the keyword or symbol, if any. | |
| std::string | data_ |
| Holds the data of the token. | |
This class implements a token for the scanner.
| enum Ocean::IO::Scanner::Token::Type : uint32_t |
Definition of different token types.
| Enumerator | |
|---|---|
| TOKEN_INVALID | Invalid token. |
| TOKEN_CHARACTER | Character token. |
| TOKEN_END_OF_FILE | End of file token. |
| TOKEN_IDENTIFIER | Identifier token. |
| TOKEN_LINE | Line token. |
| TOKEN_NUMBER | Number token. |
| TOKEN_INTEGER | Integer token. |
| TOKEN_KEYWORD | Keyword token. |
| TOKEN_STRING | String token. |
| TOKEN_SYMBOL | Symbol token. |
|
default |
Creates an invalid token.
| Ocean::IO::Scanner::Token::Token | ( | std::string && | data, |
| const Type | type | ||
| ) |
| Ocean::IO::Scanner::Token::Token | ( | const std::string & | data, |
| const Type | type | ||
| ) |
| Ocean::IO::Scanner::Token::Token | ( | std::string && | data, |
| const uint32_t | id, | ||
| const Type | type | ||
| ) |
Creates a new token with given keyword or symbol id.
| data | Raw token data |
| id | Keyword or symbol id of the token |
| type | Token type |
| Ocean::IO::Scanner::Token::Token | ( | const std::string & | data, |
| const uint32_t | id, | ||
| const Type | type | ||
| ) |
Creates a new token with given keyword or symbol id.
| data | Raw token data |
| id | Keyword or symbol id of the token |
| type | Token type |
| uint8_t Ocean::IO::Scanner::Token::character | ( | ) | const |
Returns the character value of this token.
| const std::string & Ocean::IO::Scanner::Token::identifier | ( | ) | const |
Returns the identifier value of this token.
| int Ocean::IO::Scanner::Token::integer | ( | ) | const |
Returns the integer value of this token.
| Scalar Ocean::IO::Scanner::Token::integerOrNumber | ( | ) | const |
Returns the integer or float value of this token.
|
inline |
Returns whether this token holds a character.
|
inline |
Returns whether this token holds a end of file.
|
inline |
Returns whether this token holds an identifier.
|
inline |
Returns whether this token holds an integer.
|
inline |
Returns whether this token holds an integer or a number.
|
inline |
Returns whether this token holds a keyword.
| bool Ocean::IO::Scanner::Token::isKeyword | ( | const uint32_t | keyword | ) | const |
Returns whether this token holds a special keyword.
| keyword | The keyword id to check |
|
inline |
Returns whether this token holds a remaining line.
|
inline |
Returns whether this token holds a number.
|
inline |
Returns whether this token holds a string.
|
inline |
Returns whether this token holds a symbol.
| bool Ocean::IO::Scanner::Token::isSymbol | ( | const uint32_t | symbol | ) | const |
Returns whether this token holds a special symbol.
| symbol | The symbol id to check |
|
inline |
Returns whether this token is of a specific type.
| type | The type to check |
| uint32_t Ocean::IO::Scanner::Token::keyword | ( | ) | const |
Returns the id of the keyword of this token.
| const std::string & Ocean::IO::Scanner::Token::line | ( | ) | const |
Returns the remaining line of this token.
| std::string Ocean::IO::Scanner::Token::moveString | ( | ) |
Returns the string value of this token and invalidates the token.
| Scalar Ocean::IO::Scanner::Token::number | ( | ) | const |
Returns the float value of this token.
|
inlineexplicit |
Returns whether the token is valid.
|
inline |
Returns the raw data of the token.
| const std::string & Ocean::IO::Scanner::Token::string | ( | ) | const |
Returns the string value of this token.
| uint32_t Ocean::IO::Scanner::Token::symbol | ( | ) | const |
Returns the id of the symbol of this token.
|
inline |
Returns the type of the token.
|
protected |
Holds the data of the token.
|
protected |
Holds the id of the keyword or symbol, if any.
|
protected |
Holds the type of the token.