aboutsummaryrefslogtreecommitdiffstats
path: root/src/output.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-17 01:47:41 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-17 01:47:41 -0300
commit047e4e3753c597628024847a524d44ca67fa1382 (patch)
tree8c0d63ecd8d395815a4eee155c2ce6283e0e7fab /src/output.c
parentf5da9cc42acc79d7dda78e57fab8a1b8d7aa6a7d (diff)
downloadblogc-047e4e3753c597628024847a524d44ca67fa1382.tar.gz
blogc-047e4e3753c597628024847a524d44ca67fa1382.tar.bz2
blogc-047e4e3753c597628024847a524d44ca67fa1382.zip
replaced leg-based parser with handmade parser for source files
Diffstat (limited to 'src/output.c')
-rw-r--r--src/output.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/output.c b/src/output.c
new file mode 100644
index 0000000..bd96b8e
--- /dev/null
+++ b/src/output.c
@@ -0,0 +1,39 @@
+/*
+ * blogc: A blog compiler.
+ * Copyright (C) 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br>
+ *
+ * This program can be distributed under the terms of the BSD License.
+ * See the file COPYING.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include "utils/utils.h"
+#include "output.h"
+
+
+void
+blogc_parser_syntax_error(const char *name, const char *src, size_t src_len,
+ size_t current)
+{
+ b_string_t *msg = b_string_new();
+
+ while (current < src_len) {
+ char c = src[current];
+
+ if (c == '\r' || c == '\n')
+ break;
+
+ b_string_append_c(msg, c);
+
+ current++;
+ }
+
+ fprintf(stderr, "%s parser error: syntax error near \"%s\"\n", name,
+ msg->str);
+
+ b_string_free(msg, true);
+}