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 | |
Christian Heimes | 90c3d9b | 2008-02-23 13:18:03 +0000 | [diff] [blame] | 10 | #define MAXSTACK 1500 |
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 */ |
Thomas Wouters | 34aa7ba | 2006-02-28 19:02:24 +0000 | [diff] [blame] | 28 | #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD |
| 29 | unsigned long p_flags; /* see co_flags in Include/code.h */ |
Neil Schemenauer | c24ea08 | 2002-03-22 23:53:36 +0000 | [diff] [blame] | 30 | #endif |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 31 | } parser_state; |
| 32 | |
Tim Peters | dbd9ba6 | 2000-07-09 03:09:57 +0000 | [diff] [blame] | 33 | parser_state *PyParser_New(grammar *g, int start); |
| 34 | void PyParser_Delete(parser_state *ps); |
Martin v. Löwis | 49c5da1 | 2006-03-01 22:49:05 +0000 | [diff] [blame] | 35 | int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset, |
Fred Drake | 85f3639 | 2000-07-11 17:53:00 +0000 | [diff] [blame] | 36 | int *expected_ret); |
Tim Peters | dbd9ba6 | 2000-07-09 03:09:57 +0000 | [diff] [blame] | 37 | void PyGrammar_AddAccelerators(grammar *g); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 38 | |
| 39 | #ifdef __cplusplus |
| 40 | } |
| 41 | #endif |
| 42 | #endif /* !Py_PARSER_H */ |