Beispiel #1
0
    def visitVardecl(self, ctx: MCParser.VardeclContext):
        lst = []

        for item in self.visit(ctx.variablelist()):
            if item[0] == 1:
                lst.append(VarDecl(item[1], self.visit(ctx.primitivetype())))
            elif item[0] == 2:
                lst.append(
                    VarDecl(
                        item[1],
                        ArrayType(
                            item[2],
                            self.visit(ctx.primitivetype()),
                        )))
            else:
                lst.append(
                    VarDecl(
                        item[1],
                        ArrayPointerType(self.visit(ctx.primitivetype()), )))
        return lst
Beispiel #2
0
 def visitVardecl(self, ctx: MCParser.VardeclContext):
     def create(item):
         if item[0] == 1:
             return VarDecl(
                 item[1],
                 self.visit(ctx.primitivetype())
             )
         elif item[0] == 2:
             return VarDecl(
                 item[1],
                 ArrayType(item[2], self.visit(ctx.primitivetype()),)
             )
         else:
             return VarDecl(
                 item[1],
                 ArrayPointerType(self.visit(ctx.primitivetype()),)
             )
     return list(map(
         create,
         self.visit(ctx.variablelist())
     ))