本文整理匯總了PHP中Twig_Token::Operator方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Token::Operator方法的具體用法?PHP Twig_Token::Operator怎麽用?PHP Twig_Token::Operator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twig_Token
的用法示例。
在下文中一共展示了Twig_Token::Operator方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: lexExpression
private function lexExpression()
{
$match = NULL;
// skip whitespace
while (preg_match('/\\s+/A', $this->code, $match, NULL, $this->cursor)) {
$this->cursor += strlen($match[0]);
$this->lineno += substr_count($match[0], '\\n');
}
// sanity check
if ($this->cursor >= $this->end) {
throw new Twig_SyntaxError('unexpected end of stream', $this->lineno, $this->filename);
}
// first parse operators
if (preg_match(self::REGEX_OPERATOR, $this->code, $match, NULL, $this->cursor)) {
$this->cursor += strlen($match[0]);
return Twig_Token::Operator($match[0], $this->lineno);
}
// now names
if (preg_match(self::REGEX_NAME, $this->code, $match, NULL, $this->cursor)) {
$this->cursor += strlen($match[0]);
return Twig_Token::Name($match[0], $this->lineno);
} else {
if (preg_match(self::REGEX_NUMBER, $this->code, $match, NULL, $this->cursor)) {
$this->cursor += strlen($match[0]);
$value = (double) $match[0];
if ((int) $value === $value) {
$value = (int) $value;
}
return Twig_Token::Number($value, $this->lineno);
} else {
if (preg_match(self::REGEX_STRING, $this->code, $match, NULL, $this->cursor)) {
$this->cursor += strlen($match[0]);
$this->lineno += substr_count($match[0], '\\n');
$value = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2));
return Twig_Token::String($value, $this->lineno);
}
}
}
// unlexable
throw new Twig_SyntaxError("Unexpected character '" . $this->code[$this->cursor] . "'.", $this->lineno, $this->filename);
}