diff options
Diffstat (limited to 'src/bnf-lexeme.h')
| -rw-r--r-- | src/bnf-lexeme.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/bnf-lexeme.h b/src/bnf-lexeme.h new file mode 100644 index 0000000..20c532c --- /dev/null +++ b/src/bnf-lexeme.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #ifndef INCLUDED_BNF_LEXEME_H | ||
| 2 | #define INCLUDED_BNF_LEXEME_H | ||
| 3 | |||
| 4 | #include <stddef.h> | ||
| 5 | #include <stdint.h> | ||
| 6 | #include "utils.h" | ||
| 7 | #include "string-view.h" | ||
| 8 | |||
| 9 | #define BNF_LEXEME_KINDS() \ | ||
| 10 | X (TERMINAL, "\"[^\"]*\"|'[^']*'") \ | ||
| 11 | X (NONTERMINAL, "<[^>]*>" ) \ | ||
| 12 | X (SYMBOL_ALTERNATIVE, "\\|" ) \ | ||
| 13 | X (SYMBOL_IS_REPLACED_BY, "::=" ) \ | ||
| 14 | X (COMMENT, "#[^\n]*" ) | ||
| 15 | |||
| 16 | #define X(SYM, ...) BNF_LEXEME_KIND_##SYM, | ||
| 17 | enum bnf_lexeme_kind { | ||
| 18 | BNF_LEXEME_KINDS () | ||
| 19 | BNF_LEXEME_KIND_END_OF_LINE, | ||
| 20 | BNF_LEXEME_KIND_END_OF_FILE, | ||
| 21 | BNF_LEXEME_KIND_INVALID, | ||
| 22 | BNF_LEXEME_KIND_COUNT, | ||
| 23 | }; | ||
| 24 | #undef X | ||
| 25 | |||
| 26 | #define BNF_LEXEME_REGEX_COUNT (BNF_LEXEME_KIND_COUNT - 3) | ||
| 27 | |||
| 28 | struct bnf_lexeme { | ||
| 29 | struct string_view sv; | ||
| 30 | enum bnf_lexeme_kind kind; | ||
| 31 | }; | ||
| 32 | |||
| 33 | extern const char *bnf_lexeme_kind_names[BNF_LEXEME_KIND_COUNT]; | ||
| 34 | |||
| 35 | #endif // INCLUDED_BNF_LEXEME_H | ||
