[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: switch and continue





Begin forwarded message:

From: Dave Baum <dbaum@enteract.com>
Date: 2000-06-06 01:56:14 +0200
To: "Axel T. Schreiner" <axel@uos.de>
Subject: Re: switch and continue
In-Reply-To: <004501bfced5$92434020$55829fc1@Noname>
Delivered-To: axel@luna2.informatik.Uni-Osnabrueck.DE
X-Sender: dbaum@pop.enteract.com
X-UIDL: f7850185e8c338e4b06e2154158552fc

>Is it intentional that in nqc (2.1 I believe) the following draws  
an error:
>
>while(true) switch (x) { case 1: if (...) continue; }
>
>i.e., continue is allowed in a loop but not in a switch inside a loop?

Just an oversight on my part - I'll fix it in the next release.

>[As I recall from my compiler construction book, a C compiler needs  
to use
>explicit stacks for break and continue and they have to be pushed  
and popped
>by the various loop and decision structures; you cannot use yacc's  
own stack
>for this.]

You're correct - loop contexts need to be managed separately.  My
mistake was that 'switch' pushes its own loop context (for 'break')
and instead of inheriting an existing 'continue' context (if any) it 
sets it to null because I combined break/continue into a single
context.  I'll either have to split them out separately or let the
switch statement inherit an existing continue context.

Dave