MIDAS
Loading...
Searching...
No Matches
tinyexpr.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: Zlib
2
/*
3
* TINYEXPR - Tiny recursive descent parser and evaluation engine in C
4
*
5
* Copyright (c) 2015-2020 Lewis Van Winkle
6
*
7
* http://CodePlea.com
8
*
9
* This software is provided 'as-is', without any express or implied
10
* warranty. In no event will the authors be held liable for any damages
11
* arising from the use of this software.
12
*
13
* Permission is granted to anyone to use this software for any purpose,
14
* including commercial applications, and to alter it and redistribute it
15
* freely, subject to the following restrictions:
16
*
17
* 1. The origin of this software must not be misrepresented; you must not
18
* claim that you wrote the original software. If you use this software
19
* in a product, an acknowledgement in the product documentation would be
20
* appreciated but is not required.
21
* 2. Altered source versions must be plainly marked as such, and must not be
22
* misrepresented as being the original software.
23
* 3. This notice may not be removed or altered from any source distribution.
24
*/
25
26
#ifndef TINYEXPR_H
27
#define TINYEXPR_H
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
typedef
struct
te_expr
{
34
int
type
;
35
union
{
36
double
value
;
37
const
double
*
bound
;
38
const
void
*
function
;
39
};
40
void
*
parameters
[1];
41
}
te_expr
;
42
43
enum
{
44
TE_VARIABLE
= 0,
45
46
TE_FUNCTION0
= 8,
47
TE_FUNCTION1
,
48
TE_FUNCTION2
,
49
TE_FUNCTION3
,
50
TE_FUNCTION4
,
51
TE_FUNCTION5
,
52
TE_FUNCTION6
,
53
TE_FUNCTION7
,
54
55
TE_CLOSURE0
= 16,
56
TE_CLOSURE1
,
57
TE_CLOSURE2
,
58
TE_CLOSURE3
,
59
TE_CLOSURE4
,
60
TE_CLOSURE5
,
61
TE_CLOSURE6
,
62
TE_CLOSURE7
,
63
64
TE_FLAG_PURE
= 32
65
};
66
67
typedef
struct
te_variable
{
68
const
char
*
name
;
69
const
void
*
address
;
70
int
type
;
71
void
*
context
;
72
}
te_variable
;
73
74
/* Parses the input expression, evaluates it, and frees it. */
75
/* Returns NaN on error. */
76
double
te_interp
(
const
char
*
expression
,
int
*error);
77
78
/* Parses the input expression and binds variables. */
79
/* Returns NULL on error. */
80
te_expr
*
te_compile
(
const
char
*
expression
,
const
te_variable
*variables,
int
var_count
,
int
*error);
81
82
/* Evaluates the expression. */
83
double
te_eval
(
const
te_expr
*
n
);
84
85
/* Prints debugging information on the syntax tree. */
86
void
te_print
(
const
te_expr
*
n
);
87
88
/* Frees the expression. */
89
/* This is safe to call on NULL pointers. */
90
void
te_free
(
te_expr
*
n
);
91
92
#ifdef __cplusplus
93
}
94
#endif
95
96
#endif
/*TINYEXPR_H*/
n
DWORD n[4]
Definition
mana.cxx:247
h1_book
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition
rmidas.h:24
te_expr
Definition
tinyexpr.h:33
te_expr::type
int type
Definition
tinyexpr.h:34
te_expr::value
double value
Definition
tinyexpr.h:36
te_expr::bound
const double * bound
Definition
tinyexpr.h:37
te_expr::function
const void * function
Definition
tinyexpr.h:38
te_expr::parameters
void * parameters[1]
Definition
tinyexpr.h:40
te_variable
Definition
tinyexpr.h:67
te_variable::address
const void * address
Definition
tinyexpr.h:69
te_variable::context
void * context
Definition
tinyexpr.h:71
te_variable::name
const char * name
Definition
tinyexpr.h:68
te_variable::type
int type
Definition
tinyexpr.h:70
te_interp
double te_interp(const char *expression, int *error)
Definition
tinyexpr.c:690
te_free
void te_free(te_expr *n)
Definition
tinyexpr.c:128
te_eval
double te_eval(const te_expr *n)
Definition
tinyexpr.c:583
te_compile
te_expr * te_compile(const char *expression, const te_variable *variables, int var_count, int *error)
Definition
tinyexpr.c:665
TE_CLOSURE6
@ TE_CLOSURE6
Definition
tinyexpr.h:61
TE_FUNCTION2
@ TE_FUNCTION2
Definition
tinyexpr.h:48
TE_FUNCTION1
@ TE_FUNCTION1
Definition
tinyexpr.h:47
TE_FUNCTION6
@ TE_FUNCTION6
Definition
tinyexpr.h:52
TE_FLAG_PURE
@ TE_FLAG_PURE
Definition
tinyexpr.h:64
TE_FUNCTION4
@ TE_FUNCTION4
Definition
tinyexpr.h:50
TE_CLOSURE2
@ TE_CLOSURE2
Definition
tinyexpr.h:57
TE_FUNCTION5
@ TE_FUNCTION5
Definition
tinyexpr.h:51
TE_FUNCTION0
@ TE_FUNCTION0
Definition
tinyexpr.h:46
TE_CLOSURE5
@ TE_CLOSURE5
Definition
tinyexpr.h:60
TE_FUNCTION7
@ TE_FUNCTION7
Definition
tinyexpr.h:53
TE_FUNCTION3
@ TE_FUNCTION3
Definition
tinyexpr.h:49
TE_CLOSURE7
@ TE_CLOSURE7
Definition
tinyexpr.h:62
TE_CLOSURE4
@ TE_CLOSURE4
Definition
tinyexpr.h:59
TE_CLOSURE0
@ TE_CLOSURE0
Definition
tinyexpr.h:55
TE_CLOSURE3
@ TE_CLOSURE3
Definition
tinyexpr.h:58
TE_CLOSURE1
@ TE_CLOSURE1
Definition
tinyexpr.h:56
TE_VARIABLE
@ TE_VARIABLE
Definition
tinyexpr.h:44
te_print
void te_print(const te_expr *n)
Definition
tinyexpr.c:739
include
tinyexpr.h
Generated on Sat May 3 2025 05:01:05 for MIDAS by
1.9.8