]> git.lizzy.rs Git - nothing.git/blobdiff - src/script/parser.h
TODO(#330)
[nothing.git] / src / script / parser.h
index b2141ae319e53493b4c71d1a427a17a3d8233f9b..21247dae5757a019dac8a1f8e0c4a192557ef6fe 100644 (file)
@@ -1,28 +1,31 @@
 #ifndef PARSER_H_
 #define PARSER_H_
 
+#include <stdio.h>
 #include <stdbool.h>
 #include "script/expr.h"
+#include "script/tokenizer.h"
 
 struct ParseResult
 {
     bool is_error;
+    const char *end;
     union {
         struct Expr expr;
-        struct {
-            const char *error;
-            size_t error_cursor;
-        };
+        const char *error_message;
     };
 };
 
-struct ParseResult parse_success(struct Expr expr);
+struct ParseResult parse_success(struct Expr expr,
+                                 const char *end);
 struct ParseResult parse_failure(const char *error,
-                                 size_t error_cursor);
+                                 const char *end);
 
-struct ParseResult create_expr_from_str(const char *str,
-                                        size_t *cursor,
-                                        size_t n);
+struct ParseResult read_expr_from_string(Gc *gc, const char *str);
+struct ParseResult read_expr_from_file(Gc *gc, const char *filename);
 
+void print_parse_error(FILE *stream,
+                       const char *str,
+                       struct ParseResult result);
 
 #endif  // PARSER_H_