Code

Updated error msgs in semantic class
[gosa.git] / include / sieve / class_My_Parser.inc
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 {
10         var $parent = NULL;
12         function My_Parser($parent)
13         {
14                 $this->parent = $parent;
15         }
17         function execute()
18         {
19                 $ret = $this->dumpParseTree();
20                 return($ret);
21         }
22         
24         /* Check if there are errors, collect them and return them */
25         function check()
26         {
27                 return($this->tree_->check());
28         }
29         
31         /* Initiate parser, but use some other 
32      *  classes, that are rewritten.
33      */
34         function parse($script) 
35         {
36         $this->status_text = "incomplete";
37         $this->script_ = $script;
38         $this->tree_ = new My_Tree(@Scanner::scriptStart(),$this);
39         $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
40         $this->scanner_ = new Scanner($this->script_);
41         $this->scanner_->setCommentFunc(array($this, 'comment_'));
43         if ($this->commands_($this->tree_->getRoot()) &&
44             $this->scanner_->nextTokenIs('script-end'))
45         {
46                         $this->scanner_->nextToken(); 
47             return $this->success_('success');
48         }
50         return $this->status_;
51         }
53         
54         function get_sieve_script()
55         {
56                 return($this->tree_->get_sieve_script());
57         }               
59         
60         function save_object()
61         {
62                 $this->tree_->save_object();
63         }
66         /* Should be obsolete in the end. */
67         function dumpToken_(&$token)
68         {
69                 if (is_array($token))
70                 {
71                         $str = "<" . $token['text'] . "> ";
72                         foreach ($token as $k => $v)
73                         {
74                                 $str .= " $k:$v";
75                         }
76                         return $str;
77                 }
78                 return strval($token);
79         }
82         function dumpParseTree()
83         {
84                 return $this->tree_->execute();
85         }
86 }
87 ?>