-
Notifications
You must be signed in to change notification settings - Fork 5
/
eval.h
48 lines (43 loc) · 1.17 KB
/
eval.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* # eval.h
* A mathematical expression evaluator.
*
* It uses a recursive descent parser internally.
*
* ### License
*
* Author: Werner Stoop
* This software is provided under the terms of the unlicense.
* See http://unlicense.org/ for more details.
*
* ## API
*/
#ifndef EVAL_H
#define EVAL_H
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
/**
* #### `double eval(const char *expr, int *ep)`
* Evaluates a mathematical expression.
*
* * `expr` is the expression to valuate.
* * `ep` is a pointer to an integer that will contain an error code if
* any errors were encountered during parsing. `ep` will be 0 if
* the evaluation was successful.
*
* It returns the result of evaluating the expression.
*/
double eval(const char *expr, int *ep);
/**
* #### `const char *eval_error(int err)`
* Returns a string describing a specific error code.
*
* `err` is the value returned in `eval()`'s `ep` parameter.
* It returns a string describing the error.
*/
const char *eval_error(int err);
#if defined(__cplusplus) || defined(c_plusplus)
} /* extern "C" */
#endif
#endif /* EVAL_H */