2
/* Grammar subroutines needed by parser */
5
#include "pgenheaders.h"
9
/* Return the DFA for the given type */
12
PyGrammar_FindDFA(grammar *g, register int type)
16
/* Massive speed-up */
17
d = &g->g_dfa[type - NT_OFFSET];
18
assert(d->d_type == type);
21
/* Old, slow version */
24
for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {
25
if (d->d_type == type)
34
PyGrammar_LabelRepr(label *lb)
38
if (lb->lb_type == ENDMARKER)
40
else if (ISNONTERMINAL(lb->lb_type)) {
41
if (lb->lb_str == NULL) {
42
PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type);
49
if (lb->lb_str == NULL)
50
return _PyParser_TokenNames[lb->lb_type];
52
PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)",
53
_PyParser_TokenNames[lb->lb_type], lb->lb_str);