class_docstr: Parser engine.
  
  The proper usage sequence is:
  
  p = Parser(grammar, [converter])  # create instance
  p.setup([start])                  # prepare for parsing
  <for each input token>:
      if p.addtoken(...):           # parse a token; may raise ParseError
          break
  root = p.rootnode                 # root of abstract syntax tree
  
  A Parser instance may be reused by calling setup() repeatedly.
  
  A Parser instance contains state pertaining to the current token
  sequence, and should not be used concurrently by different threads
  to parse separate token sequences.
  
  See driver.py for how to get input tokens by tokenizing a file or
  string.
  
  Parsing is complete when addtoken() returns True; the root of the
  abstract syntax tree can then be retrieved from the rootnode
  instance variable.  When a syntax error occurs, addtoken() raises
  the ParseError exception.  There is no error recovery; the parser
  cannot be used after a syntax error was reported (but it can be
  reinitialized by calling setup()).
class_docstr_tok: ["Parser","engine",".","The","proper","usage","sequence","is",":","p","=","Parser","(","grammar",",","[","converter","]",")","#","create","instance","p.setup","(","[","start","]",")","#","prepare","for","parsing","<","for","each","input","token",">",":","if","p.addtoken","(","...",")",":","#","parse","a","token",";","may","raise","ParseError","break","root","=","p.rootnode","#","root","of","abstract","syntax","tree","A","Parser","instance","may","be","reused","by","calling","setup","(",")","repeatedly",".","A","Parser","instance","contains","state","pertaining","to","the","current","token","sequence",",","and","should","not","be","used","concurrently","by","different","threads","to","parse","separate","token","sequences",".","See","driver.py","for","how","to","get","input","tokens","by","tokenizing","a","file","or","string",".","Parsing","is","complete","when","addtoken","(",")","returns","True",";","the","root","of","the","abstract","syntax","tree","can","then","be","retrieved","from","the","rootnode","instance","variable",".","When","a","syntax","error","occurs",",","addtoken","(",")","raises","the","ParseError","exception",".","There","is","no","error","recovery",";","the","parser","can","not","be","used","after","a","syntax","error","was","reported","(","but","it","can","be","reinitialized","by","calling","setup","(",")",")","."]
docstr: Prepare for parsing.
  
  This *must* be called before starting to parse.
  
  The optional argument is an alternative start symbol; it
  defaults to the grammar's start symbol.
  
  You can use a Parser instance to parse any number of programs;
  each time you call setup() the parser is reset to an initial
  state determined by the (implicit or explicit) start symbol.
docstr_tok: ["Prepare","for","parsing",".","This","*","must","*","be","called","before","starting","to","parse",".","The","optional","argument","is","an","alternative","start","symbol",";","it","defaults","to","the","grammar","'s","start","symbol",".","You","can","use","a","Parser","instance","to","parse","any","number","of","programs",";","each","time","you","call","setup","(",")","the","parser","is","reset","to","an","initial","state","determined","by","the","(","implicit","or","explicit",")","start","symbol","."]
code: def setup(
      self, proxy: "TokenProxy", start: Optional[int] = None
  ) -> None:
      """Prepare for parsing.
  
      This *must* be called before starting to parse.
  
      The optional argument is an alternative start symbol; it
      defaults to the grammar's start symbol.
  
      You can use a Parser instance to parse any number of programs;
      each time you call setup() the parser is reset to an initial
      state determined by the (implicit or explicit) start symbol.
  
      """
      if start is None:
          start = self.grammar.start
      # Each stack entry is a tuple: (dfa, state, node).
      # A node is a tuple: (type, value, context, children),
      # where children is a list of nodes or None, and context may be None.
      newnode: RawNode = (start, None, None, [])
      stackentry = (self.grammar.dfas[start], 0, newnode)
      self.stack: List[Tuple[DFAS, int, RawNode]] = [stackentry]
      self.rootnode: Optional[NL] = None
      self.used_names: Set[str] = set()
      self.proxy = proxy
      self.last_token = None
  
imports: from contextlib import contextmanager
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Union, cast
  from blib2to3.pgen2.grammar import Grammar
  from blib2to3.pytree import NL, Context, Leaf, Node, RawNode, convert
  from .None import grammar, token, tokenize
label_desc: Use image node_id 2 for calling the Parser obj's underlying member method code with example usage: obj.setup(proxy, start) without return types