Example #1
0
    def cond(self, ast):
        cmd1 = ast.c1
        cmd2 = ast.c2

        if not (isinstance(cmd1, pi.Cmd)):
            for i in range(1, len(ast.c1)):
                cmd1 = pi.CSeq(cmd1, ast.c1[i])

        if not (isinstance(cmd2, pi.Cmd)):
            for i in range(1, len(ast.c2)):
                cmd2 = pi.CSeq(cmd2, ast.c2[i])

        return pi.Cond(ast.e, cmd1, cmd2)
Example #2
0
 def cmd_seq(self, ast):
     if isinstance(ast.ac, list):
         cs = ast.ac[0]
         for c in ast.ac[1:]:
             cs = pi.CSeq(cs, c)
         return cs
     else:
         return ast.ac
Example #3
0
 def loop(self, ast):
     if isinstance(ast.c, pi.Cmd):
         return pi.Loop(ast.e, ast.c)
     else:
         cmd = ast.c[0]
         for i in range(1, len(ast.c)):
             cmd = pi.CSeq(cmd, ast.c[i])
         return pi.Loop(ast.e, cmd)
Example #4
0
 def let(self, ast):
     if isinstance(ast.c, pi.Cmd):
         return pi.Blk(ast.d, ast.c)
     elif isinstance(ast.c, list):
         cmd = ast.c[0]
         for i in range(1, len(ast.c)):
             cmd = pi.CSeq(cmd, ast.c[i])
         return pi.Blk(ast.d, cmd)