1 #ifndef SNOWBALL_INCLUDED_SNOWBALL_RUNTIME_H
2 #define SNOWBALL_INCLUDED_SNOWBALL_RUNTIME_H
6 #define HEAD 2*sizeof(int)
10 # define SIZE(p) (reinterpret_cast<const int *>(p))[-1]
11 # define SET_SIZE(p, n) (reinterpret_cast<int *>(p))[-1] = n
12 # define CAPACITY(p) (reinterpret_cast<int *>(p))[-2]
14 # define SIZE(p) ((const int *)(p))[-1]
15 # define SET_SIZE(p, n) ((int *)(p))[-1] = n
16 # define CAPACITY(p) ((int *)(p))[-2]
19 #ifdef SNOWBALL_RUNTIME_THROW_EXCEPTIONS
20 # define SNOWBALL_ERR void
22 # define SNOWBALL_ERR int
25 #ifdef SNOWBALL_DEBUG_COMMAND_USED
27 static void debug(
struct SN_env * z,
int number,
int line_count) {
29 int limit =
SIZE(z->
p);
30 if (number >= 0) printf(
"%3d (line %4d): [%d]'", number, line_count, limit);
31 for (i = 0; i <= limit; i++) {
32 if (z->
lb == i) printf(
"{");
33 if (z->
bra == i) printf(
"[");
34 if (z->
c == i) printf(
"|");
35 if (z->
ket == i) printf(
"]");
36 if (z->
l == i) printf(
"}");
39 if (ch == 0) ch =
'#';
62 #if defined __cplusplus && !defined SNOWBALL_RUNTIME_THROW_EXCEPTIONS
73 extern int in_grouping_U(
struct SN_env * z,
const unsigned char * s,
int min,
int max,
int repeat);
75 extern int out_grouping_U(
struct SN_env * z,
const unsigned char * s,
int min,
int max,
int repeat);
78 extern int in_grouping(
struct SN_env * z,
const unsigned char * s,
int min,
int max,
int repeat);
79 extern int in_grouping_b(
struct SN_env * z,
const unsigned char * s,
int min,
int max,
int repeat);
80 extern int out_grouping(
struct SN_env * z,
const unsigned char * s,
int min,
int max,
int repeat);
81 extern int out_grouping_b(
struct SN_env * z,
const unsigned char * s,
int min,
int max,
int repeat);
106 #if defined __cplusplus && !defined SNOWBALL_RUNTIME_THROW_EXCEPTIONS
int out_grouping_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
int in_grouping_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
SNOWBALL_ERR insert_s(struct SN_env *z, int bra, int ket, int s_size, const symbol *s)
int eq_v_b(struct SN_env *z, const symbol *p)
SNOWBALL_ERR slice_from_s(struct SN_env *z, int s_size, const symbol *s)
int in_grouping(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
SNOWBALL_ERR slice_to(struct SN_env *z, symbol **p)
SNOWBALL_ERR assign_to(struct SN_env *z, symbol **p)
SNOWBALL_ERR slice_from_v(struct SN_env *z, const symbol *p)
int eq_s(struct SN_env *z, int s_size, const symbol *s)
SNOWBALL_ERR insert_v(struct SN_env *z, int bra, int ket, const symbol *p)
int eq_v(struct SN_env *z, const symbol *p)
SNOWBALL_ERR replace_s(struct SN_env *z, int c_bra, int c_ket, int s_size, const symbol *s)
int out_grouping_b(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
int in_grouping_b_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
int skip_b_utf8(const symbol *p, int c, int limit, int n)
int eq_s_b(struct SN_env *z, int s_size, const symbol *s)
int out_grouping(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
SNOWBALL_ERR slice_del(struct SN_env *z)
int out_grouping_b_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
int skip_utf8(const symbol *p, int c, int limit, int n)
int in_grouping_b(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
int find_among_b(struct SN_env *z, const struct among *v, int v_size, int(*)(struct SN_env *))
int len_utf8(const symbol *p)
int find_among(struct SN_env *z, const struct among *v, int v_size, int(*)(struct SN_env *))