import re


def parse_variable_declaration(srcline):
    """Return (name, decl) for the given declaration line."""
    # XXX possible false negatives...
    decl, sep, _ = srcline.partition('=')
    if not sep:
        if not srcline.endswith(';'):
            return None, None
        decl = decl.strip(';')
    decl = decl.strip()
    m = re.match(r'.*\b(\w+)\s*(?:\[[^\]]*\])?$', decl)
    if not m:
        return None, None
    name = m.group(1)
    return name, decl