1
2#include <limits.h>
3
4#include "api.h"
5
6#define MAXINT INT_MAX
7#define MININT INT_MIN
8
9#define HEAD 2*sizeof(int)
10
11#define SIZE(p) ((int *)(p))[-1]
12#define SET_SIZE(p, n) ((int *)(p))[-1] = n
13#define CAPACITY(p) ((int *)(p))[-2]
14
15struct among
16{ int s_size; /* number of chars in string */
17 const symbol * s; /* search string */
18 int substring_i;/* index to longest matching substring */
19 int result; /* result of the lookup */
20 int (* function)(struct SN_env *);
21};
22
23extern symbol * create_s(void);
24extern void lose_s(symbol * p);
25
26extern int skip_utf8(const symbol * p, int c, int lb, int l, int n);
27
28extern int in_grouping_U(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
29extern int in_grouping_b_U(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
30extern int out_grouping_U(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
31extern int out_grouping_b_U(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
32
33extern int in_grouping(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
34extern int in_grouping_b(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
35extern int out_grouping(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
36extern int out_grouping_b(struct SN_env * z, const unsigned char * s, int min, int max, int repeat);
37
38extern int eq_s(struct SN_env * z, int s_size, const symbol * s);
39extern int eq_s_b(struct SN_env * z, int s_size, const symbol * s);
40extern int eq_v(struct SN_env * z, const symbol * p);
41extern int eq_v_b(struct SN_env * z, const symbol * p);
42
43extern int find_among(struct SN_env * z, const struct among * v, int v_size);
44extern int find_among_b(struct SN_env * z, const struct among * v, int v_size);
45
46extern int replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s, int * adjustment);
47extern int slice_from_s(struct SN_env * z, int s_size, const symbol * s);
48extern int slice_from_v(struct SN_env * z, const symbol * p);
49extern int slice_del(struct SN_env * z);
50
51extern int insert_s(struct SN_env * z, int bra, int ket, int s_size, const symbol * s);
52extern int insert_v(struct SN_env * z, int bra, int ket, const symbol * p);
53
54extern symbol * slice_to(struct SN_env * z, symbol * p);
55extern symbol * assign_to(struct SN_env * z, symbol * p);
56
57extern int len_utf8(const symbol * p);
58
59extern void debug(struct SN_env * z, int number, int line_count);
60
61