public function parse(Input $input) { if (!$input->complete()) { return $input->errorHere("Unable to process {$input->get()}")->addParser($this); } return $input->nonCapturingMatchHere()->addParser($this); }
public function parse(Input $input) { if ($input->complete()) { return $input->errorHere('Not cannot be matched at end of stream.')->addParser($this); } // Initially no parser should match, this would be a zero width result if ($this->matches($input)) { return $input->errorHere("Found a match at the start of the source {$input->get()}")->addParser($this); } $consumed = ''; while (!$this->matches($input) && !$input->complete()) { $consumed .= $input->peek(0); $input->consume(1); } return $input->matchHere([$consumed])->addParser($this); }