pascalabcnet/AdditionalLanguages/SPython/SPythonLanguageInfo/SPythonLanguage.cs
Александр Земляк b23f9c96d0
Деактивация кнопок, связанных с Intellisense, для языков без Intellisense + разделение ILanguageInformation на два интерфейса (#3378)
* Refactor language information classes

* Implement SimpleLanguageInformation abstract class

* Move some properties to SimpleLanguageInformation

* Implement format and debug buttons disabling if Intellisense is not supported for current language

* Add Intellisense available check in FormsExtensions to deactivate menu items if needed

* Change function interfaces in VisibilityService

* Replace CodeCompletionController.CurrentParser null checks with IntellisenseAvailable method call

* Refactor IParser and BaseParser to deduplicate code

* Fix BuildTreeInSpecialMode in SPythonParser

* Add SimpleParser class for new languages without Intellisense

* Delete duplicate SetDebugButtonsEnabled function

* Add Intellisense available check in RunService when attaching debugger

* Delete inner check in SetDebugButtonsEnabled to improve architecture

* Change CurrentParser property in CodeCompletion to be CurrentLanguage

* Divide ILanguageInformation into two interfaces (creating new ILanguageIntellisenseSupport)

* Fix LanguageIntellisenseSupport initialization in BaseLanguage

* Fix RunService fictive_attach logic

* Disable Intellisense parsing for languages without Intellisense support

* Add DefaultLanguageInformation abstract class

* Add default implementation for SetSemanticConstants in BaseLanguage

* Simplify IParser interface

* Update developer guide documentation
2026-01-27 22:25:28 +03:00

54 lines
2.5 KiB
C#

using System.Collections.Generic;
using Languages.Facade;
using PascalABCCompiler.SyntaxTreeConverters;
using PascalABCCompiler.SystemLibrary;
using PascalABCCompiler.TreeConverter;
namespace Languages.SPython
{
public class SPythonLanguage : BaseLanguage
{
public SPythonLanguage() : base(
languageInformation: new Frontend.Data.SPythonLanguageInformation(),
languageIntellisenseSupport: new Frontend.Data.SPythonIntellisenseSupport(),
parser: new SPythonParser.SPythonLanguageParser(),
docParser: null,
syntaxTreeConverters: new List<ISyntaxTreeConverter>() { new Frontend.Converters.StandardSyntaxTreeConverter(), new SyntaxSemanticVisitors.LambdaAnyConverter() }
)
{
((SPythonParser.SPythonLanguageParser)Parser).SyntaxTreeConvertersForIntellisense = SyntaxTreeConverters;
}
/// <summary>
/// TODO: требуется проверка и настройка работы EVA
/// </summary>
public override void SetSemanticConstants()
{
SemanticRulesConstants.ClassBaseType = SystemLibrary.object_type;
SemanticRulesConstants.StructBaseType = SystemLibrary.value_type;
SemanticRulesConstants.AddResultVariable = true;
SemanticRulesConstants.ZeroBasedStrings = true;
SemanticRulesConstants.FastStrings = false;
SemanticRulesConstants.InitStringAsEmptyString = true;
SemanticRulesConstants.UseDivisionAssignmentOperatorsForIntegerTypes = false;
SemanticRulesConstants.ManyVariablesOneInitializator = false;
SemanticRulesConstants.OrderIndependedMethodNames = true;
SemanticRulesConstants.OrderIndependedFunctionNames = false;
SemanticRulesConstants.OrderIndependedTypeNames = false;
SemanticRulesConstants.EnableExitProcedure = true;
SemanticRulesConstants.StrongPointersTypeCheckForDotNet = true;
SemanticRulesConstants.AllowChangeLoopVariable = false;
SemanticRulesConstants.AllowGlobalVisibilityForPABCDll = true;
SemanticRulesConstants.AllowMethodCallsWithoutParentheses = false;
}
public override void SetSyntaxTreeToSemanticTreeConverter()
{
SyntaxTreeToSemanticTreeConverter = new SPythonSyntaxTreeVisitor.spython_syntax_tree_visitor(LanguageProvider.Instance.MainLanguage.SyntaxTreeToSemanticTreeConverter);
}
}
}