RPA Toolkit
added optimization to reduce the size of the garbage records
[rpatk.git] / rpa2 / rparecord.h
1 #ifndef _RPARECORD_H_
2 #define _RPARECORD_H_
3
4 #include "rtypes.h"
5 #include "rarray.h"
6 #include "rlist.h"
7 #include "rpavm.h"
8
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 #define RPA_RECORD_NONE (0)
15 #define RPA_RECORD_START (1 << 0)
16 #define RPA_RECORD_END (1 << 1)
17 #define RPA_RECORD_MATCH (1 << 2)
18 #define RPA_RECORD_HEAD (1 << 3)
19 #define RPA_RECORD_TAIL (1 << 4)
20
21 #define RPA_RECORD_INVALID_UID ((ruint32)-1)
22
23 typedef struct rparecord_s {
24         rlist_t head;
25         rlink_t lnk;
26         rlong next;
27         rword loo;
28         const char *rule;
29         ruint32 ruleid;
30         ruint32 top;
31         ruint32 size;
32         ruint32 type;
33         const char *input;
34         rsize_t inputsiz;
35         ruint32 ruleuid;
36         ruint32 usertype;
37         rword userdata;
38 } rparecord_t;
39
40
41 typedef rlong (*rpa_recordtree_callback)(rarray_t *records, rlong rec, rpointer userdata);
42
43 rlong rpa_recordtree_walk(rarray_t *src, rlong rec, rpa_recordtree_callback callaback, rpointer userdata);
44 rlong rpa_recordtree_get(rarray_t *records, rlong rec, rulong type);
45 rlong rpa_recordtree_firstchild(rarray_t *records, rlong rec, rulong type);
46 rlong rpa_recordtree_lastchild(rarray_t *records, rlong rec, rulong type);
47 rlong rpa_recordtree_next(rarray_t *records, rlong rec, rulong type);
48 rlong rpa_recordtree_prev(rarray_t *records, rlong rec, rulong type);
49 rlong rpa_recordtree_parent(rarray_t *records, rlong rec, rulong type);
50 rlong rpa_recordtree_rotatedown(rarray_t *records, rlong parent);                       /* Rotate children down, the last child becomes the first */
51 rlong rpa_recordtree_size(rarray_t *records, rlong rec);                                        /* Size of the tree */
52 rlong rpa_recordtree_copy(rarray_t *dst, rarray_t *src, rlong rec);
53
54 void rpa_record_dumpindented(rarray_t *records, rlong rec, rint level);
55 void rpa_record_dump(rarray_t *records, rlong rec);
56 void rpa_record_setusertype(rarray_t *records, rlong rec, ruint32 usertype, rvalset_t op);
57 rlong rpa_record_getusertype(rarray_t *records, rlong rec);
58 rint rpa_record_optchar(rparecord_t *prec, rint defc);
59 rint rpa_record_loopchar(rparecord_t *prec, rint defc);
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif