diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/main.c | 25 |
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; +} |
