Exemplo n.º 1
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)
 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)
Exemplo n.º 3
0
 def visitFunc_decl(self, ctx: MCParser.Func_declContext):
     return [
         FuncDecl(self.visit(ctx.func_name()),
                  self.visit(ctx.param_list()) if ctx.param_list() else [],
                  self.visit(ctx.mctype()), self.visit(ctx.block_stm()))
     ]