Beispiel #1
0
 def visitProgram(self, ctx: MPParser.ProgramContext):
     lst = []
     for x in ctx.decl():
         if type(self.visit(x)) is list:
             lst = lst + self.visit(x)
         else:
             lst.append(self.visit(x))
     return Program(lst)
 def visitProgram(self,ctx:MPParser.ProgramContext):
     lstdecl = []
     for x in ctx.decl():
         decl_ = self.visit(x)
         if type(decl_) == type([]):
             lstdecl = lstdecl + decl_
         else:
             lstdecl.append(decl_)
     return Program(lstdecl)
 def visitProgram(self, ctx: MPParser.ProgramContext):
     # ctx.decl() ==> List() = [DeclContext0, DeclContext1, DeclContext2, ...., DeclContextN]
     listDecl = []
     for x in ctx.decl():
         a = self.visit(x)
         # check VarDeclare will return a List or not
         if isinstance(a, list):
             for every in a:
                 # print(type(every))
                 listDecl.append(every)
         else:
             listDecl.append(a)
     return Program(listDecl)
Beispiel #4
0
 def visitProgram(self, ctx: MPParser.ProgramContext):
     return Program([self.visit(x) for x in ctx.decl()])
Beispiel #5
0
 def visitProgram(self, ctx: MPParser.ProgramContext):
     return 2 + sum(1 + self.visit(x) for x in ctx.decl())
Beispiel #6
0
 def visitProgram(self, ctx: MPParser.ProgramContext):
     return Program(
         reduce(lambda a, x: a + x, [self.visit(x) for x in ctx.decl()],
                []))
Beispiel #7
0
 def visitProgram(self, ctx: MPParser.ProgramContext):
     list_decl = [self.visit(x) for x in ctx.decl()]
     return Program([i for j in list_decl for i in j])