]> git.lyx.org Git - lyx.git/blob - src/mathed/math_factory.C
new parser
[lyx.git] / src / mathed / math_factory.C
1 #include <config.h>
2
3 #include "math_parser.h"
4 #include "math_bigopinset.h"
5 #include "math_binominset.h"
6 #include "math_decorationinset.h"
7 #include "math_dotsinset.h"
8 #include "math_funcinset.h"
9 #include "math_funcliminset.h"
10 #include "math_fracinset.h"
11 #include "math_macro.h"
12 #include "math_macrotable.h"
13 #include "math_noglyphinset.h"
14 #include "math_notinset.h"
15 #include "math_rootinset.h"
16 #include "math_spaceinset.h"
17 #include "math_sqrtinset.h"
18 #include "math_symbolinset.h"
19 #include "math_stackrelinset.h"
20
21
22 MathInset * createMathInset(latexkeys const * l)
23 {
24         switch (l->token) {
25                 case LM_TK_NOGLYPH:
26                 case LM_TK_NOGLYPHB:
27                         return new MathNoglyphInset(l);
28                 case LM_TK_BIGSYM:
29                         return new MathBigopInset(l);
30                 case LM_TK_FUNCLIM:
31                         return new MathFuncLimInset(l);
32                 case LM_TK_SYM: 
33                         return new MathSymbolInset(l);
34                 case LM_TK_STACK:
35                         return new MathStackrelInset;
36                 case LM_TK_BINOM:
37                 case LM_TK_CHOOSE:
38                         return new MathBinomInset;
39                 case LM_TK_OVER:
40                 case LM_TK_FRAC:
41                         return new MathFracInset;
42                 case LM_TK_NOT:
43                         return new MathNotInset;
44                 case LM_TK_SQRT:
45                         return new MathSqrtInset;
46                 case LM_TK_ROOT:
47                         return new MathRootInset;
48                 case LM_TK_DECORATION:
49                         return new MathDecorationInset(l);
50                 case LM_TK_SPACE:
51                         return new MathSpaceInset(l->id);
52                 case LM_TK_DOTS:
53                         return new MathDotsInset(l);
54         }
55         return new MathFuncInset(l->name);
56 }
57
58
59 MathInset * createMathInset(string const & s)
60 {
61         latexkeys const * l = in_word_set(s);
62         if (l) 
63                 return createMathInset(l);
64
65         if (MathMacroTable::hasTemplate(s)) 
66                 return new MathMacro(MathMacroTable::provideTemplate(s));
67
68         return new MathFuncInset(s);
69 }