Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * XML/Beautifier.php
4
 *
5
 * Format XML files containing unknown entities (like all of peardoc)
6
 *
7
 * phpDocumentor :: automatic documentation generator
8
 *
9
 * PHP versions 4 and 5
10
 *
11
 * Copyright (c) 2004-2006 Gregory Beaver
12
 *
13
 * LICENSE:
14
 *
15
 * This library is free software; you can redistribute it
16
 * and/or modify it under the terms of the GNU Lesser General
17
 * Public License as published by the Free Software Foundation;
18
 * either version 2.1 of the License, or (at your option) any
19
 * later version.
20
 *
21
 * This library is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
 * Lesser General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Lesser General Public
27
 * License along with this library; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
 *
30
 * @package    phpDocumentor
31
 * @subpackage Parsers
32
 * @author     Greg Beaver <cellog@php.net>
33
 * @copyright  2004-2006 Gregory Beaver
34
 * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
35
 * @version    CVS: $Id: Tokenizer.php 238276 2007-06-22 14:58:30Z ashnazg $
36
 * @filesource
37
 * @link       http://www.phpdoc.org
38
 * @link       http://pear.php.net/PhpDocumentor
39
 * @since      1.3.0
40
 */
41
/**
42
 * From the XML_Beautifier package
43
 */
44
require_once 'XML/Beautifier/Tokenizer.php';
45
/**
46
 * Highlights source code using {@link parse()}
47
 * @package phpDocumentor
48
 * @subpackage Parsers
49
 */
50
class phpDocumentor_XML_Beautifier_Tokenizer extends XML_Beautifier_Tokenizer
51
{
52
    /**#@+
53
     * @access private
54
     */
55
    var $_curthing;
56
    var $_tag;
57
    var $_attrs;
58
    var $_attr;
59
 
60
    /**#@-*/
61
    /**
62
     * @var array
63
     */
64
    var $eventHandlers = array(
65
                                PHPDOC_XMLTOKEN_EVENT_NOEVENTS => 'normalHandler',
66
                                PHPDOC_XMLTOKEN_EVENT_XML => 'parseXMLHandler',
67
                                PHPDOC_XMLTOKEN_EVENT_PI => 'parsePiHandler',
68
                                PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE => 'attrHandler',
69
                                PHPDOC_XMLTOKEN_EVENT_OPENTAG => 'tagHandler',
70
                                PHPDOC_XMLTOKEN_EVENT_IN_CDATA => 'realcdataHandler',
71
                                PHPDOC_XMLTOKEN_EVENT_DEF => 'defHandler',
72
                                PHPDOC_XMLTOKEN_EVENT_CLOSETAG => 'closetagHandler',
73
                                PHPDOC_XMLTOKEN_EVENT_ENTITY => 'entityHandler',
74
                                PHPDOC_XMLTOKEN_EVENT_COMMENT => 'commentHandler',
75
                                PHPDOC_XMLTOKEN_EVENT_SINGLEQUOTE => 'stringHandler',
76
                                PHPDOC_XMLTOKEN_EVENT_DOUBLEQUOTE => 'stringHandler',
77
                                PHPDOC_XMLTOKEN_EVENT_CDATA => 'parseCdataHandler',
78
    );
79
 
80
    /**
81
     * Parse a new file
82
     *
83
     * The parse() method is a do...while() loop that retrieves tokens one by
84
     * one from the {@link $_event_stack}, and uses the token event array set up
85
     * by the class constructor to call event handlers.
86
     *
87
     * The event handlers each process the tokens passed to them, and use the
88
     * {@link _addoutput()} method to append the processed tokens to the
89
     * {@link $_line} variable.  The word parser calls {@link newLineNum()}
90
     * every time a line is reached.
91
     *
92
     * In addition, the event handlers use special linking functions
93
     * {@link _link()} and its cousins (_classlink(), etc.) to create in-code
94
     * hyperlinks to the documentation for source code elements that are in the
95
     * source code.
96
     *
97
     * @uses setupStates() initialize parser state variables
98
     * @uses configWordParser() pass $parse_data to prepare retrieval of tokens
99
     * @param    string
100
     * @param    Converter
101
     * @param    false|string full path to file with @filesource tag, if this
102
     *           is a @filesource parse
103
     * @param    false|integer starting line number from {@}source linenum}
104
     * @staticvar    integer    used for recursion limiting if a handler for
105
     *                          an event is not found
106
     * @return    bool
107
     */
108
    function parseString ($parse_data)
109
    {
110
        static $endrecur = 0;
111
        $parse_data = str_replace(array("\r\n", "\t"), array("\n", '    '), $parse_data);
112
        $this->setupStates($parse_data);
113
 
114
        $this->configWordParser(PHPDOC_XMLTOKEN_EVENT_NOEVENTS);
115
        // initialize variables so E_ALL error_reporting doesn't complain
116
        $pevent = 0;
117
        $word = 0;
118
        $this->_curthing = '';
119
 
120
        do
121
        {
122
            $lpevent = $pevent;
123
            $pevent = $this->_event_stack->getEvent();
124
            if ($lpevent != $pevent)
125
            {
126
                $this->_last_pevent = $lpevent;
127
                $this->configWordParser($pevent);
128
            }
129
            $this->_wp->setWhitespace(true);
130
 
131
            $dbg_linenum = $this->_wp->linenum;
132
            $dbg_pos = $this->_wp->getPos();
133
            $this->_pv_last_word = $word;
134
            $this->_pv_curline = $this->_wp->linenum;
135
            $word = $this->_wp->getWord();
136
 
137
            if (PHPDOCUMENTOR_DEBUG == true)
138
            {
139
                echo "LAST: ";
140
                echo "|" . $this->_pv_last_word;
141
                echo "|\n";
142
                echo "PEVENT: " . $this->getParserEventName($pevent) . "\n";
143
                echo "LASTPEVENT: " . $this->getParserEventName($this->_last_pevent) . "\n";
144
//                echo "LINE: ".$this->_line."\n";
145
//                echo "OUTPUT: ".$this->_output."\n";
146
                echo $dbg_linenum.'-'.$dbg_pos . ": ";
147
                echo '|'.htmlspecialchars($word);
148
                echo "|\n";
149
                echo "-------------------\n\n\n";
150
                flush();
151
            }
152
            if (isset($this->eventHandlers[$pevent]))
153
            {
154
                $handle = $this->eventHandlers[$pevent];
155
                $this->$handle($word, $pevent);
156
            } else
157
            {
158
                echo ('WARNING: possible error, no handler for event number '.$pevent);
159
                if ($endrecur++ == 25)
160
                {
161
                    return $this->raiseError("FATAL ERROR, recursion limit reached");
162
                }
163
            }
164
        } while (!($word === false));
165
        return true;
166
    }
167
 
168
    /**#@+
169
     * Event Handlers
170
     *
171
     * All Event Handlers use {@link checkEventPush()} and
172
     * {@link checkEventPop()} to set up the event stack and parser state.
173
     * @access private
174
     * @param string|array token value
175
     * @param integer parser event from {@link Parser.inc}
176
     */
177
    /**
178
     * Most tokens only need highlighting, and this method handles them
179
     */
180
    function normalHandler($word, $pevent)
181
    {
182
        if ($this->checkEventPush($word, $pevent)) {
183
            $this->_wp->backupPos($word);
184
            $this->_addoutput($pevent);
185
            $this->_curthing = '';
186
            return;
187
        }
188
        $this->_curthing .= $word;
189
 
190
        if ($this->checkEventPop($word, $pevent)) {
191
            $this->_addoutput($pevent);
192
            $this->_curthing = '';
193
        }
194
    }
195
 
196
    /**
197
     * handle <!-- comments -->
198
     */
199
    function commentHandler($word, $pevent)
200
    {
201
        if ($this->checkEventPush($word, $pevent)) {
202
            $this->_wp->backupPos($word);
203
            return;
204
        }
205
 
206
        $this->_curthing .= $word;
207
        if ($this->checkEventPop($word, $pevent)) {
208
            $this->_addoutput($pevent);
209
            $this->_curthing = '';
210
        }
211
    }
212
 
213
    /**
214
     * handle <?Processor instructions?>
215
     */
216
    function parsePiHandler($word, $pevent)
217
    {
218
        if ($this->checkEventPush($word, $pevent)) {
219
            $this->_wp->backupPos($word);
220
            return;
221
        }
222
        if ($this->checkEventPop($word, $pevent)) {
223
            $this->_addoutput($pevent);
224
            $this->_curthing = '';
225
            $this->_attrs = null;
226
            return;
227
        }
228
        if (!strlen($this->_curthing)) {
229
            $this->_curthing .= str_replace('<?', '', $word);
230
        } else {
231
            if (!isset($this->_attrs) || !is_string($this->_attrs)) {
232
                $this->_attrs = '';
233
            }
234
            $this->_attrs .= $word;
235
        }
236
    }
237
 
238
    /**
239
     * handle <?xml Processor instructions?>
240
     */
241
    function parseXMLHandler($word, $pevent)
242
    {
243
        if ($this->checkEventPush($word, $pevent)) {
244
            $this->_wp->backupPos($word);
245
            return;
246
        }
247
 
248
        $this->_curthing .= $word;
249
        if ($this->checkEventPop($word, $pevent)) {
250
            $this->_addoutput($pevent);
251
            $this->_curthing = '';
252
        }
253
    }
254
 
255
    /**
256
     * handle <![CDATA[ unescaped text ]]>
257
     */
258
    function realcdataHandler($word, $pevent)
259
    {
260
        $this->_curthing .= $word;
261
        if ($this->checkEventPop($word, $pevent)) {
262
            $this->_addoutput($pevent);
263
            $this->_curthing = '';
264
        }
265
    }
266
 
267
    /**
268
     * handle <tags>
269
     */
270
    function tagHandler($word, $pevent)
271
    {
272
        if ($this->checkEventPush($word, $pevent)) {
273
            $this->_wp->backupPos($word);
274
            $this->_curthing = '';
275
            return;
276
        }
277
 
278
        if ($word{0} == '<') {
279
            $this->_tag = substr($word, 1);
280
        }
281
 
282
        if ($this->checkEventPop($word, $pevent)) {
283
            $this->_addoutput($pevent);
284
            $this->_tag = null;
285
            $this->_attrs = null;
286
            if ($word == '>') {
287
                $this->_event_stack->pushEvent(PHPDOC_XMLTOKEN_EVENT_CDATA);
288
                return;
289
            }
290
        }
291
    }
292
 
293
    /**
294
     * handle </tags>
295
     */
296
    function closetagHandler($word, $pevent)
297
    {
298
        if ($this->checkEventPush($word, $pevent)) {
299
            $this->_wp->backupPos($word);
300
            return;
301
        }
302
        if ($this->checkEventPop($word, $pevent)) {
303
            $this->_addoutput($pevent);
304
            $this->_tag = '';
305
            return;
306
        }
307
        $this->_tag = trim(str_replace('</', '', $word));
308
    }
309
 
310
    /**
311
     * handle <!def>
312
     */
313
    function defHandler($word, $pevent)
314
    {
315
        if ($this->checkEventPush($word, $pevent)) {
316
            $this->_wp->backupPos($word);
317
            return;
318
        }
319
 
320
        $this->_curthing .= $word;
321
        if ($this->checkEventPop($word, $pevent)) {
322
            $this->_addoutput($pevent);
323
            $this->_curthing = '';
324
        }
325
    }
326
 
327
    /**
328
     * Most tokens only need highlighting, and this method handles them
329
     */
330
    function attrHandler($word, $pevent)
331
    {
332
        if ($e = $this->checkEventPush($word, $pevent)) {
333
            return;
334
        }
335
        if (!isset($this->_attrs) || !is_array($this->_attrs)) {
336
            $this->_attrs = array();
337
        }
338
        if (strpos($word, '=')) {
339
            $this->_attrs[$this->_attr = trim(str_replace('=', '', $word))] = '';
340
        }
341
        if ($this->checkEventPop($word, $pevent)) {
342
            $this->_wp->backupPos($word);
343
            return;
344
        }
345
    }
346
 
347
    /**
348
     * handle attribute values
349
     */
350
    function stringHandler($word, $pevent)
351
    {
352
        if ($this->checkEventPop($word, $pevent)) {
353
            return;
354
        }
355
        $this->_attrs[$this->_attr] = $word;
356
    }
357
 
358
    /**
359
     * handle &entities;
360
     */
361
    function entityHandler($word, $pevent)
362
    {
363
        if ($this->checkEventPop($word, $pevent)) {
364
            $this->_addoutput($pevent);
365
            $this->_curthing = '';
366
            return;
367
        }
368
        if (strlen($word) && $word{0} == '&') {
369
            $word = substr($word, 1);
370
        }
371
        $this->_curthing .= $word;
372
    }
373
 
374
    /**
375
     * handle tag contents
376
     */
377
    function parseCdataHandler($word, $pevent)
378
    {
379
        if ($this->checkEventPush($word, $pevent)) {
380
            $this->_wp->backupPos($word);
381
            if (strlen($this->_curthing)) {
382
                $this->_addoutput($pevent);
383
            }
384
            $this->_curthing = '';
385
            return;
386
        }
387
        if ($this->checkEventPop($word, $pevent)) {
388
            if (strlen($this->_curthing)) {
389
                $this->_addoutput($pevent);
390
            }
391
            $this->_curthing = '';
392
            $this->_event_stack->pushEvent(PHPDOC_XMLTOKEN_EVENT_CLOSETAG);
393
            return;
394
        }
395
        $this->_curthing .= $word;
396
    }
397
 
398
    /**#@-*/
399
 
400
    /**
401
     * Handler for real character data
402
     *
403
     * @access protected
404
     * @param  object XML parser object
405
     * @param  string CDATA
406
     * @return void
407
     */
408
    function incdataHandler($parser, $cdata)
409
    {
410
        if ((string)$cdata === '') {
411
            return true;
412
        }
413
 
414
        $struct = array(
415
                         "type"  => PHPDOC_BEAUTIFIER_CDATA,
416
                         "data"  => $cdata,
417
                         "depth" => $this->_depth
418
                       );
419
 
420
        $this->_appendToParent($struct);
421
    }
422
    /**#@+
423
     * Output Methods
424
     * @access private
425
     */
426
    /**
427
     * This method adds output to {@link $_line}
428
     *
429
     * If a string with variables like "$test this" is present, then special
430
     * handling is used to allow processing of the variable in context.
431
     * @see _flush_save()
432
     */
433
    function _addoutput($event)
434
    {
435
        $type =
436
        array(
437
            PHPDOC_XMLTOKEN_EVENT_NOEVENTS => '_handleXMLDefault',
438
            PHPDOC_XMLTOKEN_EVENT_CLOSETAG => 'endHandler',
439
            PHPDOC_XMLTOKEN_EVENT_ENTITY => 'entityrefHandler',
440
            PHPDOC_XMLTOKEN_EVENT_DEF => '_handleXMLDefault',
441
            PHPDOC_XMLTOKEN_EVENT_PI => 'parsePiHandler',
442
            PHPDOC_XMLTOKEN_EVENT_XML => '_handleXMLDefault',
443
            PHPDOC_XMLTOKEN_EVENT_OPENTAG => 'startHandler',
444
            PHPDOC_XMLTOKEN_EVENT_COMMENT => '_handleXMLDefault',
445
            PHPDOC_XMLTOKEN_EVENT_CDATA => 'cdataHandler',
446
            PHPDOC_XMLTOKEN_EVENT_IN_CDATA => 'incdataHandler',
447
        );
448
        $method = $type[$event];
449
        switch ($event) {
450
            case PHPDOC_XMLTOKEN_EVENT_COMMENT :
451
//                echo "comment: $this->_curthing\n";
452
                $this->$method(false, $this->_curthing);
453
            break;
454
            case PHPDOC_XMLTOKEN_EVENT_OPENTAG :
455
//                echo "open tag: $this->_tag\n";
456
//                var_dump($this->_attrs);
457
                $this->$method(false, $this->_tag, $this->_attrs);
458
            break;
459
            case PHPDOC_XMLTOKEN_EVENT_CLOSETAG :
460
//                echo "close tag: $this->_tag\n";
461
                $this->$method(false, $this->_curthing);
462
            break;
463
            case PHPDOC_XMLTOKEN_EVENT_NOEVENTS :
464
                if (!strlen($this->_curthing)) {
465
                    return;
466
                }
467
//                echo "default: $this->_curthing\n";
468
                $this->$method(false, $this->_curthing);
469
            break;
470
            case PHPDOC_XMLTOKEN_EVENT_DEF :
471
//                echo "<!definition: $this->_curthing\n";
472
                $this->$method(false, $this->_curthing);
473
            break;
474
            case PHPDOC_XMLTOKEN_EVENT_PI :
475
//                echo "<?pi: $this->_curthing\n";
476
//                echo "<?pi attrs: $this->_attrs\n";
477
                $this->$method(false, $this->_curthing, $this->_attrs);
478
            break;
479
            case PHPDOC_XMLTOKEN_EVENT_XML :
480
//                echo "<?xml: $this->_curthing\n";
481
                $this->$method(false, $this->_curthing, $this->_attrs);
482
            break;
483
            case PHPDOC_XMLTOKEN_EVENT_CDATA :
484
            case PHPDOC_XMLTOKEN_EVENT_IN_CDATA :
485
//                echo "cdata: $this->_curthing\n";
486
                $this->$method(false, $this->_curthing);
487
            break;
488
            case PHPDOC_XMLTOKEN_EVENT_ENTITY :
489
//                echo "entity: $this->_curthing\n";
490
                $this->$method(false, $this->_curthing, false, false, false);
491
            break;
492
        }
493
    }
494
    /**#@-*/
495
 
496
    /**
497
     * tell the parser's WordParser {@link $wp} to set up tokens to parse words by.
498
     * tokens are word separators.  In English, a space or punctuation are examples of tokens.
499
     * In PHP, a token can be a ;, a parenthesis, or even the word "function"
500
     * @param    $value integer an event number
501
     * @see WordParser
502
     */
503
 
504
    function configWordParser($e)
505
    {
506
        $this->_wp->setSeperator($this->tokens[($e + 100)]);
507
    }
508
    /**
509
     * this function checks whether parameter $word is a token for pushing a new event onto the Event Stack.
510
     * @return mixed    returns false, or the event number
511
     */
512
 
513
    function checkEventPush($word,$pevent)
514
    {
515
        $e = false;
516
        if (isset($this->pushEvent[$pevent]))
517
        {
518
            if (isset($this->pushEvent[$pevent][strtolower($word)]))
519
            $e = $this->pushEvent[$pevent][strtolower($word)];
520
        }
521
        if ($e)
522
        {
523
            $this->_event_stack->pushEvent($e);
524
            return $e;
525
        } else {
526
            return false;
527
        }
528
    }
529
 
530
    /**
531
     * this function checks whether parameter $word is a token for popping the current event off of the Event Stack.
532
     * @return mixed    returns false, or the event number popped off of the stack
533
     */
534
 
535
    function checkEventPop($word,$pevent)
536
    {
537
        if (!isset($this->popEvent[$pevent])) return false;
538
        if (in_array(strtolower($word),$this->popEvent[$pevent]))
539
        {
540
            return $this->_event_stack->popEvent();
541
        } else {
542
            return false;
543
        }
544
    }
545
 
546
    /**
547
     * Initialize all parser state variables
548
     * @param boolean true if we are highlighting an inline {@}source} tag's
549
     *                output
550
     * @param false|string name of class we are going to start from
551
     * @uses $_wp sets to a new {@link phpDocumentor_HighlightWordParser}
552
     */
553
    function setupStates($parsedata)
554
    {
555
        $this->_output = '';
556
        $this->_line = '';
557
        unset($this->_wp);
558
        $this->_wp = new WordParser;
559
        $this->_wp->setup($parsedata);
560
        $this->_event_stack = @(new EventStack);
561
        $this->_event_stack->popEvent();
562
        $this->_event_stack->pushEvent(PHPDOC_XMLTOKEN_EVENT_NOEVENTS);
563
        $this->_pv_linenum = null;
564
        $this->_pv_next_word = false;
565
    }
566
 
567
    /**
568
     * Initialize the {@link $tokenpushEvent, $wordpushEvent} arrays
569
     */
570
    function phpDocumentor_XML_Beautifier_Tokenizer()
571
    {
572
        $this->tokens[STATE_XMLTOKEN_CDATA] =
573
        $this->tokens[STATE_XMLTOKEN_NOEVENTS]        = array('<?xml', '<!--', '<![CDATA[', '<!', '</', '<?', '<');//, '&');
574
        $this->tokens[STATE_XMLTOKEN_OPENTAG]        = array("\n","\t"," ", '>', '/>');
575
        $this->tokens[STATE_XMLTOKEN_XML] =
576
        $this->tokens[STATE_XMLTOKEN_PI]        = array("\n","\t"," ", '?>');
577
        $this->tokens[STATE_XMLTOKEN_IN_CDATA]        = array(']]>');
578
        $this->tokens[STATE_XMLTOKEN_CLOSETAG]        = array("\n",'>');
579
        $this->tokens[STATE_XMLTOKEN_COMMENT]        = array("\n",'-->');
580
        $this->tokens[STATE_XMLTOKEN_DEF]        = array("\n",']>','>');
581
        $this->tokens[STATE_XMLTOKEN_ENTITY]        = array("\n",';');
582
        $this->tokens[STATE_XMLTOKEN_ATTRIBUTE]        = array("\n",'"',"'",'>','/>');
583
        $this->tokens[STATE_XMLTOKEN_DOUBLEQUOTE]        = array("\n",'"');
584
        $this->tokens[STATE_XMLTOKEN_SINGLEQUOTE]        = array("\n","'");
585
/**************************************************************/
586
 
587
        $this->pushEvent[PHPDOC_XMLTOKEN_EVENT_NOEVENTS] =
588
            array(
589
                '<' => PHPDOC_XMLTOKEN_EVENT_OPENTAG,
590
                '<?' => PHPDOC_XMLTOKEN_EVENT_PI,
591
                '<?xml' => PHPDOC_XMLTOKEN_EVENT_XML,
592
                '</' => PHPDOC_XMLTOKEN_EVENT_CLOSETAG,
593
//                '&' => PHPDOC_XMLTOKEN_EVENT_ENTITY,
594
                '<![cdata[' => PHPDOC_XMLTOKEN_EVENT_IN_CDATA,
595
                '<!--' => PHPDOC_XMLTOKEN_EVENT_COMMENT,
596
                '<!' => PHPDOC_XMLTOKEN_EVENT_DEF,
597
            );
598
/**************************************************************/
599
 
600
        $this->pushEvent[PHPDOC_XMLTOKEN_EVENT_OPENTAG] =
601
            array(
602
                " " => PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE,
603
                "\n" => PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE,
604
            );
605
/**************************************************************/
606
 
607
        $this->pushEvent[PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE] =
608
            array(
609
                "'" => PHPDOC_XMLTOKEN_EVENT_SINGLEQUOTE,
610
                '"' => PHPDOC_XMLTOKEN_EVENT_DOUBLEQUOTE,
611
            );
612
/**************************************************************/
613
 
614
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_IN_CDATA] = array(']]>');
615
/**************************************************************/
616
 
617
        $this->pushEvent[PHPDOC_XMLTOKEN_EVENT_CDATA] =
618
            array(
619
                '<' => PHPDOC_XMLTOKEN_EVENT_OPENTAG,
620
                '<?' => PHPDOC_XMLTOKEN_EVENT_PI,
621
//                '&' => PHPDOC_XMLTOKEN_EVENT_ENTITY,
622
                '<!--' => PHPDOC_XMLTOKEN_EVENT_COMMENT,
623
                '<!' => PHPDOC_XMLTOKEN_EVENT_DEF,
624
                '<![cdata[' => PHPDOC_XMLTOKEN_EVENT_IN_CDATA,
625
            );
626
/**************************************************************/
627
 
628
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_XML] =
629
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_PI] = array('?>');
630
/**************************************************************/
631
 
632
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_ENTITY] = array(';');
633
/**************************************************************/
634
 
635
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_SINGLEQUOTE] = array("'");
636
/**************************************************************/
637
 
638
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_DOUBLEQUOTE] = array('"');
639
/**************************************************************/
640
 
641
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_OPENTAG] = array('>', '/>');
642
/**************************************************************/
643
 
644
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_CLOSETAG] = array('>');
645
/**************************************************************/
646
 
647
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_COMMENT] = array('-->');
648
/**************************************************************/
649
 
650
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_DEF] = array('>',']>');
651
/**************************************************************/
652
 
653
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE] = array('>','/>');
654
/**************************************************************/
655
 
656
        $this->popEvent[PHPDOC_XMLTOKEN_EVENT_CDATA] =
657
            array('</');
658
/**************************************************************/
659
    }
660
 
661
    function getParserEventName ($value)
662
    {
663
        $lookup = array(
664
            PHPDOC_XMLTOKEN_EVENT_NOEVENTS         => "PHPDOC_XMLTOKEN_EVENT_NOEVENTS",
665
            PHPDOC_XMLTOKEN_EVENT_PI         => "PHPDOC_XMLTOKEN_EVENT_PI",
666
            PHPDOC_XMLTOKEN_EVENT_OPENTAG         => "PHPDOC_XMLTOKEN_EVENT_OPENTAG",
667
            PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE         => "PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE",
668
            PHPDOC_XMLTOKEN_EVENT_CLOSETAG         => "PHPDOC_XMLTOKEN_EVENT_CLOSETAG",
669
            PHPDOC_XMLTOKEN_EVENT_ENTITY         => "PHPDOC_XMLTOKEN_EVENT_ENTITY",
670
            PHPDOC_XMLTOKEN_EVENT_COMMENT         => "PHPDOC_XMLTOKEN_EVENT_COMMENT",
671
            PHPDOC_XMLTOKEN_EVENT_SINGLEQUOTE         => "PHPDOC_XMLTOKEN_EVENT_SINGLEQUOTE",
672
            PHPDOC_XMLTOKEN_EVENT_DOUBLEQUOTE         => "PHPDOC_XMLTOKEN_EVENT_DOUBLEQUOTE",
673
            PHPDOC_XMLTOKEN_EVENT_CDATA => 'PHPDOC_XMLTOKEN_EVENT_CDATA',
674
            PHPDOC_XMLTOKEN_EVENT_DEF => 'PHPDOC_XMLTOKEN_EVENT_DEF',
675
            PHPDOC_XMLTOKEN_EVENT_XML => 'PHPDOC_XMLTOKEN_EVENT_XML',
676
            PHPDOC_XMLTOKEN_EVENT_IN_CDATA => 'PHPDOC_XMLTOKEN_EVENT_IN_CDATA',
677
        );
678
        if (isset($lookup[$value]))
679
        return $lookup[$value];
680
        else return $value;
681
    }
682
}
683
 
684
 
685
/** starting state */
686
define("PHPDOC_XMLTOKEN_EVENT_NOEVENTS"    ,    1);
687
/** currently in starting state */
688
define("STATE_XMLTOKEN_NOEVENTS"    ,    101);
689
 
690
/** used when a processor instruction is found */
691
define("PHPDOC_XMLTOKEN_EVENT_PI"    ,    2);
692
/** currently in processor instruction */
693
define("STATE_XMLTOKEN_PI"    ,    102);
694
 
695
/** used when an open <tag> is found */
696
define("PHPDOC_XMLTOKEN_EVENT_OPENTAG"    ,    3);
697
/** currently parsing an open <tag> */
698
define("STATE_XMLTOKEN_OPENTAG"    ,    103);
699
 
700
/** used when a <tag attr="attribute"> is found */
701
define("PHPDOC_XMLTOKEN_EVENT_ATTRIBUTE"    ,    4);
702
/** currently parsing an open <tag> */
703
define("STATE_XMLTOKEN_ATTRIBUTE"    ,    104);
704
 
705
/** used when a close </tag> is found */
706
define("PHPDOC_XMLTOKEN_EVENT_CLOSETAG"    ,    5);
707
/** currently parsing a close </tag> */
708
define("STATE_XMLTOKEN_CLOSETAG"    ,    105);
709
 
710
/** used when an &entity; is found */
711
define("PHPDOC_XMLTOKEN_EVENT_ENTITY"    ,    6);
712
/** currently parsing an &entity; */
713
define("STATE_XMLTOKEN_ENTITY"    ,    106);
714
 
715
/** used when a <!-- comment --> is found */
716
define("PHPDOC_XMLTOKEN_EVENT_COMMENT"    ,    7);
717
/** currently parsing a <!-- comment --> */
718
define("STATE_XMLTOKEN_COMMENT"    ,    107);
719
 
720
/** used when a <!-- comment --> is found */
721
define("PHPDOC_XMLTOKEN_EVENT_SINGLEQUOTE"    ,    8);
722
/** currently parsing a <!-- comment --> */
723
define("STATE_XMLTOKEN_SINGLEQUOTE"    ,    108);
724
 
725
/** used when a <!-- comment --> is found */
726
define("PHPDOC_XMLTOKEN_EVENT_DOUBLEQUOTE"    ,    9);
727
/** currently parsing a <!-- comment --> */
728
define("STATE_XMLTOKEN_DOUBLEQUOTE"    ,    109);
729
 
730
/** used when a <! is found */
731
define("PHPDOC_XMLTOKEN_EVENT_DEF"    ,    10);
732
/** currently parsing a <! */
733
define("STATE_XMLTOKEN_DEF"    ,    110);
734
 
735
/** used when a <! is found */
736
define("PHPDOC_XMLTOKEN_EVENT_CDATA"    ,    11);
737
/** currently parsing a <! */
738
define("STATE_XMLTOKEN_CDATA"    ,    111);
739
 
740
/** used when a <?xml is found */
741
define("PHPDOC_XMLTOKEN_EVENT_XML"    ,    12);
742
/** currently parsing a <?xml */
743
define("STATE_XMLTOKEN_XML"    ,    112);
744
 
745
/** used when a <![CDATA[ section is found */
746
define('PHPDOC_XMLTOKEN_EVENT_IN_CDATA', 13);
747
/** currently parsing a <![CDATA[ ]]> */
748
define('STATE_XMLTOKEN_IN_CDATA', 113);
749
 
750
/** do not remove, needed in plain renderer */
751
define('PHPDOC_BEAUTIFIER_CDATA', 100000);
752
?>