Ejemplo n.º 1
0
 def _read_from(self:object, tr:TextReader, **options) -> ReadResult:
     rslt = Fullmatch([], self)
     acc = []
     for th in self.thseq:
         rslt = tr.read_thing(th, **options)
         if rslt.is_fullmatch():
             acc.extend(rslt.readedlist)
         else:
             tr.push_back(acc)
             break
     #print(repr(rslt))
     if rslt.is_fullmatch():
         return Fullmatch(acc, self)
     else:
         return ReadResult(rslt.state, acc, self)
Ejemplo n.º 2
0
 def _read_from(self:object, tr:TextReader, **options) -> ReadResult:
     rslt = Fullmatch([],self)
     acc = []
     n = 0
     while True:
         if self.max_num >= 0 and n >= self.max_num:
             break
         rslt = tr.read_thing(self.thing, **options)
         if rslt.is_fullmatch():
             acc.extend(rslt.readedlist)
         else:
             break
         n += 1
     if not rslt.is_fullmatch():
         if n >= self.min_num:
             return Fullmatch(acc, self)
         else:
             tr.push_back(acc)
             return ReadResult(rslt.state, acc, self)
     else:
         return Fullmatch(acc, self)