comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/python3.8/grammar.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1
2 /* Grammar interface */
3
4 #ifndef Py_GRAMMAR_H
5 #define Py_GRAMMAR_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 #include "bitset.h" /* Sigh... */
11
12 /* A label of an arc */
13
14 typedef struct {
15 int lb_type;
16 const char *lb_str;
17 } label;
18
19 #define EMPTY 0 /* Label number 0 is by definition the empty label */
20
21 /* A list of labels */
22
23 typedef struct {
24 int ll_nlabels;
25 const label *ll_label;
26 } labellist;
27
28 /* An arc from one state to another */
29
30 typedef struct {
31 short a_lbl; /* Label of this arc */
32 short a_arrow; /* State where this arc goes to */
33 } arc;
34
35 /* A state in a DFA */
36
37 typedef struct {
38 int s_narcs;
39 const arc *s_arc; /* Array of arcs */
40
41 /* Optional accelerators */
42 int s_lower; /* Lowest label index */
43 int s_upper; /* Highest label index */
44 int *s_accel; /* Accelerator */
45 int s_accept; /* Nonzero for accepting state */
46 } state;
47
48 /* A DFA */
49
50 typedef struct {
51 int d_type; /* Non-terminal this represents */
52 char *d_name; /* For printing */
53 int d_nstates;
54 state *d_state; /* Array of states */
55 bitset d_first;
56 } dfa;
57
58 /* A grammar */
59
60 typedef struct {
61 int g_ndfas;
62 const dfa *g_dfa; /* Array of DFAs */
63 const labellist g_ll;
64 int g_start; /* Start symbol of the grammar */
65 int g_accel; /* Set if accelerators present */
66 } grammar;
67
68 /* FUNCTIONS */
69 const dfa *PyGrammar_FindDFA(grammar *g, int type);
70 const char *PyGrammar_LabelRepr(label *lb);
71 void PyGrammar_AddAccelerators(grammar *g);
72 void PyGrammar_RemoveAccelerators(grammar *);
73
74 #ifdef __cplusplus
75 }
76 #endif
77 #endif /* !Py_GRAMMAR_H */