+ vec_push(lex_filenames, lex->name);
+ return lex;
+}
+
+lex_file* lex_open_string(const char *str, size_t len, const char *name)
+{
+ lex_file *lex;
+
+ lex = (lex_file*)mem_a(sizeof(*lex));
+ if (!lex) {
+ lexerror(NULL, "out of memory\n");
+ return NULL;
+ }
+
+ memset(lex, 0, sizeof(*lex));
+
+ lex->file = NULL;
+ lex->open_string = str;
+ lex->open_string_length = len;
+ lex->open_string_pos = 0;
+
+ lex->name = util_strdup(name ? name : "<string-source>");
+ lex->line = 1; /* we start counting at 1 */
+
+ lex->peekpos = 0;
+ lex->eof = false;
+
+ vec_push(lex_filenames, lex->name);