Skip to content

Commit

Permalink
#236 - Rework parser (remove RPN)
Browse files Browse the repository at this point in the history
  • Loading branch information
sys27 committed Aug 1, 2019
1 parent c3ae1e2 commit 1b7e963
Show file tree
Hide file tree
Showing 26 changed files with 954 additions and 665 deletions.
20 changes: 10 additions & 10 deletions xFunc.Benchmark/Benchmarks/ParserBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public void Setup()
.Number(100.1)
.Operation(Operations.Addition)
.OpenBracket()
.Function(Functions.Sine, 1)
.Function(Functions.Sine)
.OpenBracket()
.Function(Functions.Cosine, 1)
.Function(Functions.Cosine)
.OpenBracket()
.Function(Functions.Tangent, 1)
.Function(Functions.Tangent)
.OpenBracket()
.Function(Functions.Cotangent, 1)
.Function(Functions.Cotangent)
.OpenBracket()
.VariableX()
.CloseBracket()
Expand All @@ -59,7 +59,7 @@ public void Setup()
.CloseBracket()
.Operation(Operations.Subtraction)
.OpenBracket()
.Function(Functions.Cosine, 1)
.Function(Functions.Cosine)
.OpenBracket()
.VariableY()
.CloseBracket()
Expand All @@ -78,18 +78,18 @@ public void Setup()
.CloseBracket()
.Operation(Operations.Addition)
.OpenBracket()
.Function(Functions.Determinant, 1)
.Function(Functions.Determinant)
.OpenBracket()
.Function(Functions.Matrix, 2)
.Function(Functions.Matrix)
.OpenBrace()
.Function(Functions.Vector, 2)
.Function(Functions.Vector)
.OpenBrace()
.Number(1)
.Comma()
.Number(2)
.CloseBrace()
.Comma()
.Function(Functions.Vector, 2)
.Function(Functions.Vector)
.OpenBrace()
.Number(3)
.Comma()
Expand All @@ -98,7 +98,7 @@ public void Setup()
.CloseBrace()
.CloseBracket()
.Operation(Operations.Multiplication)
.Function(Functions.Log, 2)
.Function(Functions.Log)
.OpenBracket()
.Number(2)
.Comma()
Expand Down
1 change: 1 addition & 0 deletions xFunc.DotnetTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using xFunc.Maths.Analyzers.TypeAnalyzers;
using xFunc.Maths.Expressions;
using xFunc.Maths.Expressions.Collections;
using xFunc.Maths.Tokenization;

namespace xFunc.DotnetTool
{
Expand Down
248 changes: 116 additions & 132 deletions xFunc.Maths/ExpressionFactory.cs

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions xFunc.Maths/Expressions/BinaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace xFunc.Maths.Expressions
/// <summary>
/// The base class for binary operations.
/// </summary>
public abstract class BinaryExpression : IFunctionExpression
public abstract class BinaryExpression : IExpression
{

/// <summary>
Expand Down Expand Up @@ -197,14 +197,6 @@ public virtual IExpression Right
/// </summary>
public virtual IExpression Parent { get; set; }

/// <summary>
/// Gets the count of parameters.
/// </summary>
/// <value>
/// The count of parameters.
/// </value>
public virtual int ParametersCount => 2;

}

}
10 changes: 1 addition & 9 deletions xFunc.Maths/Expressions/Define.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace xFunc.Maths.Expressions
/// <summary>
/// Represents the Define operation.
/// </summary>
public class Define : IFunctionExpression
public class Define : IExpression
{

private IExpression key;
Expand Down Expand Up @@ -168,14 +168,6 @@ public IExpression Clone()
/// </summary>
public IExpression Parent { get; set; }

/// <summary>
/// Gets the count of parameters.
/// </summary>
/// <value>
/// The count of parameters.
/// </value>
public int ParametersCount => 2;

/// <summary>
/// Gets or sets the key.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/DifferentParametersExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace xFunc.Maths.Expressions
/// <summary>
/// The base class for expressions with different number of parameters.
/// </summary>
public abstract class DifferentParametersExpression : IFunctionExpression
public abstract class DifferentParametersExpression : IExpression
{

/// <summary>
Expand Down
35 changes: 0 additions & 35 deletions xFunc.Maths/Expressions/IFunctionExpression.cs

This file was deleted.

10 changes: 1 addition & 9 deletions xFunc.Maths/Expressions/UnaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace xFunc.Maths.Expressions
/// <summary>
/// The abstract base class that represents the unary operation.
/// </summary>
public abstract class UnaryExpression : IFunctionExpression
public abstract class UnaryExpression : IExpression
{

/// <summary>
Expand Down Expand Up @@ -165,14 +165,6 @@ public virtual IExpression Argument
/// </summary>
public IExpression Parent { get; set; }

/// <summary>
/// Gets the count of parameters.
/// </summary>
/// <value>
/// The count of parameters.
/// </value>
public virtual int ParametersCount => 1;

}

}
10 changes: 1 addition & 9 deletions xFunc.Maths/Expressions/Undefine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace xFunc.Maths.Expressions
/// <summary>
/// Represents the Undefice operation.
/// </summary>
public class Undefine : IFunctionExpression
public class Undefine : IExpression
{

private IExpression key;
Expand Down Expand Up @@ -158,14 +158,6 @@ public IExpression Clone()
[ExcludeFromCodeCoverage]
public IExpression Parent { get; set; }

/// <summary>
/// Gets the count of parameters.
/// </summary>
/// <value>
/// The count of parameters.
/// </value>
public int ParametersCount => 1;

/// <summary>
/// Gets or sets the key.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions xFunc.Maths/IExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Collections.Generic;
using xFunc.Maths.Expressions;
using xFunc.Maths.Tokenization.Tokens;

Expand All @@ -31,7 +30,7 @@ public interface IExpressionFactory
/// <param name="token">The token.</param>
/// <param name="arguments">The list of arguments.</param>
/// <returns>The expression.</returns>
IExpression Create(IToken token, IEnumerable<IExpression> arguments);
IExpression Create(IToken token, params IExpression[] arguments);

}

Expand Down

0 comments on commit 1b7e963

Please sign in to comment.