[Libreoffice-commits] core.git: starmath/inc starmath/source

Takeshi Abe tabe at fixedpoint.jp
Wed Mar 22 18:04:19 UTC 2017


 starmath/inc/parse.hxx    |    2 +-
 starmath/source/parse.cxx |   35 +++++++++++++++--------------------
 2 files changed, 16 insertions(+), 21 deletions(-)

New commits:
commit a69632cc1fdc931adcab4751607f3dd79b8cf771
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Thu Mar 23 00:16:57 2017 +0900

    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 at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index 6c3e7dbe7a78..d158c3995151 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -69,7 +69,7 @@ class SmParser
     void    DoProduct();
     SmNode *DoSubSup(TG nActiveGroup, SmNode *pGivenNode);
     SmNode *DoOpSubSup();
-    void    DoPower();
+    SmNode *DoPower();
     SmBlankNode *DoBlank();
     SmNode *DoTerm(bool bGroupNumberIdent);
     SmNode *DoEscape();
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)
     {


More information about the Libreoffice-commits mailing list