mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 21:12:15 +09:00
#356 switch 구문 지원 추가
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4341 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
c4fdd3fc47
commit
b0cd9370c6
1 changed files with 24 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue