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)
Exemplo n.º 2
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     # return Program([FuncDecl(Id(ctx.ID().getText()), [],
     # self.visit(ctx.mctype()),Block([self.visit(ctx.body())] if ctx.body() else []))])
     decl_list = [self.visit(x) for x in ctx.declaration()]
     res = functools.reduce(
         lambda x, y: x + y
         if isinstance(y, list) else x + [y], decl_list, [])
     return Program(res)
 def visitProgram(self, ctx: MCParser.ProgramContext):
     """
     return Program(list of Decl)
     where Decl:
         + VarDecl  ==> var_decl
         + FuncDecl ==> func_decl
     """
     return Program(self.visit(ctx.manydecl()))
Exemplo n.º 4
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     #danh cho vardecl
     # varDecListList=[self.visit(x) for x in ctx.dec()];
     # varDecList= reduce(lambda x,y:x+y,varDecListList)        # return Program(varDeclList)
     #danh cho funcdecl
     DecListList = [self.visit(x) for x in ctx.dec()]
     DecList = reduce(lambda x, y: x + y,
                      DecListList) if DecListList else []
     return Program(DecList)
Exemplo n.º 5
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     decllist = list()
     for x in ctx.declaration():
         decl = self.visitDeclaration(x)
         if isinstance(decl, list):
             decllist.extend(decl)
         else:
             decllist.append(decl)
     return Program(decllist)
Exemplo n.º 6
0
 def visitProgram(self, ctx:MCParser.ProgramContext):
     declList = []
     for x in ctx.declarates():
         decl = self.visitDeclarates(x)
         if isinstance(decl, list):
             declList.extend(decl if decl else [])
         else:
             declList.append(decl)
     return Program(declList)
 def visitProgram(self, ctx: MCParser.ProgramContext):
     decl = [self.visit(i) for i in ctx.manydeclares().declare()]
     result = []
     for i in decl:
         if type(i) is not list:
             result.append(i)
         else:
             for j in i:
                 result.append(j)
     return Program(result)
Exemplo n.º 8
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     # program: decls+ EOF;
     lstDecl = []
     for decl in ctx.decls():
         if (isinstance(self.visit(decl), list)):
             lstDecl += self.visit(decl)
         else:
             lstDecl += [self.visit(decl)]
     return Program(
         lstDecl
     )  #return Program(list(map(lambda x:self.visit(x),ctx.decls())))
Exemplo n.º 9
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)    
Exemplo n.º 10
0
Arquivo: Count.py Projeto: khangsk/PPL
 def visitProgram(self,ctx:MCParser.ProgramContext):
     # return ctx.vardecls().accept(self) + 1
     return self.visitVardecls(ctx.vardecls()) + 1
Exemplo n.º 11
0
 def visitProgram(self,ctx:MCParser.ProgramContext):
     arr = []
     for i in ctx.vardecl():
         arr += i.accept(self)
     return Program(arr) # return a Program object
Exemplo n.º 12
0
 def visitProgram(self,ctx:MCParser.ProgramContext):
     # program : manydecls EOF;
     return Program(self.visit(ctx.manydecls()))
Exemplo n.º 13
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program(
         self.flatten([self.visit(x) for x in ctx.program_part()]))
Exemplo n.º 14
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program([j for i in ctx.decl() for j in self.visit(i)])
Exemplo n.º 15
0
    def visitProgram(self, ctx: MCParser.ProgramContext):

        return Program(fatten([self.visit(decl) for decl in ctx.decl()]))
Exemplo n.º 16
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     # EOF is also considered as a node
     return 1 + self.visit(ctx.vardecls())
Exemplo n.º 17
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     d = []
     for i in ctx.decl():
         d = d + self.visit(i)
     return Program(d)
Exemplo n.º 18
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program(self.visit(ctx.vardecls()))  # return a Program object
Exemplo n.º 19
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     lst = []
     for x in ctx.decl():
         lst += self.visit(x)
     return Program(lst)
Exemplo n.º 20
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     x = Program([i for x in ctx.decl() for i in self.visit(x)])
     return x
Exemplo n.º 21
0
 def visitProgram (self, ctx:MCParser.ProgramContext):
     return Program(list(reduce(lambda x,y: x + self.visit(y),ctx.decl(),[])))
 def visitProgram(self,ctx:MCParser.ProgramContext):
     return Program(self.visit(ctx.manydeclarations()))
Exemplo n.º 23
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program(ctx.vardecls().accept(self))  # return a Program object
 def visitProgram(self, ctx: MCParser.ProgramContext):
     mnDecls = self.visit(ctx.manydecls())
     # print('mnDecls =>', mnDecls)
     return Program(mnDecls)
Exemplo n.º 25
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program(
         i for x in ctx.decl() for i in self.visit(x)
     )
Exemplo n.º 26
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program(
         list(
             self.flatten(
                 self.visit(decl)
                 for decl in list(ctx.getChildren())[:-1])))
Exemplo n.º 27
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program(self.visit(ctx.decls()))
Exemplo n.º 28
0
 def visitProgram(self, ctx:MCParser.ProgramContext):
     return 1 + self.visitVardecls(ctx.vardecls())
Exemplo n.º 29
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     return Program([
         self.visit(ctx.getChild(x)) for x in range(ctx.getChildCount() - 1)
     ])
Exemplo n.º 30
0
 def visitProgram(self, ctx: MCParser.ProgramContext):
     '''program: declare+ EOF;'''
     return Program(
         list(
             reduce(lambda x, y: x + y,
                    [self.visit(t) for t in ctx.declare()], [])))