blob: 608737363a72ad0a6afb7b0b643881bb0723a1ec [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 Rossumfd71b9e2000-06-30 23:50:40 +00008Copyright (c) 2000, BeOpen.com.
9Copyright (c) 1995-2000, Corporation for National Research Initiatives.
10Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
11All rights reserved.
Guido van Rossumf70e43a1991-02-19 12:39:46 +000012
Guido van Rossumfd71b9e2000-06-30 23:50:40 +000013See the file "Misc/COPYRIGHT" for information on usage and
14redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossumf70e43a1991-02-19 12:39:46 +000015******************************************************************/
16
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000017/* Parser interface */
18
Guido van Rossuma9e7dc11992-10-18 18:53:57 +000019#define MAXSTACK 500
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000020
Guido van Rossum1d5735e1994-08-30 08:27:36 +000021typedef struct {
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000022 int s_state; /* State in current DFA */
23 dfa *s_dfa; /* Current DFA */
Guido van Rossum3f5da241990-12-20 15:06:42 +000024 struct _node *s_parent; /* Where to add next node */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000025} stackentry;
26
Guido van Rossum1d5735e1994-08-30 08:27:36 +000027typedef struct {
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000028 stackentry *s_top; /* Top entry */
29 stackentry s_base[MAXSTACK];/* Array of stack entries */
30 /* NB The stack grows down */
31} stack;
32
33typedef struct {
Guido van Rossum1d5735e1994-08-30 08:27:36 +000034 stack p_stack; /* Stack of parser states */
35 grammar *p_grammar; /* Grammar to use */
36 node *p_tree; /* Top of parse tree */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000037} parser_state;
38
Tim Petersdbd9ba62000-07-09 03:09:57 +000039parser_state *PyParser_New(grammar *g, int start);
40void PyParser_Delete(parser_state *ps);
41int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno);
42void PyGrammar_AddAccelerators(grammar *g);
Guido van Rossuma3309961993-07-28 09:05:47 +000043
44#ifdef __cplusplus
45}
46#endif
47#endif /* !Py_PARSER_H */