2 * FML interpreter. Europagate, 1995
5 * Revision 1.1.1.1 1995/02/06 13:48:10 adam
6 * First version of the FML interpreter. It's slow and memory isn't
7 * freed properly. In particular, the FML nodes aren't released yet.
18 static char lex_buf[FML_MAX_TOKEN];
20 static void lexer (Fml fml);
22 struct fml_node *fml_group (Fml fml);
24 struct fml_node *fml_tokenize (Fml fml)
28 look_char = (*fml->read_func)();
38 void fml_pr_list (struct fml_node *p)
47 fml_atom_str (p->p[0], buf);
53 fml_pr_list (p->p[0]);
60 struct fml_node *fml_group (Fml fml)
62 struct fml_node *ptr0 = NULL, *ptr1, *ptr2;
71 ptr2 = fml_node_alloc (fml);
76 ptr2->p[0] = fml_atom_alloc (fml, lex_buf);
79 else if (look_type == '{')
81 struct fml_node *sptr = fml_group (fml);
85 ptr2 = fml_node_alloc (fml);
103 ptr2 = fml_node_alloc (fml);
119 static void lexer (Fml fml)
124 if (look_char == fml->eof_mark)
129 else if (look_char == fml->comment_char)
132 look_char = (*fml->read_func)();
133 while (look_char != '\n' && look_char != fml->eof_mark);
137 if (!strchr (fml->white_chars, look_char))
139 look_char = (*fml->read_func)();
142 if (look_char == '{')
145 look_char = (*fml->read_func)();
147 else if (look_char == '}')
150 look_char = (*fml->read_func)();
157 lex_buf[off++] = look_char;
158 look_char = (*fml->read_func)();
159 } while (look_char != fml->eof_mark
160 && !strchr (fml->white_chars, look_char)
161 && look_char != '{' && look_char != '}');
168 if (look_type == 'a')
169 printf ("[%s]", lex_buf);
171 printf ("[%c]", look_type);