LibreOffice Module starmath (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SmNodeListParser Class Reference

Minimalistic recursive decent SmNodeList parser. More...

#include <cursor.hxx>

Public Member Functions

 SmNodeListParser ()
 Create an instance of SmNodeListParser. More...
 
SmNode * Parse (SmNodeList *list)
 Parse a list of nodes to an expression. More...
 

Static Public Member Functions

static bool IsOperator (const SmToken &token)
 True, if the token is an operator. More...
 
static bool IsRelationOperator (const SmToken &token)
 True, if the token is a relation operator. More...
 
static bool IsSumOperator (const SmToken &token)
 True, if the token is a sum operator. More...
 
static bool IsProductOperator (const SmToken &token)
 True, if the token is a product operator. More...
 
static bool IsUnaryOperator (const SmToken &token)
 True, if the token is a unary operator. More...
 
static bool IsPostfixOperator (const SmToken &token)
 True, if the token is a postfix operator. More...
 

Private Member Functions

SmNode * Terminal ()
 Get the current terminal. More...
 
SmNode * Next ()
 Move to next terminal. More...
 
SmNode * Take ()
 Take the current terminal. More...
 
SmNode * Expression ()
 
SmNode * Relation ()
 
SmNode * Sum ()
 
SmNode * Product ()
 
SmNode * Factor ()
 
SmNode * Postfix ()
 

Static Private Member Functions

static SmNode * Error ()
 

Private Attributes

SmNodeList * pList
 

Detailed Description

Minimalistic recursive decent SmNodeList parser.

This parser is used to take a list of nodes that constitutes a line and parse them to a tree of SmBinHorNode, SmUnHorNode and SmExpression.

Please note, this will not handle all kinds of nodes, only nodes that constitutes and entry in a line.

Below is an EBNF representation of the grammar used for this parser:

Relation -> Sum [(=|<|>|...) Sum]*
Sum -> Product [(+|-) Product]*
Product -> Factor [(*|/) Factor]*
Factor -> [+|-|-+|...]* Factor | Postfix
Postfix -> node [!]*
SmNode * Postfix()
Definition: cursor.cxx:1520
SmNode * Product()
Definition: cursor.cxx:1481
SmNode * Expression()
Definition: cursor.cxx:1435
SmNode * Sum()
Definition: cursor.cxx:1464
SmNode * Relation()
Definition: cursor.cxx:1447
SmNode * Factor()
Definition: cursor.cxx:1498

Definition at line 376 of file cursor.hxx.

Constructor & Destructor Documentation

◆ SmNodeListParser()

SmNodeListParser::SmNodeListParser ( )
inline

Create an instance of SmNodeListParser.

Definition at line 380 of file cursor.hxx.

References pList.

Member Function Documentation

◆ Error()

SmNode * SmNodeListParser::Error ( )
staticprivate

Definition at line 1539 of file cursor.cxx.

Referenced by Factor(), and Postfix().

◆ Expression()

SmNode * SmNodeListParser::Expression ( )
private

Definition at line 1435 of file cursor.cxx.

References Relation(), SmStructureNode::SetSubNodes(), and Terminal().

Referenced by Parse().

◆ Factor()

SmNode * SmNodeListParser::Factor ( )
private

Definition at line 1498 of file cursor.cxx.

References Error(), Factor(), IsUnaryOperator(), Next(), Postfix(), SmStructureNode::SetSubNodes(), and Terminal().

Referenced by Factor(), and Product().

◆ IsOperator()

bool SmNodeListParser::IsOperator ( const SmToken &  token)
static

True, if the token is an operator.

Definition at line 1543 of file cursor.cxx.

References IsPostfixOperator(), IsProductOperator(), IsRelationOperator(), IsSumOperator(), and IsUnaryOperator().

Referenced by SmCursor::PatchLineList(), and Postfix().

◆ IsPostfixOperator()

bool SmNodeListParser::IsPostfixOperator ( const SmToken &  token)
static

True, if the token is a postfix operator.

Definition at line 1578 of file cursor.cxx.

References SmToken::eType, and TFACT.

Referenced by IsOperator(), and Postfix().

◆ IsProductOperator()

bool SmNodeListParser::IsProductOperator ( const SmToken &  token)
static

True, if the token is a product operator.

Definition at line 1559 of file cursor.cxx.

References SmToken::eType, SmToken::nGroup, Product, TOVER, TOVERBRACE, TUNDERBRACE, TWIDEBACKSLASH, and TWIDESLASH.

Referenced by IsOperator(), and Product().

◆ IsRelationOperator()

bool SmNodeListParser::IsRelationOperator ( const SmToken &  token)
static

True, if the token is a relation operator.

Definition at line 1551 of file cursor.cxx.

References SmToken::nGroup, and Relation.

Referenced by IsOperator(), and Relation().

◆ IsSumOperator()

bool SmNodeListParser::IsSumOperator ( const SmToken &  token)
static

True, if the token is a sum operator.

Definition at line 1555 of file cursor.cxx.

References SmToken::nGroup, and Sum.

Referenced by IsOperator(), and Sum().

◆ IsUnaryOperator()

bool SmNodeListParser::IsUnaryOperator ( const SmToken &  token)
static

True, if the token is a unary operator.

Definition at line 1568 of file cursor.cxx.

References SmToken::eType, SmToken::nGroup, TMINUS, TMINUSPLUS, TNEG, TPLUS, TPLUSMINUS, TUOPER, and UnOper.

Referenced by Factor(), and IsOperator().

◆ Next()

SmNode * SmNodeListParser::Next ( void  )
inlineprivate

Move to next terminal.

Definition at line 409 of file cursor.hxx.

References pList, and Terminal().

Referenced by Factor(), and Take().

◆ Parse()

SmNode * SmNodeListParser::Parse ( SmNodeList *  list)

Parse a list of nodes to an expression.

Old error nodes will be deleted.

Definition at line 1418 of file cursor.cxx.

References Error, Expression(), and pList.

Referenced by SmCursor::DeletePrev(), and SmCursor::InsertSubSup().

◆ Postfix()

SmNode * SmNodeListParser::Postfix ( )
private

Definition at line 1520 of file cursor.cxx.

References Error(), IsOperator(), IsPostfixOperator(), Take(), and Terminal().

Referenced by Factor().

◆ Product()

SmNode * SmNodeListParser::Product ( )
private

Definition at line 1481 of file cursor.cxx.

References Factor(), IsProductOperator(), Take(), and Terminal().

Referenced by Sum().

◆ Relation()

SmNode * SmNodeListParser::Relation ( )
private

Definition at line 1447 of file cursor.cxx.

References IsRelationOperator(), Sum(), Take(), and Terminal().

Referenced by Expression().

◆ Sum()

SmNode * SmNodeListParser::Sum ( )
private

Definition at line 1464 of file cursor.cxx.

References IsSumOperator(), Product(), Take(), and Terminal().

Referenced by Relation().

◆ Take()

SmNode * SmNodeListParser::Take ( )
inlineprivate

Take the current terminal.

Definition at line 415 of file cursor.hxx.

References Next(), and Terminal().

Referenced by Postfix(), Product(), Relation(), and Sum().

◆ Terminal()

SmNode * SmNodeListParser::Terminal ( )
inlineprivate

Get the current terminal.

Definition at line 402 of file cursor.hxx.

References pList.

Referenced by Expression(), Factor(), Next(), Postfix(), Product(), Relation(), Sum(), and Take().

Member Data Documentation

◆ pList

SmNodeList* SmNodeListParser::pList
private

Definition at line 400 of file cursor.hxx.

Referenced by Next(), Parse(), SmNodeListParser(), and Terminal().


The documentation for this class was generated from the following files: