xapian-core  2.1.0
header.h
Go to the documentation of this file.
1 #include <stdio.h>
2 #if __STDC_VERSION__ < 202311l
3 # include <stdbool.h>
4 #endif
5 
6 #define SNOWBALL_VERSION "3.1.1"
7 
8 typedef unsigned char byte;
9 typedef unsigned short symbol;
10 
11 #define MALLOC check_malloc
12 #define FREE check_free
13 
14 // Declare variable `V` of type `struct TYPE *` and dynamically allocate it.
15 // We exit on allocation failure so `V` is always non-NULL.
16 #define NEW(TYPE, V) struct TYPE * V = (struct TYPE *) MALLOC(sizeof(struct TYPE))
17 
18 // Similar to NEW() but allocates an array of N objects of type `struct TYPE *`.
19 #define NEWVEC(TYPE, V, N) struct TYPE * V = (struct TYPE *) MALLOC(sizeof(struct TYPE) * (N))
20 
21 #define SIZE(p) ((const int *)(p))[-1]
22 #define SET_SIZE(p, n) ((int *)(p))[-1] = (n)
23 #define ADD_TO_SIZE(p, n) ((int *)(p))[-1] += (n)
24 #define CAPACITY(p) ((int *)(p))[-2]
25 
26 extern symbol * create_b(int n);
27 extern void report_b(FILE * out, const symbol * p);
28 extern void lose_b(symbol * p);
29 extern symbol * reserve_b_(symbol * p, int n);
30 static inline symbol * reserve_b(symbol * p, int n) {
31  if (n > CAPACITY(p)) p = reserve_b_(p, n);
32  return p;
33 }
34 extern symbol * resize_b(symbol * p, int n);
35 static inline symbol * ensure_nul_b(symbol * p) {
36  p = reserve_b(p, SIZE(p) + 1);
37  p[SIZE(p)] = 0;
38  return p;
39 }
40 extern symbol * add_to_b(symbol * p, const symbol * q, int n);
41 extern symbol * copy_b(const symbol * p);
42 extern char * b_to_sz(const symbol * p);
44 
45 // These routines are like those above but work in byte instead of symbol.
46 
47 extern byte * create_s(int n);
48 extern byte * create_s_from_sz(const char * s);
49 extern byte * create_s_from_data(const char * s, int n);
50 
51 extern void report_s(FILE * out, const byte * p);
52 extern void lose_s(byte * p);
53 extern byte * reserve_s_(byte * p, int n);
54 static inline byte * reserve_s(byte * p, int n) {
55  if (n > CAPACITY(p)) p = reserve_s_(p, n);
56  return p;
57 }
58 extern byte * resize_s(byte * p, int n);
59 static inline byte * ensure_nul_s(byte * p) {
60  p = reserve_s(p, SIZE(p) + 1);
61  p[SIZE(p)] = 0;
62  return p;
63 }
64 extern byte * copy_s(const byte * p);
65 extern byte * add_s_to_s(byte * p, const byte * s);
66 extern byte * add_slen_to_s(byte * p, const char * s, int n);
67 extern byte * add_sz_to_s(byte * p, const char * s);
68 extern byte * add_char_to_s(byte * p, char ch);
69 // "" LIT is a trick to make compilation fail if LIT is not a string literal.
70 #define add_literal_to_s(P, LIT) add_slen_to_s(P, "" LIT, sizeof(LIT) - 1)
71 
72 struct str; /* defined in space.c */
73 
74 extern struct str * str_new(void);
75 extern void str_delete(struct str * str);
76 extern void str_append(struct str * str, const struct str * add);
77 extern void str_append_ch(struct str * str, char add);
78 extern void str_append_s(struct str * str, const byte * q);
79 extern void str_append_string(struct str * str, const char * s);
80 extern void str_append_int(struct str * str, int i);
81 extern void str_append_wchar_as_utf8(struct str * str, symbol ch);
82 extern void str_clear(struct str * str);
83 extern void str_assign(struct str * str, const char * s);
84 extern struct str * str_copy(const struct str * old);
85 extern byte * str_data(const struct str * str);
86 extern int str_len(const struct str * str);
87 extern int str_back(const struct str *str);
88 extern void str_pop(const struct str *str);
89 extern void str_pop_n(const struct str *str, int n);
90 extern void output_str(FILE * outfile, struct str * str);
91 
92 extern int get_utf8(const symbol * p, int * slot);
93 extern int put_utf8(int ch, symbol * p);
94 
95 typedef enum { ENC_SINGLEBYTE = 0, ENC_UTF8, ENC_WIDECHARS } enc;
96 
97 /* stringdef name and value */
98 struct m_pair {
99  struct m_pair * next;
100  byte * name;
102 
103 };
104 
105 /* struct input must be a prefix of struct tokeniser. */
106 struct input {
107  struct input * next;
108  byte * p;
109  int c;
110  char * file;
111  // -1 : Release file with: lose_s((byte *)file)
112  // 0 : We don't own file.
113  // 1 : Release file with: free(file)
116 
117 };
118 
119 struct include {
120  struct include * next;
121  byte * s;
122 
123 };
124 
126  /* The relational operator token values are chosen such that we can
127  * invert the relation with a simple xor with 1.
128  */
129  c_gt = 0, c_le,
132 
133  /* Other token values just need to be unique. */
147 
148  /* These token values don't directly correspond to a keyword. */
152 
153  /* These token values are synthesised by the analyser. */
165 
167 };
168 
173 };
174 
175 /* struct input must be a prefix of struct tokeniser. */
176 struct tokeniser {
177  struct input * next;
178  byte * p;
179  int c;
180  char * file;
181  // -1 : Release file with: lose_s((byte *)file)
182  // 0 : We don't own file.
183  // 1 : Release file with: free(file)
186 
187  // Used for c_literalstring values.
189  // Used for c_name names.
190  byte * s;
191  int number;
192  // String escape start character or -1.
193  int m_start;
194  // String escape end character.
195  int m_end;
196  // Link list of stringdefs.
197  struct m_pair * m_pairs;
198  // Nesting depth of get directives.
201  int token;
206 
207  struct include * includes;
208 
209  /* Mode in which U+ has been used:
210  * UPLUS_NONE - not used yet
211  * UPLUS_DEFINED - stringdef U+xxxx ....
212  * UPLUS_UNICODE - {U+xxxx} used with implicit meaning
213  */
215 
217 };
218 
219 extern byte * get_input(const char * filename);
220 extern struct tokeniser * create_tokeniser(byte * b, char * file);
221 extern int read_token(struct tokeniser * t);
222 extern int peek_token(struct tokeniser * t);
223 extern void push_token(struct tokeniser * t, int token);
224 #define hold_token(T) ((T)->token_held = true)
225 extern const char * name_of_token(int code);
226 extern void disable_token(struct tokeniser * t, int code);
227 extern void close_tokeniser(struct tokeniser * t);
228 
229 extern int space_count;
230 extern void * check_malloc(size_t n);
231 extern void check_free(void * p);
232 
233 extern int checked_snprintf(char * str, size_t size,
234  const char * format, ...)
235 #ifdef __GNUC__
236  __attribute__ ((__format__ (__printf__, 3, 4)))
237 #endif
238  ;
239 
240 struct node;
241 
242 struct name {
243  struct name * next;
244  byte * s;
245  byte type; /* t_string etc */
246  byte mode; /* for routines, externals (m_forward, etc) */
247  bool value_used; /* (For variables) is its value ever used? */
248  bool initialised; /* (For variables) is it ever initialised? */
249  bool used_in_definition; /* (grouping) used in grouping definition? */
250  // (routines/externals) contains among
251  bool has_among;
252  // (routines/externals) contains among with function(s)
254  bool case_collision; /* A name of the same type differs only by case */
255  // (routines/externals) Could this directly or indirectly call itself?
256  bool recursive;
257  // (routines/externals) Temporary flag used while determining `recursive`.
258  bool visited;
259  struct node * definition; /* (routines/externals) c_define node */
260  int uses_in_among; /* (routines/externals) Count of uses in amongs */
261  // Initialised to -1; set to -2 if reachable from an external.
262  // Reachable names are then numbered 0, 1, 2, ... with separate numbering
263  // per type.
264  int count;
265  // Number of references to this name.
267  struct grouping * grouping; /* for grouping names */
268  struct node * used; /* First use, or NULL if not used */
269  struct name * local_to; /* Local to one routine/external */
270  int among_index; /* for functions used in among */
271  int declaration_line_number;/* Line number of declaration */
272 };
273 
275  struct literalstring * next;
277 };
278 
279 struct amongvec {
280  symbol * b; /* the string giving the case */
281  int size; /* - and its size */
282  struct node * action; /* the corresponding action */
283  // The amongvec index of the longest substring of b, or -1 for none.
284  int i;
285  // among_var value for this case (starts from 1, or -1 for empty action).
286  int result;
287  int line_number; /* for diagnostics */
288  int function_index; /* 1-based */
289  // 0-based index giving order of strings in source. Used for stable
290  // sorting of amongvec entries and -coverage.
292  struct name * function;
293 };
294 
295 struct among {
296  struct among * next;
297  struct amongvec * v; /* pointer to the amongvec */
298  int number; /* amongs are numbered 0, 1, 2 ... */
299  int literalstring_count; /* in this among */
300  int command_count; /* in this among (excludes "no command" entries) */
301  int nocommand_count; /* number of "no command" entries in this among */
302  int function_count; /* number of cases with a function in this among */
303  int unique_function_count;/* number of different functions in this among */
304  bool amongvar_needed; /* do we need to set among_var? */
305  bool always_matches; /* will this among always match? */
306  bool used; /* is this among in reachable code? */
307  int same_action; /* type code if same for all actions; <0 otherwise */
308  int shortest_size; /* smallest non-zero string length in this among */
309  int longest_size; /* longest string length in this among */
310  struct node * substring; /* i.e. substring ... among ( ... ) */
311  struct node ** commands; /* array with command_count entries */
312  struct node * node; /* pointer to the node for this among */
313 };
314 
315 struct grouping {
316  struct grouping * next;
317  symbol * b; /* the characters of this group */
318  int largest_ch; /* character with max code */
319  int smallest_ch; /* character with min code */
320  struct name * name; /* so g->name->grouping == g */
322 };
323 
324 struct node {
325  struct node * next;
326  struct node * left;
327  struct node * aux; /* used in setlimit */
328  struct among * among; /* used in among */
329  struct node * right;
330  byte type;
331  byte mode;
332  // We want to distinguish constant AEs which have the same value everywhere
333  // (e.g. 42, 2+2, lenof '{U+0246}') from constant AEs which can have a
334  // different value depending on platform and/or target language and/or
335  // Unicode mode (e.g. maxint, sizeof '{U+0246}') - some warnings which
336  // depend on a constant AE's value should only fire for the first set.
338  // Return 0 for always f.
339  // Return 1 for always t.
340  // Return -1 for don't know (or can raise t or f).
341  signed char possible_signals;
342  struct node * AE;
343  struct name * name;
345  int number;
347 };
348 
350  t_size = 6,
351 
353  t_grouping = 5
354 
355 /* If this list is extended, adjust write_varname in generator.c */
356 };
357 
358 struct analyser {
360  struct node * nodes;
361  struct name * names;
363  byte mode;
364  bool modifyable; /* false inside reverse(...) */
365  struct node * program;
366  struct node * program_end;
367  /* name_count[i] counts the number of names of type i, where i is an enum
368  * name_types value. These counts *EXCLUDE* localised variables and
369  * variables which optimised away (e.g. declared but never used).
370  */
372  /* name_count[t_string] + name_count[t_boolean] + name_count[t_integer] */
374  struct among * amongs;
375  struct among * amongs_end;
376  int among_with_function_count; /* number of amongs with functions */
377  struct grouping * groupings;
379  struct node * substring; /* pending 'substring' in current routine definition */
380  struct name * current_routine; /* routine/external we're currently on. */
382  bool int_limits_used; /* are maxint or minint used? */
383  bool debug_used; /* is the '?' command used? */
384 };
385 
387  // m_unknown is used as the initial value for struct node's mode member.
388  // When a routine (or external) is used or defined we check the mode
389  // member matches, but for the first use/definition we see we want to
390  // instead set it to the mode of that use/definition.
392 };
393 
394 extern void print_program(struct analyser * a);
395 extern struct analyser * create_analyser(struct tokeniser * t);
396 extern void close_analyser(struct analyser * a);
397 
402 extern void read_program(struct analyser * a, unsigned localise_mask);
403 
404 struct generator {
405  struct analyser * analyser;
406  struct options * options;
407  bool unreachable; /* false if code can be reached, true if current
408  * code is unreachable. */
409  int var_number; /* Number of next variable to use. */
410  struct str * outbuf; /* temporary str to store output */
411  struct str * declarations; /* str storing variable declarations */
413  int max_label; /* Only used by Python */
414  int margin;
415 
416  /* Target language code to execute in case of failure. */
417  struct str * failure_str;
418 
419  int label_used; /* Keep track of whether the failure label is used. */
422  int copy_from_count; /* count of calls to copy_from() */
423 
424  const char * S[10]; /* strings */
425  byte * B[10]; /* byte blocks */
426  int I[10]; /* integers */
427 
428  int line_count; /* counts number of lines output */
429  int line_labelled; /* in ISO C, will need extra ';' if it is a block end */
431  int keep_count; /* used to number keep/restore pairs to avoid compiler warnings
432  about shadowed variables */
433  bool temporary_used; /* track if temporary variable used (Ada and Pascal) */
434  char java_import_arrays; /* need `import java.util.Arrays;` */
435  char java_import_chararraysequence; /* need `import org.tartarus.snowball.CharArraySequence;` */
436  // Prefix for generated variable names (`v_` by default).
437  const char * varname_prefix;
438  // String to indent by for each margin level (four spaces by default).
439  const char * margin_indent;
440 };
441 
442 /* Special values for failure_label in struct generator. */
444  x_return = -1
445 };
446 
447 struct options {
448  /* for the command line: */
449  byte * output_file;
450  // output_file but without any path.
451  byte * output_leaf;
452  // Extension specified in -o option (or NULL if none).
453  byte * extension;
454  byte * name;
455  FILE * output_src;
456  FILE * output_h;
458  bool comments;
459  bool coverage;
461  enum {
462  LANG_C = 0, // We generate C by default.
474  LANG_ZIG
476  const char * externals_prefix;
477  const char * variables_prefix;
478  const char * cheader;
479  const char * hheader;
480  const char * runtime_path;
481  const char * parent_class_name;
482  const char * package;
483  const char * go_snowball_runtime;
484  const char * string_class;
485  const char * among_class;
486  struct include * includes;
488 };
489 
490 /* Generator functions common to several backends. */
491 
492 extern struct generator * create_generator(struct analyser * a, struct options * o);
493 extern void close_generator(struct generator * g);
494 
495 static inline int new_label(struct generator * g) {
496  return g->next_label++;
497 }
498 
499 extern struct str * vars_newname(struct generator * g);
500 
501 extern void write_margin(struct generator * g);
502 
503 extern void write_char(struct generator * g, int ch);
504 extern void write_newline(struct generator * g);
505 extern void write_string(struct generator * g, const char * s);
506 extern void write_wchar_as_utf8(struct generator * g, symbol ch);
507 extern void write_int(struct generator * g, int i);
508 extern void wi3(struct generator * g, int i);
509 extern void write_hex4(struct generator * g, unsigned ch);
510 extern void write_hex(struct generator * g, unsigned i);
511 extern void write_octal3(struct generator * g, unsigned n);
512 extern void write_symbol(struct generator * g, symbol s);
513 extern void write_s(struct generator * g, const byte * b);
514 extern void write_str(struct generator * g, struct str * str);
515 extern void write_c_relop(struct generator * g, int relop);
516 
517 extern void write_comment_content(struct generator * g, struct node * p,
518  const char * end);
520 extern void write_start_comment(struct generator * g,
521  const char * comment_start,
522  const char * comment_end);
523 
524 extern int K_needed(struct node * p);
525 extern int K_needed_node_on_f(struct node * p);
526 extern int K_needed_for_and(struct node * p);
527 extern int K_needed_for_or(struct node * p);
528 extern int repeat_restore(struct node * p);
529 extern bool amongvar_needed(struct node * p);
530 
531 extern int just_return_on_fail(struct generator * g);
532 extern int tailcallable(struct generator * g, struct node * p);
533 
534 /* Generator for C code. */
535 extern void generate_program_c(struct generator * g);
536 
537 /* Generator for Java code. */
538 extern void generate_program_java(struct generator * g);
539 
540 /* Generator for Dart code. */
541 extern void generate_program_dart(struct generator * g);
542 
543 /* Generator for C# code. */
544 extern void generate_program_csharp(struct generator * g);
545 
546 extern void generate_program_pascal(struct generator * g);
547 
548 extern void generate_program_php(struct generator * g);
549 
550 /* Generator for Python code. */
551 extern void generate_program_python(struct generator * g);
552 
553 extern void generate_program_js(struct generator * g);
554 
555 extern void generate_program_rust(struct generator * g);
556 
557 extern void generate_program_go(struct generator * g);
558 
559 extern void generate_program_ada(struct generator * g);
560 
561 extern void generate_program_zig(struct generator * g);
unsigned char symbol
Definition: api.h:4
Definition: unittest.cc:660
PositionList * p
void generate_program_c(struct generator *g)
void str_pop(const struct str *str)
void str_append_int(struct str *str, int i)
void str_clear(struct str *str)
byte * get_input(const char *filename)
unsigned char byte
Definition: header.h:8
void generate_program_csharp(struct generator *g)
symbol * add_to_b(symbol *p, const symbol *q, int n)
static byte * reserve_s(byte *p, int n)
Definition: header.h:54
void generate_program_js(struct generator *g)
int K_needed(struct node *p)
void str_delete(struct str *str)
void generate_program_php(struct generator *g)
void str_append_s(struct str *str, const byte *q)
void close_generator(struct generator *g)
void write_generated_comment_content(struct generator *g)
int just_return_on_fail(struct generator *g)
int K_needed_for_and(struct node *p)
void generate_program_ada(struct generator *g)
int get_utf8(const symbol *p, int *slot)
byte * copy_s(const byte *p)
void write_hex(struct generator *g, unsigned i)
void write_newline(struct generator *g)
static symbol * reserve_b(symbol *p, int n)
Definition: header.h:30
#define SIZE(p)
Definition: header.h:21
byte * reserve_s_(byte *p, int n)
special_labels
Definition: header.h:443
@ x_return
Definition: header.h:444
int checked_snprintf(char *str, size_t size, const char *format,...)
void report_s(FILE *out, const byte *p)
void generate_program_dart(struct generator *g)
void write_int(struct generator *g, int i)
struct generator * create_generator(struct analyser *a, struct options *o)
analyser_modes
Definition: header.h:386
@ m_backward
Definition: header.h:391
@ m_unknown
Definition: header.h:391
@ m_forward
Definition: header.h:391
void disable_token(struct tokeniser *t, int code)
void write_char(struct generator *g, int ch)
uplus_modes
Definition: header.h:169
@ UPLUS_UNICODE
Definition: header.h:172
@ UPLUS_NONE
Definition: header.h:170
@ UPLUS_DEFINED
Definition: header.h:171
void write_s(struct generator *g, const byte *b)
void lose_s(byte *p)
byte * create_s_from_data(const char *s, int n)
void output_str(FILE *outfile, struct str *str)
unsigned short symbol
Definition: header.h:9
void write_str(struct generator *g, struct str *str)
byte * add_sz_to_s(byte *p, const char *s)
void generate_program_python(struct generator *g)
int put_utf8(int ch, symbol *p)
symbol * add_symbol_to_b(symbol *p, symbol ch)
byte * add_char_to_s(byte *p, char ch)
void write_comment_content(struct generator *g, struct node *p, const char *end)
void str_append(struct str *str, const struct str *add)
void report_b(FILE *out, const symbol *p)
void generate_program_pascal(struct generator *g)
int str_back(const struct str *str)
int space_count
void str_append_wchar_as_utf8(struct str *str, symbol ch)
void write_hex4(struct generator *g, unsigned ch)
static symbol * ensure_nul_b(symbol *p)
Definition: header.h:35
void print_program(struct analyser *a)
void str_assign(struct str *str, const char *s)
void write_symbol(struct generator *g, symbol s)
void write_wchar_as_utf8(struct generator *g, symbol ch)
int repeat_restore(struct node *p)
byte * resize_s(byte *p, int n)
void str_append_ch(struct str *str, char add)
enc
Definition: header.h:95
@ ENC_UTF8
Definition: header.h:95
@ ENC_WIDECHARS
Definition: header.h:95
@ ENC_SINGLEBYTE
Definition: header.h:95
int str_len(const struct str *str)
void close_tokeniser(struct tokeniser *t)
int read_token(struct tokeniser *t)
void wi3(struct generator *g, int i)
void write_margin(struct generator *g)
void close_analyser(struct analyser *a)
int K_needed_for_or(struct node *p)
void * check_malloc(size_t n)
void push_token(struct tokeniser *t, int token)
static int new_label(struct generator *g)
Definition: header.h:495
void read_program(struct analyser *a, unsigned localise_mask)
Read and analyse the program.
int K_needed_node_on_f(struct node *p)
void write_string(struct generator *g, const char *s)
void str_append_string(struct str *str, const char *s)
void check_free(void *p)
token_codes
Definition: header.h:125
@ c_unset
Definition: header.h:146
@ c_literalstring
Definition: header.h:151
@ c_substring
Definition: header.h:145
@ c_as
Definition: header.h:134
@ c_stringescapes
Definition: header.h:145
@ c_delete
Definition: header.h:137
@ c_neg
Definition: header.h:155
@ c_setlimit
Definition: header.h:144
@ c_plus
Definition: header.h:142
@ c_set
Definition: header.h:144
@ c_booltest
Definition: header.h:158
@ c_hex
Definition: header.h:139
@ c_setmark
Definition: header.h:144
@ c_loop
Definition: header.h:140
@ c_not_booltest
Definition: header.h:164
@ c_size
Definition: header.h:144
@ c_le
Definition: header.h:129
@ c_len
Definition: header.h:140
@ c_functionend
Definition: header.h:159
@ c_for
Definition: header.h:138
@ c_comment1
Definition: header.h:136
@ c_goto
Definition: header.h:139
@ c_strings
Definition: header.h:145
@ c_gt
Definition: header.h:129
@ c_sliceto
Definition: header.h:145
@ c_and
Definition: header.h:134
@ c_externals
Definition: header.h:138
@ c_decimal
Definition: header.h:137
@ c_debug
Definition: header.h:136
@ c_booleans
Definition: header.h:136
@ c_insert
Definition: header.h:139
@ c_minus
Definition: header.h:141
@ c_leftslice
Definition: header.h:140
@ c_grouping
Definition: header.h:157
@ c_try
Definition: header.h:146
@ c_name
Definition: header.h:149
@ c_not
Definition: header.h:142
@ c_define
Definition: header.h:137
@ c_do
Definition: header.h:137
@ c_goto_grouping
Definition: header.h:160
@ c_sizeof
Definition: header.h:144
@ c_reverse
Definition: header.h:143
@ c_tolimit
Definition: header.h:146
@ c_ket
Definition: header.h:140
@ c_eq
Definition: header.h:131
@ c_hop
Definition: header.h:139
@ c_lenof
Definition: header.h:140
@ c_integers
Definition: header.h:140
@ c_multiply
Definition: header.h:141
@ c_plusassign
Definition: header.h:143
@ c_atlimit
Definition: header.h:135
@ c_maxint
Definition: header.h:141
@ c_routines
Definition: header.h:143
@ c_attach
Definition: header.h:135
@ c_true
Definition: header.h:146
@ c_gopast
Definition: header.h:139
@ c_call
Definition: header.h:156
@ c_slicefrom
Definition: header.h:144
@ c_fail
Definition: header.h:138
@ c_cursor
Definition: header.h:136
@ c_stringassign
Definition: header.h:154
@ c_ne
Definition: header.h:131
@ c_groupings
Definition: header.h:139
@ c_minint
Definition: header.h:141
@ c_gopast_non
Definition: header.h:163
@ c_lt
Definition: header.h:130
@ c_get
Definition: header.h:138
@ NUM_TOKEN_CODES
Definition: header.h:166
@ c_non
Definition: header.h:142
@ c_atmark
Definition: header.h:135
@ c_divideassign
Definition: header.h:137
@ c_comment2
Definition: header.h:136
@ c_multiplyassign
Definition: header.h:142
@ c_atleast
Definition: header.h:134
@ c_repeat
Definition: header.h:143
@ c_dollar
Definition: header.h:138
@ c_or
Definition: header.h:142
@ c_backwards
Definition: header.h:135
@ c_next
Definition: header.h:142
@ c_limit
Definition: header.h:140
@ c_ge
Definition: header.h:130
@ c_test
Definition: header.h:146
@ c_bra
Definition: header.h:136
@ c_rightslice
Definition: header.h:143
@ c_assignto
Definition: header.h:134
@ c_gopast_grouping
Definition: header.h:161
@ c_minusassign
Definition: header.h:141
@ c_divide
Definition: header.h:137
@ c_number
Definition: header.h:150
@ c_tomark
Definition: header.h:146
@ c_stringdef
Definition: header.h:145
@ c_assign
Definition: header.h:134
@ c_backwardmode
Definition: header.h:135
@ c_goto_non
Definition: header.h:162
@ c_false
Definition: header.h:138
@ c_among
Definition: header.h:134
void lose_b(symbol *p)
int peek_token(struct tokeniser *t)
byte * create_s_from_sz(const char *s)
void str_pop_n(const struct str *str, int n)
struct str * vars_newname(struct generator *g)
#define CAPACITY(p)
Definition: header.h:24
char * b_to_sz(const symbol *p)
symbol * resize_b(symbol *p, int n)
byte * create_s(int n)
symbol * copy_b(const symbol *p)
void write_octal3(struct generator *g, unsigned n)
struct str * str_new(void)
static byte * ensure_nul_s(byte *p)
Definition: header.h:59
struct tokeniser * create_tokeniser(byte *b, char *file)
byte * str_data(const struct str *str)
symbol * create_b(int n)
const char * name_of_token(int code)
void write_c_relop(struct generator *g, int relop)
void generate_program_zig(struct generator *g)
symbol * reserve_b_(symbol *p, int n)
void generate_program_java(struct generator *g)
void write_start_comment(struct generator *g, const char *comment_start, const char *comment_end)
void generate_program_rust(struct generator *g)
byte * add_slen_to_s(byte *p, const char *s, int n)
bool amongvar_needed(struct node *p)
byte * add_s_to_s(byte *p, const byte *s)
name_types
Definition: header.h:349
@ t_grouping
Definition: header.h:353
@ t_routine
Definition: header.h:352
@ t_boolean
Definition: header.h:352
@ t_size
Definition: header.h:350
@ t_external
Definition: header.h:352
@ t_string
Definition: header.h:352
@ t_integer
Definition: header.h:352
void generate_program_go(struct generator *g)
int tailcallable(struct generator *g, struct node *p)
struct analyser * create_analyser(struct tokeniser *t)
struct str * str_copy(const struct str *old)
string str(int value)
Convert int to std::string.
Definition: str.cc:91
static string format(const char *fmt, T value)
Definition: str.cc:128
Definition: header.h:295
bool used
Definition: header.h:306
struct node * substring
Definition: header.h:310
int command_count
Definition: header.h:300
int same_action
Definition: header.h:307
bool amongvar_needed
Definition: header.h:304
struct amongvec * v
Definition: header.h:297
int function_count
Definition: header.h:302
bool always_matches
Definition: header.h:305
int nocommand_count
Definition: header.h:301
struct node ** commands
Definition: header.h:311
int literalstring_count
Definition: header.h:299
int shortest_size
Definition: header.h:308
struct node * node
Definition: header.h:312
struct among * next
Definition: header.h:296
int unique_function_count
Definition: header.h:303
int longest_size
Definition: header.h:309
int number
Definition: header.h:298
symbol * b
Definition: header.h:280
struct node * action
Definition: header.h:282
int result
Definition: header.h:286
int function_index
Definition: header.h:288
int size
Definition: header.h:281
int i
Definition: header.h:284
int line_number
Definition: header.h:287
int string_index
Definition: header.h:291
int among_with_function_count
Definition: header.h:376
bool int_limits_used
Definition: header.h:382
struct name * names
Definition: header.h:361
int variable_count
Definition: header.h:373
struct among * amongs_end
Definition: header.h:375
bool modifyable
Definition: header.h:364
struct node * nodes
Definition: header.h:360
struct literalstring * literalstrings
Definition: header.h:362
struct among * amongs
Definition: header.h:374
byte mode
Definition: header.h:363
struct grouping * groupings_end
Definition: header.h:378
struct grouping * groupings
Definition: header.h:377
struct tokeniser * tokeniser
Definition: header.h:359
struct node * substring
Definition: header.h:379
struct name * current_routine
Definition: header.h:380
bool debug_used
Definition: header.h:383
enc encoding
Definition: header.h:381
struct node * program_end
Definition: header.h:366
int name_count[t_size]
Definition: header.h:371
struct node * program
Definition: header.h:365
int max_label
Definition: header.h:413
char java_import_chararraysequence
Definition: header.h:435
const char * varname_prefix
Definition: header.h:437
char java_import_arrays
Definition: header.h:434
struct options * options
Definition: header.h:406
bool temporary_used
Definition: header.h:433
struct str * declarations
Definition: header.h:411
int keep_count
Definition: header.h:431
struct analyser * analyser
Definition: header.h:405
struct str * failure_str
Definition: header.h:417
const char * margin_indent
Definition: header.h:439
int line_labelled
Definition: header.h:429
int var_number
Definition: header.h:409
bool unreachable
Definition: header.h:407
int copy_from_count
Definition: header.h:422
const char * S[10]
Definition: header.h:424
int debug_count
Definition: header.h:421
int failure_label
Definition: header.h:420
int next_label
Definition: header.h:412
struct str * outbuf
Definition: header.h:410
int line_count
Definition: header.h:428
int I[10]
Definition: header.h:426
int label_used
Definition: header.h:419
int literalstring_count
Definition: header.h:430
int margin
Definition: header.h:414
struct grouping * next
Definition: header.h:316
int smallest_ch
Definition: header.h:319
int line_number
Definition: header.h:321
int largest_ch
Definition: header.h:318
symbol * b
Definition: header.h:317
struct name * name
Definition: header.h:320
byte * s
Definition: header.h:121
struct include * next
Definition: header.h:120
Definition: header.h:106
int line_number
Definition: header.h:115
char * file
Definition: header.h:110
byte * p
Definition: header.h:108
struct input * next
Definition: header.h:107
int c
Definition: header.h:109
int file_owned
Definition: header.h:114
symbol * b
Definition: header.h:276
struct literalstring * next
Definition: header.h:275
Definition: header.h:98
symbol * value
Definition: header.h:101
struct m_pair * next
Definition: header.h:99
byte * name
Definition: header.h:100
Definition: header.h:242
struct node * definition
Definition: header.h:259
struct node * used
Definition: header.h:268
byte type
Definition: header.h:245
byte mode
Definition: header.h:246
int uses_in_among
Definition: header.h:260
bool visited
Definition: header.h:258
struct name * local_to
Definition: header.h:269
int references
Definition: header.h:266
bool has_among
Definition: header.h:251
byte * s
Definition: header.h:244
struct name * next
Definition: header.h:243
int among_index
Definition: header.h:270
bool case_collision
Definition: header.h:254
struct grouping * grouping
Definition: header.h:267
bool used_in_definition
Definition: header.h:249
bool has_among_function
Definition: header.h:253
bool value_used
Definition: header.h:247
int count
Definition: header.h:264
bool initialised
Definition: header.h:248
int declaration_line_number
Definition: header.h:271
bool recursive
Definition: header.h:256
Definition: header.h:324
symbol * literalstring
Definition: header.h:344
byte mode
Definition: header.h:331
struct node * left
Definition: header.h:326
signed char possible_signals
Definition: header.h:341
bool fixed_constant
Definition: header.h:337
int number
Definition: header.h:345
byte type
Definition: header.h:330
struct node * aux
Definition: header.h:327
struct name * name
Definition: header.h:343
struct node * AE
Definition: header.h:342
struct node * right
Definition: header.h:329
struct node * next
Definition: header.h:325
int line_number
Definition: header.h:346
struct among * among
Definition: header.h:328
@ LANG_C
Definition: header.h:462
@ LANG_ZIG
Definition: header.h:474
@ LANG_JAVASCRIPT
Definition: header.h:469
@ LANG_ADA
Definition: header.h:463
@ LANG_PASCAL
Definition: header.h:470
@ LANG_CPLUSPLUS
Definition: header.h:464
@ LANG_DART
Definition: header.h:466
@ LANG_CSHARP
Definition: header.h:465
@ LANG_PYTHON
Definition: header.h:472
@ LANG_JAVA
Definition: header.h:468
@ LANG_GO
Definition: header.h:467
@ LANG_RUST
Definition: header.h:473
@ LANG_PHP
Definition: header.h:471
struct include * includes_end
Definition: header.h:487
bool syntax_tree
Definition: header.h:457
FILE * output_h
Definition: header.h:456
bool coverage
Definition: header.h:459
const char * package
Definition: header.h:482
byte * output_leaf
Definition: header.h:451
const char * among_class
Definition: header.h:485
byte * output_file
Definition: header.h:449
const char * runtime_path
Definition: header.h:480
FILE * output_src
Definition: header.h:455
bool comments
Definition: header.h:458
const char * parent_class_name
Definition: header.h:481
byte * extension
Definition: header.h:453
byte * name
Definition: header.h:454
enum options::@16 target_lang
const char * string_class
Definition: header.h:484
const char * externals_prefix
Definition: header.h:476
const char * go_snowball_runtime
Definition: header.h:483
const char * variables_prefix
Definition: header.h:477
const char * cheader
Definition: header.h:478
struct include * includes
Definition: header.h:486
enc encoding
Definition: header.h:460
const char * hheader
Definition: header.h:479
Definition: tokens.h:1
struct include * includes
Definition: header.h:207
char token_disabled[NUM_TOKEN_CODES]
Definition: header.h:216
int get_depth
Definition: header.h:199
int token
Definition: header.h:201
byte * s
Definition: header.h:190
int file_owned
Definition: header.h:184
byte * p
Definition: header.h:178
struct input * next
Definition: header.h:177
int c
Definition: header.h:179
struct m_pair * m_pairs
Definition: header.h:197
int previous_token
Definition: header.h:202
int uplusmode
Definition: header.h:214
bool token_held
Definition: header.h:203
char * file
Definition: header.h:180
bool token_reported_as_unexpected
Definition: header.h:204
symbol * b
Definition: header.h:188
int error_count
Definition: header.h:200
int m_start
Definition: header.h:193
int number
Definition: header.h:191
enc encoding
Definition: header.h:205
int m_end
Definition: header.h:195
int line_number
Definition: header.h:185