Esempio n. 1
0
 private static void Project_Compile(Dictionary <string, IList <Token> > project, bool embDebugToken)
 {
     foreach (KeyValuePair <string, IList <Token> > f in project)
     {
         //先把所有代码里的类注册一遍
         IList <IType> types = CQ_Expression_Compiler.FilePreCompile(f.Key, f.Value);
         foreach (var type in types)
         {
             RegisterType(type);
         }
     }
     foreach (KeyValuePair <string, IList <Token> > f in project)
     {
         //预处理符号
         for (int i = 0; i < f.Value.Count; i++)
         {
             if (f.Value[i].type == TokenType.IDENTIFIER && CQ_TokenParser.ContainsType(f.Value[i].text)) //有可能预处理导致新的类型
             {
                 if (i > 0
                     &&
                     (f.Value[i - 1].type == TokenType.TYPE || f.Value[i - 1].text == "."))
                 {
                     continue;
                 }
                 Token rp = f.Value[i];
                 rp.type    = TokenType.TYPE;
                 f.Value[i] = rp;
             }
         }
         File_CompileToken(f.Key, f.Value, embDebugToken);
     }
 }
Esempio n. 2
0
        private static void File_CompileToken(string filename, IList <Token> listToken, bool embDebugToken)
        {
            DebugUtil.Log("File_CompilerToken:" + filename);
            IList <IType> types = CQ_Expression_Compiler.FileCompile(filename, listToken, embDebugToken);

            foreach (var type in types)
            {
                if (GetTypeByKeywordQuiet(type.keyword) == null)
                {
                    RegisterType(type);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 这里的filename只是为了编译时报错可以看到出错文件
        /// </summary>

        public static ICQ_Expression BuildBlock(string code)
        {
            var token = ParserToken(code);

            return(CQ_Expression_Compiler.Compile(token));
        }