Example #1
0
 function parse()
 {
     $fp = fopen($this->filePath, "r") or die("Couldnot open file");
     $varListStr = "";
     $checkListStr = "";
     $stepListStr = "";
     $collectListStr = "";
     while (!feof($fp)) {
         $line = trim(fgets($fp, 1024));
         $flag = substr($line, 0, 1);
         $elementArray = explode('.', $line, 2);
         $element = $elementArray[0];
         switch ($flag) {
             case "\$":
                 $varListStr .= $line . '\\n';
                 break;
             case "{":
                 $stepListStr .= $line . '\\nflag';
                 $checkListStr .= $line . '\\nflag';
                 $collectListStr .= $line . '\\nflag';
                 break;
             case "}":
                 $stepListStr .= $line . '\\n';
                 $checkListStr .= $line . '\\n';
                 $collectListStr .= $line . '\\n';
                 break;
             case "#":
                 break;
             default:
                 switch ($element) {
                     case "step":
                         $stepListStr .= $line . '\\n';
                         break;
                     case "check":
                         $checkListStr .= $line . '\\n';
                         break;
                     case "collect":
                         $collectListStr .= $line . '\\n';
                         break;
                     default:
                         break;
                 }
                 break;
         }
     }
     fclose($fp);
     //echo "</br></br>".$varListStr."</br></br>";
     //echo $checkListStr."</br></br>";
     //echo $stepListStr."</br></br>";
     //echo $collectListStr."</br></br>";
     $this->varibles = Varible::parseList($varListStr);
     $this->checks = Check::parseList($checkListStr, "check");
     $this->steps = Step::parseList($stepListStr, "step");
     $this->collects = Collect::parseList($collectListStr, "collect");
 }
Example #2
0
 function parse()
 {
     $fp = fopen($this->filePath, "r") or die("Couldnot open file");
     $confObj = array("var" => "", "check" => "", "step" => "", "collect" => "");
     $type = "";
     $num = 0;
     while (!feof($fp)) {
         $line = trim(fgets($fp, 1024));
         $head = substr($line, 0, 1);
         $elementArray = explode('.', $line, 2);
         $element = $elementArray[0];
         switch ($head) {
             case "\$":
                 $confObj["var"] .= $line . '\\nline_split';
                 break;
             case "{":
                 if ($type == "") {
                     $confObj["step"] .= '\\nmodule_split';
                     $confObj["check"] .= '\\nmodule_split';
                     $confObj["collect"] .= '\\nmodule_split';
                 } else {
                     if (array_key_exists($type, $confObj)) {
                         $confObj[$type] .= $line . '\\nline_split';
                         $num = $num + 1;
                     }
                 }
                 break;
             case "}":
                 if ($num == 0) {
                     $confObj["step"] .= '\\nline_split';
                     $confObj["check"] .= '\\nline_split';
                     $confObj["collect"] .= '\\nline_split';
                     $type = "";
                 } else {
                     if ($num > 0) {
                         $num = $num - 1;
                         $confObj[$type] .= $line . '\\nline_split';
                     }
                 }
                 break;
             case "#":
                 if (array_key_exists($type, $confObj)) {
                     $confObj[$type] .= $line . '\\nline_split';
                 }
                 break;
             default:
                 if (array_key_exists($type, $confObj)) {
                     $confObj[$type] .= $line . '\\nline_split';
                 } else {
                     if (array_key_exists($element, $confObj)) {
                         $confObj[$element] .= $line . '\\nline_split';
                         $type = $element;
                     }
                 }
                 break;
         }
     }
     fclose($fp);
     $this->varibles = Varible::parseList($confObj["var"]);
     $this->checks = Check::parseList($confObj["check"], "check");
     $this->steps = Step::parseList($confObj["step"], "step");
     //echo $confObj["step"];
     $this->collects = Collect::parseList($confObj["collect"], "collect");
 }