Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
§ àÀ fª%ãóH—dZddlZddlmZmZGd„dej¦«ZdS)aýConvert graminit.[ch] spit out by pgen to Python code. Pgen is the Python parser generator. It is useful to quickly create a parser from a grammar file in Python's grammar notation. But I don't want my parsers to be written in C (yet), so I'm translating the parsing tables to Python data structures and writing a Python parse engine. Note that the token numbers are constants determined by the standard Python tokenizer. The standard token module defines these numbers and their names (the names are not used much). The token numbers are hardcoded into the Python tokenizer and into pgen. A Python implementation of the Python tokenizer is also available, in the standard tokenize module. On the other hand, symbol numbers (representing the grammar's non-terminals) are assigned by pgen based on the actual grammar input. Note: this module is pretty much obsolete; the pgen module generates equivalent grammar tables directly from the Grammar.txt input file without having to invoke the Python pgen C program. éN)ÚgrammarÚtokencó*—eZdZdZd„Zd„Zd„Zd„ZdS)Ú Convertera2Grammar subclass that reads classic pgen output files. The run() method reads the tables as produced by the pgen parser generator, typically contained in two C files, graminit.h and graminit.c. The other methods are for internal use only. See the base class for more documentation. có‚—| |¦«| |¦«| ¦«dS)z| ¦«r*t|›d|›d | ¦«›�¦«Œ\| ¦«\}}t|¦«}||jvsJ‚||jvsJ‚||j|<||j|<Œ­d S) zðParse the .h file written by pgen. (Internal) This file is a sequence of #define statements defining the nonterminals of the grammar as numbers. We build two tables mapping the numbers to names and back. ú Can't open ú: NFréz^#define\s+(\w+)\s+(\d+)$ú(z): can't parse T) ÚopenÚOSErrorÚprintÚ symbol2numberÚ number2symbolÚreÚmatchÚstripÚgroupsÚint) r ÚfilenameÚfÚerrÚlinenoÚlineÚmoÚsymbolÚnumbers rrzConverter.parse_graminit_h5sU€ð Ý�X‘”ˆAˆAøÝð ð ð Ý ˆE¨¨¨°3°3Ð7Ñ 8Ô 8Ð 8Ø�5�5�5�5�5øøøøð øøøð ˆÔØˆÔØˆØð 4ð 4ˆDØ �a‰KˆFÝ”Ð6¸Ñ=Ô=ˆBØð 4˜$Ÿ*š*™,œ,ð 4ݰ(°(°(¸F¸F¸FØ26·*²*±,´,°,ð@ñAôAðAðAð"$§¢¡¤‘�˜Ý˜V™œ�Ø TÔ%7Ð7Ð7Ð7Ð7Ø TÔ%7Ð7Ð7Ð7Ð7Ø-3�Ô" 6Ñ*Ø-3�Ô" 6Ñ*Ð*؈ts‚’ <œ7·<c ó@— t|¦«}n-#t$r }td|›d|›�¦«Yd}~dSd}~wwxYwd}|dzt|¦«}}|dks J||f¦«‚|dzt|¦«}}|dks J||f¦«‚|dzt|¦«}}i}g}| d ¦«�r| d ¦«�rKt jd |¦«}|s J||f¦«‚ttt|  ¦«¦«¦«\} } } g} t| ¦«D]‡} |dzt|¦«}}t jd |¦«}|s J||f¦«‚ttt|  ¦«¦«¦«\}}|   ||f¦«Œˆ|dzt|¦«}}|d ks J||f¦«‚| || | f<|dzt|¦«}}| d ¦«�°Kt jd |¦«}|s J||f¦«‚ttt|  ¦«¦«¦«\}}|t|¦«ks J||f¦«‚g}t|¦«D]¯} |dzt|¦«}}t jd|¦«}|s J||f¦«‚ttt|  ¦«¦«¦«\} } } || | f} | t| ¦«ks J||f¦«‚|  | ¦«Œ°|  |¦«|dzt|¦«}}|d ks J||f¦«‚|dzt|¦«}}| d ¦«�°||_i}t jd|¦«}|s J||f¦«‚t| d¦«¦«}t|¦«D�]ª}|dzt|¦«}}t jd|¦«}|s J||f¦«‚| d¦«}ttt| dddd¦«¦«¦«\}}}}|j||ks J||f¦«‚|j||ks J||f¦«‚|dks J||f¦«‚||}|t|¦«ks J||f¦«‚|dzt|¦«}}t jd|¦«}|s J||f¦«‚i}t%| d¦«¦«}t'|¦«D]9\}}t)|¦«}td¦«D]}|d|zzr d||dz|z<ŒŒ:||f||<�Œ¬|dzt|¦«}}|d ks J||f¦«‚||_g}|dzt|¦«}}t jd|¦«}|s J||f¦«‚t| d¦«¦«}t|¦«D]Ž}|dzt|¦«}}t jd|¦«}|s J||f¦«‚|  ¦«\}}t|¦«}|dkrd}nt%|¦«}|  ||f¦«Œ�|dzt|¦«}}|d ks J||f¦«‚||_|dzt|¦«}}|dks J||f¦«‚|dzt|¦«}}t jd|¦«}|s J||f¦«‚t| d¦«¦«}|t|j¦«ksJ‚|dzt|¦«}}|dks J||f¦«‚|dzt|¦«}}t jd|¦«}|s J||f¦«‚t| d¦«¦«}|t|j¦«ks J||f¦«‚|dzt|¦«}}t jd|¦«}|s J||f¦«‚t| d¦«¦«} | |jvs J||f¦«‚| |_|dzt|¦«}}|d ks J||f¦«‚ |dzt|¦«}}J||f¦«‚#t0$rYdSwxYw)aùParse the .c file written by pgen. (Internal) The file looks as follows. The first two lines are always this: #include "pgenheaders.h" #include "grammar.h" After that come four blocks: 1) one or more state definitions 2) a table defining dfas 3) a table defining labels 4) a struct defining the grammar A state definition has the following form: - one or more arc arrays, each of the form: static arc arcs__[] = { {, }, ... }; - followed by a state array, of the form: static state states_[] = { {, arcs__}, ... }; rrNFrrz#include "pgenheaders.h" z#include "grammar.h" z static arc z)static arc arcs_(\d+)_(\d+)\[(\d+)\] = {$z\s+{(\d+), (\d+)},$z}; 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+")},$Ú0zgrammar _PyParser_Grammar = { z \s+(\d+),$z dfas, z\s+{(\d+), labels},$z \s+(\d+)$)rrrÚnextÚ startswithrrÚlistÚmaprrÚrangeÚappendÚlenÚstatesÚgrouprrÚevalÚ enumerateÚordÚdfasÚlabelsÚstartÚ StopIteration)!r r r!r"r#r$Úallarcsr6r%ÚnÚmÚkÚarcsÚ_ÚiÚjÚsÚtÚstater;Úndfasr&r'ÚxÚyÚzÚfirstÚ rawbitsetÚcÚbyter<Únlabelsr=s! rr zConverter.parse_graminit_cTs³ €ð8 Ý�X‘”ˆAˆAøÝð ð ð Ý ˆE¨¨¨°3°3Ð7Ñ 8Ô 8Ð 8Ø�5�5�5�5�5øøøøð øøøðˆð˜a‘x¥ a¡¤�ˆØÐ3Ò3Ð3Ð3°f¸d°^Ñ3Ô3Ð3ؘa‘x¥ a¡¤�ˆØÐ/Ò/Ð/Ð/°&¸$°Ñ/Ô/Ð/ð˜a‘x¥ a¡¤�ˆØˆØˆØ�oŠo˜mÑ,Ô,ñ! -Ø—/’/ -Ñ0Ô0ñ 1Ý”XÐJØ"ñ$ô$�àÐ)Ð)˜F D˜>Ñ)Ô)�rÝ�s¥3¨¯ ª © ¬ Ñ4Ô4Ñ5Ô5‘��1�aØ�ݘq™œð(ð(�AØ#)¨!¡8­T°!©W¬W˜D�FÝœÐ"8¸$Ñ?Ô?�BØÐ-Ð- ¨˜~Ñ-Ô-˜2Ý¥¥C¨¯ª©¬Ñ 5Ô 5Ñ6Ô6‘D�A�qØ—K’K  A Ñ'Ô'Ð'Ð'Ø% a™x­¨a©¬˜�ؘv’~�~�~¨° ~‘~”~�~Ø"&�˜˜A˜‘Ø% a™x­¨a©¬˜�ð—/’/ -Ñ0Ô0ñ 1õ ”ÐDÀdÑKÔKˆBØÐ %Ð %˜ �~Ñ %Ô %�2Ý��C §¢¡¤Ñ-Ô-Ñ.Ô.‰DˆAˆqØ�˜F™ œ Ò#Ð#Ð# f¨d ^Ñ#Ô#Ð#؈Eݘ1‘X”Xð #ð #�Ø% a™x­¨a©¬˜�Ý”XÐ?ÀÑFÔF�ØÐ)Ð)˜F D˜>Ñ)Ô)�rÝ�s¥3¨¯ ª © ¬ Ñ4Ô4Ñ5Ô5‘��1�aؘq !˜t”}�Ø�C ™IœI’~�~�~¨° ~‘~”~�~Ø— ’ ˜TÑ"Ô"Ð"Ð"Ø �MŠM˜%Ñ Ô Ð Ø! !™8¥T¨!¡W¤W�DˆFؘ6’>�>�> F¨D >‘>”>�>Ø! !™8¥T¨!¡W¤W�DˆFðC�oŠo˜mÑ,Ô,ñ! -ðDˆŒ ðˆÝ ŒXÐ6¸Ñ =Ô =ˆØÐ!Ð!�F˜D�>Ñ!Ô!ˆrÝ�B—H’H˜Q‘K”KÑ Ô ˆÝ�u‘”ð *ñ *ˆAØ! !™8¥T¨!¡W¤W�DˆFÝ”ÐMØñ ô ˆBàÐ %Ð %˜ �~Ñ %Ô %�2Ø—X’X˜a‘[”[ˆFÝ"¥3¥s¨B¯HªH°Q¸¸1¸aÑ,@Ô,@Ñ#AÔ#AÑBÔB‰OˆF�A�q˜!ØÔ% fÔ-°Ò7Ð7Ð7¸&À$¸Ñ7Ô7Ð7ØÔ% fÔ-°Ò7Ð7Ð7¸&À$¸Ñ7Ô7Ð7ؘ’6�6�6˜F D˜>‘6”6�6ؘ1”IˆEØ�˜E™ œ ’?�?�? V¨T N‘?”?�?Ø! !™8¥T¨!¡W¤W�DˆFÝ”Ð4°dÑ;Ô;ˆBØÐ %Ð %˜ �~Ñ %Ô %�2؈EݘRŸXšX a™[œ[Ñ)Ô)ˆIÝ! )Ñ,Ô,ð +ð +‘��1ݘ1‘v”v�ݘq™œð+ð+�Aؘq !™t‘}ð+Ø)*˜˜a ™c A™g™øð+ð" 5˜>ˆD�‰L‰Lؘa‘x¥ a¡¤�ˆØ�vŠ~ˆ~ˆ~ ¨˜~‰~Œ~ˆ~؈Œ ðˆØ˜a‘x¥ a¡¤�ˆÝ ŒXÐ:¸DÑ AÔ AˆØÐ!Ð!�F˜D�>Ñ!Ô!ˆrÝ�b—h’h˜q‘k”kÑ"Ô"ˆÝ�w‘”ð "ð "ˆAØ! !™8¥T¨!¡W¤W�DˆFÝ”Ð4°dÑ;Ô;ˆBØÐ %Ð %˜ �~Ñ %Ô %�2Ø—9’9‘;”;‰DˆAˆqÝ�A‘”ˆAØ�CŠxˆxØ��嘑G”G�Ø �MŠM˜1˜a˜&Ñ !Ô !Ð !Ð !ؘa‘x¥ a¡¤�ˆØ�vŠ~ˆ~ˆ~ ¨˜~‰~Œ~ˆ~؈Œ ð˜a‘x¥ a¡¤�ˆØÐ8Ò8Ð8Ð8¸6À4¸.Ñ8Ô8Ð8ؘa‘x¥ a¡¤�ˆÝ ŒX�m TÑ *Ô *ˆØÐ!Ð!�F˜D�>Ñ!Ô!ˆrÝ�B—H’H˜Q‘K”KÑ Ô ˆØ�˜DœI™œÒ&Ð&Ð&Ð&ؘa‘x¥ a¡¤�ˆØ�{Ò"Ð"Ð" V¨T NÑ"Ô"Ð"ؘa‘x¥ a¡¤�ˆÝ ŒXÐ-¨tÑ 4Ô 4ˆØÐ!Ð!�F˜D�>Ñ!Ô!ˆrÝ�b—h’h˜q‘k”kÑ"Ô"ˆØ�#˜dœkÑ*Ô*Ò*Ð*Ð*¨V°T¨NÑ*Ô*Ð*ؘa‘x¥ a¡¤�ˆÝ ŒX�l DÑ )Ô )ˆØÐ!Ð!�F˜D�>Ñ!Ô!ˆrÝ�B—H’H˜Q‘K”KÑ Ô ˆØ˜Ô*Ð*Ð*Ð*¨V°T¨NÑ*Ô*Ð*؈Œ ؘa‘x¥ a¡¤�ˆØ�vŠ~ˆ~ˆ~ ¨˜~‰~Œ~ˆ~ð %Ø! !™8¥T¨!¡W¤W�DˆFð %�v˜t�nÑ $Ô $�1øõð ð ð Ø ˆDˆDð øøøs"‚’ <œ7·<ã/dä dädcó®—i|_i|_t|j¦«D]1\}\}}|tjkr |� ||j|<Œ%|€ ||j|<Œ2dS)z1Create additional useful structures. (Internal).N)ÚkeywordsÚtokensr9r<rÚNAME)r ÚilabelÚtypeÚvalues rr zConverter.finish_offùso€àˆŒ ؈Œ Ý%.¨t¬{Ñ%;Ô%;ð +ð +Ñ !ˆF‘M�T˜5Ø•u”zÒ!Ð! eÐ&7Ø'-�” ˜eÑ$Ð$Ø�Ø$*�” ˜DÑ!øð  +ð +rN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr r ©rrrr$s^€€€€€ðððððð ððð>c%ðc%ðc%ðJ+ð+ð+ð+ð+rr)r]rÚpgen2rrÚGrammarrr^rrúrastðððð4 € € € ð!Ð Ð Ð Ð Ð Ð Ð ð]+ð]+ð]+ð]+ð]+�”ñ]+ô]+ð]+ð]+ð]+r