summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-03-24 12:02:22 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2017-03-24 21:37:13 +0000
commit075585928cc77cb53cce675d13dd7d55de8aa122 (patch)
treee11acd7c277de043d0f56f7437c7a7b2bcb7fc81 /starmath
parentcfe2411ae0d2deb84408a13397659ef0389df045 (diff)
starmath: Make SmParser::DoAlign() return SmNode
instead of pushing it to the stack, for later refactoring. Change-Id: I61760fbfe95771dede62f90f82df3e9961efdcd6 Reviewed-on: https://gerrit.libreoffice.org/35609 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/parse.hxx2
-rw-r--r--starmath/source/parse.cxx29
2 files changed, 12 insertions, 19 deletions
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index 8872b8edac9a..43b84bab221c 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -76,7 +76,7 @@ class SmParser
SmOperNode *DoOperator();
SmNode *DoOper();
SmStructureNode *DoUnOper();
- void DoAlign();
+ SmNode *DoAlign();
SmStructureNode *DoFontAttribut();
SmAttributNode *DoAttribut();
SmStructureNode *DoFont();
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 4ba51289bf1b..3effa80d1ed4 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -963,7 +963,7 @@ SmTableNode *SmParser::DoTable()
return pSNode.release();
}
-void SmParser::DoAlign()
+SmNode *SmParser::DoAlign()
// parse alignment info (if any), then go on with rest of expression
{
std::unique_ptr<SmStructureNode> pSNode;
@@ -976,10 +976,7 @@ void SmParser::DoAlign()
// allow for just one align statement in 5.0
if (TokenInGroup(TG::Align))
- {
- Error(SmParseError::DoubleAlign);
- return;
- }
+ return DoError(SmParseError::DoubleAlign);
}
std::unique_ptr<SmNode> pNode(DoExpression());
@@ -987,10 +984,9 @@ void SmParser::DoAlign()
if (pSNode)
{
pSNode->SetSubNode(0, pNode.release());
- m_aNodeStack.push_front(std::move(pSNode));
+ return pSNode.release();
}
- else
- m_aNodeStack.push_front(std::move(pNode));
+ return pNode.release();
}
void SmParser::DoLine()
@@ -1001,10 +997,7 @@ void SmParser::DoLine()
// (and go on with expressions that must not have alignment
// statements in 'while' loop below. See also 'Expression()'.)
if (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE)
- {
- DoAlign();
- ExpressionArray.push_back(popOrZero(m_aNodeStack));
- }
+ ExpressionArray.push_back(DoAlign());
while (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE)
ExpressionArray.push_back(DoExpression());
@@ -1304,7 +1297,7 @@ SmNode *SmParser::DoTerm(bool bGroupNumberIdent)
return pSNode.release();
}
// go as usual
- DoAlign();
+ m_aNodeStack.emplace_front(DoAlign());
if (m_aCurToken.eType != TRGROUP)
return DoError(SmParseError::RgroupExpected);
NextToken();
@@ -1984,7 +1977,7 @@ SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight)
}
else if (m_aCurToken.eType != TRIGHT)
{
- DoAlign();
+ m_aNodeStack.emplace_front(DoAlign());
nNum++;
if (m_aCurToken.eType != TMLINE && m_aCurToken.eType != TRIGHT)
@@ -2004,7 +1997,7 @@ SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight)
}
else if (!TokenInGroup(TG::RBrace))
{
- DoAlign();
+ m_aNodeStack.emplace_front(DoAlign());
nNum++;
if (m_aCurToken.eType != TMLINE && !TokenInGroup(TG::RBrace))
@@ -2087,7 +2080,7 @@ SmStructureNode *SmParser::DoStack()
do
{
NextToken();
- DoAlign();
+ m_aNodeStack.emplace_front(DoAlign());
n++;
}
while (m_aCurToken.eType == TPOUND);
@@ -2120,7 +2113,7 @@ SmStructureNode *SmParser::DoMatrix()
do
{
NextToken();
- DoAlign();
+ m_aNodeStack.emplace_front(DoAlign());
c++;
}
while (m_aCurToken.eType == TPOUND);
@@ -2132,7 +2125,7 @@ SmStructureNode *SmParser::DoMatrix()
NextToken();
for (sal_uInt16 i = 0; i < c; i++)
{
- DoAlign();
+ m_aNodeStack.emplace_front(DoAlign());
if (i < (c - 1))
{
if (m_aCurToken.eType == TPOUND)