diff --git a/pyfuzzyparser.py b/pyfuzzyparser.py index 464da4e7..c4f57c62 100644 --- a/pyfuzzyparser.py +++ b/pyfuzzyparser.py @@ -533,7 +533,6 @@ class PyFuzzyParser(object): if tok == 'in': break - print 'for_tok', tok token_type, tok, indent = self.next() return (value_list, tok) @@ -710,7 +709,7 @@ class PyFuzzyParser(object): breaks += added_breaks while not (tok in always_break or tok in breaks and level <= 0): - set_string = '' + set_string = None #print 'parse_stmt', tok, token.tok_name[token_type] if tok == 'as': string += " %s " % tok @@ -728,8 +727,9 @@ class PyFuzzyParser(object): set_string = '' elif tok in ['return', 'yield', 'del', 'raise', 'assert']: set_string = tok + ' ' - elif tok == 'print': - set_string = tok + ' ' + elif tok in ['print', 'exec']: + # delete those statements, just let the rest stand there + set_string = '' else: path, token_type, tok, start_indent = \ self._parsedotname(self.current) @@ -740,7 +740,7 @@ class PyFuzzyParser(object): else: if not n.names[0] in ['global']: used_vars.append(n) - if string and re.match(r'[\w\d]', string[-1]): + if string and re.match(r'[\w\d\'"]', string[-1]): string += ' ' string += ".".join(path) #print 'parse_stmt', tok, token.tok_name[token_type] @@ -754,7 +754,7 @@ class PyFuzzyParser(object): elif tok in ['}', ')', ']']: level -= 1 - if set_string: + if set_string is not None: string = set_string else: string += tok diff --git a/test.py b/test.py index 12c5dbc9..4842102d 100644 --- a/test.py +++ b/test.py @@ -72,6 +72,8 @@ def ass_test(a): # (comment without indent) (b, c, d) = (1,2,3) del b + f = {} + exec 'a = 999' in f # test strange statements [a,c] ; {1: a}; (1,); `a` result = int((a+b)*2) @@ -105,7 +107,7 @@ def flow_test(a): raise e yield e #except TypeError, e: - # pass + pass except: pass finally: