Add a TeX driver
[pspp] / src / output / tex-parsing.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2020 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef TEX_PARSING_H
18 #define TEX_PARSING_H
19
20
21 #include "libpspp/str.h"
22 #include "libpspp/ll.h"
23
24 /* These are the default TeX categories as defined in Chapter 7 of
25    The TeXbook ,  plus a new one: CAT_CONTROL_SEQUENCE.  */
26 enum tex_cat
27   {
28    CAT_ESCAPE = 0,
29    CAT_BEGIN_GROUP,  // 1
30    CAT_END_GROUP,    // 2
31    CAT_MATH_MODE,    // 3
32    CAT_ALIGNMENT,    // 4
33    CAT_PARAMETER,    // 5
34    CAT_SUPERSCRIPT,  // 6
35    CAT_SUBSCRIPT,    // 7
36    CAT_IGNORED,      // 8
37    CAT_EOL,          // 9
38    CAT_SPACE,        // 10
39    CAT_LETTER,       // 11
40    CAT_OTHER,        // 12
41    CAT_ACTIVE,       // 13
42    CAT_COMMENT,      // 14
43    CAT_INVALID,       // 15
44    CAT_CONTROL_SEQ,
45   };
46
47
48 struct tex_token
49 {
50   struct ll ll;
51   struct string str;
52   enum tex_cat cat;
53 };
54
55
56 /* Parse the TeX fragment STR into TeX tokens and push them
57    on to LIST. */
58 void tex_parse (const char *str, struct ll_list *list);
59
60
61 #endif //TEX_PARSING_H