예제 #1
0
        public static Dictionary <syntax_tree_node, compiler_directive> BuildLinks(SyntaxTree.compilation_unit unit, List <Errors.Error> ErrorsList)
        {
            Dictionary <syntax_tree_node, compiler_directive> links = new Dictionary <syntax_tree_node, compiler_directive>();

            SyntaxTreeNodeFinder finder = new SyntaxTreeNodeFinder();

            if (unit.compiler_directives != null)
            {
                foreach (compiler_directive cd in unit.compiler_directives)
                {
                    if (IsKnownDirectivee(cd))
                    {
                        syntax_tree_node sn = finder.Find(unit, cd.source_context);
                        if (sn != null)
                        {
                            if (!links.ContainsKey(sn))
                            {
                                links.Add(sn, cd);
                            }
                            else
                            {
                                ErrorsList.Add(new PascalABCCompiler.Errors.CommonCompilerError("Повторное объявление директивы", unit.file_name, sn.source_context.begin_position.line_num, sn.source_context.begin_position.column_num));
                            }
                        }
                    }
                }
            }
            return(links);
        }
        public static Dictionary<syntax_tree_node, compiler_directive> BuildLinks(SyntaxTree.compilation_unit unit, List<Errors.Error> ErrorsList)
        {
            Dictionary<syntax_tree_node, compiler_directive> links = new Dictionary<syntax_tree_node, compiler_directive>();

            SyntaxTreeNodeFinder finder = new SyntaxTreeNodeFinder();

            if (unit.compiler_directives != null)
                foreach (compiler_directive cd in unit.compiler_directives)
                    if (IsKnownDirectivee(cd))
                    {
                        syntax_tree_node sn = finder.Find(unit, cd.source_context);
                        if (sn != null)
                            if (!links.ContainsKey(sn))
                                links.Add(sn, cd);
                            else
                                ErrorsList.Add(new PascalABCCompiler.Errors.CommonCompilerError("Повторное объявление директивы", unit.file_name, sn.source_context.begin_position.line_num, sn.source_context.begin_position.column_num));
                    }
            return links;
        }