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:  * Macro tag tokenizer.
19:  *
20:  * @author     David Grudl
21:  */
22: class MacroTokenizer extends Nette\Utils\Tokenizer
23: {
24:     const T_WHITESPACE = 1,
25:         T_COMMENT = 2,
26:         T_SYMBOL = 3,
27:         T_NUMBER = 4,
28:         T_VARIABLE = 5,
29:         T_STRING = 6,
30:         T_CAST = 7,
31:         T_KEYWORD = 8,
32:         T_CHAR = 9;
33: 
34: 
35:     public function __construct($input)
36:     {
37:         parent::__construct(array(
38:             self::T_WHITESPACE => '\s+',
39:             self::T_COMMENT => '(?s)/\*.*?\*/',
40:             self::T_STRING => Parser::RE_STRING,
41:             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
42:             self::T_CAST => '\((?:expand|string|array|int|integer|float|bool|boolean|object)\)', // type casting
43:             self::T_VARIABLE => '\$[\w\pL_]+',
44:             self::T_NUMBER => '[+-]?[0-9]+(?:\.[0-9]+)?(?:e[0-9]+)?',
45:             self::T_SYMBOL => '[\w\pL_]+(?:-[\w\pL_]+)*',
46:             self::T_CHAR => '::|=>|[^"\']', // =>, any char except quotes
47:         ), 'u');
48:         $this->ignored = array(self::T_COMMENT, self::T_WHITESPACE);
49:         $this->tokenize($input);
50:     }
51: 
52: 
53:     /**
54:      * Reads single token (optionally delimited by comma) from string.
55:      * @param  string
56:      * @return string
57:      */
58:     public function fetchWord()
59:     {
60:         $word = $this->fetchUntil(self::T_WHITESPACE, ',');
61:         $this->fetch(',');
62:         $this->fetchAll(self::T_WHITESPACE, self::T_COMMENT);
63:         return $word;
64:     }
65: 
66: }
67: 
Nette Framework 2.0.11 API API documentation generated by ApiGen 2.8.0