Lines Matching full:gr

102 static void compile_rule(nfagrammar *gr, node *n);
107 nfagrammar *gr; in newnfagrammar() local
109 gr = (nfagrammar *)PyObject_MALLOC(sizeof(nfagrammar)); in newnfagrammar()
110 if (gr == NULL) in newnfagrammar()
112 gr->gr_nnfas = 0; in newnfagrammar()
113 gr->gr_nfa = NULL; in newnfagrammar()
114 gr->gr_ll.ll_nlabels = 0; in newnfagrammar()
115 gr->gr_ll.ll_label = NULL; in newnfagrammar()
116 addlabel(&gr->gr_ll, ENDMARKER, "EMPTY"); in newnfagrammar()
117 return gr; in newnfagrammar()
121 freenfagrammar(nfagrammar *gr) in freenfagrammar() argument
124 for (i = 0; i < gr->gr_nnfas; i++) { in freenfagrammar()
125 PyObject_FREE(gr->gr_nfa[i]->nf_state); in freenfagrammar()
127 PyObject_FREE(gr->gr_nfa); in freenfagrammar()
128 PyObject_FREE(gr); in freenfagrammar()
132 addnfa(nfagrammar *gr, char *name) in addnfa() argument
137 gr->gr_nfa = (nfa **)PyObject_REALLOC(gr->gr_nfa, in addnfa()
138 sizeof(nfa*) * (gr->gr_nnfas + 1)); in addnfa()
139 if (gr->gr_nfa == NULL) in addnfa()
141 gr->gr_nfa[gr->gr_nnfas++] = nf; in addnfa()
142 addlabel(&gr->gr_ll, NAME, nf->nf_name); in addnfa()
164 nfagrammar *gr; in metacompile() local
169 gr = newnfagrammar(); in metacompile()
175 compile_rule(gr, n); in metacompile()
177 return gr; in metacompile()
181 compile_rule(nfagrammar *gr, node *n) in compile_rule() argument
189 nf = addnfa(gr, n->n_str); in compile_rule()
194 compile_rhs(&gr->gr_ll, nf, n, &nf->nf_start, &nf->nf_finish); in compile_rule()
398 makedfa(nfagrammar *gr, nfa *nf, dfa *d) in makedfa() argument
492 printssdfa(xx_nstates, xx_state, nbits, &gr->gr_ll, in makedfa()
498 printssdfa(xx_nstates, xx_state, nbits, &gr->gr_ll, in makedfa()
651 maketables(nfagrammar *gr) in maketables() argument
658 if (gr->gr_nnfas == 0) in maketables()
660 g = newgrammar(gr->gr_nfa[0]->nf_type); in maketables()
662 g->g_ll = gr->gr_ll; in maketables()
664 for (i = 0; i < gr->gr_nnfas; i++) { in maketables()
665 nf = gr->gr_nfa[i]; in maketables()
668 dumpnfa(&gr->gr_ll, nf); in maketables()
672 makedfa(gr, gr->gr_nfa[i], d); in maketables()
681 nfagrammar *gr; in pgen() local
684 gr = metacompile(n); in pgen()
685 g = maketables(gr); in pgen()
688 freenfagrammar(gr); in pgen()