Go to the documentation of this file.
43 if (isalpha(source) || isdigit(source) || source ==
'.') {
45 }
else if (strchr(
"=+-/*^", source)) {
47 }
else if (strchr(
",()", source)) {
67 if (isalpha(source)) {
69 }
else if (isdigit(source) || source ==
'.') {
91 }
else if (source ==
'+') {
93 }
else if (source ==
'-') {
95 }
else if (source ==
'*') {
97 }
else if (source ==
'/') {
99 }
else if (source ==
'^') {
121 }
else if (source ==
'(') {
123 }
else if (source ==
')') {
156 char* lowercase_keyword = NULL;
157 char* keyword_occurrence = NULL;
158 uint8_t keyword_occurrence_position;
161 while ((keyword_occurrence = strstr(lowercase_buffer,
"pi")) != NULL) {
162 keyword_occurrence_position = keyword_occurrence - lowercase_buffer;
164 lowercase_buffer[keyword_occurrence_position] =
'~';
165 lowercase_buffer[keyword_occurrence_position + 1] =
'~';
172 if ((keyword_occurrence = strstr(lowercase_buffer, lowercase_keyword)) != NULL) {
173 if (strlen(keyword_occurrence) != strlen(
keyword_strings[i]))
continue;
182 for (j = 0; j < keyword_occurrence_position; j++) {
183 if (lowercase_buffer[j] !=
'~') {
210 if (source[0] ==
'-') {
215 for ( ; isdigit(source[i]); i++) {
216 a = 10 * a + (source[i] -
'0');
220 if (source[i] ==
'.') {
222 for (i = i + 1; isdigit(source[i]); i++) {
223 b = 10 * b + (source[i] -
'0');
246 uint8_t buffer_position = 0;
249 buffer[buffer_position++] = source[(*index)++];
252 buffer[buffer_position] =
'\0';
297 for (i = 0; query[i] !=
'\0'; i++) {
299 if (query[i] ==
' ')
continue;
324 int8_t open_parentheses = 0;
339 if (tuple[0] == tuple[1])
continue;
359 if (tuple[0] == tuple[1] && i == 0)
continue;
378 uint8_t child_count = 0;
397 for (i = 0; i < child_count; i++) {
void parse_control_expression(expression *tokens, uint8_t *index, expression *output_stack, expression *operator_stack)
uint8_t validate(expression *tokens)
void tokenize_control_expression(expression *tokens, char source)
expression_identifier identifier
void smart_free(void *pointer)
Frees a pointer.
expression_identifier get_operator_identifier(char source)
Determines the expression identifier of a character of the type EXPT_OPERATION.
#define ERROR_CHECK(F)
Check if the return status of a function is RETS_ERROR. If so, return RETS_ERROR.
expression * new_symbol(expression_identifier identifier, const char *value)
Allocates and initializes a new symbol/variable expression.
union expression::@0 value
void merge_expressions_with_operator(expression *output_stack, expression *operator_stack)
char * string_to_lower(const char *string)
Converts a string to lowercase.
void free_expression(expression *source, bool persistent)
uint8_t string_to_literal(expression **result, const char *source)
uint8_t set_error(error_domain domain, error_identifier identifier, const char *body)
Sets current_error to the arguments provided.
uint8_t tokenize_value_expression(expression *tokens, uint8_t *index, const char *source)
uint8_t tokenize(expression *tokens, const char *query)
void append_multiplication_if_necessary(expression *tokens)
Appends a multiplication expression if necessary.
expression_identifier get_control_identifier(char source)
Determines the expression identifier of a character of the type EXPT_CONTROL.
expression * copy_expression(const expression *source)
Returns a deep copy of an expression.
expression_identifier get_value_identifier(char source)
Determines the expression identifier of a character of the type EXPT_VALUE.
uint8_t simplify(expression *source, bool recursive)
void append_child(expression *parent, expression *child)
Appends a child to an expression.
expression * new_expression(expression_type type, expression_identifier identifier, uint8_t child_count,...)
Allocates and initializes a new expression with the arguments provided.
uint8_t tokenize_buffer(expression *tokens, char *buffer)
expression_type get_expression_type(char source)
Determines the expression type of a character.
expression_identifier keyword_identifiers[]
expression * new_literal(int8_t sign, uintmax_t numerator, uintmax_t denominator)
Allocates and initializes a new literal expression.
void tokenize_operator_expression(expression *tokens, char source)
struct expression ** children
void parse(expression *tokens)