def operator_pattern(operators):
    """Generate a grammar rule to match a dict of operators."""
    # Sort operators and reverse them so that operators sharing a prefix
    # always have the shortest forms last. Otherwise, the shorter forms
    # will match operators early, i.e. `<` will match `<=` and ignore
    # the `=`, causing a parse error.
    operators = sorted(operators, key=lambda op: op.symbol, reverse=True)
    operator_literals = ['"{}"'.format(op.symbol) for op in operators]
    return ' / '.join(operator_literals)