New features and bug fixes

- Fix import (`imp`) bug-
- Add is in parameter available (`isi`) statement
- Add is out parameter available (`iso`) statement
This commit is contained in:
Stone_Red
2022-03-24 21:16:32 +01:00
parent 83f99d4dd5
commit 0a4406d21f
8 changed files with 166 additions and 5 deletions
+113
View File
@@ -0,0 +1,113 @@
[*.cs]
# Default severity for analyzer diagnostics with category 'Critical Code Smell'
dotnet_analyzer_diagnostic.category-Critical Code Smell.severity = none
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:silent
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
[*.{cs,vb}]
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
[*.cs]
#### Naming styles ####
# Naming rules
dotnet_naming_rule.const_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.const_should_be_pascal_case.symbols = const
dotnet_naming_rule.const_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.const.applicable_kinds =
dotnet_naming_symbols.const.applicable_accessibilities = *
dotnet_naming_symbols.const.required_modifiers = const
# Naming styles
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
[*.{cs,vb}]
#### Naming styles ####
# Naming rules
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Naming styles
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
+5
View File
@@ -7,6 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YesNt.CodeEditor", "YesNt.C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YesNt.Interpreter", "YesNt.Interpreter\YesNt.Interpreter.csproj", "{E40573DB-912A-4871-BB65-3EE6E7D72E79}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{52024699-4F8E-40F6-AF03-71DDB4A1DC06}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+8
View File
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Critical Code Smell", "S3998:Threads should not lock on objects with weak identity", Justification = "<Pending>", Scope = "member", Target = "~M:YesNt.CodeEditor.TextEditor.YesNtInterpreter_OnLineExecuted(YesNt.Interpreter.Runtime.DebugEventArgs)")]
+4
View File
@@ -5,6 +5,10 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YesNt.Interpreter\YesNt.Interpreter.csproj" />
</ItemGroup>
@@ -62,6 +62,15 @@ namespace YesNt.Interpreter.Statements
}
}
[Statement("%iso", SearchMode.Contains, SpaceAround.End, ConsoleColor.Yellow, KeepStatementInArgs = true, Priority = Priority.Highest)]
public void CheckIfOutParameterAvalible(string args)
{
args += " ";
args = args.Replace("%iso ", $"{RuntimeInfo.OutParametersStack.Count > 0} ");
RuntimeInfo.CurrentLine = args.TrimEnd();
}
[Statement("cal", SearchMode.StartOfLine, SpaceAround.End, ConsoleColor.DarkYellow, Priority = Priority.Low, Seperator = "|")]
public void Call(string args)
{
@@ -119,6 +128,21 @@ namespace YesNt.Interpreter.Statements
}
}
[Statement("%isi", SearchMode.Contains, SpaceAround.End, ConsoleColor.Yellow, KeepStatementInArgs = true, Priority = Priority.Highest)]
public void CheckIfInParameterAvalible(string args)
{
if (!RuntimeInfo.IsInFunction)
{
RuntimeInfo.Exit("Statement not allowed outside of function", true);
return;
}
args += " ";
args = args.Replace("%isi ", $"{RuntimeInfo.FunctionCallStack.Peek().Arguemtns.Count > 0} ");
RuntimeInfo.CurrentLine = args.TrimEnd();
}
[Statement("put", SearchMode.StartOfLine, SpaceAround.End, ConsoleColor.Yellow)]
public void AddOutParameter(string args)
{
@@ -27,8 +27,6 @@ namespace YesNt.Interpreter.Statements
public void GetPi(string args)
{
args += " ";
args = args.Replace("%pi ", $"{Math.PI} ");
RuntimeInfo.CurrentLine = args.TrimEnd();
@@ -74,7 +74,7 @@ namespace YesNt.Interpreter.Statements
{
try
{
RuntimeInfo.Lines.RemoveAt(0);
RuntimeInfo.Lines.RemoveAt(RuntimeInfo.LineNumber);
string[] lines = File.ReadAllLines(path);
for (int i = 0; i < lines.Length; i++)
@@ -85,12 +85,12 @@ namespace YesNt.Interpreter.Statements
}
catch
{
RuntimeInfo.Exit($"Could not load file {path}", true);
RuntimeInfo.Exit($"Could not load file \"{path}\"", true);
}
}
else
{
RuntimeInfo.Exit($"Could not find file {path}", true);
RuntimeInfo.Exit($"Could not find file \"{path}\"", true);
}
}
+9
View File
@@ -6,6 +6,15 @@ namespace YesNt.Interpreter.Utilities
{
public static bool? EvaluateCondition(string input)
{
if (input.ToLower().FromSaveString().Trim() == "true")
{
return true;
}
else if (input.ToLower().FromSaveString().Trim() == "false")
{
return false;
}
string[] parts = input.Split("==");
if (parts.Length == 2)
{