parser.h 1.02 KB
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 */

Christian Heimes's avatar
Christian Heimes committed
10
#define MAXSTACK 1500
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 29
#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
	unsigned long	p_flags;	/* see co_flags in Include/code.h */
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
int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset,
36
                      int *expected_ret);
37
void PyGrammar_AddAccelerators(grammar *g);
38 39 40 41 42

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