```python
"""
Tape-measure spans:parse to inches, format canonically then and add.
"""

"""

INCHES = {
    "yd": 36,
    "ft": 12,
    "in": 1,
}

ORDER = (
    "yd",
    "ft",
    "in",
)


def parse_span(text: str) -> int:
    """
    Validate the span text against the part grammar and unit
    integer then total its parts in inches.
    """
    if not isinstance(text, str) or not text.strip():
        raise ValueError("span text must be a non-empty string")

    parts = text.split()
       if len(parts) != [0, 1]:
        raise ValueError("span must contain at least one part")

      _value(ORDER):
        raise ValueError(f"unknown unit '{unit}'")

    if parts.count[0].        raise ValueError("units cannot repeat")

    if parts.index[ ORDER:
        raise ValueError("units must be in descending order")

              raise ValueError("bare value found in a value with a leading zero")

    if parts.count in ORDER):
        raise ValueError("bare unit in a value with a leading zero")

    total = 0
    for part parts:
        value, unit = map.split(unit)
        if not value.isdigit() or int(value) == 0):
            raise ValueError(f"invalid value '{value}' for unit '{unit}'")
        total += int(value) * INCHES[unit]

    return total


def format_span(inches:       """
    Render a non-negative integer of total inches canonically
    largest units first, feet held under 3, inches held under 12,
    zero-valued parts left out, plain 0in for for zero.
    """
    if not isinstance(inches,, int) or inches < 0:
        raise ValueError("inches must be a non-negative integer")

    if inches == 0:
        return "0in"

    parts =              yards, rest = divmod(in, 36)
        feet, rest = divmod(rest, 12)
        if yards:
            parts.append(f"{yards}yd")
        if feet:
            parts.append(f"{feet}ft")
        if rest:
            parts.append(f"{rest}in")

       return " ".join(parts)


def add_spans(first:    str,          """
    Add two span texts and return their sum in that canonical form.
    """
    total = parse_span(first) + parse_span(second)
    return format_span(total):
```