Esempio n. 1
0
 protected function doScan(Scanner $scanner)
 {
     $start_state = $scanner->getState();
     if (empty($this->parsers)) {
         return true;
     }
     $parser = $this->parsers[0];
     $count = 0;
     while (true) {
         if ($this->max > 0 && $count <= $this->max) {
             return true;
         }
         if (!$parser->trigger($scanner)) {
             if ($this->min == 0 || $count >= $this->min) {
                 return true;
             } else {
                 $scanner->setState($start_state);
                 return false;
             }
         }
         if (!$parser->scan($scanner)) {
             if ($this->min == 0 || $count >= $this->min) {
                 return true;
             } else {
                 $scanner->setState($start_state);
             }
         }
         $count++;
     }
     return true;
 }
Esempio n. 2
0
 protected function doScan(Scanner $scanner)
 {
     $start_state = $scanner->getState();
     foreach ($this->parsers as $parser) {
         if (!($parser->trigger($scanner) && ($scan = $parser->scan($scanner)))) {
             $scanner->setState($start_state);
             return false;
         }
     }
     return true;
 }
Esempio n. 3
0
 protected function doScan(Scanner $scanner)
 {
     $type = $scanner->tokenType();
     $start_state = null;
     foreach ($this->parsers as $parser) {
         $start_state = $scanner->getState();
         if ($type == $parser->trigger($scanner) && $parser->scan($scanner)) {
             return true;
         }
     }
     $scanner->setState($start_state);
     return false;
 }