File: uirx.h

package info (click to toggle)
libmoe 1.5.7-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 6,772 kB
  • ctags: 267,602
  • sloc: ansic: 478,515; perl: 2,318; makefile: 201; sh: 22
file content (108 lines) | stat: -rw-r--r-- 2,458 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef UIRX_H
#define UIRX_H

#include <limits.h>
#include <stddef.h>
#include <string.h>
#include <altmalloc.h>

#ifdef UIRX_WC_T
typedef UIRX_WC_T uirx_wc_t;
#else
typedef unsigned int uirx_wc_t;
#endif

#ifndef UIRX_WC_MAX
#define UIRX_WC_MAX (UINT_MAX)
#endif

typedef enum {
  uirx_alpha_is_e,
  uirx_alpha_is_c,
  uirx_alpha_is_v,
} uirx_alpha_type_t;

typedef struct uirx_alpha_range_t {
  uirx_wc_t beg, end;
} uirx_alpha_range_t;

typedef void (*uirx_special_callback_t)(uirx_wc_t, void *);

typedef struct uirx_posv_st {
  ptrdiff_t *v;
  ptrdiff_t n;
} uirx_posv_t;

typedef struct {
  int type;
  union {
    uirx_alpha_range_t c;
    struct {
      uirx_alpha_range_t *cs;
      ptrdiff_t n;
    } v;
  } a;
  uirx_special_callback_t cb_func;
  union {
    unsigned char *map;
    uirx_posv_t posv;
  } followpos;
} uirx_alpha_t;

enum {
  uirx_expr_is_alpha,
  uirx_expr_is_cat,
  uirx_expr_is_or,
  uirx_expr_is_star,
  uirx_expr_is_plus,
  uirx_expr_is_0or1,
};

typedef unsigned char uirx_expr_type_t;

typedef struct uirx_expr_st {
  uirx_expr_type_t type;
  unsigned char nullable;
  unsigned char *firstpos;
  unsigned char *lastpos;
  union {
    ptrdiff_t one;
    ptrdiff_t two[2];
  } data;
} uirx_expr_t;

typedef struct uirx_exprv_st {
  uirx_expr_t *v;
  ptrdiff_t n, n_max;
  unsigned char **mv;
  ptrdiff_t mn, mn_max;
} uirx_exprv_t;

typedef struct uirx_nfa_st {
  uirx_alpha_t *v;
  ptrdiff_t n, n_max, n_bytes;
  unsigned char *posflag;
  uirx_posv_t first, stack[2];
  ptrdiff_t from;
} uirx_nfa_t;

typedef struct uirx_parse_stack_st {
  struct uirx_parse_stack_st *sup;
  ptrdiff_t last;
  uirx_exprv_t *exprv;
  uirx_nfa_t *nfa;
} uirx_parse_stack_t;

extern uirx_alpha_t *uirx_new_alpha(uirx_nfa_t *nfa);
extern uirx_expr_t *uirx_parse_alpha(uirx_parse_stack_t *sp, uirx_alpha_t *alpha);
extern uirx_nfa_t *uirx_parse_start(uirx_parse_stack_t *sp, uirx_parse_stack_t *sup, uirx_alpha_t *alpha);
extern uirx_expr_t *uirx_parse_end(uirx_parse_stack_t *sp, uirx_alpha_t *alpha);
extern uirx_expr_t *uirx_parse_or(uirx_parse_stack_t *sp);
extern uirx_expr_t *uirx_parse_postfix(uirx_parse_stack_t *sp, uirx_expr_type_t t);
extern uirx_nfa_t *uirx_complete_nfa(uirx_parse_stack_t *sp);
extern void uirx_match_start(uirx_nfa_t *nfa);
extern ptrdiff_t uirx_match(uirx_nfa_t *nfa, void *cb_arg, uirx_wc_t wc);
extern void uirx_match_end(uirx_nfa_t *nfa, void *cb_arg);
extern void uirx_free_exprv(uirx_exprv_t *exprv);

#endif