ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Lexer Class Reference

Lexes a template string. More...

+ Inheritance diagram for Twig_Lexer:
+ Collaboration diagram for Twig_Lexer:

Public Member Functions

 __construct (Twig_Environment $env, array $options=array())
 
 tokenize ($code, $name=null)
 Tokenizes a source code. More...
 
 tokenize ($code, $name=null)
 Tokenizes a source code. More...
 

Data Fields

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 = '()[]{}?:.,|'
 

Protected Member Functions

 lexData ()
 
 lexBlock ()
 
 lexVar ()
 
 lexExpression ()
 
 lexRawData ($tag)
 
 lexComment ()
 
 lexString ()
 
 lexInterpolation ()
 
 pushToken ($type, $value='')
 
 moveCursor ($text)
 
 getOperatorRegex ()
 
 pushState ($state)
 
 popState ()
 

Protected Attributes

 $tokens
 
 $code
 
 $cursor
 
 $lineno
 
 $end
 
 $state
 
 $states
 
 $brackets
 
 $env
 
 $filename
 
 $options
 
 $regexes
 
 $position
 
 $positions
 
 $currentVarBlockLine
 

Private Attributes

 $source
 

Detailed Description

Lexes a template string.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 18 of file Lexer.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Lexer::__construct ( Twig_Environment  $env,
array  $options = array() 
)

Definition at line 52 of file Lexer.php.

53 {
54 $this->env = $env;
55
56 $this->options = array_merge(array(
57 'tag_comment' => array('{#', '#}'),
58 'tag_block' => array('{%', '%}'),
59 'tag_variable' => array('{{', '}}'),
60 'whitespace_trim' => '-',
61 'interpolation' => array('#{', '}'),
62 ), $options);
63
64 $this->regexes = array(
65 'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
66 'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
67 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
68 'operator' => $this->getOperatorRegex(),
69 'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s',
70 'lex_block_raw' => '/\s*(raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As',
71 'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As',
72 'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
73 'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
74 'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A',
75 );
76 }
getOperatorRegex()
Definition: Lexer.php:381

References $env, $options, and getOperatorRegex().

+ Here is the call graph for this function:

Member Function Documentation

◆ getOperatorRegex()

Twig_Lexer::getOperatorRegex ( )
protected

Definition at line 381 of file Lexer.php.

382 {
383 $operators = array_merge(
384 array('='),
385 array_keys($this->env->getUnaryOperators()),
386 array_keys($this->env->getBinaryOperators())
387 );
388
389 $operators = array_combine($operators, array_map('strlen', $operators));
390 arsort($operators);
391
392 $regex = array();
393 foreach ($operators as $operator => $length) {
394 // an operator that ends with a character must be followed by
395 // a whitespace or a parenthesis
396 if (ctype_alpha($operator[$length - 1])) {
397 $r = preg_quote($operator, '/').'(?=[\s()])';
398 } else {
399 $r = preg_quote($operator, '/');
400 }
401
402 // an operator with a space can be any amount of whitespaces
403 $r = preg_replace('/\s+/', '\s+', $r);
404
405 $regex[] = $r;
406 }
407
408 return '/'.implode('|', $regex).'/A';
409 }
$r
Definition: example_031.php:79

References $r.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ lexBlock()

Twig_Lexer::lexBlock ( )
protected

Definition at line 209 of file Lexer.php.

210 {
211 if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) {
213 $this->moveCursor($match[0]);
214 $this->popState();
215 } else {
216 $this->lexExpression();
217 }
218 }
pushToken($type, $value='')
Definition: Lexer.php:365
popState()
Definition: Lexer.php:417
moveCursor($text)
Definition: Lexer.php:375
lexExpression()
Definition: Lexer.php:231
const BLOCK_END_TYPE
Definition: Token.php:30

References Twig_Token\BLOCK_END_TYPE, lexExpression(), moveCursor(), popState(), and pushToken().

Referenced by tokenize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexComment()

Twig_Lexer::lexComment ( )
protected

Definition at line 319 of file Lexer.php.

320 {
321 if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
322 throw new Twig_Error_Syntax('Unclosed comment.', $this->lineno, $this->source);
323 }
324
325 $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
326 }
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Definition: Syntax.php:19

References moveCursor().

Referenced by lexData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexData()

Twig_Lexer::lexData ( )
protected

Definition at line 153 of file Lexer.php.

154 {
155 // if no matches are left we return the rest of the template as simple text token
156 if ($this->position == count($this->positions[0]) - 1) {
157 $this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor));
158 $this->cursor = $this->end;
159
160 return;
161 }
162
163 // Find the first token after the current cursor
164 $position = $this->positions[0][++$this->position];
165 while ($position[1] < $this->cursor) {
166 if ($this->position == count($this->positions[0]) - 1) {
167 return;
168 }
169 $position = $this->positions[0][++$this->position];
170 }
171
172 // push the template text first
173 $text = $textContent = substr($this->code, $this->cursor, $position[1] - $this->cursor);
174 if (isset($this->positions[2][$this->position][0])) {
175 $text = rtrim($text);
176 }
178 $this->moveCursor($textContent.$position[0]);
179
180 switch ($this->positions[1][$this->position][0]) {
181 case $this->options['tag_comment'][0]:
182 $this->lexComment();
183 break;
184
185 case $this->options['tag_block'][0]:
186 // raw data?
187 if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, null, $this->cursor)) {
188 $this->moveCursor($match[0]);
189 $this->lexRawData($match[1]);
190 // {% line \d+ %}
191 } elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) {
192 $this->moveCursor($match[0]);
193 $this->lineno = (int) $match[1];
194 } else {
196 $this->pushState(self::STATE_BLOCK);
197 $this->currentVarBlockLine = $this->lineno;
198 }
199 break;
200
201 case $this->options['tag_variable'][0]:
203 $this->pushState(self::STATE_VAR);
204 $this->currentVarBlockLine = $this->lineno;
205 break;
206 }
207 }
lexRawData($tag)
Definition: Lexer.php:299
lexComment()
Definition: Lexer.php:319
pushState($state)
Definition: Lexer.php:411
const VAR_START_TYPE
Definition: Token.php:29
const TEXT_TYPE
Definition: Token.php:27
const BLOCK_START_TYPE
Definition: Token.php:28
$text
Definition: errorreport.php:18

References $end, $lineno, $position, $text, Twig_Token\BLOCK_START_TYPE, lexComment(), lexRawData(), moveCursor(), pushState(), pushToken(), Twig_Token\TEXT_TYPE, and Twig_Token\VAR_START_TYPE.

Referenced by tokenize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexExpression()

Twig_Lexer::lexExpression ( )
protected

Definition at line 231 of file Lexer.php.

232 {
233 // whitespace
234 if (preg_match('/\s+/A', $this->code, $match, null, $this->cursor)) {
235 $this->moveCursor($match[0]);
236
237 if ($this->cursor >= $this->end) {
238 throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', self::STATE_BLOCK === $this->state ? 'block' : 'variable'), $this->currentVarBlockLine, $this->source);
239 }
240 }
241
242 // operators
243 if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) {
244 $this->pushToken(Twig_Token::OPERATOR_TYPE, preg_replace('/\s+/', ' ', $match[0]));
245 $this->moveCursor($match[0]);
246 }
247 // names
248 elseif (preg_match(self::REGEX_NAME, $this->code, $match, null, $this->cursor)) {
249 $this->pushToken(Twig_Token::NAME_TYPE, $match[0]);
250 $this->moveCursor($match[0]);
251 }
252 // numbers
253 elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, null, $this->cursor)) {
254 $number = (float) $match[0]; // floats
255 if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
256 $number = (int) $match[0]; // integers lower than the maximum
257 }
258 $this->pushToken(Twig_Token::NUMBER_TYPE, $number);
259 $this->moveCursor($match[0]);
260 }
261 // punctuation
262 elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) {
263 // opening bracket
264 if (false !== strpos('([{', $this->code[$this->cursor])) {
265 $this->brackets[] = array($this->code[$this->cursor], $this->lineno);
266 }
267 // closing bracket
268 elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
269 if (empty($this->brackets)) {
270 throw new Twig_Error_Syntax(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
271 }
272
273 list($expect, $lineno) = array_pop($this->brackets);
274 if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
275 throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
276 }
277 }
278
279 $this->pushToken(Twig_Token::PUNCTUATION_TYPE, $this->code[$this->cursor]);
281 }
282 // strings
283 elseif (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
284 $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)));
285 $this->moveCursor($match[0]);
286 }
287 // opening double quoted string
288 elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
289 $this->brackets[] = array('"', $this->lineno);
290 $this->pushState(self::STATE_STRING);
291 $this->moveCursor($match[0]);
292 }
293 // unlexable
294 else {
295 throw new Twig_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
296 }
297 }
const NUMBER_TYPE
Definition: Token.php:33
const NAME_TYPE
Definition: Token.php:32
const STRING_TYPE
Definition: Token.php:34
const PUNCTUATION_TYPE
Definition: Token.php:36
const OPERATOR_TYPE
Definition: Token.php:35

References $cursor, $lineno, moveCursor(), Twig_Token\NAME_TYPE, Twig_Token\NUMBER_TYPE, Twig_Token\OPERATOR_TYPE, Twig_Token\PUNCTUATION_TYPE, pushState(), pushToken(), and Twig_Token\STRING_TYPE.

Referenced by lexBlock(), lexInterpolation(), and lexVar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexInterpolation()

Twig_Lexer::lexInterpolation ( )
protected

Definition at line 352 of file Lexer.php.

353 {
354 $bracket = end($this->brackets);
355 if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) {
356 array_pop($this->brackets);
358 $this->moveCursor($match[0]);
359 $this->popState();
360 } else {
361 $this->lexExpression();
362 }
363 }
const INTERPOLATION_END_TYPE
Definition: Token.php:38

References Twig_Token\INTERPOLATION_END_TYPE, lexExpression(), moveCursor(), popState(), and pushToken().

Referenced by tokenize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexRawData()

Twig_Lexer::lexRawData (   $tag)
protected

Definition at line 299 of file Lexer.php.

300 {
301 if ('raw' === $tag) {
302 @trigger_error(sprintf('Twig Tag "raw" is deprecated since version 1.21. Use "verbatim" instead in %s at line %d.', $this->filename, $this->lineno), E_USER_DEPRECATED);
303 }
304
305 if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
306 throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block.', $tag), $this->lineno, $this->source);
307 }
308
309 $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
310 $this->moveCursor($text.$match[0][0]);
311
312 if (false !== strpos($match[1][0], $this->options['whitespace_trim'])) {
313 $text = rtrim($text);
314 }
315
317 }
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

References $tag, $text, moveCursor(), pushToken(), and Twig_Token\TEXT_TYPE.

Referenced by lexData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexString()

Twig_Lexer::lexString ( )
protected

Definition at line 328 of file Lexer.php.

329 {
330 if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
331 $this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
333 $this->moveCursor($match[0]);
334 $this->pushState(self::STATE_INTERPOLATION);
335 } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
336 $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
337 $this->moveCursor($match[0]);
338 } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
339 list($expect, $lineno) = array_pop($this->brackets);
340 if ('"' != $this->code[$this->cursor]) {
341 throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
342 }
343
344 $this->popState();
346 } else {
347 // unlexable
348 throw new Twig_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
349 }
350 }
const INTERPOLATION_START_TYPE
Definition: Token.php:37

References $cursor, $lineno, Twig_Token\INTERPOLATION_START_TYPE, moveCursor(), popState(), pushState(), pushToken(), and Twig_Token\STRING_TYPE.

Referenced by tokenize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lexVar()

Twig_Lexer::lexVar ( )
protected

Definition at line 220 of file Lexer.php.

221 {
222 if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) {
224 $this->moveCursor($match[0]);
225 $this->popState();
226 } else {
227 $this->lexExpression();
228 }
229 }
const VAR_END_TYPE
Definition: Token.php:31

References lexExpression(), moveCursor(), popState(), pushToken(), and Twig_Token\VAR_END_TYPE.

Referenced by tokenize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveCursor()

Twig_Lexer::moveCursor (   $text)
protected

Definition at line 375 of file Lexer.php.

376 {
377 $this->cursor += strlen($text);
378 $this->lineno += substr_count($text, "\n");
379 }

References $text.

Referenced by lexBlock(), lexComment(), lexData(), lexExpression(), lexInterpolation(), lexRawData(), lexString(), and lexVar().

+ Here is the caller graph for this function:

◆ popState()

Twig_Lexer::popState ( )
protected

Definition at line 417 of file Lexer.php.

418 {
419 if (0 === count($this->states)) {
420 throw new Exception('Cannot pop state without a previous state.');
421 }
422
423 $this->state = array_pop($this->states);
424 }

Referenced by lexBlock(), lexInterpolation(), lexString(), and lexVar().

+ Here is the caller graph for this function:

◆ pushState()

Twig_Lexer::pushState (   $state)
protected

Definition at line 411 of file Lexer.php.

412 {
413 $this->states[] = $this->state;
414 $this->state = $state;
415 }

References $state.

Referenced by lexData(), lexExpression(), and lexString().

+ Here is the caller graph for this function:

◆ pushToken()

Twig_Lexer::pushToken (   $type,
  $value = '' 
)
protected

Definition at line 365 of file Lexer.php.

366 {
367 // do not push empty text tokens
368 if (Twig_Token::TEXT_TYPE === $type && '' === $value) {
369 return;
370 }
371
372 $this->tokens[] = new Twig_Token($type, $value, $this->lineno);
373 }
Represents a Token.
Definition: Token.php:21
$type

References $type, and Twig_Token\TEXT_TYPE.

Referenced by lexBlock(), lexData(), lexExpression(), lexInterpolation(), lexRawData(), lexString(), lexVar(), and tokenize().

+ Here is the caller graph for this function:

◆ tokenize()

Twig_Lexer::tokenize (   $code,
  $name = null 
)

Tokenizes a source code.

Parameters
string | Twig_Source$codeThe source code
string$nameA unique identifier for the source code
Returns
Twig_TokenStream
Exceptions
Twig_Error_SyntaxWhen the code is syntactically wrong

Implements Twig_LexerInterface.

Definition at line 78 of file Lexer.php.

79 {
80 if (!$code instanceof Twig_Source) {
81 @trigger_error(sprintf('Passing a string as the $code argument of %s() is deprecated since version 1.27 and will be removed in 2.0. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
82 $this->source = new Twig_Source($code, $name);
83 } else {
84 $this->source = $code;
85 }
86
87 if (((int) ini_get('mbstring.func_overload')) & 2) {
88 @trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED);
89 }
90
91 if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
92 $mbEncoding = mb_internal_encoding();
93 mb_internal_encoding('ASCII');
94 } else {
95 $mbEncoding = null;
96 }
97
98 $this->code = str_replace(array("\r\n", "\r"), "\n", $this->source->getCode());
99 $this->filename = $this->source->getName();
100 $this->cursor = 0;
101 $this->lineno = 1;
102 $this->end = strlen($this->code);
103 $this->tokens = array();
104 $this->state = self::STATE_DATA;
105 $this->states = array();
106 $this->brackets = array();
107 $this->position = -1;
108
109 // find all token starts in one go
110 preg_match_all($this->regexes['lex_tokens_start'], $this->code, $matches, PREG_OFFSET_CAPTURE);
111 $this->positions = $matches;
112
113 while ($this->cursor < $this->end) {
114 // dispatch to the lexing functions depending
115 // on the current state
116 switch ($this->state) {
117 case self::STATE_DATA:
118 $this->lexData();
119 break;
120
122 $this->lexBlock();
123 break;
124
125 case self::STATE_VAR:
126 $this->lexVar();
127 break;
128
130 $this->lexString();
131 break;
132
134 $this->lexInterpolation();
135 break;
136 }
137 }
138
140
141 if (!empty($this->brackets)) {
142 list($expect, $lineno) = array_pop($this->brackets);
143 throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
144 }
145
146 if ($mbEncoding) {
147 mb_internal_encoding($mbEncoding);
148 }
149
150 return new Twig_TokenStream($this->tokens, $this->source);
151 }
const STATE_INTERPOLATION
Definition: Lexer.php:43
const STATE_BLOCK
Definition: Lexer.php:40
lexInterpolation()
Definition: Lexer.php:352
const STATE_STRING
Definition: Lexer.php:42
const STATE_DATA
Definition: Lexer.php:39
lexData()
Definition: Lexer.php:153
lexString()
Definition: Lexer.php:328
const STATE_VAR
Definition: Lexer.php:41
lexBlock()
Definition: Lexer.php:209
lexVar()
Definition: Lexer.php:220
Holds information about a non-compiled Twig template.
Definition: Source.php:20
Represents a token stream.
Definition: TokenStream.php:21
const EOF_TYPE
Definition: Token.php:26

References $code, $lineno, $name, Twig_Token\EOF_TYPE, lexBlock(), lexData(), lexInterpolation(), lexString(), lexVar(), pushToken(), STATE_BLOCK, STATE_DATA, STATE_INTERPOLATION, STATE_STRING, and STATE_VAR.

+ Here is the call graph for this function:

Field Documentation

◆ $brackets

Twig_Lexer::$brackets
protected

Definition at line 27 of file Lexer.php.

◆ $code

Twig_Lexer::$code
protected

Definition at line 21 of file Lexer.php.

Referenced by tokenize().

◆ $currentVarBlockLine

Twig_Lexer::$currentVarBlockLine
protected

Definition at line 35 of file Lexer.php.

◆ $cursor

Twig_Lexer::$cursor
protected

Definition at line 22 of file Lexer.php.

Referenced by lexExpression(), and lexString().

◆ $end

Twig_Lexer::$end
protected

Definition at line 24 of file Lexer.php.

Referenced by lexData().

◆ $env

Twig_Lexer::$env
protected

Definition at line 28 of file Lexer.php.

Referenced by __construct().

◆ $filename

Twig_Lexer::$filename
protected

Definition at line 30 of file Lexer.php.

◆ $lineno

Twig_Lexer::$lineno
protected

Definition at line 23 of file Lexer.php.

Referenced by lexData(), lexExpression(), lexString(), and tokenize().

◆ $options

Twig_Lexer::$options
protected

Definition at line 31 of file Lexer.php.

Referenced by __construct().

◆ $position

Twig_Lexer::$position
protected

Definition at line 33 of file Lexer.php.

Referenced by lexData().

◆ $positions

Twig_Lexer::$positions
protected

Definition at line 34 of file Lexer.php.

◆ $regexes

Twig_Lexer::$regexes
protected

Definition at line 32 of file Lexer.php.

◆ $source

Twig_Lexer::$source
private

Definition at line 37 of file Lexer.php.

◆ $state

Twig_Lexer::$state
protected

Definition at line 25 of file Lexer.php.

Referenced by pushState().

◆ $states

Twig_Lexer::$states
protected

Definition at line 26 of file Lexer.php.

◆ $tokens

Twig_Lexer::$tokens
protected

Definition at line 20 of file Lexer.php.

◆ PUNCTUATION

const Twig_Lexer::PUNCTUATION = '()[]{}?:.,|'

Definition at line 50 of file Lexer.php.

◆ REGEX_DQ_STRING_DELIM

const Twig_Lexer::REGEX_DQ_STRING_DELIM = '/"/A'

Definition at line 48 of file Lexer.php.

◆ REGEX_DQ_STRING_PART

const Twig_Lexer::REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'

Definition at line 49 of file Lexer.php.

◆ REGEX_NAME

const Twig_Lexer::REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'

◆ REGEX_NUMBER

const Twig_Lexer::REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'

Definition at line 46 of file Lexer.php.

◆ REGEX_STRING

const Twig_Lexer::REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'

Definition at line 47 of file Lexer.php.

◆ STATE_BLOCK

const Twig_Lexer::STATE_BLOCK = 1

Definition at line 40 of file Lexer.php.

Referenced by tokenize().

◆ STATE_DATA

const Twig_Lexer::STATE_DATA = 0

Definition at line 39 of file Lexer.php.

Referenced by tokenize().

◆ STATE_INTERPOLATION

const Twig_Lexer::STATE_INTERPOLATION = 4

Definition at line 43 of file Lexer.php.

Referenced by tokenize().

◆ STATE_STRING

const Twig_Lexer::STATE_STRING = 3

Definition at line 42 of file Lexer.php.

Referenced by tokenize().

◆ STATE_VAR

const Twig_Lexer::STATE_VAR = 2

Definition at line 41 of file Lexer.php.

Referenced by tokenize().


The documentation for this class was generated from the following file: