summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-03-25 16:27:19 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2017-03-30 11:08:39 +0000
commiteeadfca73794593b07829b4ffa36c97dff59660c (patch)
treee17411177cc6e3fa7fd16ba5ef237a7fc8f1758c /starmath
parent2b789f2e9db61937763c7f69a37ee44a4913284a (diff)
starmath: Hold error nodes as subnodes of SmBracebodyNode
so that the resulting tree aligns them in a straightforward way. Change-Id: Ica86be557c5d462425f5e88930dbdec29947e5d7 Reviewed-on: https://gerrit.libreoffice.org/35882 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/parse.cxx28
1 files changed, 7 insertions, 21 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index bbfa2e0f67e7..182e2498a07d 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1962,8 +1962,7 @@ SmStructureNode *SmParser::DoBrace()
SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight)
{
auto pBody = o3tl::make_unique<SmBracebodyNode>(m_aCurToken);
- sal_uInt16 nNum = 0;
-
+ SmNodeArray aNodes;
// get body if any
if (bIsLeftRight)
{
@@ -1971,17 +1970,14 @@ SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight)
{
if (m_aCurToken.eType == TMLINE)
{
- m_aNodeStack.push_front(o3tl::make_unique<SmMathSymbolNode>(m_aCurToken));
+ aNodes.push_back(new SmMathSymbolNode(m_aCurToken));
NextToken();
- nNum++;
}
else if (m_aCurToken.eType != TRIGHT)
{
- m_aNodeStack.emplace_front(DoAlign());
- nNum++;
-
+ aNodes.push_back(DoAlign());
if (m_aCurToken.eType != TMLINE && m_aCurToken.eType != TRIGHT)
- Error(SmParseError::RightExpected);
+ aNodes.push_back(DoError(SmParseError::RightExpected));
}
} while (m_aCurToken.eType != TEND && m_aCurToken.eType != TRIGHT);
}
@@ -1991,28 +1987,18 @@ SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight)
{
if (m_aCurToken.eType == TMLINE)
{
- m_aNodeStack.push_front(o3tl::make_unique<SmMathSymbolNode>(m_aCurToken));
+ aNodes.push_back(new SmMathSymbolNode(m_aCurToken));
NextToken();
- nNum++;
}
else if (!TokenInGroup(TG::RBrace))
{
- m_aNodeStack.emplace_front(DoAlign());
- nNum++;
-
+ aNodes.push_back(DoAlign());
if (m_aCurToken.eType != TMLINE && !TokenInGroup(TG::RBrace))
- Error(SmParseError::RbraceExpected);
+ aNodes.push_back(DoError(SmParseError::RbraceExpected));
}
} while (m_aCurToken.eType != TEND && !TokenInGroup(TG::RBrace));
}
- // build argument vector in parsing order
- SmNodeArray aNodes(nNum);
- for (auto rIt = aNodes.rbegin(), rEnd = aNodes.rend(); rIt != rEnd; ++rIt)
- {
- *rIt = popOrZero(m_aNodeStack);
- }
-
pBody->SetSubNodes(aNodes);
pBody->SetScaleMode(bIsLeftRight ? SCALE_HEIGHT : SCALE_NONE);
return pBody.release();