phpDocumentor phpDocumentor
[ class tree: phpDocumentor ] [ index: phpDocumentor ] [ all elements ]

Source for file ParserDescCleanup.inc

Documentation is available at ParserDescCleanup.inc

  1. <?php
  2. /**
  3.  * All of the functions to clean up and handle the long description
  4.  * of a DocBlock are in this file.
  5.  *
  6.  * The primary functionality is based on Parser and WordParser, and modified to recognize
  7.  * only the tokens defined in the PHPDOCUMENTOR_PDP_* constants
  8.  * 
  9.  * phpDocumentor :: automatic documentation generator
  10.  * 
  11.  * PHP versions 4 and 5
  12.  *
  13.  * Copyright (c) 2002-2006 Gregory Beaver
  14.  * 
  15.  * LICENSE:
  16.  * 
  17.  * This library is free software; you can redistribute it
  18.  * and/or modify it under the terms of the GNU Lesser General
  19.  * Public License as published by the Free Software Foundation;
  20.  * either version 2.1 of the License, or (at your option) any
  21.  * later version.
  22.  * 
  23.  * This library is distributed in the hope that it will be useful,
  24.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26.  * Lesser General Public License for more details.
  27.  * 
  28.  * You should have received a copy of the GNU Lesser General Public
  29.  * License along with this library; if not, write to the Free Software
  30.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  31.  *
  32.  * @package    phpDocumentor
  33.  * @subpackage Parsers
  34.  * @author     Gregory Beaver <[email protected]>
  35.  * @copyright  2002-2006 Gregory Beaver
  36.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  37.  * @version    CVS: $Id: ParserDescCleanup.inc,v 1.9 2006/05/23 13:06:57 cellog Exp $
  38.  * @link       http://www.phpdoc.org
  39.  * @link       http://pear.php.net/PhpDocumentor
  40.  * @see        Parser, WordParser
  41.  * @since      1.2
  42.  */
  43.  
  44. /**#@+
  45.  * {@link parserDescParser} token constants
  46.  */
  47. /** when <<code>> is found in a desc */
  48. define('PHPDOCUMENTOR_PDP_EVENT_CODE'600);
  49. /** when <<code>> is found in a desc */
  50. define('PHPDOCUMENTOR_PDP_STATE_CODE'700);
  51. /** when <<p>> is found in a desc */
  52. define('PHPDOCUMENTOR_PDP_EVENT_P'601);
  53. /** when <<p>> is found in a desc */
  54. define('PHPDOCUMENTOR_PDP_STATE_P'701);
  55. /** when \n\n is found in a desc */
  56. define('PHPDOCUMENTOR_PDP_EVENT_DOUBLECR'602);
  57. /** when \n\n is found in a desc */
  58. define('PHPDOCUMENTOR_PDP_STATE_DOUBLECR'702);
  59. /** when <<pre>> is found in a desc */
  60. define('PHPDOCUMENTOR_PDP_EVENT_PRE'603);
  61. /** when <<pre>> is found in a desc */
  62. define('PHPDOCUMENTOR_PDP_STATE_PRE'703);
  63. /** when <<ul>>/<<ol>> is found in a desc */
  64. define('PHPDOCUMENTOR_PDP_EVENT_LIST'604);
  65. /** when <<ul>>/<<ol>> is found in a desc */
  66. define('PHPDOCUMENTOR_PDP_STATE_LIST'704);
  67. /** when <<b>> is found in a desc */
  68. define('PHPDOCUMENTOR_PDP_EVENT_B'605);
  69. /** when <<b>> is found in a desc */
  70. define('PHPDOCUMENTOR_PDP_STATE_B'705);
  71. /** when <<i>> is found in a desc */
  72. define('PHPDOCUMENTOR_PDP_EVENT_I'606);
  73. /** when <<i>> is found in a desc */
  74. define('PHPDOCUMENTOR_PDP_STATE_I'706);
  75. /** when <<br>> is found in a desc */
  76. define('PHPDOCUMENTOR_PDP_EVENT_BR'607);
  77. /** when <<br>> is found in a desc */
  78. define('PHPDOCUMENTOR_PDP_STATE_BR'707);
  79. /** when the << potential escape for tags is found in a desc */
  80. define('PHPDOCUMENTOR_PDP_EVENT_ESCAPE',608);
  81. /** when the << potential escape for tags is found in a desc */
  82. define('PHPDOCUMENTOR_PDP_STATE_ESCAPE',708);
  83. /** when << /pre>> is found in a <<pre>><</pre>> section */
  84. define('PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE',609);
  85. /** when << /pre>> is found in a <<pre>><</pre>> section */
  86. define('PHPDOCUMENTOR_PDP_STATE_ESCAPE_PRE',709);
  87. /** when << /code>> is found in a <<code>><</code>> section  */
  88. define('PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE',610);
  89. /** when << /code>> is found in a <<code>><</code>> section  */
  90. define('PHPDOCUMENTOR_PDP_STATE_ESCAPE_CODE',710);
  91. /** when <<var>> is found in a desc  */
  92. define('PHPDOCUMENTOR_PDP_EVENT_VAR',611);
  93. /** when <<var>> is found in a desc  */
  94. define('PHPDOCUMENTOR_PDP_STATE_VAR',711);
  95. /** when <<samp>> is found in a desc  */
  96. define('PHPDOCUMENTOR_PDP_EVENT_SAMP',612);
  97. /** when <<samp>> is found in a desc  */
  98. define('PHPDOCUMENTOR_PDP_STATE_SAMP',712);
  99. /** when <<kbd>> is found in a desc  */
  100. define('PHPDOCUMENTOR_PDP_EVENT_KBD',613);
  101. /** when <<kbd>> is found in a desc  */
  102. define('PHPDOCUMENTOR_PDP_STATE_KBD',713);
  103. /** when a simple list is found in a desc
  104.  *
  105.  * like
  106.  * <pre>
  107.  *  o item 1
  108.  *  o item 2
  109.  * </pre>
  110.  */
  111. define('PHPDOCUMENTOR_PDP_EVENT_SIMLIST',614);
  112. /** when a simple list is found in a desc
  113.  *
  114.  * like
  115.  * <pre>
  116.  *  o item 1
  117.  *  o item 2
  118.  * </pre>
  119.  */
  120. define('PHPDOCUMENTOR_PDP_STATE_SIMLIST',714);
  121. /**#@-*/
  122. * Like WordParser but designed to handle an array with strings and
  123. {@link parserInlineTag}s
  124. @package phpDocumentor
  125. @subpackage WordParsers
  126. @author Greg Beaver <[email protected]>
  127. @since 1.2
  128. */
  129. class ObjectWordParser extends WordParser
  130. {
  131.     /**
  132.      * Determines whether text searching is case-sensitive or not
  133.      * @access private
  134.      */
  135.     var $_casesensitive false;
  136.     
  137.     function ObjectWordParser($casesensitive false)
  138.     {
  139.         $this->_casesensitive $casesensitive;
  140.     }
  141.     
  142.     /**
  143.      * Set the word parser to go.
  144.      *
  145.      * @param array {@link parserStringWithInlineTags::$value} style-array, with
  146.      *               alternating text and inline tags
  147.      */
  148.     function setup(&$input)
  149.     {
  150. //        if (is_string($input[0])) $input[0] = ltrim($input[0]);
  151.         $this->data $input;
  152.         $this->pos 0;
  153.         $this->linenum 0;
  154.         $this->linenumpos 0;
  155.         $this->cache array();
  156.         reset($this->data);
  157.         list($this->index,each($this->data);
  158.         if (!is_object($this->data[$this->index]))
  159.         $this->size strlen($this->data[$this->index]);
  160.         else $this->size 0;
  161.         //$this->run = 0;
  162.         //$this->word = WORD_PARSER_RET_WORD;
  163.     }
  164.     
  165.     function getWord()
  166.     {
  167.         if (!isset($this->data[$this->index])) return false;
  168.         // return any inline tags unchanged
  169.         if (is_object($this->data[$this->index]))
  170.         {
  171.             $index $this->index;
  172.             list($this->index,each($this->data);
  173.             $this->pos 0;
  174.             if ($this->index)
  175.             {
  176.                 if (!is_object($this->data[$this->index]))
  177.                 $this->size strlen($this->data[$this->index]);
  178.                 else $this->size 0;
  179.                 $this->cache array();
  180.                 return $this->data[$index];
  181.             else
  182.             {
  183.                 return false;
  184.             }
  185.         }
  186.         //$st = $this->mtime();
  187.         if ($this->size == $this->pos)
  188.         {
  189.             // cycle to next line in the array
  190.             list($this->index,each($this->data);
  191.             if (!$this->indexreturn false;
  192.             $this->pos 0;
  193.             if (!is_object($this->data[$this->index]))
  194.             $this->size strlen($this->data[$this->index]);
  195.             else $this->size 0;
  196.             $this->cache array();
  197.             return $this->getWord();
  198.         }
  199.  
  200.         $npos $this->size;
  201.         if (is_array($this->wordseperators))
  202.         {
  203.             //$this->wordseperators = array();
  204.             foreach($this->wordseperators as $sep)
  205.             {
  206.                 if (isset($this->cache[$sep]))
  207.                 $tpos $this->cache[$sep];
  208.                 else
  209.                 $tpos false;
  210.                 if ($tpos $this->pos || !is_int($tpos))
  211.                 {
  212.                     if ($this->_casesensitive)
  213.                         $tpos strpos($this->data[$this->index],$sep,$this->pos);
  214.                     else
  215.                         $tpos strpos(strtolower($this->data[$this->index]),$sep,$this->pos);
  216.                 }
  217.             
  218.                 if ( ($tpos $npos&& !($tpos === false))
  219.                 {
  220.                     //echo trim($sep) . "=$tpos\n";
  221.                     $npos $tpos;
  222.                     $seplen strlen($sep);
  223.                 
  224.                   else if (!($tpos === false))
  225.                 {
  226.                     $this->cache[$sep$tpos;
  227.                 }
  228.             }
  229.         else {
  230.             // its time to cycle
  231.             return "";
  232.         }
  233.  
  234.         $len $npos $this->pos;
  235.         if ($len == 0)
  236.         {
  237.             $len $seplen;
  238.         }
  239.  
  240.         //$st3 = $this->mtime();
  241.         $word substr($this->data[$this->index],$this->pos,$len);
  242.         
  243.         // Change random other os newlines to the unix one
  244.         if ($word == "\r" || $word == "\r\n")
  245.         {
  246.             $word "\n";
  247.         }
  248.         
  249.         if ($this->linenumpos <= $this->pos)
  250.         {
  251.             $this->linenumpos $this->pos $len;
  252.             $this->linenum += count(explode("\n",$word)) 1;
  253.         }
  254.  
  255.         if ($this->getsource)
  256.         {
  257.             $this->source .= $word;
  258.         }
  259.         $this->pos $this->pos $len;
  260.         //$this->word = WORD_PARSER_RET_SEP;
  261.  
  262.         // Things like // commenats rely on the newline to find their end so im going to have to return them
  263.         // never return worthless white space /t ' '
  264.         if ($this->returnWhiteSpace == false)
  265.         {
  266.             if (strlen(trim($word)) == && $word != "\n"
  267.             {
  268.                 $word $this->getWord();
  269.             }
  270.         }
  271.         //$this->time3 = $this->time3 + ($this->mtime() - $st3);
  272.         //$this->time = $this->time + ($this->mtime() - $st);
  273.         return $word;
  274.     }
  275.     
  276.     /**
  277.      * Determine if the next word is an inline tag
  278.      * @return boolean 
  279.      */
  280.     function nextIsObjectOrNonNL()
  281.     {
  282.         return (($this->size == $this->pos&& isset($this->data[$this->index 1])
  283.             && is_object($this->data[$this->index 1])) ||
  284.                (($this->size $this->pos&& !in_array($this->data[$this->index]{$this->pos}array("\n""\r")));
  285.     }
  286. }
  287.  
  288. /**
  289.  * Parses a DocBlock description to retrieve abstract representations of
  290.  * <<pre>>,<<code>>,<<p>>,<<ul>>,<<ol>>,<<li>>,<<b>>,<<i>>
  291.  * @tutorial phpDocumentor.howto.pkg#basics.desc
  292.  * @package phpDocumentor
  293.  * @subpackage Parsers
  294.  * @author Greg Beaver <[email protected]>
  295.  * @since 1.2
  296.  */
  297. class parserDescParser extends Parser
  298. {
  299.     /**#@+
  300.      * @access private
  301.      */
  302.     /**
  303.      * @var array 
  304.      */
  305.     var $eventHandlers array(PHPDOCUMENTOR_PDP_EVENT_CODE => 'handleCode',
  306.                                PHPDOCUMENTOR_PDP_EVENT_PRE => 'handlePre',
  307.                                PHPDOCUMENTOR_PDP_EVENT_P => 'handleP',
  308.                                PHPDOCUMENTOR_PDP_EVENT_DOUBLECR => 'handleDoubleCR',
  309.                                PHPDOCUMENTOR_PDP_EVENT_LIST => 'handleList',
  310.                                PHPDOCUMENTOR_PDP_EVENT_B => 'handleB',
  311.                                PHPDOCUMENTOR_PDP_EVENT_I => 'handleI',
  312.                                PHPDOCUMENTOR_PDP_EVENT_VAR => 'handleVar',
  313.                                PHPDOCUMENTOR_PDP_EVENT_KBD => 'handleKbd',
  314.                                PHPDOCUMENTOR_PDP_EVENT_SAMP => 'handleSamp',
  315.                                PHPDOCUMENTOR_PDP_EVENT_BR => 'handleBr',
  316.                                PHPDOCUMENTOR_PDP_EVENT_ESCAPE => 'handleEscape',
  317.                                PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE => 'handleEscapeCode',
  318.                                PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE => 'handleEscapePre',
  319.                                PHPDOCUMENTOR_PDP_EVENT_SIMLIST => 'handleSimpleList',
  320.                                PARSER_EVENT_NOEVENTS => 'defaultHandler',
  321.                                );
  322.     
  323.     /**
  324.      * @var array 
  325.      */
  326.     var $pars array();
  327.     /**
  328.      * Determines whether parsing of &lt;p&gt; tags will occur, or double CR will
  329.      * be used
  330.      * @var boolean 
  331.      */
  332.     var $parse_Ps;
  333.     /**
  334.      * Context stack.
  335.      *
  336.      * Values can be 'normal', or any tag container like 'my_i', 'my_b'.  This
  337.      * is used to determine which tag text or nested tags should be added to
  338.      * @var array 
  339.      */
  340.     var $_context array('normal');
  341.     /**#@-*/
  342.     
  343.     /**
  344.      * sets $wp to be a {@link ObjectWordParser}
  345.      * 
  346.      * $wp is the word parser that retrieves tokens
  347.      */
  348.     function parserDescParser()
  349.     {
  350.         $this->wp new ObjectWordParser;
  351.     }
  352.     
  353.     /**
  354.      * Parse a long or short description for tags
  355.      *
  356.      * @param array array of strings or {@link parserInlineTag}s
  357.      * @param boolean true if the description is a short description. (only 1 paragraph allowed in short desc)
  358.      * @param string name of the class to instantiate for each paragraph.  parserDesc for desc/sdesc,
  359.      *                parserStringWithInlineTags for tag data
  360.      * @staticvar integer used for recursion limiting if a handler for an event is not found
  361.      */
  362.     function parse (&$parse_data,$sdesc false,$ind_type 'parserDesc')
  363.     {
  364.         static $endrecur 0;
  365.         global $_phpDocumentor_setting;
  366.         if (!is_array($parse_data|| count($parse_data== 0)
  367.         {
  368.             return false;
  369.         }
  370.         $this->p_vars['indtype'$ind_type;
  371.         $this->setupStates($sdesc);
  372.         if (isset($_phpDocumentor_setting['javadocdesc']&& $_phpDocumentor_setting['javadocdesc'== 'on')
  373.             $this->parse_Ps true;
  374.  
  375.         // initialize variables so E_ALL error_reporting doesn't complain
  376.         $pevent 0;
  377.         $word 0;
  378.         $this->p_vars['curpar'0;
  379.         $this->pars array();
  380.         $this->p_vars['start'true;
  381.         $this->p_vars['event_stack'new EventStack;
  382.  
  383.         $this->wp->setup($parse_data,$sdesc);
  384.         $this->wp->setWhitespace(true);
  385.         $this->p_vars['list_count'0;
  386.         if ($sdesc$this->p_vars['start'false;
  387.         do
  388.         {
  389.             if (!isset($this->pars[$this->p_vars['curpar']])) $this->pars[$this->p_vars['curpar']] new $ind_type;
  390.             $lpevent $pevent;
  391.             $pevent $this->p_vars['event_stack']->getEvent();
  392.             if ($lpevent != $pevent)
  393.             {
  394.                 $this->p_vars['last_pevent'$lpevent;
  395.             }
  396.  
  397.             if ($this->p_vars['last_pevent'!= $pevent)
  398.             {
  399.                 // its a new event so the word parser needs to be reconfigured 
  400.                 $this->configWordParser($pevent);
  401.             }
  402.  
  403.  
  404.             $this->p_vars['last_word'$word;
  405.             $word $this->wp->getWord();
  406.  
  407.             if (0)//PHPDOCUMENTOR_DEBUG == true)
  408.             {
  409.                 echo "----------------\n";
  410.                 echo "LAST: |" htmlentities($this->p_vars['last_word']"|\n";
  411. //                echo "INDEX: ".$this->p_vars['curpar']."\n";
  412.                 echo "PEVENT: " $this->getParserEventName($pevent"\n";
  413.                 echo "LASTPEVENT: " $this->getParserEventName($this->p_vars['last_pevent']"\n";
  414.                 echo $this->wp->getPos(" WORD: |".htmlentities($word)."|\n\n";
  415.                 var_dump($this->_context);
  416.             }
  417.             if (isset($this->eventHandlers[$pevent]))
  418.             {
  419.                 $handle $this->eventHandlers[$pevent];
  420.                 if ($word !== false$this->$handle($word$pevent);
  421.                 else
  422.                 {
  423.                     if (!count($this->pars[$this->p_vars['curpar']]->value)) unset($this->pars[$this->p_vars['curpar']]);
  424.                 }
  425.             else
  426.             {
  427.                 debug('WARNING: possible error, no ParserDescParser handler for event number '.$pevent);
  428.                 if ($endrecur++ == 25)
  429.                 {
  430.                     die("FATAL ERROR, recursion limit reached");
  431.                 }
  432.             }
  433.             if (is_object($word|| trim($word!= '')
  434.             {
  435.                 $this->p_vars['start'false;
  436.             }
  437.         while (is_object($word|| !($word === false&& $word != '');
  438.         $context $this->getContext();
  439.         if ($context != 'normal')
  440.         {
  441.             if ($context == 'list' && $this->p_flags['simplelist'])
  442.             {
  443.                 $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
  444.                 unset($this->p_vars['list_item'][0]);
  445.                 $this->setContext('normal');
  446.                 $this->addText($this->p_vars['lists'][0]);
  447.             else addError(PDERROR_UNCLOSED_TAG,str_replace('my_','',$context));
  448.         }
  449.         if ($this->p_vars['list_count'0addError(PDERROR_UNMATCHED_LIST_TAG);
  450.         if ($sdesc)
  451.         $this->publishEvent(2,$this->pars);
  452.         else
  453.         $this->publishEvent(1,$this->pars);
  454.     }
  455.     /**#@+ @access private */
  456.     /**
  457.      * basic handling
  458.      *
  459.      * This function checks to see if the first thing in
  460.      * a description is the <p> tag.  If so, it will switch
  461.      * into a mode of parsing out paragraphs by <p> instead
  462.      * of a double line-break
  463.      *
  464.      * It also removes extra whitespace
  465.      * @uses doSimpleList()
  466.      */
  467.     function defaultHandler($word$pevent)
  468.     {
  469.         $context $this->getContext();
  470.         if ($context != 'normal'$this->setContext('normal');
  471.         if ($this->p_vars['start'&& is_string($word&& strtolower($word== '<p>')
  472.         {
  473.             $this->parse_Ps true;
  474.         }
  475.         if (is_string($word&& $this->checkEventPush($word$pevent)) return;
  476. //        if (!isset($this->parse_Ps) || !$this->parse_Ps)
  477.         {
  478.             if (is_string($word&& is_string($this->p_vars['last_word']&&
  479.                   ($word == ' ' && $this->p_vars['last_word'== ' ')) return;
  480.             if ($pevent == PARSER_EVENT_NOEVENTS)
  481.             {
  482.                 if ($this->doSimpleList($word)) return;
  483.             }
  484.             $this->addText($word);
  485.         }
  486.     }
  487.     
  488.     /**
  489.      * Retrieve the current top-level tag to add text into
  490.      * @uses $_context
  491.      */
  492.     function getContext()
  493.     {
  494.         array_push($this->_context,$a array_pop($this->_context));
  495.         return $a;
  496.     }
  497.     
  498.     /**
  499.      * Pop a context off of the context stack
  500.      * @uses $_context
  501.      */
  502.     function dropContext()
  503.     {
  504.         array_pop($this->_context);
  505.         if (count($this->_context== 0)
  506.         $this->_context array('normal');
  507.     }
  508.     
  509.     /**
  510.      * @uses $_context
  511.      * @param string context name
  512.      */
  513.     function setContext($context)
  514.     {
  515.         array_push($this->_context,$context);
  516.     }
  517.     
  518.     /**
  519.      * add input as text to the current paragraph or list
  520.      * @param string|parserInlineTag
  521.      */
  522.     function addText($text)
  523.     {
  524.         $context $this->getContext();
  525.         if ($context == 'list')
  526.         {
  527. //            debug('aded to '.$context);
  528.             if (!is_object($this->p_vars['list_item'][$this->p_vars['list_count']])) {
  529.                 addErrorDie(PDERROR_UL_IN_UL);
  530.             }
  531.             $this->p_vars['list_item'][$this->p_vars['list_count']]->add($text);
  532.         elseif ($context != 'normal')
  533.         {
  534. //            debug('added to '.$context);
  535.             $this->p_vars[$context]->add($text);
  536.         else
  537.         {
  538. //            debug('added to normal ');
  539.             $indtype $this->p_vars['indtype'];
  540.             if (!isset($this->pars[$this->p_vars['curpar']]))
  541.                 $this->pars[$this->p_vars['curpar']] new $indtype;
  542.             $this->pars[$this->p_vars['curpar']]->add($text);
  543.         }
  544.     }
  545.     
  546.     /**#@-*/
  547.     /**#@+
  548.      * @access private
  549.      * @param string|parserInlineTagtoken from the ObjectWordParser
  550.      * @param integer parser event from {@link ParserDescCleanup.inc}
  551.      */
  552.     /**
  553.      * Handles special case where a description needs the text "<tag>" and tag
  554.      * is one of code, b, i, pre, var, or any other valid in-DocBlock html tag.
  555.      *
  556.      * the text <<<code>>> in a DocBlock will parse out as <<code>>, instead
  557.      * of being parsed as markup.
  558.      */
  559.     function handleEscape($word$pevent)
  560.     {
  561.         $this->p_vars['event_stack']->popEvent();
  562.         if (!in_array($word$this->tokens[PHPDOCUMENTOR_PDP_STATE_ESCAPE]))
  563.         {
  564.             if ($word == '<')
  565.             {
  566.                 $this->addText($word);
  567.                 $this->wp->backupPos($word.$word);
  568.             else
  569.             $this->wp->backupPos($word);
  570.             return;
  571.         }
  572.         $this->addText('<'.str_replace('>>','>',$word));
  573.     }
  574.     
  575.     /**
  576.      * Just like {@link handleEscape}, except the only valid escape is
  577.      * <<</pre>>>
  578.      */
  579.     function handleEscapePre($word$pevent)
  580.     {
  581.         $this->p_vars['event_stack']->popEvent();
  582.         $this->addText('</pre>');
  583.     }
  584.     
  585.     /**
  586.      * Just like {@link handleEscape}, except the only valid escape is
  587.      * <<</code>>>
  588.      */
  589.     function handleEscapeCode($word$pevent)
  590.     {
  591.         $this->p_vars['event_stack']->popEvent();
  592.         $this->addText('</code>');
  593.     }
  594.     
  595.     /**
  596.      * Handle "<<br>>"
  597.      * Add a new {@link parserBr}
  598.      * @uses addText()
  599.      */
  600.     function handleBr($word$pevent)
  601.     {
  602.         if (is_string($word&& $this->checkEventPop($word$pevent))
  603.         {
  604.             $this->addText(new parserBr);
  605.         }
  606.     }
  607.     
  608.     /**
  609.      * Handles simple lists
  610.      *
  611.      * phpEdit has an ingenious facility to handle simple lists used in a
  612.      * DocBlock like this:
  613.      *
  614.      * - item 1
  615.      * - item 2
  616.      * - item 3
  617.      *
  618.      * The DocBlock is:
  619.      * <pre>
  620.      * * - item 1
  621.      * * - item 2
  622.      * * - item 3
  623.      * </pre>
  624.      * This function converts these simple lists into the parserList class
  625.      * @param boolean true if this is the first list item in the list
  626.      */
  627.     function handleSimpleList($word$pevent$start false)
  628.     {
  629.         if (is_object($word&& $this->p_flags['in_item'])
  630.         {
  631.             $this->p_vars['list_item'][0]->add($word);
  632.             return;
  633.         }
  634.         if (is_string($word&& $this->checkEventPush($word$pevent))
  635.         {
  636.             $this->p_flags['in_event'true;
  637.             return;
  638.         }
  639.         $ltrimword @substr($word@strpos($wordltrim($word)));
  640.         $is_valid false;
  641.         if (strlen(trim($word)) == 0)
  642.         {
  643.             if ($this->wp->nextIsObjectOrNonNL())
  644.             {
  645.                 $is_valid true;
  646.             }
  647.         }
  648.         if ($word == "\n" && is_string($this->p_vars['last_word'])
  649.             && $this->p_vars['last_word']{strlen($this->p_vars['last_word']1}
  650.                 == "\n")
  651.         {
  652.             if ($this->p_flags['in_item'])
  653.             {
  654.                 $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
  655.                 unset($this->p_vars['list_item'][0]);
  656.                 $this->setContext('normal');
  657.                 $this->p_flags['simplelist'false;
  658.                 $this->addText($this->p_vars['lists'][0]);
  659.                 unset($this->p_vars['lists']);
  660.                 unset($this->p_vars['last_list']);
  661.                 $this->wp->backuppos($word);
  662.                 $this->p_vars['event_stack']->popEvent();
  663.                 $this->p_flags['in_item'false;
  664. //                debug('end of list 3');
  665.                 return;
  666.             else
  667.             {
  668.                 $this->wp->backuppos($word);
  669.                 $this->p_vars['event_stack']->popEvent();
  670.                 $this->p_flags['in_item'false;
  671. //                debug('not a list 2');
  672.                 return;
  673.             }
  674.         }
  675.         $start_list $this->getStartList($word);
  676.         if (substr($ltrimword,0,strlen($start_list)) != $start_list 
  677.              || $this->p_flags['in_event'|| is_object($this->p_vars['last_word']))
  678.         {
  679.             if (((strlen($this->p_vars['whitespace']1strlen(substr($word,0,strpos($word$ltrimword))))
  680.                    || $word == "\n"
  681.                    || $is_valid
  682.                    || $this->p_flags['in_event']
  683.                    || (is_object($this->p_vars['last_word']&& $this->p_flags['in_item']))
  684.             {
  685.                 $this->p_vars['list_item'][0]->add($word);
  686.                 $this->resetStartList($start_list);
  687.                 $this->p_flags['in_event'false;
  688. //                debug('middle of list');
  689.             else
  690.             {
  691.                 if ($this->p_flags['in_item'])
  692.                 {
  693.                     $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
  694.                     unset($this->p_vars['list_item'][0]);
  695.                     $this->setContext('normal');
  696.                     $this->p_flags['simplelist'false;
  697.                     $this->addText($this->p_vars['lists'][0]);
  698.                     unset($this->p_vars['lists']);
  699.                     unset($this->p_vars['last_list']);
  700.                     $this->wp->backuppos($word);
  701.                     $this->p_vars['event_stack']->popEvent();
  702.                     $this->p_flags['in_item'false;
  703. //                    debug('end of list 1');
  704.                     return;
  705.                 else
  706.                 {
  707.                     $this->wp->backuppos($word);
  708.                     $this->p_vars['event_stack']->popEvent();
  709.                     $this->p_flags['in_item'false;
  710. //                    debug('not a list');
  711.                     return;
  712.                 }
  713.             }
  714.         else
  715.         {
  716.             if ($this->p_vars['whitespace'!= substr($word,0,strpos($word$start_list)))
  717.             // if the whitespace is greater than that preceding the list
  718.               // delimiter, it's a multi-line list item
  719.                 $this->setContext('normal');
  720.                 $this->p_flags['simplelist'false;
  721.                 $this->addText($this->p_vars['lists'][0]);
  722.                 unset($this->p_vars['lists']);
  723.                 $this->wp->backuppos($word);
  724.                 $this->p_vars['event_stack']->popEvent();
  725.                 unset($this->p_vars['last_list']);
  726.                 $this->p_flags['in_item'false;
  727. //                debug('end of list 2');
  728.                 return;
  729.             else
  730.             {
  731.                 if ($this->p_flags['in_item'])
  732.                 {
  733.                     // end of a list item, add it to the list
  734.                     $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
  735.                     unset($this->p_vars['list_item'][0]);
  736.                 }
  737. //                debug('next list item');
  738.                 $this->p_vars['list_item'][0new parserStringWithInlineTags;
  739.                 $this->p_vars['list_item'][0]->add(ltrim(substr($ltrimword,strlen($start_list))));
  740.                 $this->p_flags['in_item'true;
  741.             }
  742.         }
  743.     }
  744.     /**#@-*/
  745.     /**
  746.      * Get the next list marker
  747.      *
  748.      * In unordered lists, this will be something like "o", "-"
  749.      *
  750.      * In ordered lists, this will be either the number "3", "5" or "3.", "5."
  751.      * @return string text of the next list marker to look for
  752.      * @param string current word from the parser
  753.      * @access private
  754.      */
  755.     function getStartList($word)
  756.     {
  757.         // unordered, return the first marker found
  758.         if (!$this->p_flags['orderedlist']return $this->p_vars['start_list'];
  759.         if (isset($this->p_vars['last_list']))
  760.         {
  761.             $this->p_vars['save_list'$this->p_vars['last_list'];
  762.             $next $this->p_vars['last_list'];
  763.             // increment to next list number, convert to string
  764.             if (substr($this->p_vars['start_list']strlen($this->p_vars['start_list']1== '.')
  765.                 $next (substr($next0strpos($next,'.')) 1'.';
  766.             else
  767.                 $next ($next 1'';
  768. //                debug("next is '$next'");
  769.             if ($this->p_vars['whitespace'== substr($word,0,strpos($word$next)))
  770.                 return $this->p_vars['last_list'$next;
  771.             // the next number is not in this word, so return but don't save
  772.             return $next;
  773.         else
  774.         {
  775.             $this->p_vars['last_list'$this->p_vars['start_list'];
  776.             return $this->p_vars['start_list'];
  777.         }
  778.     }
  779.     
  780.     /**
  781.      * Set the next list marker to the current list marker
  782.      *
  783.      * In ordered lists, this will ensure that the next number returned is the
  784.      * right number
  785.      * @param string token for next list marker
  786.      * @access private
  787.      */
  788.     function resetStartList($start)
  789.     {
  790.         if (!isset($this->p_vars['save_list'])) return false;
  791.         $this->p_vars['last_list'$this->p_vars['save_list'];
  792.     }
  793.     
  794.     /**#@+
  795.      * @access private
  796.      * @param string|parserInlineTagtoken from the ObjectWordParser
  797.      * @param integer parser event from {@link ParserDescCleanup.inc}
  798.      */
  799.     /**
  800.      * Handles <<ol>>,<<li>>,<<ul>>
  801.      *
  802.      * This allows parsing of lists nested to any level.  Using
  803.      * the lists and list_item temporary variables and using
  804.      * list_count to control nesting, the method creates a {@link parserList}
  805.      * for each <<ol>> or <<ul>> tag, and a
  806.      * standard {@link parserStringWithInlineTags} for all the text, adding
  807.      * in nested lists as if they were inline tags (the conversion interface
  808.      * is the same for both object types)
  809.      */
  810.     function handleList($word$pevent)
  811.     {
  812.         if (is_string($word&& $this->checkEventPush($word$pevent))
  813.         {
  814.             return;
  815.         }
  816.         $ordered false;
  817.         if (!is_object($this->p_vars['last_word']&& strtolower($this->p_vars['last_word']== '<ol>')
  818.         {
  819.             // ordered list
  820.             $ordered true;
  821.         }
  822.         // start a new list
  823.         if (!is_object($this->p_vars['last_word']&& (strtolower($this->p_vars['last_word']== '<ol>' || strtolower($this->p_vars['last_word']== '<ul>'))
  824.         {
  825.             $this->p_flags['in_item'false;
  826.             $this->setContext('list');
  827.             $this->p_vars['lists'][++$this->p_vars['list_count']] new parserList($ordered);
  828.         }
  829.         if (!is_object($word&& strtolower($word== '<li>')
  830.         {
  831.             if ($this->p_flags['in_item'])
  832.             {
  833.                 // end of a list item (no end tag), add it to the list
  834.                 $this->p_vars['lists'][$this->p_vars['list_count']]->addItem($this->p_vars['list_item'][$this->p_vars['list_count']]);
  835.                 unset($this->p_vars['list_item'][$this->p_vars['list_count']]);
  836.             }
  837.             // start a new list item
  838.             $this->p_vars['list_item'][$this->p_vars['list_count']] new parserStringWithInlineTags;
  839.             $this->p_flags['in_item'true;
  840.         else
  841.         {
  842.             if (is_object($word|| (strtolower($word!= '</li>'))
  843.             {
  844.                 if (is_object($word|| (strtolower($word!= '</ul>' && strtolower($word!= '</ol>'))
  845.                 {
  846.                     // item text
  847.                     if (isset($this->p_vars['list_item'][$this->p_vars['list_count']]))
  848.                     {
  849.                         if (is_string($word&& $word == ' ' &&
  850.                               $this->p_vars['last_word'== ' 'return;
  851.                         $this->p_vars['list_item'][$this->p_vars['list_count']]->add($word);
  852.                     }
  853.                 else
  854.                 {
  855.                     if ($this->p_flags['in_item'])
  856.                     {
  857.                         // end the current list item before ending a list
  858.                         $this->p_vars['lists'][$this->p_vars['list_count']]->addItem($this->p_vars['list_item'][$this->p_vars['list_count']]);
  859.                         unset($this->p_vars['list_item'][$this->p_vars['list_count']]);
  860.                         $this->p_flags['in_item'false;
  861.                     }
  862.                     if (is_string($word&& $this->checkEventPop($word$pevent))
  863.                     {
  864.                         if ($this->p_vars['list_count'1)
  865.                         {
  866.                             // this is a sublist, add it to the list item of the parent list
  867.                             if (!isset($this->p_vars['list_item'][$this->p_vars['list_count'1])) {
  868.                                 addErrorDie(PDERROR_UL_IN_UL);
  869.                             }
  870.                             $this->p_vars['list_item'][$this->p_vars['list_count'1]->add($this->p_vars['lists'][$this->p_vars['list_count']]);
  871.                             // remove the sublist item and sublist, drop to parent list
  872.                             unset($this->p_vars['lists'][$this->p_vars['list_count']]);
  873.                             unset($this->p_vars['lists'][$this->p_vars['list_count']]);
  874.                             $this->p_vars['list_count']--;
  875.                             $this->p_flags['in_item'true;
  876.                         else
  877.                         {
  878.                             // this is a primary list and it has concluded
  879.                             $this->pars[$this->p_vars['curpar']]->add($this->p_vars['lists'][$this->p_vars['list_count']]);
  880.                             unset($this->p_vars['lists']);
  881.                             unset($this->p_vars['list_item']);
  882.                             $this->p_vars['list_count'0;
  883.                             $this->dropContext();
  884.                         }
  885.                     }
  886.                 }
  887.             else
  888.             {
  889.                 // check to make sure our list item is not unclosed
  890.                 if (!$this->p_flags['in_item'])
  891.                 {
  892.                     addError(PDERROR_TEXT_OUTSIDE_LI);
  893.                 else
  894.                 {
  895.                     // end of a list item, add it to the list
  896.                     $this->p_vars['lists'][$this->p_vars['list_count']]->addItem($this->p_vars['list_item'][$this->p_vars['list_count']]);
  897.                     unset($this->p_vars['list_item'][$this->p_vars['list_count']]);
  898.                     $this->p_flags['in_item'false;
  899.                 }
  900.             }
  901.         }
  902.     }
  903.  
  904.     /**
  905.      * Handles <<code>><</code>> blocks
  906.      */
  907.     function handleCode($word$pevent)
  908.     {
  909.         if (!isset($this->p_vars['my_code']))
  910.         {
  911.             $this->setContext('my_code');
  912.             $this->p_vars['my_code'new parserCode;
  913.         }
  914.         if (is_string($word&& $this->checkEventPush($word$pevent)) return;
  915.         if (is_object($word|| strtolower($word!= '</code>'$this->p_vars['my_code']->add($word);
  916.         if (is_string($word))
  917.         {
  918.             if ($this->checkEventPop($word,$pevent))
  919.             {
  920.                 $this->dropContext();
  921.                 $this->addText($this->p_vars['my_code']);
  922.                 unset($this->p_vars['my_code']);
  923.             }
  924.         }
  925.     }
  926.     
  927.     /**
  928.      * Handles <<pre>><</pre>> blocks
  929.      */
  930.     function handlePre($word$pevent)
  931.     {
  932.         if (!isset($this->p_vars['my_pre']))
  933.         {
  934.             $this->setContext('my_pre');
  935.             $this->p_vars['my_pre'new parserPre;
  936.         }
  937.         if (is_string($word&& $this->checkEventPush($word$pevent)) return;
  938.         if (is_object($word|| strtolower($word!= '</pre>'$this->p_vars['my_pre']->add($word);
  939.         if (is_string($word))
  940.         {
  941.             if ($this->checkEventPop($word,$pevent))
  942.             {
  943.                 $this->dropContext();
  944.                 $this->addText($this->p_vars['my_pre']);
  945.                 unset($this->p_vars['my_pre']);
  946.             }
  947.         }
  948.     }
  949.     
  950.     /**
  951.      * Handles <<b>><</b>> blocks
  952.      */
  953.     function handleB($word$pevent)
  954.     {
  955.         if (!isset($this->p_vars['my_b']))
  956.         {
  957.             $this->setContext('my_b');
  958.             $this->p_vars['my_b'new parserB;
  959.         }
  960.         if (is_string($word))
  961.         {
  962.             if ($this->checkEventPop($word,$pevent))
  963.             {
  964.                 $this->dropContext();
  965.                 $this->addText($this->p_vars['my_b']);
  966.                 unset($this->p_vars['my_b']);
  967.             else
  968.             {
  969.                 $this->p_vars['my_b']->add($word);
  970.             }
  971.         else $this->p_vars['my_b']->add($word);
  972.     }
  973.     
  974.     /**
  975.      * Handles <<i>><</i>> blocks
  976.      */
  977.     function handleI($word$pevent)
  978.     {
  979.         if (!isset($this->p_vars['my_i']))
  980.         {
  981.             $this->p_vars['my_i'new parserI;
  982.             $this->setContext('my_i');
  983.         }
  984.         if (is_string($word))
  985.         {
  986.             if ($this->checkEventPop($word,$pevent))
  987.             {
  988.                 $this->dropContext();
  989.                 $this->addText($this->p_vars['my_i']);
  990.                 unset($this->p_vars['my_i']);
  991.             else
  992.             {
  993.                 $this->p_vars['my_i']->add($word);
  994.             }
  995.         else $this->p_vars['my_i']->add($word);
  996.     }
  997.     
  998.     /**
  999.      * Handles <<var>><</var>> blocks
  1000.      */
  1001.     function handleVar($word$pevent)
  1002.     {
  1003.         if (!isset($this->p_vars['my_var']))
  1004.         {
  1005.             $this->setContext('my_var');
  1006.             $this->p_vars['my_var'new parserDescVar;
  1007.         }
  1008.         if (is_string($word))
  1009.         {
  1010.             if ($this->checkEventPop($word,$pevent))
  1011.             {
  1012.                 $this->dropContext();
  1013.                 $this->addText($this->p_vars['my_var']);
  1014.                 unset($this->p_vars['my_var']);
  1015.             else
  1016.             {
  1017.                 $this->p_vars['my_var']->add($word);
  1018.             }
  1019.         else $this->p_vars['my_var']->add($word);
  1020.     }
  1021.     
  1022.     /**
  1023.      * Handles <<samp>><</samp>> blocks
  1024.      */
  1025.     function handleSamp($word$pevent)
  1026.     {
  1027.         if (!isset($this->p_vars['my_samp']))
  1028.         {
  1029.             $this->setContext('my_samp');
  1030.             $this->p_vars['my_samp'new parserSamp;
  1031.         }
  1032.         if (is_string($word))
  1033.         {
  1034.             if ($this->checkEventPop($word,$pevent))
  1035.             {
  1036.                 $this->dropContext();
  1037.                 $this->addText($this->p_vars['my_samp']);
  1038.                 unset($this->p_vars['my_samp']);
  1039.             else
  1040.             {
  1041.                 $this->p_vars['my_samp']->add($word);
  1042.             }
  1043.         else $this->p_vars['my_samp']->add($word);
  1044.     }
  1045.     
  1046.     /**
  1047.      * Handles <<kbd>><</kbd>> blocks
  1048.      */
  1049.     function handleKbd($word$pevent)
  1050.     {
  1051.         if (!isset($this->p_vars['my_kbd']))
  1052.         {
  1053.             $this->setContext('my_kbd');
  1054.             $this->p_vars['my_kbd'new parserKbd;
  1055.         }
  1056.         if (is_string($word))
  1057.         {
  1058.             if ($this->checkEventPop($word,$pevent))
  1059.             {
  1060.                 $this->dropContext();
  1061.                 $this->addText($this->p_vars['my_kbd']);
  1062.                 unset($this->p_vars['my_kbd']);
  1063.             else
  1064.             {
  1065.                 $this->p_vars['my_kbd']->add($word);
  1066.             }
  1067.         else $this->p_vars['my_kbd']->add($word);
  1068.     }
  1069.     
  1070.     /**
  1071.      * Handles <<p>><</p>> blocks
  1072.      *
  1073.      * Note that the only time <<p>> will be interpreted as delimiting a
  1074.      * paragraph is if it is the first thing in the description.
  1075.      */
  1076.     function handleP($word$pevent)
  1077.     {
  1078.         if (!isset($this->parse_Ps)) $this->parse_Ps false;
  1079.         if (is_string($word))
  1080.         {
  1081.             if (is_string($word&& $this->checkEventPush($word$pevent)) return;
  1082.         }
  1083.         if (!$this->parse_Ps)
  1084.         {
  1085.             $this->p_vars['event_stack']->popEvent();
  1086.             if (!is_object($word&& strtolower($this->p_vars['last_word']== '<p>'$this->addText('<p>');
  1087.             $this->addText($word);
  1088.             return;
  1089.         }
  1090.         if (is_string($word&& $word == "\n"$word " ";
  1091.         if (is_string($word))
  1092.         {
  1093.             if ($this->checkEventPop($word$pevent))
  1094.             {
  1095.                 $this->p_vars['curpar']++;
  1096.                 return;
  1097.             }
  1098.             // if no closing tag, pretend there was one
  1099.             if (!is_object($word&& strtolower($word== '<p>' && $this->parse_Ps)
  1100.             {
  1101.                 $this->p_vars['curpar']++;
  1102.                 return;
  1103.             }
  1104.         }
  1105.         if ($this->p_vars['start'])
  1106.         {
  1107.             $this->addText($word);
  1108.         else
  1109.         {// if the <p> is not at the beginning of the desc, then it is not
  1110.          // possible to parse into paragraphs using this tag
  1111.             if (is_string($word&& $word == ' ' && $this->p_vars['last_word'== ' 'return;
  1112.             $this->addText($word);
  1113.         }
  1114.     }
  1115.     
  1116.     /**
  1117.      * Handles \n\n as a paragraph marker
  1118.      * @uses doSimpleList()
  1119.      */
  1120.     function handleDoubleCR($word$pevent)
  1121.     {
  1122.         $this->p_vars['event_stack']->popEvent();
  1123.         if ($word == "\n")
  1124.         {
  1125.             // only use this if <p> isn't being used
  1126.             if ((!isset($this->parse_Ps|| !$this->parse_Ps))
  1127.             {
  1128.                 if ($this->p_vars['last_word'== "\n")
  1129.                 {
  1130.                     $this->p_vars['curpar']++;
  1131.                     $this->parse_Ps false;
  1132.                 else
  1133.                 {
  1134.                     if (is_string($word&& !$this->checkEventPush($word$pevent))
  1135.                     {
  1136.                         if ($word == ' ' && $this->p_vars['last_word'== ' 'return;
  1137.                         $this->addText($word);
  1138.                     }
  1139.                 }
  1140.             else
  1141.             {
  1142.                 if (is_string($word&& !$this->checkEventPush($word$pevent))
  1143.                 {
  1144.                     if ($word == ' ' && $this->p_vars['last_word'== ' 'return;
  1145.                     $this->addText($word);
  1146.                 }
  1147.             }
  1148.         else
  1149.         {
  1150.             if ($this->p_vars['last_word'== "\n")
  1151.             {
  1152.                 if ((!isset($this->parse_Ps|| !$this->parse_Ps))
  1153.                 {
  1154.                     $this->addText(' ');
  1155.                 }
  1156.             }
  1157.             if (is_string($word&& !($e $this->checkEventPush($word$pevent)))
  1158.             {
  1159.                 if ($word == ' ' && $this->p_vars['last_word'== ' 'return;
  1160.                 if ($this->doSimpleList($word)) return;
  1161.                 $this->addText($word);
  1162.             }
  1163.         }
  1164.     }
  1165.     
  1166.     /**#@-*/
  1167.     /**
  1168.      * Return a simple list, if found
  1169.      *
  1170.      * This helper function extracts a simple list beginning with any of
  1171.      * 'o','-'.'#','+','0','1','0.','1.' and starts parsing it.
  1172.      * @param string line that may contain a simple list
  1173.      * @return boolean true if a list is found, false otherwise
  1174.      */
  1175.     function doSimpleList($word)
  1176.     {
  1177.         if ($this->p_flags['in_event']return true;
  1178.         if (is_object($word)) return false;
  1179.         $ltrimword ltrim($word);
  1180.         if ((strlen($ltrimword!= strlen($word))
  1181.              && strlen($ltrimword1
  1182.              && ((in_array($ltrimword{0},array('o','-','1','0','#','+')) && $ltrimword{1== ' '))
  1183.                  || ((strlen($ltrimword>= 2&& (substr($ltrimword,0,2=== '1.' || substr($ltrimword,0,2=== '0.'&& $ltrimword{2== ' '))
  1184.         {
  1185.             // save the whitespace for comparison
  1186.             $this->p_vars['whitespace'substr($word,0,strlen($wordstrlen($ltrimword));
  1187.             $this->p_vars['start_list'$ltrimword{0};
  1188.             if ($this->p_vars['start_list'!= '1' && $this->p_vars['start_list'!= '1.' &&
  1189.                 $this->p_vars['start_list'!= '0' && $this->p_vars['start_list'!= '0.')
  1190.             {
  1191.                 $this->p_flags['orderedlist'false;
  1192.             else
  1193.             {
  1194.                 if (substr($ltrimword,0,2== '1.')
  1195.                 {
  1196.                     $this->p_vars['start_list''1.';
  1197.                 }
  1198.                 $this->p_flags['orderedlist'true;
  1199.             }
  1200.             $this->p_vars['event_stack']->pushEvent(PHPDOCUMENTOR_PDP_EVENT_SIMLIST);
  1201.             $this->setContext('list');
  1202.             $this->p_flags['simplelist'true;
  1203.             $this->p_vars['lists'][0new parserList($this->p_flags['orderedlist']);
  1204.             $this->p_vars['list_count'0;
  1205.             $this->handleSimpleList($wordPHPDOCUMENTOR_PDP_EVENT_SIMLISTtrue);
  1206.             return true;
  1207.         }
  1208.         return false;
  1209.     }
  1210.     /**
  1211.     * setup the parser tokens, and the pushEvent/popEvent arrays
  1212.     * @see $tokens, $pushEvent, $popEvent
  1213.     * @param boolean determines whether to allow paragraph parsing
  1214.     * @global boolean used to determine whether to slow things down or not by
  1215.     *  eliminating whitespace from comments
  1216.     */
  1217.     
  1218.     function setupStates($sdesc)
  1219.     {
  1220.         $this->p_flags['in_item'false;
  1221.         $this->p_flags['in_event'false;
  1222.         $this->p_flags['simplelist'false;
  1223.         $this->_context array('normal');
  1224.         $this->tokens[STATE_NOEVENTS]            array("\n""<code>""<pre>""<ol>""<ul>"
  1225.                                                          "<b>""<i>"'<var>''<kbd>''<samp>'"<br"'<<');
  1226.         if (!$sdesc)
  1227.         {
  1228.             $this->tokens[STATE_NOEVENTS]["<p>";
  1229.             $this->tokens[STATE_NOEVENTS]["</p>";
  1230.         }
  1231.         if (PHPDOCUMENTOR_KILL_WHITESPACE$this->tokens[STATE_NOEVENTS][' ';
  1232.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_P]        array("</p>","<code>","<pre>","\n","<ol>","<ul>","<b>","<i>","<br","<p>"'<<',
  1233.                                                                 '<var>''<kbd>''<samp>');
  1234.         if (PHPDOCUMENTOR_KILL_WHITESPACE$this->tokens[PHPDOCUMENTOR_PDP_STATE_P][' ';
  1235.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_CODE]        array("</code>"'<</code>>');
  1236.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_PRE]        array("</pre>"'<</pre>>');
  1237.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_LIST]        array("<ul>","<ol>","</ul>","</ol>","<li>","</li>","<b>","<i>","<br"'<<',"<code>","<pre>","<br",
  1238.                                                                    '<var>''<kbd>''<samp>');
  1239.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_DOUBLECR]        array("\n","<ol>","<ul>","<code>","<pre>","<b>","<i>","<br","<p>","</p>",
  1240.                                                                        '<var>''<kbd>''<samp>''<<');
  1241.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_SIMLIST]      array("\n",'<var>''<kbd>''<samp>','<b>','<i>''<pre>''<code>',
  1242.                                                                     '<br''<<');
  1243.  
  1244.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_B]    array("<code>","\n","<pre>","<ol>","<ul>","</b>","<i>","<br"'<<',
  1245.                                                             '<var>''<kbd>''<samp>');
  1246.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_KBD]    array("<code>","\n","<pre>","<ol>","<ul>","<b>","<i>","<br"'<<',
  1247.                                                             '<var>''</kbd>''<samp>');
  1248.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_VAR]    array("<code>","\n","<pre>","<ol>","<ul>","<b>","<i>","<br"'<<',
  1249.                                                             '</var>''<kbd>''<samp>');
  1250.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_SAMP]    array("<code>","\n","<pre>","<ol>","<ul>","<b>","<i>","<br"'<<',
  1251.                                                             '<var>''<kbd>''</samp>');
  1252.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_I]    array("<code>","\n","<pre>","<ol>","<ul>","<b>","</i>","<br"'<<',
  1253.                                                             '<var>''<kbd>''<samp>');
  1254.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_BR]    array(">","/>");
  1255.         $this->tokens[PHPDOCUMENTOR_PDP_STATE_ESCAPE]    array('code>>''/code>>''pre>>''/pre>>''b>>''/b>>'
  1256.                                                                  'i>>''/i>>''ol>>''/ol>>''ul>>''/ul>>''li>>''/li>>'
  1257.                                                                  'br>>''br />>''p>>''/p>>''samp>>''/samp>>'
  1258.                                                                  'kbd>>''/kbd>>''var>>''/var>>')
  1259.         if (PHPDOCUMENTOR_KILL_WHITESPACE$this->tokens[PHPDOCUMENTOR_PDP_STATE_DOUBLECR][' ';
  1260.  
  1261.         // For each event word to event mapings
  1262.         $this->pushEvent[PARSER_EVENT_NOEVENTS
  1263.             array(
  1264.                 "<code>"    => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1265.                 "<pre>"    => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1266.                 "<p>" => PHPDOCUMENTOR_PDP_EVENT_P,
  1267.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1268.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1269.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1270.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1271.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1272.                 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
  1273.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1274.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1275.                 "\n" => PHPDOCUMENTOR_PDP_EVENT_DOUBLECR,
  1276.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1277.             );
  1278. ##########################
  1279.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_CODE=
  1280.             array(
  1281.                 '<</code>>' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE,
  1282.             );
  1283.          
  1284.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_CODEarray("</code>");
  1285. ##########################
  1286.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_PRE=
  1287.             array(
  1288.                 '<</pre>>' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE,
  1289.             );
  1290.          
  1291.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_PREarray("</pre>");
  1292. ##########################
  1293.          
  1294.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_BRarray(">","/>");
  1295. ##########################
  1296.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_P=
  1297.             array(
  1298.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1299.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1300.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1301.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1302.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1303.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1304.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1305.                 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
  1306.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1307.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1308.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1309.             );
  1310.          
  1311.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_Parray("</p>");
  1312. ##########################
  1313.         
  1314.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_LIST=
  1315.             array(
  1316.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1317.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1318.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1319.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1320.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1321.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1322.                 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
  1323.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1324.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1325.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1326.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1327.             );
  1328.         
  1329.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_LISTarray("</ul>","</ol>");
  1330. ##########################
  1331.  
  1332.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_SIMLIST
  1333.             array(
  1334.                 "<code>"    => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1335.                 "<pre>"    => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1336.                 "<p>" => PHPDOCUMENTOR_PDP_EVENT_P,
  1337.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1338.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1339.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1340.                 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
  1341.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1342.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1343.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1344.             );
  1345. ##########################
  1346.         
  1347.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_DOUBLECR=
  1348.             array(
  1349.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1350.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1351.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1352.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1353.                 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
  1354.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1355.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1356.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1357.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1358.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1359.                 "<p>" => PHPDOCUMENTOR_PDP_EVENT_P,
  1360.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1361.             );
  1362.         
  1363. ##########################
  1364.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_B=
  1365.             array(
  1366.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1367.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1368.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1369.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1370.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1371.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1372.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1373.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1374.                 '<i>' => PHPDOCUMENTOR_PDP_EVENT_I,
  1375.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1376.             );
  1377.          
  1378.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_Barray("</b>");
  1379.  
  1380. ##########################
  1381.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_I=
  1382.             array(
  1383.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1384.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1385.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1386.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1387.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1388.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1389.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1390.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1391.                 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
  1392.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1393.             );
  1394.          
  1395.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_Iarray("</i>");
  1396.  
  1397. ##########################
  1398.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_VAR=
  1399.             array(
  1400.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1401.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1402.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1403.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1404.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1405.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1406.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1407.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1408.                 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
  1409.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1410.             );
  1411.          
  1412.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_VARarray("</var>");
  1413.  
  1414. ##########################
  1415.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_SAMP=
  1416.             array(
  1417.                 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1418.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1419.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1420.                 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1421.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1422.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1423.                 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
  1424.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1425.                 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
  1426.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1427.             );
  1428.          
  1429.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_SAMParray("</samp>");
  1430.  
  1431. ##########################
  1432.         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_KBD=
  1433.             array(
  1434.                 "<code" => PHPDOCUMENTOR_PDP_EVENT_CODE,
  1435.                 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1436.                 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
  1437.                 "<pre" => PHPDOCUMENTOR_PDP_EVENT_PRE,
  1438.                 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
  1439.                 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
  1440.                 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
  1441.                 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
  1442.                 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
  1443.                 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
  1444.             );
  1445.          
  1446.         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_KBDarray("</kbd>");
  1447.     }
  1448.     
  1449.     function getParserEventName ($value)
  1450.     {    
  1451.         $lookup array(
  1452.             PARSER_EVENT_NOEVENTS         => "PARSER_EVENT_NOEVENTS",
  1453.             PHPDOCUMENTOR_PDP_EVENT_CODE        => "PHPDOCUMENTOR_PDP_EVENT_CODE",
  1454.             PHPDOCUMENTOR_PDP_EVENT_P        => "PHPDOCUMENTOR_PDP_EVENT_P",
  1455.             PHPDOCUMENTOR_PDP_EVENT_B        => "PHPDOCUMENTOR_PDP_EVENT_B",
  1456.             PHPDOCUMENTOR_PDP_EVENT_I        => "PHPDOCUMENTOR_PDP_EVENT_I",
  1457.             PHPDOCUMENTOR_PDP_EVENT_BR        => "PHPDOCUMENTOR_PDP_EVENT_BR",
  1458.             PHPDOCUMENTOR_PDP_EVENT_VAR        => "PHPDOCUMENTOR_PDP_EVENT_VAR",
  1459.             PHPDOCUMENTOR_PDP_EVENT_SAMP        => "PHPDOCUMENTOR_PDP_EVENT_SAMP",
  1460.             PHPDOCUMENTOR_PDP_EVENT_KBD        => "PHPDOCUMENTOR_PDP_EVENT_KBD",
  1461.             PHPDOCUMENTOR_PDP_EVENT_ESCAPE        => "PHPDOCUMENTOR_PDP_EVENT_ESCAPE",
  1462.             PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE        => "PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE",
  1463.             PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE        => "PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE",
  1464.             PHPDOCUMENTOR_PDP_EVENT_DOUBLECR        => "PHPDOCUMENTOR_PDP_EVENT_DOUBLECR",
  1465.             PHPDOCUMENTOR_PDP_EVENT_LIST    => "PHPDOCUMENTOR_PDP_EVENT_LIST",
  1466.             PHPDOCUMENTOR_PDP_EVENT_PRE => "PHPDOCUMENTOR_PDP_EVENT_PRE",
  1467.             PHPDOCUMENTOR_PDP_EVENT_SIMLIST => "PHPDOCUMENTOR_PDP_EVENT_SIMLIST",
  1468.         );
  1469.         if (isset($lookup[$value]))
  1470.         return $lookup[$value];
  1471.         else return $value;
  1472.     }
  1473. }
  1474.  
  1475. ?>

Documentation generated on Tue, 24 Oct 2006 09:24:58 -0500 by phpDocumentor 1.3.1