\Twig_Lexer
Lexes a template string.
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
class Twig_Lexer
implements
Twig_LexerInterface
{
- // constants
- const STATE_DATA = 0;
- const STATE_BLOCK = 1;
- const STATE_VAR = 2;
- const STATE_STRING = 3;
- const STATE_INTERPOLATION = 4;
- const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A';
- const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A';
- const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
- const REGEX_DQ_STRING_DELIM = '/"/A';
- const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
- const PUNCTUATION = '()[]{}?:.,|';
- // members
- protected $tokens;
- protected $code;
- protected $cursor;
- protected $lineno;
- protected $end;
- protected $state;
- protected $states;
- protected $brackets;
- protected $env;
- protected $filename;
- protected $options;
- protected $regexes;
- protected $position;
- protected $positions;
- protected $currentVarBlockLine;
- // methods
- public void __construct()
- public Twig_TokenStream tokenize()
- protected void lexData()
- protected void lexBlock()
- protected void lexVar()
- protected void lexExpression()
- protected void lexRawData()
- protected void lexComment()
- protected void lexString()
- protected void lexInterpolation()
- protected void pushToken()
- protected void moveCursor()
- protected void getOperatorRegex()
- protected void pushState()
- protected void popState()
Hierarchy
Implements
Constants
Name | Value |
---|---|
STATE_DATA | 0 |
STATE_BLOCK | 1 |
STATE_VAR | 2 |
STATE_STRING | 3 |
STATE_INTERPOLATION | 4 |
REGEX_NAME | '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A' |
REGEX_NUMBER | '/[0-9]+(?:\.[0-9]+)?/A' |
REGEX_STRING | '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As' |
REGEX_DQ_STRING_DELIM | '/"/A' |
REGEX_DQ_STRING_PART | '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As' |
PUNCTUATION | '()[]{}?:.,|' |
Members
protected
- $brackets
- $code
- $currentVarBlockLine
- $cursor
- $end
- $env
- $filename
- $lineno
- $options
- $position
- $positions
- $regexes
- $state
- $states
- $tokens
Methods
protected
- getOperatorRegex()
- lexBlock()
- lexComment()
- lexData()
- lexExpression()
- lexInterpolation()
- lexRawData()
- lexString()
- lexVar()
- moveCursor()
- popState()
- pushState()
- pushToken()
public
- __construct()
- tokenize() — Tokenizes a source code.