Source for file Tokenizer.php
Documentation is available at Tokenizer.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: nobody <nobody@localhost> |
// +----------------------------------------------------------------------+
// $Id: Tokenizer.php 231255 2007-03-05 20:42:42Z cellog $
require_once 'PHP/Parser/DocblockParser.php';
* The tokenizer wrapper for parser - implements the 'standard?' yylex interface
* <li>constructor, which takes the data to parse
* calls php's internal tokenizer, then tidies up the array
* a little (key=>value) rather than mixed type.</li>
* <li>advance, which returns true while tokens are available
* <li>parseError, which returns a string to appear on parser error messages.
* (could also display some of the code that has an error)
* - {@link $line} - current line number
* - {@link $pos} - current token id
* - {@link $N} - total no. of tokens
* @version $Id: Tokenizer.php 231255 2007-03-05 20:42:42Z cellog $
class PHP_Parser_DocblockParser_Tokenizer {
* Tokens - array of all the tokens.
* Total Number of tokens.
* Current token position.
* The current token (either a ord(';') or token numer - see php tokenizer.
* The value associated with a token - eg. for T_STRING it's the string
* Load the tokenizer - with a string to tokenize.
* tidies up array, sets vars pos, line, N and tokens
* @param string PHP code to serialize
function __construct ($data, $options = array ())
$this->tokens = docblock_tokenize ($data, true );
$this->N = count($this->tokens);
* The main advance call required by the parser
* return true if a token is available, false if no more are available.
* skips stuff that is not a valid token
* stores lastcomment, lastcommenttoken
* @return boolean - true = have tokens
while ($this->pos < $this->N) {
echo docblock_token_name ($this->tokens[$this->pos][0 ]). '(' .
(PHP_Parser_DocblockParser ::tokenName (PHP_Parser_DocblockParser ::$transTable[$this->tokens[$this->pos[0 ]]])) .
')' ." : {$this->tokens[$this->pos][1 ]}\n";
switch ($this->tokens[$this->pos][0 ]) {
$this->token = $this->tokens[$this->pos][0 ];
$this->value = $this->tokens[$this->pos][1 ];
$this->token = PHP_Parser_DocblockParser ::$transTable[$this->token];
* return something useful, when a parse error occurs.
* used to build error messages if the parser fails, and needs to know the line number..
return " Error at line {$this->line}";
Documentation generated on Mon, 11 Mar 2019 15:41:15 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|