1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef PARSE_CTX_H 3 #define PARSE_CTX_H 1 4 5 #define EXPR_MAX_OTHER 20 6 #define MAX_PARSE_ID EXPR_MAX_OTHER 7 8 struct expr_parse_id { 9 const char *name; 10 double val; 11 }; 12 13 struct expr_parse_ctx { 14 int num_ids; 15 struct expr_parse_id ids[MAX_PARSE_ID]; 16 }; 17 18 struct expr_scanner_ctx { 19 int start_token; 20 int runtime; 21 }; 22 23 void expr__ctx_init(struct expr_parse_ctx *ctx); 24 void expr__add_id(struct expr_parse_ctx *ctx, const char *id, double val); 25 int expr__parse(double *final_val, struct expr_parse_ctx *ctx, const char *expr, int runtime); 26 int expr__find_other(const char *expr, const char *one, const char ***other, 27 int *num_other, int runtime); 28 29 #endif 30