[ class tree: phpDocumentor ] [ index: phpDocumentor ] [ all elements ]

Class: WordParser

Source Location: /PhpDocumentor-1.5.0a1/phpDocumentor/

Class Overview

Retrieves tokens from source code for use by the Parser



  • Release: 1.5.0a1


  • 2000-2007 Joshua Eichorn


Child classes:

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

Inherited Variables

Inherited Methods

Class Details

[line 56]
Retrieves tokens from source code for use by the Parser

[ Top ]

Method Detail

backupPos   [line 346]

void backupPos( string $word)

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.

Overridden in child classes as:

backs the parser up to the previous position
back the word parser to the previous token as defined by $last_token


string   $word     token to back up to

[ Top ]

getBlock   [line 305]

string getBlock( integer $start, integer $len)


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

  • Return: the requested block of characters


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

[ Top ]

getPos   [line 290]

int getPos( )

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

[ Top ]

getSource   [line 149]

string getSource( )

Retrieve source code for the last function/method

Overridden in child classes as:

loads up next set of source code

[ Top ]

getWord   [line 206]

string|false getWord( )

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

Overridden in child classes as:

Retrieve a token for the phpDocumentorTParser
Retrieve the next token

[ Top ]

setPos   [line 330]

void setPos( integer $pos)

Set the internal cursor within the source code


integer   $pos     the position

[ Top ]

setSeperator   [line 318]

void setSeperator( array &$seps)

Sets the list of possible separator tokens
  • Uses: $wordseperators


array   &$seps     array of strings that separate tokens

[ Top ]

setup   [line 132]

void setup( string &$input)

Initialize the WordParser

Overridden in child classes as:

Set the word parser to go.
Uses to tokenize the source code.
Initialize the parser object


string   &$input     source code

[ Top ]

setWhitespace   [line 360]

void setWhitespace( [boolean $val = false])

set parser to return or strip whitespace


boolean   $val     flag to return or strip whitespace

[ Top ]

Documentation generated on Sun, 02 Sep 2012 00:03:21 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.