forked from jatovm/jato
/
monoburg.h
72 lines (50 loc) · 1.25 KB
/
monoburg.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef __MONO_MONOBURG_H__
#define __MONO_MONOBURG_H__
#include <glib.h>
void yyerror (char *fmt, ...);
int yylex (void);
extern FILE *inputfd;
extern FILE *outputfd;
extern GHashTable *definedvars;
typedef struct _Rule Rule;
typedef struct _Term Term;
struct _Term{
char *name;
int number;
int arity;
GList *rules; /* rules that start with this terminal */
};
typedef struct _NonTerm NonTerm;
struct _NonTerm {
char *name;
int number;
GList *rules; /* rules with this nonterm on the left side */
GList *chain;
gboolean reached;
};
typedef struct _Tree Tree;
struct _Tree {
Term *op;
Tree *left;
Tree *right;
NonTerm *nonterm; /* used by chain rules */
};
struct _Rule {
NonTerm *lhs;
Tree *tree;
char *code;
char *cost;
char *cfunc;
};
Tree *create_tree (char *id, Tree *left, Tree *right);
Term *create_term (char *id, int num);
void create_term_prefix (char *id);
NonTerm *nonterm (char *id);
void start_nonterm (char *id);
Rule *make_rule (char *id, Tree *tree);
void rule_add (Rule *rule, char *code, char *cost, char *cfunc);
void create_rule (char *id, Tree *tree, char *code, char *cost,
char *cfunc);
void yyparsetail (void);
void reset_parser (void);
#endif