diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2017-03-23 00:16:57 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2017-03-22 18:03:54 +0000 |
commit | a69632cc1fdc931adcab4751607f3dd79b8cf771 (patch) | |
tree | e3745267ccd7b0f59fccab6e702cf53bb9d044ec /starmath/source | |
parent | b396bc042dad1d553ebf51897ef012c08c41a86a (diff) |
starmath: Make SmParser::DoPower() return SmNode
instead of pushing it to the stack.
Change-Id: I7b1640e1b3f835c06726941adfe6d212853f3af6
Reviewed-on: https://gerrit.libreoffice.org/35537
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/parse.cxx | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 9a147f48ee37..14ab62aad504 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -1097,12 +1097,11 @@ void SmParser::DoSum() void SmParser::DoProduct() { - DoPower(); + SmNode *pFirst = DoPower(); while (TokenInGroup(TG::Product)) { SmStructureNode *pSNode; - SmNode *pFirst = popOrZero(m_aNodeStack), - *pOper; + SmNode *pOper; bool bSwitchArgs = false; SmTokenType eType = m_aCurToken.eType; @@ -1153,19 +1152,20 @@ void SmParser::DoProduct() pOper = DoOpSubSup(); } - DoPower(); + SmNode *pArg = DoPower(); if (bSwitchArgs) { //! vgl siehe SmBinDiagonalNode::Arrange - pSNode->SetSubNodes(pFirst, popOrZero(m_aNodeStack), pOper); + pSNode->SetSubNodes(pFirst, pArg, pOper); } else { - pSNode->SetSubNodes(pFirst, pOper, popOrZero(m_aNodeStack)); + pSNode->SetSubNodes(pFirst, pOper, pArg); } - m_aNodeStack.push_front(std::unique_ptr<SmStructureNode>(pSNode)); + pFirst = pSNode; } + m_aNodeStack.emplace_front(pFirst); } SmNode *SmParser::DoSubSup(TG nActiveGroup, SmNode *pGivenNode) @@ -1240,15 +1240,14 @@ SmNode *SmParser::DoOpSubSup() return pNode.release(); } -void SmParser::DoPower() +SmNode *SmParser::DoPower() { // get body for sub- supscripts on top of stack SmNode *pNode = DoTerm(false); if (m_aCurToken.nGroup == TG::Power) - m_aNodeStack.emplace_front(DoSubSup(TG::Power, pNode)); - else - m_aNodeStack.emplace_front(pNode); + return DoSubSup(TG::Power, pNode); + return pNode; } SmBlankNode *SmParser::DoBlank() @@ -1481,9 +1480,7 @@ SmNode *SmParser::DoTerm(bool bGroupNumberIdent) || TokenInGroup(TG::FontAttr)) aStack.push((bIsAttr) ? DoAttribut() : DoFontAttribut()); - DoPower(); - - SmNode *pFirstNode = popOrZero(m_aNodeStack); + SmNode *pFirstNode = DoPower(); while (!aStack.empty()) { SmStructureNode *pNode = aStack.top(); @@ -1549,9 +1546,9 @@ SmOperNode *SmParser::DoOperator() pOperator = DoSubSup(m_aCurToken.nGroup, pOperator); // get argument - DoPower(); + SmNode *pArg = DoPower(); - pSNode->SetSubNodes(pOperator, popOrZero(m_aNodeStack)); + pSNode->SetSubNodes(pOperator, pArg); return pSNode.release(); } @@ -1631,8 +1628,7 @@ SmStructureNode *SmParser::DoUnOper() case TNROOT : NextToken(); - DoPower(); - pExtra = popOrZero(m_aNodeStack); + pExtra = DoPower(); break; case TUOPER : @@ -1657,8 +1653,7 @@ SmStructureNode *SmParser::DoUnOper() } // get argument - DoPower(); - pArg = popOrZero(m_aNodeStack); + pArg = DoPower(); if (eType == TABS) { |