diff options
| author | 2026-11-08 06:02:38 +0000 | |
|---|---|---|
| committer | 2026-11-08 06:26:07 +0000 | |
| commit | 6ecea40c849effd171c1d27c961f5c1ee100481f (patch) | |
| tree | 99a92dafddf7d2ef0e318d927ae70c3b642e4171 /src/bnf-parser.h | |
| download | lab-03-6ecea40c849effd171c1d27c961f5c1ee100481f.tar.gz | |
Diffstat (limited to 'src/bnf-parser.h')
| -rw-r--r-- | src/bnf-parser.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/bnf-parser.h b/src/bnf-parser.h new file mode 100644 index 0000000..db9804d --- /dev/null +++ b/src/bnf-parser.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef INCLUDED_BNF_PARSER_H | ||
| 2 | #define INCLUDED_BNF_PARSER_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include "bnf-lexer.h" | ||
| 7 | |||
| 8 | struct bnf_sequence { | ||
| 9 | union { struct bnf_lexeme *items, *terms; }; | ||
| 10 | union { uint32_t count, term_count; }; | ||
| 11 | uint32_t capacity; | ||
| 12 | }; | ||
| 13 | |||
| 14 | struct bnf_rule { | ||
| 15 | struct bnf_lexeme name; | ||
| 16 | struct { | ||
| 17 | union { struct bnf_sequence *items, *sequences; }; | ||
| 18 | union { uint32_t count, sequence_count; }; | ||
| 19 | uint32_t capacity; | ||
| 20 | } is_replaced_by; | ||
| 21 | }; | ||
| 22 | |||
| 23 | struct bnf_syntax { | ||
| 24 | union { struct bnf_rule *items, *rules; }; | ||
| 25 | union { uint32_t count, rule_count; }; | ||
| 26 | uint32_t capacity; | ||
| 27 | }; | ||
| 28 | |||
| 29 | // struct term_table { | ||
| 30 | // union { struct bnf_lexeme *items, *terms; }; | ||
| 31 | // union { uint32_t count, term_count; }; | ||
| 32 | // uint32_t capacity; | ||
| 33 | // }; | ||
| 34 | |||
| 35 | struct bnf_parser { | ||
| 36 | struct bnf_lexer lexer; | ||
| 37 | }; | ||
| 38 | |||
| 39 | bool is_bnf_lexeme_valid (struct bnf_lexeme); | ||
| 40 | bool is_bnf_sequence_valid (struct bnf_sequence); | ||
| 41 | bool is_bnf_rule_valid (struct bnf_rule); | ||
| 42 | |||
| 43 | bool bnf_check_syntax (struct bnf_lexer *, struct bnf_syntax); | ||
| 44 | bool bnf_parse_lexeme (struct bnf_lexer *, enum bnf_lexeme_kind); | ||
| 45 | struct bnf_lexeme bnf_parse_nonterminal (struct bnf_lexer *); | ||
| 46 | struct bnf_lexeme bnf_parse_terminal (struct bnf_lexer *); | ||
| 47 | struct bnf_sequence bnf_parse_sequence (struct bnf_lexer *); | ||
| 48 | struct bnf_rule bnf_parse_rule (struct bnf_lexer *); | ||
| 49 | struct bnf_syntax bnf_parse_syntax (struct bnf_lexer *); | ||
| 50 | |||
| 51 | #endif // INCLUDED_BNF_PARSER_H | ||
