1/* 2 See license.txt in the root of this project. 3*/ 4 5# ifndef LMT_CONDITIONAL_H 6# define LMT_CONDITIONAL_H 7 8/*tex 9 10 The next list should be in sync with |if_branch_mapping| at the top of the |c| file with the 11 same name. The next ones also go on the condition stack so we need to retain this order and 12 organization. 13 14 There is a catch here: the codes of the |if_test_cmd|, |fi_or_else_cmd| and |or_else_cmd| are 15 all in this enumeration. This has to do with the history of not always checking for the cmd 16 code in the fast skipping branches. We could change that but not now. 17 18 Well, in the end I combined |if_test_cmd|, |fi_or_else_cmd| and |or_else_cmd| because they use 19 the same chr range anyway and it also simplifies some of the testing (especially after some 20 more robust cmd/chr checking was added, and after that the |fi_or_else_cmd| and |or_else_cmd| 21 were combined. The main motivation is that we can have a more consistent \LUA\ token interface 22 end. It is debatable as we divert from the original, but we already did that by introducing 23 more conditionals, |\orelse| and the generic |\ifconditional| that also demandeed all kind of 24 adaptations. Sorry. The comments are mostly the same, including references to the older cmd 25 codes (pre 2.07 there used to be some switch/case statements in places but these were flattened). 26 27 Btw, the |\unless| prefix is kept out of this because it relates to expansion and prefixes are 28 separate anyway. It would make the code less pretty. 29 30 One reason for a split in cmd codes is performance but we didn't loose on the change. 31 32*/ 33 34typedef enum if_test_codes { 35 /*tex These are private chr codes: */ 36 37 no_if_code, /*tex We're not in a condition. */ 38 if_code, /*tex We have a condition. */ 39 40 /*tex These are public chr codes: */ 41 42 fi_code, /*tex |\fi| */ 43 else_code, /*tex |\else| */ 44 or_code, /*tex |\or| */ 45 or_else_code, /*tex |\orelse| */ 46 or_unless_code, /*tex |\orunless| */ 47 48 /*tex 49 Here come the \if... codes. Some are just there to minimize tracing and are not faster, 50 like |\ifzerodim| (we can use |\ifcase| instead but not with |\unless|). 51 */ 52 53 if_char_code, /*tex |\if| */ 54 if_cat_code, /*tex |\ifcat| */ 55 if_int_code, /*tex |\ifnum| */ 56 if_abs_int_code, /*tex |\ifabsnum| */ 57 if_zero_int_code, /*tex |\ifzeronum|*/ 58 if_interval_int_code, 59 if_posit_code, 60 if_abs_posit_code, 61 if_zero_posit_code, 62 if_interval_posit_code, 63 if_dim_code, /*tex |\ifdim| */ 64 if_abs_dim_code, /*tex |\ifabsdim| */ 65 if_zero_dim_code, /*tex |\ifzerodim| */ 66 if_interval_dim_code, 67 if_odd_code, /*tex |\ifodd| */ 68 if_vmode_code, /*tex |\ifvmode| */ 69 if_hmode_code, /*tex |\ifhmode| */ 70 if_mmode_code, /*tex |\ifmmode| */ 71 if_inner_code, /*tex |\ifinner| */ 72 if_void_code, /*tex |\ifvoid| */ 73 if_hbox_code, /*tex |\ifhbox| */ 74 if_vbox_code, /*tex |\ifvbox| */ 75 if_tok_code, /*tex |\iftok| */ 76 if_cstok_code, /*tex |\ifcstok| */ 77 if_x_code, /*tex |\ifx| */ 78 if_true_code, /*tex |\iftrue| */ 79 if_false_code, /*tex |\iffalse| */ 80 if_chk_int_code, /*tex |\ifchknum| */ 81 if_chk_integer_code, /*tex |\ifchknumber| */ 82 if_val_int_code, /*tex |\ifnumval| */ 83 if_cmp_int_code, /*tex |\ifcmpnum| */ 84 if_chk_dim_code, /*tex |\ifchkdim| */ 85 if_chk_dimension_code, /*tex |\ifchkdimension| */ 86 if_val_dim_code, /*tex |\ifdimval| */ 87 if_cmp_dim_code, /*tex |\ifcmpdim| */ 88 if_case_code, /*tex |\ifcase| */ 89 if_defined_code, /*tex |\ifdefined| */ 90 if_csname_code, /*tex |\ifcsname| */ 91 if_in_csname_code, /*tex |\ifincsname| */ 92 if_font_char_code, /*tex |\iffontchar| */ 93 if_condition_code, /*tex |\ifcondition| */ 94 if_flags_code, /*tex |\ifflags| */ 95 if_empty_code, /*tex |\ifempty| */ 96 if_relax_code, /*tex |\ifrelax| */ 97 if_boolean_code, /*tex |\ifboolean| */ 98 if_numexpression_code, /*tex |\ifnumexpression| */ 99 if_dimexpression_code, /*tex |\ifdimexpression| */ 100 if_last_named_cs_code, /*tex |\iflastnamedcs| */ 101 if_math_parameter_code, /*tex |\ifmathparameter| */ 102 if_math_style_code, /*tex |\ifmathstyle| */ 103 if_arguments_code, /*tex |\ifarguments| */ 104 if_parameters_code, /*tex |\ifparameters| */ 105 if_parameter_code, /*tex |\ifparameter| */ 106 if_has_tok_code, /*tex |\ifhastok| */ 107 if_has_toks_code, /*tex |\ifhastoks| */ 108 if_has_xtoks_code, /*tex |\ifhasxtoks| */ 109 if_has_char_code, /*tex |\ifhaschar| */ 110 if_insert_code, /*tex |\ifinsert| */ 111 if_in_alignment_code, /*tex |\ifinalignment| */ 112 // if_bitwise_and_code, /*tex |\ifbitwiseand| */ 113} if_test_codes; 114 115# define first_if_test_code fi_code 116# define last_if_test_code if_in_alignment_code 117//define last_if_test_code if_bitwise_and_code 118 119# define first_real_if_test_code if_char_code 120# define last_real_if_test_code if_in_alignment_code 121//define last_real_if_test_code if_bitwise_and_code 122 123typedef struct condition_state_info { 124 halfword cond_ptr; /*tex top of the condition stack */ 125 int cur_if; /*tex type of conditional being worked on */ 126 int cur_unless; 127 int if_step; 128 int if_limit; /*tex upper bound on |fi_or_else| codes */ 129 int if_line; /*tex line where that conditional began */ 130 halfword if_nesting; 131 int if_unless; 132 int skip_line; /*tex skipping began here */ 133 halfword chk_integer; 134 scaled chk_dimension; 135 halfword padding; 136} condition_state_info ; 137 138extern condition_state_info lmt_condition_state; 139 140extern void tex_conditional_if (halfword code, int unless); 141extern void tex_conditional_fi_or_else (void); 142extern void tex_conditional_unless (void); 143extern void tex_show_ifs (void); 144/* void tex_quit_fi (void); */ 145/* void tex_conditional_after_fi (void); */ 146 147# endif 148 |