parser.h 1000 Bytes
Newer Older
1 2 3 4 5 6
#ifndef Py_PARSER_H
#define Py_PARSER_H
#ifdef __cplusplus
extern "C" {
#endif

7

Guido van Rossum's avatar
Guido van Rossum committed
8 9
/* Parser interface */

10
#define MAXSTACK 500
Guido van Rossum's avatar
Guido van Rossum committed
11

12
typedef struct {
Guido van Rossum's avatar
Guido van Rossum committed
13 14
	int		 s_state;	/* State in current DFA */
	dfa		*s_dfa;		/* Current DFA */
Guido van Rossum's avatar
Guido van Rossum committed
15
	struct _node	*s_parent;	/* Where to add next node */
Guido van Rossum's avatar
Guido van Rossum committed
16 17
} stackentry;

18
typedef struct {
Guido van Rossum's avatar
Guido van Rossum committed
19 20 21 22 23 24
	stackentry	*s_top;		/* Top entry */
	stackentry	 s_base[MAXSTACK];/* Array of stack entries */
					/* NB The stack grows down */
} stack;

typedef struct {
25 26 27
	stack	 	p_stack;	/* Stack of parser states */
	grammar		*p_grammar;	/* Grammar to use */
	node		*p_tree;	/* Top of parse tree */
28
#if 0 /* future keyword */
29
	int		p_generators;	/* 1 if yield is a keyword */
30
#endif
Guido van Rossum's avatar
Guido van Rossum committed
31 32
} parser_state;

33 34
parser_state *PyParser_New(grammar *g, int start);
void PyParser_Delete(parser_state *ps);
35 36
int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno,
                      int *expected_ret);
37
void PyGrammar_AddAccelerators(grammar *g);
38 39 40 41 42

#ifdef __cplusplus
}
#endif
#endif /* !Py_PARSER_H */