int lineno() const { return lineno_; }
///
void putback();
+ /// store current position
+ void pushPosition();
+ /// restore previous position
+ void popPosition();
+ /// forget last saved position
+ void dropPosition();
private:
///
vector<Token> tokens_;
///
unsigned pos_;
+ ///
+ std::vector<unsigned> positions_;
/// Stack of active environments
vector<docstring> environments_;
///
}
+void Parser::pushPosition()
+{
+ positions_.push_back(pos_);
+}
+
+
+void Parser::popPosition()
+{
+ pos_ = positions_.back();
+ positions_.pop_back();
+}
+
+
+void Parser::dropPosition()
+{
+ positions_.pop_back();
+}
+
+
bool Parser::good() const
{
return pos_ < tokens_.size();
else if (t.cs() == "\\") {
if (flags & FLAG_ALIGN)
return success_;
- bool added = false;
+ bool starred = false;
+ docstring arg;
if (nextToken().asInput() == "*") {
getToken();
- added = addRow(grid, cellrow, docstring(), false);
- } else if (good())
- added = addRow(grid, cellrow, getArg('[', ']'));
- else
+ starred = true;
+ } else if (nextToken().asInput() == "[")
+ arg = getArg('[', ']');
+ else if (!good())
error("missing token after \\\\");
+ // skip "{}" added in front of "[" (the
+ // counterpart is in InsetMathGrid::eolString())
+ // skip spaces because formula could come from tex2lyx
+ bool skipBraces = false;
+ pushPosition();
+ if (nextToken().cat() == catBegin) {
+ getToken();
+ if (nextToken().cat() == catEnd) {
+ getToken();
+ pushPosition();
+ skipSpaces();
+ if (nextToken().asInput() == "[")
+ skipBraces = true;
+ popPosition();
+ }
+ }
+ if (skipBraces)
+ dropPosition();
+ else
+ popPosition();
+ bool const added = addRow(grid, cellrow, arg, !starred);
if (added) {
cellcol = 0;
if (grid.asHullInset())