Version 1
[yaffs-website] / vendor / symfony / expression-language / Resources / bin / generate_operator_regex.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 $operators = array('not', '!', 'or', '||', '&&', 'and', '|', '^', '&', '==', '===', '!=', '!==', '<', '>', '>=', '<=', 'not in', 'in', '..', '+', '-', '~', '*', '/', '%', 'matches', '**');
13 $operators = array_combine($operators, array_map('strlen', $operators));
14 arsort($operators);
15
16 $regex = array();
17 foreach ($operators as $operator => $length) {
18     // an operator that ends with a character must be followed by
19     // a whitespace or a parenthesis
20     $regex[] = preg_quote($operator, '/').(ctype_alpha($operator[$length - 1]) ? '(?=[\s(])' : '');
21 }
22
23 echo '/'.implode('|', $regex).'/A';