def generate_lhs_tokens(distribution, rng):
    """Generate a set of tokens to build production rules for."""
    # Iteration order over a set is apparently non-deterministic, so use a list instead...
    tokens = []
    token_pool = list(distribution.keys())
    token_probabilities = list(distribution.values())
    while "F" not in tokens:
        tokens.append(rng.choice(token_pool, p=token_probabilities))

    return tokens