blob: aee1c86cb044e93d5343a0802026993b53325b95 [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
Emily Morehouse8f59ee02019-01-24 16:49:56 -070010#define MAXSTACK 1700
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000011
Guido van Rossum1d5735e1994-08-30 08:27:36 +000012typedef struct {
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020013 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 Rossum85a5fbb1990-10-14 12:07:46 +000016} stackentry;
17
Guido van Rossum1d5735e1994-08-30 08:27:36 +000018typedef struct {
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020019 stackentry *s_top; /* Top entry */
20 stackentry s_base[MAXSTACK];/* Array of stack entries */
21 /* NB The stack grows down */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000022} stack;
23
24typedef struct {
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020025 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
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020029 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);
Ivan Levkivskyi9932a222019-01-22 11:18:22 +000035int PyParser_AddToken(parser_state *ps, int type, char *str,
36 int lineno, int col_offset,
37 int end_lineno, int end_col_offset,
Fred Drake85f36392000-07-11 17:53:00 +000038 int *expected_ret);
Tim Petersdbd9ba62000-07-09 03:09:57 +000039void PyGrammar_AddAccelerators(grammar *g);
Guido van Rossuma3309961993-07-28 09:05:47 +000040
41#ifdef __cplusplus
42}
43#endif
44#endif /* !Py_PARSER_H */