Represents a single token in a parsed expression. More...
#include <elamexpression.h>
Public Types | |
enum | Type { Invalid =0, Function = 1, Constant = 2, Variable = 4, Name =0xff, NameMask =Name, UnaryOp = 0x100, BinaryOp = 0x200, AssignmentOp = 0x400, PipeOp = 0x800, Operator =0xff00, OperatorMask =Operator, SpecialCharMask =0xff0000, ParenthesesMask =0xf0000, Parentheses =0x10000, ParOpen =0x20000, ParClose =0x40000, Comma =0x100000, Literal =0x1000000, LiteralMask =Literal, FunctionalMask =NameMask|OperatorMask|SpecialCharMask, Whitespace =0x10000000, IgnoredTokenMask =0xf0000000 } |
The type of token. More... | |
Public Member Functions | |
Token (Position pos=Position(-1,-1)) | |
creates an empty/invalid token More... | |
Token (QString, Type, Position pos=Position(-1,-1)) | |
creates a token from a parsed piece of string, only generic types can be used More... | |
Token (QString, QVariant, Position pos=Position(-1,-1)) | |
creates a literal token More... | |
QString | content () const |
returns the string content of the token More... | |
Type | type () const |
returns the type of token this is More... | |
QVariant | literalValue () const |
for literals: returns the value More... | |
Position | position () const |
returns the original position of the token More... | |
QList< Token > | subTokens () const |
when the token is hierarchised (Parentheses, Function) this returns the subordinate tokens More... | |
bool | isFunctional () const |
true if the token is functional (not ignored) More... | |
bool | isOperator () const |
true if the token represents an operator More... | |
bool | isIgnored () const |
true if the token can be ignored More... | |
bool | isName () const |
true if the token represents a name More... | |
bool | isLiteral () const |
true if the token is a literal More... | |
Protected Member Functions | |
void | setSubType (Type) |
makes the tokens type more specialized More... | |
void | changeNameToOperator (Type) |
transmutes a name token to an operator token More... | |
void | addSubToken (const Token &) |
adds a token to the sub-token list More... | |
void | setSubTokens (const QList< Token > &) |
overrides the list of sub-tokens More... | |
Friends | |
class | Expression |
Represents a single token in a parsed expression.
Tokens are pretty stupid themselves - they just know their type, position, their original piece of text and an optional value (literals). They are used by the engine and expressions to transform text into executable expressions.
enum ELAM::Token::Type |
The type of token.
creates a token from a parsed piece of string, only generic types can be used
|
protected |
adds a token to the sub-token list
|
protected |
transmutes a name token to an operator token
QString ELAM::Token::content | ( | ) | const |
returns the string content of the token
|
inline |
true if the token is functional (not ignored)
|
inline |
true if the token can be ignored
|
inline |
true if the token is a literal
|
inline |
true if the token represents a name
|
inline |
true if the token represents an operator
QVariant ELAM::Token::literalValue | ( | ) | const |
for literals: returns the value
Position ELAM::Token::position | ( | ) | const |
returns the original position of the token
|
protected |
overrides the list of sub-tokens
|
protected |
makes the tokens type more specialized
QList<Token> ELAM::Token::subTokens | ( | ) | const |
when the token is hierarchised (Parentheses, Function) this returns the subordinate tokens
Type ELAM::Token::type | ( | ) | const |
returns the type of token this is
|
friend |