Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/cudl.h
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2021-10-03 18:57:27 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2021-10-03 18:57:27 +0100
commit69852d9ae210080e999eb5bbb81481f527580a97 (patch)
treee1ecb61cfa9b81846d15a11dcaf95fef5e64f465 /cudl.h
parentcc219d714960ed68d2a822cd98bb428c32b71e1f (diff)
downloadcudl-69852d9ae210080e999eb5bbb81481f527580a97.tar
Complete parser with arrays, bools and nulls. Create empty testing file
Diffstat (limited to 'cudl.h')
-rw-r--r--cudl.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/cudl.h b/cudl.h
new file mode 100644
index 0000000..6586bba
--- /dev/null
+++ b/cudl.h
@@ -0,0 +1,49 @@
+#ifndef cudl_h_INCLUDED
+#define cudl_h_INCLUDED
+
+struct cudl_array_value {
+ struct cudl_value *values;
+ size_t length;
+};
+
+struct cudl_map_value {
+ struct cudl_map_field {
+ char *key;
+ struct cudl_value value;
+ } *fields;
+ size_t length;
+};
+
+struct cudl_value {
+ union {
+ char *string;
+ double number;
+ int boolean;
+ struct array_value array;
+ struct map_value map;
+ } data;
+ int tag;
+};
+
+enum {
+ CUDL_TAG_NULL;
+ CUDL_TAG_BOOL;
+ CUDL_TAG_ARRAY;
+}
+
+enum {
+ CUDL_OK = 0;
+ CUDL_ERR_OUT_OF_MEMORY;
+ CUDL_ERR_EXPECTED_VALUE;
+ CUDL_ERR_READING;
+ CUDL_ERR_EXPECTED_BOOL_OR_NULL;
+};
+
+extern int cudl_err;
+
+void cudl_debug(struct cudl_value value);
+void cudl_deinit_value(struct cudl_value value);
+void cudl_parse_from_file(FILE *file, struct cudl_value *value);
+size_t cudl_parse(char *input, struct cudl_value *value);
+
+#endif // cudl_h_INCLUDED