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
 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 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: 
35:     public function __construct($input)
36:     {
37:         parent::__construct(array(
38:             self::T_WHITESPACE => '\s+',
39:             self::T_COMMENT => '(?s)/\*.*?\*/',
40:             self::T_STRING => NParser::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:     /**
55:      * Reads single token (optionally delimited by comma) from string.
56:      * @param  string
57:      * @return string
58:      */
59:     public function fetchWord()
60:     {
61:         $word = $this->fetchUntil(self::T_WHITESPACE, ',');
62:         $this->fetch(',');
63:         $this->fetchAll(self::T_WHITESPACE, self::T_COMMENT);
64:         return $word;
65:     }
66: 
67: }
68: 
Nette Framework 2.0.1 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.7.0