Class PT_Parser

Description

Implements interfaces:

  • Iterator (internal interface)

Smart iterator for tokens obtained parsed code.

Located in /pt-parser.php (line 43)


	
			
Variable Summary
 Array[String]Int $braceBlock
 Array[String]Bool $inBlock
 Array $mods
 Mixed $mod_list
 Int $position
 Array() $tokens
Method Summary
 PT_Parser __construct (String $data)
 Bool block ([String $id = ''])
 void each ()
 void key ()
 void line ()
 void modifiers ()
 void next ()
 void reset_modifiers ()
 void rewind ()
 void skip_till ( $token)
 void val ()
 void valid ()
Variables
Array[String]Int $braceBlock = array() (line 95)

Braces counter for the block function.

  • access: protected
Array[String]Bool $inBlock = array() (line 89)

State for the block function.

  • access: protected
Array $mods = array() (line 61)

Possible modifiers for upcoming tokens.

  • access: protected
Int $mod_distance = 0 (line 67)

Distance since the modifier was captured.

  • access: protected
Mixed $mod_list = array(
T_DOC_COMMENT,
T_CONST,
T_FINAL,
T_PUBLIC,
T_PRIVATE,
T_PROTECTED,
T_VAR,
T_STATIC,
'&'
)
(line 73)

Tokens of modifiers to be captured.

  • access: protected
Int $position (line 55)

Current Position

  • access: protected
Array() $tokens (line 49)

Token list

  • access: protected
Methods
Constructor __construct (line 104)

Constructor -- tokenizes code.

Function required for the Iterator interface.

  • access: public
PT_Parser __construct (String $data)
  • String $data: Code to be parsed.
block (line 241)

Returns true while till the _upcoming_ pair of braces is matched.

Useful for parsing blocks encapsulated using { }: for example, to parse a function definition. Should only be used from the _same place_ in a single file: identifying which block must be managed is done on the basis of uniqueness of the line number and the file name.

Can also be passed an id to over-ride the auto generated id when the 1st stack frame from `debug_backtrace` doesn't prove sufficient for identifing the final caller: for example from a constructor of another class.

  • return: True while the block hasn't ended.
  • access: public
Bool block ([String $id = ''])
  • String $id: The identifier for the caller.
current (line 150)

Returns a PT_Parser_Token instance or NULL in case the iterator has overshot.

Function required for the Iterator interface.

  • access: public
PT_Parser_Token|Null current ()

Implementation of:
Iterator::current
each (line 200)

Run on all tokens internally. Useful in derived classes.

  • access: protected
void each ()
key (line 137)

Returns the current key val.

Function required for the Iterator interface.

  • access: public
void key ()

Implementation of:
Iterator::key
line (line 207)

Returns the line of the current token.

  • access: protected
void line ()
modifiers (line 179)

Saves modifiers for future tokens.

Saves modifiers from the mod_list, resets in case they become inapplicable.

  • access: protected
void modifiers ()
next (line 127)

Moves to the next token and runs an 'each' internal call.

Function required for the Iterator interface.

  • access: public
void next ()

Implementation of:
Iterator::next
reset_modifiers (line 193)

Resets all modifiers

  • access: protected
void reset_modifiers ()
rewind (line 120)

Return to the start.

Function required for the Iterator interface.

  • access: public
void rewind ()

Implementation of:
Iterator::rewind
skip_till (line 220)

Skip tokens till the specified token is reached.

Useful for exploratory parsing

  • access: public
void skip_till ( $token)
  • $token
val (line 165)

Return the current val of the token.

  • access: public
void val ()
valid (line 113)

Checks whether the iterator can still move forward.

Function required for the Iterator interface.

  • access: public
void valid ()

Implementation of:
Iterator::valid

Documentation generated on Thu, 29 Sep 2011 01:44:45 +0530 by phpDocumentor 1.4.3