class_docstr: Context-sensitive token parsing.
  
  Provides methods to examine the input stream to check whether the next token
  matches.
class_docstr_tok: ["Context-sensitive","token","parsing",".","Provides","methods","to","examine","the","input","stream","to","check","whether","the","next","token","matches","."]
docstr: Check whether the next token has the provided name.
  
  By default, if the check succeeds, the token *must* be read before
  another check. If `peek` is set to `True`, the token is not loaded and
  would need to be checked again.
docstr_tok: ["Check","whether","the","next","token","has","the","provided","name",".","By","default",",","if","the","check","succeeds",",","the","token","*","must","*","be","read","before","another","check",".","If","`","peek","`","is","set","to","`","True","`",",","the","token","is","not","loaded","and","would","need","to","be","checked","again","."]
code: def check(self, name: str, *, peek: bool = False) -> bool:
      """Check whether the next token has the provided name.
  
      By default, if the check succeeds, the token *must* be read before
      another check. If `peek` is set to `True`, the token is not loaded and
      would need to be checked again.
      """
      assert (
          self.next_token is None
      ), f"Cannot check for {name!r}, already have {self.next_token!r}"
      assert name in self.rules, f"Unknown token name: {name!r}"
  
      expression = self.rules[name]
  
      match = expression.match(self.source, self.position)
      if match is None:
          return False
      if not peek:
          self.next_token = Token(name, match[0], self.position)
      return True
  
file_path: metaflow/metaflow/_vendor/packaging/_tokenizer.py
imports: import contextlib
  import re
  from dataclasses import dataclass
  from typing import Dict, Iterator, NoReturn, Optional, Tuple, Union
  from .specifiers import Specifier
label_desc: Use image node_id 3 for calling the Tokenizer obj's underlying member method code with example usage: obj.check(name) and returns: True, False