blob: db9804d7c3a53f5f04d5adff9fc1aff84c6e620f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef INCLUDED_BNF_PARSER_H
#define INCLUDED_BNF_PARSER_H
#include <stdint.h>
#include <stdbool.h>
#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
|