1: <?php
2:
3: 4: 5: 6: 7:
8:
9:
10:
11: 12: 13: 14: 15: 16:
17: class NMacroTokenizer extends NTokenizer
18: {
19: const T_WHITESPACE = 1,
20: = 2,
21: T_SYMBOL = 3,
22: T_NUMBER = 4,
23: T_VARIABLE = 5,
24: T_STRING = 6,
25: T_CAST = 7,
26: T_KEYWORD = 8,
27: T_CHAR = 9;
28:
29:
30: public function __construct($input)
31: {
32: parent::__construct(array(
33: self::T_WHITESPACE => '\s+',
34: self::T_COMMENT => '(?s)/\*.*?\*/',
35: self::T_STRING => NParser::RE_STRING,
36: self::T_KEYWORD => '(?:true|false|null|and|or|xor|clone|new|instanceof|return|continue|break|endif|endforeach|endwhile|endswitch|[A-Z_][A-Z0-9_]{2,})(?![\w\pL_])',
37: self::T_CAST => '\((?:expand|string|array|int|integer|float|bool|boolean|object)\)',
38: self::T_VARIABLE => '\$[\w\pL_]+',
39: self::T_NUMBER => '[+-]?[0-9]+(?:\.[0-9]+)?(?:e[0-9]+)?',
40: self::T_SYMBOL => '[\w\pL_]+(?:-[\w\pL_]+)*',
41: self::T_CHAR => '::|=>|->|\+\+|--|<<|>>|<=|>=|===|!==|==|!=|<>|&&|\|\||[^"\']',
42: ), 'u');
43: $this->ignored = array(self::T_COMMENT, self::T_WHITESPACE);
44: $this->tokenize($input);
45: }
46:
47:
48: 49: 50: 51: 52:
53: public function fetchWord()
54: {
55: $word = $this->fetchUntil(self::T_WHITESPACE, ',');
56: $this->fetch(',');
57: $this->fetchAll(self::T_WHITESPACE, self::T_COMMENT);
58: return $word;
59: }
60:
61: }
62: