今学期のオペレーティングシステムのクラスでステートマシンについて学び、苦労しています。これは、提供されたコードの抜粋です。誰かが私にそれが何をしているのか、またはスイッチがどのように実装されるのかを説明してもらえますか?私は運がなくて本を読み終えました、そして私の先生は今週利用できません。これは課題ではなく、状態の実装方法を理解するのに役立つ段階的でない演習です。私を助けてください!
/* Implements a state machine that parses the command line arguments, searching for switches and switch parameters.*/
int switches::getswitch()
{
while (true) // loop until a switch is identified and returned
{
int c = next(); // get next character to parse
switch (state) // process the current state
{
case START: //whats going on here?
{
sign = 0;
if (c == END_S && index >= args.size())
return END_S;
switch (c)
{
case '/':
state = S_SWITCH;
break;
default:
next_arg();
state = START;
break;
}
break;
}
// Add states here, what are the states that need to be implemented and how are they implemented?
}
}
}