public function setInput(StringInterface $string) { $this->result = null; $this->lexer->setInput((string) $string); $this->currentStyle = new Style(); return $this; }
/** * Parse the template to a regular expression * * @param string $template * @return string * @throws ParserException */ public function parse($template) { $this->lexer->setInput($template); $regex = ''; while ($this->lexer->moveNext()) { switch ($this->lexer->lookahead['type']) { case Lexer::T_PLACEHOLDER_START: $regex .= $this->parsePlaceholder(); break; case Lexer::T_STRING: $regex .= $this->lexer->lookahead['value']; break; default: $this->syntaxError(sprintf('%s or %s', $this->lexer->getLiteral(Lexer::T_PLACEHOLDER_START), $this->lexer->getLiteral(Lexer::T_STRING))); } } return "#^{$regex}\$#"; }