public function scan(Scanner $scan) { if ($scan->type() === Scanner::SOF) { $this->next($scan); } $ret = $this->doScan($scan); $this->report("scan={$ret} discard={$this->discard} term=" . $this->term()); if ($ret && !$this->discard && $this->term()) { $this->push($scan); } if ($ret) { $this->invokeHandler($scan); } if ($this->term() && $ret) { $this->next($scan); } return $ret; }