Somewhere between C and ADA...

John Hascall hascall at cs.iastate.edu
Thu Mar 15 13:21:50 AEST 1990


#include <stdio.h>
#include <ctype.h>
#include "ohmygod.h"

int main(int argc, char **argv) {

	register int	i;
	register int	n;
	register char	c;

	n = strlen(argv[1]);
	begin(for_each_char, iterate, i = 0; i < n; i++)
		c = tolower(argv[1][i]);
		begin(which_kind, when, c)
			is 'a' or 'e' or 'i' or 'o' or 'u':
				printf("it's a vowel:\t");
			is 'y':
				printf("it might be a vowel:\t");
			is ' ':
				printf("(blank)\n");
				resume(for_each_char);
			is 'j':
				printf("don't like the letter `j'!\n");
				leave(for_each_char);
			is 'b':
				if (i < 5) {
					printf("don't care for this here:\t");
					leave(which_kind);
				}
				printf("this is ok here:\t
			is 'w':
				c = '?';
				resume(which_kind);
			otherwise:
				printf("it's not a vowel:\t");
		end(which_kind, when)
		printf("%c.\n", c);
	end(for_each_char, iterate)
}
-------------- ohmygod.h -------------------------

#define begin(name,what,exp) what(name,exp)
#define	end(name,what)       end_/**/what(name)
#define	iterate(name,exp)    if (0) {L/**/name: ;} else for(exp) {
#define	end_iterate(name)    R/**/name:;}
#define	when(name,exp)       if (0) {name: break;} else R/**/name: switch(exp){
#define	end_when(name)       }
#define is                   break;case
#define or                   : case
#define	otherwise            default
#define	leave(name)          goto L/**/name
#define	resume(name)         goto R/**/name
/* etc... */
-----------------------------------------------------------

Lock me away in the Wolfe ward of the loony-bin for even
dreaming this up!

John Hascall  /  ISU Comp Ctr  / hascall at atanasoff.cs.iastate.edu



More information about the Comp.lang.c mailing list