コード例 #1
0
 public Dictionary<syntax_tree_node, string> Construct(syntax_tree_node tree_root, documentation_comment_list sections_list)
 {
     documentation = new Dictionary<syntax_tree_node, string>();
     if (sections_list.sections.Count == 0)
         return documentation;
     foreach (documentation_comment_section dcs in sections_list.sections)
         line_to_section.Add(dcs.source_context.end_position.line_num + 1, dcs);
     try
     {
         visit_node(tree_root);
     }
     catch
     {
     }
     //visit_node(tree_root);
     line_to_section.Clear();
     Dictionary<syntax_tree_node, string> dcn = documentation;
     documentation = null;
     return dcn;
 }
コード例 #2
0
		public void write_documentation_comment_list(documentation_comment_list _documentation_comment_list)
		{
			write_syntax_tree_node(_documentation_comment_list);
			if (_documentation_comment_list.sections == null)
			{
				bw.Write((byte)0);
			}
			else
			{
				bw.Write((byte)1);
				bw.Write(_documentation_comment_list.sections.Count);
				for(Int32 ssyy_i = 0; ssyy_i < _documentation_comment_list.sections.Count; ssyy_i++)
				{
					if (_documentation_comment_list.sections[ssyy_i] == null)
					{
						bw.Write((byte)0);
					}
					else
					{
						bw.Write((byte)1);
						_documentation_comment_list.sections[ssyy_i].visit(this);
					}
				}
			}
		}
コード例 #3
0
		public void visit(documentation_comment_list _documentation_comment_list)
		{
			bw.Write((Int16)173);
			write_documentation_comment_list(_documentation_comment_list);
		}
コード例 #4
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);
        }
コード例 #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>();
            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);
        }
コード例 #6
0
ファイル: DocParser.cs プロジェクト: Slav76/pascalabcnet
 public syntax_tree_node BuildTree(string FileName, string Text, ParseMode ParseMode, List<string> DefinesList = null)
 {
     MatchCollection mc = Regex.Matches(Text, @"(([\f\t\v\x85\p{Z}])*///.*\r\n)*([\f\t\v\x85\p{Z}])*'''.*", RegexOptions.Compiled);
     syntax_tree_node cu = null;
     documentation_comment_list dcl = new documentation_comment_list();
     if (mc.Count > 0)
     {
         int i = 0;
         int mci = 0, curmindex = mc[0].Index;
         int line_num = 1;
         int col = 1;
         documentation_comment_section dcs=null;
         int dcs_count = 0;
         int dcs_length = 0;
         while (true)
         {
             if (Text[i] == '\n')
             {
                 line_num++;
             }
             if (dcs!=null && dcs_count == dcs_length)
             {
                 dcs.source_context = new SourceContext(dcs.source_context.begin_position.line_num, dcs.source_context.begin_position.column_num, line_num-1, col);
                 dcs = null;
             }
             if (Text[i] == '\n')
             {
                 col = 0;
             }
             if (curmindex == i)
             {
                 dcs = parse_section(mc[mci].Value);
                 if (dcs.tags.Count > 0 || dcs.text!=null)
                 {
                     dcs.source_context = new SourceContext(line_num, col, -1, -1);
                     dcl.sections.Add(dcs);
                     dcs_count = 0;
                     dcs_length = mc[mci].Length;
                 }
                 mci++;
                 if (mci < mc.Count)
                     curmindex = mc[mci].Index;
                 else
                     curmindex = -1;
             }
             i++;
             col++;
             if (dcs != null)
                 dcs_count++;
             if(i==Text.Length || (curmindex==-1 && dcs==null))
                 break;
         }
     }
     return dcl;
 }
コード例 #7
0
        public override void visit(documentation_comment_list _documentation_comment_list)
        {

        }
コード例 #8
0
 public override void visit(documentation_comment_list node)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
		public void read_documentation_comment_list(documentation_comment_list _documentation_comment_list)
		{
			read_syntax_tree_node(_documentation_comment_list);
			if (br.ReadByte() == 0)
			{
				_documentation_comment_list.sections = null;
			}
			else
			{
				_documentation_comment_list.sections = new List<documentation_comment_section>();
				Int32 ssyy_count = br.ReadInt32();
				for(Int32 ssyy_i = 0; ssyy_i < ssyy_count; ssyy_i++)
				{
					_documentation_comment_list.sections.Add(_read_node() as documentation_comment_section);
				}
			}
		}
コード例 #10
0
		public void visit(documentation_comment_list _documentation_comment_list)
		{
			read_documentation_comment_list(_documentation_comment_list);
		}
コード例 #11
0
ファイル: visualizator.cs プロジェクト: Slav76/pascalabcnet
 public override void visit(documentation_comment_list node)
 {
     prepare_collection(node.sections, "sections");
 }
コード例 #12
0
 public void visit(documentation_comment_list _documentation_comment_list)
 {
     throw new NotImplementedException();
 }