Returns the next token relative to *idx*. If *skip_ws* is ``True`` (the default) whitespace tokens are ignored. If *skip_cm* is ``True`` comments are ignored. ``None`` is returned if there's no next token.
(self, idx, skip_ws=True, skip_cm=False, _reverse=False)
| 284 | |
| 285 | # TODO: May need to re-add default value to idx |
| 286 | def token_next(self, idx, skip_ws=True, skip_cm=False, _reverse=False): |
| 287 | """Returns the next token relative to *idx*. |
| 288 | |
| 289 | If *skip_ws* is ``True`` (the default) whitespace tokens are ignored. |
| 290 | If *skip_cm* is ``True`` comments are ignored. |
| 291 | ``None`` is returned if there's no next token. |
| 292 | """ |
| 293 | if idx is None: |
| 294 | return None, None |
| 295 | idx += 1 # alot of code usage current pre-compensates for this |
| 296 | |
| 297 | def matcher(tk): |
| 298 | return not ((skip_ws and tk.is_whitespace) |
| 299 | or (skip_cm and imt(tk, t=T.Comment, i=Comment))) |
| 300 | return self._token_matching(matcher, idx, reverse=_reverse) |
| 301 | |
| 302 | def token_index(self, token, start=0): |
| 303 | """Return list index of token.""" |