U iÛfª%ã@s.ddlZddlmZmZGdd„dejƒZdS)éN)ÚgrammarÚtokenc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú ConvertercCs | |¡| |¡| ¡dS©N)Úparse_graminit_hÚparse_graminit_cÚ finish_off)ÚselfZ graminit_hZ graminit_c©r ú7/opt/alt/python38/lib64/python3.8/lib2to3/pgen2/conv.pyÚrun/s  z Converter.runc CsÄz t|ƒ}Wn8tk rD}ztd||fƒWY¢dSd}~XYnXi|_i|_d}|D]d}|d7}t d|¡}|s–| ¡r–td||| ¡fƒqZ| ¡\}}t |ƒ}||j|<||j|<qZdS)NúCan't open %s: %sFréz^#define\s+(\w+)\s+(\d+)$z%s(%s): can't parse %sT) ÚopenÚOSErrorÚprintZ symbol2numberZ number2symbolÚreÚmatchÚstripÚgroupsÚint) r ÚfilenameÚfÚerrÚlinenoÚlineÚmoÚsymbolÚnumberr r r r5s(   ÿ    zConverter.parse_graminit_hc! CsÂz t|ƒ}Wn8tk rD}ztd||fƒWY¢dSd}~XYnXd}|dt|ƒ}}|dt|ƒ}}|dt|ƒ}}i}g}| d¡rü| d¡rJt d|¡}ttt |  ¡ƒƒ\} } } g} t | ƒD]F} |dt|ƒ}}t d|¡}ttt |  ¡ƒƒ\}}|   ||f¡qÐ|dt|ƒ}}| || | f<|dt|ƒ}}q”t d|¡}ttt |  ¡ƒƒ\}}g}t |ƒD]R} |dt|ƒ}}t d |¡}ttt |  ¡ƒƒ\} } } || | f} |  | ¡qx|  |¡|dt|ƒ}}|dt|ƒ}}qˆ||_ i}t d |¡}t | d¡ƒ}t |ƒD]Þ}|dt|ƒ}}t d |¡}| d ¡}ttt | dd dd¡ƒƒ\}}}}||}|dt|ƒ}}t d|¡}i}t| d¡ƒ}t|ƒD]@\}}t|ƒ}t dƒD]$}|d|>@rÎd||d|<qÎq¶||f||<q(|dt|ƒ}}||_g}|dt|ƒ}}t d|¡}t | d¡ƒ}t |ƒD]^}|dt|ƒ}}t d|¡}|  ¡\}}t |ƒ}|dkržd}nt|ƒ}|  ||f¡qX|dt|ƒ}}||_|dt|ƒ}}|dt|ƒ}}t d|¡}t | d¡ƒ}|dt|ƒ}}|dt|ƒ}}t d|¡}t | d¡ƒ}|dt|ƒ}}t d|¡}t | d¡ƒ} | |_|dt|ƒ}}z|dt|ƒ}}Wntk r¼YnXdS)Nr Frrz static arc z)static arc arcs_(\d+)_(\d+)\[(\d+)\] = {$z\s+{(\d+), (\d+)},$z'static state states_(\d+)\[(\d+)\] = {$z\s+{(\d+), arcs_(\d+)_(\d+)},$zstatic dfa dfas\[(\d+)\] = {$z0\s+{(\d+), "(\w+)", (\d+), (\d+), states_(\d+),$ééééz\s+("(?:\\\d\d\d)*")},$éz!static label labels\[(\d+)\] = {$z\s+{(\d+), (0|"\w+")},$Ú0z \s+(\d+),$z\s+{(\d+), labels},$z \s+(\d+)$)rrrÚnextÚ startswithrrÚlistÚmaprrÚrangeÚappendÚstatesÚgroupÚevalÚ enumerateÚordÚdfasÚlabelsÚstartÚ StopIteration)!r rrrrrZallarcsr+rÚnÚmÚkZarcsÚ_ÚiÚjÚsÚtÚstater0ZndfasrrÚxÚyÚzÚfirstZ rawbitsetÚcZbyter1Znlabelsr2r r r rTs¾   ÿ          ÿ "          zConverter.parse_graminit_ccCsXi|_i|_t|jƒD]<\}\}}|tjkr@|dk r@||j|<q|dkr||j|<qdSr)ÚkeywordsÚtokensr.r1rÚNAME)r ZilabelÚtypeÚvaluer r r rùs zConverter.finish_offN)Ú__name__Ú __module__Ú __qualname__r rrrr r r r r$s  &r)rZpgen2rrZGrammarrr r r r Ús