Source
xxxxxxxxxx
private static function parseConstant(string $source, int &$pos, array &$tokens, array $options, int $depth): bool {
<?php declare(strict_types = 1);
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class CExpressionParser extends CParser {
// For parsing of expressions.
private const STATE_AFTER_OPEN_BRACE = 1;
private const STATE_AFTER_BINARY_OPERATOR = 2;
private const STATE_AFTER_LOGICAL_OPERATOR = 3;
private const STATE_AFTER_NOT_OPERATOR = 4;
private const STATE_AFTER_UNARY_MINUS = 5;
private const STATE_AFTER_CLOSE_BRACE = 6;
private const STATE_AFTER_CONSTANT = 7;
// For parsing of math function parameters.
private const STATE_NEW = 1;
private const STATE_END = 2;
private const STATE_END_OF_PARAMS = 3;
private const MAX_MATH_FUNCTION_DEPTH = 32;
/**
* An error message if trigger expression is not valid
*
* @var string
*/
private $error = '';
/**
* An options array.
*
* Supported options:
* 'usermacros' => false Enable user macros usage in expression.
* 'lldmacros' => false Enable low-level discovery macros usage in expression.
* 'collapsed_expression' => false Short trigger expression.
* For example: {439} > {$MAX_THRESHOLD} or {439} < {$MIN_THRESHOLD}
* 'calculated' => false Parse calculated item formula instead of trigger expression.
* 'host_macro' => false Allow {HOST.HOST} macro as host name part in the query.
* 'host_macro_n' => false Allow {HOST.HOST} and {HOST.HOST<1-9>} macros as host name part in the query.
* 'empty_host' => false Allow empty hostname in the query string.
*
* @var array
*/
private $options = [
'usermacros' => false,