+
    ÖÇÜhít  ã                   ó  € R t ^ RIt^ RIHtHtHtHtHtHtH	t	H
t
HtHt ^ RIHtHt ^ RIHtHtHtHtHt ^ RIHtHtHtHt ^ RIHt  ! R R]4      tR	t ! R
 R4      t ! R R4      t R t!R t"R t#]$R8X  d
   ]"! 4        R# R# )z
Visualization tools for CFGs.
N)
ÚButtonÚCanvasÚEntryÚFrameÚIntVarÚLabelÚ	ScrollbarÚTextÚTkÚToplevel)ÚTreeSegmentWidgetÚtree_to_treesegment)ÚCanvasFrameÚColorizedListÚShowTextÚSymbolWidgetÚ
TextWidget)ÚCFGÚNonterminalÚ_read_cfg_productionÚnonterminals)ÚTreec                   óR   a € ] tR t^Ot o ]P
                  R,          tR tR tRt	V t
R# )ÚProductionListÚ
rightarrowc                ó|   € VP                  R RR7       VP                  RRRR7       VP                  RRRR	7       R
# )Úterminalú#006000©Ú
foregroundÚarrowÚsymbolÚ0)ÚfontÚ	underlineÚnonterminalÚblue©r   r#   N©Ú	helveticaiôÿÿÿÚbold©Ú
tag_config)ÚselfÚ
textwidgetÚoptionss   &&&Ú//usr/lib/python3/dist-packages/nltk/draw/cfg.pyÚ_init_colortagsÚProductionList._init_colortagsR   sE   € Ø×Ñ˜j°YÐÔ?Ø×Ñ˜g¨HÀÐÔDØ×ÑØ fÐ3Mð 	ö 	
ó    c                óv  € . pVP                  R VP                  4       ,          R34       VP                  V P                  R34       VP                  4        F]  p\	        V\
        4      '       d+   VP                  RVP                  4       ,          R34       KC  VP                  RV,          R34       K_  	  V# )z%s	r%   r    ú %sú %rr   )ÚappendÚlhsÚARROWÚrhsÚ
isinstancer   r!   )r-   ÚitemÚcontentsÚelts   &&  r0   Ú
_item_reprÚProductionList._item_reprY   s�   € ØˆØ�‰˜ $§(¡(£*Õ,¨mÐ<Ô=Ø�‰˜Ÿ™ WÐ-Ô.Ø—8‘8–:ˆCÜ˜#œ{×+Ò+Ø—‘ ¨¯©«Õ!5°}Ð EÖFà—‘ ¨¥¨jÐ 9Ö:ñ	 ð
 ˆr3   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   ÚSYMBOLSr9   r1   r?   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r0   r   r   O   s$   ø‡ € Ø× Ñ  Õ.€Eò
÷	ð 	r3   r   aM  

The CFG Editor can be used to create or modify context free grammars.
A context free grammar consists of a start symbol and a list of
productions.  The start symbol is specified by the text entry field in
the upper right hand corner of the editor; and the list of productions
are specified in the main text editing box.

Every non-blank line specifies a single production.  Each production
has the form "LHS -> RHS," where LHS is a single nonterminal, and RHS
is a list of nonterminals and terminals.

Nonterminals must be a single word, such as S or NP or NP_subj.
Currently, nonterminals must consists of alphanumeric characters and
underscores (_).  Nonterminals are colored blue.  If you place the
mouse over any nonterminal, then all occurrences of that nonterminal
will be highlighted.

Terminals must be surrounded by single quotes (') or double
quotes(").  For example, "dog" and "New York" are terminals.
Currently, the string within the quotes must consist of alphanumeric
characters, underscores, and spaces.

To enter a new production, go to a blank line, and type a nonterminal,
followed by an arrow (->), followed by a sequence of terminals and
nonterminals.  Note that "->" (dash + greater-than) is automatically
converted to an arrow symbol.  When you move your cursor to a
different line, your production will automatically be colorized.  If
there are any errors, they will be highlighted in red.

Note that the order of the productions is significant for some
algorithms.  To re-order the productions, use cut and paste to move
them.

Use the buttons at the bottom of the window when you are done editing
the CFG:
  - Ok: apply the new CFG, and exit the editor.
  - Apply: apply the new CFG, and do not exit the editor.
  - Reset: revert to the original CFG, and do not exit the editor.
  - Cancel: revert to the original CFG, and exit the editor.

c                   óÜ  a € ] tR t^•t o Rt]P                  R,          t]P                  ! R],           R,           4      t
]P                  ! R],           R,           4      t]P                  ! R],           R,           R,           4      t]P                  ! R],           R	,           4      tR tR!R ltR tR tR tR tR tR tR tR tR"R ltR tR tR tR tR tR tR tR t R t!R t"Rt#V t$R
# )#Ú	CFGEditora  
A dialog window for creating and editing context free grammars.
``CFGEditor`` imposes the following restrictions:

- All nonterminals must be strings consisting of word
  characters.
- All terminals must be strings consisting of word characters
  and space characters.
r   z(^\s*\w+\s*)(->|(z))z\s*(->|(z))\s*z#((\w+|'[\w ]*'|\"[\w ]*\"|\|)\s*)*$z\w+|->|'[\w ]+'|"[\w ]+"|(Ú)Nc                óþ  € Wn         Ve   W n        M\        \        R4      . 4      V n        W0n        ^V n        \        V4      V n        V P                  4        V P                  4        V P                  P                  RR^ R7       V P                  4        V P                  P                  RR^R7       V P                  4        V P                  P                  RR^ R7       V P                   P#                  4        R # )NÚSÚtopÚx©ÚsideÚfillÚexpandÚbothÚbottom)Ú_parentÚ_cfgr   r   Ú_set_cfg_callbackÚ _highlight_matching_nonterminalsr   Ú_topÚ_init_bindingsÚ_init_startframeÚ_startframeÚpackÚ_init_prodframeÚ
_prodframeÚ_init_buttonsÚ_buttonframeÚ_textwidgetÚfocus)r-   ÚparentÚcfgÚset_cfg_callbacks   &&&&r0   Ú__init__ÚCFGEditor.__init__¯   sÑ   € ØŒØŠ?Ø�IäœK¨Ó,¨bÓ1ˆDŒIØ!1Ôà01ˆÔ-ô ˜VÓ$ˆŒ	Ø×ÑÔà×ÑÔØ×Ñ×Ñ 5¨s¸1ÐÔ=Ø×ÑÔØ�‰×Ñ %¨f¸QÐÔ?Ø×ÑÔØ×Ñ×Ñ H°3¸qÐÔAà×Ñ×ÑÖ r3   c                óŒ  € \        V P                  4      ;qn        \        V4      V n        V P                  P                  R R7       \        VRR7      P                  R R7       \        VRR7      P                  RR7       V P                  P                  ^ V P                  P                  4       P                  4       4       R# )Úright©rS   zStart Symbol:©ÚtextzProductions:ÚleftN)r   r\   r_   r   Ú_startr`   r   ÚinsertrY   Ústartr!   ©r-   Úframes   & r0   r^   ÚCFGEditor._init_startframeÆ   sŽ   € Ü#(¨¯©Ó#3Ð3ˆÔ Ü˜E“lˆŒØ�‰×Ñ˜gÐÔ&Üˆe˜/Ô*×/Ñ/°WÐ/Ô=Üˆe˜.Ô)×.Ñ.°FÐ.Ô;Ø�‰×Ñ˜1˜dŸi™iŸo™oÓ/×6Ñ6Ó8Ö9r3   c                óà  € \        V P                  4      ;qn        \        VR V P                  ^ ^ R7      P                  RR7       \        VRV P                  ^ ^ R7      P                  RR7       \        VRV P                  ^ ^ R7      P                  RR7       \        VRV P                  ^ ^ R7      P                  RR7       \        VRV P                  ^ ^ R7      P                  RR7       R	# )
ÚOk)rp   Úcommandr$   Ú	takefocusrq   rn   ÚApplyÚResetÚCancelÚHelprm   N)
r   r\   rd   r   Ú_okr`   Ú_applyÚ_resetÚ_cancelÚ_helpru   s   & r0   rc   ÚCFGEditor._init_buttonsÎ   sá   € Ü$)¨$¯)©)Ó$4Ð4ˆÔ!Üˆu˜4¨¯©¸QÈ!ÔL×QÑQØð 	Rô 	
ô 	ˆu˜7¨D¯K©KÀ1ÐPQÔR×WÑWØð 	Xô 	
ô 	ˆu˜7¨D¯K©KÀ1ÐPQÔR×WÑWØð 	Xô 	
ô 	Ø˜¨$¯,©,À!Èqô	
ç
‰$�Fˆ$Ô
Üˆu˜6¨4¯:©:ÀÈaÔP×UÑUØð 	Vö 	
r3   c                ó°  € V P                   P                  R 4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  R	V P
                  4       V P                   P                  R
V P
                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       V P                   P                  RV P                  4       R# )z
CFG Editorú<Control-q>z<Alt-q>z<Control-d>z<Alt-x>z<Escape>z<Alt-c>z<Control-o>z<Alt-o>z<Control-a>z<Alt-a>z<Control-r>z<Alt-r>z<Control-h>z<Alt-h>z<F1>N)r\   ÚtitleÚbindrƒ   r€   r�   r‚   r„   )r-   s   &r0   r]   ÚCFGEditor._init_bindingsà   s\  € Ø�	‰	�‰˜Ô%Ø�	‰	�‰�} d§l¡lÔ3Ø�	‰	�‰�y $§,¡,Ô/Ø�	‰	�‰�} d§l¡lÔ3à�	‰	�‰�y $§,¡,Ô/Ø�	‰	�‰�z 4§<¡<Ô0à�	‰	�‰�y $§,¡,Ô/à�	‰	�‰�} d§h¡hÔ/Ø�	‰	�‰�y $§(¡(Ô+Ø�	‰	�‰�} d§k¡kÔ2Ø�	‰	�‰�y $§+¡+Ô.Ø�	‰	�‰�} d§k¡kÔ2Ø�	‰	�‰�y $§+¡+Ô.Ø�	‰	�‰�} d§j¡jÔ1Ø�	‰	�‰�y $§*¡*Ô-Ø�	‰	�‰�v˜tŸz™zÖ*r3   c                óì  € \        V P                  4      V n        \        V P                  R ^R7      V n        \        V P                  ^ RR7      V n        V P                  P                  V P                  P                  R7       V P                  P                  V P                  P                  R7       V P                  P                  RRR7       V P                  P                  ^R	R
R7       V P                  P                  RRR7       V P                  P                  RRR7       V P                  P                  RRR7       ^ V n        V P                  P                  RV P                  4       V P                  P                  RV P                  4       V P                  P                  RV P                   4       V P                  P                  RV P                   4       V P                  3R lpV P                  P                  RV4       V P"                  P%                  4        Uu. uF#  q"P'                  4       VP)                  4       .3NK%  	  pp\+        \-        V4      ^,
          ^ R"4       FË  pW4,          ^ ,          W4^,
          ,          ^ ,          8X  g   K-  R#W4,          ^,          9   d   KC  R#W4^,
          ,          ^,          9   d   K`  \/        W4^,
          ,          ^,          4       \/        W4,          ^,          4       W4^,
          ,          ^,          P1                  W4,          ^,          4       W4 KÍ  	  V F”  w  rV\/        WV4       RV,          pV FM  pV F;  p	\3        V	\4        4      '       d   VRV	,          ,          pK+  VRV	,          ,          pK=  	  VR,          pKO  	  VRR$ R ,           pV P                  P7                  R!V4       K–  	  V P                  4        R# u upi )%z#e0e0e0)Ú
backgroundÚexportselectionÚvertical)r{   Úorient)Úyscrollcommand)rz   rm   Úy©rS   rT   rV   rq   )rU   rT   rS   r   r   r   r    r!   )r#   ÚerrorÚred©rŒ   Ú>z	<<Paste>>z
<KeyPress>z<ButtonPress>c                 óB   € VP                  4       P                  4        R # ©N)Útk_focusNextrf   )Úer.   s   &&r0   ÚcycleÚ(CFGEditor._init_prodframe.<locals>.cycle  s   € Ø×#Ñ#Ó%×+Ñ+Ö-r3   z<Tab>z%s ->r5   r6   z |NÚ
ÚendéÿÿÿÿrA   éþÿÿÿ)r   r\   rb   r	   re   r   Ú_textscrollÚconfigÚsetÚyviewr`   r,   Ú_linenumr‰   Ú_replace_arrowsÚ_analyzeÚ_check_analyzerY   Úproductionsr8   r:   ÚrangeÚlenÚprintÚextendr;   r   rs   )
r-   r›   ÚpÚprod_tuplesÚir8   ÚrhssÚsr:   r>   s
   &         r0   ra   ÚCFGEditor._init_prodframeõ   s  € Ü §	¡	Ó*ˆŒô  Ø�O‰O¨	À1ô
ˆÔô % T§_¡_ÀÈ*ÔUˆÔØ×Ñ×Ñ¨t×/?Ñ/?×/CÑ/CÐÔDØ×Ñ×Ñ¨×(8Ñ(8×(>Ñ(>ÐÔ?Ø×Ñ×Ñ 7°ÐÔ5Ø×Ñ×Ñ Q¨V¸&ÐÔAð 	×Ñ×#Ñ# J¸9Ð#ÔEØ×Ñ×#Ñ# G°(Ð#Ô;Ø×Ñ×#Ñ# G¸Ð#Ô>ð ˆŒð 	�	‰	�‰�s˜D×0Ñ0Ô1ð 	�	‰	�‰�{ D§M¡MÔ2Ø�	‰	�‰�| T×%8Ñ%8Ô9Ø�	‰	�‰�¨×(;Ñ(;Ô<ð !%× 0Ñ 0ô 	.ð 	×Ñ×Ñ˜g uÔ-à59·Y±Y×5JÑ5JÔ5LÓMÑ5L°Ÿ™› !§%¡%£' Ó+Ñ5LˆÐMÜ”s˜;Ó'¨!Õ+¨Q°Ö3ˆAØ�~˜aÕ  K°AµÕ$6°qÕ$9Ö9Ø˜�¨Õ*Ô*ÙØ˜¨¥UÕ+¨AÕ.Ô.ÙÜ�k a¥%Õ(¨Õ+Ô,Ü�k•n QÕ'Ô(Ø �EÕ" 1Õ%×,Ñ,¨[­^¸AÕ->Ô?Ø’Nñ 4ó %‰IˆCÜ�#ÔØ˜#•ˆAÛ�Û�CÜ! #¤{×3Ò3Ø˜U S�[Õ(šà˜U S�[Õ(šñ	 ð
 �T•	’ñ ð �#�2�˜•ˆAØ×Ñ×#Ñ# E¨1Ö-ñ %ð 	�‰Žùò3 Ns   È.)O1c                ó¶   € RV,          pRV,          pV P                   P                  4        F(  pVR9  g   K  V P                   P                  WBV4       K*  	  R# )zy
Remove all tags (except ``arrow`` and ``sel``) from the given
line of the text widget used for editing the productions.
ú%d.0ú%d.endN)r    Úsel)re   Ú	tag_namesÚ
tag_remove)r-   Úlinenumrt   rž   Útags   &&   r0   Ú_clear_tagsÚCFGEditor._clear_tagsN  sP   € ð
 ˜Õ ˆØ˜Õ ˆØ×#Ñ#×-Ñ-Ö/ˆCØÐ*Ö*Ø× Ñ ×+Ñ+¨C¸Ö<ó 0r3   c                ó  € \        V P                  P                  R4      P                  R4      ^ ,          4      pW P                  8w  d5   V P                  V4       V P                  V P                  4       W n        R# R# )z—
Check if we've moved to a new line.  If we have, then remove
all colorization from the line we moved to, and re-colorize
the line that we moved from.
rs   Ú.N)Úintre   ÚindexÚsplitr¥   r¼   Ú_analyze_line)r-   rš   rº   s   &* r0   r¨   ÚCFGEditor._check_analyzeY  sc   € ô �d×&Ñ&×,Ñ,¨XÓ6×<Ñ<¸SÓAÀ!ÕDÓEˆØ—m‘mÔ#Ø×Ñ˜WÔ%Ø×Ñ˜tŸ}™}Ô-Ø#ŽMñ $r3   c                óÜ  € Rp V P                   P                  RVR4      pVR8X  d   MfV P                   P                  W"R,           4       V P                   P                  W P                  R4       V P                   P                  VR4       KŒ  Rp V P                   P                  V P                  VR,           R4      pVR8X  d   R	# V P                   P                  RW"R,           4       K]  )
z£
Replace any ``'->'`` text strings with arrows (char \256, in
symbol font).  This searches the whole buffer, but is fast
enough to be done anytime they press '>'.
ú1.0ú->z	end+1charÚ z+2charr    Ú	z+1charN)re   ÚsearchÚdeleters   r9   Útag_add)r-   rš   r    s   &* r0   r¦   ÚCFGEditor._replace_arrowse  sÉ   € ð ˆØØ×$Ñ$×+Ñ+¨D°%¸ÓEˆEØ˜Œ{ØØ×Ñ×#Ñ# E°8Õ+;Ô<Ø×Ñ×#Ñ# E¯:©:°wÔ?Ø×Ñ×#Ñ# E¨4Ö0àˆØØ×$Ñ$×+Ñ+¨D¯J©J¸ÀÕ8HÈ+ÓVˆEØ˜Œ{ÙØ×Ñ×$Ñ$ W¨e¸XÕ5EÖFr3   c                ó°  € VP                  4       ^ ,          R9   d   RpMjVP                  4       RV P                  39   d   RpMFRVP                  4       ,           pW0P                  P                  4       9  d   V P	                  V4       RW!P                  4       3,          pRW!P                  4       3,          pV P                  P                  W4V4       R# )zÅ
Given a line number and a regexp match for a token on that
line, colorize the token.  Note that the regexp match gives us
the token's text, start index (on the line), and end index (on
the line).
z'"r   rÇ   r    Únonterminal_ú%d.%dN)Úgroupr9   re   r¸   Ú_init_nonterminal_tagrt   rž   rÌ   )r-   Úmatchrº   r»   rt   rž   s   &&&   r0   Ú_analyze_tokenÚCFGEditor._analyze_token{  s©   € ð �;‰;‹=˜Õ˜uÔ$Ø‰CØ�[‰[‹]˜t T§Z¡ZÐ0Ô0Ø‰Cð
 ! 5§;¡;£=Õ0ˆCØ×*Ñ*×4Ñ4Ó6Ô6Ø×*Ñ*¨3Ô/à˜7§K¡K£MÐ2Õ2ˆØ˜§)¡)£+Ð.Õ.ˆØ×Ñ× Ñ  ¨SÖ1r3   c                ó<  € V P                   P                  W\        P                  R 7       V P                  '       g   R# V P                   V3R lpV P                   V3R lpV P                   P                  VRV4       V P                   P                  VRV4       R# )r'   Nc                 ó,   € VP                  VR R7       R# )z#80ff80r•   Nr+   ©rš   r.   r»   s   &&&r0   ÚenterÚ.CFGEditor._init_nonterminal_tag.<locals>.enter˜  s   € Ø×!Ñ! #°)Ð!Ö<r3   c                 ó,   € VP                  VR R7       R# )rÈ   r•   Nr+   rØ   s   &&&r0   ÚleaveÚ.CFGEditor._init_nonterminal_tag.<locals>.leave›  s   € Ø×!Ñ! #°"Ð!Ö5r3   z<Enter>z<Leave>)re   r,   rL   Ú_BOLDr[   Útag_bind)r-   r»   r   rÙ   rÜ   s   &&&  r0   rÒ   ÚCFGEditor._init_nonterminal_tag“  s‚   € Ø×Ñ×#Ñ# CÄYÇ_Á_Ð#ÔUØ×4×4Ð4Ùà $× 0Ñ 0°cô 	=ð !%× 0Ñ 0°cô 	6ð 	×Ñ×!Ñ! # y°%Ô8Ø×Ñ×!Ñ! # y°%Ö8r3   c                óˆ  € V P                  V4       V P                  P                  \        V4      R,           \        V4      R,           4      p\        P
                  P                  V4      '       d(   W3R lp\        P                  P                  W24       R# VP                  4       R8w  d   V P                  W4       R# R# )z
Colorize a given line.
z.0z.endc                 ó(   € VP                  W4       R # )rÈ   )rÔ   )rÓ   r-   rº   s   &&&r0   Úanalyze_tokenÚ.CFGEditor._analyze_line.<locals>.analyze_token¯  s   € Ø×#Ñ# EÔ3Ùr3   rÈ   N)r¼   re   ÚgetÚreprrL   Ú_PRODUCTION_RErÓ   Ú	_TOKEN_REÚsubÚstripÚ_mark_error)r-   rº   Úlinerã   s   &&  r0   rÃ   ÚCFGEditor._analyze_line¡  s˜   € ð
 	×Ñ˜Ô!ð ×Ñ×#Ñ#¤D¨£M°DÕ$8¼$¸w»-È&Õ:PÓQˆô ×#Ñ#×)Ñ)¨$×/Ò/ð +/ô ô ×Ñ×#Ñ# MÖ8Ø�Z‰Z‹\˜RÔà×Ñ˜WÖ+ñ  r3   c                óì  € \         P                  P                  V4      pV'       g   RV,          pRV,          pMh\         P                  P	                  V4      '       g#   RV,          pRWP                  4       3,          pM!RWP                  4       3,          pRV,          pV P                  P                  VRV4      '       d   RV,          pRV,          pV P                  P                  RWE4       R# )z*
Mark the location of an error in a line.
rµ   r¶   rÐ   z==r“   N)
rL   Ú	_ARROW_RErÊ   Ú_LHS_RErÓ   rt   rž   re   ÚcomparerÌ   )r-   rº   rì   Ú
arrowmatchrt   rž   s   &&&   r0   rë   ÚCFGEditor._mark_error¸  sÏ   € ô ×(Ñ(×/Ñ/°Ó5ˆ
ßà˜WÕ$ˆEØ˜WÕ$‰CÜ×"Ñ"×(Ñ(¨×.Ò.à˜WÕ$ˆEØ˜W×&6Ñ&6Ó&8Ð9Õ9‰Cð ˜w¯©Ó(8Ð9Õ9ˆEØ˜WÕ$ˆCð ×Ñ×#Ñ# E¨4°×5Ò5Ø˜WÕ$ˆEØ˜WÕ$ˆCØ×Ñ× Ñ  ¨%Ö5r3   c                óð   € V P                  4        \        V P                  P                  R4      P	                  R4      ^ ,          4      p\        ^V^,           4       F  pV P                  V4       K  	  R# )z=
Replace ``->`` with arrows, and colorize the entire buffer.
rž   r¿   N)r¦   rÀ   re   rÁ   rÂ   rª   rÃ   )r-   rš   Únumlinesrº   s   &*  r0   r§   ÚCFGEditor._analyzeÐ  s^   € ð 	×ÑÔÜ�t×'Ñ'×-Ñ-¨eÓ4×:Ñ:¸3Ó?ÀÕBÓCˆÜ˜Q ¨1¥Ö-ˆGØ×Ñ˜wÖ'ó .r3   c                ó@  € . pV P                   P                  RR4      p\        P                  ! V P                  RV4      p\        P                  ! RRV4      pVP                  R4      pV F.  pVP                  4       pVR8X  d   K  V\        V4      ,          pK0  	  V# )zW
Parse the current contents of the textwidget buffer, to create
a list of productions.
rÆ   rž   rÇ   rÉ   Ú r�   rÈ   )re   rå   Úreré   r9   rÂ   rê   r   )r-   r©   rp   Úlinesrì   s   &    r0   Ú_parse_productionsÚCFGEditor._parse_productionsÙ  s’   € ð
 ˆð ×Ñ×#Ñ# E¨5Ó1ˆÜ�vŠv�d—j‘j $¨Ó-ˆÜ�vŠv�d˜C Ó&ˆØ—
‘
˜4Ó ˆó ˆDØ—:‘:“<ˆDØ�rŒzÙØÔ/°Ó5Õ5ŠKñ	 ð* Ðr3   c                óh   € V P                   f   R # V P                   P                  4        R V n         R # r˜   ©r\   Údestroy©r-   rš   s   &*r0   Ú_destroyÚCFGEditor._destroyþ  s&   € Ø�9‰9ÒÙØ�	‰	×ÑÔØˆŽ	r3   c                óF   € V P                  4        V P                  4        R # r˜   )r�   r  r   s   &*r0   r€   ÚCFGEditor._ok  s   € Ø�‰ŒØ�‰Žr3   c                óÄ   € V P                  4       p\        V P                  P                  4       4      p\	        W24      pV P
                  e   V P                  V4       R # R # r˜   )rû   r   rr   rå   r   rZ   )r-   rš   r©   rt   rh   s   &*   r0   r�   ÚCFGEditor._apply  sN   € Ø×-Ñ-Ó/ˆÜ˜DŸK™KŸO™OÓ-Ó.ˆÜ�%Ó%ˆØ×!Ñ!Ò-Ø×"Ñ" 3Ö'ñ .r3   c                ó<  € V P                   P                  R R4       V P                  P                  4        F&  pV P                   P	                  RRV,          4       K(  	  V P                  4        V P                  e   V P                  V P                  4       R# R# )rÆ   rž   z%s
N)re   rË   rY   r©   rs   r§   rZ   )r-   rš   Ú
productions   &* r0   r‚   ÚCFGEditor._reset  sv   € Ø×Ñ×Ñ  uÔ-ØŸ)™)×/Ñ/Ö1ˆJØ×Ñ×#Ñ# E¨6°JÕ+>Ö?ñ 2à�‰ŒØ×!Ñ!Ò-Ø×"Ñ" 4§9¡9Ö-ñ .r3   c                óV   €  V P                  4        T P                  4        R #     L; ir˜   )r‚   r  r   s   &*r0   rƒ   ÚCFGEditor._cancel  s%   € ð	Ø�K‰KŒMð 	�‰Žøð	Ùús   ‚$ ¤(c                óÆ   €  \        V P                  R \        P                  4       ^KRR7       R#    \        T P                  R \        P                  4       ^KR7        R# ; i)zHelp: Chart Parser DemoÚfixed)Úwidthr#   ©r  N)r   rX   Ú_CFGEditor_HELPrê   r   s   &*r0   r„   ÚCFGEditor._help  sX   € ð	ÜØ—‘Ø)Ü ×'Ñ'Ó)ØØ÷øð	ÜØ—‘Ø)Ü ×'Ñ'Ó)Ø÷	ð ús	   ‚,0 °-A )rd   rY   r[   r¥   rX   rb   rZ   rr   r_   r¡   re   r\   r(   )NN)r&   )%rB   rC   rD   rE   Ú__doc__r   rF   r9   rù   Úcompilerð   rï   rç   rè   rÞ   rj   r^   rc   r]   ra   r¼   r¨   r¦   rÔ   rÒ   rÃ   rë   r§   rû   r  r€   r�   r‚   rƒ   r„   rG   rH   rI   s   @r0   rL   rL   •   s  ø‡ € ñð × Ñ  Õ.€EØ�jŠjÐ-°Õ5¸Õ<Ó=€GØ—
’
˜;¨Õ.°Õ9Ó:€IØ—Z’Zð	à
õ	ð õ	ð 1õ		1ó€Nð —
’
Ð<¸uÕDÀsÕJÓK€IØ&€Eô!ò.:ò
ò$+ò*>òr	=ò
$òGò,2ô09ò,ò.6ò0(ò#òJòò(ò.ò÷ð r3   rL   c                   ór   a € ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tRR ltR tR tR tRtV tR# )ÚCFGDemoi6  c                óJ  € Wn         W n        \        4       V n        V P                  P	                  R 4       \        V P                  4      V n        V P                  P                  ^4       V P                  V P                  4       \        V P                  4      pVP                  RR^ R7       V P                  V P                  4       V P                  V P                  4       V P                  V4       V P                  V4       V P                  V P                  4       R# )zContext Free Grammar Demorq   r‘   rR   N)Ú_grammarÚ_textr
   r\   rˆ   r   Ú_sizer£   r]   r   r`   Ú_init_menubarrc   Ú_init_grammarÚ_init_treeletÚ_init_workspace)r-   Úgrammarrp   Úframe1s   &&& r0   rj   ÚCFGDemo.__init__7  sÒ   € ØŒØŒ
ô “DˆŒ	Ø�	‰	�‰Ð3Ô4ô ˜DŸI™IÓ&ˆŒ
Ø�
‰
�‰�rÔð 	×Ñ˜DŸI™IÔ&ô �t—y‘yÓ!ˆØ�‰˜ c°!ˆÔ4Ø×Ñ˜4Ÿ9™9Ô%Ø×Ñ˜4Ÿ9™9Ô%Ø×Ñ˜6Ô"Ø×Ñ˜6Ô"Ø×Ñ˜TŸY™YÖ'r3   c                ó>   € VP                  R V P                  4       R# )r‡   N)r‰   rÿ   )r-   rP   s   &&r0   r]   ÚCFGDemo._init_bindingsS  s   € Ø�‰� §¡Ö-r3   c                ó   € R # r˜   rA   ©r-   rg   s   &&r0   r  ÚCFGDemo._init_menubarV  ó   € Ùr3   c                ó   € R # r˜   rA   r$  s   &&r0   rc   ÚCFGDemo._init_buttonsY  r&  r3   c                óF  € \        WP                  ^R7      V n        V P                  P                  RR^R7       V P                  P	                  4        V P                  P                  RV P                  4       V P                  P                  RV P                  4       R# )é   r  rP   rV   rR   ÚselectÚmoveN)r   r  Ú	_prodlistr`   rf   Úadd_callbackÚ_selectprod_cbr$  s   &&r0   r  ÚCFGDemo._init_grammar\  sq   € Ü'¨·±ÀRÔHˆŒØ�‰×Ñ ¨V¸AÐÔ>Ø�‰×ÑÔØ�‰×#Ñ# H¨d×.AÑ.AÔBØ�‰×#Ñ# F¨D×,?Ñ,?Ö@r3   c                ór   € \        VR R7      V n        V P                  P                  RRR7       RV n        R# )Úwhiter•   rW   rQ   r’   N)r   Ú_treelet_canvasr`   Ú_treeletr$  s   &&r0   r  ÚCFGDemo._init_treeletc  s1   € Ü% f¸ÔAˆÔØ×Ñ×!Ñ! x°cÐ!Ô:ØˆŽr3   c                ó”   € \        VR R7      V n        V P                  P                  RR^R7       RV n        V P	                  4        R# )r2  r•   rm   rV   rR   N)r   Ú
_workspacer`   Ú_treeÚreset_workspacer$  s   &&r0   r  ÚCFGDemo._init_workspaceh  s<   € Ü% f¸ÔAˆŒØ�‰×Ñ '°¸qÐÔAØˆŒ
Ø×ÑÖr3   c           
     óŽ  € V P                   P                  4       p\        V P                  P	                  4       4      pR V^,           ) R3pR V^,           ) 3pV P
                  e&   V P                   P                  V P
                  4       V P                  P                  4       P                  4       p\        WV^R7      p. pV P                   F   pVP                  \        WV^R7      4       K"  	  \        WVRR7      V n        V P                   P                  V P
                  4       V F  p	V	P                  ^ ^d4       K  	  R# )r)   r*   N)r#   Ú	draggabler2  )Úcolor)r7  ÚcanvasrÀ   r  rå   r8  Úremove_widgetr  rt   r!   r   r  r7   r   Ú
add_widgetr,  )
r-   ÚcÚfontsizeÚ	node_fontÚ	leaf_fontrt   ÚrootnodeÚleavesÚwordÚleafs
   &         r0   r9  ÚCFGDemo.reset_workspacer  s  € Ø�O‰O×"Ñ"Ó$ˆÜ�t—z‘z—~‘~Ó'Ó(ˆØ  H¨q¥L /°6Ð:ˆ	Ø  H¨q¥L /Ð2ˆ	ð �:‰:Ò!Ø�O‰O×)Ñ)¨$¯*©*Ô5ð —‘×#Ñ#Ó%×,Ñ,Ó.ˆÜ˜a¨YÀ!ÔDˆð ˆØ—J”JˆDØ�M‰Mœ* Q°9ÈÔJÖKñ ô ' q°FÀ'ÔJˆŒ
ð 	�‰×"Ñ" 4§:¡:Ô.ó ˆDØ�I‰I�a˜Öó r3   c                ó   € R # r˜   rA   )r-   r  s   &&r0   Úworkspace_markprodÚCFGDemo.workspace_markprod’  r&  r3   Nc                óÂ  € Vf   V P                   p\        \        VP                  4       4      \        VP	                  4       4      ,
          4       EF	  pVRV3,          R8X  d   V P
                   \        VP	                  4       4       FÀ  w  rEVP                  4       W4,           ,          p\        V\        4      '       dF   \        V\        4      '       d0   VP                  VP                  4       P                  4       8X  d   K}  \        V\        4      '       d-   \        V\        4      '       d   WVP                  4       8X  d   K¿   Kû  	  \        RV4       EK  	  R # )Nr=  r2  zMATCH AT)r8  rª   r«   Úsubtreesr:   Ú_markproductionÚ	enumerater;   r   r   r!   Úlabelrp   Ústrr   r¬   )r-   ÚprodÚtreer°   ÚjÚnodeÚwidgets   &&&    r0   rO  ÚCFGDemo._markproduction•  sí   € ØŠ<Ø—:‘:ˆDÜ”s˜4Ÿ=™=›?Ó+¬c°$·(±(³*«oÕ=×>ˆAØ�G˜Q�JÕ 7Ô*Ø×$Ò$ä$ T§X¡X£ZÖ0‘�ØŸ™›¨­Õ/�ä˜t¤[×1Ò1Ü" 6Ô+<×=Ò=ØŸ™ v§|¡|£~×':Ñ':Ó'<Ô<áä˜t¤S×)Ò)Ü" 6¬:×6Ò6Ø§¡£Ô-áâñ 1ô$ �j !×$ó- ?r3   c                óh  € V P                   pV P                  P                  V4       V P                  e   V P                  P	                  4        VP                  4       p\        V4       F(  w  rE\        V\        4      '       g   K  \        V4      pK*  	  \        VP                  4       P                  4       .VO5!  p\        V P                  P                  4       4      pRV^,           ) R3pRV^,           ) 3p	\        W&W‰R7      V n        ^V P                  R&   V P                  P!                  4       w  r«rÍ\        VR,          4      \        VR,          4      rþV P                  P#                  Wê,
          V,
          ^,          Wû,
          V,
          ^,          4       V P%                  V4       R # )Nr)   r*   )rC  rD  r<  r  Úheight)r3  r-  Ú	highlightr4  rÿ   r:   rP  r;   r   r   r8   r!   rÀ   r  rå   r   Úbboxr,  rO  )r-   r  r>  r:   r°   r>   rT  rB  rC  rD  Úx1Úy1Úx2Úy2ÚwÚhs   &&              r0   r/  ÚCFGDemo._selectprod_cb´  sU  € Ø×%Ñ%ˆà�‰× Ñ  Ô,Ø�=‰=Ò$Ø�M‰M×!Ñ!Ô#ð �n‰nÓˆÜ –n‰FˆAÜ˜#œ{×+Ô+Ü˜3“i’ñ %ô �J—N‘NÓ$×+Ñ+Ó-Ð4°Ó4ˆô �t—z‘z—~‘~Ó'Ó(ˆØ  H¨q¥L /°6Ð:ˆ	Ø  H¨q¥L /Ð2ˆ	Ü+Ø Iô
ˆŒð &'ˆ�‰�kÑ"ð  Ÿ=™=×-Ñ-Ó/Ñˆ�Ü�6˜'•?Ó#¤S¨°Õ)9Ó%:ˆ1Ø�‰×Ñ˜A�F R�K¨1Õ,¨q­v¸­{¸aÕ.?Ô@ð 	×Ñ˜ZÖ(r3   c                ó:   € V P                   P                  4        R # r˜   rþ   )r-   Úargss   &*r0   rÿ   ÚCFGDemo.destroyÓ  s   € Ø�	‰	×ÑÖr3   c                ó>   € V P                   P                  ! V/ VB  R # r˜   )r\   Úmainloop)r-   re  Úkwargss   &*,r0   rh  ÚCFGDemo.mainloopÖ  s   € Ø�	‰	×Ò˜DÐ+ FÔ+r3   )	r  r-  r  r  r\   r8  r4  r3  r7  r˜   )rB   rC   rD   rE   rj   r]   r  rc   r  r  r  r9  rK  rO  r/  rÿ   rh  rG   rH   rI   s   @r0   r  r  6  sM   ø‡ € ò(ò8.òòòAòò
òò@ô%ò>)ò>÷,ð ,r3   r  c                  ó6  a€ ^ RI Hp HoHp RpV3R lVP                  ! 4        4       w	  r4rVrxršpV! W5V.4      V! W[V.4      V! WUV.4      V! WDV.4      V! WJWV.4      V! WJV.4      V! WgV.4      V! V. 4      V! VRRV.4      V! VR.4      V! VR.4      V! VR.4      V! VR	.4      V! V
R
.4      V! VR.4      V! VR.4      V! VR.4      V! VR.4      V! VR.4      V! VR.4      3pV ! W<4      pRP	                  4       p\        WÞ4      pVP                  4        R# )é    )r   r   Ú
ProductionúS VP NP PP P N Name V Detc              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5ir˜   rA   ©Ú.0r²   r   s   & €r0   Ú	<genexpr>Údemo2.<locals>.<genexpr>Þ  ó   øé € Ð*XÑCW¸a©;°q¯>¨>ÓCWùó   ƒÚupÚoverÚIÚtheÚaÚmanÚsawÚinÚwithÚparkÚdogÚstatueÚmyzI saw a man in the parkN)Únltkr   r   rm  rÂ   r  rh  )r   rm  r   rO   ÚVPÚNPÚPPÚPÚNÚNameÚVÚDetr©   r  rp   Údr   s                   @r0   Údemo2r�  Ú  sU  ø€ ß1Ñ1à.€LÜ*XÀ<×CUÒCUÔCWÓ*XÑ'€QˆB�A˜$ 3ñ 	�1˜2�hÓÙ�2˜Q�xÓ Ù�2˜B�xÓ Ù�2˜B�xÓ Ù�2˜2�{Ó#Ù�2˜2�wÓÙ�2˜2�wÓÙ�2�rÓÙ�2˜˜f bÐ)Ó*á�2˜�uÓÙ�3˜˜Ó Ù�3˜˜ÓÙ�1�u�gÓÙ�1�u�gÓÙ�1�t�fÓÙ�1�v�hÓÙ�1�v�hÓÙ�1�u�gÓÙ�1�x�jÓ!Ù�3˜˜Óð-€Kñ0 �!Ó!€Gà$×*Ñ*Ó,€DÜ�Ó€AØ‡J�J†Lr3   c            	      óV  a€ ^ RI Hp Ho RpV3R lVP                  ! 4        4       w	  r#rErgr‰p
V P                  ! R4      pR p\        4       p\        WÛV4      p\        VRR7      P                  4        \        VRVP                  R	7      P                  4        VP                  4        R
# )rl  )r   r   rn  c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5ir˜   rA   rp  s   & €r0   rr  Údemo.<locals>.<genexpr>  rt  ru  a+  
    S -> NP VP
    PP -> P NP
    NP -> Det N
    NP -> NP PP
    VP -> V NP
    VP -> VP PP
    Det -> 'a'
    Det -> 'the'
    Det -> 'my'
    NP -> 'I'
    N -> 'dog'
    N -> 'man'
    N -> 'park'
    N -> 'statue'
    V -> 'saw'
    P -> 'in'
    P -> 'up'
    P -> 'over'
    P -> 'with'
    c                 ó   € \        V 4       R # r˜   )r¬   )r  s   &r0   ÚcbÚdemo.<locals>.cb!  s	   € ÜˆgŽr3   z
Testing CFG Editor
ro   ÚQuit)rp   rz   N)rƒ  r   r   rÂ   Ú
fromstringr
   rL   r   r`   r   rÿ   rh  )r   r   rO   r„  r…  r†  r‡  rˆ  r‰  rŠ  r‹  r  r’  rP   Úeditorr   s                  @r0   Údemor—    sŒ   ø€ ß%à.€LÜ*XÀ<×CUÒCUÔCWÓ*XÑ'€QˆB�A˜$ 3à�nŠnð	ó€Gò0ô ‹$€CÜ�s RÓ(€FÜ	ˆ#Ð,Ô-×2Ñ2Ô4Ü
ˆ3�V S§[¡[Ô1×6Ñ6Ô8Ø‡L�L†Nr3   c                  ó  € ^ RI Hp  \        R4      w	  rr4rVrxp	V ! WV.4      V ! W9V.4      V ! W3V.4      V ! W"V.4      V ! W(W4.4      V ! W(V.4      V ! WEV.4      V ! V. 4      V ! VRRV.4      V ! VR.4      V ! V	R.4      V ! V	R.4      V ! VR.4      V ! VR	.4      V ! VR
.4      V ! VR.4      V ! VR.4      V ! VR.4      V ! VR.4      V ! V	R.4      3p
\        4       pV3R lpVP	                  RV4       \        Wº4      pVP                  ^RR7       VP                  RVP                  4       VP                  RVP                  4       VP                  4        VP                  V
^,          4       VP                  V
^,          4       R# )rl  )rm  z!S, VP, NP, PP, P, N, Name, V, Detrv  rw  rx  ry  rz  r{  r|  r}  r~  r  r€  r�  r‚  c                 ó&   € VP                  4        R # r˜   )rÿ   )rš   Úts   &&r0   rÿ   Údemo3.<locals>.destroyM  s   € Ø	�	‰	Žr3   ÚqrV   )rU   rT   r+  r,  N)rƒ  rm  r   r
   r‰   r   r`   r.  Úmarkonlyrf   Úmark)rm  rO   r„  r…  r†  r‡  rˆ  r‰  rŠ  r‹  r©   rš  rÿ   r®   s                 r0   Údemo3rŸ  +  s¡  € Ýä*6Ø+ó+Ñ'€QˆB�A˜$ 3ñ 	�1˜2�hÓÙ�2˜Q�xÓ Ù�2˜B�xÓ Ù�2˜B�xÓ Ù�2˜2�{Ó#Ù�2˜2�wÓÙ�2˜2�wÓÙ�2�rÓÙ�2˜˜f bÐ)Ó*á�2˜�uÓÙ�3˜˜Ó Ù�3˜˜ÓÙ�1�u�gÓÙ�1�u�gÓÙ�1�t�fÓÙ�1�v�hÓÙ�1�v�hÓÙ�1�u�gÓÙ�1�x�jÓ!Ù�3˜˜Óð-€Kô2 	‹€Aàô ð ‡F�Fˆ3�ÔÜ�qÓ&€AØ‡F�F�!˜&€FÔ!Ø‡N�N�8˜QŸZ™ZÔ(Ø‡N�N�6˜1Ÿ:™:Ô&Ø‡G�G„IØ‡F�Fˆ;�q�>ÔØ‡F�Fˆ;�q�>Ör3   Ú__main__)%r  rù   Útkinterr   r   r   r   r   r   r   r	   r
   r   Únltk.draw.treer   r   Únltk.draw.utilr   r   r   r   r   Únltk.grammarr   r   r   r   Ú	nltk.treer   r   r  rL   r  r�  r—  rŸ  rB   rA   r3   r0   Ú<module>r¦     s�   ðñóR 
÷÷ ÷ ÷ B÷õ ÷ NÓ MÝ ô�]ô ð4)€÷XYñ Y÷Ba,ñ a,òH!òR%òP,ð^ ˆzÔÙ†Fñ r3   