Tools.Dfa.AddNfaNode C# (CSharp) Method

AddNfaNode() private method

private AddNfaNode ( NfaNode nfa ) : bool
nfa NfaNode
return bool
        internal bool AddNfaNode(NfaNode nfa)
        {
            if (!m_nfa.Add(nfa))
                return false;
            if (nfa.m_sTerminal!="")
            {
                int qi,n=0;
                string tokClass = "";
                string p=nfa.m_sTerminal;
                if (p[0]=='%')
                { // check for %Tokname special action
                    for (n=0,qi=1;qi<p.Length;qi++,n++) // extract the class name
                        if (p[qi]==' '||p[qi]=='\t'||p[qi]=='\n'||p[qi]=='{'||p[qi]==':')
                            break;
                    tokClass = nfa.m_sTerminal.Substring(1,n);
                }
                // check for ResWds machinery // 4.7
                if (n>0 && n+1<p.Length)
                {
                    string st = nfa.m_sTerminal.Substring(n+1).Trim();
                    if (st.Length>0) {
                        if (st.StartsWith("%except"))
                        {
                            m_reswds = nfa.m_state;
                            m_tks.m_tokens.reswds[nfa.m_state] = ResWds.New(m_tks,st.Substring(7));
                        }
                    }
                }
                // special action is always last in the list
                if (tokClass=="")
                { //nfa has an old action
                    if (m_tokClass=="" // if both are old-style
                        || // or we have a special action that is later
                        (m_actions.a_act)>nfa.m_state)   // m_actions has at least one entry
                        AddAction(nfa.m_state);
                    // else we have a higher-precedence special action so we do nothing
                }
                else if (m_actions==null || m_actions.a_act>nfa.m_state)
                {
                    MakeLastAction(nfa.m_state);
                    m_tokClass = tokClass;
                } // else we have a higher-precedence special action so we do nothing
            }
            return true;
        }

Usage Example

Ejemplo n.º 1
0
 // helper for building DFa
 public void AddTarget(char ch, Dfa next)
 {
     for (int j = 0; j < m_arcs.Count; j++)
     {
         Arc a = (Arc)m_arcs[j];
         if (a.Match(ch))
         {
             next.AddNfaNode(a.m_next);
         }
     }
 }
All Usage Examples Of Tools.Dfa::AddNfaNode