]> git.lyx.org Git - lyx.git/blob - src/mathed/MathParser.h
Substack should not be allowed to change columns
[lyx.git] / src / mathed / MathParser.h
1 // -*- C++ -*-
2 /**
3  * \file MathParser.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author André Pönitz
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef MATH_PARSER_H
14 #define MATH_PARSER_H
15
16 #include "MathParser_flags.h"
17
18 #include "support/docstring.h"
19
20
21 namespace lyx {
22
23 class Buffer;
24 class MathAtom;
25 class MathData;
26 class InsetMathGrid;
27 class Lexer;
28
29
30 ///
31 class latexkeys {
32 public:
33         ///
34         latexkeys() : hidden(false) {}
35         ///
36         char const * MathMLtype() const;
37         /// name of the macro or primitive
38         docstring name;
39         /// name of a inset that handles that macro
40         std::string inset;
41         /**
42          * The string or symbol to draw.
43          * This is a string of length 1 if \p name is a known symbol, and
44          * the corresponding font is available. In this case it is
45          * NO UCS4 STRING! The only "character" of the string simply denotes
46          * the code point of the symbol in the font. Therefore you have to
47          * be very careful if you pass \c draw to any function that takes a
48          * docstring argument.
49          * If \p name is a known symbol, but the corresponding font is not
50          * available, or if it is a function name, then \c draw contains a
51          * regular UCS4 string (actuallay \c draw == \c name) that is painted
52          * on screen.
53          */
54         docstring draw;
55         /// the same thing, but as an alternative in display mode
56         // Useful for \sum operator, for example
57         docstring dsp_draw;
58         /// operator/..., fontname e
59         docstring extra;
60         /// how is this called as HTML entity in MathML?
61         docstring htmlname;
62         /// how is this called as XML entity in MathML?
63         docstring xmlname;
64         /// required LaTeXFeatures
65         std::string required;
66         /// Should this macro be hidden from autocompletion (since it requires
67         /// user preamble code)?
68         bool hidden;
69 };
70
71
72 /// check whether this is a well-known (La)TeX macro or primitive
73 latexkeys const * in_word_set(docstring const & str);
74
75 /// parse formula from a string
76 bool mathed_parse_normal(Buffer * buf, MathAtom &, docstring const &,
77                 Parse::flags f = Parse::NORMAL);
78
79 /// parse formula from the LyX lexxer
80 bool mathed_parse_normal(Buffer * buf, MathAtom &, Lexer &,
81                 Parse::flags f = Parse::NORMAL);
82
83 /// parse formula from a string into a grid
84 bool mathed_parse_normal(InsetMathGrid &, docstring const &,
85                 Parse::flags f = Parse::NORMAL);
86
87 /// parse a single cell from a string
88 bool mathed_parse_cell(MathData & ar, docstring const &,
89                 Parse::flags f = Parse::NORMAL);
90
91 /// parse a single cell from a stream. Only use this for reading from .lyx
92 /// file format, for the reason see Parser::tokenize(std::istream &).
93 bool mathed_parse_cell(MathData & ar, std::istream &,
94                 Parse::flags f = Parse::NORMAL);
95
96 void initParser();
97
98
99 } // namespace lyx
100
101 #endif