Implement programming languages integration functionality (#3001)
* 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: commit8f9dc7e5a0Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Mon Mar 11 20:33:13 2024 +0300 fix #3050 commit90363ced45Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sun Mar 3 21:37:25 2024 +0300 Недобитки при сортировке строк commitc9d7ba7758Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Mar 2 13:32:14 2024 +0300 Order и OrderDescending для строк с Ordinal commit6fbc0200bfAuthor: 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 commite4d63bfef9Author: bormant <bormant@mail.ru> Date: Tue Feb 27 23:18:25 2024 +0300 Fix typo: C (ru) -> C (en) (#3042) commit0d37232d21Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Feb 27 19:15:08 2024 +0300 School - исправление пустого диапазона простых и IP-адресов commit9fd4c7f338Merge:3cca2a896027083bAuthor: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Feb 21 20:57:10 2024 +0100 Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet commit3cca2a8949Author: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Feb 21 20:56:49 2024 +0100 fix in formatter
This commit is contained in:
parent
8f9dc7e5a0
commit
0ae7595f0d
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -45,6 +45,7 @@
|
|||
**/NETGenerator.dll
|
||||
**/OptimizerConversion.dll
|
||||
**/PABCRtl.dll
|
||||
**/LanguageIntegrator.dll
|
||||
**/ParserTools.dll
|
||||
**/PascalABCParser.dll
|
||||
**/PluginsSupport.dll
|
||||
|
|
|
|||
|
|
@ -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<PascalABCCompiler.SyntaxTree.syntax_tree_node, string> docs = new Dictionary<PascalABCCompiler.SyntaxTree.syntax_tree_node, string>();
|
||||
|
|
@ -78,10 +78,10 @@ namespace CodeCompletion
|
|||
internal compilation_unit ParsersControllerGetCompilationUnit(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> 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<PascalABCCompiler.Errors.Error>());
|
||||
return cu;
|
||||
}
|
||||
|
|
@ -89,10 +89,10 @@ namespace CodeCompletion
|
|||
internal compilation_unit ParsersControllerGetCompilationUnitSpecial(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> 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<PascalABCCompiler.Errors.Error>());
|
||||
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<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
||||
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,10 @@
|
|||
<Project>{44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}</Project>
|
||||
<Name>Errors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ParserTools\ParserTools.csproj">
|
||||
<Project>{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<expression> { _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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2041,7 +2041,7 @@ namespace CodeCompletion
|
|||
|
||||
method_call mc = new method_call();
|
||||
mc.parameters = new expression_list(new List<expression> { _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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -413,15 +413,18 @@ namespace PascalABCCompiler
|
|||
/// поле для проверки на циклическую зависимость интерфейсов модулей
|
||||
/// </summary>
|
||||
public string currentUsedUnitId;
|
||||
public PascalABCCompiler.Errors.SyntaxError syntax_error;
|
||||
public SyntaxError syntax_error;
|
||||
public string UnitFileName;
|
||||
public List<Errors.Error> ErrorList = new List<Errors.Error>();
|
||||
public List<Error> ErrorList = new List<Error>();
|
||||
public bool Documented;
|
||||
internal List<SyntaxTree.unit_or_namespace> possibleNamespaces = new List<PascalABCCompiler.SyntaxTree.unit_or_namespace>();
|
||||
//internal List<CompilationUnit> AssemblyReferences = new List<CompilationUnit>();
|
||||
|
||||
//private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList();
|
||||
|
||||
// название языка модуля
|
||||
public string languageName = TreeConverter.compiler_string_consts.pascalLanguageName;
|
||||
|
||||
/// <summary>
|
||||
/// Только "реальные" юниты (не dll и namespace)
|
||||
/// </summary>
|
||||
|
|
@ -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<string, List<StandardModule>> standardModules = new Dictionary<string, List<StandardModule>>();
|
||||
|
||||
/// <summary>
|
||||
/// Списки стандартных модулей для поддерживаемых языков (первым в списке должен быть модуль "System")
|
||||
/// </summary>
|
||||
public Dictionary<string, List<StandardModule>> StandardModules
|
||||
{
|
||||
get
|
||||
{
|
||||
if (standardModules.Count == 0)
|
||||
LoadStandardModules();
|
||||
return standardModules;
|
||||
}
|
||||
set
|
||||
{
|
||||
standardModules = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// module at index 0 is System module
|
||||
/// Заполняет словарь стандартных модулей для всех поддерживаемых языков
|
||||
/// </summary>
|
||||
public List<StandardModule> 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<StandardModule>();
|
||||
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<string, CompilationUnit> DLLCache = new Dictionary<string, CompilationUnit>();
|
||||
|
||||
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<SyntaxTree.unit_or_namespace> 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<Error> errorList, List<CompilerWarning> warnings, List<string> 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
|
|||
/// генерация синтаксического дерева,
|
||||
/// обработка синтаксических ошибок
|
||||
/// </summary>
|
||||
private void InitializeNewUnit(SyntaxTree.unit_or_namespace currentUnitNode, string UnitFileName, string UnitId, ref CompilationUnit currentUnit, ref Dictionary<SyntaxTree.syntax_tree_node, string> docs)
|
||||
private void InitializeNewUnit(SyntaxTree.unit_or_namespace currentUnitNode, string unitFileName, string UnitId, ref CompilationUnit currentUnit, ref Dictionary<SyntaxTree.syntax_tree_node, string> 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<Error> errors = new List<Error>();
|
||||
|
||||
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<CompilerWarning>(), 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,9 +183,6 @@
|
|||
<Compile Include="..\Configuration\GlobalAssemblyInfo.cs">
|
||||
<Link>Config\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="string_constants.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SyntaxTreeConvertersController\SyntaxTreeConvertersController.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -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 - части
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
87
LanguageIntegrator/LanguageIntegrator.cs
Normal file
87
LanguageIntegrator/LanguageIntegrator.cs
Normal file
|
|
@ -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";
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает директорию, содержащую комплекты языков
|
||||
/// </summary>
|
||||
private static DirectoryInfo GetLanguageKitsDirectory()
|
||||
{
|
||||
string binDirectoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string languageKitsDirectoryPath = Path.Combine(binDirectoryPath, languageKitsDirectoryName);
|
||||
|
||||
return new DirectoryInfo(languageKitsDirectoryPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загружает все языковые комплекты для использования
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загружает все языки, доступные в системе
|
||||
/// </summary>
|
||||
public static void LoadAllLanguages()
|
||||
{
|
||||
ParsersController.LoadStandardParsers();
|
||||
|
||||
LoadAllLanguageKits();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезагружает парсеры всех языков
|
||||
/// </summary>
|
||||
public static void ReloadAllParsers()
|
||||
{
|
||||
ParsersController.Parsers.Clear();
|
||||
ParsersController.LoadStandardParsers();
|
||||
LoadParsersFromLanguageKits();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загружает все парсеры из языковых комплектов
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
53
LanguageIntegrator/LanguageIntegrator.csproj
Normal file
53
LanguageIntegrator/LanguageIntegrator.csproj
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A48D9069-D569-4110-9252-A10F139B669B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LanguageIntegration</RootNamespace>
|
||||
<AssemblyName>LanguageIntegrator</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LanguageIntegrator.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ParserTools\ParserTools.csproj">
|
||||
<Project>{af2efd7b-69dd-4b43-af65-b59b29349c23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
37
LanguageIntegrator/Properties/AssemblyInfo.cs
Normal file
37
LanguageIntegrator/Properties/AssemblyInfo.cs
Normal file
|
|
@ -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")]
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<Controller> lazyInstanceWrapper = new Lazy<Controller>(() => 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<IParser> ParserConnected;
|
||||
public event Action<string> ParserLoadErrorOccured;
|
||||
|
||||
public List<IParser> Parsers = new List<IParser>();
|
||||
|
||||
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)
|
||||
|
||||
/// <summary>
|
||||
/// Загружает стандартные парсеры из папки бин (в частности PascalABCParser.dll)
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загружает все парсеры языков из переданной сборки, используя рефлексию
|
||||
/// </summary>
|
||||
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 += "<Loader exceptions>:" + 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)
|
||||
|
||||
/// <summary>
|
||||
/// Добавляет парсер в общий список парсеров (с вызовом инициализации парсера)
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает подходящий для переданного расширения парсер из имеющихся
|
||||
/// </summary>
|
||||
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<Error> Errors, List<CompilerWarning> Warnings, ParseMode ParseMode, List<string> DefinesList = null)
|
||||
|
||||
/// <summary>
|
||||
/// Строит синтаксическое дерево с автоматическим выбором подходящего парсера
|
||||
/// </summary>
|
||||
/// <exception cref="ParserBadFileExtension"></exception>
|
||||
public SyntaxTree.syntax_tree_node SelectParserForUnitAndBuildTree(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode ParseMode, List<string> 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<Error> Errors, List<CompilerWarning> 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<Error> Errors, List<CompilerWarning> Warnings, List<string> 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"));
|
||||
/// <summary>
|
||||
/// Возвращеает синтаксическое дерево модуля
|
||||
/// </summary>
|
||||
public SyntaxTree.compilation_unit GetCompilationUnit(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode parseMode, List<string> DefinesList = null)
|
||||
{
|
||||
return GetSyntaxTree<SyntaxTree.compilation_unit>(FileName, Text, Errors, Warnings, parseMode, DefinesList);
|
||||
}
|
||||
|
||||
public SyntaxTree.compilation_unit GetCompilationUnitForFormatter(string FileName, string Text, List<Error> Errors, List<CompilerWarning> 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<SyntaxTree.compilation_unit>(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<Error> Errors, List<CompilerWarning> 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<SyntaxTree.expression>(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<Error> Errors, List<CompilerWarning> 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<SyntaxTree.expression> (FileName, Text, Errors, Warnings, ParseMode.TypeAsExpression);
|
||||
}
|
||||
|
||||
public SyntaxTree.statement GetStatement(string FileName, string Text, List<Error> Errors, List<CompilerWarning> 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<SyntaxTree.statement>(FileName, Text, Errors, Warnings, ParseMode.Statement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обобщенная функция для получения различных синтаксических узлов
|
||||
/// </summary>
|
||||
private T GetSyntaxTree<T>(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode parseMode, List<string> 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()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" })
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ Section
|
|||
${AddDirectory} "$INSTDIR\PT4"
|
||||
${AddDirectory} "$INSTDIR\Ico"
|
||||
${AddDirectory} "$INSTDIR\Doc"
|
||||
${AddDirectory} "$INSTDIR\LanguageKits"
|
||||
${AddInstallerFile} "Uninstall.exe"
|
||||
SectionEnd
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
${AddFile} "RunUnitTests.exe"
|
||||
|
||||
SetOutPath "$INSTDIR\Temp"
|
||||
SetOutPath "$INSTDIR\LanguageKits"
|
||||
SetOutPath "$INSTDIR"
|
||||
Push "Pause.exe"
|
||||
Call NGEN
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<string> ParsedFiles = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Выводит сообщения о подключенных парсерах
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выводит сообщения об ошибках, возникших при загрузке парсеров
|
||||
/// </summary>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<PascalABCCompiler.Errors.Error>();
|
||||
var warnings = new List<PascalABCCompiler.Errors. CompilerWarning>();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -812,6 +812,10 @@
|
|||
<Project>{2DE2842F-0912-4251-BC0F-480854C44A13}</Project>
|
||||
<Name>Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ParserTools\ParserTools.csproj">
|
||||
<Project>{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
|
|
|
|||
|
|
@ -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
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаляет модуль сервиса времени выполнения из списков стандартных модулей всех языков
|
||||
/// </summary>
|
||||
private void RemoveRuntimeServicesModuleFromStandardModules()
|
||||
{
|
||||
foreach (var kv in CompilerOptions1.StandardModules)
|
||||
{
|
||||
CompilerOptions1.RemoveStandardModuleAtIndex(kv.Key, CompilerOptions1.StandardModules[kv.Key].Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавляет модуль сервиса времени выполнения в списки стандартных модулей всех языков
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Windows.Forms;
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
using PascalABCCompiler;
|
||||
|
||||
namespace VisualPascalABC
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<string> ParsedFiles = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Выводит сообщения о подключенных парсерах
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выводит сообщения об ошибках, возникших при загрузке парсеров
|
||||
/// </summary>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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<PascalABCCompiler.Errors.Error>();
|
||||
var warnings = new List<PascalABCCompiler.Errors. CompilerWarning>();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.IO;
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Build.BuildEngine;
|
||||
using PascalABCCompiler;
|
||||
|
||||
namespace VisualPascalABC
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Drawing;
|
|||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using PascalABCCompiler;
|
||||
|
||||
namespace VisualPascalABC
|
||||
{
|
||||
|
|
|
|||
|
|
@ -930,6 +930,10 @@
|
|||
<Project>{2DE2842F-0912-4251-BC0F-480854C44A13}</Project>
|
||||
<Name>Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ParserTools\ParserTools.csproj">
|
||||
<Project>{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
|
|
|
|||
|
|
@ -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
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаляет модуль сервиса времени выполнения из списков стандартных модулей всех языков
|
||||
/// </summary>
|
||||
private void RemoveRuntimeServicesModuleFromStandardModules()
|
||||
{
|
||||
foreach (var kv in CompilerOptions1.StandardModules)
|
||||
{
|
||||
CompilerOptions1.RemoveStandardModuleAtIndex(kv.Key, CompilerOptions1.StandardModules[kv.Key].Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавляет модуль сервиса времени выполнения в списки стандартных модулей всех языков
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using System.Drawing;
|
|||
//using ICSharpCode.FormsDesigner;
|
||||
using VisualPascalABCPlugins;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using PascalABCCompiler;
|
||||
|
||||
namespace VisualPascalABC
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ namespace VisualPascalABCPlugins
|
|||
string FileText = (string)VisualEnvironmentCompiler.Compiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText);
|
||||
List<Error> Errors = new List<Error>();
|
||||
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
||||
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<CompilerWarning>(), PascalABCCompiler.Parsers.ParseMode.Normal);
|
||||
return VisualEnvironmentCompiler.StandartCompiler.ParsersController.SelectParserForUnitAndBuildTree(FileName + fileNamePosfix, FileText, Errors, new List<CompilerWarning>(), PascalABCCompiler.Parsers.ParseMode.Normal);
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click_1(object sender, EventArgs e)
|
||||
|
|
|
|||
0
bin/LanguageKits/.gitkeep
Normal file
0
bin/LanguageKits/.gitkeep
Normal file
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
@ -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}
|
||||
|
|
@ -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}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,10 @@
|
|||
<Project>{2DE2842F-0912-4251-BC0F-480854C44A13}</Project>
|
||||
<Name>Localization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ParserTools\ParserTools.csproj">
|
||||
<Project>{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}</Project>
|
||||
<Name>ParserTools</Name>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -153,6 +153,10 @@
|
|||
<Project>{1e42361a-eda3-4872-88af-a3aaf600d36d}</Project>
|
||||
<Name>Compiler</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LanguageIntegrator\LanguageIntegrator.csproj">
|
||||
<Project>{a48d9069-d569-4110-9252-a10f139b669b}</Project>
|
||||
<Name>LanguageIntegrator</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue