コード例 #1
0
 public function match(SequenceInterface $sequence)
 {
     while (!$sequence->endOfSequence()) {
         $sequence->next();
         $this->tokens[] = $sequence->current();
     }
 }
コード例 #2
0
 public function match(SequenceInterface $sequence)
 {
     if ($sequence->endOfSequence()) {
         throw new ExpectationNotMatched();
     }
     $nextToken = $sequence->peek();
     if ($nextToken['code'] === $this->code) {
         if ($this->content === null || $this->content === $nextToken['content']) {
             $sequence->next();
             return;
         }
     }
     throw new ExpectationNotMatched();
 }