Return list of ranges defined in `tchain`.

        `kw` is the statement keyword determining the type of the
        range, i.e. 'range' or 'length'. `tchain` is the chain of type
        definitions from which the resulting range is obtained.

        The returned value is a list of tuples containing the segments
        of the resulting range.

def get_ranges(self, tchain, kw):
        """Return list of ranges defined in `tchain`.

        `kw` is the statement keyword determining the type of the
        range, i.e. 'range' or 'length'. `tchain` is the chain of type
        definitions from which the resulting range is obtained.

        The returned value is a list of tuples containing the segments
        of the resulting range.
        """
        (lo, hi) = ("min", "max")
        ran = None
        for t in tchain:
            rstmt = t.search_one(kw)
            if rstmt is None: continue
            parts = [ p.strip() for p in rstmt.arg.split("|") ]
            ran = [ [ i.strip() for i in p.split("..") ] for p in parts ]
            if ran[0][0] != 'min': lo = ran[0][0]
            if ran[-1][-1] != 'max': hi = ran[-1][-1]
        if ran is None: return None
        if len(ran) == 1:
            return [(lo, hi)]
        else:
            return [(lo, ran[0][-1])] + ran[1:-1] + [(ran[-1][0], hi)]