-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
59 lines (45 loc) · 966 Bytes
/
parser.h
File metadata and controls
59 lines (45 loc) · 966 Bytes
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
52
53
54
55
56
57
58
59
#ifndef YACC_PARSER
#define YACC_PARSER
enum actiontype {
ACTION_ACCEPT = 1 << 0,
ACTION_SHIFT = 1 << 1,
ACTION_REDUCE = 1 << 2,
};
typedef struct {
enum actiontype type;
union actunion {
int prod; /* reduce */
int state; /* shift */
} u;
} Action;
Action *
action_accept(int prod);
Action *
action_shift(int st);
Action *
action_reduce(int prod);
#define DEFAULT_TERM_VALUE 257
typedef struct {
Itemset *state;
struct map **action;
size_t nstate;
char *S; /* start symbol, used for acceptance */
struct lrprodset {
char **sym;
Prod **prod;
size_t n;
} prods;
struct map *yyterms; /* non-literal terminals → yylex-returned integers */
char *precode, *postcode;
} Parser;
Parser
parser_create(Grammar *, char *precode, char *postcode);
Parser
parser_create_term(Grammar *, char *, char *, struct map *yyterms);
void
parser_destroy(Parser);
char *
parser_str(Parser);
char *
parser_str_ordered(Parser, Symbolset *order);
#endif