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 function execute()
12 {
13 return($this->dumpParseTree());
14 }
17 /* Initiate parser, but use some other
18 * classes, that are rewritten.
19 */
20 function parse($script)
21 {
22 $this->status_text = "incomplete";
23 $this->script_ = $script;
24 $this->tree_ = new My_Tree(@Scanner::scriptStart());
25 $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
26 $this->scanner_ = new Scanner($this->script_);
27 $this->scanner_->setCommentFunc(array($this, 'comment_'));
29 if ($this->commands_($this->tree_->getRoot()) &&
30 $this->scanner_->nextTokenIs('script-end'))
31 {
32 return $this->success_('success');
33 }
35 return $this->status_;
36 }
39 function save_object()
40 {
41 $this->tree_->save_object();
42 }
45 /* Should be obsolete in the end. */
46 function dumpToken_(&$token)
47 {
48 if (is_array($token))
49 {
50 $str = "<" . $token['text'] . "> ";
51 foreach ($token as $k => $v)
52 {
53 $str .= " $k:$v";
54 }
55 return $str;
56 }
57 return strval($token);
58 }
59 }
60 ?>