Envision
A visual programming IDE for object-oriented languages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
Interaction::Token Class Reference

Public Types

enum  Type { Identifier , Literal , OperatorDelimiter , PartialLiteral , SubExpression }
 

Public Member Functions

 Token ()
 
 Token (QString text, Type type)
 
const QString & text () const
 
Type type () const
 

Static Public Member Functions

static QVector< TokencreateSubExpressions (const QVector< Token > &tokens)
 
static QVector< Tokentokenize (QString input, const OperatorDescriptorList *ops)
 

Static Private Member Functions

static int countUnmatched (QVector< Token >::const_iterator start, QVector< Token >::const_iterator end, QChar openParen, QChar closeParen)
 
static QVector< TokencreateSubExpressions (QVector< Token >::const_iterator start, QVector< Token >::const_iterator end, QChar openParen, QChar closeParen)
 
static bool findSplit (QVector< Token >::const_iterator &splitStart, QVector< Token >::const_iterator &splitEnd, QChar openParen, QChar closeParen)
 Adjusts the splitStart and splitEnd arguments to indicate the best split of the given range and returns true if a split was found. More...
 
static Token parseIdentifier (QString::const_iterator &it, const QString::const_iterator end, const OperatorDescriptorList *ops)
 
static Token parseNumberLiteral (QString::const_iterator &it, const QString::const_iterator end)
 
static Token parseOperator (QString::const_iterator &it, const QString::const_iterator end, const OperatorDescriptorList *ops)
 
static Token parseStringLiteral (QString::const_iterator &it, const QString::const_iterator end)
 
static bool tokenExistsInOperators (QString token, const OperatorDescriptorList *ops)
 

Private Attributes

ParseResult subExpressionResult_ {}
 
QVector< TokensubExpressionTokens_ {}
 
QString text_
 
Type type_
 

Static Private Attributes

static QStringList specialSignatureWords_ = {"SPACE", "EXPR", "ID"}
 

Friends

class Parser
 

Member Enumeration Documentation

◆ Type

Enumerator
Identifier 

This token is an identifier.

It is not identical to a keyword

Literal 

This token is a string or a number literal.

OperatorDelimiter 

This token is an operator delimiter - a keyword or an operator, including parenthesis.

PartialLiteral 

This token is a partial literal, such an incomplete string.

SubExpression 

This token is a sub expression.

This is used with expressions surrounded by braces or parenthesis to speed up the parsing process.

Constructor & Destructor Documentation

◆ Token() [1/2]

Interaction::Token::Token ( )

◆ Token() [2/2]

Interaction::Token::Token ( QString  text,
Type  type 
)

Member Function Documentation

◆ countUnmatched()

int Interaction::Token::countUnmatched ( QVector< Token >::const_iterator  start,
QVector< Token >::const_iterator  end,
QChar  openParen,
QChar  closeParen 
)
staticprivate

◆ createSubExpressions() [1/2]

QVector< Token > Interaction::Token::createSubExpressions ( const QVector< Token > &  tokens)
static

◆ createSubExpressions() [2/2]

QVector< Token > Interaction::Token::createSubExpressions ( QVector< Token >::const_iterator  start,
QVector< Token >::const_iterator  end,
QChar  openParen,
QChar  closeParen 
)
staticprivate

◆ findSplit()

bool Interaction::Token::findSplit ( QVector< Token >::const_iterator &  splitStart,
QVector< Token >::const_iterator &  splitEnd,
QChar  openParen,
QChar  closeParen 
)
staticprivate

Adjusts the splitStart and splitEnd arguments to indicate the best split of the given range and returns true if a split was found.

If the return value is false the input sequence of tokens should remain as it is.

The range is given by the initial values of splitStart and splitEnd. The returned values are such that: tokens before splitStart should remain as they are (there is no open paren); splitStart points just after the first open paren; splitEnd points at the closing paren that matches the one from splitStart.

The best possible split is determined by trying to minimize the sum of the unmatched count of the tokens: between splitStart and splitEnd; after splitEnd

◆ parseIdentifier()

Token Interaction::Token::parseIdentifier ( QString::const_iterator &  it,
const QString::const_iterator  end,
const OperatorDescriptorList ops 
)
staticprivate

◆ parseNumberLiteral()

Token Interaction::Token::parseNumberLiteral ( QString::const_iterator &  it,
const QString::const_iterator  end 
)
staticprivate

◆ parseOperator()

Token Interaction::Token::parseOperator ( QString::const_iterator &  it,
const QString::const_iterator  end,
const OperatorDescriptorList ops 
)
staticprivate

◆ parseStringLiteral()

Token Interaction::Token::parseStringLiteral ( QString::const_iterator &  it,
const QString::const_iterator  end 
)
staticprivate

◆ text()

const QString & Interaction::Token::text ( ) const
inline

◆ tokenExistsInOperators()

bool Interaction::Token::tokenExistsInOperators ( QString  token,
const OperatorDescriptorList ops 
)
staticprivate

◆ tokenize()

QVector< Token > Interaction::Token::tokenize ( QString  input,
const OperatorDescriptorList ops 
)
static

◆ type()

Token::Type Interaction::Token::type ( ) const
inline

Friends And Related Function Documentation

◆ Parser

friend class Parser
friend

Member Data Documentation

◆ specialSignatureWords_

QStringList Interaction::Token::specialSignatureWords_ = {"SPACE", "EXPR", "ID"}
staticprivate

◆ subExpressionResult_

ParseResult Interaction::Token::subExpressionResult_ {}
private

◆ subExpressionTokens_

QVector<Token> Interaction::Token::subExpressionTokens_ {}
private

◆ text_

QString Interaction::Token::text_
private

◆ type_

Type Interaction::Token::type_
private