NPLMono.NPLLex.SetInput C# (CSharp) Method

SetInput() public method

public SetInput ( string input ) : LexState
input string
return LexState
        public LexState SetInput(string input)
        {
            m_zio.setinput(input);

            m_lexState.bSucceed = true;
            m_lexState.lookahead.token = (int)RESERVED.TK_EOS;  /* no look-ahead token */
            m_lexState.z = m_zio;
            m_lexState.linenumber = 1;
            m_lexState.lastline = 1;
            m_lexState.buff = new char[0];

            next(m_lexState);  /* read first char */
            if (m_lexState.current == '#')
            {
                do
                {  /* skip first line */
                    next(m_lexState);
                } while (m_lexState.current != '\n' && m_lexState.current != EOZ);
            }
            return m_lexState;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// converting string to NPL table object 
        /// </summary>
        /// <param name="input">such as "{nid=10, name=\"value\", tab={name1=\"value1\"}}"</param>
        /// <returns>may return null if failed.</returns>
        public static NPLObjectProxy StringToNPLTable(string input)
        {
            NPLLex lex = new NPLLex();
            NPLLex.LexState ls = lex.SetInput(input);
            ls.nestlevel = 0;

            try
            {
                NPLParser.next(ls);  /* read first token */

                if(ls.t.token == '{')
                {
                    NPLObjectProxy output = new NPLObjectProxy();
                    if (DeserializePureNPLDataBlock(ls, ref output))
                    {
                        NPLParser.testnext(ls, ';');
                        if (ls.t.token == (int)NPLLex.RESERVED.TK_EOS)
                        {
                            return output;
                        }
                    }
                }
            }
            catch (Exception err)
            {
                ParaGlobal.applog("error:" + err.ToString() + "in NPLHelper::StringToNPLTable()");
                return null;
            }
            return null;
        }