diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2017-04-05 19:10:28 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2017-04-05 12:55:20 +0000 |
commit | 51de452ef613a50637b839f088860d6c654fd91d (patch) | |
tree | bdb94da66c66da988ee964b0c2b2d71d4385eb82 /starmath | |
parent | e1b31fbe6bdf9f02e3ebeb42891bbab77085ed68 (diff) |
starmath: Kill newly unused m_aNodeStack
which now has been replaced naturally with the call stack
of SmParser functions.
Change-Id: I970a350aae6927c6d13ed4917aa29bce3888a3fe
Reviewed-on: https://gerrit.libreoffice.org/36136
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/parse.hxx | 5 | ||||
-rw-r--r-- | starmath/source/parse.cxx | 34 |
2 files changed, 9 insertions, 30 deletions
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 4911e8516a81..1bcef035d5b2 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -33,7 +33,6 @@ class SmParser { OUString m_aBufferString; SmToken m_aCurToken; - SmNodeStack m_aNodeStack; std::vector<std::unique_ptr<SmErrorDesc>> m_aErrDescList; int m_nCurError; sal_Int32 m_nBufferIndex, @@ -62,7 +61,7 @@ class SmParser // grammar SmTableNode *DoTable(); - void DoLine(); + SmLineNode *DoLine(); SmNode *DoExpression(bool bUseExtraSpaces = true); SmNode *DoRelation(); SmNode *DoSum(); @@ -93,8 +92,6 @@ class SmParser SmExpressionNode *DoError(SmParseError Error); // end of grammar - void Error(SmParseError Error); - public: SmParser(); diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 1a2418314178..6ae84de21c3e 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -942,24 +942,19 @@ void SmParser::NextToken() SmTableNode *SmParser::DoTable() { - DoLine(); + SmNodeArray aLineArray; + aLineArray.push_back(DoLine()); while (m_aCurToken.eType == TNEWLINE) { NextToken(); - DoLine(); + aLineArray.push_back(DoLine()); } if (m_aCurToken.eType != TEND) - Error(SmParseError::UnexpectedChar); - - SmNodeArray LineArray(m_aNodeStack.size()); - for (auto rIt = LineArray.rbegin(), rEnd = LineArray.rend(); rIt != rEnd; ++rIt) - { - *rIt = popOrZero(m_aNodeStack); - } + aLineArray.push_back(DoError(SmParseError::UnexpectedChar)); std::unique_ptr<SmTableNode> pSNode(new SmTableNode(m_aCurToken)); - pSNode->SetSubNodes(LineArray); + pSNode->SetSubNodes(aLineArray); return pSNode.release(); } @@ -989,7 +984,7 @@ SmNode *SmParser::DoAlign(bool bUseExtraSpaces) return pNode.release(); } -void SmParser::DoLine() +SmLineNode *SmParser::DoLine() { SmNodeArray ExpressionArray; @@ -1012,9 +1007,9 @@ void SmParser::DoLine() ExpressionArray.push_back(new SmExpressionNode(aTok)); } - std::unique_ptr<SmStructureNode> pSNode(new SmLineNode(m_aCurToken)); + auto pSNode = o3tl::make_unique<SmLineNode>(m_aCurToken); pSNode->SetSubNodes(ExpressionArray); - m_aNodeStack.push_front(std::move(pSNode)); + return pSNode.release(); } SmNode *SmParser::DoExpression(bool bUseExtraSpaces) @@ -2170,15 +2165,6 @@ SmExpressionNode *SmParser::DoError(SmParseError eError) return pSNode.release(); } -void SmParser::Error(SmParseError eError) -{ - //! put a structure node on the stack (instead of the error node itself) - //! because sometimes such a node is expected in order to attach some - //! subnodes - m_aNodeStack.emplace_front(DoError(eError)); -} - - // end grammar @@ -2208,8 +2194,6 @@ SmTableNode *SmParser::Parse(const OUString &rBuffer) m_aErrDescList.clear(); - m_aNodeStack.clear(); - NextToken(); return DoTable(); } @@ -2225,8 +2209,6 @@ SmNode *SmParser::ParseExpression(const OUString &rBuffer) m_aErrDescList.clear(); - m_aNodeStack.clear(); - NextToken(); return DoExpression(); } |