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