def evaluate(self, node, filename=None):
if isinstance(node, string_types):<EOL><INDENT>self.source = node<EOL>kwargs = {'<STR_LIT>': '<STR_LIT>'}<EOL>if filename:<EOL><INDENT>kwargs['<STR_LIT:filename>'] = filename<EOL><DEDENT>try:<EOL><INDENT>node = ast.parse(node, **kwargs)<EOL><DEDENT>except SyntaxError as e:<EOL><INDENT>s = self.get_fragment(e.offset)<EOL>raise SyntaxError('<STR_LIT>' % s)<EOL><DEDENT><DEDENT>node_type = node.__class__.__name__.lower()<EOL>handler = self.get_handler(node_type)<EOL>if handler is None:<EOL><INDENT>if self.source is None:<EOL><INDENT>s = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>s = self.get_fragment(node.col_offset)<EOL><DEDENT>raise SyntaxError("<STR_LIT>" % (<EOL>node_type, s))<EOL><DEDENT>return handler(node)<EOL>
Evaluate a source string or node, using ``filename`` when
displaying errors.