Provides operations on token streams, for use by pretty printer.

  • internal
CloneableInstantiable
Methods
public __construct(array $tokens)
 

Create token stream instance.

    public findRight( $pos, $findTokenType)
    public getIndentationBefore(int $pos) : int
     

    Get indentation before token position.

    • return int Indentation depth (in spaces)
    public getTokenCode(int $from, int $to, int $indent) : string
     

    Get the code corresponding to a token offset range, optionally adjusted for indentation.

    • return string Code corresponding to token range, adjusted for indentation
    public haveBraces(int $startPos, int $endPos) : bool
     

    Whether the given position is immediately surrounded by braces.

    • return bool
    public haveParens(int $startPos, int $endPos) : bool
     

    Whether the given position is immediately surrounded by parenthesis.

    • return bool
    public haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool
     

    Check whether the position is directly followed by a certain token type.

    During this check whitespace and comments are skipped.

    • return bool Whether the expected token was found
    public haveTokenImmediativelyBefore(int $pos, $expectedTokenType) : bool
     

    Check whether the position is directly preceded by a certain token type.

    During this check whitespace and comments are skipped.

    • return bool Whether the expected token was found
    public skipLeft(int $pos, $skipTokenType)
    public skipLeftWhitespace(int $pos)
     

    Return first non-whitespace token position smaller or equal to passed position.

    • return int Non-whitespace token position
    public skipRight(int $pos, $skipTokenType)
    public skipRightWhitespace(int $pos)
     

    Return first non-whitespace position greater or equal to passed position.

    • return int Non-whitespace token position
    Properties
    private $indentMap
     
    • var int[] Map from position to indentation
    private $tokens
     
    • var array Tokens (in token_get_all format)
    Methods
    private calcIndentMap()
     

    Precalculate the indentation at every token position.

    • return int[] Token position to indentation map
    © 2020 Bruce Wells
    Search Namespaces \ Classes
    ConfigurationNumbers (0-9.) only