Kaydet (Commit) 51de452e authored tarafından Takeshi Abe's avatar Takeshi Abe

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/36136Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTakeshi Abe <tabe@fixedpoint.jp>
üst e1b31fbe
...@@ -33,7 +33,6 @@ class SmParser ...@@ -33,7 +33,6 @@ class SmParser
{ {
OUString m_aBufferString; OUString m_aBufferString;
SmToken m_aCurToken; SmToken m_aCurToken;
SmNodeStack m_aNodeStack;
std::vector<std::unique_ptr<SmErrorDesc>> m_aErrDescList; std::vector<std::unique_ptr<SmErrorDesc>> m_aErrDescList;
int m_nCurError; int m_nCurError;
sal_Int32 m_nBufferIndex, sal_Int32 m_nBufferIndex,
...@@ -62,7 +61,7 @@ class SmParser ...@@ -62,7 +61,7 @@ class SmParser
// grammar // grammar
SmTableNode *DoTable(); SmTableNode *DoTable();
void DoLine(); SmLineNode *DoLine();
SmNode *DoExpression(bool bUseExtraSpaces = true); SmNode *DoExpression(bool bUseExtraSpaces = true);
SmNode *DoRelation(); SmNode *DoRelation();
SmNode *DoSum(); SmNode *DoSum();
...@@ -93,8 +92,6 @@ class SmParser ...@@ -93,8 +92,6 @@ class SmParser
SmExpressionNode *DoError(SmParseError Error); SmExpressionNode *DoError(SmParseError Error);
// end of grammar // end of grammar
void Error(SmParseError Error);
public: public:
SmParser(); SmParser();
......
...@@ -942,24 +942,19 @@ void SmParser::NextToken() ...@@ -942,24 +942,19 @@ void SmParser::NextToken()
SmTableNode *SmParser::DoTable() SmTableNode *SmParser::DoTable()
{ {
DoLine(); SmNodeArray aLineArray;
aLineArray.push_back(DoLine());
while (m_aCurToken.eType == TNEWLINE) while (m_aCurToken.eType == TNEWLINE)
{ {
NextToken(); NextToken();
DoLine(); aLineArray.push_back(DoLine());
} }
if (m_aCurToken.eType != TEND) if (m_aCurToken.eType != TEND)
Error(SmParseError::UnexpectedChar); aLineArray.push_back(DoError(SmParseError::UnexpectedChar));
SmNodeArray LineArray(m_aNodeStack.size());
for (auto rIt = LineArray.rbegin(), rEnd = LineArray.rend(); rIt != rEnd; ++rIt)
{
*rIt = popOrZero(m_aNodeStack);
}
std::unique_ptr<SmTableNode> pSNode(new SmTableNode(m_aCurToken)); std::unique_ptr<SmTableNode> pSNode(new SmTableNode(m_aCurToken));
pSNode->SetSubNodes(LineArray); pSNode->SetSubNodes(aLineArray);
return pSNode.release(); return pSNode.release();
} }
...@@ -989,7 +984,7 @@ SmNode *SmParser::DoAlign(bool bUseExtraSpaces) ...@@ -989,7 +984,7 @@ SmNode *SmParser::DoAlign(bool bUseExtraSpaces)
return pNode.release(); return pNode.release();
} }
void SmParser::DoLine() SmLineNode *SmParser::DoLine()
{ {
SmNodeArray ExpressionArray; SmNodeArray ExpressionArray;
...@@ -1012,9 +1007,9 @@ void SmParser::DoLine() ...@@ -1012,9 +1007,9 @@ void SmParser::DoLine()
ExpressionArray.push_back(new SmExpressionNode(aTok)); 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); pSNode->SetSubNodes(ExpressionArray);
m_aNodeStack.push_front(std::move(pSNode)); return pSNode.release();
} }
SmNode *SmParser::DoExpression(bool bUseExtraSpaces) SmNode *SmParser::DoExpression(bool bUseExtraSpaces)
...@@ -2170,15 +2165,6 @@ SmExpressionNode *SmParser::DoError(SmParseError eError) ...@@ -2170,15 +2165,6 @@ SmExpressionNode *SmParser::DoError(SmParseError eError)
return pSNode.release(); 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 // end grammar
...@@ -2208,8 +2194,6 @@ SmTableNode *SmParser::Parse(const OUString &rBuffer) ...@@ -2208,8 +2194,6 @@ SmTableNode *SmParser::Parse(const OUString &rBuffer)
m_aErrDescList.clear(); m_aErrDescList.clear();
m_aNodeStack.clear();
NextToken(); NextToken();
return DoTable(); return DoTable();
} }
...@@ -2225,8 +2209,6 @@ SmNode *SmParser::ParseExpression(const OUString &rBuffer) ...@@ -2225,8 +2209,6 @@ SmNode *SmParser::ParseExpression(const OUString &rBuffer)
m_aErrDescList.clear(); m_aErrDescList.clear();
m_aNodeStack.clear();
NextToken(); NextToken();
return DoExpression(); return DoExpression();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment