blob: 16eee0e8fe5cfc6e00117973d765db42dc50b33e [file] [log] [blame]
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00001/* Parser interface */
2
3#define MAXSTACK 100
4
5typedef struct _stackentry {
6 int s_state; /* State in current DFA */
7 dfa *s_dfa; /* Current DFA */
8 node *s_parent; /* Where to add next node */
9} stackentry;
10
11typedef struct _stack {
12 stackentry *s_top; /* Top entry */
13 stackentry s_base[MAXSTACK];/* Array of stack entries */
14 /* NB The stack grows down */
15} stack;
16
17typedef struct {
18 struct _stack p_stack; /* Stack of parser states */
19 struct _grammar *p_grammar; /* Grammar to use */
20 struct _node *p_tree; /* Top of parse tree */
21} parser_state;
22
23parser_state *newparser PROTO((struct _grammar *g, int start));
24void delparser PROTO((parser_state *ps));
25int addtoken PROTO((parser_state *ps, int type, char *str));