2 * FML interpreter. Europagate, 1995
5 * Revision 1.2 1995/02/07 16:09:24 adam
6 * The \ character is no longer INCLUDED when terminating a token.
7 * Major changes in tokenization routines. Bug fixes in expressions
8 * with lists (fml_sub0).
10 * Revision 1.1.1.1 1995/02/06 13:48:10 adam
11 * First version of the FML interpreter. It's slow and memory isn't
12 * freed properly. In particular, the FML nodes aren't released yet.
23 static char lex_buf[FML_MAX_TOKEN];
25 static void lexer (Fml fml);
27 struct fml_node *fml_group (Fml fml);
29 struct fml_node *fml_tokenize (Fml fml)
33 look_char = (*fml->read_func)();
43 void fml_pr_list (struct fml_node *p)
52 fml_atom_str (p->p[0], buf);
58 fml_pr_list (p->p[0]);
65 struct fml_node *fml_group (Fml fml)
67 struct fml_node *ptr0 = NULL, *ptr1, *ptr2;
76 ptr2 = fml_node_alloc (fml);
81 ptr2->p[0] = fml_atom_alloc (fml, lex_buf);
84 else if (look_type == '{')
86 struct fml_node *sptr = fml_group (fml);
90 ptr2 = fml_node_alloc (fml);
99 /* make group of one become an element ... */
102 ptr2 = fml_node_alloc (fml);
122 ptr2 = fml_node_alloc (fml);
138 static void lexer (Fml fml)
143 if (look_char == fml->eof_mark)
148 else if (look_char == fml->comment_char)
151 look_char = (*fml->read_func)();
152 while (look_char != '\n' && look_char != fml->eof_mark);
156 if (!strchr (fml->white_chars, look_char))
158 look_char = (*fml->read_func)();
161 if (look_char == '{')
164 look_char = (*fml->read_func)();
166 else if (look_char == '}')
169 look_char = (*fml->read_func)();
176 lex_buf[off++] = look_char;
177 look_char = (*fml->read_func)();
178 } while (look_char != fml->eof_mark
179 && !strchr (fml->white_chars, look_char)
180 && look_char != '{' && look_char != '}');
187 if (look_type == 'a')
188 printf ("[%s]", lex_buf);
190 printf ("[%c]", look_type);