Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • Compiler
  • Engine
  • HtmlNode
  • MacroNode
  • MacroTokenizer
  • Parser
  • PhpWriter
  • Token

Interfaces

  • IMacro

Exceptions

  • CompileException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  */
11: 
12: namespace Nette\Latte;
13: 
14: use Nette;
15: 
16: 
17: 
18: /**
19:  * Macro tag tokenizer.
20:  *
21:  * @author     David Grudl
22:  */
23: class MacroTokenizer extends Nette\Utils\Tokenizer
24: {
25:     const T_WHITESPACE = 1,
26:         T_COMMENT = 2,
27:         T_SYMBOL = 3,
28:         T_NUMBER = 4,
29:         T_VARIABLE = 5,
30:         T_STRING = 6,
31:         T_CAST = 7,
32:         T_KEYWORD = 8,
33:         T_CHAR = 9;
34: 
35: 
36: 
37:     public function __construct($input)
38:     {
39:         parent::__construct(array(
40:             self::T_WHITESPACE => '\s+',
41:             self::T_COMMENT => '(?s)/\*.*?\*/',
42:             self::T_STRING => Parser::RE_STRING,
43:             self::T_KEYWORD => '(?:true|false|null|and|or|xor|clone|new|instanceof|return|continue|break|[A-Z_][A-Z0-9_]{2,})(?![\w\pL_])', // keyword or const
44:             self::T_CAST => '\((?:expand|string|array|int|integer|float|bool|boolean|object)\)', // type casting
45:             self::T_VARIABLE => '\$[\w\pL_]+',
46:             self::T_NUMBER => '[+-]?[0-9]+(?:\.[0-9]+)?(?:e[0-9]+)?',
47:             self::T_SYMBOL => '[\w\pL_]+(?:-[\w\pL_]+)*',
48:             self::T_CHAR => '::|=>|[^"\']', // =>, any char except quotes
49:         ), 'u');
50:         $this->ignored = array(self::T_COMMENT, self::T_WHITESPACE);
51:         $this->tokenize($input);
52:     }
53: 
54: 
55: 
56:     /**
57:      * Reads single token (optionally delimited by comma) from string.
58:      * @param  string
59:      * @return string
60:      */
61:     public function fetchWord()
62:     {
63:         $word = $this->fetchUntil(self::T_WHITESPACE, ',');
64:         $this->fetch(',');
65:         $this->fetchAll(self::T_WHITESPACE, self::T_COMMENT);
66:         return $word;
67:     }
68: 
69: }
70: 
Nette Framework 2.0.7 API API documentation generated by ApiGen 2.8.0