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

Takeshi Abe tabe at fixedpoint.jp
Wed Apr 5 12:55:47 UTC 2017


 starmath/inc/parse.hxx    |    5 +----
 starmath/source/parse.cxx |   34 ++++++++--------------------------
 2 files changed, 9 insertions(+), 30 deletions(-)

New commits:
commit 51de452ef613a50637b839f088860d6c654fd91d
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Wed Apr 5 19:10:28 2017 +0900

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

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();
 }


More information about the Libreoffice-commits mailing list