Exemplo n.º 1
0
 /**
  * @param string $src
  * @param array  $options
  * @param int    $line
  *
  * @throws ParserException
  * @throws LexerException
  *
  * @return mixed
  */
 public function read($src, array $options = [], $line = 1)
 {
     $cursor = new Cursor($src, $line);
     $tokens = $this->lexer->tokenize($cursor);
     $stream = new Stream($tokens);
     $out = $this->parser->parse($stream, $options);
     $stream->close();
     return $out;
 }
Exemplo n.º 2
0
Arquivo: Lexer.php Projeto: phn-io/dal
 /**
  * @param Cursor $cursor
  *
  * @throws \Exception
  *
  * @return Stream
  */
 public function tokenize(Cursor $cursor)
 {
     $stream = [];
     foreach (parent::tokenize($cursor) as $offset => $token) {
         if ($token->is(Token::TYPE_STRING | Token::TYPE_BACK_QUOTED)) {
             $line = $token->getLine();
             $stream = array_merge($stream, $this->templateLexer->tokenize(new Cursor($token->getValue(), $line)));
         } else {
             $stream[] = $token;
         }
     }
     return $stream;
 }
Exemplo n.º 3
0
 /**
  * @When I lex the DSL:
  */
 public function tokenize(PyStringNode $dsl)
 {
     $lexer = new Lexer($this->skipRules, $this->matchRules);
     $this->stream = $lexer->tokenize(new Cursor($dsl, 1));
 }