cvs: pear /PHP_Parser/Parser/DocBlock Default.jay Default.php DefaultLexer.lex DefaultLexer.php /PHP_Parser/tests
PHP_Parser_DocBlock_DefaultLexer_test.php PHP_Parser_DocBlock_Default_basic_test.php

From: Date: Sat, 17 Apr 2004 18:29:36 +0000
Subject: cvs: pear /PHP_Parser/Parser/DocBlock Default.jay Default.php DefaultLexer.lex DefaultLexer.php /PHP_Parser/tests
PHP_Parser_DocBlock_DefaultLexer_test.php PHP_Parser_DocBlock_Default_basic_test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-18353@lists.php.net to get a copy of this message
cellog Sat Apr 17 14:29:36 2004 EDT Modified files: /pear/PHP_Parser/Parser/DocBlock Default.jay Default.php DefaultLexer.lex DefaultLexer.php /pear/PHP_Parser/tests PHP_Parser_DocBlock_DefaultLexer_test.php PHP_Parser_DocBlock_Default_basic_test.php Log: fix simplelist with non-text at start - <b>text</b> - <<code>> etc.

http://cvs.php.net/diff.php/pear/PHP_Parser/Parser/DocBlock/Default.jay?r1=1.14&r2=1.15&ty=u Index: pear/PHP_Parser/Parser/DocBlock/Default.jay diff -u pear/PHP_Parser/Parser/DocBlock/Default.jay:1.14 pear/PHP_Parser/Parser/DocBlock/Default.jay:1.15 --- pear/PHP_Parser/Parser/DocBlock/Default.jay:1.14 Sat Apr 17 13:53:16 2004 +++ pear/PHP_Parser/Parser/DocBlock/Default.jay Sat Apr 17 14:29:35 2004 @@ -17,7 +17,7 @@ // | Authors: Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Default.jay,v 1.14 2004/04/17 17:53:16 cellog Exp $ +// $Id: Default.jay,v 1.15 2004/04/17 18:29:35 cellog Exp $ // define('PHP_PARSER_DOCBLOCK_DEFAULT_ERROR_PARSE', 1); require_once 'PHP/Parser/MsgServer.php'; @@ -642,7 +642,7 @@ } | T_ESCAPED_TAG { - $$ = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $1); + $$ = str_replace(array('<<', '>>'), array('<', '>'), $1); } | T_INLINE_ESC { @@ -693,9 +693,9 @@ $$ = $1; $index = count($$) - 1; if (is_string($$[$index])) { - $$[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $2); } else { - $$[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[] = str_replace(array('<<', '>>'), array('<', '>'), $2); } } | text_expr_with_p T_INLINE_ESC @@ -749,7 +749,7 @@ } | T_ESCAPED_TAG { - $$ = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $1); + $$ = str_replace(array('<<', '>>'), array('<', '>'), $1); } | T_CLOSE_P { @@ -795,9 +795,9 @@ $$ = $1; $index = count($$) - 1; if (is_string($$[$index])) { - $$[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $2); } else { - $$[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[] = str_replace(array('<<', '>>'), array('<', '>'), $2); } } | paragraph T_OPEN_P @@ -1243,7 +1243,7 @@ } | T_ESCAPED_TAG { - $$ = array(str_replace(array('<<', '>>', '/'), array('<', '>', ''), $1)); + $$ = array(str_replace(array('<<', '>>'), array('<', '>'), $1)); } | inlinetag { @@ -1271,10 +1271,11 @@ | simplelist_line T_ESCAPED_TAG { $$ = $1; + $index = count($$) - 1; if (is_string($$[$index])) { - $$[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $2); } else { - $$[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[] = str_replace(array('<<', '>>'), array('<', '>'), $2); } } | simplelist_line inlinetag @@ -1321,7 +1322,7 @@ } | T_ESCAPED_TAG { - $$ = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $1); + $$ = str_replace(array('<<', '>>'), array('<', '>'), $1); } | inlinetag { @@ -1351,9 +1352,9 @@ $$ = $1; $index = count($$) - 1; if (is_string($$[$index])) { - $$[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $2); } else { - $$[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $2); + $$[] = str_replace(array('<<', '>>'), array('<', '>'), $2); } } | simplelist_line_with_p inlinetag http://cvs.php.net/diff.php/pear/PHP_Parser/Parser/DocBlock/Default.php?r1=1.12&r2=1.13&ty=u Index: pear/PHP_Parser/Parser/DocBlock/Default.php diff -u pear/PHP_Parser/Parser/DocBlock/Default.php:1.12 pear/PHP_Parser/Parser/DocBlock/Default.php:1.13 --- pear/PHP_Parser/Parser/DocBlock/Default.php:1.12 Sat Apr 17 13:53:16 2004 +++ pear/PHP_Parser/Parser/DocBlock/Default.php Sat Apr 17 14:29:35 2004 @@ -33,7 +33,7 @@ // | Authors: Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Default.php,v 1.12 2004/04/17 17:53:16 cellog Exp $ +// $Id: Default.php,v 1.13 2004/04/17 18:29:35 cellog Exp $ // define('PHP_PARSER_DOCBLOCK_DEFAULT_ERROR_PARSE', 1); require_once 'PHP/Parser/MsgServer.php'; @@ -873,7 +873,7 @@ function _22($yyTop) // line 644 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { - $this->yyVal = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } function _23($yyTop) // line 648 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" @@ -932,9 +932,9 @@ $this->yyVal = $this->yyVals[-1+$yyTop]; $index = count($this->yyVal) - 1; if (is_string($this->yyVal[$index])) { - $this->yyVal[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } else { - $this->yyVal[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[] = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } } @@ -993,7 +993,7 @@ function _38($yyTop) // line 751 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { - $this->yyVal = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } function _39($yyTop) // line 755 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" @@ -1046,9 +1046,9 @@ $this->yyVal = $this->yyVals[-1+$yyTop]; $index = count($this->yyVal) - 1; if (is_string($this->yyVal[$index])) { - $this->yyVal[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } else { - $this->yyVal[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[] = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } } @@ -1444,7 +1444,7 @@ function _114($yyTop) // line 1245 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { - $this->yyVal = array(str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop])); + $this->yyVal = array(str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop])); } function _115($yyTop) // line 1249 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" @@ -1477,20 +1477,21 @@ function _119($yyTop) // line 1272 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; + $index = count($this->yyVal) - 1; if (is_string($this->yyVal[$index])) { - $this->yyVal[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } else { - $this->yyVal[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[] = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } } - function _120($yyTop) // line 1281 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _120($yyTop) // line 1282 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = $this->yyVals[0+$yyTop]; } - function _121($yyTop) // line 1286 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _121($yyTop) // line 1287 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { if ($this->yyVals[0+$yyTop] == '{@}') { $t = array('{@'); @@ -1507,39 +1508,39 @@ } } - function _122($yyTop) // line 1302 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _122($yyTop) // line 1303 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = $this->yyVals[0+$yyTop]; } - function _123($yyTop) // line 1307 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _123($yyTop) // line 1308 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = "\n\n"; } - function _124($yyTop) // line 1315 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _124($yyTop) // line 1316 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = array($this->yyVals[0+$yyTop]); } - function _125($yyTop) // line 1319 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _125($yyTop) // line 1320 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = array("\n\n"); } - function _126($yyTop) // line 1323 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _126($yyTop) // line 1324 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { - $this->yyVal = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } - function _127($yyTop) // line 1327 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _127($yyTop) // line 1328 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = array($this->yyVals[0+$yyTop]); } - function _128($yyTop) // line 1331 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _128($yyTop) // line 1332 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { if ($this->yyVals[0+$yyTop] == '{@}') { $this->yyVal = array('{@'); @@ -1550,35 +1551,35 @@ } } - function _129($yyTop) // line 1341 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _129($yyTop) // line 1342 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = array($this->yyVals[0+$yyTop]); } - function _130($yyTop) // line 1345 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _130($yyTop) // line 1346 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = $this->yyVals[0+$yyTop]; } - function _131($yyTop) // line 1350 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _131($yyTop) // line 1351 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $index = count($this->yyVal) - 1; if (is_string($this->yyVal[$index])) { - $this->yyVal[$index] .= str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[$index] .= str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } else { - $this->yyVal[] = str_replace(array('<<', '>>', '/'), array('<', '>', ''), $this->yyVals[0+$yyTop]); + $this->yyVal[] = str_replace(array('<<', '>>'), array('<', '>'), $this->yyVals[0+$yyTop]); } } - function _132($yyTop) // line 1360 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _132($yyTop) // line 1361 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = $this->yyVals[0+$yyTop]; } - function _133($yyTop) // line 1365 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _133($yyTop) // line 1366 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { if ($this->yyVals[0+$yyTop] == '{@}') { $t = array('{@'); @@ -1596,29 +1597,29 @@ } } - function _134($yyTop) // line 1382 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _134($yyTop) // line 1383 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = $this->yyVals[0+$yyTop]; } - function _135($yyTop) // line 1387 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _135($yyTop) // line 1388 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->yyVals[-1+$yyTop]; $this->yyVal[] = "\n\n"; } - function _136($yyTop) // line 1395 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _136($yyTop) // line 1396 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->_parseInlineTag($this->yyVals[-2+$yyTop], $this->yyVals[-1+$yyTop]); } - function _137($yyTop) // line 1399 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _137($yyTop) // line 1400 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { $this->yyVal = $this->_parseInlineTag($this->yyVals[-1+$yyTop], array()); } - function _138($yyTop) // line 1406 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _138($yyTop) // line 1407 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { if ($this->_options['parseInternal']) { $this->yyVal = $this->yyVals[-1+$yyTop]; @@ -1627,7 +1628,7 @@ } } - function _139($yyTop) // line 1417 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + function _139($yyTop) // line 1418 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" { if ($this->_options['parseInternal']) { $this->yyVal = $this->yyVals[-1+$yyTop]; @@ -1635,13 +1636,13 @@ $this->yyVal = ''; } } - // line 1639 "-" + // line 1640 "-" - // line 1425 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" + // line 1426 "C:/devel/PHP_Parser/Parser/DocBlock/Default.jay" /**#@-*/ } - // line 1645 "-" + // line 1646 "-" $GLOBALS['_PHP_PARSER_DOCBLOCK_DEFAULT']['yyLhs'] = array( -1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 2, http://cvs.php.net/diff.php/pear/PHP_Parser/Parser/DocBlock/DefaultLexer.lex?r1=1.17&r2=1.18&ty=u Index: pear/PHP_Parser/Parser/DocBlock/DefaultLexer.lex diff -u pear/PHP_Parser/Parser/DocBlock/DefaultLexer.lex:1.17 pear/PHP_Parser/Parser/DocBlock/DefaultLexer.lex:1.18 --- pear/PHP_Parser/Parser/DocBlock/DefaultLexer.lex:1.17 Sat Apr 17 13:50:18 2004 +++ pear/PHP_Parser/Parser/DocBlock/DefaultLexer.lex Sat Apr 17 14:29:35 2004 @@ -16,7 +16,7 @@ // | Authors: Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DefaultLexer.lex,v 1.17 2004/04/17 17:50:18 cellog Exp $ +// $Id: DefaultLexer.lex,v 1.18 2004/04/17 18:29:35 cellog Exp $ // require_once 'PEAR/ErrorStack.php'; @@ -251,6 +251,17 @@ } while ($next && $next[0] == PHP_PARSER_DOCLEX_TEXT); $this->restoreState($save); } + if ($lex[0] == PHP_PARSER_DOCLEX_SIMPLELIST) { + $save = $this->saveState(); + do { + $next = $this->yylex(); + if ($next[0] == PHP_PARSER_DOCLEX_SIMPLELIST) { + $save = $this->saveState(); + $lex[1] .= $next[1]; + } + } while ($next && $next[0] == PHP_PARSER_DOCLEX_SIMPLELIST); + $this->restoreState($save); + } $this->tokenWithWhitespace = $lex[0]; $this->token = $lex[0]; $this->value = $lex[1]; @@ -374,7 +385,7 @@ } else { // if $this->_atBullet if ($this->_atNewLine) { $this->_atNewLine = false; - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -392,11 +403,15 @@ } elseif (strlen($whitespace) >= ($wstrlen + $this->_lastBulletLen + 1)) { if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if (strlen($test) > 2 && - ($test{0} != '1' && ($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || - ($test{0} == '1' && (($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ((strlen($test) > 2 || !in_array($next, array(PHP_PARSER_DOCLEX_DOUBLENL, false))) && + ($test{0} != '1' && ($test{1} == ' ') || + ($test{0} == '1' && (($test{1} == ' ') || ($test{1} == '.') && - ($test{2} == ' ' && preg_match("/[^\s]/", $test{3})))))) { + ($test{2} == ' ' ))))) { // found a nested list array_push($this->_listTypeStack, $this->_listType); array_push($this->_bulletLenStack, $this->_lastBulletLen); @@ -479,15 +494,19 @@ } } - function _checkList($whitespace, $test, $newstate, $startingstate) + function _checkList($next, $whitespace, $test, $newstate, $startingstate) { + if (is_array($next)) { + $next = $next[0]; + } // check for simple lists - if (strlen($test) > 2 && - ($test{0} != '1' && ($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || - ($test{0} == '1' && (($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || + if ((strlen($test) > 2 || !in_array($next, array(PHP_PARSER_DOCLEX_DOUBLENL, false))) && + ($test{0} != '1' && ($test{1} == ' ') || + ($test{0} == '1' && (($test{1} == ' ') || ($test{1} == '.') && - ($test{2} == ' ' && preg_match("/[^\s]/", $test{3})))))) { + ($test{2} == ' '))))) { // found one + if ($this->debug) echo "found valid bullet\n"; if ($test{1} == '.') { $this->_lastNum = 0; $this->_listType = LIST_NUMBERED_DOT; @@ -687,7 +706,7 @@ } <INTAG> [^\n{<]+ { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -695,7 +714,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, SIMPLELIST, YYINITIAL)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, SIMPLELIST, YYINITIAL)) { return $res; } else { break; @@ -778,7 +801,7 @@ } <YYINITIAL> {NORMAL_DESC_TEXT} { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -786,7 +809,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, SIMPLELIST, YYINITIAL)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, SIMPLELIST, YYINITIAL)) { return $res; } else { break; @@ -898,7 +925,7 @@ } <INLINEINTERNALTAG> {INTERNAL_DESC_TEXT} { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -906,7 +933,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { return $res; } else { break; http://cvs.php.net/diff.php/pear/PHP_Parser/Parser/DocBlock/DefaultLexer.php?r1=1.15&r2=1.16&ty=u Index: pear/PHP_Parser/Parser/DocBlock/DefaultLexer.php diff -u pear/PHP_Parser/Parser/DocBlock/DefaultLexer.php:1.15 pear/PHP_Parser/Parser/DocBlock/DefaultLexer.php:1.16 --- pear/PHP_Parser/Parser/DocBlock/DefaultLexer.php:1.15 Sat Apr 17 13:50:18 2004 +++ pear/PHP_Parser/Parser/DocBlock/DefaultLexer.php Sat Apr 17 14:29:35 2004 @@ -16,7 +16,7 @@ // | Authors: Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DefaultLexer.php,v 1.15 2004/04/17 17:50:18 cellog Exp $ +// $Id: DefaultLexer.php,v 1.16 2004/04/17 18:29:35 cellog Exp $ // require_once 'PEAR/ErrorStack.php'; define('PHP_Parser_DocBlock_DefaultLexer_ERROR', 1); @@ -207,6 +207,17 @@ } while ($next && $next[0] == PHP_PARSER_DOCLEX_TEXT); $this->restoreState($save); } + if ($lex[0] == PHP_PARSER_DOCLEX_SIMPLELIST) { + $save = $this->saveState(); + do { + $next = $this->yylex(); + if ($next[0] == PHP_PARSER_DOCLEX_SIMPLELIST) { + $save = $this->saveState(); + $lex[1] .= $next[1]; + } + } while ($next && $next[0] == PHP_PARSER_DOCLEX_SIMPLELIST); + $this->restoreState($save); + } $this->tokenWithWhitespace = $lex[0]; $this->token = $lex[0]; $this->value = $lex[1]; @@ -326,7 +337,7 @@ } else { // if $this->_atBullet if ($this->_atNewLine) { $this->_atNewLine = false; - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -344,11 +355,15 @@ } elseif (strlen($whitespace) >= ($wstrlen + $this->_lastBulletLen + 1)) { if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if (strlen($test) > 2 && - ($test{0} != '1' && ($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || - ($test{0} == '1' && (($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ((strlen($test) > 2 || !in_array($next, array(PHP_PARSER_DOCLEX_DOUBLENL, false))) && + ($test{0} != '1' && ($test{1} == ' ') || + ($test{0} == '1' && (($test{1} == ' ') || ($test{1} == '.') && - ($test{2} == ' ' && preg_match("/[^\s]/", $test{3})))))) { + ($test{2} == ' ' ))))) { // found a nested list array_push($this->_listTypeStack, $this->_listType); array_push($this->_bulletLenStack, $this->_lastBulletLen); @@ -430,15 +445,19 @@ return array (PHP_PARSER_DOCLEX_SIMPLELIST, $this->yytext()); } } - function _checkList($whitespace, $test, $newstate, $startingstate) + function _checkList($next, $whitespace, $test, $newstate, $startingstate) { + if (is_array($next)) { + $next = $next[0]; + } // check for simple lists - if (strlen($test) > 2 && - ($test{0} != '1' && ($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || - ($test{0} == '1' && (($test{1} == ' ' && preg_match("/[^\s]/", $test{2})) || + if ((strlen($test) > 2 || !in_array($next, array(PHP_PARSER_DOCLEX_DOUBLENL, false))) && + ($test{0} != '1' && ($test{1} == ' ') || + ($test{0} == '1' && (($test{1} == ' ') || ($test{1} == '.') && - ($test{2} == ' ' && preg_match("/[^\s]/", $test{3})))))) { + ($test{2} == ' '))))) { // found one + if ($this->debug) echo "found valid bullet\n"; if ($test{1} == '.') { $this->_lastNum = 0; $this->_listType = LIST_NUMBERED_DOT; @@ -1207,7 +1226,7 @@ } case 3: { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -1215,7 +1234,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, SIMPLELIST, YYINITIAL)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, SIMPLELIST, YYINITIAL)) { return $res; } else { break; @@ -1445,7 +1468,7 @@ } case 17: { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -1453,7 +1476,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { return $res; } else { break; @@ -1592,7 +1619,7 @@ } case 23: { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -1600,7 +1627,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, SIMPLELIST, YYINITIAL)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, SIMPLELIST, YYINITIAL)) { return $res; } else { break; @@ -1795,7 +1826,7 @@ } case 40: { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -1803,7 +1834,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { return $res; } else { break; @@ -1867,7 +1902,7 @@ } case 45: { - $test = trim($this->yytext()); + $test = ltrim($this->yytext()); if (strlen($test)) { $whitespace = substr($this->yytext(), 0, strpos($this->yytext(), $test)); } else { @@ -1875,7 +1910,11 @@ } if (strlen($test) && in_array($test{0}, array('-', '+', 'o', '1'))) { // check for simple lists - if ($res = $this->_checkList($whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { + $save = $this->saveState(); + if ($this->debug) echo ">>checking next token\n"; + $next = $this->yylex(); + $this->restoreState($save); + if ($res = $this->_checkList($next, $whitespace, $test, INTERNALSIMPLELIST, INLINEINTERNALTAG)) { return $res; } else { break; http://cvs.php.net/diff.php/pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultLexer_test.php?r1=1.7&r2=1.8&ty=u Index: pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultLexer_test.php diff -u pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultLexer_test.php:1.7 pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultLexer_test.php:1.8 --- pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultLexer_test.php:1.7 Thu Apr 15 00:19:58 2004 +++ pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultLexer_test.php Sat Apr 17 14:29:35 2004 @@ -3,7 +3,7 @@ /** * API Unit tests for PHP_Parser package. * - * @version $Id: PHP_Parser_DocBlock_DefaultLexer_test.php,v 1.7 2004/04/15 04:19:58 cellog Exp $ + * @version $Id: PHP_Parser_DocBlock_DefaultLexer_test.php,v 1.8 2004/04/17 18:29:35 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PHP_Parser @@ -1526,6 +1526,38 @@ array(PHP_PARSER_DOCLEX_ENDINTERNAL, '}}'), ), $data, 'simple list 1'); } + + function test_simplelist_nontext() + { + if (!$this->_methodExists('setup')) { + return; + } + if (!$this->_methodExists('advance')) { + return; + } + $this->lexer->setup(' - <<code>> + - <b>stuff</b>'); + $data = array(); + while ($a = $this->lexer->advance()) { + $data[] = array($this->lexer->token, $this->lexer->value); + } + $this->assertEquals( + array( + array(PHP_PARSER_DOCLEX_WHITESPACE, ' '), + array(PHP_PARSER_DOCLEX_BULLET, '-'), + array(PHP_PARSER_DOCLEX_SIMPLELIST, ' '), + array(PHP_PARSER_DOCLEX_ESCAPED_TAG, '<<code>>'), + array(PHP_PARSER_DOCLEX_SIMPLELIST_NL, "\n"), + array(PHP_PARSER_DOCLEX_WHITESPACE, ' '), + array(PHP_PARSER_DOCLEX_BULLET, '-'), + array(PHP_PARSER_DOCLEX_SIMPLELIST, ' '), + array(PHP_PARSER_DOCLEX_OPEN_B, '<b>'), + array(PHP_PARSER_DOCLEX_SIMPLELIST, 'stuff'), + array(PHP_PARSER_DOCLEX_CLOSE_B, '</b>'), + array(PHP_PARSER_DOCLEX_SIMPLELIST_END, ''), + ), $data, 'simple list with other stuff'); + $this->assertNoErrors('test_simplelist_nontext', 'oops'); + } function test_simplelist_invalid1() { http://cvs.php.net/diff.php/pear/PHP_Parser/tests/PHP_Parser_DocBlock_Default_basic_test.php?r1=1.7&r2=1.8&ty=u Index: pear/PHP_Parser/tests/PHP_Parser_DocBlock_Default_basic_test.php diff -u pear/PHP_Parser/tests/PHP_Parser_DocBlock_Default_basic_test.php:1.7 pear/PHP_Parser/tests/PHP_Parser_DocBlock_Default_basic_test.php:1.8 --- pear/PHP_Parser/tests/PHP_Parser_DocBlock_Default_basic_test.php:1.7 Sat Apr 17 13:50:18 2004 +++ pear/PHP_Parser/tests/PHP_Parser_DocBlock_Default_basic_test.php Sat Apr 17 14:29:35 2004 @@ -3,7 +3,7 @@ /** * API Unit tests for PHP_Parser package. * - * @version $Id: PHP_Parser_DocBlock_Default_basic_test.php,v 1.7 2004/04/17 17:50:18 cellog Exp $ + * @version $Id: PHP_Parser_DocBlock_Default_basic_test.php,v 1.8 2004/04/17 18:29:35 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PHP_Parser @@ -573,6 +573,7 @@ ), $this->parser->parse($this->getOptions($comment, true)), 'parse'); $this->assertNoErrors('test_parse_simplelist', 'oops 1'); } + function test_parse_simplelist_multiparagraph() { if (!$this->_methodExists('parse')) { @@ -608,5 +609,38 @@ // $this->parser->debug = false; $this->assertNoErrors('test_parse_simplelist', 'oops 1'); } + + function test_parse_simplelist_escapedtag() + { + if (!$this->_methodExists('parse')) { + return; + } + $comment = ' - <<code>><<br/>> + - second item<<code>> + - third item'; +// $this->parser->debug = true; +// echo '<pre>'; + $this->assertEquals(array( + 'summary' => array(), + 'documentation' => array( + array( + array('list' => + array( + array(' <code><br/>'), + array(' second item<code>'), + array(' third item'), + ), + 'type' => '-', + ), + ) + ), + 'tags' => array(), + 'startline' => 1, + 'endline' => 4, + ), $this->parser->parse($this->getOptions($comment, true)), 'parse'); +// echo '</pre>'; +// $this->parser->debug = false; + $this->assertNoErrors('test_parse_simplelist', 'oops 1'); + } } ?>
« previous php.pear.cvs (#18353) next »