| 663 | |
| 664 | |
| 665 | te_expr *te_compile(const char *expression, const te_variable *variables, int var_count, int *error) { |
| 666 | state s; |
| 667 | s.start = s.next = expression; |
| 668 | s.lookup = variables; |
| 669 | s.lookup_len = var_count; |
| 670 | |
| 671 | next_token(&s); |
| 672 | te_expr *root = list(&s); |
| 673 | if (root == NULL) { |
| 674 | if (error) *error = -1; |
| 675 | return NULL; |
| 676 | } |
| 677 | |
| 678 | if (s.type != TOK_END) { |
| 679 | te_free(root); |
| 680 | if (error) { |
| 681 | *error = (s.next - s.start); |
| 682 | if (*error == 0) *error = 1; |
| 683 | } |
| 684 | return 0; |
| 685 | } else { |
| 686 | optimize(root); |
| 687 | if (error) *error = 0; |
| 688 | return root; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | |
| 693 | double te_interp(const char *expression, int *error) { |
no test coverage detected