Lines Matching refs:cp
76 parse_variable (g, cp, varp) in parse_variable() argument
78 const char *cp;
81 SKIPSPACE (cp);
83 if (!isvarfirstletter (*cp))
84 return CALLFUNC(g, handle_error) (g, cp, "variable name");
86 *varp = cp;
88 for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;
89 return cp;
94 parse_number (g, cp, valp) in parse_number() argument
96 const char *cp;
99 SKIPSPACE (cp);
101 if (!isdigit(*cp))
102 return CALLFUNC(g, handle_error) (g, cp, "number");
105 *valp = strtol(cp, &cp, 0);
107 *valp = atoi (cp);
109 for (cp++; isdigit(*cp); cp++) ;
111 return cp;
116 parse_value (g, cp, valp) in parse_value() argument
118 const char *cp;
125 SKIPSPACE (cp);
126 if (!*cp)
127 return cp;
129 switch (*cp) {
131 DO (cp = ParseIfExpression (g, cp + 1, valp));
132 SKIPSPACE (cp);
133 if (*cp != ')')
134 return CALLFUNC(g, handle_error) (g, cp, ")");
136 return cp + 1; /* skip the right paren */
139 DO (cp = parse_value (g, cp + 1, valp));
141 return cp;
144 DO (cp = parse_value (g, cp + 1, valp));
146 return cp;
149 DO (cp = parse_variable (g, cp + 1, &var));
150 SKIPSPACE (cp);
151 if (*cp != '(')
152 return CALLFUNC(g, handle_error) (g, cp, "(");
154 DO (cp = parse_variable (g, cp + 1, &var));
155 SKIPSPACE (cp);
156 } while (*cp && *cp != ')');
157 if (*cp != ')')
158 return CALLFUNC(g, handle_error) (g, cp, ")");
160 return cp + 1;
163 if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {
167 cp += 7;
168 SKIPSPACE (cp);
169 if (*cp == '(') {
171 cp++;
173 DO (cp = parse_variable (g, cp, &var));
174 len = cp - var;
175 SKIPSPACE (cp);
176 if (paren && *cp != ')')
177 return CALLFUNC(g, handle_error) (g, cp, ")");
179 return cp + paren; /* skip the right paren */
184 if (isdigit(*cp)) {
185 DO (cp = parse_number (g, cp, valp));
186 } else if (!isvarfirstletter(*cp))
187 return CALLFUNC(g, handle_error) (g, cp, "variable or number");
189 DO (cp = parse_variable (g, cp, &var));
190 *valp = (*(g->funcs.eval_variable)) (g, var, cp - var);
193 return cp;
199 parse_product (g, cp, valp) in parse_product() argument
201 const char *cp;
206 DO (cp = parse_value (g, cp, valp));
207 SKIPSPACE (cp);
209 switch (*cp) {
211 DO (cp = parse_product (g, cp + 1, &rightval));
216 DO (cp = parse_product (g, cp + 1, &rightval));
225 DO (cp = parse_product (g, cp + 1, &rightval));
229 return cp;
234 parse_sum (g, cp, valp) in parse_sum() argument
236 const char *cp;
241 DO (cp = parse_product (g, cp, valp));
242 SKIPSPACE (cp);
244 switch (*cp) {
246 DO (cp = parse_sum (g, cp + 1, &rightval));
251 DO (cp = parse_sum (g, cp + 1, &rightval));
255 return cp;
260 parse_shift (g, cp, valp) in parse_shift() argument
262 const char *cp;
267 DO (cp = parse_sum (g, cp, valp));
268 SKIPSPACE (cp);
270 switch (*cp) {
272 if (cp[1] == '<') {
273 DO (cp = parse_shift (g, cp + 2, &rightval));
279 if (cp[1] == '>') {
280 DO (cp = parse_shift (g, cp + 2, &rightval));
285 return cp;
290 parse_inequality (g, cp, valp) in parse_inequality() argument
292 const char *cp;
297 DO (cp = parse_shift (g, cp, valp));
298 SKIPSPACE (cp);
300 switch (*cp) {
302 if (cp[1] == '=') {
303 DO (cp = parse_inequality (g, cp + 2, &rightval));
306 DO (cp = parse_inequality (g, cp + 1, &rightval));
312 if (cp[1] == '=') {
313 DO (cp = parse_inequality (g, cp + 2, &rightval));
316 DO (cp = parse_inequality (g, cp + 1, &rightval));
321 return cp;
326 parse_equality (g, cp, valp) in parse_equality() argument
328 const char *cp;
333 DO (cp = parse_inequality (g, cp, valp));
334 SKIPSPACE (cp);
336 switch (*cp) {
338 if (cp[1] == '=')
339 cp++;
340 DO (cp = parse_equality (g, cp + 1, &rightval));
345 if (cp[1] != '=')
347 DO (cp = parse_equality (g, cp + 2, &rightval));
351 return cp;
356 parse_band (g, cp, valp) in parse_band() argument
358 const char *cp;
363 DO (cp = parse_equality (g, cp, valp));
364 SKIPSPACE (cp);
366 switch (*cp) {
368 if (cp[1] != '&') {
369 DO (cp = parse_band (g, cp + 1, &rightval));
374 return cp;
379 parse_bor (g, cp, valp) in parse_bor() argument
381 const char *cp;
386 DO (cp = parse_band (g, cp, valp));
387 SKIPSPACE (cp);
389 switch (*cp) {
391 if (cp[1] != '|') {
392 DO (cp = parse_bor (g, cp + 1, &rightval));
397 return cp;
402 parse_land (g, cp, valp) in parse_land() argument
404 const char *cp;
409 DO (cp = parse_bor (g, cp, valp));
410 SKIPSPACE (cp);
412 switch (*cp) {
414 if (cp[1] != '&')
415 return CALLFUNC(g, handle_error) (g, cp, "&&");
416 DO (cp = parse_land (g, cp + 2, &rightval));
420 return cp;
425 parse_lor (g, cp, valp) in parse_lor() argument
427 const char *cp;
432 DO (cp = parse_land (g, cp, valp));
433 SKIPSPACE (cp);
435 switch (*cp) {
437 if (cp[1] != '|')
438 return CALLFUNC(g, handle_error) (g, cp, "||");
439 DO (cp = parse_lor (g, cp + 2, &rightval));
443 return cp;
452 ParseIfExpression (g, cp, valp) in ParseIfExpression() argument
454 const char *cp;
457 return parse_lor (g, cp, valp);