def isFunction(token, lines):
  """Determines if the given token is the start of a function.

  All function definitions are assumed to have a name field and the token in
  the compiled source is the keyword 'function'. Sometimes the function is
  defined on the previous semicolon and sometimes that semicolon appears on
  the previous line.

  Arguments:
    token - The Token to check.
    lines - An array of compiled code lines.

  Returns:
    whether the token is a function.
  """

  # All functions have a name.
  if not token.name:
    return False

  # Sometimes a function token starts with the previous ;
  # Also sometimes the token starts on the ; that is on the previous
  # line.
  partialLine = lines[token.dstLine][token.dstCol:]
  if partialLine == ';\n':
    if len(lines) == token.dstLine + 1:
      return False
    else:
      return lines[token.dstLine + 1].startswith('function')
  else:
    return (partialLine.startswith('function') or
        partialLine.startswith(';function'))