#356 switch 구문 지원 추가

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4341 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2008-07-09 13:09:01 +00:00
parent c4fdd3fc47
commit b0cd9370c6

View file

@ -176,19 +176,33 @@
case 'endif' :
case 'endfor' :
case 'endforeach' :
case 'endswitch' :
$output = '}';
break;
case 'break' :
$output = 'break;';
break;
case 'default' :
$output = 'default :';
break;
default :
if(substr($code,0,4)=='else') {
$suffix = '{';
if(substr($code, 0, 4) == 'else') {
$code = '}'.$code;
} elseif(substr($code,0,7)=='foreach') {
$tmp_str = substr($code,8);
} elseif(substr($code, 0, 7) == 'foreach') {
$tmp_str = substr($code, 8);
$tmp_arr = explode(' ', $tmp_str);
$var_name = $tmp_arr[0];
if(substr($var_name,0,1)=='$') $prefix = sprintf('if(count($__Context->%s)) ', substr($var_name,1));
else $prefix = sprintf('if(count(%s)) ', $var_name);
if(substr($var_name, 0, 1) == '$') {
$prefix = sprintf('if(count($__Context->%s)) ', substr($var_name, 1));
} else {
$prefix = sprintf('if(count(%s)) ', $var_name);
}
} elseif(substr($code, 0, 4) == 'case') {
$suffix = ':';
}
$output = preg_replace('/\$([a-zA-Z0-9\_\-]+)/i','$__Context->\\1', $code).'{';
$output = preg_replace('/\$([a-zA-Z0-9\_\-]+)/i', '$__Context->\\1', $code.$suffix);
break;
}