blob: cf8d318697209a17a0aa0052c98c68ed53aeb184 [file] [log] [blame]
Guido van Rossuma3309961993-07-28 09:05:47 +00001#ifndef Py_PARSER_H
2#define Py_PARSER_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
Guido van Rossumf70e43a1991-02-19 12:39:46 +00007
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00008/* Parser interface */
9
Guido van Rossuma9e7dc11992-10-18 18:53:57 +000010#define MAXSTACK 500
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000011
Guido van Rossum1d5735e1994-08-30 08:27:36 +000012typedef struct {
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000013 int s_state; /* State in current DFA */
14 dfa *s_dfa; /* Current DFA */
Guido van Rossum3f5da241990-12-20 15:06:42 +000015 struct _node *s_parent; /* Where to add next node */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000016} stackentry;
17
Guido van Rossum1d5735e1994-08-30 08:27:36 +000018typedef struct {
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000019 stackentry *s_top; /* Top entry */
20 stackentry s_base[MAXSTACK];/* Array of stack entries */
21 /* NB The stack grows down */
22} stack;
23
24typedef struct {
Guido van Rossum1d5735e1994-08-30 08:27:36 +000025 stack p_stack; /* Stack of parser states */
26 grammar *p_grammar; /* Grammar to use */
27 node *p_tree; /* Top of parse tree */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000028} parser_state;
29
Tim Petersdbd9ba62000-07-09 03:09:57 +000030parser_state *PyParser_New(grammar *g, int start);
31void PyParser_Delete(parser_state *ps);
Fred Drake85f36392000-07-11 17:53:00 +000032int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno,
33 int *expected_ret);
Tim Petersdbd9ba62000-07-09 03:09:57 +000034void PyGrammar_AddAccelerators(grammar *g);
Guido van Rossuma3309961993-07-28 09:05:47 +000035
36#ifdef __cplusplus
37}
38#endif
39#endif /* !Py_PARSER_H */