Mercurial > hg-old > index.cgi
comparison src/expr.c @ 61:73423b66e511
Fixed error with single char ascii constants
author | lost |
---|---|
date | Mon, 05 Jan 2009 00:57:14 +0000 |
parents | 804d7465e0f9 |
children | 2fe5fd7d65a3 |
comparison
equal
deleted
inserted
replaced
60:309810f39ab7 | 61:73423b66e511 |
---|---|
183 { | 183 { |
184 lwasm_expr_term_t *t; | 184 lwasm_expr_term_t *t; |
185 debug_message(2, "Expression string %s", *p); | 185 debug_message(2, "Expression string %s", *p); |
186 | 186 |
187 eval_next: | 187 eval_next: |
188 if (!**p || isspace(**p) || **p == ')' || **p == ']') | |
189 return -1; | |
188 if (**p == '(') | 190 if (**p == '(') |
189 { | 191 { |
190 debug_message(3, "Starting paren"); | 192 debug_message(3, "Starting paren"); |
191 (*p)++; | 193 (*p)++; |
192 lwasm_expr_parse_expr(s, p, 0); | 194 lwasm_expr_parse_expr(s, p, 0); |
302 else if (**p == '\'') | 304 else if (**p == '\'') |
303 { | 305 { |
304 // single ascii constant | 306 // single ascii constant |
305 int val; | 307 int val; |
306 (*p)++; | 308 (*p)++; |
309 debug_message(3, "Single ascii character constant '%c'", **p); | |
307 if (!**p) | 310 if (!**p) |
308 return -1; | 311 return -1; |
309 val = **p; | 312 val = **p; |
310 (*p)++; | 313 (*p)++; |
311 t = lwasm_expr_term_create_int(val); | 314 t = lwasm_expr_term_create_int(val); |
312 lwasm_expr_stack_push(s, t); | 315 lwasm_expr_stack_push(s, t); |
313 lwasm_expr_term_free(t); | 316 lwasm_expr_term_free(t); |
317 return 0; | |
314 } | 318 } |
315 else if (**p == '&') | 319 else if (**p == '&') |
316 { | 320 { |
317 // decimal constant | 321 // decimal constant |
318 int val = 0; | 322 int val = 0; |
580 }; | 584 }; |
581 int opern, i; | 585 int opern, i; |
582 lwasm_expr_term_t *operterm; | 586 lwasm_expr_term_t *operterm; |
583 | 587 |
584 // return if we are at the end of the expression or a subexpression | 588 // return if we are at the end of the expression or a subexpression |
585 if (!**p || isspace(**p) || **p == ')' || **p == ',') | 589 if (!**p || isspace(**p) || **p == ')' || **p == ',' || **p == ']') |
586 return 0; | 590 return 0; |
587 | 591 |
588 if (lwasm_expr_parse_term(s, p) < 0) | 592 if (lwasm_expr_parse_term(s, p) < 0) |
589 return -1; | 593 return -1; |
590 | 594 |
591 eval_next: | 595 eval_next: |
592 if (!**p || isspace(**p) || **p == ')' || **p == ',') | 596 if (!**p || isspace(**p) || **p == ')' || **p == ',' || **p == ']') |
593 return 0; | 597 return 0; |
594 | 598 |
595 // expecting an operator here | 599 // expecting an operator here |
596 for (opern = 0; operators[opern].opernum != LWASM_OPER_NONE; opern++) | 600 for (opern = 0; operators[opern].opernum != LWASM_OPER_NONE; opern++) |
597 { | 601 { |