libamxp  1.4.0
Patterns C Implementation
amxp_expr_priv.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** SPDX-License-Identifier: BSD-2-Clause-Patent
4 **
5 ** SPDX-FileCopyrightText: Copyright (c) 2023 SoftAtHome
6 **
7 ** Redistribution and use in source and binary forms, with or without modification,
8 ** are permitted provided that the following conditions are met:
9 **
10 ** 1. Redistributions of source code must retain the above copyright notice,
11 ** this list of conditions and the following disclaimer.
12 **
13 ** 2. Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each copyright holder
18 ** and contributor hereby grants to those receiving rights under this license
19 ** a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
20 ** (except for failure to satisfy the conditions of this license) patent license
21 ** to make, have made, use, offer to sell, sell, import, and otherwise transfer
22 ** this software, where such license applies only to those patent claims, already
23 ** acquired or hereafter acquired, licensable by such copyright holder or contributor
24 ** that are necessarily infringed by:
25 **
26 ** (a) their Contribution(s) (the licensed copyrights of copyright holders and
27 ** non-copyrightable additions of contributors, in source or binary form) alone;
28 ** or
29 **
30 ** (b) combination of their Contribution(s) with the work of authorship to which
31 ** such Contribution(s) was added by such copyright holder or contributor, if,
32 ** at the time the Contribution is added, such addition causes such combination
33 ** to be necessarily infringed. The patent license shall not apply to any other
34 ** combinations which include the Contribution.
35 **
36 ** Except as expressly stated above, no rights or licenses from any copyright
37 ** holder or contributor is granted under this license, whether expressly, by
38 ** implication, estoppel or otherwise.
39 **
40 ** DISCLAIMER
41 **
42 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
51 ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 **
53 ****************************************************************************/
54 
55 #if !defined(__AMXP_EXPR_PRIV_H__)
56 #define __AMXO_EXPR_PRIV_H__
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #include <amxc/amxc_macros.h>
64 #include <amxp/amxp_expression.h>
65 
67  token_eof
68 };
69 
70 typedef struct _amxp_txt {
71  char* txt;
72  int length;
74 
75 typedef enum _amxp_expr_node_type {
85 
86 typedef enum _amxp_expr_comp {
100 
102  amxc_llist_it_t it;
105  amxc_var_t* value;
106  union {
108  amxc_var_t* value;
109  char* func_name;
110  char* field;
111  } left;
112  union {
114  amxc_llist_t args;
115  } right;
116 };
117 
118 PRIVATE
120 
121 PRIVATE
123 
124 PRIVATE
125 void amxp_expr_msg(amxp_expr_t* expr, const char* format, ...) \
126  __attribute__ ((format(printf, 2, 3)));
127 
128 PRIVATE
129 int amxp_expr_printf(const char* format, ...) \
130  __attribute__ ((format(printf, 1, 2)));
131 
132 PRIVATE
133 bool amxp_expr_compare(amxp_expr_t* expr,
134  amxc_var_t* lvalue,
135  amxc_var_t* rvalue,
136  amxp_expr_comp_t comperator);
137 
138 PRIVATE
140  const char* func,
141  amxc_var_t* args,
142  amxc_var_t* ret);
143 
144 PRIVATE
146  const char* func,
147  amxc_var_t* args);
148 
149 PRIVATE
151  amxc_var_t* var,
152  const char* path);
153 
154 
155 PRIVATE
157 
158 PRIVATE
160 
161 PRIVATE
162 void amxp_expr_node_push(amxc_lstack_t* stack, amxp_expr_node_t* node);
163 
164 PRIVATE
165 amxp_expr_node_t* amxp_expr_node_pop(amxc_lstack_t* stack);
166 
167 PRIVATE
169 
170 PRIVATE
172 
173 PRIVATE
174 void amxp_expr_node_set_value(amxp_expr_node_t* node, amxc_var_t* value);
175 
176 PRIVATE
177 void amxp_expr_node_set_function(amxp_expr_node_t* node, char* func_name);
178 
179 PRIVATE
180 void amxp_expr_node_set_field(amxp_expr_node_t* node, char* field);
181 
182 PRIVATE
184 
185 PRIVATE
187 
188 PRIVATE
190 
191 PRIVATE
192 amxc_var_t* amxp_expr_node_get_value(amxp_expr_t* expr, amxp_expr_node_t* node);
193 
194 PRIVATE
196 
197 PRIVATE
198 void amxp_expr_node_dump(amxp_expr_t* expr, amxp_expr_node_t* node, uint32_t level, uint32_t parent_id);
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif // __AMXP_EXPR_PRIV_H__
205 
PRIVATE void amxp_expr_node_new(amxp_expr_node_t **node, amxp_expr_node_type_t type)
PRIVATE void amxp_expr_msg(amxp_expr_t *expr, const char *format,...) __attribute__((format(printf
PRIVATE void amxp_expr_create_lex(amxp_expr_t *expr)
PRIVATE void amxp_expr_node_set_left(amxp_expr_node_t *node, amxp_expr_node_t *left)
PRIVATE void amxp_expr_node_push(amxc_lstack_t *stack, amxp_expr_node_t *node)
PRIVATE void amxp_expr_node_set_right(amxp_expr_node_t *node, amxp_expr_node_t *right)
struct _amxp_txt amxp_txt_t
PRIVATE void amxp_expr_node_set_compop(amxp_expr_node_t *node, amxp_expr_comp_t comop)
PRIVATE amxp_expr_node_t * amxp_expr_get_node(amxp_expr_t *expr)
enum _amxp_expr_node_type amxp_expr_node_type_t
amxp_expr_tokens_t
@ token_eof
PRIVATE void amxp_expr_node_set_field(amxp_expr_node_t *node, char *field)
PRIVATE void PRIVATE int PRIVATE bool amxp_expr_compare(amxp_expr_t *expr, amxc_var_t *lvalue, amxc_var_t *rvalue, amxp_expr_comp_t comperator)
enum _amxp_expr_comp amxp_expr_comp_t
PRIVATE void amxp_expr_node_delete(amxp_expr_node_t **node)
PRIVATE amxp_expr_status_t amxp_expr_call_value_func(amxp_expr_t *expr, const char *func, amxc_var_t *args, amxc_var_t *ret)
_amxp_expr_node_type
@ amxp_expr_value
@ amxp_expr_bool_func
@ amxp_expr_or
@ amxp_expr_not
@ amxp_expr_compare_oper
@ amxp_expr_value_func
@ amxp_expr_field
@ amxp_expr_and
PRIVATE void amxp_expr_node_set_function(amxp_expr_node_t *node, char *func_name)
PRIVATE void PRIVATE int amxp_expr_printf(const char *format,...) __attribute__((format(printf
PRIVATE void amxp_expr_node_dump(amxp_expr_t *expr, amxp_expr_node_t *node, uint32_t level, uint32_t parent_id)
PRIVATE void amxp_expr_node_add_value(amxp_expr_node_t *node, amxp_expr_node_t *value)
PRIVATE amxc_var_t * amxp_expr_node_get_value(amxp_expr_t *expr, amxp_expr_node_t *node)
PRIVATE amxp_expr_status_t amxp_expr_get_field(amxp_expr_t *expr, amxc_var_t *var, const char *path)
PRIVATE void amxp_expr_destroy_lex(amxp_expr_t *expr)
PRIVATE void amxp_expr_node_set_value(amxp_expr_node_t *node, amxc_var_t *value)
PRIVATE amxp_expr_node_t * amxp_expr_node_pop(amxc_lstack_t *stack)
PRIVATE bool amxp_expr_node_eval(amxp_expr_t *expr, amxp_expr_node_t *node)
PRIVATE bool amxp_expr_call_bool_func(amxp_expr_t *expr, const char *func, amxc_var_t *args)
_amxp_expr_comp
@ amxp_expr_comp_bigger_equal
@ amxp_expr_comp_ends_with
@ amxp_expr_comp_in
@ amxp_expr_comp_starts_with
@ amxp_expr_comp_lesser
@ amxp_expr_comp_matches
@ amxp_expr_comp_equal
@ amxp_expr_comp_bigger
@ amxp_expr_comp_equals_ignorecase
@ amxp_expr_comp_not_equal
@ amxp_expr_comp_contains
@ amxp_expr_comp_lesser_equal
Ambiorix expression parser and evaluate API header file.
enum _expr_status amxp_expr_status_t
Expression status/error codes.
union _amxp_expr_node::@0 left
amxp_expr_node_t * node
amxc_llist_t args
amxc_llist_it_t it
union _amxp_expr_node::@1 right
amxp_expr_comp_t compare
amxp_expr_node_type_t type
amxc_var_t * value
char * txt
static amxc_string_t path