Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!VAX1.CC.UAKRON.EDU!math-cs.kent.edu!usenet.ins.cwru.edu!abvax!abaa!korsberg From: korsberg@abaa.uucp (Ed Korsberg) Newsgroups: comp.lang.c Subject: Re: The right-left rule Keywords: declaration decipher Message-ID: <5593@abaa.UUCP> Date: 17 Jul 90 14:25:50 GMT References: <1990Jul16.163612.5344@kfw.COM> <1990Jul16.195111.5976@kfw.COM> <1990Jul17.125413.7968@agate.berkeley.edu> Reply-To: korsberg@abaa.UUCP (Ed Korsberg) Distribution: na Organization: Allen Bradley Lines: 53 In article <1990Jul16.195111.5976@kfw.COM> will@kfw.com (Will Crowder) writes: >[150 lines about the right-left rule] I have a table driven FSM with a state variable (state_variable) which points to one of several state tables (see trivial example below). Given the current state (state_variable) and an event, I want to call the appropriate action (func_x in tables). void (*state1_table[]) () = { func_1 /* EVENT 1 */ ,func_2 /* EVENT 2 */ ,func_3 /* EVENT 3 */ ,func_4 /* EVENT 4 */ }; void (*state2_table[]) () = { func_1 /* EVENT 1 */ ,func_2 /* EVENT 2 */ ,func_7 /* EVENT 3 */ ,func_6 /* EVENT 4 */ }; void (*state3_table[]) () = { func_1 /* EVENT 1 */ ,func_8 /* EVENT 2 */ ,func_0 /* EVENT 3 */ ,func_4 /* EVENT 4 */ }; fsm(event) unsigned int event; /* occurance of EVENT n */ { void (*action)(); action = state_variable[event]; /* From STATE and EVENT, get action */ (*action)(); /* perform action */ } **************************************************************************** Problem is how do you declare a pointer to an array of pointers of functions returning void? I need something like void (*state_variable)[] but cannot seem to get the syntax correct. Any help on this would be appreciated. --------------------------------------------------------------------------- Ed Korsberg korsberg@aa.ab.com