예제 #1
0
        public Script CompileDirect(List <Token> tokenList, Data custom = null, string fileName = "",
                                    CompilerOptions options             = default(CompilerOptions))
        {
            script = new Script();
            if (custom != null)
            {
                script.data = custom;
            }
            tokenList.RemoveAll(token => token.type == TokenType.EOF &&
                                tokenList.IndexOf(token) + 1 < tokenList.Count &&
                                tokenList[tokenList.IndexOf(token) + 1].type == TokenType.EOF);
            TokenProcessor.Process(tokenList, fileName, options);
            compile(new Queue <Token>(tokenList));

            return(script);
        }
예제 #2
0
        public Script Compile(string code, Data custom = null, string fileName = "",
                              CompilerOptions options  = default(CompilerOptions))
        {
            code = code.Replace("\r", "");
            if (tokenizer == null)
            {
                tokenizer = new Tokenizer();
            }
            script = new Script();
            if (custom != null)
            {
                script.data = custom;
            }
            var tokenList = tokenizer.Tokenize(code);

            tokenList.RemoveAll(token => token.type == TokenType.EOF &&
                                tokenList.IndexOf(token) + 1 < tokenList.Count &&
                                tokenList[tokenList.IndexOf(token) + 1].type == TokenType.EOF);
            TokenProcessor.Process(tokenList, fileName, options);
            compile(new Queue <Token>(tokenList));

            return(script);
        }