- def process_tokens(self, tokens):
- for token in tokens:
- self.tokens.append(token)
- if (token.ttype == Punctuation) and (token.value == ';'):
- self.statements.append(Statement(self.tokens))
- self.tokens = []
+ def process_lines(self):
+ statements = parse('\n'.join(self.lines))
+ last_stmt = statements[-1]
+ for i in xrange(len(last_stmt.tokens) - 1, 0, -1):
+ token = last_stmt.tokens[i]
+ if token.ttype in (Comment.Single, Comment.Multiline,
+ Newline, Whitespace):
+ continue
+ if token.ttype is Punctuation and token.value == ';':
+ break # The last statement is complete
+ # The last statement is still incomplete - wait for the next line
+ return
+ self.lines = []
+ self.statements = statements