Example #1
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     name = Id(ctx.ID().getText())
     param = self.visit(ctx.list_params())
     returnType = self.visit(ctx.mctype())
     body = self.visit(ctx.block_stmt())
     func_decl = FuncDecl(name, param, returnType, body)
     return func_decl
Example #2
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     name = ctx.ID().getText()
     para = ([self.visit(x) for x in ctx.para_list().para_decl()]
             if ctx.para_list() else [])
     return_type = self.visit(ctx.types())
     body = self.visit(ctx.block_stmt())
     return [FuncDecl(Id(name), para, return_type, body)]
Example #3
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     #name: Id
     #param: list(VarDecl)
     #returnType: Type
     #body: Block
     #ID = Id(ctx.ID().getText())
     #p = self.visit(ctx.paralist()) if ctx.paralist() else []
     return FuncDecl(Id(ctx.ID().getText()),
                     self.visit(ctx.paralist()) if ctx.paralist() else [],
                     self.visit(ctx.functype()),
                     self.visit(ctx.block_stmt()))
Example #4
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     name = Id(ctx.ID().getText())
     if ctx.primi_type():
         returnType = self.visit(ctx.primi_type())
     else:
         if ctx.VOIDTYPE():
             returnType = VoidType()
         else:
             returnType = self.visit(ctx.array_pointer_type())
     param = [] if ctx.param_list() == None else self.visit(
         ctx.param_list())
     body = self.visit(ctx.block_stmt())
     return FuncDecl(name, param, returnType, body)
Example #5
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     return [FuncDecl(Id(ctx.ID().getText()),self.visit(ctx.para_list()),self.visit(ctx.all_type()),self.visit(ctx.block_stmt()))]
Example #6
0
 def visitFunc_decl(self, ctx:MCParser.Func_declContext):
     func_type = self.visitFunc_type(ctx.func_type())
     paralist = self.visitParalist(ctx.paralist())
     block_stmt = self.visitBlock_stmt(ctx.block_stmt())
     id = Id(ctx.ID().getText())
     return FuncDecl(id, paralist, func_type, block_stmt)