我讀檸檬解析器的PHP portation:檸檬解析器LALR(1)還是SLR(1)?
for ($i = 0; $i < $this->nstate; $i++) { /* Loop over all states */
$stp = $this->sorted[$i]->data;
for ($cfp = $stp->cfp; $cfp; $cfp = $cfp->next) {
/* Loop over all configurations */
if ($cfp->rp->nrhs == $cfp->dot) { /* Is dot at extreme right? */
for ($j = 0; $j < $this->nterminal; $j++) {
if (isset($cfp->fws[$j])) {
/* Add a reduce action to the state "stp" which will reduce by the
** rule "cfp->rp" if the lookahead symbol is "$this->symbols[j]" */
PHP_ParserGenerator_Action::Action_add($stp->ap, PHP_ParserGenerator_Action::REDUCE,
$this->symbols[$j], $cfp->rp);
}
}
}
}
}
在我看來,解析器是根據它如何計算動作表SLR(1)語法分析器,但檸檬@the主頁它表現爲LALR(1)解析器本身:
http://www.hwaci.com/sw/lemon/
它是SLR(1)還是LALR(1)?
@yoyo:你說得對,我修改我的答案。 – 2011-02-17 16:14:21