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

Class: WordParser

Source Location: /phpDocumentor/WordParser.inc

Class WordParser

Class Overview

Retrieves tokens from source code for use by the Parser

Located in /phpDocumentor/WordParser.inc [line 46]



		
				Author(s):
		
		
		API Tags:
See:  Parser

Information Tags:
Version:  $Id: WordParser.inc,v 1.3 2006/04/30 22:18:14 cellog Exp $

Methods

[ Top ]
Direct descendents
Child 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.

[ Top ]
Method Summary
void   backupPos()   Backup to the previous token so that it can be retrieved again in a new context.
void   getBlock()   Unused
void   getPos()   Returns the current pointer position, or 1 character after the end of the word
string   getSource()   Retrieve source code for the last function/method
string|false   getWord()   Retrieve a token from the token list
void   setPos()   Set the internal cursor within the source code
void   setSeperator()  
void   setup()   Initialize the WordParser
void   setWhitespace()   set parser to return or strip whitespace

[ Top ]
Methods
backupPos  [line 322]

  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.

Parameters:
string   $word:  token to back up to


Redefined in descendants as:

[ Top ]
getBlock  [line 291]

  void 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


[ Top ]
getPos  [line 279]

  void getPos( )

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



[ Top ]
getSource  [line 135]

  string getSource( )

Retrieve source code for the last function/method



Redefined in descendants as:

[ Top ]
getWord  [line 187]

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


API Tags:
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


Redefined in descendants as:

[ Top ]
setPos  [line 309]

  void setPos( integer $pos  )

Set the internal cursor within the source code

Parameters:
integer   $pos: 


[ Top ]
setSeperator  [line 300]

  void setSeperator( array &$seps  )

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

API Tags:
Uses:  $wordseperators


[ Top ]
setup  [line 119]

  void setup( string &$input  )

Initialize the WordParser

Parameters:
string   &$input:  source code


Redefined in descendants as:

[ Top ]
setWhitespace  [line 332]

  void setWhitespace( [boolean $val = false]  )

set parser to return or strip whitespace

Parameters:
boolean   $val: 


[ Top ]

Documentation generated on Tue, 24 Oct 2006 09:26:42 -0500 by phpDocumentor 1.3.1