def temp_grammar_file(tmpdir_factory, temp_text):
    """Set up a pytest tmpdir_factory fixture to simulate a grammar regular expressions file."""

    # Create a temporary directory 'temp', and define a file path to a temporary text file 'temp_file.txt'
    temp_file_path = tmpdir_factory.mktemp("temp").join("temp_file.txt")

    # Write `temp_text` to `temp_file_path`
    _ = temp_file_path.write(temp_text)

    # Return the file path
    return temp_file_path