diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 8ae66c7cb7..c81c2ae7b0 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -39,6 +39,7 @@ #include "font.h" #include "math_arrayinset.h" #include "math_spaceinset.h" +#include "math_macrotable.h" #include "support/lyxlib.h" #include "mathed/support.h" #include "undo_funcs.h" @@ -125,7 +126,12 @@ MathArrayInset * matrixpar(int & idx) InsetFormulaBase::InsetFormulaBase(MathInset * par) : par_(par) -{} +{ +#ifdef WITH_WARNINGS +#warning This is needed as long the math parser is not re-entrant +#endif + MathMacroTable::builtinMacros(); +} InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f) diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index c18456063f..71a3536789 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -101,7 +101,7 @@ void MathMacroTable::builtinMacros() built = true; - lyxerr[Debug::MATHED] << "Building macros" << endl; + //lyxerr[Debug::MATHED] << "Building macros" << endl; /* // This macro doesn't have arguments diff --git a/src/mathed/math_macrotable.h b/src/mathed/math_macrotable.h index 68ea049476..bb4e725984 100644 --- a/src/mathed/math_macrotable.h +++ b/src/mathed/math_macrotable.h @@ -28,9 +28,9 @@ public: static MathMacro * cloneTemplate(string const &); /// static void createTemplate(string const &, int, string const &); -private: /// static void builtinMacros(); +private: /// typedef std::map table_type; // diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 1848d74925..918f4c81d2 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -323,7 +323,7 @@ int yylex() yyis->putback(c); //lyxerr[Debug::MATHED] << "reading: text '" << yytext << "'\n"; latexkeys const * l = in_word_set(yytext); - if (!l) + if (!l) return LM_TK_UNDEF; if (l->token == LM_TK_BEGIN || l->token == LM_TK_END) { @@ -511,18 +511,19 @@ void handle_frac(MathArray & array, string const & name) void mathed_parse(MathArray & array, unsigned flags) { - int t = yylex(); - bool panic = false; static int plevel = -1; - yyvarcode = LM_TC_VAR; - - int brace = 0; - int limits = 0; ++plevel; + yyvarcode = LM_TC_VAR; + + int t = yylex(); + bool panic = false; + int brace = 0; + int limits = 0; + while (t) { - //lyxerr << "t: " << t << " flags: " << flags << " i: " << yylval.i << "\n"; - // << " plevel: " << plevel << " "; + //lyxerr << "t: " << t << " flags: " << flags << " i: " << yylval.i + // << " '" << yytext << "'\n"; //array.dump(lyxerr); //lyxerr << "\n"; @@ -753,6 +754,7 @@ void mathed_parse(MathArray & array, unsigned flags) case LM_TK_UNDEF: if (MathMacroTable::hasTemplate(yytext)) { + lyxerr << "@@@ Found macro!\n"; MathMacro * m = MathMacroTable::cloneTemplate(yytext); for (int i = 0; i < m->nargs(); ++i) mathed_parse(m->cell(i), FLAG_ITEM);