class_docstr: A DataShape parser object.
class_docstr_tok: ["A","DataShape","parser","object","."]
docstr: dim : typevar
      | ellipsis_typevar
      | type
      | type_constr
      | INTEGER
      | ELLIPSIS
  typevar : NAME_UPPER
  ellipsis_typevar : NAME_UPPER ELLIPSIS
  type : NAME_LOWER
  type_constr : NAME_LOWER LBRACKET type_arg_list RBRACKET
  
  Returns a the dim object, or None.
  TODO: Support type constructors
docstr_tok: ["dim",":","typevar","|","ellipsis_typevar","|","type","|","type_constr","|","INTEGER","|","ELLIPSIS","typevar",":","NAME_UPPER","ellipsis_typevar",":","NAME_UPPER","ELLIPSIS","type",":","NAME_LOWER","type_constr",":","NAME_LOWER","LBRACKET","type_arg_list","RBRACKET","Returns","a","the","dim","object",",","or","None",".","TODO",":","Support","type","constructors"]
code: def parse_dim(self):
      """
      dim : typevar
          | ellipsis_typevar
          | type
          | type_constr
          | INTEGER
          | ELLIPSIS
      typevar : NAME_UPPER
      ellipsis_typevar : NAME_UPPER ELLIPSIS
      type : NAME_LOWER
      type_constr : NAME_LOWER LBRACKET type_arg_list RBRACKET
  
      Returns a the dim object, or None.
      TODO: Support type constructors
      """
      saved_pos = self.pos
      tok = self.tok
      if tok.id == lexer.NAME_UPPER:
          val = tok.val
          self.advance_tok()
          if self.tok.id == lexer.ELLIPSIS:
              self.advance_tok()
              # TypeVars ellipses are treated as the "ellipsis" dim
              tconstr = self.syntactic_sugar(
                  self.sym.dim_constr,
                  "ellipsis",
                  "TypeVar... dim constructor",
                  saved_pos,
              )
              return tconstr(val)
          elif self.tok.id == lexer.ASTERISK:
              # Using a lookahead check for '*' after the TypeVar, so that
              # the error message would be about a dtype problem instead
              # of a dim problem when 'typevar' isn't in the symbol table
              #
              # TypeVars are treated as the "typevar" dim
              tconstr = self.syntactic_sugar(
                  self.sym.dim_constr,
                  "typevar",
                  "TypeVar dim constructor",
                  saved_pos,
              )
              return tconstr(val)
          else:
              self.pos = saved_pos
              return None
      elif tok.id == lexer.NAME_LOWER:
          name = tok.val
          self.advance_tok()
          if self.tok.id == lexer.LBRACKET:
              dim_constr = self.sym.dim_constr.get(name)
              if dim_constr is None:
                  self.pos = saved_pos
                  return None
              self.advance_tok()
              args = self.parse_type_arg_list()  # noqa: F841
              if self.tok.id == lexer.RBRACKET:
                  self.advance_tok()
                  raise NotImplementedError(
                      "dim type constructors not actually supported yet"
                  )
              else:
                  self.raise_error('Expected a closing "]"')
          else:
              dim = self.sym.dim.get(name)
              if dim is not None:
                  return dim
              else:
                  self.pos = saved_pos
                  return None
      elif tok.id == lexer.INTEGER:
          val = tok.val
          self.advance_tok()
          # If the token after the INTEGER is not ASTERISK,
          # it cannot be a dim, so skip it
          if self.tok.id != lexer.ASTERISK:
              self.pos = saved_pos
              return None
          # Integers are treated as "fixed" dimensions
          tconstr = self.syntactic_sugar(
              self.sym.dim_constr, "fixed", "integer dimensions"
          )
          return tconstr(val)
      elif tok.id == lexer.ELLIPSIS:
          self.advance_tok()
          # Ellipses are treated as the "ellipsis" dim
          dim = self.syntactic_sugar(
              self.sym.dim, "ellipsis", "... dim", saved_pos
          )
          return dim
      else:
          return None
  
imports: from __future__ import absolute_import, division, print_function
  from .None import lexer, error
  from .None import coretypes
label_desc: Use image node_id 9 for calling the DataShapeParser obj's underlying member method code with example usage: obj.parse_dim() and returns: tconstr, tconstr, None, tconstr, None, dim, None, None, dim, None