Lines Matching defs:ex
43 #define getchr(ex) (*(ex)->nextchr++)
44 #define peekchr(ex) (*(ex)->nextchr)
45 #define ungetchr(ex) ((ex)->nextchr--)
47 #define error(ex,msg) return(seterror(ex,msg))
63 seterror(register Expr_t* ex, char* msg)
65 if (!ex->errmsg) ex->errmsg = msg;
66 ex->errchr = ex->nextchr;
67 ex->nextchr = "";
76 expr(register Expr_t* ex, register int precedence)
84 while (c = getchr(ex), isspace(c));
88 ungetchr(ex);
90 error(ex, "more tokens expected");
92 n = -expr(ex, 13);
95 n = expr(ex, 13);
98 n = !expr(ex, 13);
101 n = ~expr(ex, 13);
104 ungetchr(ex);
111 switch (c = getchr(ex))
116 if (!precedence) error(ex, "too many )'s");
119 n = expr(ex, 1);
120 if (getchr(ex) != ')')
122 ungetchr(ex);
123 error(ex, "closing ) expected");
126 if (operand) error(ex, "operator expected");
131 if (peekchr(ex) == ':')
133 getchr(ex);
134 x = expr(ex, 2);
139 x = expr(ex, 2);
140 if (getchr(ex) != ':')
142 ungetchr(ex);
143 error(ex, ": expected for ? operator");
148 expr(ex, 2);
150 else n = expr(ex, 2);
156 if (peekchr(ex) == '|')
159 getchr(ex);
160 x = expr(ex, 3);
166 x = expr(ex, 5);
172 x = expr(ex, 6);
176 if (peekchr(ex) == '&')
179 getchr(ex);
180 x = expr(ex, 4);
186 x = expr(ex, 7);
192 if (peekchr(ex) != '=') error(ex, "operator syntax error");
194 getchr(ex);
195 x = expr(ex, 8);
201 if (peekchr(ex) == c)
204 getchr(ex);
205 x = expr(ex, 10);
212 if (peekchr(ex) == '=')
214 getchr(ex);
215 x = expr(ex, 9);
221 x = expr(ex, 9);
230 x = expr(ex, 11);
238 x = expr(ex, 12);
240 else if (x == 0) error(ex, "divide by zero");
246 pos = --ex->nextchr;
247 if (isdigit(c)) n = strton(ex->nextchr, &ex->nextchr, NiL, 0);
248 else if (ex->convert) n = (*ex->convert)(ex->nextchr, &ex->nextchr, ex->handle);
249 if (ex->nextchr == pos) error(ex, "syntax error");
252 if (ex->errmsg) return(0);
253 if (!operand) error(ex, "operand expected");
256 ungetchr(ex);
257 if (!operand) error(ex, "operand expected");
270 * NOTE: (*convert)() may call strexpr(ex, )
277 Expr_t ex;
279 ex.nextchr = (char*)s;
280 ex.errmsg = 0;
281 ex.convert = convert;
282 ex.handle = handle;
283 n = expr(&ex, 0);
284 if (peekchr(&ex) == ':')
285 seterror(&ex, "invalid use of :");
286 if (ex.errmsg)
288 if (convert) (*convert)(NiL, &ex.errmsg, handle);
289 ex.nextchr = ex.errchr;
292 if (end) *end = ex.nextchr;