| 689 | |
| 690 | |
| 691 | te_expr *te_compile(const char *expression, const te_variable *variables, int var_count, int *error) { |
| 692 | state s; |
| 693 | s.start = s.next = expression; |
| 694 | s.lookup = variables; |
| 695 | s.lookup_len = var_count; |
| 696 | |
| 697 | next_token(&s); |
| 698 | te_expr *root = list(&s); |
| 699 | if (root == NULL) { |
| 700 | if (error) *error = -1; |
| 701 | return NULL; |
| 702 | } |
| 703 | |
| 704 | if (s.type != TOK_END) { |
| 705 | te_free(root); |
| 706 | if (error) { |
| 707 | *error = (s.next - s.start); |
| 708 | if (*error == 0) *error = 1; |
| 709 | } |
| 710 | return 0; |
| 711 | } else { |
| 712 | optimize(root); |
| 713 | if (error) *error = 0; |
| 714 | return root; |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | |
| 719 | double te_interp(const char *expression, int *error) { |
no test coverage detected