English 中文(简体)
PHP没有错误而失败。
原标题:PHP fails with no error

我正在构建一个模板解析器。

模板解析器的工作方式如下:

  • Tokenize (make for each part of the template code a token)
  • Parse
    • Use my ParserHelper class. You can add rules for this system, and then it checks the token list for a valid grammar.
    • Add / change some tokens for extra functionality
  • Compile (translate to php (for fast transforming to html))

解析器助手是具有以下结构的类:

  • protected function parseRecursive(&$offset, $ruleName)
  • protected function tryOption(&$offset, vdParserHelperRuleOption& $option)
  • protected function tryItem(&$offset, vdParserHelperRuleOptionItem& $item, $count)

偏移量代表标记的偏移量(因此,`offset=0`表示要解析的第一个标记等)。

我的解析器帮助规则具有这种结构:

  • Rule
    • Options
      • Items

对于了解上下文无关文法的人:

规则-> < 备选办法1 > ́lt; 备选办法2; 备选办法2; 备选办法...... N >

使用OptionX时,labda是空选项或者一个列表:

  • a rule link (a link to an other rule (can be recursion)) or
  • a token

因此,传讯、审判和审判职能可以称为教职员工。

错误出现在函数 tryItem 中:

...
// Try item
if($item->getType()==vdParserHelperRuleOptionItem::RuleLink){
    ///// The next line !!!!!!!!!!!!!
    if(!$this->parseRecursive($currentOffset, $item->getData())){
    ///// The previous line !!!!!!!!!

        return $item->isOptional();
    }
}else if($item->getType()==vdParserHelperRuleOptionItem::Type){
    ...
}
...

当我删除(替换为if(true){或类似内容)评论之间的这一行时,php代码将被执行。 但是当我不删除该行时,php不执行我的代码并且不输出任何内容,我根本没有错误。 当我查看apache日志文件时,我会收到此错误:

[notice] child pid 11957 exit signal Segmentation fault (11)

这是 PHP 的一个错误,还是 PHP 不能处理间接递归?还是其他原因?

问题回答

我相信这是您清理发布代码时疏忽,但您有一个没有关闭的额外 {。





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签