1 <?php
3 define("SIEVE_INDENT_TAB"," ");
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 $ret = $this->dumpParseTree();
14 return($ret);
15 }
18 /* Initiate parser, but use some other
19 * classes, that are rewritten.
20 */
21 function parse($script)
22 {
23 $this->status_text = "incomplete";
24 $this->script_ = $script;
25 $this->tree_ = new My_Tree(@Scanner::scriptStart());
26 $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
27 $this->scanner_ = new Scanner($this->script_);
28 $this->scanner_->setCommentFunc(array($this, 'comment_'));
30 if ($this->commands_($this->tree_->getRoot()) &&
31 $this->scanner_->nextTokenIs('script-end'))
32 {
33 return $this->success_('success');
34 }
36 return $this->status_;
37 }
40 function get_sieve_script()
41 {
42 return($this->tree_->get_sieve_script());
43 }
46 function save_object()
47 {
48 $this->tree_->save_object();
49 }
52 /* Should be obsolete in the end. */
53 function dumpToken_(&$token)
54 {
55 if (is_array($token))
56 {
57 $str = "<" . $token['text'] . "> ";
58 foreach ($token as $k => $v)
59 {
60 $str .= " $k:$v";
61 }
62 return $str;
63 }
64 return strval($token);
65 }
66 }
67 ?>