public override void Generate(ScriptLoader owner) { LookaheadStack <INodeEnumerator> nodes = this.nodes; LookaheadStack <uint> states = this.states; int proc_state = 0; object proc_arg = null; INodeEnumerator ne = m_enumerator; IExceptionHandler ehnd = m_handler; loop: uint state = states.PopOrDefault(); while (ne.MoveNext()) { INode node = ne.Current; if (node.ChildCount == 0) { bool goNext; do { goNext = OnGenerate(node.GetToken(), state, ref proc_state, ref proc_arg); if (ehnd.FailCount > 0) { ne.Dispose(); while (nodes.Count > 0) { nodes.Pop().Dispose(); } return; } else if (proc_state != 0) { proc_arg = OnRequested(ref state, ref proc_state, proc_arg); } // 다음으로 넘어가지 않는다 // 반복 } while (!goNext); } else { nodes.Push(ne); ne = node.GetEnumerator(); } } ne.Dispose(); if (nodes.Count > 0) { ne = nodes.Pop(); goto loop; } // 끝내기 전에 마무리지어야 한다 }
/// <summary> /// 요청된 state에 대한 자료를 처리합니다 /// </summary> /// <param name="processing_state">요청된 state</param> /// <param name="in_argument">함께 전달된 argument (default: null)</param> /// <returns>반환할 argument</returns> protected virtual object OnRequested(ref uint state, ref int processing_state, object in_argument) { if (processing_state <= PROC_SKIP) { processing_state = 0; } else if (processing_state == PROC_SYSTEM_NEXTSTATE) { state = states.PopOrDefault(); processing_state = 0; } return(null); }