def syntax_length(syntax):
    """Return the number of bytes in a particular syntax definition.

    If the syntax has any optional parameters or parameters that have an
    undefined length then return zero.
    """
    length = 0
    for param in syntax:
        if not param.mandatory or param.length == 0:
            return 0
        length += param.length
    return length