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.13 1995/05/16 09:39:34 adam
51 * Revision 1.12 1995/03/02 08:06:05 adam
52 * Fml function strsub implemented. New test files marc[45].fml.
53 * New test options in fmltest.
55 * Revision 1.11 1995/02/27 09:01:21 adam
56 * Regular expression support. Argument passing by name option. New FML
59 * Revision 1.10 1995/02/23 08:32:06 adam
62 * Revision 1.8 1995/02/10 18:15:52 adam
63 * FML function 'strcmp' implemented. This function can be used to
64 * test for existence of MARC fields.
66 * Revision 1.7 1995/02/10 15:50:56 adam
67 * MARC interface implemented. Minor bugs fixed. fmltest can
68 * be used to format single MARC records. New function '\list'
71 * Revision 1.6 1995/02/09 16:06:07 adam
72 * FML can be called from the outside multiple times by the functions:
73 * fml_exec_call and fml_exec_call_str.
74 * An interactive parameter (-i) to fmltest starts a shell-like
75 * interface to FML by using the fml_exec_call_str function.
77 * Revision 1.5 1995/02/09 14:37:19 adam
78 * Removed .depend from cvs. Removed function fml_mk_list.
80 * Revision 1.4 1995/02/09 14:33:37 adam
81 * Split source fml.c and define relevant build-in functions in separate
82 * files. New operators mult, div, not, llen implemented.
84 * Revision 1.3 1995/02/09 13:07:15 adam
85 * Nodes are freed now. Many bugs fixed.
87 * Revision 1.2 1995/02/07 16:09:23 adam
88 * The \ character is no longer INCLUDED when terminating a token.
89 * Major changes in tokenization routines. Bug fixes in expressions
90 * with lists (fml_sub0).
92 * Revision 1.1.1.1 1995/02/06 13:48:10 adam
93 * First version of the FML interpreter. It's slow and memory isn't
94 * freed properly. In particular, the FML nodes aren't released yet.
103 #define FML_MAX_TOKEN 2048
105 #define FML_ATOM_BUF 12
109 unsigned is_atom : 1;
113 struct fml_atom *next;
114 char buf[FML_ATOM_BUF];
117 struct fml_node *fml_tokenize (Fml fml);
118 struct fml_node *fml_node_alloc (Fml fml);
119 struct fml_atom *fml_atom_alloc (Fml fml, char *str);
120 int fml_atom_str (struct fml_atom *a, char *str);
121 int fml_atom_len (struct fml_atom *a);
122 void fml_atom_strx (struct fml_atom *a, char *str, int max);
123 int fml_atom_val (struct fml_atom *a);
124 void fml_node_delete (Fml fml, struct fml_node *fn);
125 struct fml_node *fml_node_copy (Fml fml, struct fml_node *fn);
126 struct fml_node *fml_mk_node_val (Fml fml, int val);
127 int fml_atom_cmp (Fml fml, struct fml_atom *a1, struct fml_atom *a2);
128 struct fml_atom *fml_atom_strsub (Fml fml, struct fml_atom *a, int o, int l);
140 struct fml_node *sub;
141 struct fml_atom *atom;
142 char sbuf[FML_ATOM_BUF*4];
145 struct fml_sym_info {
147 struct fml_node *args;
148 struct fml_node *body;
149 struct fml_node *(*binary)(Fml fml, struct fml_node *l,
151 struct fml_node *(*prefix)(Fml fml, struct fml_node **lp,
155 struct fml_sym_tab *fml_sym_open (void);
156 void fml_sym_close (struct fml_sym_tab **tabp);
157 struct fml_sym_info *fml_sym_add (struct fml_sym_tab *tab, const char *s);
158 struct fml_sym_info *fml_sym_add_local (struct fml_sym_tab *tab,const char *s);
160 struct fml_sym_info *fml_sym_lookup (struct fml_sym_tab *tab, const char *s);
161 struct fml_sym_info *fml_sym_lookup_local (struct fml_sym_tab *tab,
163 void fml_sym_push (struct fml_sym_tab *tab);
164 void fml_sym_pop (struct fml_sym_tab *tab, void(*ph)(struct fml_sym_info *i));
166 void fml_pr_list (struct fml_node *p);
167 void fml_node_stat (Fml fml);
174 #define FML_FOREACH 6
178 #define FML_CBINARY 10
179 #define FML_CPREFIX 11
180 #define FML_BINARY 12
184 void fml_rel_init (Fml fml);
185 void fml_arit_init (Fml fml);
186 void fml_list_init (Fml fml);
187 void fml_str_init (Fml fml);
188 void fml_lr_values (Fml fml, struct fml_node *l, int *left_val,
189 struct fml_node *r, int *right_val);
190 void fml_cmd_lex (struct fml_node **np, struct token *tp);
191 void fml_cmd_lex_s (struct fml_node **np, struct token *tp, int esc_stop);
192 void fml_init_token (struct token *tp, Fml fml);
193 void fml_del_token (struct token *tp, Fml fml);
194 struct fml_node *fml_expr_term (Fml fml, struct fml_node **lp,
196 struct fml_node *fml_exec_group (struct fml_node *list, Fml fml);