예제 #1
0
        public PascalABCCompiler.SyntaxTree.compilation_unit ParseOnlySyntaxTree(string FileName, string Text)
        {
            List <PascalABCCompiler.Errors.Error> ErrorsList = new List <PascalABCCompiler.Errors.Error>();
            List <CompilerWarning> Warnings = new List <CompilerWarning>();

            PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings);
            return(cu);
        }
  	public void ConvertToDom(compilation_unit cu)
      {
          CodeCompletionController.comp.CompilerOptions.SourceFileName = cu.file_name;
          stv.Convert(cu);
         	is_compiled = true;
          cur_used_assemblies = (Hashtable)PascalABCCompiler.NetHelper.NetHelper.cur_used_assemblies.Clone();
 			return;
      }
예제 #3
0
 public void Compare(compilation_unit left, compilation_unit right)
 {
     if (left.GetType() != right.GetType())
         throw_not_equal(left, right);
     if (left is program_module)
         CompareInternal(left as program_module, right as program_module);
     else if (left is unit_module)
         CompareInternal(left as unit_module, right as unit_module);
 }
예제 #4
0
 public ReferenceFinder(IBaseScope founded_scope, IBaseScope entry_scope, compilation_unit cu, string FileName, bool for_refactoring)
 {
     this.founded_scope = founded_scope;
     this.entry_scope = entry_scope;
     this.cur_scope = entry_scope;
     this.pos_list = new List<Position>();
     this.cu = cu;
     this.FileName = FileName;
     this.for_refactoring = for_refactoring;
 }
예제 #5
0
		public void Convert(compilation_unit cu)
        {
            try
            {
				cu.visit(this);
            }
            catch(Exception e)
            {
            	//System.Diagnostics.Debug.WriteLine(e.StackTrace);
            }
        }
예제 #6
0
 public Dictionary<syntax_tree_node, string[]> Bind(compilation_unit cu, string Text)
 {
     this.Text = Text;
     string[] lines = Text.Split('\n');
     line_lens = new int[lines.Length];
     for (int i = 0; i < lines.Length; i++)
     {
         if (i > 0)
             line_lens[i] = lines[i].Length + line_lens[i-1] + 1;
         else
             line_lens[i] = lines[i].Length + 1;
     }
     cu.visit(this);
     return comment_table;
 }
		public void visit(compilation_unit _compilation_unit)
		{
			read_compilation_unit(_compilation_unit);
		}
예제 #8
0
		public override void visit(compilation_unit _compilation_unit)
        {
            prepare_collection(_compilation_unit.compiler_directives, "compiler_directives");			
		}
 public string FormatTree(string Text, compilation_unit cu, int cursor_line, int cursor_col)
 {
     PascalABCCompiler.Parsers.CommentBinder binder = new PascalABCCompiler.Parsers.CommentBinder();
     //comments = binder.Bind(cu, Text);
     this.Text = Text;
     string[] lines = Text.Split('\n');
     line_lens = new int[lines.Length];
     for (int i = 0; i < lines.Length; i++)
     {
         if (i > 0)
             line_lens[i] = lines[i].Length + line_lens[i - 1] + 1;
         else
             line_lens[i] = lines[i].Length + 1;
     }
     caret_line = cursor_line;
     caret_col = cursor_col;
     caret_pos = GetPosition(cursor_line, cursor_col);
     visit_node(cu);
     return sb.ToString();
 }
예제 #10
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void ReplaceInList(compilation_unit el, IEnumerable<compilation_unit> newels)
		{
			var ind = FindIndexInList(el);
			compilation_units.RemoveAt(ind);
			compilation_units.InsertRange(ind, newels);
		}
        public Object CreateNonTerminalObject()
        {
            switch ((RuleConstants) LRParser.ReductionRule.Index)
            {
		case RuleConstants.RULE_PREPROCESSOR_PROGRAM :
		//<preprocessor_program> ::= <directive_groups> <empty>
         
		{
			compilation_unit _compilation_unit=new compilation_unit();
			 
				_compilation_unit.Language=LanguageId.PascalABCNET;
                                if(LRParser.GetReductionSyntaxNode(0)!=null){
                                	parsertools.create_source_context(_compilation_unit,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(0));
					CompilerDirectives.AddRange(((compiler_directive_list)LRParser.GetReductionSyntaxNode(0)).directives);
				}
				
			return _compilation_unit;
		}


		case RuleConstants.RULE_DIRECTIVE_GROUPS :
		//<directive_groups> ::= <_directive_groups>
return LRParser.GetReductionSyntaxNode(0);

		case RuleConstants.RULE_DIRECTIVE_GROUPS2 :
		//<directive_groups> ::= 
		//NONTERMINAL:<directive_groups> ::= 
		return null;
		//ENDNONTERMINAL

		case RuleConstants.RULE__DIRECTIVE_GROUPS :
		//<_directive_groups> ::= <directive_group> <empty>
         
		{
			compiler_directive_list _compiler_directive_list=new compiler_directive_list();
			
						  if(LRParser.GetReductionSyntaxNode(0) is compiler_directive)
							_compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(0));
						    parsertools.create_source_context(_compiler_directive_list,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(0));
			return _compiler_directive_list;
		}


		case RuleConstants.RULE__DIRECTIVE_GROUPS2 :
		//<_directive_groups> ::= <directive_groups> <directive_group>
         
		{
			compiler_directive_list _compiler_directive_list=(compiler_directive_list)LRParser.GetReductionSyntaxNode(0); 
						  if(LRParser.GetReductionSyntaxNode(1) is compiler_directive)
							_compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(1));
						  parsertools.create_source_context(_compiler_directive_list,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(1));
			return _compiler_directive_list;
		}


		case RuleConstants.RULE_DIRECTIVE_GROUP_TKNEWLINE :
		//<directive_group> ::= 'TKNEWLINE'
return LRParser.GetReductionSyntaxNode(0);

		case RuleConstants.RULE_DIRECTIVE_GROUP_TKPROGRAM_LINE_PART :
		//<directive_group> ::= 'TKPROGRAM_LINE_PART'
return LRParser.GetReductionSyntaxNode(0);

		case RuleConstants.RULE_DIRECTIVE_GROUP_TKDIRECTIVE :
		//<directive_group> ::= 'TKDIRECTIVE' <empty>
         
		{
			compiler_directive _compiler_directive=(compiler_directive)pascal_parsertools.MakeDirective((token_info)LRParser.GetReductionSyntaxNode(0));
			return _compiler_directive;
		}


		case RuleConstants.RULE_EMPTY :
		//<empty> ::= 
		//NONTERMINAL:<empty> ::= 
		return null;
		//ENDNONTERMINAL

            }
            throw new RuleException("Unknown rule");
        }
예제 #12
0
		public void visit(compilation_unit _compilation_unit)
		{
			bw.Write((Int16)55);
			write_compilation_unit(_compilation_unit);
		}
예제 #13
0
		public program_tree Add(compilation_unit _compilation_unit)
		{
		    compilation_units.Add(_compilation_unit);
		    return this;
		}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//CreateNonTerminalObject
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

public Object CreateNonTerminalObject()
{
switch ((RuleConstants)LRParser.ReductionRule.Index)
{
	case RuleConstants.RULE_PREPROCESSOR_PROGRAM :
	//<preprocessor_program> ::= <preprocessor_lexems> <empty>
			{
                        compilation_unit _compilation_unit = new compilation_unit();

                        _compilation_unit.Language = LanguageId.PascalABCNET;
                        if (LRParser.GetReductionSyntaxNode(0) != null)
                        {
                            parsertools.create_source_context(_compilation_unit, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                            CompilerDirectives.AddRange(((compiler_directive_list)LRParser.GetReductionSyntaxNode(0)).directives);
                            if (CompilerDirectives.Count != 0)
                                prepr.CompilerDirectives.AddRange(CompilerDirectives);
                        }

                        return _compilation_unit;
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEMS :
	//<preprocessor_lexems> ::= <_preprocessor_lexems>
			return LRParser.GetReductionSyntaxNode(0);
	case RuleConstants.RULE_PREPROCESSOR_LEXEMS2 :
	//<preprocessor_lexems> ::= 
	//NONTERMINAL:<preprocessor_lexems> ::= 
	return null;
	//ENDNONTERMINAL
	case RuleConstants.RULE__PREPROCESSOR_LEXEMS :
	//<_preprocessor_lexems> ::= <preprocessor_lexem> <empty>
			{
                        compiler_directive_list _compiler_directive_list = new compiler_directive_list();

                        if (LRParser.GetReductionSyntaxNode(0) is compiler_directive)
                            _compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(0));
                        parsertools.create_source_context(_compiler_directive_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0));
                        return _compiler_directive_list;
                    }
	case RuleConstants.RULE__PREPROCESSOR_LEXEMS2 :
	//<_preprocessor_lexems> ::= <preprocessor_lexems> <preprocessor_lexem>
			{
                        compiler_directive_list _compiler_directive_list = (compiler_directive_list)LRParser.GetReductionSyntaxNode(0);
                        if (LRParser.GetReductionSyntaxNode(1) is compiler_directive)
                            _compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(1));
                        parsertools.create_source_context(_compiler_directive_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1));
                        return _compiler_directive_list;
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_NEWLINE :
	//<preprocessor_lexem> ::= 'TK_NEWLINE'
			return LRParser.GetReductionSyntaxNode(0);
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_SLASH :
	//<preprocessor_lexem> ::= 'TK_SLASH'
			{
                        if (prepr.sm.AllowWrite())
                            prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text);
                        return LRParser.GetReductionSyntaxNode(0);
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_SLASHEKV :
	//<preprocessor_lexem> ::= 'TK_SLASHEKV'
			{
                        if (prepr.sm.AllowWrite())
                            prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text);
                        return LRParser.GetReductionSyntaxNode(0);
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_AP :
	//<preprocessor_lexem> ::= 'TK_AP'
			{
                        if (prepr.sm.AllowWrite())
                            prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text);
                        return LRParser.GetReductionSyntaxNode(0);
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_KAV :
	//<preprocessor_lexem> ::= 'TK_KAV'
			{
                        if (prepr.sm.AllowWrite())
                            prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text);
                        return LRParser.GetReductionSyntaxNode(0);
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_PROGRAM_LINE :
	//<preprocessor_lexem> ::= 'TK_PROGRAM_LINE'
			{
                        if (prepr.sm.AllowWrite())
                            prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text);
                        return LRParser.GetReductionSyntaxNode(0);
                    }
	case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_DIRECTIVE :
	//<preprocessor_lexem> ::= 'TK_DIRECTIVE' <empty>
			{
                bool inline = ( ((token_info)LRParser.GetReductionSyntaxNode(0)).source_context.begin_position.line_num - ((token_info)LRParser.GetReductionSyntaxNode(0)).source_context.end_position.line_num == 0 );
                string token_text = ((token_info)LRParser.GetReductionSyntaxNode(0)).text;

                if (token_text[1] == '$' && inline)
                {
                        compiler_directive _compiler_directive = (compiler_directive)pascal_parsertools.MakeDirective((token_info)LRParser.GetReductionSyntaxNode(0));
                        _compiler_directive.source_context.FileName = prepr.CurrentFileName;
                        prepr.CurrentFileName = _compiler_directive.source_context.FileName;

                        //INCLUDE
                        if (_compiler_directive.Name.text == prepr.INCLUDE)
                        {
                            if (prepr.sm.AllowWrite())
                            {
                                string IncludeFileName = _compiler_directive.Directive.text;
                                if (prepr.ProcessedFileNames.Contains(IncludeFileName) || Path.GetFileName(prepr.CurrentFileName) == Path.GetFileName(IncludeFileName))
                                {
                                    prepr.Errors.Add(new CircularInclude(prepr.CurrentFileName, _compiler_directive.source_context, null, IncludeFileName));
                                }
                                else
                                {
                                    if (!(bool)prepr.SourceFilesProvider(IncludeFileName, SourceFileOperation.Exists))
                                        prepr.Errors.Add(new IncludeFileNotFound(prepr.CurrentFileName, _compiler_directive.source_context, null, IncludeFileName));
                                    string b = prepr.CurrentFileName;
                                    //string t = prepr.SourceText;
                                    //string[] sl = prepr.SourceLines;
                                    prepr.ProcessFile(IncludeFileName);
                                    prepr.CurrentFileName = b;
                                    //prepr.SourceText = t;
                                    //prepr.SourceLines = sl;
                                    prepr.ProcessedFileNames.Remove(IncludeFileName);
                                }
                            }
                            return _compiler_directive;
                        }
                        //DEFINE                        
                        if (_compiler_directive.Name.text == prepr.DEFINE)
                        {
                            if (prepr.sm.AllowWrite())
                            {
                                string directive = _compiler_directive.Directive.text;
                                string name = prepr.getFirstIdent(directive);
                                string text = prepr.getSecondIdent(directive);
                                prepr.AddDefineDirective(name, text, _compiler_directive);
                            }
                            return _compiler_directive;
                        }
                        //UNDEF                        
                        if (_compiler_directive.Name.text == prepr.UNDEF)
                        {
                            if (prepr.sm.AllowWrite())
                            {
                                string directive = _compiler_directive.Directive.text;
                                string name = prepr.getFirstIdent(directive);
                                if (name != null)
                                    if (prepr.DefineDirectiveDefinded(name))
                                        prepr.DeleteDefineDirective(name, _compiler_directive);
                            }
                            return _compiler_directive;
                        }
                        //IFDEF                        
                        if (_compiler_directive.Name.text == prepr.IFDEF)
                        {
                            string directive = _compiler_directive.Directive.text;
                            if (prepr.sm.AllowWrite())
                            {

                                if (directive != null)
                                {
                                    if (!prepr.DefineDirectiveDefinded(directive))
                                        prepr.sm.ChangeState(false, 1);
                                    else
                                        prepr.sm.ChangeState(true, 1);
                                }

                            }
                            else
                                prepr.sm.ChangeState(false, -1);
                            return _compiler_directive;
                        }
                        //IFNDEF                        
                        if (_compiler_directive.Name.text == prepr.IFNDEF)
                        {
                            string directive = _compiler_directive.Directive.text;
                            if (prepr.sm.AllowWrite())
                            {

                                if (directive != null)
                                {
                                    if (prepr.DefineDirectiveDefinded(directive))
                                        prepr.sm.ChangeState(false, 1);
                                    else
                                        prepr.sm.ChangeState(true, 1);
                                }

                            }
                            else
                                prepr.sm.ChangeState(false, -1);
                            return _compiler_directive;
                        }
                        //ELSE                        
                        if (_compiler_directive.Name.text == prepr.ELSE)
                        {
                            if (prepr.sm.GetEndifCount() == 0 || prepr.sm.AllowElse() == false)
                            {
                                prepr.Errors.Add(new UnexpectedElse(prepr.CurrentFileName, _compiler_directive.source_context));
                            }
                            else
                            {
                                if (prepr.sm.AllowWrite())
                                    prepr.sm.ChangeState(false, false);
                                else
                                {
                                    if (prepr.sm.LastCondition() == 1)
                                        prepr.sm.ChangeState(true, false);
                                    else
                                        prepr.sm.ChangeState(false, false);
                                }
                            }
                            return _compiler_directive;
                        }
                        //ENDIF                        
                        if (_compiler_directive.Name.text == prepr.ENDIF)
                        {
                            if (prepr.sm.GetEndifCount() == 0)
                            {
                                prepr.Errors.Add(new UnexpectedEndif(prepr.CurrentFileName, _compiler_directive.source_context));
                            }
                            else
                            {
                                if (prepr.sm.AllowWrite())
                                    prepr.sm.ChangeState(true, true);
                                else
                                {
                                    if (prepr.sm.LastEndifCondition() == 1)
                                        prepr.sm.ChangeState(true, true);
                                    else
                                        prepr.sm.ChangeState(false, true);
                                }
                            }
                            return _compiler_directive;
                        }
                        return _compiler_directive;
                  }
                return LRParser.GetReductionSyntaxNode(0);
              }
	case RuleConstants.RULE_EMPTY :
	//<empty> ::= 
	//NONTERMINAL:<empty> ::= 
	return null;
	//ENDNONTERMINAL
}
throw new RuleException("Unknown rule");
}  
예제 #15
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		private int FindIndexInList(compilation_unit el)
		{
			var ind = compilation_units.FindIndex(x => x == el);
			if (ind == -1)
				throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
			return ind;
		}
예제 #16
0
 public override void visit(compilation_unit _compilation_unit)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #17
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void AddFirst(compilation_unit el)
		{
			compilation_units.Insert(0, el);
		}
예제 #18
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		// Методы списка
		public program_tree Add(compilation_unit elem, SourceContext sc = null)
		{
			compilation_units.Add(elem);
			if (sc != null)
				source_context = sc;
			return this;
		}
예제 #19
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		// Конструкторы списка
		public program_tree(compilation_unit elem, SourceContext sc = null)
		{
			Add(elem, sc);
		}
		public void read_compilation_unit(compilation_unit _compilation_unit)
		{
			read_syntax_tree_node(_compilation_unit);
			if (br.ReadByte() == 0)
			{
				_compilation_unit.file_name = null;
			}
			else
			{
				_compilation_unit.file_name = br.ReadString();
			}
			if (br.ReadByte() == 0)
			{
				_compilation_unit.compiler_directives = null;
			}
			else
			{
				_compilation_unit.compiler_directives = new List<compiler_directive>();
				Int32 ssyy_count = br.ReadInt32();
				for(Int32 ssyy_i = 0; ssyy_i < ssyy_count; ssyy_i++)
				{
					_compilation_unit.compiler_directives.Add(_read_node() as compiler_directive);
				}
			}
			_compilation_unit.Language = (LanguageId)br.ReadByte();
		}
예제 #21
0
		public program_tree(compilation_unit _compilation_unit, SourceContext sc)
		{
		    Add(_compilation_unit,sc);
		}
예제 #22
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void InsertAfter(compilation_unit el, compilation_unit newel)
		{
			compilation_units.Insert(FindIndex(el) + 1, newel);
		}
예제 #23
0
		public program_tree Add(compilation_unit _compilation_unit, SourceContext sc)
		{
		    compilation_units.Add(_compilation_unit);
		    source_context = sc;
		    return this;
		}
예제 #24
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void InsertAfter(compilation_unit el, IEnumerable<compilation_unit> newels)
		{
			compilation_units.InsertRange(FindIndex(el) + 1, newels);
		}
예제 #25
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void InsertBefore(compilation_unit el, compilation_unit newel)
		{
			compilation_units.Insert(FindIndex(el), newel);
		}
예제 #26
0
 public override void visit(compilation_unit _compilation_unit)
 {
     throw new NotImplementedException();
 }
예제 #27
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void InsertBefore(compilation_unit el, IEnumerable<compilation_unit> newels)
		{
			compilation_units.InsertRange(FindIndex(el), newels);
		}
예제 #28
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);
        }
예제 #29
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public bool Remove(compilation_unit el)
		{
			return compilation_units.Remove(el);
		}
예제 #30
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);
        }
예제 #31
0
파일: Tree.cs 프로젝트: Slav76/pascalabcnet
		public void ReplaceInList(compilation_unit el, compilation_unit newel)
		{
			compilation_units[FindIndexInList(el)] = newel;
		}
예제 #32
0
		public void write_compilation_unit(compilation_unit _compilation_unit)
		{
			write_syntax_tree_node(_compilation_unit);
			if (_compilation_unit.file_name == null)
			{
				bw.Write((byte)0);
			}
			else
			{
				bw.Write((byte)1);
				bw.Write(_compilation_unit.file_name);
			}
			if (_compilation_unit.compiler_directives == null)
			{
				bw.Write((byte)0);
			}
			else
			{
				bw.Write((byte)1);
				bw.Write(_compilation_unit.compiler_directives.Count);
				for(Int32 ssyy_i = 0; ssyy_i < _compilation_unit.compiler_directives.Count; ssyy_i++)
				{
					if (_compilation_unit.compiler_directives[ssyy_i] == null)
					{
						bw.Write((byte)0);
					}
					else
					{
						bw.Write((byte)1);
						_compilation_unit.compiler_directives[ssyy_i].visit(this);
					}
				}
			}
			bw.Write((byte)_compilation_unit.Language);
		}
예제 #33
0
 public Dictionary<syntax_tree_node,string[]> Bind(compilation_unit cu, string Text)
 {
     return null;
 }