code: def match_case_tokens(loc, tokens, check_var, top):
      
      if len(tokens) == 2:
          matches, stmts = tokens
          cond = None
      elif len(tokens) == 3:
          matches, cond, stmts = tokens
      else:
          raise CoconutInternalException("invalid case match tokens", tokens)
      matching = Matcher(loc, check_var)
      matching.match(matches, match_to_var)
      if cond:
          matching.add_guard(cond)
      return matching.build(stmts, set_check_var=top)
docs: Build code for matching the given case.