/* Grammar interface */#ifndef Py_GRAMMAR_H#define Py_GRAMMAR_H#ifdef __cplusplusextern"C"{#endif#include "bitset.h" /* Sigh... *//* A label of an arc */typedefstruct{intlb_type;char*lb_str;}label;#define EMPTY 0 /* Label number 0 is by definition the empty label *//* A list of labels */typedefstruct{intll_nlabels;label*ll_label;}labellist;/* An arc from one state to another */typedefstruct{shorta_lbl;/* Label of this arc */shorta_arrow;/* State where this arc goes to */}arc;/* A state in a DFA */typedefstruct{ints_narcs;arc*s_arc;/* Array of arcs *//* Optional accelerators */ints_lower;/* Lowest label index */ints_upper;/* Highest label index */int*s_accel;/* Accelerator */ints_accept;/* Nonzero for accepting state */}state;/* A DFA */typedefstruct{intd_type;/* Non-terminal this represents */char*d_name;/* For printing */intd_initial;/* Initial state */intd_nstates;state*d_state;/* Array of states */bitsetd_first;}dfa;/* A grammar */typedefstruct{intg_ndfas;dfa*g_dfa;/* Array of DFAs */labellistg_ll;intg_start;/* Start symbol of the grammar */intg_accel;/* Set if accelerators present */}grammar;/* FUNCTIONS */grammar*newgrammar(intstart);dfa*adddfa(grammar*g,inttype,char*name);intaddstate(dfa*d);voidaddarc(dfa*d,intfrom,intto,intlbl);dfa*PyGrammar_FindDFA(grammar*g,inttype);intaddlabel(labellist*ll,inttype,char*str);intfindlabel(labellist*ll,inttype,char*str);char*PyGrammar_LabelRepr(label*lb);voidtranslatelabels(grammar*g);voidaddfirstsets(grammar*g);voidPyGrammar_AddAccelerators(grammar*g);voidPyGrammar_RemoveAccelerators(grammar*);voidprintgrammar(grammar*g,FILE*fp);voidprintnonterminals(grammar*g,FILE*fp);#ifdef __cplusplus}#endif#endif /* !Py_GRAMMAR_H */