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