aoc-2023/c/include/parse.h

23 lines
601 B
C

/* This parsing library aims to imitate how Elm parses strings.
In contrast to Elm, however, this function makes use of the side-effects that
C brings, allowing for impurity and a lack of need to return values.
Instead, every parser merely returns a boolean that expresses whether it had
parsed successfully.
*/
#include <stdbool.h>
/* Parse a single char and fetch the result.
*/
bool parse_char(char *text, int *cursor, char *c);
/* Parse an integer.
*/
bool parse_int(char *text, int *cursor, int *output);
/* Parse a token of text.
*/
bool parse_token(char *text, int *cursor, char *token);