Esempio n. 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
Esempio n. 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)]
Esempio n. 3
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)
Esempio n. 4
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()))
 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()))
Esempio n. 6
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)
Esempio n. 7
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()))]
Esempio n. 8
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)
 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)
Esempio n. 10
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()))
     ]