コード例 #1
0
ファイル: index.php プロジェクト: moorscode/lexer-concept
function runLexer($input, LexerInterface $lexer, InterpeterInterface $interpeter)
{
    try {
        $results = $lexer->run($input);
    } catch (\Exception $exception) {
        return false;
    }
    var_export($results);
    $batch = $interpeter->begin();
    foreach ($results as $result) {
        $interpeter->parse($result, $batch);
    }
    $interpeter->end($batch);
}
コード例 #2
0
ファイル: Parser.php プロジェクト: chrisguitarguy/annotation
 /**
  * {@inheritdoc}
  */
 public function parse($input)
 {
     $stream = $this->lexer->lex($input);
     $annotations = array();
     while ($stream->valid()) {
         if (!$stream->skipUntil(Tokens::T_AT)) {
             break;
         }
         if (!$stream->peek()->test(Tokens::T_IDENTIFIER)) {
             $stream->next();
             // move along
             continue;
         }
         if (!$stream->peek(2)->test(Tokens::T_OPEN_PAREN)) {
             $stream->next();
             // move along
             continue;
         }
         $annotations[] = $this->parseAnnotation($stream);
     }
     return $annotations;
 }
コード例 #3
0
ファイル: Token.php プロジェクト: brianium/csv-parser
 /**
  * @param Lexer $lexer
  * @return string
  */
 public function __toString()
 {
     return '[<' . $this->lexer->getTokenName($this->type) . '>, <' . $this->value . '>]';
 }