1 /* conditional.h
2 
3    Copyright 2009 Taco Hoekwater <taco@luatex.org>
4 
5    This file is part of LuaTeX.
6 
7    LuaTeX is free software; you can redistribute it and/or modify it under
8    the terms of the GNU General Public License as published by the Free
9    Software Foundation; either version 2 of the License, or (at your
10    option) any later version.
11 
12    LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15    License for more details.
16 
17    You should have received a copy of the GNU General Public License along
18    with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
19 
20 
21 #ifndef CONDITIONAL_H
22 #  define CONDITIONAL_H
23 
24 
25 #  define unless_code 32        /* amount added for `\.{\\unless}' prefix */
26 
27 typedef enum {
28     if_char_code = 0,           /*  `\.{\\if}' */
29     if_cat_code = 1,            /*  `\.{\\ifcat}' */
30     if_int_code = 2,            /*  `\.{\\ifnum}' */
31     if_dim_code = 3,            /*  `\.{\\ifdim}' */
32     if_odd_code = 4,            /*  `\.{\\ifodd}' */
33     if_vmode_code = 5,          /*  `\.{\\ifvmode}' */
34     if_hmode_code = 6,          /*  `\.{\\ifhmode}' */
35     if_mmode_code = 7,          /*  `\.{\\ifmmode}' */
36     if_inner_code = 8,          /*  `\.{\\ifinner}' */
37     if_void_code = 9,           /*  `\.{\\ifvoid}' */
38     if_hbox_code = 10,          /*  `\.{\\ifhbox}' */
39     if_vbox_code = 11,          /*  `\.{\\ifvbox}' */
40     ifx_code = 12,              /*  `\.{\\ifx}' */
41     if_eof_code = 13,           /*  `\.{\\ifeof}' */
42     if_true_code = 14,          /*  `\.{\\iftrue}' */
43     if_false_code = 15,         /*  `\.{\\iffalse}' */
44     if_case_code = 16,          /*  `\.{\\ifcase}' */
45     if_def_code = 17,           /* `\.{\\ifdefined}' */
46     if_cs_code = 18,            /* `\.{\\ifcsname}'  */
47     if_font_char_code = 19,     /* `\.{\\iffontchar}' */
48     if_in_csname_code = 20,     /* `\.{\\ifincsname}' */
49     if_primitive_code = 21,     /*  `\.{\\ifprimitive}' */
50     if_abs_num_code = 22,       /* `\.{\\ifabsnum}' */
51     if_abs_dim_code = 23,       /* `\.{\\ifabsdim}' */
52 } if_type_codes;
53 
54 
55 
56 
57 #  define if_limit_subtype(A) subtype((A)+1)
58 #  define if_limit_type(A) type((A)+1)
59 #  define if_line_field(A) vlink((A)+1)
60 
61 typedef enum {
62     if_code = 1,                /* code for \.{\\if...} being evaluated */
63     fi_code = 2,                /* code for \.{\\fi} */
64     else_code = 3,              /* code for \.{\\else} */
65     or_code = 4,                /* code for \.{\\or} */
66 } else_type_codes;
67 
68 extern halfword cond_ptr;       /* top of the condition stack */
69 extern int if_limit;            /* upper bound on |fi_or_else| codes */
70 extern int cur_if;              /* type of conditional being worked on */
71 extern int if_line;             /* line where that conditional began */
72 extern int skip_line;           /* skipping began here */
73 
74 extern void pass_text(void);
75 extern void push_condition_stack(void);
76 extern void pop_condition_stack(void);
77 extern void change_if_limit(int l, halfword p);
78 
79 extern void conditional(void);
80 
81 #endif
82