2
/* Grammar interface */
10
#include "bitset.h" /* Sigh... */
12
/* A label of an arc */
19
#define EMPTY 0 /* Label number 0 is by definition the empty label */
21
/* A list of labels */
28
/* An arc from one state to another */
31
short a_lbl; /* Label of this arc */
32
short a_arrow; /* State where this arc goes to */
35
/* A state in a DFA */
39
arc *s_arc; /* Array of arcs */
41
/* Optional accelerators */
42
int s_lower; /* Lowest label index */
43
int s_upper; /* Highest label index */
44
int *s_accel; /* Accelerator */
45
int s_accept; /* Nonzero for accepting state */
51
int d_type; /* Non-terminal this represents */
52
char *d_name; /* For printing */
53
int d_initial; /* Initial state */
55
state *d_state; /* Array of states */
63
dfa *g_dfa; /* Array of DFAs */
65
int g_start; /* Start symbol of the grammar */
66
int g_accel; /* Set if accelerators present */
71
grammar *newgrammar(int start);
72
dfa *adddfa(grammar *g, int type, const char *name);
74
void addarc(dfa *d, int from, int to, int lbl);
75
dfa *PyGrammar_FindDFA(grammar *g, int type);
77
int addlabel(labellist *ll, int type, const char *str);
78
int findlabel(labellist *ll, int type, const char *str);
79
const char *PyGrammar_LabelRepr(label *lb);
80
void translatelabels(grammar *g);
82
void addfirstsets(grammar *g);
84
void PyGrammar_AddAccelerators(grammar *g);
85
void PyGrammar_RemoveAccelerators(grammar *);
87
void printgrammar(grammar *g, FILE *fp);
88
void printnonterminals(grammar *g, FILE *fp);
93
#endif /* !Py_GRAMMAR_H */