def boolean(name=None):
    """
    Creates the grammar for a Boolean (B) field, accepting only 'Y' or 'N'

    :param name: name for the field
    :return: grammar for the flag field
    """

    if name is None:
        name = 'Boolean Field'

    # Basic field
    field = pp.Regex('[YN]')

    # Parse action
    field.setParseAction(lambda b: _to_boolean(b[0]))

    # Name
    field.setName(name)

    return field