Mathematic Expressions Library  0.1
The core math data structures and manipulators
types.h
Go to the documentation of this file.
1 
10 #ifndef TYPES_H_INCLUDED
11 #define TYPES_H_INCLUDED
12 
13 #include <stddef.h> /* size_t */
14 #include <limits.h> // for LONG_MIN
15 #include <ctype.h> // character handling functions - isalpha(), isdigit(), isspace()
16 
17 
18 /*---------------------------------------------*
19  * System Integration *
20  *---------------------------------------------*/
21 typedef int long sys_int_long;
22 #define SYS_INT_LONG_T_MIN LONG_MIN
23 #define SYS_INT_LONG_T_MAX LONG_MAX
24 #define SYS_INT_LONG_T_STR_SIZE 11
26 
27 #define SIZE_T_MAX ( ~( (size_t) (0) ) )
28 #define PINDEX_MAX SIZE_T_MAX
29 #define PINDEX_BAD PINDEX_MAX
30 typedef size_t pindex_t;
31 typedef size_t pcount_t;
32 
33 #define IS_WHITESPACE(c) ( ((c) == ' ') || ((c) == '\t') )
34 #define IS_DIGIT(c) ( ( '0' <= (c) ) && ( (c) <= '9') )
35 #define IS_ALPHA(c) isalpha(c)
36 #define IS_ALNUM(c) isalnum(c)
37 
38 
39 /*---------------------------------------------*
40  * values *
41  *---------------------------------------------*/
42 
51 };
52 
56 union value_data {
58 };
59 
64 struct value {
65  enum value_types type;
66  union value_data data;
67 };
68 typedef struct value value_t;
69 
70 value_t
72 
73 value_t
75 
76 value_t
77 string_to_value(size_t src_str_len, char const *src_str);
78 
79 void
80 value_to_string (char *dst_str, value_t src_val);
81 
82 
83 /*---------------------------------------------*
84  * misc *
85  *---------------------------------------------*/
86 
88 find_matching (size_t str_len,
89  const char *str,
90  pindex_t start);
91 
92 #endif /* TYPES_H_INCLUDED */
93 
94 /* vim: set ts=4 sw=4 expandtab: */
value_t value_new_lint(sys_int_long lint)
Definition: types.c:30
value_types
value type selector
Definition: types.h:46
Definition: types.h:47
Definition: types.h:48
enum value_types type
Definition: types.h:65
value_t value_new_type(enum value_types type)
Definition: types.c:23
void value_to_string(char *dst_str, value_t src_val)
Definition: types.c:68
Definition: types.h:49
value data container provider
Definition: types.h:56
Represents a numeric value or an error.
Definition: types.h:64
int long sys_int_long
Definition: types.h:21
Definition: types.h:50
pindex_t find_matching(size_t str_len, const char *str, pindex_t start)
Find the index of the matching closing paren in a string.
Definition: types.c:103
value_t string_to_value(size_t src_str_len, char const *src_str)
Create value from a string.
Definition: types.c:46
sys_int_long lint
Definition: types.h:57
size_t pindex_t
Type for an index into an expression string during parsing.
Definition: types.h:30