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