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_envinset.h"
47 #include "math_extern.h"
48 #include "math_factory.h"
49 #include "math_kerninset.h"
50 #include "math_macro.h"
51 #include "math_macrotable.h"
52 #include "math_macrotemplate.h"
53 #include "math_hullinset.h"
54 #include "math_parboxinset.h"
55 #include "math_parinset.h"
56 #include "math_rootinset.h"
57 #include "math_sizeinset.h"
58 #include "math_sqrtinset.h"
59 #include "math_scriptinset.h"
60 #include "math_sqrtinset.h"
61 #include "math_support.h"
62 #include "math_xyarrowinset.h"
64 //#include "insets/insetref.h"
65 #include "ref_inset.h"
69 #include "support/LAssert.h"
70 #include "support/lstrings.h"
91 bool stared(string const & s)
93 string::size_type const n = s.size();
94 return n && s[n - 1] == '*';
98 // These are TeX's catcodes
100 catEscape, // 0 backslash
110 catSpace, // 10 space
111 catLetter, // 11 a-zA-Z
112 catOther, // 12 none of the above
115 catInvalid // 15 <delete>
118 CatCode theCatcode[256];
121 inline CatCode catcode(unsigned char c)
123 return theCatcode[c];
128 FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
129 FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
130 FLAG_END = 1 << 3, // next \\end ends the parsing process
131 FLAG_BRACK_LAST = 1 << 4, // next closing bracket ends the parsing
132 FLAG_TEXTMODE = 1 << 5, // we are in a box
133 FLAG_ITEM = 1 << 6, // read a (possibly braced token)
134 FLAG_LEAVE = 1 << 7, // leave the loop at the end
135 FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
136 FLAG_EQUATION = 1 << 9, // next \] leaves the loop
137 FLAG_SIMPLE2 = 1 << 10, // next \) leaves the loop
138 FLAG_OPTION = 1 << 11 // read [...] style option
144 fill(theCatcode, theCatcode + 256, catOther);
145 fill(theCatcode + 'a', theCatcode + 'z' + 1, catLetter);
146 fill(theCatcode + 'A', theCatcode + 'Z' + 1, catLetter);
148 theCatcode['\\'] = catEscape;
149 theCatcode['{'] = catBegin;
150 theCatcode['}'] = catEnd;
151 theCatcode['$'] = catMath;
152 theCatcode['&'] = catAlign;
153 theCatcode['\n'] = catNewline;
154 theCatcode['#'] = catParameter;
155 theCatcode['^'] = catSuper;
156 theCatcode['_'] = catSub;
157 theCatcode['
\7f'] = catIgnore;
158 theCatcode[' '] = catSpace;
159 theCatcode['\t'] = catSpace;
160 theCatcode['\r'] = catSpace;
161 theCatcode['~'] = catActive;
162 theCatcode['%'] = catComment;
168 // Helper class for parsing
174 Token() : cs_(), char_(0), cat_(catIgnore) {}
176 Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
178 Token(string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
181 string const & cs() const { return cs_; }
183 CatCode cat() const { return cat_; }
185 char character() const { return char_; }
187 string asString() const;
200 bool Token::isCR() const
202 return cs_ == "\\" || cs_ == "cr" || cs_ == "crcr";
205 string Token::asString() const
207 return cs_.size() ? cs_ : string(1, char_);
210 ostream & operator<<(ostream & os, Token const & t)
213 os << "\\" << t.cs();
215 os << "[" << t.character() << "," << t.cat() << "]";
224 Parser(LyXLex & lex);
226 Parser(istream & is);
229 bool parse_macro(string & name);
231 bool parse_normal(MathAtom & at);
233 void parse_into(MathArray & array, unsigned flags, bool mathmode);
235 int lineno() const { return lineno_; }
241 void parse_into1(MathGridInset & grid, unsigned flags, bool mathmode, bool numbered);
243 void parse_into2(MathAtom & at, unsigned flags, bool mathmode, bool numbered);
244 /// get arg delimited by 'left' and 'right'
245 string getArg(char left, char right);
249 void error(string const & msg);
250 /// dump contents to screen
255 void tokenize(istream & is);
257 void tokenize(string const & s);
259 void skipSpaceTokens(istream & is, char c);
261 void push_back(Token const & t);
265 Token const & prevToken() const;
267 Token const & nextToken() const;
269 Token const & getToken();
270 /// skips spaces if any
273 void lex(string const & s);
280 vector<Token> tokens_;
286 Parser::Parser(LyXLex & lexer)
287 : lineno_(lexer.getLineNo()), pos_(0)
289 tokenize(lexer.getStream());
294 Parser::Parser(istream & is)
295 : lineno_(0), pos_(0)
301 void Parser::push_back(Token const & t)
303 tokens_.push_back(t);
307 void Parser::pop_back()
313 Token const & Parser::prevToken() const
315 static const Token dummy;
316 return pos_ > 0 ? tokens_[pos_ - 1] : dummy;
320 Token const & Parser::nextToken() const
322 static const Token dummy;
323 return good() ? tokens_[pos_] : dummy;
327 Token const & Parser::getToken()
329 static const Token dummy;
330 //lyxerr << "looking at token " << tokens_[pos_] << " pos: " << pos_ << '\n';
331 return good() ? tokens_[pos_++] : dummy;
335 void Parser::skipSpaces()
337 while (nextToken().cat() == catSpace)
342 void Parser::putback()
348 bool Parser::good() const
350 return pos_ < tokens_.size();
354 char Parser::getChar()
357 error("The input stream is not well...");
358 return tokens_[pos_++].character();
362 string Parser::getArg(char left, char right)
372 while ((c = getChar()) != right && good())
379 void Parser::tokenize(istream & is)
381 // eat everything up to the next \end_inset or end of stream
382 // and store it in s for further tokenization
387 if (s.size() >= 10 && s.substr(s.size() - 10) == "\\end_inset") {
388 s = s.substr(0, s.size() - 10);
398 void Parser::skipSpaceTokens(istream & is, char c)
400 // skip trailing spaces
401 while (catcode(c) == catSpace || catcode(c) == catNewline)
404 //lyxerr << "putting back: " << c << "\n";
409 void Parser::tokenize(string const & buffer)
411 static bool init_done = false;
418 istringstream is(buffer.c_str(), ios::in | ios::binary);
422 //lyxerr << "reading c: " << c << "\n";
424 switch (catcode(c)) {
428 if (catcode(c) == catNewline)
429 ; //push_back(Token("par"));
431 push_back(Token(' ', catSpace));
438 while (is.get(c) && catcode(c) != catNewline)
447 error("unexpected end of input");
450 if (catcode(c) == catLetter) {
452 while (is.get(c) && catcode(c) == catLetter)
454 skipSpaceTokens(is, c);
463 push_back(Token(c, catcode(c)));
465 skipSpaceTokens(is, c);
470 lyxerr << "ignoring a char: " << int(c) << "\n";
475 push_back(Token(c, catcode(c)));
485 void Parser::dump() const
487 lyxerr << "\nTokens: ";
488 for (unsigned i = 0; i < tokens_.size(); ++i) {
491 lyxerr << tokens_[i];
493 lyxerr << " pos: " << pos_ << "\n";
497 void Parser::error(string const & msg)
499 lyxerr << "Line ~" << lineno_ << ": Math parse error: " << msg << endl;
505 bool Parser::parse_macro(string & name)
511 if (nextToken().cs() == "def") {
514 name = getToken().cs();
517 while (good() && nextToken().cat() != catBegin)
518 pars += getToken().cs();
521 error("bad stream in parse_macro\n");
525 //lyxerr << "read \\def parameter list '" << pars << "'\n";
527 error("can't handle non-empty parameter lists\n");
531 } else if (nextToken().cs() == "newcommand") {
533 // skip the 'newcommand'
536 if (getToken().cat() != catBegin) {
537 error("'{' in \\newcommand expected (1) \n");
541 name = getToken().cs();
543 if (getToken().cat() != catEnd) {
544 error("'}' in \\newcommand expected\n");
548 string arg = getArg('[', ']');
550 nargs = atoi(arg.c_str());
553 lyxerr << "\\newcommand or \\def expected\n";
558 if (getToken().cat() != catBegin) {
559 error("'{' in macro definition expected (2)\n");
564 parse_into(ar1, FLAG_BRACE_LAST, true);
566 // we cannot handle recursive stuff at all
568 test.push_back(createMathInset(name));
569 if (ar1.contains(test)) {
570 error("we cannot handle recursive macros at all.\n");
574 // is a version for display attached?
576 parse_into(ar2, FLAG_ITEM, true);
578 MathMacroTable::create(name, nargs, ar1, ar2);
583 bool Parser::parse_normal(MathAtom & at)
587 parse_into(ar, false, false);
588 if (ar.size() != 1 || ar.front()->getType() == "none") {
589 lyxerr << "unusual contents found: " << ar << endl;
590 at.reset(new MathParInset);
594 lyxerr << "unusual contents found: " << ar << endl;
602 void Parser::parse_into(MathArray & array, unsigned flags, bool mathmode)
604 MathGridInset grid(1, 1);
605 parse_into1(grid, flags, mathmode, false);
606 array = grid.cell(0);
610 void Parser::parse_into2(MathAtom & at, unsigned flags,
611 bool mathmode, bool numbered)
613 parse_into1(*(at->asGridInset()), flags, mathmode, numbered);
617 void Parser::parse_into1(MathGridInset & grid, unsigned flags,
618 bool mathmode, bool numbered)
621 MathGridInset::row_type cellrow = 0;
622 MathGridInset::col_type cellcol = 0;
623 MathArray * cell = &grid.cell(grid.index(cellrow, cellcol));
625 if (grid.asHullInset())
626 grid.asHullInset()->numbered(cellrow, numbered);
629 //lyxerr << "grid: " << grid << endl;
632 Token const & t = getToken();
635 lyxerr << "t: " << t << " flags: " << flags << "\n";
640 if (flags & FLAG_ITEM) {
641 if (t.cat() == catSpace)
645 if (t.cat() == catBegin) {
646 // skip the brace and collect everything to the next matching
648 flags |= FLAG_BRACE_LAST;
652 // handle only this single token, leave the loop if done
657 if (flags & FLAG_OPTION) {
658 if (t.cat() == catOther && t.character() == '[') {
659 // skip the bracket and collect everything to the clsing bracket
660 flags |= FLAG_BRACK_LAST;
664 // no option found, put back token and we are done
672 if (t.cat() == catMath) {
674 // we are inside some text mode thingy, so opening new math is allowed
675 Token const & n = getToken();
676 if (n.cat() == catMath) {
677 // TeX's $$...$$ syntax for displayed math
678 cell->push_back(MathAtom(new MathHullInset("equation")));
679 parse_into2(cell->back(), FLAG_SIMPLE, true, false);
680 getToken(); // skip the second '$' token
682 // simple $...$ stuff
684 cell->push_back(MathAtom(new MathHullInset("simple")));
685 parse_into2(cell->back(), FLAG_SIMPLE, true, false);
689 else if (flags & FLAG_SIMPLE) {
690 // this is the end of the formula
695 error("something strange in the parser\n");
700 else if (t.cat() == catLetter)
701 cell->push_back(MathAtom(new MathCharInset(t.character())));
703 else if (t.cat() == catSpace && !mathmode)
704 cell->push_back(MathAtom(new MathCharInset(t.character())));
706 else if (t.cat() == catParameter) {
707 Token const & n = getToken();
708 cell->push_back(MathAtom(new MathMacroArgument(n.character()-'0')));
711 else if (t.cat() == catBegin) {
713 parse_into(ar, FLAG_BRACE_LAST, mathmode);
714 // do not create a BraceInset if they were written by LyX
715 // this helps to keep the annoyance of "a choose b" to a minimum
716 if (ar.size() == 1 && ar[0]->extraBraces())
719 cell->push_back(MathAtom(new MathBraceInset(ar)));
722 else if (t.cat() == catEnd) {
723 if (flags & FLAG_BRACE_LAST)
725 error("found '}' unexpectedly");
727 //add(cell, '}', LM_TC_TEX);
730 else if (t.cat() == catAlign) {
732 //lyxerr << " column now " << cellcol << " max: " << grid.ncols() << "\n";
733 if (cellcol == grid.ncols()) {
734 lyxerr << "adding column " << cellcol << "\n";
735 grid.addCol(cellcol - 1);
737 cell = &grid.cell(grid.index(cellrow, cellcol));
740 else if (t.cat() == catSuper || t.cat() == catSub) {
741 bool up = (t.cat() == catSuper);
742 MathScriptInset * p = 0;
744 p = cell->back()->asScriptInset();
745 if (!p || p->has(up)) {
746 cell->push_back(MathAtom(new MathScriptInset(up)));
747 p = cell->back()->asScriptInset();
750 parse_into(p->cell(up), FLAG_ITEM, mathmode);
755 else if (t.character() == ']' && (flags & FLAG_BRACK_LAST))
758 else if (t.cat() == catOther)
759 cell->push_back(MathAtom(new MathCharInset(t.character())));
764 else if (t.cs() == "(") {
765 cell->push_back(MathAtom(new MathHullInset("simple")));
766 parse_into2(cell->back(), FLAG_SIMPLE2, true, false);
769 else if (t.cs() == "[") {
770 cell->push_back(MathAtom(new MathHullInset("equation")));
771 parse_into2(cell->back(), FLAG_EQUATION, true, false);
774 else if (t.cs() == "protect")
775 // ignore \\protect, will hopefully be re-added during output
778 else if (t.cs() == "end") {
779 if (flags & FLAG_END) {
780 // eat environment name
781 //string const name =
783 // FIXME: check that we ended the correct environment
786 error("found 'end' unexpectedly");
789 else if (t.cs() == ")") {
790 if (flags & FLAG_SIMPLE2)
792 error("found '\\)' unexpectedly");
795 else if (t.cs() == "]") {
796 if (flags & FLAG_EQUATION)
798 error("found '\\]' unexpectedly");
801 else if (t.cs() == "\\") {
802 grid.vcrskip(LyXLength(getArg('[', ']')), cellrow);
805 if (cellrow == grid.nrows())
806 grid.addRow(cellrow - 1);
807 if (grid.asHullInset())
808 grid.asHullInset()->numbered(cellrow, numbered);
809 cell = &grid.cell(grid.index(cellrow, cellcol));
813 else if (t.cs() == "multicolumn") {
814 // extract column count and insert dummy cells
816 parse_into(count, FLAG_ITEM, mathmode);
818 if (!extractNumber(count, cols)) {
819 lyxerr << " can't extract number of cells from " << count << "\n";
821 // resize the table if necessary
822 for (int i = 0; i < cols; ++i) {
824 if (cellcol == grid.ncols()) {
825 lyxerr << "adding column " << cellcol << "\n";
826 grid.addCol(cellcol - 1);
828 cell = &grid.cell(grid.index(cellrow, cellcol));
829 // mark this as dummy
830 grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = true;
832 // the last cell is the real thng, not a dummy
833 grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
835 // read special alignment
837 parse_into(align, FLAG_ITEM, mathmode);
838 //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
840 // parse the remaining contents into the "real" cell
841 parse_into(*cell, FLAG_ITEM, mathmode);
845 else if (t.cs() == "limits")
848 else if (t.cs() == "nolimits")
851 else if (t.cs() == "nonumber") {
852 if (grid.asHullInset())
853 grid.asHullInset()->numbered(cellrow, false);
856 else if (t.cs() == "number") {
857 if (grid.asHullInset())
858 grid.asHullInset()->numbered(cellrow, true);
861 else if (t.cs() == "hline") {
862 if (grid.asHullInset())
863 grid.asHullInset()->rowinfo(cellrow + 1);
866 else if (t.cs() == "sqrt") {
868 parse_into(ar, FLAG_OPTION, mathmode);
870 cell->push_back(MathAtom(new MathRootInset));
871 cell->back()->cell(0) = ar;
872 parse_into(cell->back()->cell(1), FLAG_ITEM, mathmode);
874 cell->push_back(MathAtom(new MathSqrtInset));
875 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
879 else if (t.cs() == "ref") {
880 cell->push_back(MathAtom(new RefInset));
881 parse_into(cell->back()->cell(1), FLAG_OPTION, mathmode);
882 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
885 else if (t.cs() == "left") {
886 string l = getToken().asString();
888 parse_into(ar, FLAG_RIGHT, mathmode);
889 string r = getToken().asString();
890 cell->push_back(MathAtom(new MathDelimInset(l, r, ar)));
893 else if (t.cs() == "right") {
894 if (flags & FLAG_RIGHT)
896 //lyxerr << "got so far: '" << cell << "'\n";
897 error("Unmatched right delimiter");
901 else if (t.cs() == "begin") {
902 string const name = getArg('{', '}');
903 if (name == "array" || name == "subarray") {
904 string const valign = getArg('[', ']') + 'c';
905 string const halign = getArg('{', '}');
906 cell->push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
907 parse_into2(cell->back(), FLAG_END, mathmode, false);
910 else if (name == "split" || name == "cases" ||
911 name == "gathered" || name == "aligned") {
912 cell->push_back(createMathInset(name));
913 parse_into2(cell->back(), FLAG_END, mathmode, false);
916 else if (name == "math") {
917 cell->push_back(MathAtom(new MathHullInset("simple")));
918 parse_into2(cell->back(), FLAG_SIMPLE, true, true);
921 else if (name == "equation" || name == "equation*"
922 || name == "displaymath") {
923 cell->push_back(MathAtom(new MathHullInset("equation")));
924 parse_into2(cell->back(), FLAG_END, true, (name == "equation"));
927 else if (name == "eqnarray" || name == "eqnarray*") {
928 cell->push_back(MathAtom(new MathHullInset("eqnarray")));
929 parse_into2(cell->back(), FLAG_END, true, !stared(name));
932 else if (name == "align" || name == "align*") {
933 cell->push_back(MathAtom(new MathHullInset("align")));
934 parse_into2(cell->back(), FLAG_END, true, !stared(name));
937 else if (name == "alignat" || name == "alignat*") {
938 // ignore this for a while
940 cell->push_back(MathAtom(new MathHullInset("alignat")));
941 parse_into2(cell->back(), FLAG_END, true, !stared(name));
944 else if (name == "xalignat" || name == "xalignat*") {
945 // ignore this for a while
947 cell->push_back(MathAtom(new MathHullInset("xalignat")));
948 parse_into2(cell->back(), FLAG_END, true, !stared(name));
951 else if (name == "xxalignat") {
952 // ignore this for a while
954 cell->push_back(MathAtom(new MathHullInset("xxalignat")));
955 parse_into2(cell->back(), FLAG_END, true, !stared(name));
958 else if (name == "multline" || name == "multline*") {
959 cell->push_back(MathAtom(new MathHullInset("multline")));
960 parse_into2(cell->back(), FLAG_END, true, !stared(name));
963 else if (name == "gather" || name == "gather*") {
964 cell->push_back(MathAtom(new MathHullInset("gather")));
965 parse_into2(cell->back(), FLAG_END, true, !stared(name));
968 else if (latexkeys const * l = in_word_set(name)) {
969 if (l->inset == "matrix") {
970 cell->push_back(createMathInset(name));
971 parse_into2(cell->back(), FLAG_END, mathmode, false);
976 // lyxerr << "unknow math inset begin '" << name << "'\n";
977 // create generic environment inset
978 cell->push_back(MathAtom(new MathEnvInset(name)));
979 parse_into(cell->back()->cell(0), FLAG_END, mathmode);
983 else if (t.cs() == "kern") {
989 Token const & t = getToken();
995 if (isValidLength(s))
998 cell->push_back(MathAtom(new MathKernInset(s)));
1001 else if (t.cs() == "label") {
1003 parse_into(ar, FLAG_ITEM, false);
1004 if (grid.asHullInset()) {
1005 grid.asHullInset()->label(cellrow, asString(ar));
1007 cell->push_back(createMathInset(t.cs()));
1008 cell->push_back(MathAtom(new MathBraceInset(ar)));
1012 else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
1013 MathAtom p = createMathInset(t.cs());
1014 cell->swap(p->cell(0));
1015 parse_into(p->cell(1), flags, mathmode);
1020 else if (t.cs() == "substack") {
1021 cell->push_back(createMathInset(t.cs()));
1022 parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
1025 else if (t.cs() == "xymatrix") {
1026 cell->push_back(createMathInset(t.cs()));
1027 parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
1032 else if (1 && t.cs() == "ar") {
1033 MathXYArrowInset * p = new MathXYArrowInset;
1034 // try to read target
1035 parse_into(p->cell(0), FLAG_OTPTION, mathmode);
1036 // try to read label
1037 if (nextToken().cat() == catSuper || nextToken().cat() == catSub) {
1038 p->up_ = nextToken().cat() == catSuper;
1040 parse_into(p->cell(1), FLAG_ITEM, mathmode);
1041 //lyxerr << "read label: " << p->cell(1) << "\n";
1044 cell->push_back(MathAtom(p));
1045 //lyxerr << "read cell: " << cell << "\n";
1049 else if (t.cs().size()) {
1050 latexkeys const * l = in_word_set(t.cs());
1052 if (l->inset == "font") {
1053 lyxerr << "starting font " << t.cs() << "\n";
1054 MathAtom p = createMathInset(t.cs());
1055 bool textmode = (t.cs()[0] == 't');
1056 parse_into(p->cell(0), FLAG_ITEM, !textmode);
1058 //lyxerr << "ending font\n";
1061 else if (l->inset == "oldfont") {
1062 cell->push_back(createMathInset(t.cs()));
1063 parse_into(cell->back()->cell(0), flags, l->extra == "mathmode");
1067 else if (l->inset == "mbox") {
1068 // switch to text mode
1069 cell->push_back(createMathInset(t.cs()));
1070 parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
1073 else if (l->inset == "style") {
1074 cell->push_back(createMathInset(t.cs()));
1075 parse_into(cell->back()->cell(0), flags, mathmode);
1079 else if (l->inset == "parbox") {
1080 // read optional positioning and width
1081 MathArray pos, width;
1082 parse_into(pos, FLAG_OPTION, false);
1083 parse_into(width, FLAG_ITEM, false);
1084 cell->push_back(createMathInset(t.cs()));
1085 parse_into(cell->back()->cell(0), FLAG_ITEM, false);
1086 cell->back()->asParboxInset()->setPosition(asString(pos));
1087 cell->back()->asParboxInset()->setWidth(asString(width));
1091 MathAtom p = createMathInset(t.cs());
1092 for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
1093 parse_into(p->cell(i), FLAG_ITEM, l->extra == "mathmode");
1099 MathAtom p = createMathInset(t.cs());
1100 for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
1101 parse_into(p->cell(i), FLAG_ITEM, mathmode);
1107 if (flags & FLAG_LEAVE) {
1108 flags &= ~FLAG_LEAVE;
1116 } // anonymous namespace
1119 void mathed_parse_cell(MathArray & ar, string const & str)
1121 istringstream is(str.c_str());
1122 mathed_parse_cell(ar, is);
1126 void mathed_parse_cell(MathArray & ar, istream & is)
1128 Parser(is).parse_into(ar, 0, true);
1133 bool mathed_parse_macro(string & name, string const & str)
1135 istringstream is(str.c_str());
1136 return Parser(is).parse_macro(name);
1140 bool mathed_parse_macro(string & name, istream & is)
1142 return Parser(is).parse_macro(name);
1146 bool mathed_parse_macro(string & name, LyXLex & lex)
1148 return Parser(lex).parse_macro(name);
1153 bool mathed_parse_normal(MathAtom & t, string const & str)
1155 istringstream is(str.c_str());
1156 return Parser(is).parse_normal(t);
1160 bool mathed_parse_normal(MathAtom & t, istream & is)
1162 return Parser(is).parse_normal(t);
1166 bool mathed_parse_normal(MathAtom & t, LyXLex & lex)
1168 return Parser(lex).parse_normal(t);