| 587 | |
| 588 | |
| 589 | te_expr *te_compile(const char *expression, const te_variable *variables, int var_count, int *error) { |
| 590 | state s; |
| 591 | s.start = s.next = expression; |
| 592 | s.lookup = variables; |
| 593 | s.lookup_len = var_count; |
| 594 | |
| 595 | next_token(&s); |
| 596 | te_expr *root = list(&s); |
| 597 | |
| 598 | if (s.type != TOK_END) { |
| 599 | te_free(root); |
| 600 | if (error) { |
| 601 | *error = (s.next - s.start); |
| 602 | if (*error == 0) *error = 1; |
| 603 | } |
| 604 | return 0; |
| 605 | } else { |
| 606 | optimize(root); |
| 607 | if (error) *error = 0; |
| 608 | return root; |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | |
| 613 | double te_interp(const char *expression, int *error) { |