Example #1
0
        /// <summary>
        /// New implementation of the Init function, to allocate a BuildProject instance rather than a
        /// CompilationProject.
        /// </summary>
        /// <param name="path">The path of the file to parser</param>
        /// <param name="format">The resulting document format</param>
        /// <returns>The BuildProject instance created</returns>
        public new BuildProject Init(string path, DocumentFormat format = null)
        {
            FileCompiler compiler;

            if (Compilers.TryGetValue(path, out compiler))
            {
                return(m_Projects[path]);
            }
            string        directory = Directory.GetParent(path).FullName;
            string        filename  = Path.GetFileName(path);
            DirectoryInfo root      = new DirectoryInfo(directory);

            if (format == null)
            {
                format = GetFormat(path);
            }
            TypeCobolOptions options = new TypeCobolOptions();
            BuildProject     project = new BuildProject(BuilderEngine, path, root.FullName, new string[] { "*.cbl", "*.cpy" },
                                                        format.Encoding, format.EndOfLineDelimiter, format.FixedLineLength, format.ColumnsLayout, options);

            m_Projects[path] = project;
            compiler         = new FileCompiler(null, filename, project.SourceFileProvider, project, format.ColumnsLayout, options, CustomSymbols, false);
            Compilers.Add(path, compiler);
            Inits.Add(path, false);
            return(project);
        }
Example #2
0
 /// <summary>
 /// 添加编译器
 /// </summary>
 /// <param name="name"></param>
 /// <param name="compiler"></param>
 public virtual void AddCompiler(string name, ICompiler compiler)
 {
     if (Compilers.ContainsKey(name))
     {
         return;
     }
     Compilers.Add(name, compiler);
 }
Example #3
0
        public static void Register <TCompiler>() where TCompiler : class, CompilerInterfaceType, new()
        {
            var compilerAttribute = Attribute.GetCustomAttribute(typeof(TCompiler), typeof(CompilerTypeAttribute)) as CompilerTypeAttribute;

            if (compilerAttribute == null)
            {
                throw new NotSupportedException("CompilerTypeAttribute is not assigned");
            }
            if (!typeof(ElementType).IsAssignableFrom(compilerAttribute.NodeType))
            {
                throw new NotSupportedException();
            }

            Compilers.Add(compilerAttribute.NodeType, new TCompiler());
        }
Example #4
0
        public static void Register(Type compilerType)
        {
            var compilerAttribute = Attribute.GetCustomAttribute(compilerType, typeof(CompilerTypeAttribute)) as CompilerTypeAttribute;

            if (compilerAttribute == null)
            {
                throw new NotSupportedException("CompilerTypeAttribute is not assigned");
            }
            if (!typeof(ElementType).IsAssignableFrom(compilerAttribute.NodeType))
            {
                throw new NotSupportedException();
            }

            Compilers.Add(compilerAttribute.NodeType, (CompilerInterfaceType)Activator.CreateInstance(compilerType));
        }