Пример #1
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     if ctx.paradecl():
         return FuncDecl(Id(ctx.ID().getText()), self.visit(ctx.paradecl()),
                         self.visit(ctx.func_type()),
                         self.visit(ctx.block_statement()))
     else:
         return FuncDecl(Id(ctx.ID().getText()), [],
                         self.visit(ctx.func_type()),
                         self.visit(ctx.block_statement()))
Пример #2
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     name = self.visit(ctx.func_name())
     param = []
     if ctx.one_para(0):
         for x in ctx.one_para():
             param += [self.visit(x)]
     returnType = self.visit(ctx.func_type())
     body = self.visit(ctx.block_statement())
     return FuncDecl(name, param, returnType, body)
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     ident = Id(ctx.ID().getText())
     param_list = self.visit(ctx.param_list()) if ctx.param_list() else []
     mctype = self.visit(ctx.type_plus())
     block_statement = self.visit(ctx.block_statement())
     return FuncDecl(ident, param_list, mctype, block_statement)