Packages

  • 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

  • NHtmlNode
  • NLatteCompiler
  • NLatteFilter
  • NLatteToken
  • NMacroNode
  • NMacroTokenizer
  • NParser
  • NPhpWriter

Interfaces

  • IMacro

Exceptions

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