Test a token against a token expression. This can either be a token type or ``'token_type:token_value'``. This can only test against string values and types.
(self, expr: str)
| 275 | return describe_token(self) |
| 276 | |
| 277 | def test(self, expr: str) -> bool: |
| 278 | """Test a token against a token expression. This can either be a |
| 279 | token type or ``'token_type:token_value'``. This can only test |
| 280 | against string values and types. |
| 281 | """ |
| 282 | # here we do a regular string equality check as test_any is usually |
| 283 | # passed an iterable of not interned strings. |
| 284 | if self.type == expr: |
| 285 | return True |
| 286 | |
| 287 | if ":" in expr: |
| 288 | return expr.split(":", 1) == [self.type, self.value] |
| 289 | |
| 290 | return False |
| 291 | |
| 292 | def test_any(self, *iterable: str) -> bool: |
| 293 | """Test against multiple token expressions.""" |
no outgoing calls