]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_parser.h
enable direct input of #1...#9; some whitespace changes
[lyx.git] / src / mathed / math_parser.h
index a99966423097732a5e257aa281c85de3919ab080..d641de67f4937bfa8c7357a88c0a97b172ddc556 100644 (file)
  *   the GNU General Public Licence version 2 or later.
  */
 
-#ifndef MATH_PARSER
-#define MATH_PARSER
+#ifndef MATH_PARSER_H
+#define MATH_PARSER_H
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
 #include "LString.h"
+#include "math_defs.h"
 
-#include "symbol_def.h"
-
-///
-#define LM_TK_OPEN '{'
-///
-#define LM_TK_CLOSE '}'
+class MathAtom;
+class MathArray;
+class LyXLex;
 
 ///
 enum MathTokenEnum
 {
-    ///
-    LM_TK_BOP = 256,
-    ///
-    LM_TK_ALPHA,
-    ///
-    LM_TK_STR,
-    ///
-    LM_TK_SYM,
-    ///
-    LM_TK_FRAC,
-    ///
-    LM_TK_SQRT,
-    ///
-    LM_TK_BEGIN,
-    ///
-    LM_TK_END,
-    ///
-    LM_TK_NEWLINE,
-    ///
-    LM_TK_UNDEF,
-    ///
-    LM_TK_FONT,
-    ///
-    LM_TK_LEFT,
-    ///
-    LM_TK_RIGHT,
-    ///
-    LM_TK_ACCENT,
-    ///
-    LM_TK_WIDE,
-    ///
-    LM_TK_FUNC,
-    ///
-    LM_TK_FUNCLIM,
-    ///
-    LM_TK_BIGSYM,
-    ///
-    LM_TK_LABEL,
-    ///
-    LM_TK_NONUM,
-    ///
-    LM_TK_SPACE,
-    ///
-    LM_TK_DOTS,
-    ///
-    LM_TK_LIMIT,
-    ///
-    LM_TK_STY,
-    ///
-    LM_TK_PMOD,
-    ///
-    LM_TK_BMOD,
-    ///
-    LM_TK_MACRO,
-    ///
-    LM_TK_SPECIAL,
-    ///
-    LM_TK_ARGUMENT, 
-    ///
-    LM_TK_NEWCOMMAND,
-    ///
-    LM_TK_STACK
+       ///
+       LM_TK_SYM = 256,
+       ///
+       LM_TK_BOX,
+       ///
+       LM_TK_CHOOSE,
+       ///
+       LM_TK_BINOM,
+       ///
+       LM_TK_ATOP,
+       ///
+       LM_TK_OVER,
+       ///
+       LM_TK_FRAC,
+       ///
+       LM_TK_SQRT,
+       ///
+       LM_TK_ROOT,
+       ///
+       LM_TK_LEFTEQN,
+       ///
+       LM_TK_BEGIN,
+       ///
+       LM_TK_END,
+       /// mathcal, mathrm...
+       LM_TK_OLDFONT,
+       /// cal,...
+       LM_TK_FONT,
+       ///
+       LM_TK_LEFT,
+       ///
+       LM_TK_RIGHT,
+       ///
+       LM_TK_DECORATION,
+       ///
+       LM_TK_FUNC,
+       ///
+       LM_TK_FUNCLIM,
+       ///
+       LM_TK_CMR,
+       ///
+       LM_TK_CMSY,
+       ///
+       LM_TK_CMM,
+       ///
+       LM_TK_CMEX,
+       ///
+       LM_TK_MSA,
+       ///
+       LM_TK_MSB,
+       ///
+       LM_TK_LABEL,
+       ///
+       LM_TK_NONUM,
+       ///
+       LM_TK_SPACE,
+       ///
+       LM_TK_DOTS,
+       ///
+       LM_TK_LIMIT,
+       ///
+       LM_TK_PROTECT,
+       ///
+       LM_TK_STY,
+       ///
+       LM_TK_SPECIAL,
+       ///
+       LM_TK_ARGUMENT, 
+       ///
+       LM_TK_NEWCOMMAND,
+       ///
+       LM_TK_MATH,
+       ///
+       LM_TK_NOT,
+       ///
+       LM_TK_KERN,
+       ///
+       LM_TK_STACK
 };
 
 
 ///
 struct latexkeys {
-    ///
-    char const * name;
-    ///
-    short token;
-    ///
-    int id;
+       /// name of the macro or primitive
+       string name;
+       /// one of the categories above
+       MathTokenEnum token;
+       /// an id within a category if needed (only for spaces?)
+       unsigned int id;
+       /// which font to use (optional)
+       unsigned int latex_font_id;
+       /// operator/...
+       string type;
+       /// how is this called as XML entity?
+       string xmlname;
 };
 
 
-///
-latexkeys *
-in_word_set (register char const * str, register int len);
+/// check whether this is a well-known (La)TeX macro or primitive
+latexkeys const * in_word_set(string const & str);
 
-///
-latexkeys * in_word_set(string const & str);
+/// parse formula from a string
+bool mathed_parse_normal(MathAtom &, string const &);
+/// ... a stream
+bool mathed_parse_normal(MathAtom &, std::istream &);
+/// ... the LyX lexxer
+bool mathed_parse_normal(MathAtom &, LyXLex &);
 
-///
-latexkeys * lm_get_key(int index);
-
-///
-latexkeys * lm_get_key_by_id(int id, short tc = LM_TK_SYM);
-
-///
-union YYSTYPE {
-    ///
-    unsigned char c;
-    ///
-    char * s;
-    ///
-    int i;
-    ///
-    latexkeys * l;
-};
+/// parse a macro definition from a string, enter it into the macro table
+string mathed_parse_macro(string const &);
+/// ... a stream
+string mathed_parse_macro(std::istream &);
+/// ... the LyX lexxer
+string mathed_parse_macro(LyXLex &);
 
-extern YYSTYPE yylval;
+/// parse a single cell from a string
+void mathed_parse_cell(MathArray & ar, string const &);
+/// ... a stream
+void mathed_parse_cell(MathArray & ar, std::istream &);
 
 #endif