Esempio n. 1
0
 def visitProgram(self,ctx:MCParser.ProgramContext):
     decl = (int)(len(ctx.fun_decl())+len(ctx.vardecl()))
     lst = []
     for i in range(decl):
         if(isinstance(ctx.getChild(i),MCParser.Fun_declContext)):
             lst.append(self.visit(ctx.getChild(i)))
         if(isinstance(ctx.getChild(i),MCParser.VardeclContext)):
             lst+=self.visit(ctx.getChild(i))
     return Program(lst)    
 def visitProgram(self,ctx:MCParser.ProgramContext):
     list_declaration = [self.visit(ctx.getChild(i)) for i in range(ctx.getChildCount()-1)]
     declarations = []
     for x in list_declaration:
         if isinstance(x, list):
             declarations += x
         else:
             declarations += [x]
     return Program(declarations)
Esempio n. 3
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program([
         self.visit(ctx.getChild(x)) for x in range(ctx.getChildCount() - 1)
     ])