From ea512c3b1d2d85ff76aa7d4979c73dd7f1217757 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 3 Feb 2023 22:34:04 -0600 Subject: begin refactor with bison xml parser --- src/xml/xml.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/xml/xml.c (limited to 'src/xml/xml.c') 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; +} -- cgit v1.2.1