1 <?php
5 /* This class is inherited from the original 'Parser'
6 * class written by Heiko Hund
7 */
8 class My_Parser extends Parser
9 {
11 /* Initiate parser, but use some other
12 * classes, that are rewritten.
13 */
14 function parse($script)
15 {
16 $this->status_text = "incomplete";
17 $this->script_ = $script;
18 $this->tree_ = new My_Tree(@Scanner::scriptStart());
19 $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
20 $this->scanner_ = new Scanner($this->script_);
21 $this->scanner_->setCommentFunc(array($this, 'comment_'));
23 if ($this->commands_($this->tree_->getRoot()) &&
24 $this->scanner_->nextTokenIs('script-end'))
25 {
26 return $this->success_('success');
27 }
29 return $this->status_;
30 }
33 /* Should be obsolete in the end. */
34 function dumpToken_(&$token)
35 {
36 if (is_array($token))
37 {
38 $str = "<" . $token['text'] . "> ";
39 foreach ($token as $k => $v)
40 {
41 $str .= " $k:$v";
42 }
43 return $str;
44 }
45 return strval($token);
46 }
47 }
48 ?>