Exemplo n.º 1
0
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            List <Error> Errors = new List <Error>();

            PascalABCCompiler.SyntaxTree.syntax_tree_node           sn = ParseCurrent(Errors, "");
            PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParseCurrent(Errors, "dt_") as PascalABCCompiler.SyntaxTree.documentation_comment_list;
            PascalABCCompiler.DocumentationConstructor docconst        = new PascalABCCompiler.DocumentationConstructor();
            Dictionary <PascalABCCompiler.SyntaxTree.syntax_tree_node, string> documentation = docconst.Construct(sn, dt);
        }
 private void toolStripButton2_Click_1(object sender, EventArgs e)
 {
     List<Error> Errors = new List<Error>();
     PascalABCCompiler.SyntaxTree.syntax_tree_node sn = ParseCurrent(Errors, "");
     PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParseCurrent(Errors, "dt_") as PascalABCCompiler.SyntaxTree.documentation_comment_list;
     PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
     Dictionary<PascalABCCompiler.SyntaxTree.syntax_tree_node, string> documentation = docconst.Construct(sn, dt);
 }
Exemplo n.º 3
0
        public DomConverter CompileAllIfNeed(string FileName, bool parse_only_interface = false)
        {
            this.FileName = FileName;
            this.Text     = comp.GetSourceFileText(FileName);
            string ext = Path.GetExtension(FileName);
            List <PascalABCCompiler.Errors.Error> ErrorsList = new List <PascalABCCompiler.Errors.Error>();
            List <CompilerWarning> Warnings = new List <CompilerWarning>();

            PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
            if (Text != null)
            {
                cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings);
            }
            Parser = ParsersController.selectParser(Path.GetExtension(FileName).ToLower());
            ErrorsList.Clear();
            Warnings.Clear();
            PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
            PascalABCCompiler.DocumentationConstructor docconst        = new PascalABCCompiler.DocumentationConstructor();
            if (cu != null)
            {
                docs = docconst.Construct(cu, dt);
            }
            DomConverter dconv = new DomConverter(this);

            dconv.visitor.parse_only_interface = parse_only_interface;
            if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
            {
                dconv.visitor.add_doc_from_text = false;
            }
            if (cu != null)
            {
                dconv.ConvertToDom(cu);
            }
            else
            {
                ErrorsList.Clear();
                Warnings.Clear();
                //cu = ParsersControllerGetComilationUnit(FileName, Text, ErrorsList, true);
                if (comp_modules[FileName] == null)
                {
                    string tmp = ParsersHelper.GetModifiedProgramm(Text);
                    if (tmp != null)
                    {
                        cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
                        ErrorsList.Clear();
                    }
                    if (cu == null)
                    {
                        cu = get_fictive_unit(Text, FileName);
                    }
                }
                ErrorsList.Clear();
                Warnings.Clear();
                dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
                if (cu != null)
                {
                    docs = docconst.Construct(cu, dt);
                }
                if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
                {
                    dconv.visitor.add_doc_from_text = false;
                }
                if (cu != null)
                {
                    dconv.ConvertToDom(cu);
                }
            }
            if (dconv.is_compiled)
            {
                comp_modules[FileName] = dconv;
            }
            if (docs != null)
            {
                docs.Clear();
            }
            //comp_modules[FileName] = dconv;
            // GC.Collect();
            return(dconv);
        }
Exemplo n.º 4
0
        public DomConverter Compile(string FileName, string Text)
        {
            this.Text     = Text;
            this.FileName = FileName;
            List <PascalABCCompiler.Errors.Error> ErrorsList = new List <PascalABCCompiler.Errors.Error>();
            List <CompilerWarning> Warnings = new List <CompilerWarning>();

            PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
            string ext = Path.GetExtension(FileName);

            try
            {
                cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings);
                ErrorsList.Clear();
                PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text /*+")))));end."*/, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
                PascalABCCompiler.DocumentationConstructor docconst        = new PascalABCCompiler.DocumentationConstructor();
                if (cu != null)
                {
                    docs = docconst.Construct(cu, dt);
                }
            }
            catch (Exception e)
            {
#if DEBUG
                File.AppendAllText("log.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
#endif
            }
            DomConverter dconv = new DomConverter(this);
            if (cu != null)
            {
                PascalABCCompiler.NetHelper.NetHelper.reset();

                dconv.ConvertToDom(cu);
            }
            else
            {
                ErrorsList.Clear();
                Warnings.Clear();
                try
                {
                    //cu = ParsersController.GetComilationUnit(FileName, Text+")))));end.",comp.CompilerOptions.ParserSearchPatchs,ErrorsList);
                    //cu = ParsersControllerGetComilationUnit(FileName, get_temp_text(Text), ErrorsList, true);
                    string tmp = ParsersHelper.GetModifiedProgramm(Text);
                    if (tmp != null)
                    {
                        cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
                    }
                    if (comp_modules[FileName] == null)
                    {
                        if (cu == null)
                        {
                            cu = get_fictive_unit(Text, FileName);
                        }
                    }
                    ErrorsList.Clear();
                    PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text + ")))));end.", ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
                    PascalABCCompiler.DocumentationConstructor docconst        = new PascalABCCompiler.DocumentationConstructor();
                    if (cu != null)
                    {
                        docs = docconst.Construct(cu, dt);
                    }
                }
                catch (Exception e)
                {
#if DEBUG
                    File.AppendAllText("log.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
#endif
                }
                if (cu != null)
                {
                    PascalABCCompiler.NetHelper.NetHelper.reset();
                    dconv.ConvertToDom(cu);
                }
            }
            if (docs != null)
            {
                docs.Clear();
            }
            //if (dconv.is_compiled) comp_modules[FileName]=dconv;
            return(dconv);
            //ConvertToDom(cu);
        }
Exemplo n.º 5
0
        public DomConverter Compile(string FileName, string Text)
        {
            this.Text = Text;
            this.FileName = FileName;
            List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
            PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
            string ext = Path.GetExtension(FileName);
            try
            {
                cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList);
                ErrorsList.Clear();
                PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text/*+")))));end."*/, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
                PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
                if (cu != null)
                    docs = docconst.Construct(cu, dt);
            }
            catch (Exception e)
            {

            }
            DomConverter dconv = new DomConverter(this);
            if (cu != null)
            {
                PascalABCCompiler.NetHelper.NetHelper.reset();
                
                dconv.ConvertToDom(cu);
            }
            else
            {
                ErrorsList.Clear();
                try
                {
                    //cu = ParsersController.GetComilationUnit(FileName, Text+")))));end.",comp.CompilerOptions.ParserSearchPatchs,ErrorsList);
                    //cu = ParsersControllerGetComilationUnit(FileName, get_temp_text(Text), ErrorsList, true);
                    string tmp = ParsersHelper.GetModifiedProgramm(Text);
                    if (tmp != null)
                    {
                        cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList);
                    }
                    if (comp_modules[FileName] == null)
                    {
                        if (cu == null)
                            cu = get_fictive_unit(Text, FileName);
                    }
                    ErrorsList.Clear();
                    PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text + ")))));end.", ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
                    PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
                    if (cu != null)
                        docs = docconst.Construct(cu, dt);
                }
                catch (Exception e)
                {

                }
                if (cu != null)
                {
                    PascalABCCompiler.NetHelper.NetHelper.reset();
                    dconv.ConvertToDom(cu);
                }
            }
            if (docs != null) docs.Clear();
            //if (dconv.is_compiled) comp_modules[FileName]=dconv;
            return dconv;
            //ConvertToDom(cu);
        }
Exemplo n.º 6
0
 public DomConverter CompileAllIfNeed(string FileName, bool parse_only_interface=false)
 {
     this.FileName = FileName;
     this.Text = comp.GetSourceFileText(FileName);
     string ext = Path.GetExtension(FileName);
     List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
     PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
     if (Text != null)
     {
         cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList);
     }
     Parser = ParsersController.selectParser(Path.GetExtension(FileName).ToLower());
     ErrorsList.Clear();
     PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
     PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
     if (cu != null)
         docs = docconst.Construct(cu, dt);
     DomConverter dconv = new DomConverter(this);
     dconv.visitor.parse_only_interface = parse_only_interface;
     if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
     {
         dconv.visitor.add_doc_from_text = false;
     }
     if (cu != null)
         dconv.ConvertToDom(cu);
     else
     {
         ErrorsList.Clear();
         //cu = ParsersControllerGetComilationUnit(FileName, Text, ErrorsList, true);
         if (comp_modules[FileName] == null)
         {
             string tmp = ParsersHelper.GetModifiedProgramm(Text);
             if (tmp != null)
             {
             	cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList);
             	ErrorsList.Clear();
             }
             if (cu == null)
             cu = get_fictive_unit(Text, FileName);
         }
         ErrorsList.Clear();
         dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
         if (cu != null)
             docs = docconst.Construct(cu, dt);
         if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
         {
         	dconv.visitor.add_doc_from_text = false;
         }
         if (cu != null)
         {
             dconv.ConvertToDom(cu);
         }
     }
     if (dconv.is_compiled) comp_modules[FileName] = dconv;
     if (docs != null) docs.Clear();
     //comp_modules[FileName] = dconv;
     // GC.Collect();
     return dconv;
 }
 private Dictionary<SyntaxTree.syntax_tree_node,string> AddDocumentationToNodes(SyntaxTree.compilation_unit cu, string Text)
 {
 	List<PascalABCCompiler.Errors.Error> errors = new List<PascalABCCompiler.Errors.Error>();
 	string doctagsParserExtension = Path.GetExtension(cu.file_name)+"dt"+PascalABCCompiler.Parsers.Controller.HideParserExtensionPostfixChar;
 	PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(cu.file_name, doctagsParserExtension), Text, errors, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
 	if (errors.Count > 0) return null;
 	PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
     return docconst.Construct(cu, dt);
 }