Code

Updated translation, fixed some typo/errors
[gosa.git] / include / sieve / class_My_Parser.inc
1 <?php
3 /* String used to indent the different code blocks */
4 define("SIEVE_INDENT_TAB","  ");
7 /* This class is inherited from the original 'Parser'
8  *  class written by Heiko Hund
9  */
10 class My_Parser extends Parser 
11 {
12         var $parent = NULL;
13         var $registeredExtensions_ =array();
15         function My_Parser($parent)
16         {
17                 $this->registeredExtensions_ = array();         
18                 $this->parent = $parent;
19         }
21         function execute()
22         {
23                 $ret = $this->dumpParseTree();
24                 return($ret);
25         }
26         
28         /* Check if there are errors, collect them and return them */
29         function check()
30         {
31                 return($this->tree_->check());
32         }
33         
35         /* Initiate parser, but use some other 
36      *  classes, that are rewritten.
37      */
38         function parse($script) 
39         {
40                 $script = preg_replace("/^###GOSA/","",$script);
42                 $this->registeredExtensions_ = array();
43         $this->status_text = "incomplete";
44         $this->script_ = $script;
45         $this->tree_ = new My_Tree(@Scanner::scriptStart(),$this);
46         $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
47         $this->scanner_ = new My_Scanner($this->script_);
48         $this->scanner_->setCommentFunc(array($this, 'comment_'));
50         if ($this->commands_($this->tree_->getRoot()) &&
51             $this->scanner_->nextTokenIs('script-end'))
52         {
53                         $this->scanner_->nextToken(); 
54             return $this->success_('success');
55         }
57         return $this->status_;
58         }
60         
61         function get_sieve_script()
62         {
63                 return("###GOSA\n".$this->tree_->get_sieve_script());
64         }               
66         
67         function save_object()
68         {
69                 $this->tree_->save_object();
70         }
73         function dumpParseTree()
74         {
75                 return $this->tree_->execute();
76         }
77 }
78 ?>