<s> import sys <EOL> if "<STR_LIT:..>" not in sys . path : sys . path . insert ( <NUM_LIT:0> , "<STR_LIT:..>" ) <EOL> import ply . lex as lex <EOL> tokens = ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ) <EOL> def make_calc ( ) : <EOL> t_PLUS = r'<STR_LIT>' <EOL> t_MINUS = r'<STR_LIT:->' <EOL> t_TIMES = r'<STR_LIT>' <EOL> t_DIVIDE = r'<STR_LIT:/>' <EOL> t_EQUALS = r'<STR_LIT:=>' <EOL> t_LPAREN = r'<STR_LIT>' <EOL> t_RPAREN = r'<STR_LIT>' <EOL> t_NAME = r'<STR_LIT>' <EOL> def t_NUMBER ( t ) : <EOL> r'<STR_LIT>' <EOL> try : <EOL> t . value = int ( t . value ) <EOL> except ValueError : <EOL> print ( "<STR_LIT>" % t . value ) <EOL> t . value = <NUM_LIT:0> <EOL> return t <EOL> t_ignore = "<STR_LIT>" <EOL> def t_newline ( t ) : <EOL> r'<STR_LIT>' <EOL> t . lineno += t . value . count ( "<STR_LIT:\n>" ) <EOL> def t_error ( t ) : <EOL> print ( "<STR_LIT>" % t . value [ <NUM_LIT:0> ] ) <EOL> t . lexer . skip ( <NUM_LIT:1> ) <EOL> return lex . lex ( ) <EOL> make_calc ( ) <EOL> lex . runmain ( data = "<STR_LIT>" ) </s>
