From 0ae7595f0d72848db706ba0326856711e1c3daeb Mon Sep 17 00:00:00 2001 From: AlexanderZemlyak <92867056+AlexanderZemlyak@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:16:40 +0300 Subject: [PATCH] Implement programming languages integration functionality (#3001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make standardModules Dictionary instead of LanguageId usage * Create new common string constants for pascal language * Add LanguagesData class template * Move some compiler directive string constants to Compiler project * Extract LanguagesData class to separate file Also extracted RuntimeServiceModule (IO-modules) management to new functions. * Fix pabcnetc crashing (KeyNotFoundException) * Make similar change in pabcnetc_clear * Return PABCExtensions in DomConverter.cs * Return compiler string constants to Tree Converter * Rename MoveSystemUnitForward method * Rename system unit variable * Add new parser load error (localized versions) * Fix pascal language name constant * Add system units property to parsers * Add LanguageKits directory with a test file * Implement language integrator Был реализован загрузчик комплектов дополнительных языков (всех кроме Pascal). Был пересмотрен подход к реализации ParsersController и этот класс сделан синглтоном. Добавлена загрузка стандартных модулей языков в CompilerOptions. * Squashed commit of the following: commit 8f9dc7e5a0dbe2516a2af44d8ef843b7c30e2292 Author: Mikhalkovich Stanislav Date: Mon Mar 11 20:33:13 2024 +0300 fix #3050 commit 90363ced454216ef44c4919bb694b1a2c786b4b5 Author: Mikhalkovich Stanislav Date: Sun Mar 3 21:37:25 2024 +0300 Недобитки при сортировке строк commit c9d7ba7758d1cb4f41348f5cc9095b0350e0c005 Author: Mikhalkovich Stanislav Date: Sat Mar 2 13:32:14 2024 +0300 Order и OrderDescending для строк с Ordinal commit 6fbc0200bf4b413940a459f8b5d96c4597f561f4 Author: AlexanderZemlyak <92867056+AlexanderZemlyak@users.noreply.github.com> Date: Tue Feb 27 23:21:26 2024 +0300 Fix interface loop dependency check (#3047) Tests for problematic case were added commit e4d63bfef9ef22c3a21375b542d5540a593916e5 Author: bormant Date: Tue Feb 27 23:18:25 2024 +0300 Fix typo: C (ru) -> C (en) (#3042) commit 0d37232d21ce81d3443ad680b21b865a2b2fe017 Author: Mikhalkovich Stanislav Date: Tue Feb 27 19:15:08 2024 +0300 School - исправление пустого диапазона простых и IP-адресов commit 9fd4c7f3388b7e9b5cd6dbae1d619fa11827e30d Merge: 3cca2a89 6027083b Author: Ivan Bondarev Date: Wed Feb 21 20:57:10 2024 +0100 Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet commit 3cca2a894940cf585772464d55ac5f4bcf8e01ae Author: Ivan Bondarev Date: Wed Feb 21 20:56:49 2024 +0100 fix in formatter --- .gitignore | 1 + CodeCompletion/CodeCompletion.cs | 32 +-- CodeCompletion/CodeCompletion.csproj | 4 + CodeCompletion/DomConverter.cs | 4 +- CodeCompletion/DomSyntaxTreeVisitor.cs | 18 +- CodeCompletion/ExpressionVisitor.cs | 4 +- CodeCompletion/SymTable.cs | 8 +- CodeCompletion/Testing.cs | 12 +- Compiler/Compiler.cs | 234 ++++++++------- Compiler/Compiler.csproj | 3 - Compiler/PCU/PCUReader.cs | 2 +- Compiler/RemoteCompiler.cs | 18 +- Compiler/string_constants.cs | 11 - LanguageIntegrator/LanguageIntegrator.cs | 87 ++++++ LanguageIntegrator/LanguageIntegrator.csproj | 53 ++++ LanguageIntegrator/Properties/AssemblyInfo.cs | 37 +++ NETGenerator/NETGenerator.cs | 3 +- Optimizer/Optimizer.cs | 3 +- ParserTools/ParserTools/BaseParser.cs | 7 +- ParserTools/ParserTools/Errors.cs | 4 - ParserTools/ParsersController.cs | 268 ++++++++++-------- Parsers/PascalABCParserNewSaushkin/Parser.cs | 2 +- PascalABCNET.sln | 15 + ReleaseGenerators/PascalABCNET_head.nsh | 1 + ReleaseGenerators/sect_Core.nsh | 2 + ReleaseGenerators/sect_VisualPABCNET.nsh | 1 + TreeConverter/NetWrappers/NetHelper.cs | 2 +- .../TreeConversion/compiler_string_consts.cs | 35 ++- .../convertion_data_and_alghoritms.cs | 2 +- .../semantic_checks_for_sugar.cs | 6 +- .../TreeConversion/syntax_tree_visitor.cs | 8 +- VisualPascalABCNET/DS/Tools.cs | 4 +- .../DS/VisualEnvironmentCompiler.cs | 45 +-- .../DockContent/CodeFileDocument.cs | 2 +- VisualPascalABCNET/Form1.cs | 7 +- VisualPascalABCNET/IB/Debugger/Debugger.cs | 2 +- .../Projects/ProjectExplorer.cs | 4 +- VisualPascalABCNET/Projects/ProjectHelper.cs | 10 +- VisualPascalABCNET/VisualPascalABCNET.csproj | 4 + VisualPascalABCNET/Workbench/BuildService.cs | 57 +++- .../Workbench/FileOperations.cs | 3 +- .../Workbench/WindowOperations.cs | 1 - VisualPascalABCNETLinux/DS/Tools.cs | 1 + .../DS/VisualEnvironmentCompiler.cs | 46 +-- VisualPascalABCNETLinux/Form1.cs | 13 +- .../IB/Debugger/Debugger.cs | 4 +- .../Projects/ProjectExplorer.cs | 1 + .../Projects/ProjectHelper.cs | 1 + .../VisualPascalABCNETLinux.csproj | 4 + .../Workbench/BuildService.cs | 57 +++- .../Workbench/FileOperations.cs | 1 + .../Workbench/WindowOperations.cs | 1 + .../SyntaxTreeVisualisatorForm.cs | 4 +- bin/LanguageKits/.gitkeep | 0 bin/Lng/Eng/ParserErrors.dat | 1 + bin/Lng/Rus/ParserErrors.dat | 1 + bin/Lng/Ukr/ParserErrors.dat | 1 + bin/Lng/zh_CN/ParserErrors.dat | 1 + bin/TestRunner.exe | Bin 47104 -> 47616 bytes bin/TestRunner.pas | 3 + pabcnetc/CommandConsoleCompiler.cs | 12 +- pabcnetc/ConsoleCompiler.cs | 10 +- pabcnetc/PABCNETC.csproj | 4 + pabcnetc_clear/CommandConsoleCompiler.cs | 11 +- pabcnetc_clear/ConsoleCompiler.cs | 4 +- pabcnetc_clear/PABCNETCclear.csproj | 4 + 66 files changed, 806 insertions(+), 405 deletions(-) delete mode 100644 Compiler/string_constants.cs create mode 100644 LanguageIntegrator/LanguageIntegrator.cs create mode 100644 LanguageIntegrator/LanguageIntegrator.csproj create mode 100644 LanguageIntegrator/Properties/AssemblyInfo.cs create mode 100644 bin/LanguageKits/.gitkeep diff --git a/.gitignore b/.gitignore index b0ab0f323..9b8452933 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ **/NETGenerator.dll **/OptimizerConversion.dll **/PABCRtl.dll +**/LanguageIntegrator.dll **/ParserTools.dll **/PascalABCParser.dll **/PluginsSupport.dll diff --git a/CodeCompletion/CodeCompletion.cs b/CodeCompletion/CodeCompletion.cs index 02a9bc486..9ca08aae1 100644 --- a/CodeCompletion/CodeCompletion.cs +++ b/CodeCompletion/CodeCompletion.cs @@ -14,7 +14,7 @@ namespace CodeCompletion { public class CodeCompletionController { - public static Controller ParsersController = new Controller(); + public static Controller ParsersController = Controller.Instance; string FileName; string Text; public Dictionary docs = new Dictionary(); @@ -78,10 +78,10 @@ namespace CodeCompletion internal compilation_unit ParsersControllerGetCompilationUnit(string FileName, string Text, List ErrorsList, List Warnings) { string ext = Path.GetExtension(FileName); - Parser = ParsersController.selectParser(ext.ToLower()); + Parser = ParsersController.SelectParser(ext.ToLower()); parsers[ext] = Parser; compilation_unit cu = null; - cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings); + cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal); //ParsersController.GetExpression("test.pas", "a+b", new List()); return cu; } @@ -89,10 +89,10 @@ namespace CodeCompletion internal compilation_unit ParsersControllerGetCompilationUnitSpecial(string FileName, string Text, List ErrorsList, List Warnings) { string ext = Path.GetExtension(FileName); - Parser = ParsersController.selectParser(ext.ToLower()); + Parser = ParsersController.SelectParser(ext.ToLower()); parsers[ext] = Parser; compilation_unit cu = null; - cu = ParsersController.GetCompilationUnitSpecial(FileName, Text, ErrorsList, Warnings); + cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special); //ParsersController.GetExpression("test.pas","a+b",new List()); return cu; } @@ -109,7 +109,7 @@ namespace CodeCompletion { 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.SyntaxTree.documentation_comment_list dt = ParsersController.SelectParserForUnitAndBuildTree(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); @@ -146,7 +146,7 @@ namespace CodeCompletion 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.SyntaxTree.documentation_comment_list dt = ParsersController.SelectParserForUnitAndBuildTree(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); @@ -215,10 +215,10 @@ namespace CodeCompletion string ext = Path.GetExtension(FileName); List ErrorsList = new List(); List Warnings = new List(); - PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings); - Parser = ParsersController.selectParser(Path.GetExtension(FileName).ToLower()); + compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal); + 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, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list; + PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.SelectParserForUnitAndBuildTree(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); @@ -247,7 +247,7 @@ namespace CodeCompletion } ErrorsList.Clear(); Warnings.Clear(); - 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; + dt = ParsersController.SelectParserForUnitAndBuildTree(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); @@ -278,12 +278,12 @@ namespace CodeCompletion PascalABCCompiler.SyntaxTree.compilation_unit cu = null; if (Text != null) { - cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings); + cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal); } - Parser = ParsersController.selectParser(Path.GetExtension(FileName).ToLower()); + 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.SyntaxTree.documentation_comment_list dt = ParsersController.SelectParserForUnitAndBuildTree(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); @@ -313,7 +313,7 @@ namespace CodeCompletion } 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; + dt = ParsersController.SelectParserForUnitAndBuildTree(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) @@ -335,7 +335,7 @@ namespace CodeCompletion public class CodeCompletionNameHelper { - public static readonly string system_unit_file_name = PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_file_name; + public static readonly string system_unit_file_name = PascalABCCompiler.TreeConverter.compiler_string_consts.pascalSystemUnitName; public static string system_unit_file_full_name; private static CodeCompletionNameHelper helper; diff --git a/CodeCompletion/CodeCompletion.csproj b/CodeCompletion/CodeCompletion.csproj index 00e95f89e..086165685 100644 --- a/CodeCompletion/CodeCompletion.csproj +++ b/CodeCompletion/CodeCompletion.csproj @@ -87,6 +87,10 @@ {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B} Errors + + {a48d9069-d569-4110-9252-a10f139b669b} + LanguageIntegrator + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23} ParserTools diff --git a/CodeCompletion/DomConverter.cs b/CodeCompletion/DomConverter.cs index ec3900632..14d9b4ee7 100644 --- a/CodeCompletion/DomConverter.cs +++ b/CodeCompletion/DomConverter.cs @@ -56,11 +56,11 @@ namespace CodeCompletion foreach (string s in files) { string fname = Path.GetFileNameWithoutExtension(s); - if (fname == "__RedirectIOMode" || fname == "__RunMode" || fname == "PABCExtensions") + if (fname == "__RedirectIOMode" || fname == "__RunMode" || fname == compiler_string_consts.pascalExtensionsUnitName) continue; SymInfo si = new SymInfo(Path.GetFileNameWithoutExtension(s), SymbolKind.Namespace, null); si.IsUnitNamespace = true; - + si.description = GetUnitDescription(s); standard_units[i++] = si; } diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 0e7659526..c30ef75d1 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -2633,7 +2633,7 @@ namespace CodeCompletion is_system_unit = true; add_standart_types(entry_scope); } - if (_unit_module.unit_name.idunit_name.name == PascalABCCompiler.TreeConverter.compiler_string_consts.extensions_unit_file_name) + if (_unit_module.unit_name.idunit_name.name == PascalABCCompiler.TreeConverter.compiler_string_consts.pascalExtensionsUnitName) { is_extensions_unit = true; } @@ -2729,7 +2729,7 @@ namespace CodeCompletion entry_scope.AddUsedUnit(dc.visitor.entry_scope); add_standart_types(dc.visitor.entry_scope); //get_standart_types(dc.stv); - entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_file_name,dc.visitor.entry_scope); + entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.pascalSystemUnitName,dc.visitor.entry_scope); } CodeCompletionController.comp_modules[unit_name] = dc; @@ -2739,14 +2739,14 @@ namespace CodeCompletion dc.visitor.entry_scope.InitAssemblies(); entry_scope.AddUsedUnit(dc.visitor.entry_scope); //get_standart_types(dc.stv); - entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_file_name,dc.visitor.entry_scope); + entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.pascalSystemUnitName,dc.visitor.entry_scope); } } } private void add_extensions_unit() { - string unit_name = CodeCompletionNameHelper.FindSourceFileName(PascalABCCompiler.TreeConverter.compiler_string_consts.extensions_unit_file_name, out _); + string unit_name = CodeCompletionNameHelper.FindSourceFileName(PascalABCCompiler.TreeConverter.compiler_string_consts.pascalExtensionsUnitName, out _); if (unit_name != null) { @@ -2759,7 +2759,7 @@ namespace CodeCompletion { dc.visitor.entry_scope.InitAssemblies(); entry_scope.AddUsedUnit(dc.visitor.entry_scope); - entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.extensions_unit_file_name, dc.visitor.entry_scope); + entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.pascalExtensionsUnitName, dc.visitor.entry_scope); } CodeCompletionController.comp_modules[unit_name] = dc; } @@ -2767,7 +2767,7 @@ namespace CodeCompletion { dc.visitor.entry_scope.InitAssemblies(); entry_scope.AddUsedUnit(dc.visitor.entry_scope); - entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.extensions_unit_file_name, dc.visitor.entry_scope); + entry_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.pascalExtensionsUnitName, dc.visitor.entry_scope); } } } @@ -2973,7 +2973,7 @@ namespace CodeCompletion } if (string.Compare(str, PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_name, true) == 0) has_system_unit = true; - if (string.Compare(str, PascalABCCompiler.TreeConverter.compiler_string_consts.extensions_unit_file_name, true) == 0) + if (string.Compare(str, PascalABCCompiler.TreeConverter.compiler_string_consts.pascalExtensionsUnitName, true) == 0) has_extensions_unit = true; unl.AddElement(new PascalABCCompiler.TreeRealization.using_namespace(str)); } @@ -4798,7 +4798,7 @@ namespace CodeCompletion } if (string.Compare(str, PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_name, true) == 0) has_system_unit = true; - if (string.Compare(str, PascalABCCompiler.TreeConverter.compiler_string_consts.extensions_unit_file_name, true) == 0) + if (string.Compare(str, PascalABCCompiler.TreeConverter.compiler_string_consts.pascalExtensionsUnitName, true) == 0) has_extensions_unit = true; unl.AddElement(new PascalABCCompiler.TreeRealization.using_namespace(str)); } @@ -5937,7 +5937,7 @@ namespace CodeCompletion { method_call mc = new method_call(); mc.parameters = new expression_list(new List { _diapason_expr_new.left, _diapason_expr_new.right }); - mc.dereferencing_value = new dot_node(new ident("PABCSystem"), new ident("InternalRange")); + mc.dereferencing_value = new dot_node(new ident(compiler_string_consts.pascalSystemUnitName), new ident("InternalRange")); mc.visit(this); } diff --git a/CodeCompletion/ExpressionVisitor.cs b/CodeCompletion/ExpressionVisitor.cs index 85289388c..af73b94a0 100644 --- a/CodeCompletion/ExpressionVisitor.cs +++ b/CodeCompletion/ExpressionVisitor.cs @@ -2041,7 +2041,7 @@ namespace CodeCompletion method_call mc = new method_call(); mc.parameters = new expression_list(new List { _diapason_expr_new.left, _diapason_expr_new.right }); - mc.dereferencing_value = new dot_node(new ident("PABCSystem"), new ident("InternalRange")); + mc.dereferencing_value = new dot_node(new ident(compiler_string_consts.pascalSystemUnitName), new ident("InternalRange")); mc.visit(this); } @@ -2051,7 +2051,7 @@ namespace CodeCompletion var rr = this.returned_scope; //var nn = new new_expr((syntax_type, plist, true, new SyntaxTree.array_const(acn.elements, acn.elements.source_context), acn.source_context); //var nn = new new_expr($2, el, true, $6 as array_const, @$); - var dn = new dot_node(new ident("PABCSystem"), new ident("Arr"), acn.source_context); + var dn = new dot_node(new ident(compiler_string_consts.pascalSystemUnitName), new ident("Arr"), acn.source_context); var el = new expression_list(acn.elements.expressions[0], acn.source_context); var nn = new method_call(dn, el, acn.source_context); visit(nn); diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 65c143288..df190c520 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -10,6 +10,8 @@ using PascalABCCompiler.TreeRealization; using PascalABCCompiler.SyntaxTree; using PascalABCCompiler.Parsers; using System.Linq; +using PascalABCCompiler; +using PascalABCCompiler.TreeConverter; namespace CodeCompletion { @@ -142,7 +144,7 @@ namespace CodeCompletion public static string GetTopScopeName(SymScope sc) { if (sc == null || sc.si == null) return ""; - if (sc.si.name == "" || sc.si.name.Contains("$") || sc.si.name == PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_file_name) return ""; + if (sc.si.name == "" || sc.si.name.Contains("$") || sc.si.name == PascalABCCompiler.TreeConverter.compiler_string_consts.pascalSystemUnitName) return ""; if (sc is ProcScope) return ""; return sc.si.name + "."; } @@ -493,7 +495,7 @@ namespace CodeCompletion private bool hasUsesCycle(SymScope unit, int deep=0) { - if (unit.Name == "PABCSystem") + if (unit.Name == compiler_string_consts.pascalSystemUnitName) return true; if (deep > 100) return true; @@ -523,7 +525,7 @@ namespace CodeCompletion public void AddUsedUnit(SymScope unit) { - if (this.si.name != "PABCSystem" || unit is NamespaceScope) + if (this.si.name != compiler_string_consts.pascalSystemUnitName || unit is NamespaceScope) used_units.Add(unit); } diff --git a/CodeCompletion/Testing.cs b/CodeCompletion/Testing.cs index cb0209351..7e91cb5c4 100644 --- a/CodeCompletion/Testing.cs +++ b/CodeCompletion/Testing.cs @@ -8,6 +8,8 @@ using PascalABCCompiler.SyntaxTree; using PascalABCCompiler.Parsers; using PascalABCCompiler.Errors; using System.IO; +using PascalABCCompiler; +using PascalABCCompiler.TreeConverter; //using ICSharpCode.SharpDevelop.Dom; namespace CodeCompletion @@ -30,7 +32,7 @@ namespace CodeCompletion var controller = new CodeCompletion.CodeCompletionController(); CodeCompletion.DomSyntaxTreeVisitor.use_semantic_for_intellisense = true; CodeCompletion.CodeCompletionController.comp = comp; - CodeCompletion.CodeCompletionController.SetParser(".pas"); + CodeCompletion.CodeCompletionController.SetParser(compiler_string_consts.pascalSourceFileExtension); CodeCompletion.CodeCompletionController.ParsersController = comp.ParsersController; var files = Directory.GetFiles(dir, "*.pas"); var parser = comp.ParsersController; @@ -102,7 +104,7 @@ namespace CodeCompletion var comp = new PascalABCCompiler.Compiler(); var controller = new CodeCompletion.CodeCompletionController(); CodeCompletion.CodeCompletionController.comp = comp; - CodeCompletion.CodeCompletionController.SetParser(".pas"); + CodeCompletion.CodeCompletionController.SetParser(compiler_string_consts.pascalSourceFileExtension); CodeCompletion.CodeCompletionController.ParsersController = comp.ParsersController; var files = Directory.GetFiles(dir, "*.pas"); var parser = comp.ParsersController; @@ -303,7 +305,7 @@ namespace CodeCompletion int line=0; int col=0; PascalABCCompiler.Parsers.KeywordKind keyw; - PascalABCCompiler.Parsers.IParser parser = CodeCompletionController.ParsersController.selectParser(".vb"); + PascalABCCompiler.Parsers.IParser parser = CodeCompletionController.ParsersController.SelectParser(".vb"); string test_str = "System.Console"; off = test_str.Length; @@ -338,8 +340,8 @@ namespace CodeCompletion int line=0; int col=0; PascalABCCompiler.Parsers.KeywordKind keyw; - CodeCompletionController.ParsersController.Reload(); - PascalABCCompiler.Parsers.IParser parser = CodeCompletionController.ParsersController.selectParser(".pas"); + LanguageIntegration.LanguageIntegrator.ReloadAllParsers(); + IParser parser = CodeCompletionController.ParsersController.SelectParser(compiler_string_consts.pascalSourceFileExtension); string test_str = "System.Console"; off = test_str.Length; diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 5a09bbcf4..d93bcd94a 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -413,15 +413,18 @@ namespace PascalABCCompiler /// поле для проверки на циклическую зависимость интерфейсов модулей /// public string currentUsedUnitId; - public PascalABCCompiler.Errors.SyntaxError syntax_error; + public SyntaxError syntax_error; public string UnitFileName; - public List ErrorList = new List(); + public List ErrorList = new List(); public bool Documented; internal List possibleNamespaces = new List(); //internal List AssemblyReferences = new List(); //private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList(); + // название языка модуля + public string languageName = TreeConverter.compiler_string_consts.pascalLanguageName; + /// /// Только "реальные" юниты (не dll и namespace) /// @@ -517,7 +520,7 @@ namespace PascalABCCompiler public bool Optimise = false; public bool SavePCUInThreadPull = false; public bool RunWithEnvironment = false; - public string CompiledUnitExtension = ".pcu"; + public string CompiledUnitExtension = TreeConverter.compiler_string_consts.pascalCompiledUnitExtension; public bool ProjectCompiled = false; public IProjectInfo CurrentProject = null; public OutputType OutputFileType = OutputType.ConsoleApplicaton; @@ -601,52 +604,84 @@ namespace PascalABCCompiler public string[] ParserSearchPaths; + // LeftToAll - слева во все модули, RightToMain - справа, только в основную программу public enum StandardModuleAddMethod { LeftToAll, RightToMain }; + [Serializable()] public class StandardModule : MarshalByRefObject { - public string Name = null; - public StandardModuleAddMethod AddMethod = StandardModuleAddMethod.LeftToAll; - public SyntaxTree.LanguageId AddToLanguages = SyntaxTree.LanguageId.PascalABCNET; - public StandardModule(string Name, StandardModuleAddMethod AddMethod) + public string name = null; + public StandardModuleAddMethod addMethod = StandardModuleAddMethod.LeftToAll; + public string languageToAdd = TreeConverter.compiler_string_consts.pascalLanguageName; + + public StandardModule(string Name, StandardModuleAddMethod addMethod) { - this.Name = Name; - this.AddMethod = AddMethod; + this.name = Name; + this.addMethod = addMethod; } - public StandardModule(string Name, StandardModuleAddMethod AddMethod, SyntaxTree.LanguageId AddToLanguages) + + public StandardModule(string name, StandardModuleAddMethod addMethod, string languageToAdd) { - this.Name = Name; - this.AddToLanguages = AddToLanguages; - this.AddMethod = AddMethod; + this.name = name; + this.languageToAdd = languageToAdd; + this.addMethod = addMethod; } - public StandardModule(string Name) + + public StandardModule(string name) { - this.Name = Name; + this.name = name; } - public StandardModule(string Name, SyntaxTree.LanguageId AddToLanguages) + + public StandardModule(string name, string languageToAdd) { - this.AddToLanguages = AddToLanguages; - this.Name = Name; + this.languageToAdd = languageToAdd; + this.name = name; + } + } + + private Dictionary> standardModules = new Dictionary>(); + + /// + /// Списки стандартных модулей для поддерживаемых языков (первым в списке должен быть модуль "System") + /// + public Dictionary> StandardModules + { + get + { + if (standardModules.Count == 0) + LoadStandardModules(); + return standardModules; + } + set + { + standardModules = value; } } /// - /// module at index 0 is System module + /// Заполняет словарь стандартных модулей для всех поддерживаемых языков /// - public List StandardModules; - - public void RemoveStandardModule(string name) + private void LoadStandardModules() { - int moduleIndex = StandardModules.FindIndex(module => module.Name == name); - - if (moduleIndex != -1) - StandardModules.RemoveAt(moduleIndex); + foreach (Parsers.IParser parser in Parsers.Controller.Instance.Parsers) + { + if (parser is Parsers.BaseParser baseParser) + standardModules[baseParser.Name] = baseParser.SystemUnitNames.Select(unitName => new StandardModule(unitName, baseParser.Name)).ToList(); + } } - public void RemoveStandardModuleAtIndex(int index) + public void RemoveStandardModule(string language, string name) { - if (index < StandardModules.Count) - StandardModules.RemoveAt(index); + int moduleIndex = StandardModules[language].FindIndex(module => module.name == name); + + if (moduleIndex != -1) + StandardModules[language].RemoveAt(moduleIndex); + } + + public void RemoveStandardModuleAtIndex(string language, int index) + { + if (index < StandardModules[language].Count) + StandardModules[language].RemoveAt(index); } @@ -671,13 +706,6 @@ namespace PascalABCCompiler public Hashtable StandardDirectories; - private void SetStandardModules() - { - StandardModules = new List(); - StandardModules.Add(new StandardModule("PABCSystem", SyntaxTree.LanguageId.PascalABCNET)); - StandardModules.Add(new StandardModule("PABCExtensions", SyntaxTree.LanguageId.PascalABCNET)); - } - private void SetDirectories() { SystemDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); @@ -693,13 +721,11 @@ namespace PascalABCCompiler public CompilerOptions() { SetDirectories(); - SetStandardModules(); } public CompilerOptions(string SourceFileName, OutputType OutputFileType) { SetDirectories(); - SetStandardModules(); this.SourceFileName = SourceFileName; this.OutputFileType = OutputFileType; } @@ -937,7 +963,7 @@ namespace PascalABCCompiler internal Dictionary DLLCache = new Dictionary(); - private Parsers.Controller parsersController = null; + private Parsers.Controller parsersController = Parsers.Controller.Instance; public Parsers.Controller ParsersController { get @@ -1055,35 +1081,35 @@ namespace PascalABCCompiler public Compiler() { - //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); - OnChangeCompilerState += ChangeCompilerStateEvent; Reload(); } public Compiler(ICompiler comp, SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) { - //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); // SSM 01/05/16 - подключение изменяльщика синтаксического дерева - - this.ParsersController = comp.ParsersController; - this.internalDebug = comp.InternalDebug; + internalDebug = comp.InternalDebug; OnChangeCompilerState += ChangeCompilerStateEvent; + if (SourceFilesProvider != null) - this.sourceFilesProvider = SourceFilesProvider; + sourceFilesProvider = SourceFilesProvider; + if (ChangeCompilerState != null) OnChangeCompilerState += ChangeCompilerState; - this.supportedSourceFiles = comp.SupportedSourceFiles; - this.supportedProjectFiles = comp.SupportedProjectFiles; + + supportedSourceFiles = comp.SupportedSourceFiles; + supportedProjectFiles = comp.SupportedProjectFiles; } public Compiler(SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) { - //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); // SSM 01/05/16 - подключение изменяльщика синтаксического дерева OnChangeCompilerState += ChangeCompilerStateEvent; + if (SourceFilesProvider != null) - this.sourceFilesProvider = SourceFilesProvider; + sourceFilesProvider = SourceFilesProvider; + if (ChangeCompilerState != null) OnChangeCompilerState += ChangeCompilerState; + Reload(); } @@ -1094,19 +1120,18 @@ namespace PascalABCCompiler pABCCodeHealth = 0; //А это что? - TreeRealization.type_node tn = SystemLibrary.SystemLibrary.void_type; + type_node tn = SystemLibrary.SystemLibrary.void_type; ClearAll(); errorsList.Clear(); Warnings.Clear(); InternalDebug = new CompilerInternalDebug(); - ParsersController = new Parsers.Controller(); - ParsersController.ParserConnected += new PascalABCCompiler.Parsers.Controller.ParserConnectedDeleagte(ParsersController_ParserConnected); + ParsersController.SourceFilesProvider = sourceFilesProvider; - ParsersController.Reload(); + SyntaxTreeToSemanticTreeConverter = new TreeConverter.SyntaxTreeToSemanticTreeConverter(); CodeGeneratorsController = new CodeGenerators.Controller(); - //PABCToCppCodeGeneratorsController = new PascalToCppConverter.Controller(); + SetSupportedSourceFiles(); SetSupportedProjectFiles(); @@ -1121,12 +1146,6 @@ namespace PascalABCCompiler OnChangeCompilerState(this, CompilerState.Ready, null); } - void ParsersController_ParserConnected(PascalABCCompiler.Parsers.IParser Parser) - { - if (OnChangeCompilerState != null) - OnChangeCompilerState(this, CompilerState.ParserConnected, Parser.GetType().Assembly.ManifestModule.FullyQualifiedName); - } - void syntaxTreeConvertersController_ChangeState(SyntaxTreeConvertersController.State State, ISyntaxTreeConverter SyntaxTreeConverter) { switch (State) @@ -1278,28 +1297,31 @@ namespace PascalABCCompiler throw ErrorsList[0]; } - private void MoveSystemUnitForwardInUnitLogicallySortedList() + private void MoveSystemUnitForwardInUnitsTopologicallySortedList() { if (CompilerOptions.StandardModules.Count == 0) return; - CompilationUnit system_unit = null; + CompilationUnit systemUnit = null; foreach (CompilationUnit unit in UnitsTopologicallySortedList) { - if (unit.SemanticTree != null && unit.SemanticTree is common_unit_node) + if (unit.SemanticTree == null || !(unit.SemanticTree is common_unit_node)) + continue; + + string unitName = (unit.SemanticTree as common_unit_node).unit_name; + + // Пока что сделана проверка для всех языков | Вопрос EVA + if (CompilerOptions.StandardModules.Select(kv => kv.Value[0].name).Contains(unitName)) { - if ((unit.SemanticTree as common_unit_node).unit_name == CompilerOptions.StandardModules[0].Name) - { - system_unit = unit; - break; - } + systemUnit = unit; + break; } } - if (system_unit != null && system_unit != UnitsTopologicallySortedList[0]) + if (systemUnit != null && systemUnit != UnitsTopologicallySortedList[0]) { - UnitsTopologicallySortedList.Remove(system_unit); - UnitsTopologicallySortedList.Insert(0, system_unit); + UnitsTopologicallySortedList.Remove(systemUnit); + UnitsTopologicallySortedList.Insert(0, systemUnit); } } @@ -2194,7 +2216,7 @@ namespace PascalABCCompiler } // вызов события смены состояния компилятора - начало компиляции - // событие имеет много потенциальных обработчиков + // информация о состояниях выводится в сообщениях компилятора OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); // очистка всех переменных и списков, используемых в процессе @@ -2316,7 +2338,7 @@ namespace PascalABCCompiler SetOutputFileTypeOption(); // перемещаем PABCSystem в начало списка - MoveSystemUnitForwardInUnitLogicallySortedList(); + MoveSystemUnitForwardInUnitsTopologicallySortedList(); // передача информации о типе выходного файла системному юниту if (UnitsTopologicallySortedList.Count > 0) @@ -2666,7 +2688,7 @@ namespace PascalABCCompiler { if (unitModule.interface_part.uses_modules == null) { - if (CompilerOptions.StandardModules.Count > 0) + if (CompilerOptions.StandardModules[currentCompilationUnit.languageName].Count > 0) { unitModule.interface_part.uses_modules = new SyntaxTree.uses_list(); unitModule.interface_part.uses_modules.source_context = new SyntaxTree.SourceContext(); @@ -2680,7 +2702,7 @@ namespace PascalABCCompiler { if (programModule.used_units == null) { - if (CompilerOptions.StandardModules.Count > 0) + if (CompilerOptions.StandardModules[currentCompilationUnit.languageName].Count > 0) { programModule.used_units = new SyntaxTree.uses_list(); programModule.used_units.source_context = new SyntaxTree.SourceContext(); @@ -3014,30 +3036,27 @@ namespace PascalABCCompiler public void AddStandardUnitsToInterfaceUsesSection(SyntaxTree.compilation_unit unitSyntaxTree) { - if (CompilerOptions.StandardModules.Count == 0) + if (CompilerOptions.StandardModules[currentCompilationUnit.languageName].Count == 0) return; List usesList = GetInterfaceUsesSection(unitSyntaxTree); string currentModuleName = Path.GetFileNameWithoutExtension(unitSyntaxTree.file_name).ToLower(); - foreach (CompilerOptions.StandardModule module in CompilerOptions.StandardModules) + foreach (CompilerOptions.StandardModule module in CompilerOptions.StandardModules[currentCompilationUnit.languageName]) { - string moduleName = Path.GetFileNameWithoutExtension(module.Name); + string moduleName = Path.GetFileNameWithoutExtension(module.name); if (moduleName.ToLower() == currentModuleName) return; } - foreach (CompilerOptions.StandardModule module in CompilerOptions.StandardModules) + foreach (CompilerOptions.StandardModule module in CompilerOptions.StandardModules[currentCompilationUnit.languageName]) { - if ((module.AddToLanguages & firstCompilationUnit.SyntaxTree.Language) != firstCompilationUnit.SyntaxTree.Language - && (module.AddToLanguages & currentCompilationUnit.SyntaxTree.Language) != currentCompilationUnit.SyntaxTree.Language) + // если мы компилируем не основную программу, а добавлять нужно в основную программу, то пропускаем + if (module.addMethod == CompilerOptions.StandardModuleAddMethod.RightToMain && currentCompilationUnit != firstCompilationUnit) continue; - if (module.AddMethod == CompilerOptions.StandardModuleAddMethod.RightToMain && currentCompilationUnit != firstCompilationUnit) - continue; - - string moduleName = Path.GetFileNameWithoutExtension(module.Name); + string moduleName = Path.GetFileNameWithoutExtension(module.name); // если стандартный модуль уже подключен bool isModuleAlreadyInUsesSection = false; @@ -3052,14 +3071,14 @@ namespace PascalABCCompiler } if (isModuleAlreadyInUsesSection) continue; - // здесь присвоится либо паскалевский юнит, либо пространство имен + // здесь присвоится либо юнит, либо пространство имен SyntaxTree.unit_or_namespace unitToAdd; - if (Path.GetExtension(module.Name) != "" /*&& Path.GetExtension(ModuleFileName).ToLower() != ".dll"*/) + if (Path.GetExtension(module.name) != "" /*&& Path.GetExtension(ModuleFileName).ToLower() != ".dll"*/) { unitToAdd = new SyntaxTree.uses_unit_in( new SyntaxTree.ident_list(new SyntaxTree.ident(moduleName)), - new SyntaxTree.string_const(module.Name)); + new SyntaxTree.string_const(module.name)); //uses_unit_in.source_context = uses_unit_in.in_file.source_context = uses_unit_in.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); } else @@ -3069,11 +3088,11 @@ namespace PascalABCCompiler } // добавление - if (module.AddMethod == CompilerOptions.StandardModuleAddMethod.RightToMain) + if (module.addMethod == CompilerOptions.StandardModuleAddMethod.RightToMain) { usesList.Add(unitToAdd); } - else if (module.AddMethod == CompilerOptions.StandardModuleAddMethod.LeftToAll) + else if (module.addMethod == CompilerOptions.StandardModuleAddMethod.LeftToAll) { usesList.Insert(0, unitToAdd); } @@ -3150,7 +3169,7 @@ namespace PascalABCCompiler #region SEMANTIC CHECKS : PASCAL NAMESPACE - SemanticCheckIsPascalNamespace(syntaxTree); + SemanticCheckIsUserNamespace(syntaxTree); #endregion @@ -3247,7 +3266,7 @@ namespace PascalABCCompiler } } - private void SemanticCheckIsPascalNamespace(SyntaxTree.compilation_unit unitSyntaxTree) + private void SemanticCheckIsUserNamespace(SyntaxTree.compilation_unit unitSyntaxTree) { if (!(unitSyntaxTree is SyntaxTree.unit_module)) throw new NamespaceModuleExpected(unitSyntaxTree.source_context); @@ -3541,8 +3560,9 @@ namespace PascalABCCompiler private SyntaxTree.compilation_unit InternalParseText(string fileName, string text, List errorList, List warnings, List definesList = null) { OnChangeCompilerState(this, CompilerState.BeginParsingFile, fileName); - SyntaxTree.compilation_unit unitSyntaxTree = ParsersController.GetCompilationUnit(fileName, text, ErrorsList, warnings, definesList); + SyntaxTree.compilation_unit unitSyntaxTree = ParsersController.GetCompilationUnit(fileName, text, ErrorsList, warnings, Parsers.ParseMode.Normal, definesList); OnChangeCompilerState(this, CompilerState.EndParsingFile, fileName); + //Вычисляем сколько строк скомпилировали if (errorList.Count == 0 && unitSyntaxTree != null && unitSyntaxTree.source_context != null) { @@ -3942,7 +3962,7 @@ namespace PascalABCCompiler var usedUnitFileName = GetUnitFileName(usedUnitNode, currentPath); var usedUnitId = Path.ChangeExtension(usedUnitFileName, null); - // когда образуется цикл здесь сохранится инцидентная вершина графа (используемый юнит), которая тоже принадлежит циклу + // когда образуется цикл здесь сохранится смежная вершина графа (используемый юнит), которая тоже принадлежит циклу currentUnit.currentUsedUnitId = usedUnitId; CompilationUnit usedUnit = UnitTable[usedUnitId]; @@ -3986,21 +4006,24 @@ namespace PascalABCCompiler /// генерация синтаксического дерева, /// обработка синтаксических ошибок /// - private void InitializeNewUnit(SyntaxTree.unit_or_namespace currentUnitNode, string UnitFileName, string UnitId, ref CompilationUnit currentUnit, ref Dictionary docs) + private void InitializeNewUnit(SyntaxTree.unit_or_namespace currentUnitNode, string unitFileName, string UnitId, ref CompilationUnit currentUnit, ref Dictionary docs) { currentUnit = new CompilationUnit(); if (firstCompilationUnit == null) firstCompilationUnit = currentUnit; - OnChangeCompilerState(this, CompilerState.BeginCompileFile, UnitFileName); // начало компиляции модуля + OnChangeCompilerState(this, CompilerState.BeginCompileFile, unitFileName); // начало компиляции модуля #region SYNTAX TREE CONSTRUCTING // получение синтаксического дерева - string sourceText = GetSourceCode(currentUnitNode, UnitFileName, currentUnit); + string sourceText = GetSourceCode(currentUnitNode, unitFileName, currentUnit); - currentUnit.SyntaxTree = ConstructSyntaxTree(UnitFileName, currentUnit, sourceText); + currentUnit.SyntaxTree = ConstructSyntaxTree(unitFileName, currentUnit, sourceText); #endregion + // запоминание названия языка + currentUnit.languageName = ParsersController.LastParser.Name; + if (currentUnit.SyntaxTree is SyntaxTree.unit_module) CompilerOptions.UseDllForSystemUnits = false; @@ -4019,7 +4042,7 @@ namespace PascalABCCompiler SemanticCheckDLLDirectiveOnlyForLibraries(currentUnit.SyntaxTree, isDll, dllDirective); // ошибка - компилируем вторую основную программу или вторую dll вместо юнита - SemanticCheckCurrentUnitMustBePascalUnit(UnitFileName, currentUnit, isDll); + SemanticCheckCurrentUnitMustBePascalUnit(unitFileName, currentUnit, isDll); // ошибка директива include в паскалевском юните SemanticCheckNoIncludeDirectivesInPascalUnit(currentUnit); @@ -4042,15 +4065,14 @@ namespace PascalABCCompiler UnitTable[UnitId] = currentUnit; + currentCompilationUnit = currentUnit; + // здесь добавляем стандартные модули в секцию uses интерфейса #if DEBUG if (InternalDebug.AddStandartUnits) #endif AddStandardUnitsToInterfaceUsesSection(currentUnit.SyntaxTree); - - currentCompilationUnit = currentUnit; - currentUnit.possibleNamespaces.Clear(); } @@ -4217,8 +4239,8 @@ namespace PascalABCCompiler List errors = new List(); string doctagsParserExtension = Path.GetExtension(unitSyntaxTree.file_name) + "dt" + Parsers.Controller.HideParserExtensionPostfixChar; - - SyntaxTree.documentation_comment_list docCommentList = ParsersController.Compile(Path.ChangeExtension(unitSyntaxTree.file_name, doctagsParserExtension), + + SyntaxTree.documentation_comment_list docCommentList = ParsersController.SelectParserForUnitAndBuildTree(Path.ChangeExtension(unitSyntaxTree.file_name, doctagsParserExtension), text, errors, new List(), Parsers.ParseMode.Normal) as SyntaxTree.documentation_comment_list; if (errors.Count > 0) return null; @@ -4308,7 +4330,7 @@ namespace PascalABCCompiler OnChangeCompilerState(this, CompilerState.PCUWritingError, Unit.UnitFileName); #if DEBUG if (!InternalDebug.SkipPCUErrors) - throw new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.currentCompilationUnit.SyntaxTree.file_name)), err); + throw new CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.currentCompilationUnit.SyntaxTree.file_name)), err); writer.RemoveSelf(); #endif } diff --git a/Compiler/Compiler.csproj b/Compiler/Compiler.csproj index 6c958c6ee..bb050421f 100644 --- a/Compiler/Compiler.csproj +++ b/Compiler/Compiler.csproj @@ -183,9 +183,6 @@ Config\GlobalAssemblyInfo.cs - - Code - diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 0c2ef3c93..58327b369 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -282,7 +282,7 @@ namespace PascalABCCompiler.PCU //TODO сохранить в PCU cun.scope.CaseSensitive = false; - if (string.Compare(unit_name, compiler_string_consts.system_unit_file_name, true)==0) + if (string.Compare(unit_name, compiler_string_consts.pascalSystemUnitName, true)==0) PascalABCCompiler.TreeConverter.syntax_tree_visitor.init_system_module(cun); //ssyy //Создаём область видимости для implementation - части diff --git a/Compiler/RemoteCompiler.cs b/Compiler/RemoteCompiler.cs index f0a9819e5..c787e2e57 100644 --- a/Compiler/RemoteCompiler.cs +++ b/Compiler/RemoteCompiler.cs @@ -10,6 +10,7 @@ using PascalABCCompiler.Errors; using PascalABCCompiler.TreeRealization; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; +using System.Data; namespace PascalABCCompiler { @@ -388,10 +389,16 @@ namespace PascalABCCompiler sendCommand(ConsoleCompilerConstants.CompilerOptionsClearStandartModules); if (compilerOptions.Locale != null) sendCommand(ConsoleCompilerConstants.CompilerLocale, compilerOptions.Locale); - foreach (PascalABCCompiler.CompilerOptions.StandardModule sm in compilerOptions.StandardModules) - sendCommand( - ConsoleCompilerConstants.CompilerOptionsStandartModule, - sm.Name,(int)sm.AddMethod,(int)sm.AddToLanguages); + + foreach (var kv in compilerOptions.StandardModules) + { + foreach (CompilerOptions.StandardModule module in kv.Value) + { + sendCommand(ConsoleCompilerConstants.CompilerOptionsStandartModule, + module.name, (int)module.addMethod, module.languageToAdd); + } + } + } public delegate void EnvorimentIdleDelegate(); @@ -566,6 +573,7 @@ namespace PascalABCCompiler pabcnetcProcess.StartInfo.CreateNoWindow = true; pabcnetcProcess.StartInfo.RedirectStandardOutput = true; pabcnetcProcess.StartInfo.RedirectStandardInput = true; + pabcnetcProcess.StartInfo.RedirectStandardError = true; pabcnetcProcess.EnableRaisingEvents = true; pabcnetcProcess.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8; pabcnetcProcess.Exited += pabcnetcProcess_Exited; @@ -583,6 +591,8 @@ namespace PascalABCCompiler void pabcnetcProcess_Exited(object sender, EventArgs e) { + string error = pabcnetcProcess.StandardError.ReadToEnd(); + if (!compilerReloading) { pabcnetcProcess = null; diff --git a/Compiler/string_constants.cs b/Compiler/string_constants.cs deleted file mode 100644 index 1668a8399..000000000 --- a/Compiler/string_constants.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -namespace PascalABCCompiler -{ - public class string_constants - { - public const string target_exe="exe"; - public const string target_dll="dll"; - public const string target_winexe="winexe"; - } -} \ No newline at end of file diff --git a/LanguageIntegrator/LanguageIntegrator.cs b/LanguageIntegrator/LanguageIntegrator.cs new file mode 100644 index 000000000..bd77009b3 --- /dev/null +++ b/LanguageIntegrator/LanguageIntegrator.cs @@ -0,0 +1,87 @@ +// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using PascalABCCompiler.Parsers; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; + +namespace LanguageIntegration +{ + public static class LanguageIntegrator + { + + public static Controller ParsersController = Controller.Instance; + + private const string languageKitsDirectoryName = "LanguageKits"; + + /// + /// Возвращает директорию, содержащую комплекты языков + /// + private static DirectoryInfo GetLanguageKitsDirectory() + { + string binDirectoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string languageKitsDirectoryPath = Path.Combine(binDirectoryPath, languageKitsDirectoryName); + + return new DirectoryInfo(languageKitsDirectoryPath); + } + + /// + /// Загружает все языковые комплекты для использования + /// + public static void LoadAllLanguageKits() + { + DirectoryInfo languageKitsDirectory = GetLanguageKitsDirectory(); + + foreach (var languageKit in languageKitsDirectory.GetDirectories()) + { + FileInfo[] dllFiles = languageKit.GetFiles(); + + foreach (var dll in dllFiles) + { + if (Regex.IsMatch(dll.Name, @".*Parser\.dll")) + { + ParsersController.IntegrateParsersFromAssembly(dll); + } + } + } + } + + /// + /// Загружает все языки, доступные в системе + /// + public static void LoadAllLanguages() + { + ParsersController.LoadStandardParsers(); + + LoadAllLanguageKits(); + } + + /// + /// Перезагружает парсеры всех языков + /// + public static void ReloadAllParsers() + { + ParsersController.Parsers.Clear(); + ParsersController.LoadStandardParsers(); + LoadParsersFromLanguageKits(); + } + + /// + /// Загружает все парсеры из языковых комплектов + /// + public static void LoadParsersFromLanguageKits() + { + DirectoryInfo languageKitsDirectory = GetLanguageKitsDirectory(); + + foreach (var parserDll in languageKitsDirectory.GetDirectories() + .SelectMany(directory => directory.GetFiles("*Parser.dll"))) + { + if (parserDll != null) + ParsersController.IntegrateParsersFromAssembly(parserDll); + } + } + + } +} diff --git a/LanguageIntegrator/LanguageIntegrator.csproj b/LanguageIntegrator/LanguageIntegrator.csproj new file mode 100644 index 000000000..7dcaa87c1 --- /dev/null +++ b/LanguageIntegrator/LanguageIntegrator.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {A48D9069-D569-4110-9252-A10F139B669B} + Library + Properties + LanguageIntegration + LanguageIntegrator + v4.0 + 512 + true + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + {af2efd7b-69dd-4b43-af65-b59b29349c23} + ParserTools + + + + \ No newline at end of file diff --git a/LanguageIntegrator/Properties/AssemblyInfo.cs b/LanguageIntegrator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..64a9d15d5 --- /dev/null +++ b/LanguageIntegrator/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System.Reflection; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("LanguageIntegrator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LanguageIntegrator")] +[assembly: AssemblyCopyright("Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("a48d9069-d569-4110-9252-a10f139b669b")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index c7869946c..013d458a6 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -17,6 +17,7 @@ using System.Threading; using NETGenerator; using PascalABCCompiler.NetHelper; using PascalABCCompiler.SemanticTree; +using PascalABCCompiler.TreeConverter; namespace PascalABCCompiler.NETGenerator { @@ -462,7 +463,7 @@ namespace PascalABCCompiler.NETGenerator bool IsDllAndSystemNamespace(string name, string DllFileName) { return comp_opt.target == TargetType.Dll && DllFileName != "PABCRtl.dll" && - (name == "PABCSystem" || name == "PABCExtensions" || + (name == compiler_string_consts.pascalSystemUnitName || name == compiler_string_consts.pascalExtensionsUnitName || name.EndsWith(PascalABCCompiler.TreeConverter.compiler_string_consts.ImplementationSectionNamespaceName)); } diff --git a/Optimizer/Optimizer.cs b/Optimizer/Optimizer.cs index 71abbc364..1e043d823 100644 --- a/Optimizer/Optimizer.cs +++ b/Optimizer/Optimizer.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Text; +using PascalABCCompiler.TreeConverter; using PascalABCCompiler.TreeRealization; namespace PascalABCCompiler @@ -1110,7 +1111,7 @@ namespace PascalABCCompiler private void VisitCommonNamespaceFunctionCall(common_namespace_function_call en) { CheckInfiniteRecursion(en); - if ((en.function_node.name == "Reset" || en.function_node.name == "Rewrite" || en.function_node.name == "Assign") && en.function_node.comprehensive_namespace.namespace_name == "PABCSystem") + if ((en.function_node.name == "Reset" || en.function_node.name == "Rewrite" || en.function_node.name == "Assign") && en.function_node.comprehensive_namespace.namespace_name == compiler_string_consts.pascalSystemUnitName) { expression_node p = en.parameters[0]; switch (p.semantic_node_type) diff --git a/ParserTools/ParserTools/BaseParser.cs b/ParserTools/ParserTools/BaseParser.cs index 9762ca0c5..a84d06adb 100644 --- a/ParserTools/ParserTools/BaseParser.cs +++ b/ParserTools/ParserTools/BaseParser.cs @@ -1,8 +1,6 @@ // Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -using System; using System.Collections.Generic; -using System.Text; using PascalABCCompiler.Errors; using PascalABCCompiler.SyntaxTree; @@ -11,12 +9,13 @@ namespace PascalABCCompiler.Parsers public abstract class BaseParser: IParser { - public BaseParser(string name, string version, string copyright, + public BaseParser(string name, string version, string copyright, string[] systemUnitNames, bool caseSensitive, string[] filesExtensions) { this.name = name; this.version = version; this.copyright = copyright; + this.SystemUnitNames = systemUnitNames; this.caseSensitive = caseSensitive; this.filesExtensions = filesExtensions; } @@ -91,6 +90,8 @@ namespace PascalABCCompiler.Parsers get { return copyright; } } + public string[] SystemUnitNames { get; } + public SourceFilesProviderDelegate sourceFilesProvider = null; public virtual SourceFilesProviderDelegate SourceFilesProvider { diff --git a/ParserTools/ParserTools/Errors.cs b/ParserTools/ParserTools/Errors.cs index 6abee39b9..3bce44540 100644 --- a/ParserTools/ParserTools/Errors.cs +++ b/ParserTools/ParserTools/Errors.cs @@ -1,10 +1,6 @@ // Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Collections.Generic; -using System.Text; -//using com.calitha.goldparser; -using PascalABCCompiler.Errors; using PascalABCCompiler.SyntaxTree; namespace PascalABCCompiler.Errors diff --git a/ParserTools/ParsersController.cs b/ParserTools/ParsersController.cs index 0250322b7..fbb912afb 100644 --- a/ParserTools/ParsersController.cs +++ b/ParserTools/ParsersController.cs @@ -2,77 +2,101 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.IO; -using PascalABCCompiler.ParserTools; using PascalABCCompiler.Errors; using System.Collections.Generic; -using System.Diagnostics; +using System.Reflection; using System.Linq; namespace PascalABCCompiler.Parsers { public class Controller { + + private static readonly Lazy lazyInstanceWrapper = new Lazy(() => new Controller(), true); + public static Controller Instance { get { return lazyInstanceWrapper.Value; } } + public const char HideParserExtensionPostfixChar = '_'; - public delegate void ParserConnectedDeleagte(IParser Parser); - public event ParserConnectedDeleagte ParserConnected; + + public event Action ParserConnected; + public event Action ParserLoadErrorOccured; + public List Parsers = new List(); + public IParser LastParser; - public void Reload() - { - Parsers.Clear(); - LastParser = null; - string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); - DirectoryInfo di = new DirectoryInfo(dir); - FileInfo[] dllfiles = di.GetFiles("*Parser.dll"); - System.Reflection.Assembly asssembly = null; - Type constr = null; - IParser pc = null; - foreach (FileInfo fi in dllfiles) + + /// + /// Загружает стандартные парсеры из папки бин (в частности PascalABCParser.dll) + /// + public void LoadStandardParsers() + { + string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); + + DirectoryInfo directory = new DirectoryInfo(directoryName); + + FileInfo[] dllfiles = directory.GetFiles("*Parser.dll"); + + foreach (FileInfo parserFile in dllfiles) { - if (Path.GetFileName(fi.FullName) == "VBNETParser.dll" || Path.GetFileName(fi.FullName) == "PascalABCPartParser.dll") + if (Path.GetFileName(parserFile.FullName) == "VBNETParser.dll" || Path.GetFileName(parserFile.FullName) == "PascalABCPartParser.dll") continue; - asssembly = System.Reflection.Assembly.LoadFile(fi.FullName); - try + + IntegrateParsersFromAssembly(parserFile); + } + } + + /// + /// Загружает все парсеры языков из переданной сборки, используя рефлексию + /// + public void IntegrateParsersFromAssembly(FileInfo parserFile) + { + Assembly assembly = Assembly.LoadFile(parserFile.FullName); + try + { + Type[] types = assembly.GetTypes(); + if (assembly != null) { - Type[] types = asssembly.GetTypes(); - if (asssembly != null) + foreach (Type type in types) { - foreach (Type type in types) + if (type.Name.IndexOf("LanguageParser") >= 0) { - if (type.Name.IndexOf("LanguageParser") >= 0) + object obj = Activator.CreateInstance(type); + if (obj is IParser parser) { - Object obj = Activator.CreateInstance(type); - if (obj is IParser) - { - LastParser = (IParser)obj; - Parsers.Add(LastParser); - LastParser.Reset();//Здесь поисходит инициализация парсеров - LastParser.SourceFilesProvider = sourceFilesProvider; - if (ParserConnected != null) - ParserConnected(LastParser); - } + SaveParser(parser); } } } } - catch (System.Reflection.ReflectionTypeLoadException e) - { - Console.Error.WriteLine("Parser {0} reflection error {1}", Path.GetFileName(fi.FullName), e); - foreach (var le in e.LoaderExceptions) - Console.Error.WriteLine(le); - } - catch (Exception e) - { - Console.Error.WriteLine("Parser {0} loading error {1}", Path.GetFileName(fi.FullName),e); - } } - LastParser = null; - } - public Controller() - { - sourceFilesProvider = PascalABCCompiler.SourceFilesProviders.DefaultSourceFilesProvider; + catch (ReflectionTypeLoadException e) + { +#if DEBUG + string errorMessage = e + Environment.NewLine; + errorMessage += ":" + Environment.NewLine; + errorMessage += string.Join(Environment.NewLine, e.LoaderExceptions.Select(error => error.ToString())) + Environment.NewLine; + File.AppendAllText("log.txt", errorMessage); +#endif + string errorLocalized = string.Format(ParserErrorsStringResources.Get("LOAD_ERROR{0}"), Path.GetFileName(parserFile.FullName)); + ParserLoadErrorOccured?.Invoke(errorLocalized + Environment.NewLine); + } + catch (Exception e) + { +#if DEBUG + string errorMessage = e + Environment.NewLine; + File.AppendAllText("log.txt", errorMessage); +#endif + string errorLocalized = string.Format(ParserErrorsStringResources.Get("LOAD_ERROR{0}"), Path.GetFileName(parserFile.FullName)); + ParserLoadErrorOccured?.Invoke(errorLocalized + Environment.NewLine); + } } + + private Controller() + { + sourceFilesProvider = SourceFilesProviders.DefaultSourceFilesProvider; + } + SourceFilesProviderDelegate sourceFilesProvider = null; + public SourceFilesProviderDelegate SourceFilesProvider { get @@ -88,121 +112,119 @@ namespace PascalABCCompiler.Parsers } } } - public IParser selectParser(string ext) + + /// + /// Добавляет парсер в общий список парсеров (с вызовом инициализации парсера) + /// + private void SaveParser(IParser parser) { - foreach (IParser pc in Parsers) - foreach (string sfext in pc.FilesExtensions) - if (sfext.ToLower() == ext) - return pc; + Parsers.Add(parser); + parser.Reset(); + parser.SourceFilesProvider = SourceFilesProvider; + ParserConnected?.Invoke(parser); + } + + /// + /// Возвращает подходящий для переданного расширения парсер из имеющихся + /// + public IParser SelectParser(string extension) + { + foreach (IParser parser in Parsers) + foreach (string parserExtension in parser.FilesExtensions) + if (parserExtension.ToLower() == extension) + return parser; return null; } + + public bool ParserExists(string ext) { - return selectParser(ext) != null; + return SelectParser(ext) != null; } - //public Keyword[] GetKeywordsForExtension(string extension) - //{ - // IParser p = selectParser(extension); - // if (p != null) - // return p.Keywords; - // return null; - //} - public SyntaxTree.syntax_tree_node Compile(string FileName, string Text, List Errors, List Warnings, ParseMode ParseMode, List DefinesList = null) + + /// + /// Строит синтаксическое дерево с автоматическим выбором подходящего парсера + /// + /// + public SyntaxTree.syntax_tree_node SelectParserForUnitAndBuildTree(string FileName, string Text, List Errors, List Warnings, ParseMode ParseMode, List DefinesList = null) { - LastParser = selectParser(Path.GetExtension(FileName).ToLower()); + LastParser = SelectParser(Path.GetExtension(FileName).ToLower()); + if (LastParser == null) throw new ParserBadFileExtension(FileName); + LastParser.Errors = Errors; LastParser.Warnings = Warnings; + return LastParser.BuildTree(FileName, Text, ParseMode, DefinesList); } - public SyntaxTree.compilation_unit GetCompilationUnitSpecial(string FileName, string Text, List Errors, List Warnings) - { - SyntaxTree.syntax_tree_node cu = Compile(FileName, Text, Errors, Warnings, ParseMode.Special); - if (cu == null) - return null; - if (cu is SyntaxTree.compilation_unit) - return cu as SyntaxTree.compilation_unit; - Errors.Add(new Errors.UnexpectedNodeType(FileName, cu.source_context,null)); - return null; - //throw new Errors.CompilerInternalError("Parsers.Controller.GetComilationUnit", new Exception("bad node type")); - } - public SyntaxTree.compilation_unit GetCompilationUnit(string FileName, string Text, List Errors, List Warnings, List DefinesList = null) - { - SyntaxTree.syntax_tree_node cu = Compile(FileName, Text, Errors, Warnings, ParseMode.Normal, DefinesList); - if (cu == null) - return null; - if (cu is SyntaxTree.compilation_unit) - return cu as SyntaxTree.compilation_unit; - Errors.Add(new Errors.UnexpectedNodeType(FileName, cu.source_context,null)); - return null; - //throw new Errors.CompilerInternalError("Parsers.Controller.GetComilationUnit", new Exception("bad node type")); + /// + /// Возвращеает синтаксическое дерево модуля + /// + public SyntaxTree.compilation_unit GetCompilationUnit(string FileName, string Text, List Errors, List Warnings, ParseMode parseMode, List DefinesList = null) + { + return GetSyntaxTree(FileName, Text, Errors, Warnings, parseMode, DefinesList); } + public SyntaxTree.compilation_unit GetCompilationUnitForFormatter(string FileName, string Text, List Errors, List Warnings) { - SyntaxTree.syntax_tree_node cu = null; - try // SSM 06.09.18 - { - cu = Compile(FileName, Text, Errors, Warnings, ParseMode.ForFormatter); + try // SSM 06.09.18 + { + return GetSyntaxTree(FileName, Text, Errors, Warnings, ParseMode.ForFormatter); } - catch (Errors.ParserBadFileExtension e) + catch (ParserBadFileExtension e) { Errors.Add(e); return null; // Погасить исключение если оно не погашено ранее } - if (cu == null) - return null; - if (cu is SyntaxTree.compilation_unit) - return cu as SyntaxTree.compilation_unit; - Errors.Add(new Errors.UnexpectedNodeType(FileName, cu.source_context, null)); - return null; } + public SyntaxTree.expression GetExpression(string FileName, string Text, List Errors, List Warnings) { - SyntaxTree.syntax_tree_node cu = null; - try // SSM 06.09.18 + try // SSM 06.09.18 { - cu = Compile(FileName, Text, Errors, Warnings, ParseMode.Expression); + return GetSyntaxTree(FileName, Text, Errors, Warnings, ParseMode.Expression); } catch { - - } - if (cu == null) return null; - if (cu is SyntaxTree.expression) - return cu as SyntaxTree.expression; - Errors.Add(new Errors.UnexpectedNodeType(FileName, cu.source_context, null)); - return null; - //throw new Errors.CompilerInternalError("Parsers.Controller.GetComilationUnit", new Exception("bad node type")); + } } + public SyntaxTree.expression GetTypeAsExpression(string FileName, string Text, List Errors, List Warnings) { - SyntaxTree.syntax_tree_node cu = Compile(FileName, Text, Errors, Warnings, ParseMode.TypeAsExpression); - if (cu == null) - return null; - if (cu is SyntaxTree.expression) - return cu as SyntaxTree.expression; - Errors.Add(new Errors.UnexpectedNodeType(FileName, cu.source_context, null)); - return null; - //throw new Errors.CompilerInternalError("Parsers.Controller.GetComilationUnit", new Exception("bad node type")); + return GetSyntaxTree (FileName, Text, Errors, Warnings, ParseMode.TypeAsExpression); } + public SyntaxTree.statement GetStatement(string FileName, string Text, List Errors, List Warnings) { - SyntaxTree.syntax_tree_node cu = Compile(FileName, Text, Errors, Warnings, ParseMode.Statement); - if (cu == null) - return null; - if (cu is SyntaxTree.statement) - return cu as SyntaxTree.statement; - Errors.Add(new Errors.UnexpectedNodeType(FileName, cu.source_context, null)); - return null; - //throw new Errors.CompilerInternalError("Parsers.Controller.GetComilationUnit", new Exception("bad node type")); + return GetSyntaxTree(FileName, Text, Errors, Warnings, ParseMode.Statement); } + + /// + /// Обобщенная функция для получения различных синтаксических узлов + /// + private T GetSyntaxTree(string FileName, string Text, List Errors, List Warnings, ParseMode parseMode, List DefinesList = null) where T : SyntaxTree.syntax_tree_node + { + SyntaxTree.syntax_tree_node unitNode = SelectParserForUnitAndBuildTree(FileName, Text, Errors, Warnings, parseMode, DefinesList); + + if (unitNode == null) + return null; + + if (unitNode is T) + return unitNode as T; + + Errors.Add(new UnexpectedNodeType(FileName, unitNode.source_context, null)); + + return null; + } + public void Reset() { - } - + + } + } } diff --git a/Parsers/PascalABCParserNewSaushkin/Parser.cs b/Parsers/PascalABCParserNewSaushkin/Parser.cs index e919719ec..fc7acc1d0 100644 --- a/Parsers/PascalABCParserNewSaushkin/Parser.cs +++ b/Parsers/PascalABCParserNewSaushkin/Parser.cs @@ -114,7 +114,7 @@ namespace PascalABCCompiler.PascalABCNewParser //public Preprocessor2.Preprocessor2 preprocessor2 = new PascalABCCompiler.Preprocessor2.Preprocessor2(null); public PascalABCNewLanguageParser() - : base("PascalABC.NET", "1.2", "Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich", false, new string[] { ".pas" }) + : base("PascalABC.NET", "1.2", "Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich", new string[] { "PABCSystem", "PABCExtensions" }, false, new string[] { ".pas" }) { } diff --git a/PascalABCNET.sln b/PascalABCNET.sln index 19d76a8d1..b4baa9678 100644 --- a/PascalABCNET.sln +++ b/PascalABCNET.sln @@ -107,6 +107,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LambdaAnySynToSemConverter" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Parsers\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{1443F539-DCC7-4491-B4FD-B716C739DB3C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanguageIntegrator", "LanguageIntegrator\LanguageIntegrator.csproj", "{A48D9069-D569-4110-9252-A10F139B669B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -503,6 +505,18 @@ Global {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.Build.0 = Release|Any CPU {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.ActiveCfg = Release|Any CPU {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.Build.0 = Release|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Debug|x86.ActiveCfg = Debug|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Debug|x86.Build.0 = Debug|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Release|Any CPU.Build.0 = Release|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Release|x86.ActiveCfg = Release|Any CPU + {A48D9069-D569-4110-9252-A10F139B669B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -548,6 +562,7 @@ Global {536CC813-7C4E-42BC-AE3A-BA1427F38756} = {EC68A3D8-6D63-4A79-ABA6-BF8E9D7756D7} {27D9800E-2689-4AA1-A2D6-128E4A9BAE98} = {F8CE2712-826B-450B-A72F-D32D80C99858} {1443F539-DCC7-4491-B4FD-B716C739DB3C} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} + {A48D9069-D569-4110-9252-A10F139B669B} = {F8CE2712-826B-450B-A72F-D32D80C99858} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {68E993E6-EE86-4DDF-B0A1-4FE884F8AC39} diff --git a/ReleaseGenerators/PascalABCNET_head.nsh b/ReleaseGenerators/PascalABCNET_head.nsh index aab7bb228..f04282cfe 100644 --- a/ReleaseGenerators/PascalABCNET_head.nsh +++ b/ReleaseGenerators/PascalABCNET_head.nsh @@ -113,6 +113,7 @@ Section ${AddDirectory} "$INSTDIR\PT4" ${AddDirectory} "$INSTDIR\Ico" ${AddDirectory} "$INSTDIR\Doc" + ${AddDirectory} "$INSTDIR\LanguageKits" ${AddInstallerFile} "Uninstall.exe" SectionEnd diff --git a/ReleaseGenerators/sect_Core.nsh b/ReleaseGenerators/sect_Core.nsh index 1c82e2f80..d153bc284 100644 --- a/ReleaseGenerators/sect_Core.nsh +++ b/ReleaseGenerators/sect_Core.nsh @@ -7,6 +7,7 @@ File "..\bin\Errors.dll" File "..\bin\Localization.dll" File "..\bin\NETGenerator.dll" + File "..\bin\LanguageIntegrator.dll" File "..\bin\ParserTools.dll" File "..\bin\SemanticTree.dll" File "..\bin\SyntaxTree.dll" @@ -57,6 +58,7 @@ ${AddFile} "Errors.dll" ${AddFile} "Localization.dll" ${AddFile} "NETGenerator.dll" + ${AddFile} "LanguageIntegrator.dll" ${AddFile} "ParserTools.dll" ${AddFile} "SemanticTree.dll" ${AddFile} "SyntaxTree.dll" diff --git a/ReleaseGenerators/sect_VisualPABCNET.nsh b/ReleaseGenerators/sect_VisualPABCNET.nsh index 5a3f0dae3..a6bb253a9 100644 --- a/ReleaseGenerators/sect_VisualPABCNET.nsh +++ b/ReleaseGenerators/sect_VisualPABCNET.nsh @@ -46,6 +46,7 @@ ${AddFile} "RunUnitTests.exe" SetOutPath "$INSTDIR\Temp" + SetOutPath "$INSTDIR\LanguageKits" SetOutPath "$INSTDIR" Push "Pause.exe" Call NGEN diff --git a/TreeConverter/NetWrappers/NetHelper.cs b/TreeConverter/NetWrappers/NetHelper.cs index 57756cc5b..c64ad72ab 100644 --- a/TreeConverter/NetWrappers/NetHelper.cs +++ b/TreeConverter/NetWrappers/NetHelper.cs @@ -649,7 +649,7 @@ namespace PascalABCCompiler.NetHelper { if (_assembly.ManifestModule.ScopeName == compiler_string_consts.pabc_rtl_dll_name) { - if (t.Name == "PABCSystem") + if (t.Name == compiler_string_consts.pascalSystemUnitName) PABCSystemType = t; else if (t.Name == "PT4") PT4Type = t; diff --git a/TreeConverter/TreeConversion/compiler_string_consts.cs b/TreeConverter/TreeConversion/compiler_string_consts.cs index 729474b1a..a16b48b87 100644 --- a/TreeConverter/TreeConversion/compiler_string_consts.cs +++ b/TreeConverter/TreeConversion/compiler_string_consts.cs @@ -320,6 +320,7 @@ namespace PascalABCCompiler.TreeConverter public static string default_constructor_name = "create"; // SSM - Константы директив компилятора. Вообще разбросаны по коду. Пусть будут здесь (3.1.2011) + #region COMPILER DIRECTIVES public static string compiler_directive_apptype = "apptype"; public static string compiler_directive_reference = "reference"; public static string include_namespace_directive = "includenamespace"; @@ -345,20 +346,30 @@ namespace PascalABCCompiler.TreeConverter public static string compiler_directive_define = "define"; public static string compiler_directive_include = "include"; public static string compiler_directive_targetframework = "targetframework"; + public const string version_string = "version"; + public const string product_string = "product"; + public const string company_string = "company"; + public const string copyright_string = "copyright"; + public const string trademark_string = "trademark"; + public const string main_resource_string = "mainresource"; + public const string title_string = "title"; + public const string description_string = "description"; + #endregion - // SSM (3.1.2011) Перенес эти константы сюда. - public static string version_string = "version"; - public static string product_string = "product"; - public static string company_string = "company"; - public static string copyright_string = "copyright"; - public static string trademark_string = "trademark"; - public static string main_resource_string = "mainresource"; - public static string title_string = "title"; - public static string description_string = "description"; - + // SSM (3.1.2011) Перенес эти константы сюда. public static string system_unit_marker = "__IS_SYSTEM_MODULE"; - public static string system_unit_file_name = "PABCSystem"; - public static string extensions_unit_file_name = "PABCExtensions"; + #region PASCAL LANGUAGE + public const string pascalLanguageName = "PascalABC.NET"; + public const string pascalSourceFileExtension = ".pas"; + public const string pascalCompiledUnitExtension = ".pcu"; + public static string pascalSystemUnitName = "PABCSystem"; + public static string pascalExtensionsUnitName = "PABCExtensions"; + public static readonly string[] pascalDefaultStandardModules = new string[] + { + pascalSystemUnitName, + pascalExtensionsUnitName + }; + #endregion public static string get_array_type_name(string type_name, int rank) { diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 1d9731df6..9ce0f8d65 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -2162,7 +2162,7 @@ namespace PascalABCCompiler.TreeConverter { if (function.sym_info is compiled_function_node cfn0 && cfn0.comperehensive_type is compiled_type_node ctn0 && - (ctn0.compiled_type.Name == "PABCSystem" + compiler_string_consts.ImplementationSectionNamespaceName || ctn0.compiled_type.Name == "PABCExtensions" + compiler_string_consts.ImplementationSectionNamespaceName) + (ctn0.compiled_type.Name == compiler_string_consts.pascalSystemUnitName + compiler_string_consts.ImplementationSectionNamespaceName || ctn0.compiled_type.Name == compiler_string_consts.pascalExtensionsUnitName + compiler_string_consts.ImplementationSectionNamespaceName) && !ctn0.compiled_type.Assembly.FullName.StartsWith("PABCRtl")) // пропустить функции (методы расширения), определенные в сборке в ПИ PABCSystem, но не в PABCRtl.dll continue; // В режиме only_from_not_extensions пропускать все extensions diff --git a/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs b/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs index 81853eab9..962b8fba1 100644 --- a/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs +++ b/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs @@ -96,7 +96,7 @@ namespace PascalABCCompiler.TreeConverter var semex = convert_strong(ex); var b = convertion_data_and_alghoritms.can_convert_type(semex, SystemLibrary.SystemLibrary.integer_type); var toIsIndex = (semex is common_constructor_call toCall) && - toCall.common_type.comprehensive_namespace.namespace_full_name.Equals("PABCSystem") && + toCall.common_type.comprehensive_namespace.namespace_full_name.Equals(compiler_string_consts.pascalSystemUnitName) && toCall.common_type.PrintableName.Equals("SystemIndex"); var toIsIndex1 = (semex is compiled_constructor_call toCall1) && @@ -252,7 +252,7 @@ namespace PascalABCCompiler.TreeConverter var semfrom = convert_strong(from); var fromIsIndex = (semfrom is common_constructor_call fromCall) && - fromCall.common_type.comprehensive_namespace.namespace_full_name.Equals("PABCSystem") && + fromCall.common_type.comprehensive_namespace.namespace_full_name.Equals(compiler_string_consts.pascalSystemUnitName) && fromCall.common_type.PrintableName.Equals("SystemIndex"); var b = convertion_data_and_alghoritms.can_convert_type(semfrom, SystemLibrary.SystemLibrary.integer_type); if (!b && !fromIsIndex) @@ -260,7 +260,7 @@ namespace PascalABCCompiler.TreeConverter var semto = convert_strong(to); var toIsIndex = (semto is common_constructor_call toCall) && - toCall.common_type.comprehensive_namespace.namespace_full_name.Equals("PABCSystem") && + toCall.common_type.comprehensive_namespace.namespace_full_name.Equals(compiler_string_consts.pascalSystemUnitName) && toCall.common_type.PrintableName.Equals("SystemIndex"); b = convertion_data_and_alghoritms.can_convert_type(semto, SystemLibrary.SystemLibrary.integer_type); if (!b && !toIsIndex) diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 130dbd26f..76f6511b5 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -14962,7 +14962,7 @@ namespace PascalABCCompiler.TreeConverter var cnf = exp as common_namespace_function_call; if (cnf != null) { - is_userdefined = ! (cnf.function_node.namespace_node.namespace_name.Equals("PABCSystem") || cnf.function_node.namespace_node.namespace_name.Equals("PABCSystem_implementation______")); + is_userdefined = ! (cnf.function_node.namespace_node.namespace_name.Equals(compiler_string_consts.pascalSystemUnitName) || cnf.function_node.namespace_node.namespace_name.Equals("PABCSystem_implementation______")); } return convert_strong_to_constant_node(exp, exp.type, is_const_section && is_userdefined, is_const_section); } @@ -15086,7 +15086,7 @@ namespace PascalABCCompiler.TreeConverter var cnf = exp as common_namespace_function_call; if (cnf != null) { - is_userdefined = !(cnf.function_node.namespace_node.namespace_name.Equals("PABCSystem") || cnf.function_node.namespace_node.namespace_name.Equals("PABCSystem_implementation______")); + is_userdefined = !(cnf.function_node.namespace_node.namespace_name.Equals(compiler_string_consts.pascalSystemUnitName) || cnf.function_node.namespace_node.namespace_name.Equals("PABCSystem_implementation______")); } return convert_strong_to_constant_node(exp, tn, is_const_section && is_userdefined, is_const_section); @@ -21568,7 +21568,7 @@ namespace PascalABCCompiler.TreeConverter public method_call ToNullable(expression e) { - var dn = new dot_node(new ident("PABCSystem"), new ident("DQNToNullable")); + var dn = new dot_node(new ident(compiler_string_consts.pascalSystemUnitName), new ident("DQNToNullable")); return new method_call(dn, new expression_list(e), e.source_context); } @@ -21591,7 +21591,7 @@ namespace PascalABCCompiler.TreeConverter try_convert_typed_expression_to_function_call(ref av_cs); if (!type_table.is_with_nil_allowed(av_cs.type)) { - var dn = new dot_node(new ident("PABCSystem"), new ident("DQNToNullable")); + var dn = new dot_node(new ident(compiler_string_consts.pascalSystemUnitName), new ident("DQNToNullable")); (av.new_addr_value as SyntaxTree.question_colon_expression).ret_if_false = new method_call(dn, new expression_list((av.new_addr_value as SyntaxTree.question_colon_expression).ret_if_false), av.source_context); diff --git a/VisualPascalABCNET/DS/Tools.cs b/VisualPascalABCNET/DS/Tools.cs index 7893a8bdf..8242bc65f 100644 --- a/VisualPascalABCNET/DS/Tools.cs +++ b/VisualPascalABCNET/DS/Tools.cs @@ -7,6 +7,8 @@ using System.Windows.Forms; using System.IO; using System.Runtime.InteropServices; using Microsoft.Win32; +using PascalABCCompiler; +using PascalABCCompiler.TreeConverter; namespace VisualPascalABC { @@ -56,7 +58,7 @@ namespace VisualPascalABC { string sf = PascalABCCompiler.FormatTools.ExtensionsToString(Extensions, "*", ";"); sf = string.Format(VECStringResources.Get("DIALOGS_FILTER_PART_{0}{1}|{1}|"), Name, sf); - if (sf.IndexOf(".pas") >= 0) + if (sf.IndexOf(compiler_string_consts.pascalSourceFileExtension) >= 0) return sf + Filter; else return Filter + sf; diff --git a/VisualPascalABCNET/DS/VisualEnvironmentCompiler.cs b/VisualPascalABCNET/DS/VisualEnvironmentCompiler.cs index 84864c6b2..b246064ce 100644 --- a/VisualPascalABCNET/DS/VisualEnvironmentCompiler.cs +++ b/VisualPascalABCNET/DS/VisualEnvironmentCompiler.cs @@ -2,9 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; @@ -75,7 +72,7 @@ namespace VisualPascalABC { this.StandartDirectories = StandartDirectories; this.ErrorsManager = ErrorsManager; - this.ChangeVisualEnvironmentState += new ChangeVisualEnvironmentStateDelegate(onChangeVisualEnvironmentState); + this.ChangeVisualEnvironmentState += onChangeVisualEnvironmentState; SetCompilingButtonsEnabled = setCompilingButtonsEnabled; SetDebugButtonsEnabled = setCompilingDebugEnabled; SetStateText = setStateText; @@ -85,17 +82,20 @@ namespace VisualPascalABC this.ExecuteVECAction = ExecuteVECAction; PluginsMenuItem = pluginsMenuItem; PluginsToolStrip = pluginsToolStrip; - PluginsController = new VisualPascalABCPlugins.PluginsController(this, PluginsMenuItem, PluginsToolStrip, workbench); + PluginsController = new PluginsController(this, PluginsMenuItem, PluginsToolStrip, workbench); this.RunnerManager = RunnerManager; this.DebugHelper = DebugHelper; - DebugHelper.Starting += new DebugHelper.DebugHelperActionDelegate(DebugHelper_Starting); - DebugHelper.Exited += new DebugHelper.DebugHelperActionDelegate(DebugHelper_Exited); - RunnerManager.Starting += new RunnerManagerActionDelegate(RunnerManager_Starting); - RunnerManager.Exited += new RunnerManagerActionDelegate(RunnerManager_Exited); + DebugHelper.Starting += DebugHelper_Starting; + DebugHelper.Exited += DebugHelper_Exited; + RunnerManager.Starting += RunnerManager_Starting; + RunnerManager.Exited += RunnerManager_Exited; this.CodeCompletionParserController = WorkbenchServiceFactory.CodeCompletionParserController; this.CodeCompletionParserController.visualEnvironmentCompiler = this; this.UserOptions = UserOptions; this.OpenDocuments = OpenDocuments; + + PascalABCCompiler.Parsers.Controller.Instance.ParserConnected += OnParserConnected; + PascalABCCompiler.Parsers.Controller.Instance.ParserLoadErrorOccured += OnParserLoadErrorOccured; } void RunnerManager_Exited(string fileName) @@ -316,6 +316,25 @@ namespace VisualPascalABC AddTextToCompilerMessages(VECStringResources.Get("REMOTE_COMPILER_PREFIX") + text); } List ParsedFiles = new List(); + + /// + /// Выводит сообщения о подключенных парсерах + /// + private void OnParserConnected(PascalABCCompiler.Parsers.IParser parser) + { + string parserConnectedMessage = string.Format(VECStringResources.Get("PARSER_CONNECTED{0}{1}"), parser, Path.GetFileName(parser.GetType().Assembly.Location)); + parserConnectedMessage += Environment.NewLine; + AddTextToCompilerMessages(parserConnectedMessage); + } + + /// + /// Выводит сообщения об ошибках, возникших при загрузке парсеров + /// + private void OnParserLoadErrorOccured(string errorMessage) + { + AddTextToCompilerMessages(errorMessage); + } + private void OnChangeCompilerStateEx(PascalABCCompiler.ICompiler sender, PascalABCCompiler.CompilerState State, string FullFileName) { @@ -344,14 +363,6 @@ namespace VisualPascalABC case PascalABCCompiler.CompilerState.SemanticTreeConverterConnected: RusName = VECStringResources.Get("STATE_SEMANTICTREECONVERTERCONNECTED{0}"); break; case PascalABCCompiler.CompilerState.SyntaxTreeConversion: RusName = VECStringResources.Get("STATE_SYNTAXTREECONVERSION{0}"); break; case PascalABCCompiler.CompilerState.SyntaxTreeConverterConnected: RusName = VECStringResources.Get("STATE_SYNTAXTREECONVERTERCONNECTED{0}"); break; - case PascalABCCompiler.CompilerState.ParserConnected: - FileName = Path.GetFileName(FileName); - if(sender.CompilerType== PascalABCCompiler.CompilerType.Standart) - RusName = string.Format(VECStringResources.Get("PARSER_CONNECTED{0}{1}"), sender.ParsersController.LastParser, FileName); - else - RusName = string.Format(VECStringResources.Get("PARSER_CONNECTED{0}"), FileName); - FileName = null; - break; case PascalABCCompiler.CompilerState.Ready: RusName = VECStringResources.Get("STATE_READY"); if (!StartingCompleted) diff --git a/VisualPascalABCNET/DockContent/CodeFileDocument.cs b/VisualPascalABCNET/DockContent/CodeFileDocument.cs index 8b8f9db7f..7bf2e2d5b 100644 --- a/VisualPascalABCNET/DockContent/CodeFileDocument.cs +++ b/VisualPascalABCNET/DockContent/CodeFileDocument.cs @@ -520,7 +520,7 @@ namespace VisualPascalABC VisualPABCSingleton.MainForm._currentCodeFileDocument.FileName, existing_text, //VisualPascalABC.Form1.Form1_object._currentCodeFileDocument.TextEditor.Text, Errors, - Warnings); + Warnings, PascalABCCompiler.Parsers.ParseMode.Normal); PascalABCCompiler.SyntaxTree.unit_module um = sn as PascalABCCompiler.SyntaxTree.unit_module; bool good_syntax = um != null; PascalABCCompiler.SyntaxTree.type_declaration form_decl = null; diff --git a/VisualPascalABCNET/Form1.cs b/VisualPascalABCNET/Form1.cs index e1667fb9c..dbe8c4813 100644 --- a/VisualPascalABCNET/Form1.cs +++ b/VisualPascalABCNET/Form1.cs @@ -585,8 +585,10 @@ namespace VisualPascalABC { if(_mainFormWindowStateMaximized) - this.WindowState = FormWindowState.Maximized; - //PascalABCCompiler.StringResourcesLanguage.CurrentLanguageName = "Russi + this.WindowState = FormWindowState.Maximized; + + // загрузка всех парсеров и других составляющих языков EVA + LanguageIntegration.LanguageIntegrator.LoadAllLanguages(); ChangedSelectedTab(); VisualEnvironmentCompiler.ChangeVisualEnvironmentState += new ChangeVisualEnvironmentStateDelegate(VisualEnvironmentCompiler_ChangeVisualEnvironmentState); @@ -1638,7 +1640,6 @@ namespace VisualPascalABC var aw = ABCHealthForm.Width; var ah = ABCHealthForm.Height; var c = new PascalABCCompiler.Compiler(); - c.Reload(); var errors = new List(); var warnings = new List(); diff --git a/VisualPascalABCNET/IB/Debugger/Debugger.cs b/VisualPascalABCNET/IB/Debugger/Debugger.cs index faf555ba7..341aacfaf 100644 --- a/VisualPascalABCNET/IB/Debugger/Debugger.cs +++ b/VisualPascalABCNET/IB/Debugger/Debugger.cs @@ -464,7 +464,7 @@ namespace VisualPascalABC this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.ExeFileName = fileName; CurrentLine = 0; - this.parser = CodeCompletion.CodeCompletionController.ParsersController.selectParser(Path.GetExtension(FullFileName).ToLower()); + this.parser = CodeCompletion.CodeCompletionController.ParsersController.SelectParser(Path.GetExtension(FullFileName).ToLower()); this.PrevFullFileName = FullFileName; AssemblyHelper.LoadAssembly(fileName); dbg.ProcessStarted += debugProcessStarted; diff --git a/VisualPascalABCNET/Projects/ProjectExplorer.cs b/VisualPascalABCNET/Projects/ProjectExplorer.cs index 60e9a882f..4aa7a5828 100644 --- a/VisualPascalABCNET/Projects/ProjectExplorer.cs +++ b/VisualPascalABCNET/Projects/ProjectExplorer.cs @@ -7,6 +7,8 @@ using System.IO; using System.Drawing; using System.Windows.Forms; using Microsoft.Build.BuildEngine; +using PascalABCCompiler; +using PascalABCCompiler.TreeConverter; namespace VisualPascalABC { @@ -382,7 +384,7 @@ namespace VisualPascalABC MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_NAME"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (string.Compare(Path.GetExtension(e.Label), ".pas", true) != 0) + if (string.Compare(Path.GetExtension(e.Label), compiler_string_consts.pascalSourceFileExtension, true) != 0) { e.CancelEdit = true; MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_EXTENSION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/VisualPascalABCNET/Projects/ProjectHelper.cs b/VisualPascalABCNET/Projects/ProjectHelper.cs index f5925137d..1b2db6a6d 100644 --- a/VisualPascalABCNET/Projects/ProjectHelper.cs +++ b/VisualPascalABCNET/Projects/ProjectHelper.cs @@ -7,6 +7,8 @@ using System.Drawing; using System.Windows.Forms; using System.IO; using System.Text; +using PascalABCCompiler; +using PascalABCCompiler.TreeConverter; namespace VisualPascalABC { @@ -63,7 +65,7 @@ namespace VisualPascalABC currentProject.include_debug_info = true; currentProject.project_type = projectType; - currentProject.source_files.Add(new PascalABCCompiler.SourceCodeFileInfo(projectName + ".pas", Path.Combine(dir, projectName + ".pas"))); + currentProject.source_files.Add(new PascalABCCompiler.SourceCodeFileInfo(projectName + compiler_string_consts.pascalSourceFileExtension, Path.Combine(dir, projectName + compiler_string_consts.pascalSourceFileExtension))); currentProject.references.Add(new PascalABCCompiler.ReferenceInfo("System", "System.dll")); if (projectType == PascalABCCompiler.ProjectType.WindowsApp) { @@ -77,7 +79,7 @@ namespace VisualPascalABC currentProject.references.Add(new PascalABCCompiler.ReferenceInfo("System.Xml.Linq", "System.Xml.Linq.dll")); //roman// } - currentProject.main_file = Path.Combine(dir, projectName + ".pas"); + currentProject.main_file = Path.Combine(dir, projectName + compiler_string_consts.pascalSourceFileExtension); currentProject.generate_xml_doc = false; currentProject.delete_exe = true; currentProject.delete_pdb = true; @@ -86,7 +88,7 @@ namespace VisualPascalABC currentProject.build_version = 0; currentProject.revision_version = 0; currentProject.output_directory = dir; - StreamWriter sw = File.CreateText(Path.Combine(dir, projectName + ".pas")); + StreamWriter sw = File.CreateText(Path.Combine(dir, projectName + compiler_string_consts.pascalSourceFileExtension)); currentProject.output_file_name = projectName + ".exe"; if (projectType == PascalABCCompiler.ProjectType.ConsoleApp) { @@ -229,7 +231,7 @@ namespace VisualPascalABC public string GetUnitFileName() { - return "Unit"+uid++ + ".pas"; + return "Unit"+uid++ + compiler_string_consts.pascalSourceFileExtension; } public string GetFullUnitFileName() diff --git a/VisualPascalABCNET/VisualPascalABCNET.csproj b/VisualPascalABCNET/VisualPascalABCNET.csproj index 554fa8abb..7c782f33b 100644 --- a/VisualPascalABCNET/VisualPascalABCNET.csproj +++ b/VisualPascalABCNET/VisualPascalABCNET.csproj @@ -812,6 +812,10 @@ {2DE2842F-0912-4251-BC0F-480854C44A13} Localization + + {a48d9069-d569-4110-9252-a10f139b669b} + LanguageIntegrator + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23} ParserTools diff --git a/VisualPascalABCNET/Workbench/BuildService.cs b/VisualPascalABCNET/Workbench/BuildService.cs index 16c2266b0..26d99b179 100644 --- a/VisualPascalABCNET/Workbench/BuildService.cs +++ b/VisualPascalABCNET/Workbench/BuildService.cs @@ -70,14 +70,19 @@ namespace VisualPascalABC bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate; if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower()) Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false; + if (RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } string ofn = Workbench.VisualEnvironmentCompiler.Compile(CompilerOptions1); Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = savePCU; if (RuntimeServicesModule != null) - CompilerOptions1.RemoveStandardModuleAtIndex(CompilerOptions1.StandardModules.Count - 1); + { + RemoveRuntimeServicesModuleFromStandardModules(); + } if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0) { @@ -112,8 +117,12 @@ namespace VisualPascalABC //string runtimeModuleFileName = CompilerOptions1.SearchDirectory + "\\" + RuntimeServicesModule; //if (RuntimeServicesModule!=null && File.Exists(runtimeModuleFileName)) // CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(runtimeModuleFileName, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain)); + + if (RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } ErrorsList.Clear(); @@ -127,7 +136,9 @@ namespace VisualPascalABC Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = savePCU; if (RuntimeServicesModule != null) - CompilerOptions1.RemoveStandardModuleAtIndex(CompilerOptions1.StandardModules.Count - 1); + { + RemoveRuntimeServicesModuleFromStandardModules(); + } if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0) { @@ -160,8 +171,11 @@ namespace VisualPascalABC //string runtimeModuleFileName = CompilerOptions1.SearchDirectory + "\\" + RuntimeServicesModule; //if (RuntimeServicesModule!=null && File.Exists(runtimeModuleFileName)) // CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(runtimeModuleFileName, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain)); + if (__RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } ErrorsList.Clear(); @@ -196,9 +210,11 @@ namespace VisualPascalABC //string runtimeModuleFileName = CompilerOptions1.SearchDirectory + "\\" + RuntimeServicesModule; //if (RuntimeServicesModule!=null && File.Exists(runtimeModuleFileName)) // CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(runtimeModuleFileName, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain)); - if (__RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + if (__RuntimeServicesModule != null) + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } ErrorsList.Clear(); @@ -213,6 +229,29 @@ namespace VisualPascalABC } + /// + /// Удаляет модуль сервиса времени выполнения из списков стандартных модулей всех языков + /// + private void RemoveRuntimeServicesModuleFromStandardModules() + { + foreach (var kv in CompilerOptions1.StandardModules) + { + CompilerOptions1.RemoveStandardModuleAtIndex(kv.Key, CompilerOptions1.StandardModules[kv.Key].Count - 1); + } + } + + /// + /// Добавляет модуль сервиса времени выполнения в списки стандартных модулей всех языков + /// + private void AddRuntimeServicesModuleToStandardModules(string RuntimeServicesModule) + { + foreach (var kv in CompilerOptions1.StandardModules) + { + kv.Value.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, + PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, kv.Key)); + } + } + public bool Build() { Workbench.OutputWindow.ClearTextBox(); @@ -267,7 +306,9 @@ namespace VisualPascalABC Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = __savePCU; if (__RuntimeServicesModule != null) - CompilerOptions1.RemoveStandardModuleAtIndex(CompilerOptions1.StandardModules.Count - 1); + { + RemoveRuntimeServicesModuleFromStandardModules(); + } if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0) { diff --git a/VisualPascalABCNET/Workbench/FileOperations.cs b/VisualPascalABCNET/Workbench/FileOperations.cs index 2462f4b0d..c4e708de4 100644 --- a/VisualPascalABCNET/Workbench/FileOperations.cs +++ b/VisualPascalABCNET/Workbench/FileOperations.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; using ICSharpCode.FormsDesigner; +using PascalABCCompiler; using VisualPascalABCPlugins; using WeifenLuo.WinFormsUI.Docking; @@ -112,7 +113,7 @@ namespace VisualPascalABC if (!IsNewFile) { if (Path.GetExtension(FileName) == ".pas") - { + { string XMLFile = Path.ChangeExtension(FileName, string_consts.xml_form_extention); if (File.Exists(XMLFile)) { diff --git a/VisualPascalABCNET/Workbench/WindowOperations.cs b/VisualPascalABCNET/Workbench/WindowOperations.cs index a0b68f858..974c15402 100644 --- a/VisualPascalABCNET/Workbench/WindowOperations.cs +++ b/VisualPascalABCNET/Workbench/WindowOperations.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Windows.Forms; using ICSharpCode.FormsDesigner; using ICSharpCode.SharpDevelop.Gui; diff --git a/VisualPascalABCNETLinux/DS/Tools.cs b/VisualPascalABCNETLinux/DS/Tools.cs index 3859d0e89..8721075d0 100644 --- a/VisualPascalABCNETLinux/DS/Tools.cs +++ b/VisualPascalABCNETLinux/DS/Tools.cs @@ -7,6 +7,7 @@ using System.Windows.Forms; using System.IO; using System.Runtime.InteropServices; using Microsoft.Win32; +using PascalABCCompiler; namespace VisualPascalABC { diff --git a/VisualPascalABCNETLinux/DS/VisualEnvironmentCompiler.cs b/VisualPascalABCNETLinux/DS/VisualEnvironmentCompiler.cs index b76263f8b..50b4b1ff2 100644 --- a/VisualPascalABCNETLinux/DS/VisualEnvironmentCompiler.cs +++ b/VisualPascalABCNETLinux/DS/VisualEnvironmentCompiler.cs @@ -2,14 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using VisualPascalABCPlugins; -using System.Threading; namespace VisualPascalABC { @@ -75,7 +71,7 @@ namespace VisualPascalABC { this.StandartDirectories = StandartDirectories; this.ErrorsManager = ErrorsManager; - this.ChangeVisualEnvironmentState += new ChangeVisualEnvironmentStateDelegate(onChangeVisualEnvironmentState); + this.ChangeVisualEnvironmentState += onChangeVisualEnvironmentState; SetCompilingButtonsEnabled = setCompilingButtonsEnabled; SetDebugButtonsEnabled = setCompilingDebugEnabled; SetStateText = setStateText; @@ -85,17 +81,20 @@ namespace VisualPascalABC this.ExecuteVECAction = ExecuteVECAction; PluginsMenuItem = pluginsMenuItem; PluginsToolStrip = pluginsToolStrip; - PluginsController = new VisualPascalABCPlugins.PluginsController(this, PluginsMenuItem, PluginsToolStrip, workbench); + PluginsController = new PluginsController(this, PluginsMenuItem, PluginsToolStrip, workbench); this.RunnerManager = RunnerManager; this.DebugHelper = DebugHelper; - DebugHelper.Starting += new DebugHelper.DebugHelperActionDelegate(DebugHelper_Starting); - DebugHelper.Exited += new DebugHelper.DebugHelperActionDelegate(DebugHelper_Exited); - RunnerManager.Starting += new RunnerManagerActionDelegate(RunnerManager_Starting); - RunnerManager.Exited += new RunnerManagerActionDelegate(RunnerManager_Exited); + DebugHelper.Starting += DebugHelper_Starting; + DebugHelper.Exited += DebugHelper_Exited; + RunnerManager.Starting += RunnerManager_Starting; + RunnerManager.Exited += RunnerManager_Exited; this.CodeCompletionParserController = WorkbenchServiceFactory.CodeCompletionParserController; this.CodeCompletionParserController.visualEnvironmentCompiler = this; this.UserOptions = UserOptions; this.OpenDocuments = OpenDocuments; + + PascalABCCompiler.Parsers.Controller.Instance.ParserConnected += OnParserConnected; + PascalABCCompiler.Parsers.Controller.Instance.ParserLoadErrorOccured += OnParserLoadErrorOccured; } void RunnerManager_Exited(string fileName) @@ -316,6 +315,25 @@ namespace VisualPascalABC AddTextToCompilerMessages(VECStringResources.Get("REMOTE_COMPILER_PREFIX") + text); } List ParsedFiles = new List(); + + /// + /// Выводит сообщения о подключенных парсерах + /// + private void OnParserConnected(PascalABCCompiler.Parsers.IParser parser) + { + string parserConnectedMessage = string.Format(VECStringResources.Get("PARSER_CONNECTED{0}{1}"), parser, Path.GetFileName(parser.GetType().Assembly.Location)); + parserConnectedMessage += Environment.NewLine; + AddTextToCompilerMessages(parserConnectedMessage); + } + + /// + /// Выводит сообщения об ошибках, возникших при загрузке парсеров + /// + private void OnParserLoadErrorOccured(string errorMessage) + { + AddTextToCompilerMessages(errorMessage); + } + private void OnChangeCompilerStateEx(PascalABCCompiler.ICompiler sender, PascalABCCompiler.CompilerState State, string FullFileName) { @@ -344,14 +362,6 @@ namespace VisualPascalABC case PascalABCCompiler.CompilerState.SemanticTreeConverterConnected: RusName = VECStringResources.Get("STATE_SEMANTICTREECONVERTERCONNECTED{0}"); break; case PascalABCCompiler.CompilerState.SyntaxTreeConversion: RusName = VECStringResources.Get("STATE_SYNTAXTREECONVERSION{0}"); break; case PascalABCCompiler.CompilerState.SyntaxTreeConverterConnected: RusName = VECStringResources.Get("STATE_SYNTAXTREECONVERTERCONNECTED{0}"); break; - case PascalABCCompiler.CompilerState.ParserConnected: - FileName = Path.GetFileName(FileName); - if(sender.CompilerType== PascalABCCompiler.CompilerType.Standart) - RusName = string.Format(VECStringResources.Get("PARSER_CONNECTED{0}{1}"), sender.ParsersController.LastParser, FileName); - else - RusName = string.Format(VECStringResources.Get("PARSER_CONNECTED{0}"), FileName); - FileName = null; - break; case PascalABCCompiler.CompilerState.Ready: RusName = VECStringResources.Get("STATE_READY"); if (!StartingCompleted) diff --git a/VisualPascalABCNETLinux/Form1.cs b/VisualPascalABCNETLinux/Form1.cs index 4859a9a56..ecafaf5ab 100644 --- a/VisualPascalABCNETLinux/Form1.cs +++ b/VisualPascalABCNETLinux/Form1.cs @@ -4,19 +4,14 @@ using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Text; using System.Windows.Forms; using System.IO; using VisualPascalABCPlugins; -using VisualPascalABC.Utils; using System.Threading; using System.Runtime.InteropServices; -using WeifenLuo.WinFormsUI.Docking; using VisualPascalABC.OptionsContent; using System.Security.Permissions; -using System.ComponentModel.Design; //using ICSharpCode.FormsDesigner; //using ICSharpCode.SharpDevelop.Gui; @@ -681,11 +676,12 @@ namespace VisualPascalABC { MPanel_Resize(null, EventArgs.Empty); BPanel_Resize(null, EventArgs.Empty); - //MPanel_.OnResize(EventArgs.Empty); - //BPanel.OnResize(EventArgs.Empty); + if (_mainFormWindowStateMaximized) this.WindowState = FormWindowState.Maximized; - //PascalABCCompiler.StringResourcesLanguage.CurrentLanguageName = "Russi + + // загрузка всех парсеров и других составляющих языков EVA + LanguageIntegration.LanguageIntegrator.LoadAllLanguages(); ChangedSelectedTab(); VisualEnvironmentCompiler.ChangeVisualEnvironmentState += new ChangeVisualEnvironmentStateDelegate(VisualEnvironmentCompiler_ChangeVisualEnvironmentState); @@ -1762,7 +1758,6 @@ namespace VisualPascalABC var aw = ABCHealthForm.Width; var ah = ABCHealthForm.Height; var c = new PascalABCCompiler.Compiler(); - c.Reload(); var errors = new List(); var warnings = new List(); diff --git a/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs b/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs index e9a73322d..b2aee87b1 100644 --- a/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs +++ b/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs @@ -488,7 +488,7 @@ namespace VisualPascalABC this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.ExeFileName = fileName; CurrentLine = 0; - this.parser = CodeCompletion.CodeCompletionController.ParsersController.selectParser(Path.GetExtension(FullFileName).ToLower()); + this.parser = CodeCompletion.CodeCompletionController.ParsersController.SelectParser(Path.GetExtension(FullFileName).ToLower()); this.PrevFullFileName = FullFileName; AssemblyHelper.LoadAssembly(fileName); //dbg.ProcessStarted += debugProcessStarted; @@ -512,7 +512,7 @@ namespace VisualPascalABC this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.ExeFileName = fileName; CurrentLine = 0; - this.parser = CodeCompletion.CodeCompletionController.ParsersController.selectParser(Path.GetExtension(FullFileName).ToLower()); + this.parser = CodeCompletion.CodeCompletionController.ParsersController.SelectParser(Path.GetExtension(FullFileName).ToLower()); this.PrevFullFileName = FullFileName; AssemblyHelper.LoadAssembly(fileName); diff --git a/VisualPascalABCNETLinux/Projects/ProjectExplorer.cs b/VisualPascalABCNETLinux/Projects/ProjectExplorer.cs index 110c5f091..9006cc23e 100644 --- a/VisualPascalABCNETLinux/Projects/ProjectExplorer.cs +++ b/VisualPascalABCNETLinux/Projects/ProjectExplorer.cs @@ -7,6 +7,7 @@ using System.IO; using System.Drawing; using System.Windows.Forms; using Microsoft.Build.BuildEngine; +using PascalABCCompiler; namespace VisualPascalABC { diff --git a/VisualPascalABCNETLinux/Projects/ProjectHelper.cs b/VisualPascalABCNETLinux/Projects/ProjectHelper.cs index 6791cd618..65a565af9 100644 --- a/VisualPascalABCNETLinux/Projects/ProjectHelper.cs +++ b/VisualPascalABCNETLinux/Projects/ProjectHelper.cs @@ -7,6 +7,7 @@ using System.Drawing; using System.Windows.Forms; using System.IO; using System.Text; +using PascalABCCompiler; namespace VisualPascalABC { diff --git a/VisualPascalABCNETLinux/VisualPascalABCNETLinux.csproj b/VisualPascalABCNETLinux/VisualPascalABCNETLinux.csproj index 66c128e41..14cc59fe8 100644 --- a/VisualPascalABCNETLinux/VisualPascalABCNETLinux.csproj +++ b/VisualPascalABCNETLinux/VisualPascalABCNETLinux.csproj @@ -930,6 +930,10 @@ {2DE2842F-0912-4251-BC0F-480854C44A13} Localization + + {a48d9069-d569-4110-9252-a10f139b669b} + LanguageIntegrator + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23} ParserTools diff --git a/VisualPascalABCNETLinux/Workbench/BuildService.cs b/VisualPascalABCNETLinux/Workbench/BuildService.cs index 904ef87da..f1d09c553 100644 --- a/VisualPascalABCNETLinux/Workbench/BuildService.cs +++ b/VisualPascalABCNETLinux/Workbench/BuildService.cs @@ -68,14 +68,19 @@ namespace VisualPascalABC bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate; if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower()) Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false; + if (RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } string ofn = Workbench.VisualEnvironmentCompiler.Compile(CompilerOptions1); Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = savePCU; if (RuntimeServicesModule != null) - CompilerOptions1.RemoveStandardModuleAtIndex(CompilerOptions1.StandardModules.Count - 1); + { + RemoveRuntimeServicesModuleFromStandardModules(); + } if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0) { @@ -89,6 +94,8 @@ namespace VisualPascalABC return ofn; } + + public string Compile(string FileName, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment) { Workbench.WidgetController.CompilingButtonsEnabled = false; @@ -110,8 +117,11 @@ namespace VisualPascalABC //string runtimeModuleFileName = CompilerOptions1.SearchDirectory + "\\" + RuntimeServicesModule; //if (RuntimeServicesModule!=null && File.Exists(runtimeModuleFileName)) // CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(runtimeModuleFileName, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain)); + if (RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } ErrorsList.Clear(); @@ -126,7 +136,9 @@ namespace VisualPascalABC Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = savePCU; if (RuntimeServicesModule != null) - CompilerOptions1.RemoveStandardModuleAtIndex(CompilerOptions1.StandardModules.Count - 1); + { + RemoveRuntimeServicesModuleFromStandardModules(); + } //MessageBox.Show(Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count.ToString()); if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0) @@ -161,8 +173,11 @@ namespace VisualPascalABC //string runtimeModuleFileName = CompilerOptions1.SearchDirectory + "\\" + RuntimeServicesModule; //if (RuntimeServicesModule!=null && File.Exists(runtimeModuleFileName)) // CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(runtimeModuleFileName, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain)); + if (__RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } ErrorsList.Clear(); @@ -197,8 +212,11 @@ namespace VisualPascalABC //string runtimeModuleFileName = CompilerOptions1.SearchDirectory + "\\" + RuntimeServicesModule; //if (RuntimeServicesModule!=null && File.Exists(runtimeModuleFileName)) // CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(runtimeModuleFileName, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain)); + if (__RuntimeServicesModule != null) - CompilerOptions1.StandardModules.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage)); + { + AddRuntimeServicesModuleToStandardModules(RuntimeServicesModule); + } ErrorsList.Clear(); @@ -214,6 +232,29 @@ namespace VisualPascalABC } + /// + /// Удаляет модуль сервиса времени выполнения из списков стандартных модулей всех языков + /// + private void RemoveRuntimeServicesModuleFromStandardModules() + { + foreach (var kv in CompilerOptions1.StandardModules) + { + CompilerOptions1.RemoveStandardModuleAtIndex(kv.Key, CompilerOptions1.StandardModules[kv.Key].Count - 1); + } + } + + /// + /// Добавляет модуль сервиса времени выполнения в списки стандартных модулей всех языков + /// + private void AddRuntimeServicesModuleToStandardModules(string RuntimeServicesModule) + { + foreach (var kv in CompilerOptions1.StandardModules) + { + kv.Value.Add(new PascalABCCompiler.CompilerOptions.StandardModule(RuntimeServicesModule, + PascalABCCompiler.CompilerOptions.StandardModuleAddMethod.RightToMain, kv.Key)); + } + } + public bool Build() { Workbench.OutputWindow.ClearTextBox(); @@ -268,7 +309,9 @@ namespace VisualPascalABC Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = __savePCU; if (__RuntimeServicesModule != null) - CompilerOptions1.RemoveStandardModuleAtIndex(CompilerOptions1.StandardModules.Count - 1); + { + RemoveRuntimeServicesModuleFromStandardModules(); + } if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0) { diff --git a/VisualPascalABCNETLinux/Workbench/FileOperations.cs b/VisualPascalABCNETLinux/Workbench/FileOperations.cs index 4a14a3061..2d606b7da 100644 --- a/VisualPascalABCNETLinux/Workbench/FileOperations.cs +++ b/VisualPascalABCNETLinux/Workbench/FileOperations.cs @@ -10,6 +10,7 @@ using System.Drawing; //using ICSharpCode.FormsDesigner; using VisualPascalABCPlugins; using WeifenLuo.WinFormsUI.Docking; +using PascalABCCompiler; namespace VisualPascalABC { diff --git a/VisualPascalABCNETLinux/Workbench/WindowOperations.cs b/VisualPascalABCNETLinux/Workbench/WindowOperations.cs index bc6738f09..b62ebaa0f 100644 --- a/VisualPascalABCNETLinux/Workbench/WindowOperations.cs +++ b/VisualPascalABCNETLinux/Workbench/WindowOperations.cs @@ -9,6 +9,7 @@ using System.Windows.Forms; //using ICSharpCode.FormsDesigner; //using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.TextEditor; +using PascalABCCompiler; using VisualPascalABC.OptionsContent; using VisualPascalABCPlugins; using WeifenLuo.WinFormsUI.Docking; diff --git a/VisualPlugins/SyntaxTreeVisualisator/SyntaxTreeVisualisatorForm.cs b/VisualPlugins/SyntaxTreeVisualisator/SyntaxTreeVisualisatorForm.cs index 27546724b..e412bcdc7 100644 --- a/VisualPlugins/SyntaxTreeVisualisator/SyntaxTreeVisualisatorForm.cs +++ b/VisualPlugins/SyntaxTreeVisualisator/SyntaxTreeVisualisatorForm.cs @@ -223,7 +223,7 @@ namespace VisualPascalABCPlugins string FileText = (string)VisualEnvironmentCompiler.Compiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText); List Errors = new List(); List Warnings = new List(); - PascalABCCompiler.SyntaxTree.syntax_tree_node sn = VisualEnvironmentCompiler.StandartCompiler.ParsersController.Compile(FileName+"part_", FileText, Errors, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal); + PascalABCCompiler.SyntaxTree.syntax_tree_node sn = VisualEnvironmentCompiler.StandartCompiler.ParsersController.SelectParserForUnitAndBuildTree(FileName+"part_", FileText, Errors, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal); if (Errors.Count > 0) StatusLabel.Text = Errors.Count + " errors"; syntaxTreeSelectComboBox.Items.Clear(); @@ -238,7 +238,7 @@ namespace VisualPascalABCPlugins { string FileName = (string)VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetCurrentSourceFileName, null); string FileText = (string)VisualEnvironmentCompiler.StandartCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText); - return VisualEnvironmentCompiler.StandartCompiler.ParsersController.Compile(FileName + fileNamePosfix, FileText, Errors, new List(), PascalABCCompiler.Parsers.ParseMode.Normal); + return VisualEnvironmentCompiler.StandartCompiler.ParsersController.SelectParserForUnitAndBuildTree(FileName + fileNamePosfix, FileText, Errors, new List(), PascalABCCompiler.Parsers.ParseMode.Normal); } private void toolStripButton1_Click_1(object sender, EventArgs e) diff --git a/bin/LanguageKits/.gitkeep b/bin/LanguageKits/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/bin/Lng/Eng/ParserErrors.dat b/bin/Lng/Eng/ParserErrors.dat index b607a2d61..74c03ebaa 100644 --- a/bin/Lng/Eng/ParserErrors.dat +++ b/bin/Lng/Eng/ParserErrors.dat @@ -8,5 +8,6 @@ UNEXPECTED_SYMBOL{0}=Unexpected symbol '{0}' BAD_EXPR=Bad exprssion EXPECTED{0}={0} expected BIG_CHAR_NUMBER=Too big char const +LOAD_ERROR{0}=Parser {0} loading error BAD_SOURCEFILE{0}_EXT=Can not choose parser for file '{0}' COMPILATION_ERROR{0}{1}{2}={0}{1} Compilation error: {2} diff --git a/bin/Lng/Rus/ParserErrors.dat b/bin/Lng/Rus/ParserErrors.dat index 86f2f5627..3fd792430 100644 --- a/bin/Lng/Rus/ParserErrors.dat +++ b/bin/Lng/Rus/ParserErrors.dat @@ -9,5 +9,6 @@ UNEXPECTED_SYMBOL{0}=Неожиданный символ '{0}' BAD_EXPR=Неверное выражение EXPECTED{0}=Ожидалось {0} BIG_CHAR_NUMBER=Слишком большая константа +LOAD_ERROR{0}=Ошибка загрузки парсера {0} BAD_SOURCEFILE{0}_EXT=Не могу выбрать подходящий парсер для файла '{0}' COMPILATION_ERROR{0}{1}{2}={0}{1} Ошибка компиляции: {2} \ No newline at end of file diff --git a/bin/Lng/Ukr/ParserErrors.dat b/bin/Lng/Ukr/ParserErrors.dat index baf2a4937..fb8e7d632 100644 --- a/bin/Lng/Ukr/ParserErrors.dat +++ b/bin/Lng/Ukr/ParserErrors.dat @@ -8,5 +8,6 @@ UNEXPECTED_SYMBOL{0}=Несподіваний символ '{0}' BAD_EXPR=Неправильний вираз EXPECTED{0}=Очікувалося {0} BIG_CHAR_NUMBER=Занадто велика константа +LOAD_ERROR{0}=Помилка завантаження парсера {0} BAD_SOURCEFILE{0}_EXT=Не можу вибрати відповідний парсер для файлу '{0}' COMPILATION_ERROR{0}{1}{2}={0}{1} Помилка компіляції: {2} \ No newline at end of file diff --git a/bin/Lng/zh_CN/ParserErrors.dat b/bin/Lng/zh_CN/ParserErrors.dat index 0f036f12c..b06599018 100644 --- a/bin/Lng/zh_CN/ParserErrors.dat +++ b/bin/Lng/zh_CN/ParserErrors.dat @@ -8,5 +8,6 @@ UNEXPECTED_SYMBOL{0}=意外的符号 '{0}' BAD_EXPR=错误的表达式 EXPECTED{0}={0} 预期 BIG_CHAR_NUMBER=字符常量太大 +LOAD_ERROR{0}=解析器加载错误 {0} BAD_SOURCEFILE{0}_EXT=无法为文件 '{0}' 选择解析器 COMPILATION_ERROR{0}{1}{2}={0}{1} 编译错误: {2} diff --git a/bin/TestRunner.exe b/bin/TestRunner.exe index 5d67c1da9bd4b598e7e9f6e8bfdc5df490c9c6bf..67511df1661fbeb87c16d1ab456a8e5c3b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s_~Oy*xh!&J<)!@J>5RoZs1LT9dC&ocw^wiKO?zN-So$nkn357KRZ!};r!hnB5WXS zCjE_jA9|YHcqq{?w6i~!{6h5zp(7$hg>m&~YYwxm_3u7CGgyc>QsPyDesN!dza^ls z{-H&=eFUFlYw^AY;Jo!|=WD%ZVTAo66xzRIW9;AJ+u-A|QOmwXud|k_CG}cMO6?C` zZ_(5zDhexS%$Pc-&(wKSF+S$io$h{f2SI-r4`W~^K8bi7t>Ji8eH@-Z3!gRNL(zfw z408lNoh*WfF;ap5Y*7i5>!)qW@?#0dj&L{mIvQ2oUW!IKM&7;S17739| zi)GALbFt;l9mABuwtoV_DdV3paDIJ1%2Bl|SYA8GrFk9ezP#*gDR-*H$>yu)Z` rl}yHe*EnJ|!jA#Mj;)Ie@#G`*U%YkPen|eyNdA2-zPB&2x@7I2xeX{| diff --git a/bin/TestRunner.pas b/bin/TestRunner.pas index b2995afef..b398b299b 100644 --- a/bin/TestRunner.pas +++ b/bin/TestRunner.pas @@ -6,6 +6,7 @@ {$reference CompilerTools.dll} {$reference Localization.dll} {$reference System.Windows.Forms.dll} +{$reference ParserTools.dll} uses PascalABCCompiler, System.IO, System.Diagnostics; @@ -403,6 +404,8 @@ end; begin //DeletePABCSystemPCU; try + PascalABCCompiler.Parsers.Controller.Instance.LoadStandardParsers(); + TestSuiteDir := GetTestSuiteDir; System.Environment.CurrentDirectory := Path.GetDirectoryName(GetEXEFileName()); if (ParamCount = 2) and (ParamStr(2) = '1') then diff --git a/pabcnetc/CommandConsoleCompiler.cs b/pabcnetc/CommandConsoleCompiler.cs index 550940aca..17989c58d 100644 --- a/pabcnetc/CommandConsoleCompiler.cs +++ b/pabcnetc/CommandConsoleCompiler.cs @@ -267,13 +267,14 @@ namespace PascalABCCompiler sendWorkingSet(); break; case ConsoleCompilerConstants.CompilerOptionsClearStandartModules: - compiler.CompilerOptions.StandardModules.Clear(); + foreach (var modulesList in compiler.CompilerOptions.StandardModules.Values) + modulesList.Clear(); break; case ConsoleCompilerConstants.CompilerOptionsStandartModule: CompilerOptions.StandardModule sm = new CompilerOptions.StandardModule(args[0], (CompilerOptions.StandardModuleAddMethod)Convert.ToInt32(args[1]), - (PascalABCCompiler.SyntaxTree.LanguageId)Convert.ToInt32(args[2])); - compiler.CompilerOptions.StandardModules.Add(sm); + args[2]); + compiler.CompilerOptions.StandardModules[sm.languageToAdd].Add(sm); break; case ConsoleCompilerConstants.InternalDebug: compiler.InternalDebug = (CompilerInternalDebug)ReadObject(); @@ -301,7 +302,12 @@ namespace PascalABCCompiler { Console.OutputEncoding = System.Text.Encoding.UTF8; Console.InputEncoding = System.Text.Encoding.UTF8; + + // загрузка всех парсеров и других составляющих языков EVA + LanguageIntegration.LanguageIntegrator.LoadAllLanguages(); + LoadCompiler(); + do { string line = Console.ReadLine(); diff --git a/pabcnetc/ConsoleCompiler.cs b/pabcnetc/ConsoleCompiler.cs index 4272707f1..3a0f32979 100644 --- a/pabcnetc/ConsoleCompiler.cs +++ b/pabcnetc/ConsoleCompiler.cs @@ -333,12 +333,6 @@ namespace PascalABCCompiler } private static void ChangeCompilerState(ICompiler sender, PascalABCCompiler.CompilerState State, string FileName) { - switch (State) - { - case CompilerState.ParserConnected: - Console.WriteLine(string.Format(StringResourcesGet("CONNECTED_PARSER{0}"),sender.ParsersController.LastParser)); - return; - } if (DetailOut) { Console.ForegroundColor = ConsoleColor.Gray; @@ -444,6 +438,10 @@ namespace PascalABCCompiler OutputDirectory=""; Console.Title = StringResourcesGet("STARTING"); + + // загрузка всех парсеров и других составляющих языков EVA + LanguageIntegration.LanguageIntegrator.LoadAllLanguages(); + Reset(); Console.Title = Compiler.Banner; diff --git a/pabcnetc/PABCNETC.csproj b/pabcnetc/PABCNETC.csproj index da40be07e..1fcc8d674 100644 --- a/pabcnetc/PABCNETC.csproj +++ b/pabcnetc/PABCNETC.csproj @@ -121,6 +121,10 @@ {2DE2842F-0912-4251-BC0F-480854C44A13} Localization + + {a48d9069-d569-4110-9252-a10f139b669b} + LanguageIntegrator + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23} ParserTools diff --git a/pabcnetc_clear/CommandConsoleCompiler.cs b/pabcnetc_clear/CommandConsoleCompiler.cs index 325ffd587..3f1e6eb6a 100644 --- a/pabcnetc_clear/CommandConsoleCompiler.cs +++ b/pabcnetc_clear/CommandConsoleCompiler.cs @@ -245,13 +245,14 @@ namespace PascalABCCompiler sendWorkingSet(); break; case ConsoleCompilerConstants.CompilerOptionsClearStandartModules: - compiler.CompilerOptions.StandardModules.Clear(); + foreach (var modulesList in compiler.CompilerOptions.StandardModules.Values) + modulesList.Clear(); break; case ConsoleCompilerConstants.CompilerOptionsStandartModule: CompilerOptions.StandardModule sm = new CompilerOptions.StandardModule(args[0], (CompilerOptions.StandardModuleAddMethod)Convert.ToInt32(args[1]), - (PascalABCCompiler.SyntaxTree.LanguageId)Convert.ToInt32(args[2])); - compiler.CompilerOptions.StandardModules.Add(sm); + args[2]); + compiler.CompilerOptions.StandardModules[sm.languageToAdd].Add(sm); break; case ConsoleCompilerConstants.InternalDebug: compiler.InternalDebug = (CompilerInternalDebug)ReadObject(); @@ -267,6 +268,10 @@ namespace PascalABCCompiler { Console.OutputEncoding = System.Text.Encoding.UTF8; Console.InputEncoding = System.Text.Encoding.UTF8; + + // çàãðóçêà âñåõ ïàðñåðîâ è äðóãèõ ñîñòàâëÿþùèõ ÿçûêîâ EVA + LanguageIntegration.LanguageIntegrator.LoadAllLanguages(); + LoadCompiler(); do { diff --git a/pabcnetc_clear/ConsoleCompiler.cs b/pabcnetc_clear/ConsoleCompiler.cs index 97960f77d..a503e14f3 100644 --- a/pabcnetc_clear/ConsoleCompiler.cs +++ b/pabcnetc_clear/ConsoleCompiler.cs @@ -4,7 +4,6 @@ using System; using PascalABCCompiler.Errors; using System.IO; using System.Linq; -using System.Collections.Generic; using System.Globalization; namespace PascalABCCompiler @@ -153,6 +152,9 @@ namespace PascalABCCompiler DateTime ldt = DateTime.Now; PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig(); + // загрузка всех парсеров и других составляющих языков EVA + LanguageIntegration.LanguageIntegrator.LoadAllLanguages(); + Compiler = new PascalABCCompiler.Compiler(null, null); Compiler.InternalDebug.SkipPCUErrors = false; CultureInfo ci = CultureInfo.InstalledUICulture; diff --git a/pabcnetc_clear/PABCNETCclear.csproj b/pabcnetc_clear/PABCNETCclear.csproj index efd700169..15d4b5345 100644 --- a/pabcnetc_clear/PABCNETCclear.csproj +++ b/pabcnetc_clear/PABCNETCclear.csproj @@ -153,6 +153,10 @@ {1e42361a-eda3-4872-88af-a3aaf600d36d} Compiler + + {a48d9069-d569-4110-9252-a10f139b669b} + LanguageIntegrator +