2 * Copyright (c) 1995, the EUROPAGATE consortium (see below).
4 * The EUROPAGATE consortium members are:
6 * University College Dublin
7 * Danmarks Teknologiske Videnscenter
8 * An Chomhairle Leabharlanna
9 * Consejo Superior de Investigaciones Cientificas
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation, in whole or in part, for any purpose, is hereby granted,
15 * 1. This copyright and permission notice appear in all copies of the
16 * software and its documentation. Notices of copyright or attribution
17 * which appear at the beginning of any file must remain unchanged.
19 * 2. The names of EUROPAGATE or the project partners may not be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * 3. Users of this software (implementors and gateway operators) agree to
24 * inform the EUROPAGATE consortium of their use of the software. This
25 * information will be used to evaluate the EUROPAGATE project and the
26 * software, and to plan further developments. The consortium may use
27 * the information in later publications.
29 * 4. Users of this software agree to make their best efforts, when
30 * documenting their use of the software, to acknowledge the EUROPAGATE
31 * consortium, and the role played by the software in their work.
33 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
35 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
36 * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE
37 * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF
38 * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
39 * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND
40 * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
41 * USE OR PERFORMANCE OF THIS SOFTWARE.
45 * FML interpreter. Europagate, 1995
48 * Revision 1.4 1995/05/16 09:39:34 adam
51 * Revision 1.3 1995/02/23 08:32:06 adam
54 * Revision 1.1 1995/02/09 14:33:37 adam
55 * Split source fml.c and define relevant build-in functions in separate
56 * files. New operators mult, div, not, llen implemented.
66 static struct fml_node *fml_exec_gt (Fml fml, struct fml_node *l,
69 int left_val, right_val;
71 fml_lr_values (fml, l, &left_val, r, &right_val);
72 if (left_val > right_val)
74 fn = fml_node_alloc (fml);
76 fn->p[0] = fml_atom_alloc (fml, "1");
83 static struct fml_node *fml_exec_lt (Fml fml, struct fml_node *l,
86 int left_val, right_val;
88 fml_lr_values (fml, l, &left_val, r, &right_val);
89 if (left_val < right_val)
91 fn = fml_node_alloc (fml);
93 fn->p[0] = fml_atom_alloc (fml, "1");
100 static struct fml_node *fml_exec_eq (Fml fml, struct fml_node *l,
103 int left_val, right_val;
105 fml_lr_values (fml, l, &left_val, r, &right_val);
106 if (left_val == right_val)
108 fn = fml_node_alloc (fml);
110 fn->p[0] = fml_atom_alloc (fml, "1");
117 static struct fml_node *fml_exec_ne (Fml fml, struct fml_node *l,
120 int left_val, right_val;
122 fml_lr_values (fml, l, &left_val, r, &right_val);
123 if (left_val != right_val)
125 fn = fml_node_alloc (fml);
127 fn->p[0] = fml_atom_alloc (fml, "1");
134 static struct fml_node *fml_exec_le (Fml fml, struct fml_node *l,
137 int left_val, right_val;
139 fml_lr_values (fml, l, &left_val, r, &right_val);
140 if (left_val <= right_val)
142 fn = fml_node_alloc (fml);
144 fn->p[0] = fml_atom_alloc (fml, "1");
151 static struct fml_node *fml_exec_ge (Fml fml, struct fml_node *l,
154 int left_val, right_val;
156 fml_lr_values (fml, l, &left_val, r, &right_val);
157 if (left_val >= right_val)
159 fn = fml_node_alloc (fml);
161 fn->p[0] = fml_atom_alloc (fml, "1");
168 static struct fml_node *fml_exec_and (Fml fml, struct fml_node *l,
173 fml_node_delete (fml, l);
176 fml_node_delete (fml, l);
177 fml_node_delete (fml, r);
181 static struct fml_node *fml_exec_or (Fml fml, struct fml_node *l,
186 fml_node_delete (fml, l);
192 static struct fml_node *fml_exec_not (Fml fml, struct fml_node **lp,
196 fml_cmd_lex (lp, tp);
198 fn = fml_expr_term (fml, lp, tp);
201 fml_node_delete (fml, fn);
204 fn = fml_node_alloc (fml);
206 fn->p[0] = fml_atom_alloc (fml, "1");
210 void fml_rel_init (Fml fml)
212 struct fml_sym_info *sym_info;
214 sym_info = fml_sym_add (fml->sym_tab, "gt");
215 sym_info->kind = FML_CBINARY;
216 sym_info->binary = fml_exec_gt;
217 sym_info = fml_sym_add (fml->sym_tab, "lt");
218 sym_info->kind = FML_CBINARY;
219 sym_info->binary = fml_exec_lt;
220 sym_info = fml_sym_add (fml->sym_tab, "eq");
221 sym_info->kind = FML_CBINARY;
222 sym_info->binary = fml_exec_eq;
224 sym_info = fml_sym_add (fml->sym_tab, "ge");
225 sym_info->kind = FML_CBINARY;
226 sym_info->binary = fml_exec_ge;
227 sym_info = fml_sym_add (fml->sym_tab, "le");
228 sym_info->kind = FML_CBINARY;
229 sym_info->binary = fml_exec_le;
230 sym_info = fml_sym_add (fml->sym_tab, "ne");
231 sym_info->kind = FML_CBINARY;
232 sym_info->binary = fml_exec_ne;
234 sym_info = fml_sym_add (fml->sym_tab, "and");
235 sym_info->kind = FML_CBINARY;
236 sym_info->binary = fml_exec_and;
237 sym_info = fml_sym_add (fml->sym_tab, "or");
238 sym_info->kind = FML_CBINARY;
239 sym_info->binary = fml_exec_or;
241 sym_info = fml_sym_add (fml->sym_tab, "not");
242 sym_info->kind = FML_CPREFIX;
243 sym_info->prefix = fml_exec_not;