aboutsummaryrefslogtreecommitdiff
path: root/examples/main.c
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-19 17:26:31 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-19 17:26:37 +0200
commit25fa85cbb622e1f9dc9818b0d18fe0de2ef7e5a3 (patch)
tree2d6998f27c88ff046c56fad7420c447fa407cf3a /examples/main.c
parentd1480f97e3c8ce82151d409e7c9d1545d44f3a99 (diff)
build(zig): test integrations with C
Diffstat (limited to 'examples/main.c')
-rw-r--r--examples/main.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/main.c b/examples/main.c
new file mode 100644
index 0000000..1409bd5
--- /dev/null
+++ b/examples/main.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include "typdown.h"
+
+void foo(char *v) {
+ uint8_t code;
+ char *res = parse(v, &code);
+ if (code == 0) {
+ printf("%s\n", res);
+ free(res);
+ } else printf("cannot parse '%s', error: %s (%d)\n", v, getErrorString(code), code);
+}
+
+int main() {
+ // valid
+ foo("hello world");
+ foo("he*ll*o world");
+ foo("# he*ll*o world");
+
+ // invalid
+ foo("hello *world");
+ foo("# hello :::");
+ return 0;
+}