import re


def generate_stripped_function_call_pattern(stripped_functions):
    """
    Return a Regex pattern that detects any one-line call of any function whose name is in stripped_functions
    If there are no functions to strip, return None.

    """
    # if there is nothing to strip, return None now to avoid creating a regex with just "(?:)\(\)" that would match a line starting with brackets
    if not stripped_functions:
        return None

    # Many good regex exist to match open and closing brackets, unfortunately they use PCRE features like ?> unsupported in Python re,
    #   so we use a very simple regex only capable of detecting the final closing bracket, without being certain that this is the last one.
    # Because of this, you should never end the first line of a multi-line call with a bracket as it would be interpreted as a one-line call.
    # Comments after call are supported.

    # For better regex with PCRE to detect surrounding brackets and quotes, see:
    # https://stackoverflow.com/questions/2148587/finding-quoted-strings-with-escaped-quotes-in-c-sharp-using-a-regular-expression
    # https://stackoverflow.com/questions/4568410/match-comments-with-regex-but-not-inside-a-quote adapted to lua comments
    # https://stackoverflow.com/questions/546433/regular-expression-to-match-outer-brackets#546457
    # https://stackoverflow.com/questions/18906514/regex-for-matching-functions-and-capturing-their-arguments#18908330

    # ex: '(?:log|warn|err)'
    function_names_alternative_pattern = f"(?:{'|'.join(stripped_functions)})"
    # ex: '^\s*(?:log|warn|err)\(.*\)\s*(?:--.*)?$'
    stripped_function_call_pattern = re.compile(rf'^\s*{function_names_alternative_pattern}\(.*\)\s*(?:--.*)?$')
    return stripped_function_call_pattern