- | CASE constant_expr ':' statement { $$ = createCase(STACK_PEEK(swStk),$2,$4); }
- | DEFAULT ':' statement { $$ = createDefault(STACK_PEEK(swStk),$3); }
+ | CASE constant_expr ':' statement
+ {
+ if (STACK_EMPTY(swStk))
+ $$ = createCase(NULL,$2,$4);
+ else
+ $$ = createCase(STACK_PEEK(swStk),$2,$4);
+ }
+ | DEFAULT { $<asts>$ = newNode(DEFAULT,NULL,NULL); } ':' statement
+ {
+ if (STACK_EMPTY(swStk))
+ $$ = createDefault(NULL,$<asts>2,$4);
+ else
+ $$ = createDefault(STACK_PEEK(swStk),$<asts>2,$4);
+ }