summaryrefslogtreecommitdiff
path: root/src/xml/xml.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-03 22:34:04 -0600
committersanine <sanine.not@pm.me>2023-02-03 22:34:04 -0600
commitea512c3b1d2d85ff76aa7d4979c73dd7f1217757 (patch)
treec5bd7d5151a86ae4a54a3241fe745c0e2dd64d58 /src/xml/xml.c
parent0710a40e50d12cd731b0372d79d0ccdfbaee10d4 (diff)
begin refactor with bison xml parser
Diffstat (limited to 'src/xml/xml.c')
-rw-r--r--src/xml/xml.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/xml/xml.c b/src/xml/xml.c
new file mode 100644
index 0000000..e2aa008
--- /dev/null
+++ b/src/xml/xml.c
@@ -0,0 +1,20 @@
+#include "xml.h"
+
+/* parse a string into a document */
+struct kai_tag_t * kai_parse_string(const char *str)
+{
+ yyscan_t scanner;
+ struct kai_tag_t *document;
+
+ kalmialex_init(&scanner);
+ YY_BUFFER_STATE buf = kalmia_scan_string(str, scanner);
+ int result = kalmiaparse(scanner, &document);
+ kalmia_delete_buffer(buf, scanner);
+ kalmialex_destroy(scanner);
+
+ if (result != 0) {
+ return NULL;
+ }
+
+ return document;
+}