当前位置: 首页>>代码示例>>PHP>>正文


PHP Rule::isTransitional方法代码示例

本文整理汇总了PHP中Rule::isTransitional方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::isTransitional方法的具体用法?PHP Rule::isTransitional怎么用?PHP Rule::isTransitional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rule的用法示例。


在下文中一共展示了Rule::isTransitional方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _parse

 /**
  * Parse current rule.
  *
  * @param   \Hoa\Compiler\Llk\Rule  $zeRule    Current rule.
  * @param   int                     $next      Next rule index.
  * @return  bool
  */
 protected function _parse(Rule $zeRule, $next)
 {
     if ($zeRule instanceof Rule\Token) {
         $name = $this->getCurrentToken();
         if ($zeRule->getTokenName() !== $name) {
             return false;
         }
         $value = $this->getCurrentToken('value');
         if (0 <= ($unification = $zeRule->getUnificationIndex())) {
             for ($skip = 0, $i = count($this->_trace) - 1; $i >= 0; --$i) {
                 $trace = $this->_trace[$i];
                 if ($trace instanceof Rule\Entry) {
                     if (false === $trace->isTransitional()) {
                         if ($trace->getDepth() <= $this->_depth) {
                             break;
                         }
                         --$skip;
                     }
                 } elseif ($trace instanceof Rule\Ekzit && false === $trace->isTransitional()) {
                     $skip += $trace->getDepth() > $this->_depth;
                 }
                 if (0 < $skip) {
                     continue;
                 }
                 if ($trace instanceof Rule\Token && $unification === $trace->getUnificationIndex() && $value !== $trace->getValue()) {
                     return false;
                 }
             }
         }
         $namespace = $this->getCurrentToken('namespace');
         $zzeRule = clone $zeRule;
         $zzeRule->setValue($value);
         $zzeRule->setNamespace($namespace);
         if (isset($this->_tokens[$namespace][$name])) {
             $zzeRule->setRepresentation($this->_tokens[$namespace][$name]);
         } else {
             foreach ($this->_tokens[$namespace] as $_name => $regex) {
                 if (false === ($pos = strpos($_name, ':'))) {
                     continue;
                 }
                 $_name = substr($_name, 0, $pos);
                 if ($_name === $name) {
                     break;
                 }
             }
             $zzeRule->setRepresentation($regex);
         }
         array_pop($this->_todo);
         $this->_trace[] = $zzeRule;
         $this->_errorState = ++$this->_currentState;
         return true;
     } elseif ($zeRule instanceof Rule\Concatenation) {
         if (false === $zeRule->isTransitional()) {
             ++$this->_depth;
         }
         $this->_trace[] = new Rule\Entry($zeRule->getName(), 0, null, $this->_depth);
         $content = $zeRule->getContent();
         for ($i = count($content) - 1; $i >= 0; --$i) {
             $nextRule = $content[$i];
             $this->_todo[] = new Rule\Ekzit($nextRule, 0);
             $this->_todo[] = new Rule\Entry($nextRule, 0);
         }
         return true;
     } elseif ($zeRule instanceof Rule\Choice) {
         $content = $zeRule->getContent();
         if ($next >= count($content)) {
             return false;
         }
         if (false === $zeRule->isTransitional()) {
             ++$this->_depth;
         }
         $this->_trace[] = new Rule\Entry($zeRule->getName(), $next, $this->_todo, $this->_depth);
         $nextRule = $content[$next];
         $this->_todo[] = new Rule\Ekzit($nextRule, 0);
         $this->_todo[] = new Rule\Entry($nextRule, 0);
         return true;
     } elseif ($zeRule instanceof Rule\Repetition) {
         $nextRule = $zeRule->getContent();
         if (0 === $next) {
             $name = $zeRule->getName();
             $min = $zeRule->getMin();
             if (false === $zeRule->isTransitional()) {
                 ++$this->_depth;
             }
             $this->_trace[] = new Rule\Entry($name, $min, null, $this->_depth);
             array_pop($this->_todo);
             $this->_todo[] = new Rule\Ekzit($name, $min, $this->_todo);
             for ($i = 0; $i < $min; ++$i) {
                 $this->_todo[] = new Rule\Ekzit($nextRule, 0);
                 $this->_todo[] = new Rule\Entry($nextRule, 0);
             }
             return true;
         } else {
//.........这里部分代码省略.........
开发者ID:Bizkaitarra,项目名称:pintxobot,代码行数:101,代码来源:Parser.php


注:本文中的Rule::isTransitional方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。