看板 DFBSD_kernel 關於我們 聯絡資訊
On Fri, 3 Sep 2004 20:05:08 +0200 "Simon 'corecode' Schubert" <corecode@fs.ei.tum.de> wrote: > for example: > > state_idle: > if: > written_byte & WHATEVER_BITMASK > newstate: > state_program_oneshot > output: > this_var = that_var; > run_foo(); static void (*state)(void); static void state_idle(void) { if (written_byte & WHATEVER_BITMASK) { this_var = that_var; run_foo(); state = state_program_oneshot; return; } else if ... } .... void run_fsm(void) { state = start_state; while (state != NULL) { state(); } } This design pattern is heavily employed in the installer. I don't think the specialized notation has many advantages over the C version, especially in this instance. Yacc and lex are a different area of application - they transform a regular expression or a grammar into a DFA or a LALR table - i.e. something of significantly different structure. On the other hand, these state descriptions look very very similar to their C equivalents. -Chris