2 \author André Pönitz (2001)
7 If someone desperately needs partial "structures" (such as a few
8 cells of an array inset or similar) (s)he could uses the
9 following hack as starting point to write some macros:
14 \def\makeamptab{\catcode`\&=4\relax}
15 \def\makeampletter{\catcode`\&=11\relax}
16 \def\b{\makeampletter\expandafter\makeamptab\bi}
36 #pragma implementation
39 #include "math_parser.h"
40 #include "math_inset.h"
41 #include "math_arrayinset.h"
42 #include "math_braceinset.h"
43 #include "math_boxinset.h"
44 #include "math_charinset.h"
45 #include "math_deliminset.h"
46 #include "math_extern.h"
47 #include "math_factory.h"
48 #include "math_kerninset.h"
49 #include "math_macro.h"
50 #include "math_macrotable.h"
51 #include "math_macrotemplate.h"
52 #include "math_hullinset.h"
53 #include "math_rootinset.h"
54 #include "math_sizeinset.h"
55 #include "math_sqrtinset.h"
56 #include "math_scriptinset.h"
57 #include "math_sqrtinset.h"
58 #include "math_support.h"
59 #include "math_xyarrowinset.h"
63 #include "support/LAssert.h"
64 #include "support/lstrings.h"
85 bool stared(string const & s)
87 string::size_type const n = s.size();
88 return n && s[n - 1] == '*';
92 // These are TeX's catcodes
94 catEscape, // 0 backslash
104 catSpace, // 10 space
105 catLetter, // 11 a-zA-Z
106 catOther, // 12 none of the above
109 catInvalid // 15 <delete>
112 CatCode theCatcode[256];
115 inline CatCode catcode(unsigned char c)
117 return theCatcode[c];
122 FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
123 FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
124 FLAG_END = 1 << 3, // next \\end ends the parsing process
125 FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing
126 FLAG_TEXTMODE = 1 << 5, // we are in a box
127 FLAG_ITEM = 1 << 6, // read a (possibly braced token)
128 FLAG_LEAVE = 1 << 7, // leave the loop at the end
129 FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
130 FLAG_EQUATION = 1 << 9, // next \] leaves the loop
131 FLAG_SIMPLE2 = 1 << 10 // next \) leaves the loop
137 fill(theCatcode, theCatcode + 256, catOther);
138 fill(theCatcode + 'a', theCatcode + 'z' + 1, catLetter);
139 fill(theCatcode + 'A', theCatcode + 'Z' + 1, catLetter);
141 theCatcode['\\'] = catEscape;
142 theCatcode['{'] = catBegin;
143 theCatcode['}'] = catEnd;
144 theCatcode['$'] = catMath;
145 theCatcode['&'] = catAlign;
146 theCatcode['\n'] = catNewline;
147 theCatcode['#'] = catParameter;
148 theCatcode['^'] = catSuper;
149 theCatcode['_'] = catSub;
150 theCatcode['
\7f'] = catIgnore;
151 theCatcode[' '] = catSpace;
152 theCatcode['\t'] = catSpace;
153 theCatcode['\r'] = catSpace;
154 theCatcode['~'] = catActive;
155 theCatcode['%'] = catComment;
161 // Helper class for parsing
167 Token() : cs_(), char_(0), cat_(catIgnore) {}
169 Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
171 Token(string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
174 string const & cs() const { return cs_; }
176 CatCode cat() const { return cat_; }
178 char character() const { return char_; }
180 string asString() const;
193 bool Token::isCR() const
195 return cs_ == "\\" || cs_ == "cr" || cs_ == "crcr";
198 string Token::asString() const
200 return cs_.size() ? cs_ : string(1, char_);
203 ostream & operator<<(ostream & os, Token const & t)
206 os << "\\" << t.cs();
208 os << "[" << t.character() << "," << t.cat() << "]";
217 Parser(LyXLex & lex);
219 Parser(istream & is);
222 bool parse_macro(string & name);
224 bool parse_normal(MathAtom & at);
226 void parse_into(MathArray & array, unsigned flags, bool mathmode);
228 int lineno() const { return lineno_; }
234 void parse_into1(MathGridInset & grid, unsigned flags, bool mathmode, bool numbered);
236 void parse_into2(MathAtom & at, unsigned flags, bool mathmode, bool numbered);
237 /// get arg delimited by 'left' and 'right'
238 string getArg(char left, char right);
242 void error(string const & msg);
243 /// dump contents to screen
248 void tokenize(istream & is);
250 void tokenize(string const & s);
252 void skipSpaceTokens(istream & is, char c);
254 void push_back(Token const & t);
258 Token const & prevToken() const;
260 Token const & nextToken() const;
262 Token const & getToken();
263 /// skips spaces if any
266 void lex(string const & s);
273 vector<Token> tokens_;
279 Parser::Parser(LyXLex & lexer)
280 : lineno_(lexer.getLineNo()), pos_(0)
282 tokenize(lexer.getStream());
287 Parser::Parser(istream & is)
288 : lineno_(0), pos_(0)
294 void Parser::push_back(Token const & t)
296 tokens_.push_back(t);
300 void Parser::pop_back()
306 Token const & Parser::prevToken() const
308 static const Token dummy;
309 return pos_ > 0 ? tokens_[pos_ - 1] : dummy;
313 Token const & Parser::nextToken() const
315 static const Token dummy;
316 return good() ? tokens_[pos_] : dummy;
320 Token const & Parser::getToken()
322 static const Token dummy;
323 //lyxerr << "looking at token " << tokens_[pos_] << " pos: " << pos_ << '\n';
324 return good() ? tokens_[pos_++] : dummy;
328 void Parser::skipSpaces()
330 while (nextToken().cat() == catSpace)
335 void Parser::putback()
341 bool Parser::good() const
343 return pos_ < tokens_.size();
347 char Parser::getChar()
350 error("The input stream is not well...");
351 return tokens_[pos_++].character();
355 string Parser::getArg(char left, char right)
365 while ((c = getChar()) != right && good())
372 void Parser::tokenize(istream & is)
374 // eat everything up to the next \end_inset or end of stream
375 // and store it in s for further tokenization
380 if (s.size() >= 10 && s.substr(s.size() - 10) == "\\end_inset") {
381 s = s.substr(0, s.size() - 10);
391 void Parser::skipSpaceTokens(istream & is, char c)
393 // skip trailing spaces
394 while (catcode(c) == catSpace || catcode(c) == catNewline)
397 //lyxerr << "putting back: " << c << "\n";
402 void Parser::tokenize(string const & buffer)
404 static bool init_done = false;
411 istringstream is(buffer.c_str(), ios::in | ios::binary);
415 //lyxerr << "reading c: " << c << "\n";
417 switch (catcode(c)) {
421 if (catcode(c) == catNewline)
422 ; //push_back(Token("par"));
424 push_back(Token(' ', catSpace));
431 while (is.get(c) && catcode(c) != catNewline)
440 error("unexpected end of input");
443 if (catcode(c) == catLetter) {
445 while (is.get(c) && catcode(c) == catLetter)
447 skipSpaceTokens(is, c);
456 push_back(Token(c, catcode(c)));
458 skipSpaceTokens(is, c);
463 lyxerr << "ignoring a char: " << int(c) << "\n";
468 push_back(Token(c, catcode(c)));
478 void Parser::dump() const
480 lyxerr << "\nTokens: ";
481 for (unsigned i = 0; i < tokens_.size(); ++i) {
484 lyxerr << tokens_[i];
486 lyxerr << " pos: " << pos_ << "\n";
490 void Parser::error(string const & msg)
492 lyxerr << "Line ~" << lineno_ << ": Math parse error: " << msg << endl;
498 bool Parser::parse_macro(string & name)
504 if (nextToken().cs() == "def") {
507 name = getToken().cs();
510 while (good() && nextToken().cat() != catBegin)
511 pars += getToken().cs();
514 error("bad stream in parse_macro\n");
518 //lyxerr << "read \\def parameter list '" << pars << "'\n";
520 error("can't handle non-empty parameter lists\n");
524 } else if (nextToken().cs() == "newcommand") {
528 if (getToken().cat() != catBegin) {
529 error("'{' in \\newcommand expected (1) \n");
533 name = getToken().cs();
535 if (getToken().cat() != catEnd) {
536 error("'}' expected\n");
540 string arg = getArg('[', ']');
542 nargs = atoi(arg.c_str());
545 lyxerr << "\\newcommand or \\def expected\n";
550 if (getToken().cat() != catBegin) {
551 lyxerr << "'{' in macro definition expected (2)\n";
556 parse_into(ar1, FLAG_BRACE_LAST, true);
558 // we cannot handle recursive stuff at all
560 test.push_back(createMathInset(name));
561 if (ar1.contains(test)) {
562 lyxerr << "we cannot handle recursive macros at all.\n";
566 // is a version for display attached?
568 parse_into(ar2, FLAG_ITEM, true);
570 MathMacroTable::create(name, nargs, ar1, ar2);
575 bool Parser::parse_normal(MathAtom & at)
578 parse_into(ar, false, false);
579 if (ar.size() != 1) {
580 lyxerr << "Unusual contents found: " << ar << endl;
581 at.reset(new MathParInset);
590 void Parser::parse_into(MathArray & array, unsigned flags, bool mathmode)
592 MathGridInset grid(1, 1);
593 parse_into1(grid, flags, mathmode, false);
594 array = grid.cell(0);
595 // remove 'unnecessary' braces:
596 if (array.size() == 1 && array.back()->asBraceInset()) {
597 lyxerr << "extra braces removed\n";
598 array = array.back()->asBraceInset()->cell(0);
603 void Parser::parse_into2(MathAtom & at, unsigned flags,
604 bool mathmode, bool numbered)
606 parse_into1(*(at->asGridInset()), flags, mathmode, numbered);
610 void Parser::parse_into1(MathGridInset & grid, unsigned flags,
611 bool mathmode, bool numbered)
614 MathGridInset::row_type cellrow = 0;
615 MathGridInset::col_type cellcol = 0;
616 MathArray * cell = &grid.cell(grid.index(cellrow, cellcol));
618 if (grid.asHullInset())
619 grid.asHullInset()->numbered(cellrow, numbered);
622 //lyxerr << "grid: " << grid << endl;
625 Token const & t = getToken();
628 lyxerr << "t: " << t << " flags: " << flags << "\n";
633 if (flags & FLAG_ITEM) {
634 if (t.cat() == catSpace)
638 if (t.cat() == catBegin) {
639 // skip the brace and collect everything to the next matching
641 flags |= FLAG_BRACE_LAST;
645 // handle only this single token, leave the loop if done
652 if (t.cat() == catMath) {
654 // we are inside some text mode thingy, so opening new math is allowed
655 Token const & n = getToken();
656 if (n.cat() == catMath) {
657 // TeX's $$...$$ syntax for displayed math
658 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
659 parse_into2(cell->back(), FLAG_SIMPLE, true, false);
660 getToken(); // skip the second '$' token
662 // simple $...$ stuff
664 cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
665 parse_into2(cell->back(), FLAG_SIMPLE, true, false);
669 else if (flags & FLAG_SIMPLE) {
670 // this is the end of the formula
675 error("something strange in the parser\n");
680 else if (t.cat() == catLetter)
681 cell->push_back(MathAtom(new MathCharInset(t.character())));
683 else if (t.cat() == catSpace && !mathmode)
684 cell->push_back(MathAtom(new MathCharInset(t.character())));
686 else if (t.cat() == catParameter) {
687 Token const & n = getToken();
688 cell->push_back(MathAtom(new MathMacroArgument(n.character()-'0')));
691 else if (t.cat() == catBegin) {
693 parse_into(ar, FLAG_BRACE_LAST, mathmode);
694 #ifndef WITH_WARNINGS
695 #warning this might be wrong in general!
697 // ignore braces around simple items
698 if ((ar.size() == 1 && !ar.front()->needsBraces()
699 || (ar.size() == 2 && !ar.front()->needsBraces()
700 && ar.back()->asScriptInset()))
701 || (ar.size() == 0 && cell->size() == 0))
705 cell->push_back(MathAtom(new MathBraceInset));
706 cell->back()->cell(0).swap(ar);
710 else if (t.cat() == catEnd) {
711 if (flags & FLAG_BRACE_LAST)
713 lyxerr << "found '}' unexpectedly, cell: '" << cell << "'\n";
715 //lyxerr << "found '}' unexpectedly\n";
717 //add(cell, '}', LM_TC_TEX);
720 else if (t.cat() == catAlign) {
722 //lyxerr << " column now " << cellcol << " max: " << grid.ncols() << "\n";
723 if (cellcol == grid.ncols()) {
724 lyxerr << "adding column " << cellcol << "\n";
725 grid.addCol(cellcol - 1);
727 cell = &grid.cell(grid.index(cellrow, cellcol));
730 else if (t.cat() == catSuper || t.cat() == catSub) {
731 bool up = (t.cat() == catSuper);
732 MathScriptInset * p = 0;
734 p = cell->back()->asScriptInset();
735 if (!p || p->has(up)) {
736 cell->push_back(MathAtom(new MathScriptInset(up)));
737 p = cell->back()->asScriptInset();
740 parse_into(p->cell(up), FLAG_ITEM, mathmode);
745 else if (t.character() == ')' && (flags & FLAG_SIMPLE2))
748 else if (t.character() == ']' && (flags & FLAG_BRACK_END))
751 else if (t.cat() == catOther)
752 cell->push_back(MathAtom(new MathCharInset(t.character())));
757 else if (t.cs() == "(") {
758 cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
759 parse_into2(cell->back(), FLAG_SIMPLE2, true, true);
762 else if (t.cs() == "[") {
763 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
764 parse_into2(cell->back(), FLAG_EQUATION, true, true);
767 else if (t.cs() == "protect")
768 // ignore \\protect, will hopefully be re-added during output
771 else if (t.cs() == "end") {
772 if (flags & FLAG_END) {
773 // eat environment name
774 //string const name =
776 // FIXME: check that we ended the correct environment
779 lyxerr << "found 'end' unexpectedly, cell: '" << cell << "'\n";
783 else if (t.cs() == ")")
786 else if (t.cs() == "]")
789 else if (t.cs() == "\\") {
790 grid.vcrskip(LyXLength(getArg('[', ']')), cellrow);
793 if (cellrow == grid.nrows())
794 grid.addRow(cellrow - 1);
795 if (grid.asHullInset())
796 grid.asHullInset()->numbered(cellrow, numbered);
797 cell = &grid.cell(grid.index(cellrow, cellcol));
801 else if (t.cs() == "multicolumn") {
802 // extract column count and insert dummy cells
804 parse_into(count, FLAG_ITEM, mathmode);
806 if (!extractNumber(count, cols)) {
807 lyxerr << " can't extract number of cells from " << count << "\n";
809 // resize the table if necessary
810 for (int i = 0; i < cols; ++i) {
812 if (cellcol == grid.ncols()) {
813 lyxerr << "adding column " << cellcol << "\n";
814 grid.addCol(cellcol - 1);
816 cell = &grid.cell(grid.index(cellrow, cellcol));
817 // mark this as dummy
818 grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = true;
820 // the last cell is the real thng, not a dummy
821 grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
823 // read special alignment
825 parse_into(align, FLAG_ITEM, mathmode);
826 //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
828 // parse the remaining contents into the "real" cell
829 parse_into(*cell, FLAG_ITEM, mathmode);
833 else if (t.cs() == "limits")
836 else if (t.cs() == "nolimits")
839 else if (t.cs() == "nonumber") {
840 if (grid.asHullInset())
841 grid.asHullInset()->numbered(cellrow, false);
844 else if (t.cs() == "number") {
845 if (grid.asHullInset())
846 grid.asHullInset()->numbered(cellrow, true);
849 else if (t.cs() == "hline") {
850 if (grid.asHullInset())
851 grid.asHullInset()->rowinfo(cellrow + 1);
854 else if (t.cs() == "sqrt") {
857 cell->push_back(MathAtom(new MathRootInset));
858 parse_into(cell->back()->cell(0), FLAG_BRACK_END, mathmode);
859 parse_into(cell->back()->cell(1), FLAG_ITEM, mathmode);
862 cell->push_back(MathAtom(new MathSqrtInset));
863 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
867 else if (t.cs() == "ref") {
868 cell->push_back(MathAtom(new RefInset));
871 parse_into(cell->back()->cell(1), FLAG_BRACK_END, mathmode);
874 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
877 else if (t.cs() == "left") {
878 string l = getToken().asString();
880 parse_into(ar, FLAG_RIGHT, mathmode);
881 string r = getToken().asString();
882 cell->push_back(MathAtom(new MathDelimInset(l, r)));
883 cell->back()->cell(0) = ar;
886 else if (t.cs() == "right") {
887 if (flags & FLAG_RIGHT)
889 //lyxerr << "got so far: '" << cell << "'\n";
890 error("Unmatched right delimiter");
894 else if (t.cs() == "begin") {
895 string const name = getArg('{', '}');
896 if (name == "array" || name == "subarray") {
897 string const valign = getArg('[', ']') + 'c';
898 string const halign = getArg('{', '}');
899 cell->push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
900 parse_into2(cell->back(), FLAG_END, mathmode, false);
903 else if (name == "split" || name == "cases" ||
904 name == "gathered" || name == "aligned") {
905 cell->push_back(createMathInset(name));
906 parse_into2(cell->back(), FLAG_END, mathmode, false);
909 else if (name == "math") {
910 cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
911 parse_into2(cell->back(), FLAG_SIMPLE, true, true);
914 else if (name == "equation" || name == "equation*"
915 || name == "displaymath") {
916 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
917 parse_into2(cell->back(), FLAG_END, true, (name == "equation"));
920 else if (name == "eqnarray" || name == "eqnarray*") {
921 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQNARRAY)));
922 parse_into2(cell->back(), FLAG_END, true, !stared(name));
925 else if (name == "align" || name == "align*") {
926 cell->push_back(MathAtom(new MathHullInset(LM_OT_ALIGN)));
927 parse_into2(cell->back(), FLAG_END, true, !stared(name));
930 else if (name == "alignat" || name == "alignat*") {
931 // ignore this for a while
933 cell->push_back(MathAtom(new MathHullInset(LM_OT_ALIGNAT)));
934 parse_into2(cell->back(), FLAG_END, true, !stared(name));
937 else if (name == "xalignat" || name == "xalignat*") {
938 // ignore this for a while
940 cell->push_back(MathAtom(new MathHullInset(LM_OT_XALIGNAT)));
941 parse_into2(cell->back(), FLAG_END, true, !stared(name));
944 else if (name == "xxalignat") {
945 // ignore this for a while
947 cell->push_back(MathAtom(new MathHullInset(LM_OT_XXALIGNAT)));
948 parse_into2(cell->back(), FLAG_END, true, !stared(name));
951 else if (name == "multline" || name == "multline*") {
952 cell->push_back(MathAtom(new MathHullInset(LM_OT_MULTLINE)));
953 parse_into2(cell->back(), FLAG_END, true, !stared(name));
956 else if (name == "gather" || name == "gather*") {
957 cell->push_back(MathAtom(new MathHullInset(LM_OT_GATHER)));
958 parse_into2(cell->back(), FLAG_END, true, !stared(name));
962 latexkeys const * l = in_word_set(name);
964 if (l->inset == "matrix") {
965 cell->push_back(createMathInset(name));
966 parse_into2(cell->back(), FLAG_END, mathmode, false);
969 lyxerr << "unknow math inset begin '" << name << "'\n";
974 else if (t.cs() == "kern") {
980 Token const & t = getToken();
986 if (isValidLength(s))
989 cell->push_back(MathAtom(new MathKernInset(s)));
992 else if (t.cs() == "label") {
993 if (grid.asHullInset())
994 grid.asHullInset()->label(cellrow, getArg('{', '}'));
997 else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
998 MathAtom p = createMathInset(t.cs());
999 cell->swap(p->cell(0));
1000 parse_into(p->cell(1), flags, mathmode);
1005 else if (t.cs() == "substack") {
1006 cell->push_back(createMathInset(t.cs()));
1007 parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
1010 else if (t.cs() == "xymatrix") {
1011 cell->push_back(createMathInset(t.cs()));
1012 parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
1017 else if (1 && t.cs() == "ar") {
1018 MathXYArrowInset * p = new MathXYArrowInset;
1020 // try to read target
1023 parse_into(p->cell(0), FLAG_BRACK_END, mathmode);
1024 //lyxerr << "read target: " << p->cell(0) << "\n";
1029 // try to read label
1030 if (nextToken().cat() == catSuper || nextToken().cat() == catSub) {
1031 p->up_ = nextToken().cat() == catSuper;
1033 parse_into(p->cell(1), FLAG_ITEM, mathmode);
1034 //lyxerr << "read label: " << p->cell(1) << "\n";
1037 cell->push_back(MathAtom(p));
1038 //lyxerr << "read cell: " << cell << "\n";
1042 else if (t.cs().size()) {
1043 latexkeys const * l = in_word_set(t.cs());
1045 if (l->inset == "font") {
1046 lyxerr << "starting font " << t.cs() << "\n";
1047 MathAtom p = createMathInset(t.cs());
1048 bool textmode = (t.cs()[0] == 't');
1049 parse_into(p->cell(0), FLAG_ITEM, !textmode);
1051 //lyxerr << "ending font\n";
1054 else if (l->inset == "oldfont") {
1055 cell->push_back(createMathInset(t.cs()));
1056 parse_into(cell->back()->cell(0), flags, l->extra == "mathmode");
1060 else if (l->inset == "box") {
1061 // switch to text mode
1062 cell->push_back(createMathInset(t.cs()));
1063 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
1066 else if (l->inset == "style") {
1067 cell->push_back(createMathInset(t.cs()));
1068 parse_into(cell->back()->cell(0), flags, mathmode);
1073 MathAtom p = createMathInset(t.cs());
1074 for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
1075 parse_into(p->cell(i), FLAG_ITEM, l->extra == "mathmode");
1081 MathAtom p = createMathInset(t.cs());
1082 for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
1083 parse_into(p->cell(i), FLAG_ITEM, mathmode);
1089 if (flags & FLAG_LEAVE) {
1090 flags &= ~FLAG_LEAVE;
1098 } // anonymous namespace
1101 void mathed_parse_cell(MathArray & ar, string const & str)
1103 istringstream is(str.c_str());
1104 mathed_parse_cell(ar, is);
1108 void mathed_parse_cell(MathArray & ar, istream & is)
1110 Parser(is).parse_into(ar, 0, true);
1115 bool mathed_parse_macro(string & name, string const & str)
1117 istringstream is(str.c_str());
1119 return parser.parse_macro(name);
1122 bool mathed_parse_macro(string & name, istream & is)
1125 return parser.parse_macro(name);
1128 bool mathed_parse_macro(string & name, LyXLex & lex)
1131 return parser.parse_macro(name);
1136 bool mathed_parse_normal(MathAtom & t, string const & str)
1138 istringstream is(str.c_str());
1140 return parser.parse_normal(t);
1143 bool mathed_parse_normal(MathAtom & t, istream & is)
1146 return parser.parse_normal(t);
1149 bool mathed_parse_normal(MathAtom & t, LyXLex & lex)
1152 return parser.parse_normal(t);