Esempio n. 1
0
        public CompileResult Compile(string source, string sourceFileName, bool compileFuncVarTree, ProgramPart part)
        {
            CompileResult = new CompileResult();

            string fullPath = Path.GetFullPath(sourceFileName);
            sourceFileName = Path.GetFileName(fullPath);

            // Data Transfer Object
            var dto = new CompilerDTO { ProgramPath = Path.GetDirectoryName(fullPath) };

            // Resolve Imports
            ResolveImports(source, sourceFileName, dto, part);

            // Finalize TypeIdentifiers
            FinalizeTypeIdentifiers(dto);

            // Analise and Compile all source file.
            foreach (var cu in dto.CompilationUnitList)
            {
                if (dto.CompilerMessages.AntlrErrors.Find(x => x.Interval.FileName == cu.FileName) == null)
                {
                    // Semantic analisis
                    Analise(cu, dto, part);

                    // Code generation
                    GenerateMicrolexCode(cu, dto, part);
                }
            }

            // Function Variable tree builder.
            if (compileFuncVarTree && part == ProgramPart.CompilationUnit)
                CompileResult.PsiFunctionsVariablesNodeList = GenerateFuncVarTree(dto.CompilationUnitList);

            // Finalise the overall result (CompilerDTO -> CompilerResult)
            FinaliseTheResult(dto);

            return CompileResult;
        }
Esempio n. 2
0
 public Compiler(IPsiNodeParser parser)
 {
     Parser = parser;
     CompileResult = new CompileResult();
 }