blob: 403236d1ea2b87cdedea2003df3f1e8a7bb0e7a9 [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
Christian Heimes90c3d9b2008-02-23 13:18:03 +000010#define MAXSTACK 1500
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 */
Thomas Wouters34aa7ba2006-02-28 19:02:24 +000028#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
29 unsigned long p_flags; /* see co_flags in Include/code.h */
Neil Schemenauerc24ea082002-03-22 23:53:36 +000030#endif
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000031} parser_state;
32
Tim Petersdbd9ba62000-07-09 03:09:57 +000033parser_state *PyParser_New(grammar *g, int start);
34void PyParser_Delete(parser_state *ps);
Martin v. Löwis49c5da12006-03-01 22:49:05 +000035int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset,
Fred Drake85f36392000-07-11 17:53:00 +000036 int *expected_ret);
Tim Petersdbd9ba62000-07-09 03:09:57 +000037void PyGrammar_AddAccelerators(grammar *g);
Guido van Rossuma3309961993-07-28 09:05:47 +000038
39#ifdef __cplusplus
40}
41#endif
42#endif /* !Py_PARSER_H */