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 | |
Emily Morehouse | 8f59ee0 | 2019-01-24 16:49:56 -0700 | [diff] [blame] | 10 | #define MAXSTACK 1700 |
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 { |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 13 | int s_state; /* State in current DFA */ |
| 14 | dfa *s_dfa; /* Current DFA */ |
| 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 { |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 19 | stackentry *s_top; /* Top entry */ |
| 20 | stackentry s_base[MAXSTACK];/* Array of stack entries */ |
| 21 | /* NB The stack grows down */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 22 | } stack; |
| 23 | |
| 24 | typedef struct { |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [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 |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 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); |
Ivan Levkivskyi | 9932a22 | 2019-01-22 11:18:22 +0000 | [diff] [blame] | 35 | int PyParser_AddToken(parser_state *ps, int type, char *str, |
| 36 | int lineno, int col_offset, |
| 37 | int end_lineno, int end_col_offset, |
Fred Drake | 85f3639 | 2000-07-11 17:53:00 +0000 | [diff] [blame] | 38 | int *expected_ret); |
Tim Peters | dbd9ba6 | 2000-07-09 03:09:57 +0000 | [diff] [blame] | 39 | void PyGrammar_AddAccelerators(grammar *g); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 40 | |
| 41 | #ifdef __cplusplus |
| 42 | } |
| 43 | #endif |
| 44 | #endif /* !Py_PARSER_H */ |