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)
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)
def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext): return Block(list(reduce(lambda x,y: x + self.visit(y),ctx.body(),[])))
def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext): return Block([ self.visit(ctx.getChild(x)) for x in range(1, ctx.getChildCount() - 1) ])
def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext): block = [] for i in ctx.term(): block += self.visit(i) return Block(block)
def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext): return Block( fatten([self.visit(stmt_var) for stmt_var in ctx.stmt_var_decl()]))
def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext): if ctx.body_block(): return Block(self.visit(ctx.body_block()))
def visitBlock_stmt(self, ctx: MCParser.Block_stmtContext): return Block([j for i in ctx.blockmem() for j in self.visit(i)])