Tools.Lexer.TryActions C# (CSharp) Method

TryActions() private method

private TryActions ( Dfa dfa, TOKEN &tok ) : bool
dfa Dfa
tok TOKEN
return bool
        bool TryActions(Dfa dfa,ref TOKEN tok)
        {
            int len = m_pch-m_startMatch;
            if (len==0)
                return false;
            if (m_startMatch+len<=m_buf.Length)
                yytext = m_buf.Substring(m_startMatch,len);
            else // can happen with {EOF} rules
                yytext = m_buf.Substring(m_startMatch);
            // actions is a list of old-style actions for this DFA in order of priority
            // there is a list because of the chance that any of them may REJECT
            Dfa.Action a = dfa.m_actions;
            bool reject = true;
            while (reject && a!=null)
            {
                int action = a.a_act;
                reject = false;
                a = a.a_next;
                if (a==null && dfa.m_tokClass!="")
                { // last one might not be an old-style action
                    if (m_debug)
                        Console.WriteLine("creating a "+dfa.m_tokClass);
                    tok=(TOKEN)Tfactory.create(dfa.m_tokClass,this);
                }
                else
                {
                    tok = m_tokens.OldAction(this,ref yytext,action,ref reject);
                    if (m_debug && !reject)
                        Console.WriteLine("Old action "+action);
                }
            }
            return !reject;
        }