blob: c4bb92280f997daae705be2cdfef4dfe521aabe6 [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 Rossumb9f8d6e1995-01-04 19:08:09 +00008Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
9The Netherlands.
Guido van Rossumf70e43a1991-02-19 12:39:46 +000010
11 All Rights Reserved
12
Guido van Rossumfd71b9e2000-06-30 23:50:40 +000013Copyright (c) 2000, BeOpen.com.
14Copyright (c) 1995-2000, Corporation for National Research Initiatives.
15Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
16All rights reserved.
Guido van Rossumf70e43a1991-02-19 12:39:46 +000017
Guido van Rossumfd71b9e2000-06-30 23:50:40 +000018See the file "Misc/COPYRIGHT" for information on usage and
19redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossumf70e43a1991-02-19 12:39:46 +000020
21******************************************************************/
22
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000023/* Parser interface */
24
Guido van Rossuma9e7dc11992-10-18 18:53:57 +000025#define MAXSTACK 500
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000026
Guido van Rossum1d5735e1994-08-30 08:27:36 +000027typedef struct {
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000028 int s_state; /* State in current DFA */
29 dfa *s_dfa; /* Current DFA */
Guido van Rossum3f5da241990-12-20 15:06:42 +000030 struct _node *s_parent; /* Where to add next node */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000031} stackentry;
32
Guido van Rossum1d5735e1994-08-30 08:27:36 +000033typedef struct {
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000034 stackentry *s_top; /* Top entry */
35 stackentry s_base[MAXSTACK];/* Array of stack entries */
36 /* NB The stack grows down */
37} stack;
38
39typedef struct {
Guido van Rossum1d5735e1994-08-30 08:27:36 +000040 stack p_stack; /* Stack of parser states */
41 grammar *p_grammar; /* Grammar to use */
42 node *p_tree; /* Top of parse tree */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000043} parser_state;
44
Guido van Rossum86bea461997-04-29 21:03:06 +000045parser_state *PyParser_New Py_PROTO((grammar *g, int start));
46void PyParser_Delete Py_PROTO((parser_state *ps));
47int PyParser_AddToken
48 Py_PROTO((parser_state *ps, int type, char *str, int lineno));
49void PyGrammar_AddAccelerators Py_PROTO((grammar *g));
Guido van Rossuma3309961993-07-28 09:05:47 +000050
51#ifdef __cplusplus
52}
53#endif
54#endif /* !Py_PARSER_H */