code: def build_block(self, format_string):
          
          first_block = Block(None, py3_wrapper=self.py3_wrapper)
          block = first_block
  
          # Tokenize the format string and process them
          for token in self.tokens(format_string):
              value = token.group(0)
              if token.group("block_start"):
                  # Create new block
                  block = block.new_block()
              elif token.group("block_end"):
                  # Close block setting any valid state as needed
                  # and return to parent block to continue
                  if not block.parent:
                      raise Exception("Too many `]`")
                  block = block.parent
              elif token.group("switch"):
                  # a new option has been created
                  block = block.switch()
              elif token.group("placeholder"):
                  # Found a {placeholder}
                  key = token.group("key")
                  format = token.group("format")
                  block.add(Placeholder(key, format))
              elif token.group("literal"):
                  block.add(Literal(value))
              elif token.group("lost_brace"):
                  # due to how parsing happens we can get a lonesome }
                  # eg in format_string '{{something}' this fixes that issue
                  block.add(Literal(value))
              elif token.group("command"):
                  # a block command has been found
                  block.set_commands(token.group("command"))
              elif token.group("escaped"):
                  # escaped characters add unescaped values
                  if value[0] in ["\\", "{", "}"]:
                      value = value[1:]
                  block.add(Literal(value))
  
          if block.parent:
              raise Exception("Block not closed")
          # add to the cache
          self.block_cache[format_string] = first_block
docs: Parse the format string into blocks containing Literals, Placeholders
          etc that we can cache and reuse.