Am 02.12.2010 um 12:25 schrieb Mark Cave-Ayland:
Andreas Färber wrote:
Hello, A construct like: [IFDEF] CONFIG_PPC [IFDEF] CONFIG_PPC64 5 [ELSE] 4 [THEN] [ELSE] [IFDEF] CONFIG_SPARC64 6 [ELSE] 3 [THEN] [THEN] has been seen to return, e.g., 4 3 according to the debug word. Is this nesting forbidden in Forth? Easily fixable? A better way to do this? I do want a final catch-all since returning no value would have unexpected results, and we currently do not have a define CONFIG_PPC32 so that a concatenation of independent [IFDEF]... [THEN]s wouldn't work.
IIRC [IFDEF] [ELSE] and [THEN] are simply Forth words that swallow the input unless the condition is met.
I suspect it will be similar to the bbranch & friends Fcode instructions whereby at compile time the current nested state is held on the dstack.
I don't really understand the code in forth/lib/preprocessor.fs but it looks as if some state is held in three variables. Also the [ELSE] case handling in the [IF] loop looks unintuitive...
http://repo.or.cz/w/openbios/afaerber.git/blob/HEAD:/forth/lib/preprocessor....
Andreas