This component is a port of the Python lxml library, which is copyright Infrae and distributed under the BSD license.
Author: Fabien Potencier (fabien.potencier@symfony-project.com)
Beispiel #1
0
 /**
  * Parses an expression and returns the Node object that represents
  * the parsed expression.
  *
  * @param string $string The expression to parse
  *
  * @return Node\NodeInterface
  *
  * @throws \Exception When tokenizer throws it while parsing
  */
 public function parse($string)
 {
     $tokenizer = new Tokenizer();
     $stream = new TokenStream($tokenizer->tokenize($string), $string);
     try {
         return $this->parseSelectorGroup($stream);
     } catch (\Exception $e) {
         $class = get_class($e);
         throw new $class(sprintf('%s at %s -> %s', $e->getMessage(), implode($stream->getUsed(), ''), $stream->peek()), 0, $e);
     }
 }