#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"
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)
built = true;
- lyxerr[Debug::MATHED] << "Building macros" << endl;
+ //lyxerr[Debug::MATHED] << "Building macros" << endl;
/*
// This macro doesn't have arguments
static MathMacro * cloneTemplate(string const &);
///
static void createTemplate(string const &, int, string const &);
-private:
///
static void builtinMacros();
+private:
///
typedef std::map<string, MathMacroTemplate *> table_type;
//
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) {
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";
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);