Tools.Parser.Parse C# (CSharp) Method

Parse() private method

private Parse ( ) : SYMBOL
return SYMBOL
        SYMBOL Parse()
        {
            ParserEntry pe;
            SYMBOL newtop;
            Create();
            ParseStackEntry top = new ParseStackEntry(this,0,NextSym());
            try
            {
                for (;;)
                {
                    string cnm = top.m_value.yyname;
                    if (m_debug)
                    {
                        if (cnm.Equals("TOKEN"))
                            Console.WriteLine(String.Format("State {0} with {1} \"{2}\"", top.m_state, cnm,((TOKEN)top.m_value).yytext));
                        else
                            Console.WriteLine(String.Format("State {0} with {1}", top.m_state, cnm));
                    }
                    if (top.m_value!=null && top.m_value.Pass(m_symbols,top.m_state, out pe))
                        pe.Pass(ref top);
                    else if (top.m_value==m_symbols.EOFSymbol)
                    {
                        if (top.m_state==m_symbols.m_accept.m_state)
                        { // successful parse
                            Pop(ref top,1,m_symbols.m_startSymbol);
                            if (m_symbols.erh.counter>0)
                                return new recoveredError(this,top);
                            newtop = top.m_value; // extract the return value
                            top.m_value = null;
                            return newtop;
                        }
                        if (!Error(ref top,"Unexpected EOF")) // unrecovered error
                            return top.m_value;
                    }
                    else if (!Error(ref top,"syntax error")) // unrecovered error
                        return top.m_value;
                    if (m_debug)
                    {
                        object ob = null;
                        if (top.m_value!=null)
                        {
                            ob = top.m_value.m_dollar;
                            Console.WriteLine("In state {0} top {1} value {2}",top.m_state,top.m_value.yyname,(ob==null)?"null":ob.GetType().Name);
                            if (ob!=null && ob.GetType().Name.Equals("Int32"))
                                Console.WriteLine((int)ob);
                            else
                                ((SYMBOL)(top.m_value)).Print();
                        }
                        else
                            Console.WriteLine("In state {0} top NULL",top.m_state);
                    }
                }
                // not reached
            }
            catch(CSToolsStopException ex) // stop parsing
            {
                if (m_symbols.erh.throwExceptions)
                    throw ex;						// 4.5b
                m_symbols.erh.Report(ex);			// 4.5b
            }
            return null;
        }

Same methods

Parser::Parse ( CsReader inFile ) : SYMBOL
Parser::Parse ( StreamReader input ) : SYMBOL
Parser::Parse ( string buf ) : SYMBOL