code: def parse(tokens):
      
      d = collections.OrderedDict()
      prev_line = 0
      blockname = None
      blockline = None
      for token in tokens:
          if token.type == 'COMMENT':
              continue
          elif token.type == 'BLOCK':
              block = token
              blockline = token.line
              blocktype = token.value.upper()
              blockname = None
              if blocktype not in d:
                  d[blocktype] = collections.OrderedDict()
          elif token.line == blockline:
              if blockname is None:
                  blockname = token.value
                  d[blocktype][blockname] = collections.defaultdict(list)
              else:
                  d[blocktype][blockname]['info'].append(numval(token))
          elif token.line != prev_line:
              if blockname is None:
                  raise ParseError("Found value outside block!")
              d[blocktype][blockname]['values'].append([numval(token)])
          else:
              if blockname is None:
                  raise ParseError("Found value outside block!")
              d[blocktype][blockname]['values'][-1].append(numval(token))
          prev_line = token.line
      return d
docs: Parse the token list into a hierarchical data structure