Code

Updated class location table.
[gosa.git] / include / sieve / class_My_Parser.inc
index 6d796cd8ae23d84fe9a22f31a53574ca8d0bbad4..ac99301a6f0406dac55cad68e4cf97fb160530c5 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+/* String used to indent the different code blocks */
+define("SIEVE_INDENT_TAB","  ");
 
 
 /* This class is inherited from the original 'Parser'
@@ -7,10 +9,26 @@
  */
 class My_Parser extends Parser 
 {
+       var $parent = NULL;
+       var $registeredExtensions_ =array();
+
+       function My_Parser($parent)
+       {
+               $this->registeredExtensions_ = array();         
+               $this->parent = $parent;
+       }
 
        function execute()
        {
-               return($this->dumpParseTree());
+               $ret = $this->dumpParseTree();
+               return($ret);
+       }
+       
+
+       /* Check if there are errors, collect them and return them */
+       function check()
+       {
+               return($this->tree_->check());
        }
        
 
@@ -19,42 +37,42 @@ class My_Parser extends Parser
      */
        function parse($script) 
        {
+               $script = preg_replace("/^###GOSA/","",$script);
+
+               $this->registeredExtensions_ = array();
         $this->status_text = "incomplete";
         $this->script_ = $script;
-        $this->tree_ = new My_Tree(@Scanner::scriptStart());
+        $this->tree_ = new My_Tree(@Scanner::scriptStart(),$this);
         $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
-        $this->scanner_ = new Scanner($this->script_);
+        $this->scanner_ = new My_Scanner($this->script_);
         $this->scanner_->setCommentFunc(array($this, 'comment_'));
 
         if ($this->commands_($this->tree_->getRoot()) &&
             $this->scanner_->nextTokenIs('script-end'))
         {
+                       $this->scanner_->nextToken(); 
             return $this->success_('success');
         }
 
         return $this->status_;
        }
 
-               
+       
+       function get_sieve_script()
+       {
+               return("###GOSA\n".$this->tree_->get_sieve_script());
+       }               
+
+       
        function save_object()
        {
                $this->tree_->save_object();
        }
 
 
-       /* Should be obsolete in the end. */
-       function dumpToken_(&$token)
+       function dumpParseTree()
        {
-               if (is_array($token))
-               {
-                       $str = "<" . $token['text'] . "> ";
-                       foreach ($token as $k => $v)
-                       {
-                               $str .= " $k:$v";
-                       }
-                       return $str;
-               }
-               return strval($token);
+               return $this->tree_->execute();
        }
 }
 ?>