code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(28 lines)
1 // Some common parsing utilities
2 #pragma once
4 #include <stdbool.h>
6 #include "../stdlib/util.h"
7 #include "context.h"
9 #define SPACES_PER_INDENT 4
11 CONSTFUNC bool is_keyword(const char *word);
12 size_t some_of(const char **pos, const char *allow);
13 size_t some_not(const char **pos, const char *forbid);
14 size_t spaces(const char **pos);
15 void whitespace(parse_ctx_t *ctx, const char **pos);
16 size_t match(const char **pos, const char *target);
17 size_t match_word(const char **pos, const char *word);
18 const char *get_word(const char **pos);
19 const char *get_id(const char **pos);
20 bool comment(parse_ctx_t *ctx, const char **pos);
21 bool indent(parse_ctx_t *ctx, const char **pos);
22 const char *eol(const char *str);
23 PUREFUNC int64_t get_indent(parse_ctx_t *ctx, const char *pos);
24 const char *unescape(parse_ctx_t *ctx, const char **out);
25 bool is_xid_start_next(const char *pos);
26 bool is_xid_continue_next(const char *pos);
27 bool newline_with_indentation(const char **out, int64_t target);
28 bool match_separator(parse_ctx_t *ctx, const char **pos);