Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / include / python2.4 / grammar.h
CommitLineData
86530b38
AT
1#ifndef Py_GRAMMAR_H
2#define Py_GRAMMAR_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include "bitset.h" /* Sigh... */
8
9/* A label of an arc */
10
11typedef struct {
12 int lb_type;
13 char *lb_str;
14} label;
15
16#define EMPTY 0 /* Label number 0 is by definition the empty label */
17
18/* A list of labels */
19
20typedef struct {
21 int ll_nlabels;
22 label *ll_label;
23} labellist;
24
25/* An arc from one state to another */
26
27typedef struct {
28 short a_lbl; /* Label of this arc */
29 short a_arrow; /* State where this arc goes to */
30} arc;
31
32/* A state in a DFA */
33
34typedef struct {
35 int s_narcs;
36 arc *s_arc; /* Array of arcs */
37
38 /* Optional accelerators */
39 int s_lower; /* Lowest label index */
40 int s_upper; /* Highest label index */
41 int *s_accel; /* Accelerator */
42 int s_accept; /* Nonzero for accepting state */
43} state;
44
45/* A DFA */
46
47typedef struct {
48 int d_type; /* Non-terminal this represents */
49 char *d_name; /* For printing */
50 int d_initial; /* Initial state */
51 int d_nstates;
52 state *d_state; /* Array of states */
53 bitset d_first;
54} dfa;
55
56/* A grammar */
57
58typedef struct {
59 int g_ndfas;
60 dfa *g_dfa; /* Array of DFAs */
61 labellist g_ll;
62 int g_start; /* Start symbol of the grammar */
63 int g_accel; /* Set if accelerators present */
64} grammar;
65
66/* FUNCTIONS */
67
68grammar *newgrammar(int start);
69dfa *adddfa(grammar *g, int type, char *name);
70int addstate(dfa *d);
71void addarc(dfa *d, int from, int to, int lbl);
72dfa *PyGrammar_FindDFA(grammar *g, int type);
73
74int addlabel(labellist *ll, int type, char *str);
75int findlabel(labellist *ll, int type, char *str);
76char *PyGrammar_LabelRepr(label *lb);
77void translatelabels(grammar *g);
78
79void addfirstsets(grammar *g);
80
81void PyGrammar_AddAccelerators(grammar *g);
82void PyGrammar_RemoveAccelerators(grammar *);
83
84void printgrammar(grammar *g, FILE *fp);
85void printnonterminals(grammar *g, FILE *fp);
86
87#ifdef __cplusplus
88}
89#endif
90#endif /* !Py_GRAMMAR_H */