aboutsummaryrefslogtreecommitdiff
path: root/src/parser/parsed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/parsed.c')
-rw-r--r--src/parser/parsed.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/parser/parsed.c b/src/parser/parsed.c
new file mode 100644
index 0000000..0c8eba6
--- /dev/null
+++ b/src/parser/parsed.c
@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* parsed.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/08/27 20:27:42 by charles #+# #+# */
+/* Updated: 2020/08/27 20:31:11 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "parser.h"
+
+t_parsed *parsed_new(t_ast *ast, t_tok_lst *rest)
+{
+ t_parsed *ret;
+
+ if ((ret = malloc(sizeof(t_parsed))) == NULL)
+ return (NULL);
+ ret->syntax_error = false;
+ ret->rest = rest;
+ ret->ast = ast;
+ return ret;
+}
+
+t_parsed *parsed_error(const char *format, ...)
+{
+ t_parsed *err;
+ va_list ap;
+
+ if ((err = parsed_new(NULL, NULL)) == NULL)
+ return (NULL);
+ err->syntax_error = true;
+ va_start(ap, format);
+ verrorf(format, ap);
+ va_end(ap);
+ return (err);
+}
+