'Compile all patterns into a morphology lut.
TBD :Build based on (file) morphlut:modify_lut'

def build_lut(self):

    self.build_default_lut()
    patterns = []
    for p in self.patterns:
        m = re.search('(\\w*):?\\s*\\((.+?)\\)\\s*->\\s*(\\d)', p.replace('\n', ''))
        if (not m):
            raise Exception((('Syntax    error    in    pattern    "' + p) + '"'))
        options = m.group(1)
        pattern = m.group(2)
        result = int(m.group(3))
        pattern = pattern.replace('    ', '').replace('\n', '')
        patterns += self._pattern_permute(pattern, options, result)
    for (i, pattern) in enumerate(patterns):
        p = pattern[0].replace('.', 'X').replace('X', '[01]')
        p = re.compile(p)
        patterns[i] = (p, pattern[1])
    for i in range(LUT_SIZE):
        bitpattern = bin(i)[2:]
        bitpattern = (('0' * (9 - len(bitpattern))) + bitpattern)[::(-1)]
        for (p, r) in patterns:
            if p.match(bitpattern):
                self.lut[i] = [0, 1][r]
    return self.lut
