]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.cpp
revert last patch. there's something wrong, possibly unrelated to this
[lyx.git] / src / mathed / MathParser.cpp
index c985057b997dc3686b178165fa00074e3965ec0f..1f7db010c182063042b2dc03fa3dc2a3fef08e88 100644 (file)
@@ -24,7 +24,6 @@ following hack as starting point to write some macros:
   \else
     \def\b{}\def\e{}
   \fi
-
   ...
 
   \[\begin{array}{ccc}
@@ -48,8 +47,9 @@ following hack as starting point to write some macros:
 #include "InsetMathComment.h"
 #include "InsetMathDelim.h"
 #include "InsetMathEnv.h"
+#include "InsetMathFrac.h"
 #include "InsetMathKern.h"
-#include "InsetMathMacro.h"
+#include "MathMacro.h"
 #include "InsetMathPar.h"
 #include "InsetMathRef.h"
 #include "InsetMathRoot.h"
@@ -62,28 +62,19 @@ following hack as starting point to write some macros:
 #include "MathMacroArgument.h"
 #include "MathSupport.h"
 
-#include "lyxlex.h"
-#include "debug.h"
+#include "Lexer.h"
 
+#include "support/debug.h"
 #include "support/convert.h"
+#include "support/docstream.h"
 
 #include <sstream>
 
-
-namespace lyx {
-
-using std::endl;
-using std::fill;
-
-using std::string;
-using std::ios;
-using std::istream;
-using std::ostream;
-using std::vector;
-
-
 //#define FILEDEBUG
 
+using namespace std;
+
+namespace lyx {
 
 namespace {
 
@@ -111,7 +102,7 @@ bool stared(docstring const & s)
  * environments like "equation" that have a fixed number of rows.
  */
 bool addRow(InsetMathGrid & grid, InsetMathGrid::row_type & cellrow,
-           docstring const & vskip, bool allow_pagebreak = true)
+           docstring const & vskip, bool allow_newpage_ = true)
 {
        ++cellrow;
        if (cellrow == grid.nrows()) {
@@ -128,14 +119,14 @@ bool addRow(InsetMathGrid & grid, InsetMathGrid::row_type & cellrow,
                        lyxerr << "ignoring extra row";
                        if (!vskip.empty())
                                lyxerr << " with extra space " << to_utf8(vskip);
-                       if (!allow_pagebreak)
+                       if (!allow_newpage_)
                                lyxerr << " with no page break allowed";
                        lyxerr << '.' << endl;
                        return false;
                }
        }
-       grid.vcrskip(LyXLength(to_utf8(vskip)), cellrow - 1);
-       grid.rowinfo(cellrow - 1).allow_pagebreak_ = allow_pagebreak;
+       grid.vcrskip(Length(to_utf8(vskip)), cellrow - 1);
+       grid.rowinfo(cellrow - 1).allow_newpage_ = allow_newpage_;
        return true;
 }
 
@@ -150,7 +141,7 @@ bool addCol(InsetMathGrid & grid, InsetMathGrid::col_type & cellcol)
        ++cellcol;
        if (cellcol == grid.ncols()) {
                //lyxerr << "adding column " << cellcol << endl;
-               grid.addCol(cellcol - 1);
+               grid.addCol(cellcol);
                if (cellcol == grid.ncols()) {
                        // We can't add a column to this grid, so let's
                        // append the content of this cell to the previous
@@ -242,7 +233,7 @@ enum {
        FLAG_END        = 1 << 3,  //  next \\end ends the parsing process
        FLAG_BRACK_LAST = 1 << 4,  //  next closing bracket ends the parsing
        FLAG_TEXTMODE   = 1 << 5,  //  we are in a box
-       FLAG_ITEM       = 1 << 6,  //  read a (possibly braced token)
+       FLAG_ITEM       = 1 << 6,  //  read a (possibly braced) token
        FLAG_LEAVE      = 1 << 7,  //  leave the loop at the end
        FLAG_SIMPLE     = 1 << 8,  //  next $ leaves the loop
        FLAG_EQUATION   = 1 << 9,  //  next \] leaves the loop
@@ -292,7 +283,7 @@ ostream & operator<<(ostream & os, Token const & t)
                docstring const & cs = t.cs();
                // FIXME: For some strange reason, the stream operator instanciate
                // a new Token before outputting the contents of t.cs().
-               // Because of this the line 
+               // Because of this the line
                //     os << '\\' << cs;
                // below becomes recursive.
                // In order to avoid that we return early:
@@ -314,9 +305,9 @@ public:
        typedef  InsetMath::mode_type mode_type;
 
        ///
-       Parser(LyXLex & lex);
+       Parser(Lexer & lex);
        /// Only use this for reading from .lyx file format, for the reason
-       /// see Parser::tokenize(std::istream &).
+       /// see Parser::tokenize(istream &).
        Parser(istream & is);
        ///
        Parser(docstring const & str);
@@ -324,12 +315,12 @@ public:
        ///
        bool parse(MathAtom & at);
        ///
-       void parse(MathArray & array, unsigned flags, mode_type mode);
+       void parse(MathData & array, unsigned flags, mode_type mode);
        ///
        void parse1(InsetMathGrid & grid, unsigned flags, mode_type mode,
                bool numbered);
        ///
-       MathArray parse(unsigned flags, mode_type mode);
+       MathData parse(unsigned flags, mode_type mode);
        ///
        int lineno() const { return lineno_; }
        ///
@@ -386,7 +377,7 @@ private:
 };
 
 
-Parser::Parser(LyXLex & lexer)
+Parser::Parser(Lexer & lexer)
        : lineno_(lexer.getLineNo()), pos_(0)
 {
        tokenize(lexer.getStream());
@@ -463,8 +454,11 @@ bool Parser::good() const
 
 char_type Parser::getChar()
 {
-       if (!good())
+       if (!good()) {
                error("The input stream is not well...");
+               putback();
+               return 0;
+       }
        return tokens_[pos_++].character();
 }
 
@@ -613,7 +607,7 @@ void Parser::error(string const & msg)
 bool Parser::parse(MathAtom & at)
 {
        skipSpaces();
-       MathArray ar;
+       MathData ar;
        parse(ar, false, InsetMath::UNDECIDED_MODE);
        if (ar.size() != 1 || ar.front()->getType() == hullNone) {
                lyxerr << "unusual contents found: " << ar << endl;
@@ -666,15 +660,15 @@ docstring Parser::parse_verbatim_item()
 }
 
 
-MathArray Parser::parse(unsigned flags, mode_type mode)
+MathData Parser::parse(unsigned flags, mode_type mode)
 {
-       MathArray ar;
+       MathData ar;
        parse(ar, flags, mode);
        return ar;
 }
 
 
-void Parser::parse(MathArray & array, unsigned flags, mode_type mode)
+void Parser::parse(MathData & array, unsigned flags, mode_type mode)
 {
        InsetMathGrid grid(1, 1);
        parse1(grid, flags, mode, false);
@@ -695,7 +689,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
        int limits = 0;
        InsetMathGrid::row_type cellrow = 0;
        InsetMathGrid::col_type cellcol = 0;
-       MathArray * cell = &grid.cell(grid.index(cellrow, cellcol));
+       MathData * cell = &grid.cell(grid.index(cellrow, cellcol));
 
        if (grid.asHullInset())
                grid.asHullInset()->numbered(cellrow, numbered);
@@ -746,7 +740,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
 
                if (flags & FLAG_OPTION) {
                        if (t.cat() == catOther && t.character() == '[') {
-                               MathArray ar;
+                               MathData ar;
                                parse(ar, FLAG_BRACK_LAST, mode);
                                cell->append(ar);
                        } else {
@@ -809,7 +803,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        cell->push_back(MathAtom(new InsetMathChar(t.character())));
 
                else if (t.cat() == catBegin) {
-                       MathArray ar;
+                       MathData ar;
                        parse(ar, FLAG_BRACE_LAST, mode);
                        // do not create a BraceInset if they were written by LyX
                        // this helps to keep the annoyance of  "a choose b"  to a minimum
@@ -898,65 +892,198 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                cell->back().nucleus()->lock(true);
                }
 
-               else if (t.cs() == "def" ||
-                       t.cs() == "newcommand" ||
-                       t.cs() == "renewcommand")
-               {
-                       docstring const type = t.cs();
-                       docstring name;
+               else if ((t.cs() == "global" && nextToken().cs() == "def") ||
+                        t.cs() == "def") {
+                       if (t.cs() == "global")
+                               getToken();
+                       
+                       // get name
+                       docstring name = getToken().cs();
+                       
+                       // read parameters
                        int nargs = 0;
-                       if (t.cs() == "def") {
-                               // get name
+                       docstring pars;
+                       while (good() && nextToken().cat() != catBegin) {
+                               pars += getToken().cs();
+                               ++nargs;
+                       }
+                       nargs /= 2;
+                       
+                       // read definition
+                       MathData def;
+                       parse(def, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
+                       
+                       // is a version for display attached?
+                       skipSpaces();
+                       MathData display;
+                       if (nextToken().cat() == catBegin)
+                               parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
+                       
+                       cell->push_back(MathAtom(new MathMacroTemplate(name, nargs,
+                              0, MacroTypeDef, vector<MathData>(), def, display)));
+               }
+               
+               else if (t.cs() == "newcommand" ||
+                        t.cs() == "renewcommand" ||
+                        t.cs() == "newlyxcommand") {
+                       // get name
+                       if (getToken().cat() != catBegin) {
+                               error("'{' in \\newcommand expected (1) ");
+                               return;
+                       }
+                       docstring name = getToken().cs();
+                       if (getToken().cat() != catEnd) {
+                               error("'}' in \\newcommand expected");
+                               return;
+                       }
+                               
+                       // get arity
+                       docstring const arg = getArg('[', ']');
+                       int nargs = 0;
+                       if (!arg.empty())
+                               nargs = convert<int>(arg);
+                               
+                       // optional argument given?
+                       skipSpaces();
+                       int optionals = 0;
+                       vector<MathData> optionalValues;
+                       while (nextToken().character() == '[') {
+                               getToken();
+                               optionalValues.push_back(MathData());
+                               parse(optionalValues[optionals], FLAG_BRACK_LAST, mode);
+                               ++optionals;
+                       }
+                       
+                       MathData def;
+                       parse(def, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
+                       
+                       // is a version for display attached?
+                       skipSpaces();
+                       MathData display;
+                       if (nextToken().cat() == catBegin)
+                               parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
+                       
+                       cell->push_back(MathAtom(new MathMacroTemplate(name, nargs,
+                               optionals, MacroTypeNewcommand, optionalValues, def, display)));
+                       
+               }
+               
+               else if (t.cs() == "newcommandx" ||
+                        t.cs() == "renewcommandx") {
+                       // \newcommandx{\foo}[2][usedefault, addprefix=\global,1=default]{#1,#2}
+                       // get name
+                       docstring name;
+                       if (nextToken().cat() == catBegin) {
+                               getToken();
                                name = getToken().cs();
-
-                               // read parameter
-                               docstring pars;
-                               while (good() && nextToken().cat() != catBegin) {
-                                       pars += getToken().cs();
-                                       ++nargs;
-                               }
-                               nargs /= 2;
-                               //lyxerr << "read \\def parameter list '" << pars << "'" << endl;
-
-                       } else { // t.cs() == "newcommand" || t.cs() == "renewcommand"
-
-                               if (getToken().cat() != catBegin) {
-                                       error("'{' in \\newcommand expected (1) ");
+                               if (getToken().cat() != catEnd) {
+                                       error("'}' in \\newcommandx expected");
                                        return;
                                }
-
+                       } else
                                name = getToken().cs();
-
-                               if (getToken().cat() != catEnd) {
-                                       error("'}' in \\newcommand expected");
-                                       return;
+                               
+                       // get arity
+                       docstring const arg = getArg('[', ']');
+                       if (arg.empty()) {
+                               error("[num] in \\newcommandx expected");
+                               return;
+                       }
+                       int nargs = convert<int>(arg);
+                       
+                       // get options
+                       int optionals = 0;
+                       vector<MathData> optionalValues;
+                       if (nextToken().character() == '[') {
+                               // skip '['
+                               getToken();
+                                       
+                               // handle 'opt=value' options, separated by ','.
+                               skipSpaces();
+                               while (nextToken().character() != ']' && good()) {
+                                       if (nextToken().character() >= '1'
+                                           && nextToken().character() <= '9') {
+                                               // optional value -> get parameter number
+                                               int n = getChar() - '0';
+                                               if (n > nargs) {
+                                                       error("Arity of \\newcommandx too low "
+                                                             "for given optional parameter.");
+                                                       return;
+                                               }
+                                               
+                                               // skip '='
+                                               if (getToken().character() != '=') {
+                                                       error("'=' and optional parameter value "
+                                                             "expected for \\newcommandx");
+                                                       return;
+                                               }
+                                               
+                                               // get value
+                                               int optNum = max(size_t(n), optionalValues.size());
+                                               optionalValues.resize(optNum);
+                                               optionalValues[n - 1].clear();
+                                               while (nextToken().character() != ']'
+                                                      && nextToken().character() != ',') {
+                                                       MathData data;
+                                                       parse(data, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
+                                                       optionalValues[n - 1].append(data);
+                                               }
+                                               optionals = max(n, optionals);
+                                       } else if (nextToken().cat() == catLetter) {
+                                               // we in fact ignore every non-optional
+                                               // parameter
+                                               
+                                               // get option name
+                                               docstring opt;
+                                               while (nextToken().cat() == catLetter)
+                                                       opt += getChar();
+                                       
+                                               // value?
+                                               skipSpaces();
+                                               MathData value;
+                                               if (nextToken().character() == '=') {
+                                                       getToken();
+                                                       while (nextToken().character() != ']'
+                                                               && nextToken().character() != ',')
+                                                               parse(value, FLAG_ITEM, 
+                                                                     InsetMath::UNDECIDED_MODE);
+                                               }
+                                       } else {
+                                               error("option for \\newcommandx expected");
+                                               return;
+                                       }
+                                       
+                                       // skip komma
+                                       skipSpaces();
+                                       if (nextToken().character() == ',') {
+                                               getChar();
+                                               skipSpaces();
+                                       } else if (nextToken().character() != ']') {
+                                               error("Expecting ',' or ']' in options "
+                                                     "of \\newcommandx");
+                                               return;
+                                       }
                                }
-
-                               docstring const arg = getArg('[', ']');
-                               if (!arg.empty())
-                                       nargs = convert<int>(arg);
-
+                               
+                               // skip ']'
+                               if (!good())
+                                       return;
+                               getToken();
                        }
 
-                       MathArray ar1;
-                       parse(ar1, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
-
-                       // we cannot handle recursive stuff at all
-                       //MathArray test;
-                       //test.push_back(createInsetMath(name));
-                       //if (ar1.contains(test)) {
-                       //      error("we cannot handle recursive macros at all.");
-                       //      return;
-                       //}
+                       // get definition
+                       MathData def;
+                       parse(def, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
 
                        // is a version for display attached?
                        skipSpaces();
-                       MathArray ar2;
+                       MathData display;
                        if (nextToken().cat() == catBegin)
-                               parse(ar2, FLAG_ITEM, InsetMath::MATH_MODE);
+                               parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
 
-                       cell->push_back(MathAtom(new MathMacroTemplate(name, nargs, type,
-                               ar1, ar2)));
+                       cell->push_back(MathAtom(new MathMacroTemplate(name, nargs,
+                               optionals, MacroTypeNewcommandx, optionalValues, def, 
+                               display)));
                }
 
                else if (t.cs() == "(") {
@@ -1017,12 +1144,14 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "\\") {
                        if (flags & FLAG_ALIGN)
                                return;
-                       bool added;
+                       bool added = false;
                        if (nextToken().asInput() == "*") {
                                getToken();
                                added = addRow(grid, cellrow, docstring(), false);
-                       } else
+                       } else if (good())
                                added = addRow(grid, cellrow, getArg('[', ']'));
+                       else
+                               error("missing token after \\\\");
                        if (added) {
                                cellcol = 0;
                                if (grid.asHullInset())
@@ -1036,7 +1165,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
 #if 0
                else if (t.cs() == "multicolumn") {
                        // extract column count and insert dummy cells
-                       MathArray count;
+                       MathData count;
                        parse(count, FLAG_ITEM, mode);
                        int cols = 1;
                        if (!extractNumber(count, cols)) {
@@ -1056,7 +1185,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
 
                        // read special alignment
-                       MathArray align;
+                       MathData align;
                        parse(align, FLAG_ITEM, mode);
                        //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
 
@@ -1086,7 +1215,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                }
 
                else if (t.cs() == "sqrt") {
-                       MathArray ar;
+                       MathData ar;
                        parse(ar, FLAG_OPTION, mode);
                        if (ar.size()) {
                                cell->push_back(MathAtom(new InsetMathRoot));
@@ -1098,6 +1227,33 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        }
                }
 
+               else if (t.cs() == "unit") {
+                       // Allowed formats \unit[val]{unit}
+                       MathData ar;
+                       parse(ar, FLAG_OPTION, mode);
+                       if (ar.size()) {
+                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNIT)));
+                               cell->back().nucleus()->cell(0) = ar;
+                               parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+                       } else {
+                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNIT, 1)));
+                               parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+                       }
+               }
+               else if (t.cs() == "unitfrac") {
+                       // Here allowed formats are \unitfrac[val]{num}{denom}
+                       MathData ar;
+                       parse(ar, FLAG_OPTION, mode);
+                       if (ar.size()) {
+                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC, 3)));
+                               cell->back().nucleus()->cell(2) = ar;
+                       } else {
+                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC)));
+                       }
+                       parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+                       parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+               }
+
                else if (t.cs() == "xrightarrow" || t.cs() == "xleftarrow") {
                        cell->push_back(createInsetMath(t.cs()));
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
@@ -1106,7 +1262,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
 
                else if (t.cs() == "ref" || t.cs() == "prettyref" ||
                                t.cs() == "pageref" || t.cs() == "vpageref" || t.cs() == "vref") {
-                       cell->push_back(MathAtom(new RefInset(t.cs())));
+                       cell->push_back(MathAtom(new InsetMathRef(t.cs())));
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
                        parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                }
@@ -1118,7 +1274,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        // can't handle \|
                        // FIXME: fix this in InsetMathDelim itself!
                        docstring const l = tl.cs() == "|" ? from_ascii("Vert") : tl.asString();
-                       MathArray ar;
+                       MathData ar;
                        parse(ar, FLAG_RIGHT, mode);
                        if (!good())
                                break;
@@ -1143,14 +1299,16 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (name == "array" || name == "subarray") {
                                docstring const valign = parse_verbatim_option() + 'c';
                                docstring const halign = parse_verbatim_item();
-                               cell->push_back(MathAtom(new InsetMathArray(name, (char)valign[0], halign)));
+                               cell->push_back(MathAtom(new InsetMathArray(name,
+                                       InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
                                parse2(cell->back(), FLAG_END, mode, false);
                        }
 
                        else if (name == "tabular") {
                                docstring const valign = parse_verbatim_option() + 'c';
                                docstring const halign = parse_verbatim_item();
-                               cell->push_back(MathAtom(new InsetMathTabular(name, (char)valign[0], halign)));
+                               cell->push_back(MathAtom(new InsetMathTabular(name,
+                                       InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
                                parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
                        }
 
@@ -1239,7 +1397,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                               << to_utf8(l->inset) << "'." << endl;
                                        // create generic environment inset
                                        cell->push_back(MathAtom(new InsetMathEnv(name)));
-                                       parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+                                       parse(cell->back().nucleus()->cell(0), FLAG_END, mode);
                                }
                        }
 
@@ -1249,14 +1407,12 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        << "'" << endl;
                                // create generic environment inset
                                cell->push_back(MathAtom(new InsetMathEnv(name)));
-                               parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+                               parse(cell->back().nucleus()->cell(0), FLAG_END, mode);
                        }
                }
 
                else if (t.cs() == "kern") {
-#ifdef WITH_WARNINGS
-#warning A hack...
-#endif
+                       // FIXME: A hack...
                        docstring s;
                        while (true) {
                                Token const & t = getToken();
@@ -1274,7 +1430,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "label") {
                        // FIXME: This is swallowed in inline formulas
                        docstring label = parse_verbatim_item();
-                       MathArray ar;
+                       MathData ar;
                        asArray(label, ar);
                        if (grid.asHullInset()) {
                                grid.asHullInset()->label(cellrow, label);
@@ -1284,7 +1440,9 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        }
                }
 
-               else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
+               else if (t.cs() == "choose" || t.cs() == "over"
+                               || t.cs() == "atop" || t.cs() == "brace"
+                               || t.cs() == "brack") {
                        MathAtom at = createInsetMath(t.cs());
                        at.nucleus()->cell(0) = *cell;
                        cell->clear();
@@ -1343,7 +1501,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
 
 #if 0
                else if (t.cs() == "infer") {
-                       MathArray ar;
+                       MathData ar;
                        parse(ar, FLAG_OPTION, mode);
                        cell->push_back(createInsetMath(t.cs()));
                        parse2(cell->back(), FLAG_ITEM, mode, false);
@@ -1427,7 +1585,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                //lyxerr << "default creation: m2: " << m << endl;
                                InsetMath::idx_type start = 0;
                                // this fails on \bigg[...\bigg]
-                               //MathArray opt;
+                               //MathData opt;
                                //parse(opt, FLAG_OPTION, InsetMath::VERBATIM_MODE);
                                //if (opt.size()) {
                                //      start = 1;
@@ -1454,13 +1612,13 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
 } // anonymous namespace
 
 
-void mathed_parse_cell(MathArray & ar, docstring const & str)
+void mathed_parse_cell(MathData & ar, docstring const & str)
 {
        Parser(str).parse(ar, 0, InsetMath::MATH_MODE);
 }
 
 
-void mathed_parse_cell(MathArray & ar, istream & is)
+void mathed_parse_cell(MathData & ar, istream & is)
 {
        Parser(is).parse(ar, 0, InsetMath::MATH_MODE);
 }
@@ -1472,7 +1630,7 @@ bool mathed_parse_normal(MathAtom & t, docstring const & str)
 }
 
 
-bool mathed_parse_normal(MathAtom & t, LyXLex & lex)
+bool mathed_parse_normal(MathAtom & t, Lexer & lex)
 {
        return Parser(lex).parse(t);
 }