Commit 3fa80f1e authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Add AUTO generation for local variables

parent cff55a54
......@@ -16,8 +16,8 @@ class PlutoVariables:
self.by_name[name] = (int(pluto), int(index))
pass
def codegen(self, expr):
m = re.match('([^=]+)=(AND|OR)\{(.*),(.*)\}', expr)
def codegen(self, auto, current):
m = re.match('([^=]+)=(AND|OR)\{(.*),(.*)\}', auto)
if m:
lh = m.group(1)
op = m.group(2)
......@@ -37,7 +37,17 @@ class PlutoVariables:
return("%s=%s" % (lh, '*'.join(rh)))
elif op == 'OR':
return("%s=%s" % (lh, '+'.join(rh)))
raise Exception('Invalid expression', expr)
pass
m = re.match('([^=]+)=(.*)', auto)
if m:
regexp = '^(' + m.group(1).replace('*', '.*') + ')='
expr = '{0}=' + m.group(2)
lh_m = re.match(regexp, current)
if lh_m:
matches = lh_m.groups()
return expr.format(*matches)
pass
raise Exception('Invalid expression', auto)
class SPS:
......@@ -62,7 +72,7 @@ class SPS:
result.append(l)
m = re.match(';\s*AUTO:\s*(.*)', l)
if m:
code = self.gm.codegen(m.group(1))
code = self.gm.codegen(m.group(1), current=result[-2])
if code != result[-2]:
result[-2] = code
pass
......
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