mirror of
				https://github.com/eledio-devices/thirdparty-tinyexpr.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Added closures. Refactoring.
This commit is contained in:
		| @@ -41,8 +41,10 @@ typedef struct te_expr { | ||||
|  | ||||
| enum { | ||||
|     TE_VARIABLE = 0, | ||||
|     TE_FUNCTION0, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3, | ||||
|     TE_FUNCTION4, TE_FUNCTION5, TE_FUNCTION6, TE_FUNCTION7 | ||||
|     TE_FUNCTION0 = 2, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3, | ||||
|     TE_FUNCTION4, TE_FUNCTION5, TE_FUNCTION6, TE_FUNCTION7, | ||||
|     TE_CLOSURE0, TE_CLOSURE1, TE_CLOSURE2, TE_CLOSURE3, | ||||
|     TE_CLOSURE4, TE_CLOSURE5, TE_CLOSURE6, TE_CLOSURE7 | ||||
| }; | ||||
|  | ||||
| typedef struct te_variable { | ||||
| @@ -64,6 +66,9 @@ te_expr *te_compile(const char *expression, const te_variable *variables, int va | ||||
| /* Evaluates the expression. */ | ||||
| double te_eval(const te_expr *n); | ||||
|  | ||||
| /* Evaluates the expression while passing a closure to any bound closure functions. */ | ||||
| double te_eval_closure(const te_expr *n, void *context); | ||||
|  | ||||
| /* Prints debugging information on the syntax tree. */ | ||||
| void te_print(const te_expr *n); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user