From dc43304b8b8577f4adf65a6b74ffc9b12d9d7ea2 Mon Sep 17 00:00:00 2001 From: Udayshankar Ravikumar Date: Wed, 7 Aug 2024 10:25:45 +0530 Subject: [PATCH] Fixed formatting, removed unused imports. --- src/Runtime/Interpreter.cs | 34 +++++++++---------- src/Runtime/Reference.cs | 4 +-- src/Runtime/Types/BaseTypes.cs | 4 +-- .../Core/RuntimeErrors/EzrAssertionError.cs | 1 - .../RuntimeErrors/EzrIllegalOperationError.cs | 1 - .../Core/RuntimeErrors/EzrKeyNotFoundError.cs | 1 - .../Types/Core/RuntimeErrors/EzrMathError.cs | 1 - .../EzrMissingRequiredArgumentError.cs | 1 - .../EzrPrivateMemberOperationError.cs | 1 - .../Core/RuntimeErrors/EzrRuntimeError.cs | 1 - .../RuntimeErrors/EzrUndefinedValueError.cs | 1 - .../EzrUnexpectedArgumentError.cs | 1 - .../RuntimeErrors/EzrUnexpectedTypeError.cs | 1 - .../EzrUnsupportedWrappingError.cs | 1 - .../RuntimeErrors/EzrValueOutOfRangeError.cs | 1 - .../RuntimeErrors/EzrWrapperExecutionError.cs | 1 - src/Runtime/Types/Executables/EzrClass.cs | 6 ++-- .../Types/Executables/EzrClassInstance.cs | 4 +-- .../Types/Executables/EzrRuntimeExecutable.cs | 10 +++--- src/Shell/EzrShellEditor.cs | 4 +-- src/Syntax/Lexer.cs | 16 ++++----- src/Syntax/Parser/Parser.cs | 10 +++--- 22 files changed, 46 insertions(+), 59 deletions(-) diff --git a/src/Runtime/Interpreter.cs b/src/Runtime/Interpreter.cs index e3576a4..f85806d 100644 --- a/src/Runtime/Interpreter.cs +++ b/src/Runtime/Interpreter.cs @@ -573,7 +573,7 @@ private void VisitBinaryOperationNode(BinaryOperationNode node, Context executio { case TokenType.Period: ExecuteObjectAttributeAccess(node, executionContext, callingContext, accessibilityModifiers, ignoreUndefinedVariable); break; - + case TokenType.KeywordOr: case TokenType.KeywordAnd: ExecuteConjunctiveOperators(node, executionContext, callingContext, accessibilityModifiers); break; @@ -607,7 +607,7 @@ private void ExecuteObjectAttributeAccess(BinaryOperationNode node, Context exec ? accessibilityModifiers & ~AccessMod.LocalScope : accessibilityModifiers; - VisitNode(node.Left, executionContext, callingContext, accessibilityModifiers & ~AccessMod.LocalScope); + VisitNode(node.Left, executionContext, callingContext, accessibilityModifiers & ~AccessMod.LocalScope); if (RuntimeResult.ShouldReturn) return; @@ -678,12 +678,12 @@ private void ExecuteBinaryOperation(IEzrObject first, IEzrObject second, Node no case TokenType.AssignmentAddition: first.Addition(second, RuntimeResult); break; - + case TokenType.HyphenMinus: case TokenType.AssignmentSubtraction: first.Subtraction(second, RuntimeResult); break; - + case TokenType.Asterisk: case TokenType.AssignmentMultiplication: first.Multiplication(second, RuntimeResult); @@ -693,12 +693,12 @@ private void ExecuteBinaryOperation(IEzrObject first, IEzrObject second, Node no case TokenType.AssignmentDivision: first.Division(second, RuntimeResult); break; - + case TokenType.Caret: case TokenType.AssignmentPower: first.Power(second, RuntimeResult); break; - + case TokenType.PercentSign: case TokenType.AssignmentModulo: first.Modulo(second, RuntimeResult); @@ -708,22 +708,22 @@ private void ExecuteBinaryOperation(IEzrObject first, IEzrObject second, Node no case TokenType.AssignmentBitwiseAnd: first.BitwiseAnd(second, RuntimeResult); break; - + case TokenType.VerticalBar: case TokenType.AssignmentBitwiseOr: first.BitwiseOr(second, RuntimeResult); break; - + case TokenType.Backslash: case TokenType.AssignmentBitwiseXOr: first.BitwiseXOr(second, RuntimeResult); break; - + case TokenType.BitwiseLeftShift: case TokenType.AssignmentBitwiseLeftShift: first.BitwiseLeftShift(second, RuntimeResult); break; - + case TokenType.BitwiseRightShift: case TokenType.AssignmentBitwiseRightShift: first.BitwiseRightShift(second, RuntimeResult); @@ -732,23 +732,23 @@ private void ExecuteBinaryOperation(IEzrObject first, IEzrObject second, Node no case TokenType.EqualSign: first.ComparisonEqual(second, RuntimeResult); break; - + case TokenType.ExclamationMark: first.ComparisonNotEqual(second, RuntimeResult); break; - + case TokenType.LessThanSign: first.ComparisonLessThan(second, RuntimeResult); break; - + case TokenType.GreaterThanSign: first.ComparisonGreaterThan(second, RuntimeResult); break; - + case TokenType.LessThanOrEqual: first.ComparisonLessThanOrEqual(second, RuntimeResult); break; - + case TokenType.GreaterThanOrEqual: first.ComparisonGreaterThanOrEqual(second, RuntimeResult); break; @@ -756,7 +756,7 @@ private void ExecuteBinaryOperation(IEzrObject first, IEzrObject second, Node no case TokenType.KeywordIn: second.HasValueContained(first, RuntimeResult); break; - + case TokenType.KeywordNot: second.NotHasValueContained(first, RuntimeResult); break; @@ -1327,7 +1327,7 @@ private void VisitCallNode(CallNode node, Context executionContext, Context call { Context argumentsContext = new($"<{receiver.TypeName} arguments>", false, receiver.StartPosition, callingContext, callingContext.StaticContext); arguments = new Reference[node.Arguments.Count]; - + for (int i = 0; i < node.Arguments.Count; i++) { Node argument = node.Arguments[i]; diff --git a/src/Runtime/Reference.cs b/src/Runtime/Reference.cs index 16c7c81..d1c17a3 100644 --- a/src/Runtime/Reference.cs +++ b/src/Runtime/Reference.cs @@ -73,10 +73,10 @@ public Reference Reset(IEzrObject? @object, AccessMod accessibilityModifiers, st { Object = @object ?? EzrRuntimeInvalidObject.s_instance; AccessibilityModifiers = accessibilityModifiers; - + Name = name; IsEmpty = @object is null; - + RegisteredContext = null; RegisteredIn = 0; diff --git a/src/Runtime/Types/BaseTypes.cs b/src/Runtime/Types/BaseTypes.cs index 2dc4720..f446ca9 100644 --- a/src/Runtime/Types/BaseTypes.cs +++ b/src/Runtime/Types/BaseTypes.cs @@ -284,7 +284,7 @@ public virtual void Interpret(Node code, Context callingContext, Interpreter int result.Failure(new EzrUndefinedValueError($"You cannot create nor change members of a read-only object!", Context, StartPosition, EndPosition)); return; } - + if (IsReadOnly) result.Success( ReferencePool.Get( @@ -449,7 +449,7 @@ protected internal EzrIllegalOperationError IllegalOperation() /// The error. protected internal EzrIllegalOperationError IllegalOperation(IEzrObject other, bool isRightHandSide = true) { - return + return isRightHandSide ? new EzrIllegalOperationError($"Illegal operation for types \"{TypeName}\" and \"{other.TypeName}\"!", _executionContext, StartPosition, other.EndPosition) : new EzrIllegalOperationError($"Illegal operation for types \"{other.TypeName}\" and \"{TypeName}\"!", _executionContext, other.StartPosition, EndPosition); diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrAssertionError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrAssertionError.cs index 88bd11e..a0f3d20 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrAssertionError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrAssertionError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrIllegalOperationError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrIllegalOperationError.cs index de047ff..6a09753 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrIllegalOperationError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrIllegalOperationError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrKeyNotFoundError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrKeyNotFoundError.cs index f3d41bc..2ccc1f6 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrKeyNotFoundError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrKeyNotFoundError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrMathError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrMathError.cs index 658a761..a634ff5 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrMathError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrMathError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrMissingRequiredArgumentError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrMissingRequiredArgumentError.cs index ddc21e8..118813b 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrMissingRequiredArgumentError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrMissingRequiredArgumentError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrPrivateMemberOperationError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrPrivateMemberOperationError.cs index 4f4c32a..1ceefa6 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrPrivateMemberOperationError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrPrivateMemberOperationError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs index cc96122..a17795d 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs @@ -2,7 +2,6 @@ using EzrSquared.Runtime.WrapperAttributes; using EzrSquared.Util; using System; -using System.Collections.Generic; using System.Text; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrUndefinedValueError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrUndefinedValueError.cs index 30e681a..6f15529 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrUndefinedValueError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrUndefinedValueError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedArgumentError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedArgumentError.cs index 799b01b..6d6a465 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedArgumentError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedArgumentError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedTypeError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedTypeError.cs index f26ecce..76b2d84 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedTypeError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrUnexpectedTypeError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrUnsupportedWrappingError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrUnsupportedWrappingError.cs index 4934f74..15a3555 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrUnsupportedWrappingError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrUnsupportedWrappingError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrValueOutOfRangeError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrValueOutOfRangeError.cs index d89408d..b68b3f6 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrValueOutOfRangeError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrValueOutOfRangeError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrWrapperExecutionError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrWrapperExecutionError.cs index 2944e33..ba07d52 100644 --- a/src/Runtime/Types/Core/RuntimeErrors/EzrWrapperExecutionError.cs +++ b/src/Runtime/Types/Core/RuntimeErrors/EzrWrapperExecutionError.cs @@ -1,5 +1,4 @@ using EzrSquared.Runtime.WrapperAttributes; -using System.Collections.Generic; namespace EzrSquared.Runtime.Types.Core.Errors; diff --git a/src/Runtime/Types/Executables/EzrClass.cs b/src/Runtime/Types/Executables/EzrClass.cs index 57ba483..bba6ec0 100644 --- a/src/Runtime/Types/Executables/EzrClass.cs +++ b/src/Runtime/Types/Executables/EzrClass.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using EzrSquared.Runtime.Nodes; +using EzrSquared.Runtime.Nodes; using EzrSquared.Runtime.Types.Core.Errors; +using System; +using System.Collections.Generic; namespace EzrSquared.Runtime.Types; diff --git a/src/Runtime/Types/Executables/EzrClassInstance.cs b/src/Runtime/Types/Executables/EzrClassInstance.cs index 89f7995..dbe44d5 100644 --- a/src/Runtime/Types/Executables/EzrClassInstance.cs +++ b/src/Runtime/Types/Executables/EzrClassInstance.cs @@ -1,9 +1,9 @@ -using System; -using EzrSquared.Runtime.Nodes; +using EzrSquared.Runtime.Nodes; using EzrSquared.Runtime.Types.Core; using EzrSquared.Runtime.Types.Core.Errors; using EzrSquared.Runtime.Types.Core.Numerics; using EzrSquared.Runtime.Types.Core.Text; +using System; namespace EzrSquared.Runtime.Types; diff --git a/src/Runtime/Types/Executables/EzrRuntimeExecutable.cs b/src/Runtime/Types/Executables/EzrRuntimeExecutable.cs index d9720e3..d87d162 100644 --- a/src/Runtime/Types/Executables/EzrRuntimeExecutable.cs +++ b/src/Runtime/Types/Executables/EzrRuntimeExecutable.cs @@ -1,8 +1,8 @@ -using EzrSquared.Runtime.Types.Collections; +using EzrSquared.Runtime.Collections; +using EzrSquared.Runtime.Nodes; +using EzrSquared.Runtime.Types.Collections; using EzrSquared.Runtime.Types.Core.Errors; using EzrSquared.Runtime.Types.Core.Text; -using EzrSquared.Runtime.Collections; -using EzrSquared.Runtime.Nodes; using EzrSquared.Util; using System; @@ -125,7 +125,7 @@ protected internal void CheckAndPopulateArguments(Reference[] arguments, Context // Is the key already exist? bool hasKey = isValidIndex && context.IsDefined(key); - + // If parameterIndex is out of bounds, or the key is already defined and the argument is a keyword argument, or if all the arguments have already been set: if (!isValidIndex || (hasKey && (isKeywordArgument || parameterIndex + 1 >= Parameters.Length))) { @@ -234,7 +234,7 @@ public override string ToString(RuntimeResult result) string[] paramterNames = Array.ConvertAll(Parameters, parameter => parameter.Name); return (Parameters.Length > 0, IsAnonymous) switch { - (true, true) => $"<{TypeName} {ExecutableName}, with \"{string.Join("\", \"", paramterNames)}\">", + (true, true) => $"<{TypeName} {ExecutableName}, with \"{string.Join("\", \"", paramterNames)}\">", (true, false) => $"<{TypeName} \"{ExecutableName}\", with \"{string.Join("\", \"", paramterNames)}\">", (false, true) => $"<{TypeName} {ExecutableName}>", diff --git a/src/Shell/EzrShellEditor.cs b/src/Shell/EzrShellEditor.cs index df5dd8a..5217dad 100644 --- a/src/Shell/EzrShellEditor.cs +++ b/src/Shell/EzrShellEditor.cs @@ -1,6 +1,6 @@ -using System.IO; +using System; +using System.IO; using System.Text; -using System; namespace EzrSquaredCli; diff --git a/src/Syntax/Lexer.cs b/src/Syntax/Lexer.cs index 1e7fe36..c42110f 100644 --- a/src/Syntax/Lexer.cs +++ b/src/Syntax/Lexer.cs @@ -67,7 +67,7 @@ private void Advance() _currentChar = '\0'; } } - + /// /// Reverses to the given index. /// @@ -81,12 +81,12 @@ private void ReverseTo(int index) _currentChar = _script[_position.Index]; } -/// -/// Creates a of objects from the given script. -/// -/// The created of objects. -/// Any that occurred in the lexing; if none occurred. -public SyntaxError? Tokenize(out List tokens) + /// + /// Creates a of objects from the given script. + /// + /// The created of objects. + /// Any that occurred in the lexing; if none occurred. + public SyntaxError? Tokenize(out List tokens) { SyntaxError? error; tokens = []; @@ -379,7 +379,7 @@ private Token CompileStringLike(out SyntaxError? error) tooLong ? "Value too long to be a character!" : "A character cannot be empty!", startPosition, _position); - + return Token.Empty; } diff --git a/src/Syntax/Parser/Parser.cs b/src/Syntax/Parser/Parser.cs index 37160bf..f09191f 100644 --- a/src/Syntax/Parser/Parser.cs +++ b/src/Syntax/Parser/Parser.cs @@ -246,10 +246,10 @@ or TokenType.EndOfFile or TokenType.KeywordEnd or TokenType.KeywordElse or TokenType.KeywordCatch) - // || (_usingQuickSyntax - // && (_currentToken.Type == TokenType.QeywordL - // || _currentToken.Type == TokenType.QeywordE - // || _currentToken.Type == TokenType.QeywordS))) + // || (_usingQuickSyntax + // && (_currentToken.Type == TokenType.QeywordL + // || _currentToken.Type == TokenType.QeywordE + // || _currentToken.Type == TokenType.QeywordS))) { _result.Success(new ReturnNode(null, false, startPosition, possibleEndPosition)); return; @@ -2109,7 +2109,7 @@ private void ParseClassDefinitionExpression() return; } - _result.Failure(10, new SyntaxError(SyntaxError.InvalidGrammar, + _result.Failure(10, new SyntaxError(SyntaxError.InvalidGrammar, (name is null && parents.Count == 0) ? "Expected an expression or the 'from' or 'do' keywords! An expression after the 'object' keyword defines the name, the 'from' keyword and the following expression(s, seperated by commas) define(s) the parents and the 'do' keyword declares the start of the body of the class." : (parents.Count == 0)