1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/*
|
|
|
|
* File: math_parser.h
|
|
|
|
* Purpose: Declaration of parsing utilities for mathed
|
2002-03-21 17:42:56 +00:00
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
1999-09-27 18:44:28 +00:00
|
|
|
* Created: January 1996
|
|
|
|
* Description: Parse LaTeX2e math mode code.
|
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Version: 0.8beta.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#ifndef MATH_PARSER_H
|
|
|
|
#define MATH_PARSER_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
#include "LString.h"
|
2001-07-26 10:21:18 +00:00
|
|
|
#include "math_defs.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
class MathAtom;
|
|
|
|
class MathArray;
|
2001-06-25 00:06:33 +00:00
|
|
|
class LyXLex;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
enum MathTokenEnum
|
|
|
|
{
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2002-01-08 13:31:14 +00:00
|
|
|
LM_TK_SYM = 256,
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2001-10-19 11:25:48 +00:00
|
|
|
LM_TK_BOX,
|
|
|
|
///
|
2001-08-13 14:02:37 +00:00
|
|
|
LM_TK_CHOOSE,
|
|
|
|
///
|
2001-08-13 15:26:41 +00:00
|
|
|
LM_TK_BINOM,
|
|
|
|
///
|
2001-08-17 17:50:00 +00:00
|
|
|
LM_TK_ATOP,
|
|
|
|
///
|
2001-08-13 15:26:41 +00:00
|
|
|
LM_TK_OVER,
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
LM_TK_FRAC,
|
|
|
|
///
|
|
|
|
LM_TK_SQRT,
|
|
|
|
///
|
2001-08-13 14:02:37 +00:00
|
|
|
LM_TK_ROOT,
|
|
|
|
///
|
2001-10-18 13:21:21 +00:00
|
|
|
LM_TK_LEFTEQN,
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
LM_TK_BEGIN,
|
|
|
|
///
|
|
|
|
LM_TK_END,
|
2001-08-10 15:32:26 +00:00
|
|
|
/// mathcal, mathrm...
|
|
|
|
LM_TK_OLDFONT,
|
|
|
|
/// cal,...
|
2001-02-16 09:25:43 +00:00
|
|
|
LM_TK_FONT,
|
|
|
|
///
|
|
|
|
LM_TK_LEFT,
|
|
|
|
///
|
|
|
|
LM_TK_RIGHT,
|
|
|
|
///
|
2001-07-13 07:55:55 +00:00
|
|
|
LM_TK_DECORATION,
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
|
|
|
LM_TK_FUNC,
|
|
|
|
///
|
|
|
|
LM_TK_FUNCLIM,
|
|
|
|
///
|
2001-08-31 21:15:57 +00:00
|
|
|
LM_TK_CMR,
|
2001-08-09 15:19:31 +00:00
|
|
|
///
|
2001-08-30 22:42:26 +00:00
|
|
|
LM_TK_CMSY,
|
|
|
|
///
|
|
|
|
LM_TK_CMM,
|
|
|
|
///
|
|
|
|
LM_TK_CMEX,
|
|
|
|
///
|
|
|
|
LM_TK_MSA,
|
|
|
|
///
|
|
|
|
LM_TK_MSB,
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
LM_TK_LABEL,
|
|
|
|
///
|
|
|
|
LM_TK_NONUM,
|
|
|
|
///
|
|
|
|
LM_TK_SPACE,
|
|
|
|
///
|
|
|
|
LM_TK_DOTS,
|
|
|
|
///
|
|
|
|
LM_TK_LIMIT,
|
|
|
|
///
|
2001-07-26 16:56:23 +00:00
|
|
|
LM_TK_PROTECT,
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
LM_TK_STY,
|
|
|
|
///
|
|
|
|
LM_TK_SPECIAL,
|
|
|
|
///
|
2002-03-21 17:42:56 +00:00
|
|
|
LM_TK_ARGUMENT,
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
|
|
|
LM_TK_NEWCOMMAND,
|
|
|
|
///
|
2001-07-26 16:56:23 +00:00
|
|
|
LM_TK_MATH,
|
|
|
|
///
|
2001-08-16 12:34:48 +00:00
|
|
|
LM_TK_NOT,
|
|
|
|
///
|
2002-02-01 10:33:06 +00:00
|
|
|
LM_TK_UNDERSET,
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
LM_TK_STACK
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
1999-12-13 21:59:26 +00:00
|
|
|
struct latexkeys {
|
2002-01-08 11:03:34 +00:00
|
|
|
/// name of the macro or primitive
|
2001-08-30 22:42:26 +00:00
|
|
|
string name;
|
2002-01-08 11:03:34 +00:00
|
|
|
/// one of the categories above
|
|
|
|
MathTokenEnum token;
|
|
|
|
/// an id within a category if needed (only for spaces?)
|
2001-06-27 14:10:35 +00:00
|
|
|
unsigned int id;
|
2002-01-08 11:03:34 +00:00
|
|
|
/// which font to use (optional)
|
|
|
|
unsigned int latex_font_id;
|
|
|
|
/// operator/...
|
2001-11-09 18:02:20 +00:00
|
|
|
string type;
|
2002-01-08 11:03:34 +00:00
|
|
|
/// how is this called as XML entity?
|
2001-11-09 18:55:03 +00:00
|
|
|
string xmlname;
|
1999-12-13 21:59:26 +00:00
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2002-01-08 11:03:34 +00:00
|
|
|
/// check whether this is a well-known (La)TeX macro or primitive
|
2001-02-16 09:25:43 +00:00
|
|
|
latexkeys const * in_word_set(string const & str);
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2002-01-08 11:03:34 +00:00
|
|
|
/// parse formula from a string
|
2001-10-12 12:02:49 +00:00
|
|
|
bool mathed_parse_normal(MathAtom &, string const &);
|
2002-01-08 11:03:34 +00:00
|
|
|
/// ... a stream
|
2001-10-12 12:02:49 +00:00
|
|
|
bool mathed_parse_normal(MathAtom &, std::istream &);
|
2002-01-08 11:03:34 +00:00
|
|
|
/// ... the LyX lexxer
|
2001-10-12 12:02:49 +00:00
|
|
|
bool mathed_parse_normal(MathAtom &, LyXLex &);
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2002-01-08 11:03:34 +00:00
|
|
|
/// parse a macro definition from a string, enter it into the macro table
|
2002-02-01 17:01:30 +00:00
|
|
|
bool mathed_parse_macro(string &, string const &);
|
2002-01-08 11:03:34 +00:00
|
|
|
/// ... a stream
|
2002-02-01 17:01:30 +00:00
|
|
|
bool mathed_parse_macro(string &, std::istream &);
|
2002-01-08 11:03:34 +00:00
|
|
|
/// ... the LyX lexxer
|
2002-02-01 17:01:30 +00:00
|
|
|
bool mathed_parse_macro(string &, LyXLex &);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2002-01-08 11:03:34 +00:00
|
|
|
/// 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 &);
|
2001-10-18 13:21:21 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|