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 #ifndef DAVQLPARSER_H
30 #define DAVQLPARSER_H
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #include <stdint.h>
37 #include <cx/string.h>
38 #include <cx/list.h>
39
40
41
42
43 typedef enum {
DAVQL_ERROR,
DAVQL_SELECT,
DAVQL_SET}
davqltype_t;
44
45
46
47
48 typedef enum {
49 DAVQL_TOKEN_INVALID,
DAVQL_TOKEN_KEYWORD,
50 DAVQL_TOKEN_IDENTIFIER,
DAVQL_TOKEN_FMTSPEC,
51 DAVQL_TOKEN_STRING,
DAVQL_TOKEN_NUMBER,
DAVQL_TOKEN_TIMESTAMP,
52 DAVQL_TOKEN_COMMA,
DAVQL_TOKEN_OPENP,
DAVQL_TOKEN_CLOSEP,
53 DAVQL_TOKEN_OPERATOR,
DAVQL_TOKEN_END
54 }
davqltokenclass_t;
55
56
57
58
59 typedef enum {
60 DAVQL_UNDEFINED_TYPE,
61 DAVQL_NUMBER,
DAVQL_STRING,
DAVQL_TIMESTAMP,
DAVQL_IDENTIFIER,
62 DAVQL_UNARY,
DAVQL_BINARY,
DAVQL_LOGICAL,
DAVQL_FUNCCALL
63 }
davqlexprtype_t;
64
65
66
67
68 typedef enum {
69 DAVQL_NOOP,
DAVQL_CALL,
DAVQL_ARGLIST,
70 DAVQL_ADD,
DAVQL_SUB,
DAVQL_MUL,
DAVQL_DIV,
71 DAVQL_AND,
DAVQL_OR,
DAVQL_XOR,
DAVQL_NEG,
72 DAVQL_NOT,
DAVQL_LAND,
DAVQL_LOR,
DAVQL_LXOR,
73 DAVQL_EQ,
DAVQL_NEQ,
DAVQL_LT,
DAVQL_GT,
DAVQL_LE,
DAVQL_GE,
74 DAVQL_LIKE,
DAVQL_UNLIKE
75 }
davqloperator_t;
76
77 typedef struct DavQLToken DavQLToken;
78 struct DavQLToken {
79 davqltokenclass_t tokenclass;
80 cxstring value;
81 DavQLToken *prev;
82 DavQLToken *next;
83 };
84
85
86
87
88 typedef struct _davqlexpr DavQLExpression;
89
90
91
92
93 struct _davqlexpr {
94
95
96
97
98 cxstring srctext;
99
100
101
102 davqlexprtype_t type;
103
104
105
106 davqloperator_t op;
107
108
109
110
111 DavQLExpression *left;
112
113
114
115
116 DavQLExpression *right;
117 };
118
119
120
121
122 typedef struct {
123