r'([ \t]*[#].*[^\x04][\n]?)|([ \t]+)

def t_whitespace_or_comment(self, s):
        r'([ \t]*[#].*[^\x04][\n]?)|([ \t]+)'
        if '#' in s:
            # We have a comment
            matches = re.match('(\s+)(.*[\n]?)', s)
            if matches and self.is_newline:
                self.handle_indent_dedent(matches.group(1))
                s = matches.group(2)
            if s.endswith("\n"):
                self.add_token('COMMENT', s[:-1])
                self.add_token('NEWLINE', "\n")
            else:
                self.add_token('COMMENT', s)
        elif self.is_newline:
            self.handle_indent_dedent(s)
            pass
        return