Commit 78b4d76e authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Improved AUTO handling. Made safe-cell logic auto generated

parent b8f8b8e8
......@@ -17,23 +17,26 @@ class PlutoVariables:
pass
def codegen(self, expr):
m = re.match('([^=]+)=AND\{(.*),(.*)\}', expr)
m = re.match('([^=]+)=(AND|OR)\{(.*),(.*)\}', expr)
if m:
lh = m.group(1)
regexp = m.group(2).replace('*', '.*')
rh = [ m.group(3).format(v, pluto=self.by_name[v][0])
for v in self.by_name if re.match(regexp, v)]
return("%s=%s" % (lh, '*'.join(rh)))
m = re.match('([^=]+)=OR\{(.*),(.*)\}', expr)
if m:
lh = m.group(1)
regexp = m.group(2).replace('*', '.*')
rh = [ m.group(3).format(v, pluto=self.by_name[v][0])
for v in self.by_name if re.match(regexp, v)]
return("%s=%s" % (lh, '+'.join(rh)))
op = m.group(2)
regexp = m.group(3).replace('*', '.*')
expr = m.group(4)
rh = []
for k,v in sorted(self.by_name.items()):
rh_m = re.match(regexp, k)
if rh_m:
matches = (k,)+rh_m.groups()
rh.append(expr.format(*matches, pluto=v[0]))
pass
pass
if op == 'AND':
return("%s=%s" % (lh, '*'.join(rh)))
elif op == 'OR':
return("%s=%s" % (lh, '+'.join(rh)))
raise Exception('Invalid expression', expr)
class SPS:
def __init__(self, path):
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment