<s> class Action ( object ) : <EOL> def perform ( self , token_stream , text ) : <EOL> pass <EOL> def same_as ( self , other ) : <EOL> return self is other <EOL> class Return ( Action ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def perform ( self , token_stream , text ) : <EOL> return self . value <EOL> def same_as ( self , other ) : <EOL> return isinstance ( other , Return ) and self . value == other . value <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % repr ( self . value ) <EOL> class Call ( Action ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , function ) : <EOL> self . function = function <EOL> def perform ( self , token_stream , text ) : <EOL> return self . function ( token_stream , text ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % self . function . __name__ <EOL> def same_as ( self , other ) : <EOL> return isinstance ( other , Call ) and self . function is other . function <EOL> class Begin ( Action ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , state_name ) : <EOL> self . state_name = state_name <EOL> def perform ( self , token_stream , text ) : <EOL> token_stream . begin ( self . state_name ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % self . state_name <EOL> def same_as ( self , other ) : <EOL> return isinstance ( other , Begin ) and self . state_name == other . state_name <EOL> class Ignore ( Action ) : <EOL> """<STR_LIT>""" <EOL> def perform ( self , token_stream , text ) : <EOL> return None <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" <EOL> IGNORE = Ignore ( ) <EOL> class Text ( Action ) : <EOL> """<STR_LIT>""" <EOL> def perform ( self , token_stream , text ) : <EOL> return text <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" <EOL> TEXT = Text ( ) </s>
