<s> import sys <EOL> if sys . platform == '<STR_LIT>' : <EOL> if sys . stderr is sys . __stderr__ : <EOL> sys . stderr = sys . __stdout__ <EOL> import Plex <EOL> force_debug = <NUM_LIT:0> <EOL> if force_debug or sys . argv [ <NUM_LIT:1> : <NUM_LIT:2> ] == [ "<STR_LIT>" ] : <EOL> debug = sys . stderr <EOL> else : <EOL> debug = None <EOL> def run ( lexicon , test_name , <EOL> debug = <NUM_LIT:0> , trace = <NUM_LIT:0> , scanner_class = Plex . Scanner ) : <EOL> if debug : <EOL> debug_file = sys . stdout <EOL> lexicon . machine . dump ( debug_file ) <EOL> print "<STR_LIT:=>" * <NUM_LIT> <EOL> else : <EOL> debug_file = None <EOL> in_name = test_name + "<STR_LIT>" <EOL> f = open ( in_name , "<STR_LIT>" ) <EOL> s = scanner_class ( lexicon , f , in_name ) <EOL> if trace : <EOL> s . trace = <NUM_LIT:1> <EOL> while <NUM_LIT:1> : <EOL> value , text = s . read ( ) <EOL> name , line , pos = s . position ( ) <EOL> print "<STR_LIT>" % ( name , line , pos , value , repr ( text ) ) <EOL> if value is None : <EOL> break </s>
