コード例 #1
0
ファイル: interpreter.php プロジェクト: xk0der/AFL
 private function expandLists($code)
 {
     $appendAtEnd = True;
     // AppendAt End
     $listCode = '@@';
     if (strpos($code, '@$') !== False) {
         $listCode = '@$';
     } else {
         if (strpos($code, '@^') !== False) {
             $listCode = '@^';
             $appendAtEnd = False;
         }
     }
     $listAT = strpos($code, $listCode);
     $prefix = substr($code, 0, $listAT);
     $_t = substr($code, $listAT + 2, strlen($code));
     $i_nextValList = false;
     if (sizeof(explode(':', $_t)) == 4) {
         list($initVal, $i_nextValList, $i_nextVal, $i_condition) = explode(':', $_t);
     } else {
         list($initVal, $i_nextVal, $i_condition) = explode(':', $_t);
     }
     $initVal = str_replace('[', '', $initVal);
     $initVal = str_replace(']', '', $initVal);
     $initVal = explode(",", $initVal);
     $_t = array();
     for ($i = 0; $i < sizeof($initVal); $i++) {
         if (trim($initVal[$i]) != "") {
             $_t[sizeof($_t)] = $initVal[$i];
         }
     }
     $initVal = $_t;
     $b_condition = True;
     if ($i_nextValList !== False) {
         $i_nextValList = trim($i_nextValList);
     }
     $i_nextVal = trim($i_nextVal);
     $i_condition = trim($i_condition);
     $nextVal = "";
     for ($i = strpos($i_nextVal, '#') + 1; substr($i_nextVal, $i, 1) != " " && $i < strlen($i_nextVal); $i++) {
         $nextVal .= substr($i_nextVal, $i, 1);
     }
     $i_nextVal = preg_replace('/\\#[0-9]+/', '#', $i_nextVal);
     $output = trim(implode(', ', $initVal));
     $comma = "";
     if (strlen($output) > 0) {
         $comma = ", ";
     }
     while ($b_condition) {
         if ($i_nextValList !== False) {
             $nextCode = $i_nextValList;
             while (strpos($nextCode, '#') !== False) {
                 $nextCode = trim(str_replace(" # ", " " . $nextVal . " ", " " . $nextCode . " "));
             }
             $nextListVal = $this->execute($nextCode);
         }
         $nextCode = $i_nextVal;
         while (strpos($nextCode, '#') !== False) {
             $nextCode = trim(str_replace(" # ", " " . $nextVal . " ", " " . $nextCode . " "));
         }
         $nextVal = $this->execute($nextCode);
         $condition = trim(str_replace(" # ", " " . $nextVal . " ", " " . $i_condition . " "));
         $b_condition = intval($this->execute($condition)) == 0 ? False : True;
         $val = $nextVal;
         if ($i_nextValList !== False) {
             $val = $nextListVal;
         }
         if ($appendAtEnd) {
             $output .= $comma . $val;
         } else {
             $output = $val . $comma . $output;
         }
         $comma = ", ";
     }
     $initVal = explode(',', $output);
     DEBUG::traceDump("Expanded List", $initVal);
     return $prefix . " [ " . $output . " ]";
 }