#NEWLINE# def __init__( self , name , options , tokens , rules ) : #NEWLINE# #INDENT# self . change_count = 0 #NEWLINE# self . name = name #NEWLINE# self . options = options #NEWLINE# self . preparser = '' #NEWLINE# self . postparser = None #NEWLINE# self . tokens = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . ignore = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . terminals = [ ] #NEWLINE# for t in s : #NEWLINE# #INDENT# if ( len ( t ) == 3 ) : #NEWLINE# #INDENT# ( n , t , s ) = t #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( n , t ) = t #NEWLINE# s = None #NEWLINE# #UNINDENT# if ( n == '#ignore' ) : #NEWLINE# #INDENT# n = t #NEWLINE# self . ignore [ n ] = s #NEWLINE# #UNINDENT# if ( ( n in self . tokens . keys ( ) ) and ( self . tokens [ n ] != t ) ) : #NEWLINE# #INDENT# print ( ( 'Warning: token %s defined more than once.' % n ) , file = sys . stderr ) #NEWLINE# #UNINDENT# self . tokens [ n ] = t #NEWLINE# self . terminals . append ( n ) #NEWLINE# #UNINDENT# self . rules = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . goals = [ ] #NEWLINE# for ( n , p , r ) in rules : #NEWLINE# #INDENT# self . params [ n ] = p #NEWLINE# self . rules [ n ] = r #NEWLINE# self . goals . append ( n ) #NEWLINE# #UNINDENT# self . output = sys . stdout