Esempio n. 1
0
    def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):

        if not ctx.block_member(): return Block([])
        #each visitBlock_member() return a list
        #each a stmt is a list --> stmtList is a list of lists
        #stmt: int a,b; --> [VarDecl(a,IntType),VarDecl(b,IntType)]
        #stmt: if a==b then x=1; -->[........]
        stmtList = [self.visit(x) for x in ctx.block_member()]
        #stmts: a list of prime stmt
        #stmts: [VarDecl(a,IntType),VarDecl(b,IntType),If(..),...]
        stmts = reduce(lambda x, y: x + y, stmtList)
        return Block(stmts)
Esempio n. 2
0
 def visitBlock_stmt(self, ctx:MCParser.Block_stmtContext):
     memBlock = []
     for x in ctx.stmt_vardecl():
         stmt_vardecls = self.visitStmt_vardecl(x)
         if isinstance(stmt_vardecls, list):
             memBlock.extend(stmt_vardecls)
         else:
             memBlock.append(stmt_vardecls)
     return Block(memBlock)
Esempio n. 3
0
 def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):
     return Block(list(reduce(lambda x,y: x + self.visit(y),ctx.body(),[])))
Esempio n. 4
0
 def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):
     return Block([
         self.visit(ctx.getChild(x)) for x in range(1,
                                                    ctx.getChildCount() - 1)
     ])
Esempio n. 5
0
 def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):
     block = []
     for i in ctx.term():
         block += self.visit(i)
     return Block(block)
Esempio n. 6
0
 def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):
     return Block(
         fatten([self.visit(stmt_var) for stmt_var in ctx.stmt_var_decl()]))
Esempio n. 7
0
 def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):
     if ctx.body_block():
         return Block(self.visit(ctx.body_block()))
Esempio n. 8
0
 def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext):
     return Block([j for i in ctx.blockmem() for j in self.visit(i)])