function constr_switch(&$bc) { global $type, $val, $next, $nextval; #-- prepare bc stream $r = array(JS_SWITCH, 0); #-- remove tokens jsc::want(JS_SWITCH); jsc::want(JS_BRACE1); $r[1] = jsc::expr_start(); jsc::want(JS_BRACE0); #-- read body jsc::want(JS_CURLYBR1); #-- search for "case" statements $i = 2; do { jsc::get(); # "case" or "}" if ($type == JS_CASE) { //jsc::get(); # ":" $r[$i++] = jsc::expr_start(); jsc::want(JS_COLON, ":", "_constr_switch4"); jsc::block($r[$i++], array(JS_CASE, JS_DEFAULT, JS_CURLYBR0, JS_END), false); } elseif ($type == JS_DEFAULT) { jsc::want(JS_COLON, ":", "_constr_switch5"); $r[$i++] = array(JS_DEFAULT); jsc::block($r[$i++], array(JS_CASE, JS_CURLYBR0, JS_END), false); } else { jsc::err("malformed switch construct"); } } while ($type != JS_CURLYBR0 && $next != JS_EOF); jsc::want(JS_CURLYBR0); #-- end $bc[] = $r; }