/* ===================================================================== Source: case.rule ===================================================================== */ op_case_fgl_expr_c : {$$=0;} | fgl_expr_c {$$=$1;} ; case_cmd : CASE atline op_case_fgl_expr_c { push_blockcommand("CASE"); add_feature("CASE_EXPR"); setinc(1); setinc(1); } when_unit op_otherwise_command end_case_command { int blk; blk=get_sio_ids("CASE"); /*print_after_when(0); */ //continue_blockcommand("CASE"); pop_blockcommand("CASE"); set_cmdlineno($2); $$=new_case_cmd(chk_expr($3), $5, $6,blk); } ; op_then : | KW_THEN ; when_unit : when_command { $$=malloc(sizeof(whens)); $$->whens.whens_len=1; $$->whens.whens_val=malloc(sizeof($$->whens.whens_val[0]) * $$->whens.whens_len); $$->whens.whens_val[$$->whens.whens_len-1]=$1; } | when_unit when_command { $$=$1; $$->whens.whens_len=$1->whens.whens_len+1; $$->whens.whens_val=realloc($1->whens.whens_val, sizeof($$->whens.whens_val[0]) * $$->whens.whens_len); $$->whens.whens_val[$$->whens.whens_len-1]=$2; } ; end_case_command : END_CASE ; op_otherwise_command : {$$=0;} | OTHERWISE { lastlineno=yylineno;} commands_as_list { $$=$3; } ; when_command : WHEN atline fgl_expr_c op_then { lastlineno=yylineno;} commands_as_list { $$=malloc(sizeof(when)); $$->when_expr=chk_expr($3); $$->when_commands=$6; $$->lineno=$2; $$->colno=0; setinc(-1); } ; /* ================================= case.rule ============================= */