Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.1.7

Bug #10260 exception instead of helpful error message
Submitted: 2007-03-04 01:00 UTC Modified: 2007-03-04 12:52 UTC
From: cellog Assigned: cellog
Status: Closed Package: PHP_ParserGenerator (version 0.1.4)
PHP Version: Irrelevant OS: n/a
Roadmaps: (Not assigned)    
Subscription  


 [2007-03-04 01:00 UTC] cellog (Greg Beaver)
Description: ------------ The attached grammar should result in an error along the lines of "Unreducable grammar" but instead results in an exception because one of the actions (the unreducable one) is never processed. This is because the multi-terminal DOCBLOCK_NEWLINE|DOCBLOCK_WHITESPACE in ignored_whitespace is the same as DOCBLOCK_NEWLINE|DOCBLOCK_WHITESPACE|DOCBLOCK_TEXT in text. There is no way to determine whether the token belongs to: text or ignored_whitespace paragraphs without some kind of crazy lookahead action (slow and bad). Test script: --------------- %name PHP_DocblockParser %declare_class {class PHP_DocblockParser} %syntax_error { /* ?><?php */ echo "Syntax Error on line " . $this->lex->line . ": token '" . $this->lex->value . "' while parsing rule:"; foreach ($this->yystack as $entry) { echo $this->tokenName($entry->major) . ' '; } foreach ($this->yy_get_expected_tokens($yymajor) as $token) { $expect[] = self::$yyTokenName[$token]; } if (count($expect) > 5) { $expect = array_slice($expect, 0, 5); $expect[] = '...'; } throw new Exception('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN . '), expected one of: ' . implode(',', $expect)); } %parse_accept { } start ::= description(B). {A = array('desc' => B, 'tags' => array());} description(A) ::= text(B). {A = B;} description(A) ::= paragraphs(B). {A = B;} ignored_whitespace ::= DOCBLOCK_NEWLINE|DOCBLOCK_WHITESPACE. paragraphs(A) ::= ignored_whitespace paragraphs(B) paragraph(C). { A = B; A[] = C; } paragraph ::= DOCBLOCK_POPEN. text(A) ::= DOCBLOCK_NEWLINE|DOCBLOCK_WHITESPACE|DOCBLOCK_TEXT(B). {A = B;}

Comments

 [2007-03-04 12:52 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.