]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
Some allocator changes (still doesn't work)
[xonotic/gmqcc.git] / parser.c
index 72fa486ca0f07020f3dce7a568faf34739855f9b..f548e22403f2e5a5a82a0c58b18b16a2fc562ab5 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2840,14 +2840,8 @@ bool parser_init()
     return true;
 }
 
-bool parser_compile(const char *filename)
+bool parser_compile()
 {
-    parser->lex = lex_open(filename);
-    if (!parser->lex) {
-        printf("failed to open file \"%s\"\n", filename);
-        return false;
-    }
-
     /* initial lexer/parser state */
     parser->lex->flags.noops = true;
 
@@ -2878,6 +2872,26 @@ bool parser_compile(const char *filename)
     return !parser->errors;
 }
 
+bool parser_compile_file(const char *filename)
+{
+    parser->lex = lex_open(filename);
+    if (!parser->lex) {
+        printf("failed to open file \"%s\"\n", filename);
+        return false;
+    }
+    return parser_compile();
+}
+
+bool parser_compile_string(const char *name, const char *str)
+{
+    parser->lex = lex_open_string(str, strlen(str), name);
+    if (!parser->lex) {
+        printf("failed to create lexer for string \"%s\"\n", name);
+        return false;
+    }
+    return parser_compile();
+}
+
 void parser_cleanup()
 {
     size_t i;