On Saturday, November 23, 2019 at 9:24:51 AM UTC-6, Edward K. Ream wrote: > It's just a bit tricky to look ahead in a generator.
Correction, it's amazingly tricky. My supposedly simple code fails in mysterious ways. So do the stack overflow answers <https://www.google.com/url?q=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2425270&sa=D&sntz=1&usg=AFQjCNGt91P1-L3yGA9rXLBODjPMqslZuw> . For now, I'll just use helper *lists*: def is_if(token): return token.kind == 'name' and token.value in ('if', 'elif', 'else') def is_significant(token): return ( token.kind in ('name', 'number', 'string') or token.kind == 'op' and token.value not in ',;()') def is_string(token): return token.kind == 'string' self.if_tokens = list(filter(is_if, self.tokens)) self.significant_tokens = list(filter(is_significant, self.tokens)) self.string_tokens = list(filter(is_string, self.tokens)) Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/c3945b31-e818-4362-bc58-b185af0f5c99%40googlegroups.com.
