Class WordParser

Description

Retrieves tokens from source code for use by the Parser

Located in /phpDocumentor/WordParser.inc (line 56)


	
			
Direct descendents
Class Description
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.
Method 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])
Methods
backupPos (line 346)

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.

void backupPos (string $word)
  • string $word: token to back up to

Redefined in descendants as:
getBlock (line 305)

Unused

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

  • return: the requested block of characters
string getBlock (integer $start, integer $len)
  • integer $start: starting position
  • integer $len: length of block to retrieve
getPos (line 290)

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

  • return: the position
int getPos ()
getSource (line 149)

Retrieve source code for the last function/method

string getSource ()

Redefined in descendants as:
getWord (line 206)

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. }}

  • 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
string|false getWord ()

Redefined in descendants as:
setPos (line 330)

Set the internal cursor within the source code

void setPos (integer $pos)
  • integer $pos: the position
setSeperator (line 318)

Sets the list of possible separator tokens

  • uses: $wordseperators
void setSeperator (array &$seps)
  • array &$seps: array of strings that separate tokens
setup (line 132)

Initialize the WordParser

void setup (string &$input)
  • string &$input: source code

Redefined in descendants as:
setWhitespace (line 360)

set parser to return or strip whitespace

void setWhitespace ([boolean $val = false])
  • boolean $val: flag to return or strip whitespace

Documentation generated on Mon, 05 Dec 2011 21:01:20 -0600 by phpDocumentor 1.4.4