2 * FML interpreter. Europagate, 1995
5 * Revision 1.3 1995/02/10 15:50:57 adam
6 * MARC interface implemented. Minor bugs fixed. fmltest can
7 * be used to format single MARC records. New function '\list'
10 * Revision 1.2 1995/02/07 16:09:24 adam
11 * The \ character is no longer INCLUDED when terminating a token.
12 * Major changes in tokenization routines. Bug fixes in expressions
13 * with lists (fml_sub0).
15 * Revision 1.1.1.1 1995/02/06 13:48:10 adam
16 * First version of the FML interpreter. It's slow and memory isn't
17 * freed properly. In particular, the FML nodes aren't released yet.
28 static char lex_buf[FML_MAX_TOKEN];
30 static void lexer (Fml fml);
32 struct fml_node *fml_group (Fml fml);
34 struct fml_node *fml_tokenize (Fml fml)
38 look_char = (*fml->read_func)();
48 void fml_pr_list (struct fml_node *p)
57 fml_atom_str (p->p[0], buf);
63 fml_pr_list (p->p[0]);
70 struct fml_node *fml_group (Fml fml)
72 struct fml_node *ptr0 = NULL, *ptr1, *ptr2;
81 ptr2 = fml_node_alloc (fml);
86 ptr2->p[0] = fml_atom_alloc (fml, lex_buf);
89 else if (look_type == '{')
91 struct fml_node *sptr = fml_group (fml);
94 ptr2 = fml_node_alloc (fml);
104 ptr2 = fml_node_alloc (fml);
120 static void lexer (Fml fml)
125 if (look_char == fml->eof_mark)
130 else if (look_char == fml->comment_char)
133 look_char = (*fml->read_func)();
134 while (look_char != '\n' && look_char != fml->eof_mark);
138 if (!strchr (fml->white_chars, look_char))
140 look_char = (*fml->read_func)();
143 if (look_char == '{')
146 look_char = (*fml->read_func)();
148 else if (look_char == '}')
151 look_char = (*fml->read_func)();
153 else if (look_char == '\'')
156 look_char = (*fml->read_func)();
157 while (look_char != fml->eof_mark && look_char != '\'')
159 lex_buf[off++] = look_char;
160 look_char = (*fml->read_func)();
164 if (look_char == '\'')
165 look_char = (*fml->read_func)();
172 lex_buf[off++] = look_char;
173 look_char = (*fml->read_func)();
174 } while (look_char != fml->eof_mark
175 && !strchr (fml->white_chars, look_char)
176 && look_char != '{' && look_char != '}');
183 if (look_type == 'a')
184 printf ("[%s]", lex_buf);
186 printf ("[%c]", look_type);