Ejemplo n.º 1
0
        //TODO: Исправить коллекцию модулей.
        public PascalSharp.Internal.TreeConverter.TreeRealization.common_unit_node CompileInterface(compilation_unit SyntaxUnit,
                                                                                                    PascalSharp.Internal.TreeConverter.TreeRealization.unit_node_list UsedUnits, List <Error> ErrorsList, List <CompilerWarning> WarningsList, SyntaxError parser_error,
                                                                                                    System.Collections.Hashtable bad_nodes, using_namespace_list namespaces, Dictionary <syntax_tree_node, string> docs, bool debug, bool debugging)
        {
            //convertion_data_and_alghoritms.__i = 0;
            stv.parser_error             = parser_error;
            stv.bad_nodes_in_syntax_tree = bad_nodes;
            stv.referenced_units         = UsedUnits;
            //stv.comp_units=UsedUnits;
            //stv.visit(SyntaxUnit
            //stv.interface_using_list = namespaces;
            stv.using_list.clear();
            stv.interface_using_list.clear();
            stv.using_list.AddRange(namespaces);
            stv.current_document          = new document(SyntaxUnit.file_name);
            stv.ErrorsList                = ErrorsList;
            stv.WarningsList              = WarningsList;
            stv.SymbolTable.CaseSensitive = SemanticRules.SymbolTableCaseSensitive;
            stv.docs                  = docs;
            stv.debug                 = debug;
            stv.debugging             = debugging;
            SystemLibrary.syn_visitor = stv;
            SetSemanticRules(SyntaxUnit);


            foreach (var cd in SyntaxUnit.compiler_directives)
            {
                cd.visit(stv);
            }

            stv.DirectivesToNodesLinks = CompilerDirectivesToSyntaxTreeNodesLinker.BuildLinks(SyntaxUnit, ErrorsList);  //MikhailoMMX добавил передачу списка ошибок (02.10.10)

            SyntaxUnit.visit(stv);

            /*SyntaxTree.program_module pmod=SyntaxUnit as SyntaxTree.program_module;
             * if (pmod!=null)
             * {
             *      stv.visit(pmod);
             * }
             * else
             * {
             *      SyntaxTree.unit_module umod=SyntaxUnit as SyntaxTree.unit_module;
             *      if (umod==null)
             *      {
             *              throw new PascalSharp.Internal.TreeConverter.CompilerInternalError("Undefined module type (not program and not unit)");
             *      }
             *      stv.visit(umod);
             * }*/
            //stv.visit(SyntaxUnit);
            //if (ErrorsList.Count>0) throw ErrorsList[0];
            return(stv.compiled_unit);
        }
Ejemplo n.º 2
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);
 }