Get the next waiting token. If a location is given, then return the token at currentIndex+location without advancing currentIndex; setting it gives lookahead/lookback capability.
(self, location=None)
| 262 | return self._currentIndex + location < len(self._buffer) |
| 263 | |
| 264 | def token(self, location=None): |
| 265 | """Get the next waiting token. If a location is given, then |
| 266 | return the token at currentIndex+location without advancing |
| 267 | currentIndex; setting it gives lookahead/lookback capability.""" |
| 268 | try: |
| 269 | if location is None: |
| 270 | tok = self._buffer[self._currentIndex] |
| 271 | self._currentIndex += 1 |
| 272 | else: |
| 273 | tok = self._buffer[self._currentIndex + location] |
| 274 | return tok |
| 275 | except IndexError as e: |
| 276 | raise ExpectedMoreTokensException(self._currentIndex + 1) from e |
| 277 | |
| 278 | def isvariable(self, tok): |
| 279 | return tok not in Tokens.TOKENS |
no test coverage detected