| 167 | |
| 168 | |
| 169 | def FindFirstInLine(line, token_table): |
| 170 | best_match_start = -1 |
| 171 | for (regex, token_type) in token_table: |
| 172 | m = regex.search(line) |
| 173 | if m: |
| 174 | # We found regex in lines |
| 175 | if best_match_start < 0 or m.start() < best_match_start: |
| 176 | best_match_start = m.start() |
| 177 | best_match_length = m.end() - m.start() |
| 178 | best_match_token_type = token_type |
| 179 | |
| 180 | if best_match_start < 0: |
| 181 | return None |
| 182 | |
| 183 | return (best_match_start, best_match_length, best_match_token_type) |
| 184 | |
| 185 | |
| 186 | def FindFirst(lines, token_table, cursor): |