#ifndef INCLUDED_BNF_PARSER_H #define INCLUDED_BNF_PARSER_H #include #include #include "bnf-lexer.h" struct bnf_sequence { union { struct bnf_lexeme *items, *terms; }; union { uint32_t count, term_count; }; uint32_t capacity; }; struct bnf_rule { struct bnf_lexeme name; struct { union { struct bnf_sequence *items, *sequences; }; union { uint32_t count, sequence_count; }; uint32_t capacity; } is_replaced_by; }; struct bnf_syntax { union { struct bnf_rule *items, *rules; }; union { uint32_t count, rule_count; }; uint32_t capacity; }; // struct term_table { // union { struct bnf_lexeme *items, *terms; }; // union { uint32_t count, term_count; }; // uint32_t capacity; // }; struct bnf_parser { struct bnf_lexer lexer; }; bool is_bnf_lexeme_valid (struct bnf_lexeme); bool is_bnf_sequence_valid (struct bnf_sequence); bool is_bnf_rule_valid (struct bnf_rule); bool bnf_check_syntax (struct bnf_lexer *, struct bnf_syntax); bool bnf_parse_lexeme (struct bnf_lexer *, enum bnf_lexeme_kind); struct bnf_lexeme bnf_parse_nonterminal (struct bnf_lexer *); struct bnf_lexeme bnf_parse_terminal (struct bnf_lexer *); struct bnf_sequence bnf_parse_sequence (struct bnf_lexer *); struct bnf_rule bnf_parse_rule (struct bnf_lexer *); struct bnf_syntax bnf_parse_syntax (struct bnf_lexer *); #endif // INCLUDED_BNF_PARSER_H