本文整理汇总了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);
}