Mathematic Expressions Library  0.1
The core math data structures and manipulators
expression.h
Go to the documentation of this file.
1 
7 #ifndef EXPRESSION_H_INCLUDED
8 #define EXPRESSION_H_INCLUDED
9 
10 #include <stddef.h> /* size_t */
11 
12 #include "types.h"
13 #include "symbolic.h"
14 #include "expression_lite.h" /* expression_t only exists in expression_lite.h */
15 
16 /*---------------------------------------------*
17  * Misc. String Buffer Definitions *
18  *---------------------------------------------*/
19 #define EXP_BUF_SIZE 256
20 typedef char exp_buf[EXP_BUF_SIZE];
21 
22 
23 /*---------------------------------------------*
24  * expression tree structure *
25  *---------------------------------------------*/
26 /* The tree operation element for the expression structure */
34  char op; // '+', '-', '*', or '/'
37 };
38 
39 
40 /*---------------------------------------------*
41  * expression components *
42  *---------------------------------------------*/
43 
49 // EXP_UNDEF, ///< \note Might remove
53 };
54 
60  struct expression_data_tree tree;
62 };
63 
64 /*---------------------------------------------*
65  * expression structure *
66  *---------------------------------------------*/
71 struct expression {
73  enum expression_type type;
74  union expression_data data;
75 };
76 
77 /*---------------------------------------------*
78  * expression_t allocation functions *
79  *---------------------------------------------*/
80 
82 expression_new (void);
83 
86 
91 
94 
95 void
97 
98 
99 /*---------------------------------------------*
100  * expression_t manipulation functions *
101  *---------------------------------------------*/
102 
103 value_t
105 
106 void
107 expression_to_string (char *dst_str,
108  expression_t src_exp);
109 
111 string_to_expression (size_t str_len,
112  char const *str);
113 
114 #endif // EXPRESSION_H_INCLUDED
115 
116 /* vim: set ts=4 sw=4 expandtab: */
expression_t left
Left sub-expression.
Definition: expression.h:35
A named symbol type.
Definition: symbolic.h:28
expression_t expression_new(void)
New blank expression.
Definition: expression.c:27
void expression_to_string(char *dst_str, expression_t src_exp)
Expression to String.
Definition: expression.c:133
char op
The joining operation of the two two sub expressions.
Definition: expression.h:34
An expression over an operation and sub-expression.
Definition: expression.h:51
expression_t expression_new_tree(char op, expression_t left, expression_t right)
Definition: expression.c:42
Contains a simple numeric values and undefines.
Definition: expression.h:50
void expression_free(expression_t exp)
Free an expression.
Definition: expression.c:66
Expression data container for the expanded expression.
Definition: expression.h:30
sym_t sym
Data for EXP_SYMBOLIC type.
Definition: expression.h:61
expression_t right
Right sub-expression.
Definition: expression.h:36
The stored representation of mathematical expressions.
Definition: expression.h:72
expression_type
Expression types.
Definition: expression.h:48
expression_t expression_new_sym(sym_t sym)
Definition: expression.c:55
value_t expression_evaluate(expression_t exp)
Definition: expression.c:88
Represents a numeric value or an error.
Definition: types.h:64
value_t val
Value for EXP_VALUE type.
Definition: expression.h:59
Symbolic named references.
Definition: expression.h:52
#define EXP_BUF_SIZE
Definition: expression.h:19
expression_t string_to_expression(size_t str_len, char const *str)
Convert String to an Expression.
Definition: expression.c:215
expression_t expression_new_value(value_t val)
Definition: expression.c:34
Expression data container.
Definition: expression.h:58
char exp_buf[EXP_BUF_SIZE]
Definition: expression.h:20