Exemple #1
0
 def _evalargs(self, args, lcls, ignore):
     funcname = str(args[0])
     if __debug__:
         assert isinstance(lcls.iv.last.baseobj, uclassobj), "Cannot apply class functions to a non-class object!"
     if not lcls.iv.last.attrsnodata or list(lcls.iv.last.attrsnodata.keys()) == ["$__name"]:
         whichone = lcls.iv.last
     else:
         whichone = uclassobj._classiter(lcls.iv.last)
     for line in whichone:
         if isinstance(line.baseobj, mthdobj) and line[0].datastr == funcname:
             topass = lcls.onlyuobjs()
             # topass = lclsdict(args.control)
             topass.iv.last = line
             topass.iv.this = lcls.iv.last
             delim = args.control.delims["applier"]
             # print(topass,group(data = delim[0], baseobj = delim[1],
             # control = args.control, args = args[1:]))
             topass.iv.last.baseobj.evalobj(
                 group(data=delim[0], baseobj=delim[1], control=args.control, args=args[1:]), topass
             )
             lcls.iv.last = topass.iv.last.deepcopy()
             return lcls.iv.last
     if funcname == "funcs":
         lcls.iv.last = group(
             data=":", baseobj=arrayobj(), control=args.control, args=uclassobj._classiter(lcls.iv.last)
         )
         return lcls.iv.last
     ret = super()._evalargs(args, lcls, ignore)
     if ret != NotImplemented:
         return ret
     raise ValueError("Function '{}' isn't defined for {} '{}'".format(funcname, type(self).__qualname__, args))
Exemple #2
0
 def getobj(self):
     if self.data == None and self.hasparens():
         return arrayobj()
     if self.data == None:
         return nullobj()
     if __debug__:
         assert isinstance(self.data, str), "'%s' has to be of type str, not '%s'" %(self.data, type(self.data))
     for key in objregexes:
         m = re.fullmatch(key.format(quote = self.control.allquotes, escape = self.control.escape), self.datastr)
         if m:
             self.data = m.groupdict()['keep']
             if objregexes[key] == nullobj:
                 return objregexes[key](isuser = True)
             return objregexes[key]()
     if self.data in self.control.allkws:
         return self.control.allkws[self.data]
     return obj()
Exemple #3
0
 def _speceval(self, args, lcls):
     ctrl = args.control
     if self.name in ctrl.delims:
         if self.name in ctrl.delims['applier']:
             args[0].evalgrp(lcls)
             lcls.iv.last.baseobj.evalobj(args[1:], lcls)
             return
         if self.name in ctrl.delims['endline']:
             for arg in args:
                 arg.evalgrp(lcls)
                 if lcls.iv.ret:
                     # del lcls.iv.ret
                     break
             return
         if self.name in ctrl.delims['arraysep']:
             grp = group(baseobj = arrayobj(), parens = args.parens, control = args.control)
             for arg in args:
                 arg.evalgrp(lcls)
                 if lcls.iv.ret.data:
                     break
                 grp.append(lcls.iv.last)
             lcls.iv.last = grp
             return
             # assert 0, 'todo: arraysep'
         
     if self.name in ctrl.opers['binary']:
         if __debug__:
             assert self.name not in ctrl.opers['binary']['math'], 'all math should have a func associated!'
             assert self.name not in ctrl.opers['binary']['bitwise'], 'all bitwise should have a func associated!'
         if self.name in ctrl.opers['binary']['assignment']:
             d = self.name in args.control.opers['binary']['assignment']['r']
             args[d - 1].evalgrp(lcls)
             for arg in args[slice(d or None, d - 1 or None, None)]:
                 self._evalassign(arg, lcls)
             return
         if self.name in ctrl.opers['binary']['logic']:
             pass
     raise SyntaxError("Unknown Special Operator '{}' in arguments '{}'! Known operators: {}".\
                       format(self, args, ctrl.allopers.keys()))