cvs: pear /PHP_ParserGenerator package.xml /PHP_ParserGenerator/ParserGenerator Action.php Data.php
| From: | Greg Beaver | Date: | Sun, 04 Mar 2007 17:52:05 +0000 |
| Subject: | cvs: pear /PHP_ParserGenerator package.xml /PHP_ParserGenerator/ParserGenerator Action.php Data.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44944@lists.php.net to get a copy of this message | ||
cellog Sun Mar 4 17:52:05 2007 UTC
Modified files:
/pear/PHP_ParserGenerator/ParserGenerator Action.php Data.php
/pear/PHP_ParserGenerator package.xml
Log:
- fix Bug #10260: exception instead of helpful error message
add helpful output for debugging
http://cvs.php.net/viewvc.cgi/pear/PHP_ParserGenerator/ParserGenerator/Action.php?r1=1.1&r2=1.2&diff_format=u
Index: pear/PHP_ParserGenerator/ParserGenerator/Action.php
diff -u pear/PHP_ParserGenerator/ParserGenerator/Action.php:1.1
pear/PHP_ParserGenerator/ParserGenerator/Action.php:1.2
--- pear/PHP_ParserGenerator/ParserGenerator/Action.php:1.1 Tue Jul 18 00:53:10 2006
+++ pear/PHP_ParserGenerator/ParserGenerator/Action.php Sun Mar 4 17:52:05 2007
@@ -42,7 +42,7 @@
* @author Gregory Beaver <cellog@php.net>
* @copyright 2006 Gregory Beaver
* @license http://www.opensource.org/licenses/bsd-license.php
New BSD License
- * @version CVS: $Id: Action.php,v 1.1 2006/07/18 00:53:10 cellog Exp $
+ * @version CVS: $Id: Action.php,v 1.2 2007/03/04 17:52:05 cellog Exp $
* @since File available since Release 0.1.0
*/
/**
@@ -122,30 +122,61 @@
$rc = $ap1->type - $ap2->type;
}
if ($rc === 0) {
+ if ($ap1->type == self::SHIFT) {
+ if ($ap1->x->statenum != $ap2->x->statenum) {
+ throw new Exception('Shift conflict: ' . $ap1->sp->name .
+ ' shifts both to state ' . $ap1->x->statenum . ' (rule
' .
+ $ap1->x->cfp->rp->lhs->name . ' on line ' .
+ $ap1->x->cfp->rp->ruleline . ') and to state ' .
+ $ap2->x->statenum . ' (rule ' .
+ $ap2->x->cfp->rp->lhs->name . ' on line ' .
+ $ap2->x->cfp->rp->ruleline . ')');
+ }
+ }
if ($ap1->type != self::REDUCE &&
$ap1->type != self::RD_RESOLVED &&
$ap1->type != self::CONFLICT) {
throw new Exception('action has not been processed: ' .
- $ap1->sp->name);
+ $ap1->sp->name . ' on line ' .
$ap1->x->cfp->rp->ruleline .
+ ', rule ' . $ap1->x->cfp->rp->lhs->name);
}
if ($ap2->type != self::REDUCE &&
$ap2->type != self::RD_RESOLVED &&
$ap2->type != self::CONFLICT) {
throw new Exception('action has not been processed: ' .
- $ap2->sp->name);
+ $ap2->sp->name . ' on line ' .
$ap2->x->cfp->rp->ruleline .
+ ', rule ' . $ap2->x->cfp->rp->lhs->name);
}
$rc = $ap1->x->index - $ap2->x->index;
}
return $rc;
}
+ function display($processed = false)
+ {
+ $map = array(
+ self::ACCEPT => 'ACCEPT',
+ self::CONFLICT => 'CONFLICT',
+ self::REDUCE => 'REDUCE',
+ self::SHIFT => 'SHIFT'
+ );
+ echo $map[$this->type] . ' for ' . $this->sp->name;
+ if ($this->type == self::REDUCE) {
+ echo ' - rule ' . $this->x->lhs->name . "\n";
+ } elseif ($this->type == self::SHIFT) {
+ echo ' - state ' . $this->x->statenum . ', basis ' .
$this->x->cfp->rp->lhs->name . "\n";
+ } else {
+ echo "\n";
+ }
+ }
+
/**
* create linked list of PHP_ParserGenerator_Actions
*
* @param PHP_ParserGenerator_Action|null
* @param int one of the class constants from PHP_ParserGenerator_Action
* @param PHP_ParserGenerator_Symbol
- * @param PHP_ParserGenerator_Symbol|PHP_ParserGenerator_Rule
+ * @param PHP_ParserGenerator_State|PHP_ParserGenerator_Rule
*/
static function Action_add(&$app, $type, PHP_ParserGenerator_Symbol $sp, $arg)
{
@@ -155,6 +186,8 @@
$new->type = $type;
$new->sp = $sp;
$new->x = $arg;
+ echo ' Adding ';
+ $new->display();
}
/**
@@ -174,6 +207,9 @@
*/
function PrintAction($fp, $indent)
{
+ if (!$fp) {
+ $fp = STDOUT;
+ }
$result = 1;
switch ($this->type)
{
http://cvs.php.net/viewvc.cgi/pear/PHP_ParserGenerator/ParserGenerator/Data.php?r1=1.1&r2=1.2&diff_format=u
Index: pear/PHP_ParserGenerator/ParserGenerator/Data.php
diff -u pear/PHP_ParserGenerator/ParserGenerator/Data.php:1.1
pear/PHP_ParserGenerator/ParserGenerator/Data.php:1.2
--- pear/PHP_ParserGenerator/ParserGenerator/Data.php:1.1 Tue Jul 18 00:53:10 2006
+++ pear/PHP_ParserGenerator/ParserGenerator/Data.php Sun Mar 4 17:52:05 2007
@@ -42,7 +42,7 @@
* @author Gregory Beaver <cellog@php.net>
* @copyright 2006 Gregory Beaver
* @license http://www.opensource.org/licenses/bsd-license.php
New BSD License
- * @version CVS: $Id: Data.php,v 1.1 2006/07/18 00:53:10 cellog Exp $
+ * @version CVS: $Id: Data.php,v 1.2 2007/03/04 17:52:05 cellog Exp $
* @since File available since Release 0.1.0
*/
/**
@@ -668,6 +668,11 @@
if (!$stp->ap) {
throw new Exception('state has no actions associated');
}
+ echo 'processing state ' . $stp->statenum . " actions:\n";
+ for ($ap = $stp->ap; $ap !== 0 && $ap->next !== 0; $ap = $ap->next) {
+ echo ' Action ';
+ $ap->display(true);
+ }
$stp->ap = PHP_ParserGenerator_Action::Action_sort($stp->ap);
for ($ap = $stp->ap; $ap !== 0 && $ap->next !== 0; $ap = $ap->next) {
for ($nap = $ap->next; $nap !== 0 && $nap->sp === $ap->sp ; $nap =
$nap->next) {
http://cvs.php.net/viewvc.cgi/pear/PHP_ParserGenerator/package.xml?r1=1.7&r2=1.8&diff_format=u
Index: pear/PHP_ParserGenerator/package.xml
diff -u pear/PHP_ParserGenerator/package.xml:1.7 pear/PHP_ParserGenerator/package.xml:1.8
--- pear/PHP_ParserGenerator/package.xml:1.7 Fri Mar 2 16:36:24 2007
+++ pear/PHP_ParserGenerator/package.xml Sun Mar 4 17:52:05 2007
@@ -42,6 +42,7 @@
<license uri="http://www.opensource.org/licenses/bsd-license.php">New
BSD License</license>
<notes>
- fix Bug #10245: if multiple RHS identifiers are the same, no error
+ - fix Bug #10260: exception instead of helpful error message
</notes>
<contents>
<dir baseinstalldir="PHP" name="/">