Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_PARSER_H |
| 2 | #define Py_PARSER_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 8 | /* Parser interface */ |
| 9 | |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 10 | #define MAXSTACK 500 |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 11 | |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 12 | typedef struct { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 13 | int s_state; /* State in current DFA */ |
| 14 | dfa *s_dfa; /* Current DFA */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 15 | struct _node *s_parent; /* Where to add next node */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 16 | } stackentry; |
| 17 | |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 18 | typedef struct { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19 | stackentry *s_top; /* Top entry */ |
| 20 | stackentry s_base[MAXSTACK];/* Array of stack entries */ |
| 21 | /* NB The stack grows down */ |
| 22 | } stack; |
| 23 | |
| 24 | typedef struct { |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 25 | stack p_stack; /* Stack of parser states */ |
| 26 | grammar *p_grammar; /* Grammar to use */ |
| 27 | node *p_tree; /* Top of parse tree */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 28 | } parser_state; |
| 29 | |
Tim Peters | dbd9ba6 | 2000-07-09 03:09:57 +0000 | [diff] [blame] | 30 | parser_state *PyParser_New(grammar *g, int start); |
| 31 | void PyParser_Delete(parser_state *ps); |
Fred Drake | 85f3639 | 2000-07-11 17:53:00 +0000 | [diff] [blame] | 32 | int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, |
| 33 | int *expected_ret); |
Tim Peters | dbd9ba6 | 2000-07-09 03:09:57 +0000 | [diff] [blame] | 34 | void PyGrammar_AddAccelerators(grammar *g); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 35 | |
| 36 | #ifdef __cplusplus |
| 37 | } |
| 38 | #endif |
| 39 | #endif /* !Py_PARSER_H */ |