SetInput() public method

public SetInput ( string input ) : LexState
input string
return LexState
Exemplo n.º 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;
        }