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"
61 #include "ref_inset.h"
65 #include "support/LAssert.h"
66 #include "support/lstrings.h"
87 bool stared(string const & s)
89 string::size_type const n = s.size();
90 return n && s[n - 1] == '*';
94 // These are TeX's catcodes
96 catEscape, // 0 backslash
106 catSpace, // 10 space
107 catLetter, // 11 a-zA-Z
108 catOther, // 12 none of the above
111 catInvalid // 15 <delete>
114 CatCode theCatcode[256];
117 inline CatCode catcode(unsigned char c)
119 return theCatcode[c];
124 FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
125 FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
126 FLAG_END = 1 << 3, // next \\end ends the parsing process
127 FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing
128 FLAG_TEXTMODE = 1 << 5, // we are in a box
129 FLAG_ITEM = 1 << 6, // read a (possibly braced token)
130 FLAG_LEAVE = 1 << 7, // leave the loop at the end
131 FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
132 FLAG_EQUATION = 1 << 9, // next \] leaves the loop
133 FLAG_SIMPLE2 = 1 << 10 // next \) leaves the loop
139 fill(theCatcode, theCatcode + 256, catOther);
140 fill(theCatcode + 'a', theCatcode + 'z' + 1, catLetter);
141 fill(theCatcode + 'A', theCatcode + 'Z' + 1, catLetter);
143 theCatcode['\\'] = catEscape;
144 theCatcode['{'] = catBegin;
145 theCatcode['}'] = catEnd;
146 theCatcode['$'] = catMath;
147 theCatcode['&'] = catAlign;
148 theCatcode['\n'] = catNewline;
149 theCatcode['#'] = catParameter;
150 theCatcode['^'] = catSuper;
151 theCatcode['_'] = catSub;
152 theCatcode['
\7f'] = catIgnore;
153 theCatcode[' '] = catSpace;
154 theCatcode['\t'] = catSpace;
155 theCatcode['\r'] = catSpace;
156 theCatcode['~'] = catActive;
157 theCatcode['%'] = catComment;
163 // Helper class for parsing
169 Token() : cs_(), char_(0), cat_(catIgnore) {}
171 Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
173 Token(string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
176 string const & cs() const { return cs_; }
178 CatCode cat() const { return cat_; }
180 char character() const { return char_; }
182 string asString() const;
195 bool Token::isCR() const
197 return cs_ == "\\" || cs_ == "cr" || cs_ == "crcr";
200 string Token::asString() const
202 return cs_.size() ? cs_ : string(1, char_);
205 ostream & operator<<(ostream & os, Token const & t)
208 os << "\\" << t.cs();
210 os << "[" << t.character() << "," << t.cat() << "]";
219 Parser(LyXLex & lex);
221 Parser(istream & is);
224 bool parse_macro(string & name);
226 bool parse_normal(MathAtom & at);
228 void parse_into(MathArray & array, unsigned flags, bool mathmode);
230 int lineno() const { return lineno_; }
236 void parse_into1(MathGridInset & grid, unsigned flags, bool mathmode, bool numbered);
238 void parse_into2(MathAtom & at, unsigned flags, bool mathmode, bool numbered);
239 /// get arg delimited by 'left' and 'right'
240 string getArg(char left, char right);
244 void error(string const & msg);
245 /// dump contents to screen
250 void tokenize(istream & is);
252 void tokenize(string const & s);
254 void skipSpaceTokens(istream & is, char c);
256 void push_back(Token const & t);
260 Token const & prevToken() const;
262 Token const & nextToken() const;
264 Token const & getToken();
265 /// skips spaces if any
268 void lex(string const & s);
275 vector<Token> tokens_;
281 Parser::Parser(LyXLex & lexer)
282 : lineno_(lexer.getLineNo()), pos_(0)
284 tokenize(lexer.getStream());
289 Parser::Parser(istream & is)
290 : lineno_(0), pos_(0)
296 void Parser::push_back(Token const & t)
298 tokens_.push_back(t);
302 void Parser::pop_back()
308 Token const & Parser::prevToken() const
310 static const Token dummy;
311 return pos_ > 0 ? tokens_[pos_ - 1] : dummy;
315 Token const & Parser::nextToken() const
317 static const Token dummy;
318 return good() ? tokens_[pos_] : dummy;
322 Token const & Parser::getToken()
324 static const Token dummy;
325 //lyxerr << "looking at token " << tokens_[pos_] << " pos: " << pos_ << '\n';
326 return good() ? tokens_[pos_++] : dummy;
330 void Parser::skipSpaces()
332 while (nextToken().cat() == catSpace)
337 void Parser::putback()
343 bool Parser::good() const
345 return pos_ < tokens_.size();
349 char Parser::getChar()
352 error("The input stream is not well...");
353 return tokens_[pos_++].character();
357 string Parser::getArg(char left, char right)
367 while ((c = getChar()) != right && good())
374 void Parser::tokenize(istream & is)
376 // eat everything up to the next \end_inset or end of stream
377 // and store it in s for further tokenization
382 if (s.size() >= 10 && s.substr(s.size() - 10) == "\\end_inset") {
383 s = s.substr(0, s.size() - 10);
393 void Parser::skipSpaceTokens(istream & is, char c)
395 // skip trailing spaces
396 while (catcode(c) == catSpace || catcode(c) == catNewline)
399 //lyxerr << "putting back: " << c << "\n";
404 void Parser::tokenize(string const & buffer)
406 static bool init_done = false;
413 istringstream is(buffer.c_str(), ios::in | ios::binary);
417 //lyxerr << "reading c: " << c << "\n";
419 switch (catcode(c)) {
423 if (catcode(c) == catNewline)
424 ; //push_back(Token("par"));
426 push_back(Token(' ', catSpace));
433 while (is.get(c) && catcode(c) != catNewline)
442 error("unexpected end of input");
445 if (catcode(c) == catLetter) {
447 while (is.get(c) && catcode(c) == catLetter)
449 skipSpaceTokens(is, c);
458 push_back(Token(c, catcode(c)));
460 skipSpaceTokens(is, c);
465 lyxerr << "ignoring a char: " << int(c) << "\n";
470 push_back(Token(c, catcode(c)));
480 void Parser::dump() const
482 lyxerr << "\nTokens: ";
483 for (unsigned i = 0; i < tokens_.size(); ++i) {
486 lyxerr << tokens_[i];
488 lyxerr << " pos: " << pos_ << "\n";
492 void Parser::error(string const & msg)
494 lyxerr << "Line ~" << lineno_ << ": Math parse error: " << msg << endl;
500 bool Parser::parse_macro(string & name)
506 if (nextToken().cs() == "def") {
509 name = getToken().cs();
512 while (good() && nextToken().cat() != catBegin)
513 pars += getToken().cs();
516 error("bad stream in parse_macro\n");
520 //lyxerr << "read \\def parameter list '" << pars << "'\n";
522 error("can't handle non-empty parameter lists\n");
526 } else if (nextToken().cs() == "newcommand") {
530 if (getToken().cat() != catBegin) {
531 error("'{' in \\newcommand expected (1) \n");
535 name = getToken().cs();
537 if (getToken().cat() != catEnd) {
538 error("'}' expected\n");
542 string arg = getArg('[', ']');
544 nargs = atoi(arg.c_str());
547 lyxerr << "\\newcommand or \\def expected\n";
552 if (getToken().cat() != catBegin) {
553 lyxerr << "'{' in macro definition expected (2)\n";
558 parse_into(ar1, FLAG_BRACE_LAST, true);
560 // we cannot handle recursive stuff at all
562 test.push_back(createMathInset(name));
563 if (ar1.contains(test)) {
564 lyxerr << "we cannot handle recursive macros at all.\n";
568 // is a version for display attached?
570 parse_into(ar2, FLAG_ITEM, true);
572 MathMacroTable::create(name, nargs, ar1, ar2);
577 bool Parser::parse_normal(MathAtom & at)
580 parse_into(ar, false, false);
581 if (ar.size() != 1) {
582 lyxerr << "Unusual contents found: " << ar << endl;
583 at.reset(new MathParInset);
592 void Parser::parse_into(MathArray & array, unsigned flags, bool mathmode)
594 MathGridInset grid(1, 1);
595 parse_into1(grid, flags, mathmode, false);
596 array = grid.cell(0);
597 // remove 'unnecessary' braces:
598 if (array.size() == 1 && array.back()->asBraceInset()) {
599 lyxerr << "extra braces removed\n";
600 array = array.back()->asBraceInset()->cell(0);
605 void Parser::parse_into2(MathAtom & at, unsigned flags,
606 bool mathmode, bool numbered)
608 parse_into1(*(at->asGridInset()), flags, mathmode, numbered);
612 void Parser::parse_into1(MathGridInset & grid, unsigned flags,
613 bool mathmode, bool numbered)
616 MathGridInset::row_type cellrow = 0;
617 MathGridInset::col_type cellcol = 0;
618 MathArray * cell = &grid.cell(grid.index(cellrow, cellcol));
620 if (grid.asHullInset())
621 grid.asHullInset()->numbered(cellrow, numbered);
624 //lyxerr << "grid: " << grid << endl;
627 Token const & t = getToken();
630 lyxerr << "t: " << t << " flags: " << flags << "\n";
635 if (flags & FLAG_ITEM) {
636 if (t.cat() == catSpace)
640 if (t.cat() == catBegin) {
641 // skip the brace and collect everything to the next matching
643 flags |= FLAG_BRACE_LAST;
647 // handle only this single token, leave the loop if done
654 if (t.cat() == catMath) {
656 // we are inside some text mode thingy, so opening new math is allowed
657 Token const & n = getToken();
658 if (n.cat() == catMath) {
659 // TeX's $$...$$ syntax for displayed math
660 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
661 parse_into2(cell->back(), FLAG_SIMPLE, true, false);
662 getToken(); // skip the second '$' token
664 // simple $...$ stuff
666 cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
667 parse_into2(cell->back(), FLAG_SIMPLE, true, false);
671 else if (flags & FLAG_SIMPLE) {
672 // this is the end of the formula
677 error("something strange in the parser\n");
682 else if (t.cat() == catLetter)
683 cell->push_back(MathAtom(new MathCharInset(t.character())));
685 else if (t.cat() == catSpace && !mathmode)
686 cell->push_back(MathAtom(new MathCharInset(t.character())));
688 else if (t.cat() == catParameter) {
689 Token const & n = getToken();
690 cell->push_back(MathAtom(new MathMacroArgument(n.character()-'0')));
693 else if (t.cat() == catBegin) {
695 parse_into(ar, FLAG_BRACE_LAST, mathmode);
696 #ifndef WITH_WARNINGS
697 #warning this might be wrong in general!
699 // ignore braces around simple items
700 if ((ar.size() == 1 && !ar.front()->needsBraces()
701 || (ar.size() == 2 && !ar.front()->needsBraces()
702 && ar.back()->asScriptInset()))
703 || (ar.size() == 0 && cell->size() == 0))
707 cell->push_back(MathAtom(new MathBraceInset));
708 cell->back()->cell(0).swap(ar);
712 else if (t.cat() == catEnd) {
713 if (flags & FLAG_BRACE_LAST)
715 lyxerr << "found '}' unexpectedly, cell: '" << cell << "'\n";
717 //lyxerr << "found '}' unexpectedly\n";
719 //add(cell, '}', LM_TC_TEX);
722 else if (t.cat() == catAlign) {
724 //lyxerr << " column now " << cellcol << " max: " << grid.ncols() << "\n";
725 if (cellcol == grid.ncols()) {
726 lyxerr << "adding column " << cellcol << "\n";
727 grid.addCol(cellcol - 1);
729 cell = &grid.cell(grid.index(cellrow, cellcol));
732 else if (t.cat() == catSuper || t.cat() == catSub) {
733 bool up = (t.cat() == catSuper);
734 MathScriptInset * p = 0;
736 p = cell->back()->asScriptInset();
737 if (!p || p->has(up)) {
738 cell->push_back(MathAtom(new MathScriptInset(up)));
739 p = cell->back()->asScriptInset();
742 parse_into(p->cell(up), FLAG_ITEM, mathmode);
747 else if (t.character() == ')' && (flags & FLAG_SIMPLE2))
750 else if (t.character() == ']' && (flags & FLAG_BRACK_END))
753 else if (t.cat() == catOther)
754 cell->push_back(MathAtom(new MathCharInset(t.character())));
759 else if (t.cs() == "(") {
760 cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
761 parse_into2(cell->back(), FLAG_SIMPLE2, true, false);
764 else if (t.cs() == "[") {
765 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
766 parse_into2(cell->back(), FLAG_EQUATION, true, false);
769 else if (t.cs() == "protect")
770 // ignore \\protect, will hopefully be re-added during output
773 else if (t.cs() == "end") {
774 if (flags & FLAG_END) {
775 // eat environment name
776 //string const name =
778 // FIXME: check that we ended the correct environment
781 lyxerr << "found 'end' unexpectedly, cell: '" << cell << "'\n";
785 else if (t.cs() == ")")
788 else if (t.cs() == "]")
791 else if (t.cs() == "\\") {
792 grid.vcrskip(LyXLength(getArg('[', ']')), cellrow);
795 if (cellrow == grid.nrows())
796 grid.addRow(cellrow - 1);
797 if (grid.asHullInset())
798 grid.asHullInset()->numbered(cellrow, numbered);
799 cell = &grid.cell(grid.index(cellrow, cellcol));
803 else if (t.cs() == "multicolumn") {
804 // extract column count and insert dummy cells
806 parse_into(count, FLAG_ITEM, mathmode);
808 if (!extractNumber(count, cols)) {
809 lyxerr << " can't extract number of cells from " << count << "\n";
811 // resize the table if necessary
812 for (int i = 0; i < cols; ++i) {
814 if (cellcol == grid.ncols()) {
815 lyxerr << "adding column " << cellcol << "\n";
816 grid.addCol(cellcol - 1);
818 cell = &grid.cell(grid.index(cellrow, cellcol));
819 // mark this as dummy
820 grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = true;
822 // the last cell is the real thng, not a dummy
823 grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
825 // read special alignment
827 parse_into(align, FLAG_ITEM, mathmode);
828 //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
830 // parse the remaining contents into the "real" cell
831 parse_into(*cell, FLAG_ITEM, mathmode);
835 else if (t.cs() == "limits")
838 else if (t.cs() == "nolimits")
841 else if (t.cs() == "nonumber") {
842 if (grid.asHullInset())
843 grid.asHullInset()->numbered(cellrow, false);
846 else if (t.cs() == "number") {
847 if (grid.asHullInset())
848 grid.asHullInset()->numbered(cellrow, true);
851 else if (t.cs() == "hline") {
852 if (grid.asHullInset())
853 grid.asHullInset()->rowinfo(cellrow + 1);
856 else if (t.cs() == "sqrt") {
859 cell->push_back(MathAtom(new MathRootInset));
860 parse_into(cell->back()->cell(0), FLAG_BRACK_END, mathmode);
861 parse_into(cell->back()->cell(1), FLAG_ITEM, mathmode);
864 cell->push_back(MathAtom(new MathSqrtInset));
865 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
869 else if (t.cs() == "ref") {
870 cell->push_back(MathAtom(new RefInset));
873 parse_into(cell->back()->cell(1), FLAG_BRACK_END, mathmode);
876 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
879 else if (t.cs() == "left") {
880 string l = getToken().asString();
882 parse_into(ar, FLAG_RIGHT, mathmode);
883 string r = getToken().asString();
884 cell->push_back(MathAtom(new MathDelimInset(l, r, ar)));
887 else if (t.cs() == "right") {
888 if (flags & FLAG_RIGHT)
890 //lyxerr << "got so far: '" << cell << "'\n";
891 error("Unmatched right delimiter");
895 else if (t.cs() == "begin") {
896 string const name = getArg('{', '}');
897 if (name == "array" || name == "subarray") {
898 string const valign = getArg('[', ']') + 'c';
899 string const halign = getArg('{', '}');
900 cell->push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
901 parse_into2(cell->back(), FLAG_END, mathmode, false);
904 else if (name == "split" || name == "cases" ||
905 name == "gathered" || name == "aligned") {
906 cell->push_back(createMathInset(name));
907 parse_into2(cell->back(), FLAG_END, mathmode, false);
910 else if (name == "math") {
911 cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
912 parse_into2(cell->back(), FLAG_SIMPLE, true, true);
915 else if (name == "equation" || name == "equation*"
916 || name == "displaymath") {
917 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
918 parse_into2(cell->back(), FLAG_END, true, (name == "equation"));
921 else if (name == "eqnarray" || name == "eqnarray*") {
922 cell->push_back(MathAtom(new MathHullInset(LM_OT_EQNARRAY)));
923 parse_into2(cell->back(), FLAG_END, true, !stared(name));
926 else if (name == "align" || name == "align*") {
927 cell->push_back(MathAtom(new MathHullInset(LM_OT_ALIGN)));
928 parse_into2(cell->back(), FLAG_END, true, !stared(name));
931 else if (name == "alignat" || name == "alignat*") {
932 // ignore this for a while
934 cell->push_back(MathAtom(new MathHullInset(LM_OT_ALIGNAT)));
935 parse_into2(cell->back(), FLAG_END, true, !stared(name));
938 else if (name == "xalignat" || name == "xalignat*") {
939 // ignore this for a while
941 cell->push_back(MathAtom(new MathHullInset(LM_OT_XALIGNAT)));
942 parse_into2(cell->back(), FLAG_END, true, !stared(name));
945 else if (name == "xxalignat") {
946 // ignore this for a while
948 cell->push_back(MathAtom(new MathHullInset(LM_OT_XXALIGNAT)));
949 parse_into2(cell->back(), FLAG_END, true, !stared(name));
952 else if (name == "multline" || name == "multline*") {
953 cell->push_back(MathAtom(new MathHullInset(LM_OT_MULTLINE)));
954 parse_into2(cell->back(), FLAG_END, true, !stared(name));
957 else if (name == "gather" || name == "gather*") {
958 cell->push_back(MathAtom(new MathHullInset(LM_OT_GATHER)));
959 parse_into2(cell->back(), FLAG_END, true, !stared(name));
963 latexkeys const * l = in_word_set(name);
965 if (l->inset == "matrix") {
966 cell->push_back(createMathInset(name));
967 parse_into2(cell->back(), FLAG_END, mathmode, false);
970 lyxerr << "unknow math inset begin '" << name << "'\n";
975 else if (t.cs() == "kern") {
981 Token const & t = getToken();
987 if (isValidLength(s))
990 cell->push_back(MathAtom(new MathKernInset(s)));
993 else if (t.cs() == "label") {
994 if (grid.asHullInset())
995 grid.asHullInset()->label(cellrow, getArg('{', '}'));
998 else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
999 MathAtom p = createMathInset(t.cs());
1000 cell->swap(p->cell(0));
1001 parse_into(p->cell(1), flags, mathmode);
1006 else if (t.cs() == "substack") {
1007 cell->push_back(createMathInset(t.cs()));
1008 parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
1011 else if (t.cs() == "xymatrix") {
1012 cell->push_back(createMathInset(t.cs()));
1013 parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
1018 else if (1 && t.cs() == "ar") {
1019 MathXYArrowInset * p = new MathXYArrowInset;
1021 // try to read target
1024 parse_into(p->cell(0), FLAG_BRACK_END, mathmode);
1025 //lyxerr << "read target: " << p->cell(0) << "\n";
1030 // try to read label
1031 if (nextToken().cat() == catSuper || nextToken().cat() == catSub) {
1032 p->up_ = nextToken().cat() == catSuper;
1034 parse_into(p->cell(1), FLAG_ITEM, mathmode);
1035 //lyxerr << "read label: " << p->cell(1) << "\n";
1038 cell->push_back(MathAtom(p));
1039 //lyxerr << "read cell: " << cell << "\n";
1043 else if (t.cs().size()) {
1044 latexkeys const * l = in_word_set(t.cs());
1046 if (l->inset == "font") {
1047 lyxerr << "starting font " << t.cs() << "\n";
1048 MathAtom p = createMathInset(t.cs());
1049 bool textmode = (t.cs()[0] == 't');
1050 parse_into(p->cell(0), FLAG_ITEM, !textmode);
1052 //lyxerr << "ending font\n";
1055 else if (l->inset == "oldfont") {
1056 cell->push_back(createMathInset(t.cs()));
1057 parse_into(cell->back()->cell(0), flags, l->extra == "mathmode");
1061 else if (l->inset == "box") {
1062 // switch to text mode
1063 cell->push_back(createMathInset(t.cs()));
1064 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
1067 else if (l->inset == "style") {
1068 cell->push_back(createMathInset(t.cs()));
1069 parse_into(cell->back()->cell(0), flags, mathmode);
1074 MathAtom p = createMathInset(t.cs());
1075 for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
1076 parse_into(p->cell(i), FLAG_ITEM, l->extra == "mathmode");
1082 MathAtom p = createMathInset(t.cs());
1083 for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
1084 parse_into(p->cell(i), FLAG_ITEM, mathmode);
1090 if (flags & FLAG_LEAVE) {
1091 flags &= ~FLAG_LEAVE;
1099 } // anonymous namespace
1102 void mathed_parse_cell(MathArray & ar, string const & str)
1104 istringstream is(str.c_str());
1105 mathed_parse_cell(ar, is);
1109 void mathed_parse_cell(MathArray & ar, istream & is)
1111 Parser(is).parse_into(ar, 0, true);
1116 bool mathed_parse_macro(string & name, string const & str)
1118 istringstream is(str.c_str());
1120 return parser.parse_macro(name);
1123 bool mathed_parse_macro(string & name, istream & is)
1126 return parser.parse_macro(name);
1129 bool mathed_parse_macro(string & name, LyXLex & lex)
1132 return parser.parse_macro(name);
1137 bool mathed_parse_normal(MathAtom & t, string const & str)
1139 istringstream is(str.c_str());
1141 return parser.parse_normal(t);
1144 bool mathed_parse_normal(MathAtom & t, istream & is)
1147 return parser.parse_normal(t);
1150 bool mathed_parse_normal(MathAtom & t, LyXLex & lex)
1153 return parser.parse_normal(t);