595d169aa5855fd65419c66cf87625449d429f73
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / XMLpackagePageParser.inc
1 <?php\r
2 /**\r
3  * Parser for XML DocBook-based phpDocumentor tutorials\r
4  * \r
5  * phpDocumentor :: automatic documentation generator\r
6  * \r
7  * PHP versions 4 and 5\r
8  *\r
9  * Copyright (c) 2002-2007 Gregory Beaver\r
10  * \r
11  * LICENSE:\r
12  * \r
13  * This library is free software; you can redistribute it\r
14  * and/or modify it under the terms of the GNU Lesser General\r
15  * Public License as published by the Free Software Foundation;\r
16  * either version 2.1 of the License, or (at your option) any\r
17  * later version.\r
18  * \r
19  * This library is distributed in the hope that it will be useful,\r
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
22  * Lesser General Public License for more details.\r
23  * \r
24  * You should have received a copy of the GNU Lesser General Public\r
25  * License along with this library; if not, write to the Free Software\r
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
27  *\r
28  * @category   ToolsAndUtilities\r
29  * @package    phpDocumentor\r
30  * @subpackage Parsers\r
31  * @author     Gregory Beaver <cellog@php.net>\r
32  * @copyright  2002-2007 Gregory Beaver\r
33  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL\r
34  * @version    CVS: $Id: XMLpackagePageParser.inc,v 1.14 2007/11/14 01:31:24 ashnazg Exp $\r
35  * @tutorial   tutorials.pkg\r
36  * @link       http://www.phpdoc.org\r
37  * @link       http://pear.php.net/PhpDocumentor\r
38  * @since      1.2\r
39  * @todo       CS cleanup - change package to PhpDocumentor\r
40  * @todo       CS cleanup - PHPCS needs to ignore CVS Id length\r
41  */\r
42 /**\r
43  * when <programlisting> is found\r
44  */\r
45 define('PHPDOCUMENTOR_PDP_EVENT_PROGRAMLISTING', 600);\r
46 /**\r
47  * when <programlisting> is found\r
48  */\r
49 define('PHPDOCUMENTOR_PDP_STATE_PROGRAMLISTING', 700);\r
50 /**\r
51  * when a DocBook <tag> is found\r
52  */\r
53 define('PHPDOCUMENTOR_PDP_EVENT_TAG', 601);\r
54 /**\r
55  * when a DocBook <tag> is found\r
56  */\r
57 define('PHPDOCUMENTOR_PDP_STATE_TAG', 701);\r
58 /**\r
59  * when <![CDATA[ ]]> is found\r
60  */\r
61 define('PHPDOCUMENTOR_PDP_EVENT_CDATA', 602);\r
62 /**\r
63  * when <![CDATA[ ]]> is found\r
64  */\r
65 define('PHPDOCUMENTOR_PDP_STATE_CDATA', 702);\r
66 /**\r
67  * when tag attributes name="value" are found\r
68  */\r
69 define('PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES', 603);\r
70 /**\r
71  * when tag attributes name="value" are found\r
72  */\r
73 define('PHPDOCUMENTOR_PDP_STATE_ATTRIBUTES', 703);\r
74 /**\r
75  * when tag attributes name="value" are found\r
76  */\r
77 define('PHPDOCUMENTOR_PDP_EVENT_ENTITY', 604);\r
78 /**\r
79  * when tag attributes name="value" are found\r
80  */\r
81 define('PHPDOCUMENTOR_PDP_STATE_ENTITY', 704);\r
82 \r
83 /**\r
84  * Used to parse XML DocBook-based tutorials\r
85  *\r
86  * @category   ToolsAndUtilities\r
87  * @package    phpDocumentor\r
88  * @subpackage Parsers\r
89  * @author     Gregory Beaver <cellog@php.net>\r
90  * @copyright  2002-2007 Gregory Beaver\r
91  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL\r
92  * @version    Release: 1.4.1\r
93  * @link       http://www.phpdoc.org\r
94  * @link       http://pear.php.net/PhpDocumentor\r
95  * @since      1.2\r
96  * @todo       CS cleanup - change package to PhpDocumentor\r
97  */\r
98 class XMLPackagePageParser extends Parser\r
99 {\r
100     /**\r
101      * @var array\r
102      */\r
103     var $eventHandlers = array(\r
104         PHPDOCUMENTOR_PDP_EVENT_TAG => 'handleTag',\r
105         PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES => 'handleAttributes',\r
106         PHPDOCUMENTOR_PDP_EVENT_CDATA => 'handleCData',\r
107         PARSER_EVENT_NOEVENTS => 'defaultHandler',\r
108         PARSER_EVENT_COMMENTBLOCK => 'ignoreHandler',\r
109         PARSER_EVENT_OUTPHP => 'ignoreHandler',\r
110         PARSER_EVENT_QUOTE => 'handleQuote',\r
111         PHPDOCUMENTOR_PDP_EVENT_ENTITY => 'handleEntity',\r
112     );\r
113     \r
114     /**\r
115      * @var array\r
116      */\r
117     var $pars = array();\r
118     \r
119     var $refsect1id = false;\r
120     var $refsect2id = false;\r
121     var $refsect3id = false;\r
122     /**\r
123      * @var array the tag stack\r
124      */\r
125     var $context;\r
126     /**#@+ @access private */\r
127     var $_gettoc = false;\r
128     var $_toc = array();\r
129     var $_cursection = 0;\r
130     /**#@-*/\r
131     /**\r
132      * Set up the wordparser\r
133      *\r
134      * {@source}\r
135      *\r
136      * @uses ObjectWordParser\r
137      */\r
138     function XMLPackagePageParser()\r
139     {\r
140         $this->wp = new ObjectWordParser(true);\r
141     }\r
142     /**\r
143      * Parse a new file\r
144      *\r
145      * @param string $parse_data the parse data\r
146      * @param array  $tutorial   for format, see {@link Io::getTutorials()}\r
147      *\r
148      * @return bool\r
149      * @staticvar integer used for recursion limiting \r
150      *            if a handler for an event is not found\r
151      * @uses parserTutorial using {@link Publisher::PublishEvent()}, a new tutorial\r
152      *                      is created from the file parsed, and passed to the\r
153      *                      Intermediate Parser\r
154      */\r
155     function parse ($parse_data, $tutorial)\r
156     {\r
157         $tempparse  = new ppageParser;\r
158         $parse_data = $tempparse->\r
159             parse($parse_data, true, $tutorial['package'], \r
160                 $tutorial['subpackage'], basename($tutorial['path']), \r
161                 $tutorial['category'], $tutorial['path']);\r
162         unset($tempparse);\r
163         static $endrecur = 0;\r
164         if (!is_array($parse_data) || count($parse_data) == 0) {\r
165             return false;\r
166         }\r
167         $this->setupStates();\r
168 \r
169         // initialize variables so E_ALL error_reporting doesn't complain\r
170         $pevent                      = 0;\r
171         $word                        = 0;\r
172         $this->p_vars['start']       = true;\r
173         $this->p_vars['event_stack'] = new EventStack;\r
174 \r
175         $this->wp->setup($parse_data, false);\r
176         $this->wp->setWhitespace(true);\r
177         $this->context = array();\r
178         if (isset($this->curtag)) {\r
179             unset($this->curtag);\r
180         }\r
181 \r
182         do {\r
183             $lpevent = $pevent;\r
184             $pevent  = $this->p_vars['event_stack']->getEvent();\r
185             if ($lpevent != $pevent) {\r
186                 $this->p_vars['last_pevent'] = $lpevent;\r
187             }\r
188 \r
189             if ($this->p_vars['last_pevent'] != $pevent) {\r
190                 // its a new event so the word parser needs to be reconfigured \r
191                 $this->configWordParser($pevent);\r
192             }\r
193 \r
194 \r
195             $this->p_vars['last_word'] = $word;\r
196             $word                      = $this->wp->getWord();\r
197 \r
198             if (PHPDOCUMENTOR_DEBUG == true) {\r
199                 echo "----------------\n";\r
200                 echo "LAST: |" . $this->p_vars['last_word'] . "|\n";\r
201                 echo "INDEX: ".$this->p_vars['curpar']."\n";\r
202                 echo "PEVENT: " . $this->getParserEventName($pevent) . "\n";\r
203                 echo "LASTPEVENT: " . \r
204                     $this->getParserEventName($this->p_vars['last_pevent']) . "\n";\r
205                 echo $this->wp->getPos() . " WORD: |$word|\n\n";\r
206                 echo '"'.$this->p_vars['quote_data']."\"\n";\r
207             }\r
208             if (isset($this->eventHandlers[$pevent])) {\r
209                 $handle = $this->eventHandlers[$pevent];\r
210                 if ($word !== false) {\r
211                     $this->$handle($word, $pevent);\r
212                 }\r
213             } else {\r
214                 debug('WARNING: possible error, ' .\r
215                     'no XMLPackagePageParser handler for event number '. $pevent);\r
216                 if ($endrecur++ == 25) {\r
217                     die("FATAL ERROR, recursion limit reached");\r
218                 }\r
219             }\r
220             $this->p_vars['start'] = false;\r
221         } while (!($word === false));\r
222         if (count($this->_toc) && isset($this->p_vars['toc'])) {\r
223             $a = $this->curtag->getTOC($this->p_vars['toc']);\r
224             $a->setTOC($this->_toc);\r
225             $a->setPath($tutorial['path']);\r
226             $this->curtag->setTOC($this->p_vars['toc'], $a);\r
227         }\r
228         $this->PublishEvent(PHPDOCUMENTOR_EVENT_TUTORIAL, \r
229             new parserTutorial($this->curtag, $tutorial));\r
230         return $this->curtag;\r
231     }\r
232     \r
233     /**#@+\r
234      * @param string|parserInlineTag $word  token\r
235      * @param integer                $token parser event\r
236      * @return void\r
237      * @access private\r
238      * @todo CS cleanup - PHPCS needs to recognize docblock template tags\r
239      */\r
240     /**\r
241      * handler for default events\r
242      */\r
243     function defaultHandler($word, $pevent)\r
244     {\r
245         if (is_string($word) && $this->checkEventPush($word, $pevent)) {\r
246             return;\r
247         }\r
248     }\r
249     \r
250     /**\r
251      * handler for ignore events\r
252      */\r
253     function ignoreHandler($word, $pevent)\r
254     {\r
255         $this->checkEventPop($word, $pevent);\r
256     }\r
257     \r
258     /**\r
259      * handler for QUOTE\r
260      *\r
261      * this handler recognizes strings defined with \r
262      * double quotation marks (") and handles them correctly\r
263      * in any place that they legally appear in php code\r
264      */\r
265     function handleQuote($word, $pevent)\r
266     {\r
267         if ($this->p_flags['reset_quote_data'] === true) {\r
268             $this->p_flags['reset_quote_data'] = false;\r
269             $this->p_vars['quote_data']        = "";\r
270         }\r
271         if (!is_object($word)) {\r
272             $this->checkEventPush($word, $pevent);\r
273         }\r
274         if (is_object($word)) {\r
275             $this->p_vars['quote_data'] = $word;\r
276         } else {\r
277             if ($word != "\"") {\r
278                 if (!is_object($this->p_vars['quote_data'])) {\r
279                     $this->p_vars['quote_data'] .= $word;\r
280                 }\r
281             }\r
282             if ($word == '>') {\r
283                 if (is_object($this->p_vars['quote_data'])) {\r
284                     $this->p_vars['quote_data'] = \r
285                         '{@id '.$this->p_vars['quote_data']->id.'}';\r
286                 }\r
287                 addErrorDie(PDERROR_UNTERMINATED_ATTRIB, $this->curtag->name, \r
288                     $this->p_vars['attrname'], $this->p_vars['quote_data']);\r
289             }\r
290             if ($this->checkEventPop($word, $pevent)) {\r
291                 $this->p_flags['reset_quote_data'] = true;\r
292             }\r
293         }\r
294     }\r
295     \r
296     /**\r
297      * Handles all XML DocBook tags\r
298      *\r
299      * @todo replace commented-out debug lines with debug() func\r
300      */\r
301     function handleTag($word, $pevent)\r
302     {\r
303         if (isset($this->curtag) && $this->curtag->hasTitle() && \r
304             $this->_gettoc && $this->_gettoc->name == $this->curtag->name\r
305         ) {\r
306             if (isset($this->_toc[$this->_cursection])) {\r
307                 $this->_toc[$this->_cursection]['title'] = $this->curtag->_title;\r
308                 $this->_cursection++;\r
309             }\r
310             $this->_gettoc = false;\r
311         }\r
312         if ($this->p_vars['last_word'] == '<') {\r
313             // get tag name\r
314             $this->p_flags['begin_tag'] = true;\r
315             array_push($this->context, $word);\r
316             //DEBUG if (isset($this->curtag)) debug("pushed " . $this->curtag->name);\r
317             if (isset($this->curtag)) {\r
318                 array_push($this->pars, $this->curtag);\r
319             }\r
320             $this->curtag = new parserXMLDocBookTag($word);\r
321         } elseif ($this->p_vars['last_word'] == '</' || $word == '/>') {\r
322             $tag = array_pop($this->context);\r
323             if ($word == '/>') {\r
324                 // all is OK\r
325                 $this->checkEventPop($word, $pevent);\r
326                 $word = $tag;\r
327             }\r
328             if ($tag != $word) {\r
329                 addErrorDie(PDERROR_UNMATCHED_TUTORIAL_TAG, \r
330                     $tag, $word, $this->curtag->getString());\r
331             }\r
332             if (in_array($this->curtag->name, \r
333                 array('refentry', 'refsect1', 'refsect2', 'refsect3'))\r
334             ) {\r
335                 if (!isset($this->curtag->_id)) {\r
336                     $title = '';\r
337                     if (isset($this->curtag->_title)) {\r
338                         $title = $this->curtag->_title->getString();\r
339                     }\r
340                     addWarning(PDERROR_NO_DOCBOOK_ID, $this->curtag->name, $title);\r
341                 }\r
342             }\r
343             $this->p_flags['begin_tag'] = false;\r
344             $curtag                     = @array_pop($this->pars);\r
345             //DEBUG debug("popped $tag ".$curtag->name.' I am '.$this->curtag->name);\r
346             if ($curtag) {\r
347                 if ($this->curtag->name == 'refsect1') $this->refsect1id = false;\r
348                 if ($this->curtag->name == 'refsect2') $this->refsect2id = false;\r
349                 if ($this->curtag->name == 'refsect3') $this->refsect3id = false;\r
350                 $curtag->add($this->curtag);\r
351                 //DEBUG debug("added " . $this->curtag->name . \r
352                 //DEBUG     " to " . $curtag->name . ' ' . $curtag->id);\r
353                 $this->curtag = $curtag;\r
354             } else {\r
355                 //DEBUG debug("here");\r
356             }\r
357         } elseif (is_string($word)) {\r
358             if (!($e = $this->checkEventPush($word, $pevent))) {\r
359                 if ($this->checkEventPop($word, $pevent)) {\r
360                     if ($this->p_flags['begin_tag']) {\r
361                         $this->p_vars['event_stack']->\r
362                             pushEvent(PHPDOCUMENTOR_PDP_EVENT_TAG);\r
363                         $this->p_vars['event_stack']->\r
364                             pushEvent(PHPDOCUMENTOR_PDP_EVENT_CDATA);\r
365                         $this->p_vars['last_tag'] = array_pop($this->context);\r
366                         array_push($this->context, $this->p_vars['last_tag']);\r
367                         $this->p_flags['in_cdata'] = false;\r
368                     }\r
369                     return;\r
370                 }\r
371             } else {\r
372                 $this->p_flags['start_attr'] = true;\r
373                 $this->p_flags['end_attr']   = false;\r
374             }\r
375         } else {\r
376             addErrorDie(PDERROR_CANT_HAVE_INLINE_IN_TAGNAME);\r
377         }\r
378     }\r
379     \r
380     /**\r
381      * Handle CData sections\r
382      */\r
383     function handleCData($word, $pevent)\r
384     {\r
385         if ($this->curtag->name == 'refentry' && \r
386             phpDocumentor_get_class($word) == 'parsertocinlinetag'\r
387         ) {\r
388             $this->p_vars['toc'] = $this->curtag->getTOC();\r
389         }\r
390         if (is_string($word) && !$this->p_flags['in_cdata']) {\r
391             if ($this->checkEventPop($word, $pevent)) {\r
392                 return;\r
393             }\r
394             if ($this->checkEventPush($word, $pevent)) {\r
395                 return;\r
396             }\r
397         }\r
398         if (is_string($word) && $word == '<![CDATA[') {\r
399             $this->curtag->startCData();\r
400             $this->p_flags['in_cdata'] = true;\r
401         } elseif ($this->p_flags['in_cdata'] && \r
402             is_string($word) && $word == ']]>'\r
403         ) {\r
404             $this->curtag->endCData();\r
405             $this->p_flags['in_cdata'] = false;\r
406         } else {\r
407             if ($this->p_flags['in_cdata']) {\r
408                 $this->curtag->addCData($word);\r
409             } else {\r
410                 $this->curtag->add($word);\r
411             }\r
412         }\r
413     }\r
414     \r
415     /**\r
416      * Handle Entities like &rdquo;\r
417      */\r
418     function handleEntity($word, $pevent)\r
419     {\r
420         if (!$word) {\r
421             if (!isset($this->p_vars['entity_name'])) {\r
422                 $this->p_vars['entity_name'] = '';\r
423             }\r
424             addErrorDie(PDERROR_UNTERMINATED_ENTITY, $this->p_vars['entity_name']);\r
425         }\r
426         $e = $this->checkEventPop($word, $pevent);\r
427         if ($word && !$e) { \r
428             $this->p_vars['entity_name'] = $word;\r
429         }\r
430         if ($e) {\r
431             $entity = new parserEntity($this->p_vars['entity_name']);\r
432             unset($this->p_vars['entity_name']);\r
433             $this->curtag->add($entity);\r
434         }\r
435     }\r
436     \r
437     /**\r
438      * Handle Tag attributes name="value"\r
439      *\r
440      * @todo replace commented-out debug lines with debug() func\r
441      */\r
442     function handleAttributes($word, $pevent)\r
443     {\r
444         if ($this->checkEventPush($word, $pevent)) {\r
445             return;\r
446         }\r
447         if ($word == '=') {\r
448             $this->p_flags['start_attr'] = false;\r
449             $this->p_vars['end_attr']    = true;\r
450         } else {\r
451             if ($this->p_flags['start_attr']) {\r
452                 $this->p_vars['attrname'] = $word;\r
453             } else {\r
454                 if (isset($this->p_vars['attrname'])) {\r
455                     $value = $this->p_vars['quote_data'];\r
456                     if (phpDocumentor_get_class($value) == 'parseridinlinetag') { \r
457                         // "inherit" the parent section's id, so\r
458 \r
459                         // <!-- id is 'test' -->\r
460                         // <refsect1 id="{@id test"}> \r
461                         // ...\r
462                         //  <!-- id is 'test.me' -->\r
463                         //  <refsect2 id="{@id me}"> \r
464                         //  ...\r
465                         //   <!-- id is 'test.me.out' -->\r
466                         //   <refsect3 id="{@id out}"> \r
467                         //   ...\r
468                         //    <!-- id is 'test.me.out.withexample' -->\r
469                         //    <example id="{@id withexample}"> \r
470 \r
471                         $a  = ($this->refsect1id ? $this->refsect1id . '.' : '');\r
472                         $a .= ($this->refsect2id ? $this->refsect2id . '.' : '');\r
473                         $a .= ($this->refsect3id ? $this->refsect3id . '.' : '');\r
474                         if ($this->curtag->name == 'refsect1') {\r
475                             $this->refsect1id = $value->id;\r
476                         }\r
477                         if ($this->curtag->name == 'refsect2') {\r
478                             $this->refsect2id = $value->id;\r
479                         }\r
480                         if ($this->curtag->name == 'refsect3') {\r
481                             $this->refsect3id = $value->id;\r
482                         }\r
483                         //DEBUG debug($value->id . ' is now ' . $a . $value->id);\r
484                         $value->id = $a . $value->id;\r
485                         if ($value->id != '') {\r
486                             if (isset($this->_toc[$this->_cursection])) {\r
487                                 $this->_cursection++;\r
488                             }\r
489                             $this->_toc[$this->_cursection]['id']  = $value;\r
490                             $this->_toc[$this->_cursection]['tag'] = \r
491                                 new parserXMLDocBookTag($this->curtag->name);\r
492                             //DEBUG debug("set gettoc to " . $this->curtag->name . \r
493                             //DEBUG     ' ' . $value->id);\r
494                             $this->_gettoc = $this->curtag;\r
495                         }\r
496                     }\r
497                     $this->curtag->addAttribute($this->p_vars['attrname'], $value);\r
498                     unset($this->p_vars['attrname']);\r
499                     if (is_string($word) && $this->checkEventPop($word, $pevent)) {\r
500                         $this->p_flags['start_attr'] = true;\r
501                         $this->p_flags['end_attr']   = false;\r
502                         $this->wp->setPos($this->wp->getPos() - strlen($word));\r
503                     } else {\r
504                         $this->wp->setPos($this->wp->getPos() - strlen($word));\r
505                     }\r
506                     return;\r
507                 }\r
508             }\r
509         }\r
510         if (is_string($word) && $this->checkEventPop($word, $pevent)) {\r
511             $this->p_flags['start_attr'] = true;\r
512             $this->p_flags['end_attr']   = false;\r
513             $this->wp->setPos($this->wp->getPos() - strlen($word));\r
514         }\r
515     }\r
516     /**#@-*/\r
517     \r
518     /**\r
519      * setup the parser tokens, and the pushEvent/popEvent arrays\r
520      *\r
521      * @return void\r
522      * @see $tokens, $pushEvent, $popEvent\r
523      */\r
524     function setupStates()\r
525     {\r
526         $this->_gettoc     = false;\r
527         $this->_toc        = array();\r
528         $this->_cursection = 0;\r
529         if (isset($this->p_vars['toc'])) {\r
530             unset($this->p_vars['toc']);\r
531         }\r
532         \r
533         $this->tokens[STATE_NOEVENTS]\r
534             = array('</','<!--','<!','<?','<');\r
535         $this->tokens[STATE_COMMENTBLOCK]\r
536             = array('-->');\r
537         $this->tokens[STATE_OUTPHP]\r
538             = array('?>','>');\r
539         $this->tokens[STATE_QUOTE]\r
540             = array("\\\"","\\\\","\"",'>');\r
541         $this->tokens[STATE_ESCAPE]\r
542             = false;// this tells the word parser to just cycle\r
543         $this->tokens[PHPDOCUMENTOR_PDP_STATE_TAG]\r
544             = array('>',' ','/>');\r
545         $this->tokens[PHPDOCUMENTOR_PDP_STATE_CDATA]\r
546             = array('&','<!--','</','<![CDATA[','<',']]>');\r
547         $this->tokens[PHPDOCUMENTOR_PDP_STATE_ATTRIBUTES]\r
548             = array('=','>','/>','"');\r
549         $this->tokens[PHPDOCUMENTOR_PDP_STATE_ENTITY]\r
550             = array(';');\r
551 \r
552         // For each event word to event mapings\r
553         $this->pushEvent[PARSER_EVENT_NOEVENTS] = \r
554             array(\r
555                 '<!--' => PARSER_EVENT_COMMENTBLOCK,\r
556                 '<!' => PARSER_EVENT_OUTPHP,\r
557                 "</" => PHPDOCUMENTOR_PDP_EVENT_TAG,\r
558                 '<?' => PARSER_EVENT_OUTPHP,\r
559                 "<" => PHPDOCUMENTOR_PDP_EVENT_TAG,\r
560                 '&' => PHPDOCUMENTOR_PDP_EVENT_ENTITY,\r
561             );\r
562         //##########################\r
563 \r
564         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_TAG] =\r
565             array(\r
566                 ' ' => PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES,\r
567             );\r
568          \r
569         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_TAG] = array(">","/>");\r
570         //##########################\r
571         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES] =\r
572             array(\r
573                 '"' => PARSER_EVENT_QUOTE,\r
574             );\r
575 \r
576         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES] = array(">","/>");\r
577         //##########################\r
578 \r
579         $this->popEvent[PARSER_EVENT_COMMENTBLOCK] = array("-->");\r
580         //##########################\r
581         $this->pushEvent[PARSER_EVENT_QUOTE] = \r
582             array(\r
583                 "\\"    => PARSER_EVENT_ESCAPE\r
584             );\r
585         $this->popEvent[PARSER_EVENT_QUOTE]  = array("\"");\r
586         //##########################\r
587 \r
588         $this->popEvent[PARSER_EVENT_OUTPHP] = array("?>",">");\r
589         //##########################\r
590 \r
591         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_ENTITY] = array(";");\r
592         //##########################\r
593 \r
594         $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_CDATA] =\r
595             array(\r
596                 "<" => PHPDOCUMENTOR_PDP_EVENT_TAG,\r
597                 '<!--' => PARSER_EVENT_COMMENTBLOCK,\r
598                 '<?' => PARSER_EVENT_OUTPHP,\r
599                 '&' => PHPDOCUMENTOR_PDP_EVENT_ENTITY,\r
600             );\r
601         $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_CDATA]  = array("</");\r
602     }\r
603     \r
604     /**\r
605      * debugging function\r
606      *\r
607      * {@source}\r
608      *\r
609      * @param mixed $value a value\r
610      *\r
611      * @return mixed the looked up value if found,\r
612      *               else the original value\r
613      * @static\r
614      */\r
615     function getParserEventName ($value)\r
616     {    \r
617         $lookup = array(\r
618             PARSER_EVENT_NOEVENTS\r
619                 => "PARSER_EVENT_NOEVENTS",\r
620             PHPDOCUMENTOR_PDP_EVENT_TAG\r
621                 => "PHPDOCUMENTOR_PDP_EVENT_TAG",\r
622             PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES\r
623                 => "PHPDOCUMENTOR_PDP_EVENT_ATTRIBUTES",\r
624             PHPDOCUMENTOR_PDP_EVENT_CDATA\r
625                 => "PHPDOCUMENTOR_PDP_EVENT_CDATA",\r
626             PHPDOCUMENTOR_PDP_EVENT_LIST\r
627                 => "PHPDOCUMENTOR_PDP_EVENT_LIST",\r
628             PARSER_EVENT_QUOTE\r
629                 => "PARSER_EVENT_QUOTE",\r
630             PHPDOCUMENTOR_PDP_EVENT_ENTITY\r
631                 => "PHPDOCUMENTOR_PDP_EVENT_ENTITY",\r
632             PHPDOCUMENTOR_PDP_EVENT_COMMENT\r
633                 => "PHPDOCUMENTOR_PDP_EVENT_COMMENT",\r
634             PHPDOCUMENTOR_PDP_EVENT_PI\r
635                 => "PHPDOCUMENTOR_PDP_EVENT_PI",\r
636         );\r
637         if (isset($lookup[$value])) {\r
638             return $lookup[$value];\r
639         } else {\r
640             return $value;\r
641         }\r
642     }\r
643 }\r
644 ?>\r