/**
  * @param string $input
  * @return Tokenizer
  * @throws \Exception
  */
 public function readInput($input)
 {
     $recognizer = new Recognizer($this->rules, static::START_RULE_NAME);
     $parser = new Parser();
     $tokens = $this->tokenizer->tokenize($input);
     $state = $recognizer->recognize($tokens);
     $parseTree = $parser->parse($state, $tokens);
     return $this->visitor->dispatch($parseTree);
 }
 /**
  * @param string $input
  * @param string $startRuleName
  * @return Recognizer
  * @throws \Exception
  */
 public function readInput($input, $startRuleName)
 {
     $input .= "\n";
     // Fun story. Earley parsers don't like empty rules, so
     // %TOKEN_EOL currently has to exist at the end of the input
     // in order for recognition to happen.
     $recognizer = new Recognizer($this->rules, static::START_RULE_NAME);
     $parser = new Parser();
     $tokens = $this->tokenizer->tokenize($input);
     $state = $recognizer->recognize($tokens);
     $parseTree = $parser->parse($state, $tokens);
     return $this->visitor->dispatch($parseTree, $startRuleName);
 }