Initial commit
This commit is contained in:
commit
4b1294b32d
23 changed files with 5134 additions and 0 deletions
40
MathInterpreter/Core/ScanResult.cs
Normal file
40
MathInterpreter/Core/ScanResult.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace MathInterpreter.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Result object of scan operations
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the parsed value</typeparam>
|
||||
public readonly ref struct ScanResult<T> where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new scan result based on a successfully parsed value - if parsing failed an Exception
|
||||
/// would have been thrown and this constructor would not be called
|
||||
/// </summary>
|
||||
/// <param name="value">Parsed value</param>
|
||||
/// <param name="length">Number of characters (digits) of the parsed value</param>
|
||||
/// <param name="remainingExpression">Remaining part of the expression after extracting and parsing the value</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if an invalid argument is provided</exception>
|
||||
public ScanResult(T value, int length, ReadOnlySpan<char> remainingExpression)
|
||||
{
|
||||
Value = value;
|
||||
Length = -1; // TODO
|
||||
RemainingExpression = remainingExpression;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parsed value
|
||||
/// </summary>
|
||||
public T Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of characters (digits) of the parsed value
|
||||
/// </summary>
|
||||
public int Length { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remaining part of the expression after extracting and parsing the value
|
||||
/// </summary>
|
||||
public ReadOnlySpan<char> RemainingExpression { get; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue