diff options
Diffstat (limited to 'awkgram.y')
-rw-r--r-- | awkgram.y | 45 |
1 files changed, 14 insertions, 31 deletions
@@ -602,22 +602,6 @@ statement_term | semi opt_nls ; -switch_head - : LEX_SWITCH '(' exp r_paren opt_nls - { - INSTRUCTION *ip; - - ip = $3; - if (do_pretty_print) { - (void) list_prepend(ip, $1); - (void) list_prepend(ip, instruction(Op_exec_count)); - } - /* else - $1 is NULL */ - $$ = ip; - } - ; - statement : semi opt_nls { $$ = NULL; } @@ -630,7 +614,7 @@ statement else $$ = $1; } - | switch_head l_brace case_statements opt_nls r_brace + | LEX_SWITCH '(' exp r_paren opt_nls l_brace case_statements opt_nls r_brace { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -645,12 +629,11 @@ statement dflt = instruction(Op_jmp); dflt->target_jmp = tbreak; /* if no case match and no explicit default */ - if ($3 != NULL) { - curr = $3->nexti; - bcfree($3); /* Op_list */ - } - /* else - curr = NULL; */ + if ($7 != NULL) { + curr = $7->nexti; + bcfree($7); /* Op_list */ + } /* else + curr = NULL; */ for (; curr != NULL; curr = nextc) { INSTRUCTION *caseexp = curr->case_exp; @@ -704,15 +687,15 @@ statement if (case_values != NULL) efree(case_values); - ip = $1; + ip = $3; if (do_pretty_print) { - INSTRUCTION *exp = $1->nexti->nexti; - exp->target_break = tbreak; - (exp + 1)->switch_start = cexp->nexti; - (exp + 1)->switch_end = cexp->lasti; - } - /* else - $1 is NULL */ + (void) list_prepend(ip, $1); + (void) list_prepend(ip, instruction(Op_exec_count)); + $1->target_break = tbreak; + ($1 + 1)->switch_start = cexp->nexti; + ($1 + 1)->switch_end = cexp->lasti; + }/* else + $1 is NULL */ (void) list_append(cexp, dflt); (void) list_merge(ip, cexp); |