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 | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 8 | Copyright (c) 2000, BeOpen.com. |
| 9 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 10 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 11 | All rights reserved. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 12 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 13 | See the file "Misc/COPYRIGHT" for information on usage and |
| 14 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 15 | ******************************************************************/ |
| 16 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 17 | /* Parser interface */ |
| 18 | |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 19 | #define MAXSTACK 500 |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 20 | |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 21 | typedef struct { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 22 | int s_state; /* State in current DFA */ |
| 23 | dfa *s_dfa; /* Current DFA */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 24 | struct _node *s_parent; /* Where to add next node */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 25 | } stackentry; |
| 26 | |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 27 | typedef struct { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 28 | stackentry *s_top; /* Top entry */ |
| 29 | stackentry s_base[MAXSTACK];/* Array of stack entries */ |
| 30 | /* NB The stack grows down */ |
| 31 | } stack; |
| 32 | |
| 33 | typedef struct { |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 34 | stack p_stack; /* Stack of parser states */ |
| 35 | grammar *p_grammar; /* Grammar to use */ |
| 36 | node *p_tree; /* Top of parse tree */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 37 | } parser_state; |
| 38 | |
Tim Peters | dbd9ba6 | 2000-07-09 03:09:57 +0000 | [diff] [blame] | 39 | parser_state *PyParser_New(grammar *g, int start); |
| 40 | void PyParser_Delete(parser_state *ps); |
| 41 | int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno); |
| 42 | void PyGrammar_AddAccelerators(grammar *g); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 43 | |
| 44 | #ifdef __cplusplus |
| 45 | } |
| 46 | #endif |
| 47 | #endif /* !Py_PARSER_H */ |