]> git.lyx.org Git - lyx.git/blob - src/mathed/math_factory.C
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / math_factory.C
1 #include <config.h>
2
3 #include "math_parser.h"
4 #include "math_binominset.h"
5 //#include "math_boxinset.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_kerninset.h"
12 #include "math_lefteqninset.h"
13 #include "math_macro.h"
14 #include "math_macrotable.h"
15 #include "math_macroarg.h"
16 #include "math_notinset.h"
17 #include "math_rootinset.h"
18 #include "math_spaceinset.h"
19 #include "math_specialcharinset.h"
20 #include "math_sqrtinset.h"
21 #include "math_symbolinset.h"
22 #include "math_stackrelinset.h"
23
24
25 MathAtom createMathInset(latexkeys const * l)
26 {
27         switch (l->token) {
28         case LM_TK_FUNCLIM:
29                 return MathAtom(new MathFuncLimInset(l));
30         case LM_TK_SPECIAL:
31                 return MathAtom(new MathSpecialCharInset(l->id));
32         case LM_TK_SYM:
33         case LM_TK_CMR:
34         case LM_TK_CMSY:
35         case LM_TK_CMM:
36         case LM_TK_CMEX:
37         case LM_TK_MSA:
38         case LM_TK_MSB:
39                 return MathAtom(new MathSymbolInset(l));
40         case LM_TK_STACK:
41                 return MathAtom(new MathStackrelInset);
42         case LM_TK_KERN: 
43                 return MathAtom(new MathKernInset);
44         case LM_TK_BINOM:
45         case LM_TK_CHOOSE:
46                 return MathAtom(new MathBinomInset);
47         case LM_TK_OVER:
48         case LM_TK_FRAC:
49                 return MathAtom(new MathFracInset);
50         case LM_TK_ATOP:
51                 return MathAtom(new MathFracInset(true));
52         case LM_TK_NOT:
53                 return MathAtom(new MathNotInset);
54         case LM_TK_LEFTEQN:
55                 return MathAtom(new MathLefteqnInset);
56         case LM_TK_SQRT:
57                 return MathAtom(new MathSqrtInset);
58         case LM_TK_ROOT:
59                 return MathAtom(new MathRootInset);
60         case LM_TK_DECORATION:
61                 return MathAtom(new MathDecorationInset(l->name));
62         case LM_TK_SPACE:
63                 return MathAtom(new MathSpaceInset(l->id));
64         case LM_TK_DOTS:
65                 return MathAtom(new MathDotsInset(l->name));
66         //case LM_TK_BOX:
67         //      return MathAtom(new MathBoxInset(l->name));
68         }
69         return MathAtom(new MathFuncInset(l->name));
70 }
71
72
73 MathAtom createMathInset(string const & s)
74 {
75         //cerr << "creating inset with name: '" << s << "'\n";
76         if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
77                 return MathAtom(new MathMacroArgument(s[1] - '0'));
78
79         if (s.size() == 3 && s[0] == '\\' && s[1] == '#' && s[2] >= '1' && s[2] <= '9')
80                 return MathAtom(new MathMacroArgument(s[2] - '0'));
81
82         latexkeys const * l = in_word_set(s);
83         if (l)
84                 return createMathInset(l);
85
86         if (MathMacroTable::has(s)) 
87                 return MathAtom(new MathMacro(s));
88
89         return MathAtom(new MathFuncInset(s));
90 }