#NEWLINE# def _init_prodframe( self ) : #NEWLINE# #INDENT# self . _prodframe = Frame ( self . _top ) #NEWLINE# self . _textwidget = Text ( self . _prodframe , background = '#e0e0e0' , exportselection = 1 ) #NEWLINE# self . _textscroll = Scrollbar ( self . _prodframe , takefocus = 0 , orient = 'vertical' ) #NEWLINE# self . _textwidget . config ( yscrollcommand = self . _textscroll . set ) #NEWLINE# self . _textscroll . config ( command = self . _textwidget . yview ) #NEWLINE# self . _textscroll . pack ( side = 'right' , fill = 'y' ) #NEWLINE# self . _textwidget . pack ( expand = 1 , fill = 'both' , side = 'left' ) #NEWLINE# self . _textwidget . tag_config ( 'terminal' , foreground = '#006000' ) #NEWLINE# self . _textwidget . tag_config ( 'arrow' , font = 'symbol' ) #NEWLINE# self . _textwidget . tag_config ( 'error' , background = 'red' ) #NEWLINE# self . _linenum = 0 #NEWLINE# self . _top . bind ( '>' , self . _replace_arrows ) #NEWLINE# self . _top . bind ( '<<Paste>>' , self . _analyze ) #NEWLINE# self . _top . bind ( '<KeyPress>' , self . _check_analyze ) #NEWLINE# self . _top . bind ( '<ButtonPress>' , self . _check_analyze ) #NEWLINE# def cycle( e , textwidget = self . _textwidget ) : #NEWLINE# #INDENT# textwidget . tk_focusNext ( ) . focus ( ) #NEWLINE# #UNINDENT# self . _textwidget . bind ( '<Tab>' , cycle ) #NEWLINE# prod_tuples = [ ( p . lhs ( ) , [ p . rhs ( ) ] ) for p in self . _cfg . productions ( ) ] #NEWLINE# for i in range ( ( len ( prod_tuples ) - 1 ) , 0 , ( - 1 ) ) : #NEWLINE# #INDENT# if ( prod_tuples [ i ] [ 0 ] == self [ ( i - 1 ) ] [ 0 ] ) : #NEWLINE# #INDENT# if ( ( ) in prod_tuples [ i ] [ 1 ] ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( ) in prod_tuples [ ( i - 1 ) ] [ 1 ] ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# print ( prod_tuples [ ( i - 1 ) ] [ 1 ] ) #NEWLINE# print ( prod_tuples [ i ] [ 1 ] ) #NEWLINE# prod_tuples [ ( i - 1 ) ] [ 1 ] . extend ( prod_tuples [ i ] [ 1 ] ) #NEWLINE# del prod_tuples [ i ] #NEWLINE# #UNINDENT# #UNINDENT# for ( lhs , rhss ) in prod_tuples : #NEWLINE# #INDENT# print ( lhs , rhss ) #NEWLINE# s = ( '%s ->' % lhs ) #NEWLINE# for rhs in rhss : #NEWLINE# #INDENT# for elt in rhs : #NEWLINE# #INDENT# if isinstance ( elt , Nonterminal ) : #NEWLINE# #INDENT# s += ( ' %s' % elt ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# s += ( ' %r' % elt ) #NEWLINE# #UNINDENT# #UNINDENT# s += ' |' #NEWLINE# #UNINDENT# s = ( s [ : ( - 2 ) ] + '\n' ) #NEWLINE# self . _textwidget . insert ( 'end' , s ) #NEWLINE# #UNINDENT# self . _analyze ( )