public void EvalFromFile(string fileName)
        {
        	lock(LockObj)
        	{
        		using(var tmpReader = File.OpenText(fileName))
        		{
        			var tmpLexer = new StillOneScriptCore.Parser.Lexer.LexerEngine();
        			
        			tmpLexer.Run(tmpReader);
        			
        			var tmpSyntaxer = new StillOneScriptCore.Parser.Syntaxer.SyntaxerEngine();
        			
        			tmpSyntaxer.Run(tmpLexer.Tokens);
        			
        			var tmpLoader = new StillOneScriptCore.Loader.LoaderEngine(mEngineEnvironment);

        			tmpLoader.Load(tmpSyntaxer.Result);

        			var tmpCustomFun = tmpLoader.Result;

        			tmpCustomFun.Call();
        		}
        	}   
        }
示例#2
0
        private static void TSTLexer()
        {
            var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment();

            tmpEnvironment.Init();

            using(var tmpReader = File.OpenText("Script.txt"))
            {
                var tmpLexer = new StillOneScriptCore.Parser.Lexer.LexerEngine();

                tmpLexer.Run(tmpReader);

                var tmpSyntaxer = new StillOneScriptCore.Parser.Syntaxer.SyntaxerEngine();

                try
                {
                    tmpSyntaxer.Run(tmpLexer.Tokens);
                }catch(StillOneScriptCore.Parser.Syntaxer.SyntaxerException e){
                    NLog.LogManager.GetCurrentClassLogger().Info("e.ToString() = {0}", e.ToString());
                    NLog.LogManager.GetCurrentClassLogger().Info("e.TokenText = {0}", e.TokenText);
                    NLog.LogManager.GetCurrentClassLogger().Info("e.Line = {0}", e.Line);
                    NLog.LogManager.GetCurrentClassLogger().Info("e.Pos = {0}", e.Pos);

                    return ;
                }

                var tmpRez = tmpSyntaxer.Result;

                if (tmpRez == null)
                {
                    NLog.LogManager.GetCurrentClassLogger().Info("tmpRez == null");

                    return;
                }

                NLog.LogManager.GetCurrentClassLogger().Info(tmpRez.DisplayAsTree());

                var tmpLoader = new StillOneScriptCore.Loader.LoaderEngine(tmpEnvironment);

                tmpLoader.Load(tmpSyntaxer.Result);

                var tmpCustomFun = tmpLoader.Result;

                tmpCustomFun.Call();

                NLog.LogManager.GetCurrentClassLogger().Info("Finish");
            }
        }