Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libdss/cxlib.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2002-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* C expression library private definitions
23
*
24
* Glenn Fowler
25
* AT&T Research
26
*/
27
28
#ifndef _CX_PRIVATE_
29
30
struct Cxtable_s;
31
32
struct Cxcompile_s; typedef struct Cxcompile_s Cxcompile_t;
33
struct Cxdone_s; typedef struct Cxdone_s Cxdone_t;
34
struct Cxinclude_s; typedef struct Cxinclude_s Cxinclude_t;
35
36
#define _CX_PRIVATE_ \
37
Cxexpr_t* expr; \
38
struct Cxinclude_s* include; \
39
struct Cxtable_s* table; \
40
Sfio_t* op; \
41
regdisc_t redisc; \
42
Cxcallout_f deletef; \
43
Cxcallout_f getf; \
44
Cxcallout_f returnf; \
45
Cxcallout_f referencef; \
46
char* ccbuf; \
47
char* cvtbuf; \
48
size_t ccsiz; \
49
size_t cvtsiz; \
50
int evaluating; \
51
int index; \
52
int jump; \
53
int scoped; \
54
int view; \
55
Sfio_t* tp;
56
57
#define _CX_CONSTRAINT_PRIVATE_ \
58
regex_t* re;
59
60
#define _CX_EDIT_PRIVATE_ \
61
regex_t re; \
62
regdisc_t redisc;
63
64
#define _CX_EXPR_PRIVATE_ \
65
char** files; \
66
Vmalloc_t* vm; \
67
Cxdone_t* done; \
68
struct Cxoperand_s* stack; \
69
unsigned int stacksize; \
70
int begun; \
71
int reclaim;
72
73
#define _CX_ITEM_PRIVATE_ \
74
Dtlink_t str2num; \
75
Dtlink_t num2str;
76
77
#define _CX_QUERY_PRIVATE_ \
78
int head; \
79
Cxquery_t* next; \
80
Cxinstruction_t* prog;
81
82
#define _CX_STATE_PRIVATE_ \
83
Cxheader_t* header; \
84
unsigned int initialized; \
85
Dtdisc_t codedisc; \
86
Dtdisc_t listdisc; \
87
Dtdisc_t namedisc; \
88
unsigned char ctype[UCHAR_MAX+1];
89
90
#include <ast.h>
91
#include <regex.h>
92
93
#include "cx.h"
94
95
#include <ctype.h>
96
#include <error.h>
97
98
#define CX_PAREN (((CX_OPERATORS>>CX_ATTR)+1)<<CX_ATTR)
99
#define CX_INTERNALS (((CX_OPERATORS>>CX_ATTR)+2)<<CX_ATTR)
100
101
#define CX_ADDADD (CX_ADD|CX_X2)
102
#define CX_SUBSUB (CX_SUB|CX_X2)
103
104
#define CX_SCOPE (CX_FLAGS>>1)
105
106
#define CX_VIEW_callouts (1<<0)
107
#define CX_VIEW_constraints (1<<1)
108
#define CX_VIEW_edits (1<<2)
109
#define CX_VIEW_fields (1<<3)
110
#define CX_VIEW_maps (1<<4)
111
#define CX_VIEW_queries (1<<5)
112
#define CX_VIEW_recodes (1<<6)
113
#define CX_VIEW_types (1<<7)
114
#define CX_VIEW_variables (1<<8)
115
116
#define CXH CX_HEADER_INIT
117
#define CXC(o,l,r,f,d) CX_CALLOUT_INIT(o,l,r,f,d)
118
#define CXF(n,t,f,p,d) CX_FUNCTION_INIT(n,t,f,p,d)
119
#define CXR(o,l,r,f,d) CX_RECODE_INIT(o,l,r,f,d)
120
#define CXT(n,b,e,i,m,d) CX_TYPE_INIT(n,b,e,i,m,d)
121
#define CXV(n,t,i,d) CX_VARIABLE_INIT(n,t,i,d)
122
123
struct Cxcompile_s
124
{
125
Cxcompile_t* next;
126
Cx_t* cx;
127
int balanced;
128
int collecting;
129
int paren;
130
int reclaim;
131
unsigned int level;
132
unsigned int depth;
133
unsigned int pp;
134
unsigned int stacksize;
135
Sfio_t* ip;
136
Sfio_t* tp;
137
Sfio_t* xp;
138
Vmalloc_t* vm;
139
Cxdone_t* done;
140
Cxtype_t* type;
141
struct Cxoperand_s* stack;
142
};
143
144
struct Cxdone_s
145
{
146
Cxdone_t* next;
147
Cxdone_f donef;
148
void* data;
149
};
150
151
struct Cxinclude_s
152
{
153
Cxinclude_t* pop;
154
Sfio_t* sp;
155
char* base;
156
char* next;
157
char* last;
158
char* ofile;
159
int eof;
160
int final;
161
int head;
162
int interactive;
163
int newline;
164
int oline;
165
int prompt;
166
int retain;
167
char file[1];
168
};
169
170
typedef struct Cxtable_s
171
{
172
unsigned char opcode[UCHAR_MAX];
173
unsigned char comparison[CX_INTERNALS];
174
unsigned char logical[CX_INTERNALS];
175
unsigned char precedence[CX_INTERNALS];
176
} Cxtable_t;
177
178
extern int cxinitmap(Cxmap_t*, Cxdisc_t*);
179
180
#endif
181
182