def comments_between_tokens(token1, token2):
if token2 is None:<EOL><INDENT>buf = token1.end_mark.buffer[token1.end_mark.pointer:]<EOL><DEDENT>elif (token1.end_mark.line == token2.start_mark.line and<EOL>not isinstance(token1, yaml.StreamStartToken) and<EOL>not isinstance(token2, yaml.StreamEndToken)):<EOL><INDENT>return<EOL><DEDENT>else:<EOL><INDENT>buf = token1.end_mark.buffer[token1.end_mark.pointer:<EOL>token2.start_mark.pointer]<EOL><DEDENT>line_no = token1.end_mark.line + <NUM_LIT:1><EOL>column_no = token1.end_mark.column + <NUM_LIT:1><EOL>pointer = token1.end_mark.pointer<EOL>comment_before = None<EOL>for line in buf.split('<STR_LIT:\n>'):<EOL><INDENT>pos = line.find('<STR_LIT:#>')<EOL>if pos != -<NUM_LIT:1>:<EOL><INDENT>comment = Comment(line_no, column_no + pos,<EOL>token1.end_mark.buffer, pointer + pos,<EOL>token1, token2, comment_before)<EOL>yield comment<EOL>comment_before = comment<EOL><DEDENT>pointer += len(line) + <NUM_LIT:1><EOL>line_no += <NUM_LIT:1><EOL>column_no = <NUM_LIT:1><EOL><DEDENT>
Find all comments between two tokens