Class WordParser

(line 56)

Description


Located in File: /phpDocumentor/WordParser.inc

Retrieves tokens from source code for use by the Parser


Classes extended from WordParser:
ObjectWordParser
Like WordParser but designed to handle an array with strings and
phpDocumentorTWordParser
Like WordParser, but expects an array of tokens from the tokenizer instead of a string.

Class Variables

Summary:

Class Constants

Summary:

Method Detail

Summary:
void backupPos (string $word)
string getBlock (integer $start, integer $len)
int getPos ()
string getSource ()
string|false getWord ()
void setPos (integer $pos)
void setSeperator (array &$seps)
void setup (string &$input)
void setWhitespace ([boolean $val = false])

Method backupPos (line 346)

void backupPos( string $word)

Overridden in child classes as:

phpDocumentorTWordParser::backupPos()
backs the parser up to the previous position
phpDocumentor_HighlightWordParser::backupPos()
back the word parser to the previous token as defined by $last_token

Backup to the previous token so that it can be retrieved again in a new context.

Occasionally, a word will be passed to an event handler that should be handled by another event handler. This method allows that to happen.

Parameters

  • string $word: token to back up to

Info

Method getBlock (line 305)

string getBlock( integer $start, integer $len)

Unused

  1. function getBlock($start$len)
  2.     {
  3.         return substr($this->data$start$len);
  4.     }

Parameters

  • integer $start: starting position
  • integer $len: length of block to retrieve

Info

  • return - the requested block of characters

Method getPos (line 290)

int getPos( )

Returns the current pointer position, or 1 character after the end of the word

Info

  • return - the position

Method getSource (line 149)

string getSource( )

Overridden in child classes as:

phpDocumentorTWordParser::getSource()
loads up next set of source code

Retrieve source code for the last function/method

Info

Method getWord (line 206)

string|false getWord( )

Overridden in child classes as:

ObjectWordParser::getWord()
phpDocumentorTWordParser::getWord()
Retrieve a token for the phpDocumentorTParser
phpDocumentor_HighlightWordParser::getWord()
Retrieve the next token

Retrieve a token from the token list

The Parser class relies upon this method to retrieve the next token. The $wordseperators array is a collection of strings that delineate tokens for the current parser state. $wordseperators is set by the parser with a call to Parser::configWordParser() every time a new parser state is reached.

For example, while parsing the source code for a class, the word

  1. var
is a token, and
  1. global
is not, but inside a function, the reverse is true. The parser state PARSER_STATE_CLASS has a token list that includes whitespace, code delimiters like ; and {}, and comment/DocBlock indicators

If the whitespace option has been turned off using setWhitespace(), then no whitespace is returned with tokens

{@ is of course the string containing the PHP code to be parsed, and $pos is the cursor, or current location within the parsed data. }}

Info

  • return - the next token, an empty string if there are no token separators in the $wordseperators array, or false if the end of input has been reached

Method setPos (line 330)

void setPos( integer $pos)

Set the internal cursor within the source code

Parameters

  • integer $pos: the position

Info

Method setSeperator (line 318)

void setSeperator( array &$seps)

Sets the list of possible separator tokens

Parameters

  • array &$seps: array of strings that separate tokens

Info

  • uses - $wordseperators

Method setup (line 132)

void setup( string &$input)

Overridden in child classes as:

ObjectWordParser::setup()
Set the word parser to go.
phpDocumentorTWordParser::setup()
Uses http://www.php.net/token_get_all to tokenize the source code.
phpDocumentor_HighlightWordParser::setup()
Initialize the parser object

Initialize the WordParser

Parameters

  • string &$input: source code

Info

Method setWhitespace (line 360)

void setWhitespace( [boolean $val = false])

set parser to return or strip whitespace

Parameters

  • boolean $val: flag to return or strip whitespace

Info

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary


Documentation generated on Mon, 05 Dec 2011 21:29:19 -0600 by phpDocumentor 1.4.4