Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RQL (part 1) - Match and search expressions #166

Open
wants to merge 9 commits into
base: release-3.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: Pack Rules.Framework.Providers.MongoDb
run: dotnet pack src/Rules.Framework.Providers.MongoDb/Rules.Framework.Providers.MongoDb.csproj --include-symbols -c Release /p:Version=$BUILD_VERSION

- name: Pack Rules.Framework.Rql
run: dotnet pack src/Rules.Framework.Rql/Rules.Framework.Rql.csproj --include-symbols -c Release /p:Version=$BUILD_VERSION

- name: Pack Rules.Framework.WebUI
run: dotnet pack src/Rules.Framework.WebUI/Rules.Framework.WebUI.csproj --include-symbols -c Release /p:Version=$BUILD_VERSION

Expand Down
28 changes: 28 additions & 0 deletions rules-framework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.WebUI.Tests
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.BenchmarkTests", "tests\Rules.Framework.BenchmarkTests\Rules.Framework.BenchmarkTests.csproj", "{16C9F383-3B58-4911-9D26-7FDB907DD0D2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.RqlReplTester", "tests\Rules.Framework.RqlReplTester\Rules.Framework.RqlReplTester.csproj", "{F21A8797-89E4-4EB3-92AF-4A051C3E579A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.Rql", "src\Rules.Framework.Rql\Rules.Framework.Rql.csproj", "{76298D4D-537C-4522-91AB-0084535B1FF0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.Rql.Tests", "tests\Rules.Framework.Rql.Tests\Rules.Framework.Rql.Tests.csproj", "{776E54A7-9099-4EBD-9C62-A371DFED58E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rules.Framework.Rql.IntegrationTests", "tests\Rules.Framework.Rql.IntegrationTests\Rules.Framework.Rql.IntegrationTests.csproj", "{C24A2234-AD6A-4377-9FAA-9CC58386107C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -98,6 +106,22 @@ Global
{16C9F383-3B58-4911-9D26-7FDB907DD0D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16C9F383-3B58-4911-9D26-7FDB907DD0D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16C9F383-3B58-4911-9D26-7FDB907DD0D2}.Release|Any CPU.Build.0 = Release|Any CPU
{F21A8797-89E4-4EB3-92AF-4A051C3E579A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F21A8797-89E4-4EB3-92AF-4A051C3E579A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F21A8797-89E4-4EB3-92AF-4A051C3E579A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F21A8797-89E4-4EB3-92AF-4A051C3E579A}.Release|Any CPU.Build.0 = Release|Any CPU
{76298D4D-537C-4522-91AB-0084535B1FF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76298D4D-537C-4522-91AB-0084535B1FF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76298D4D-537C-4522-91AB-0084535B1FF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76298D4D-537C-4522-91AB-0084535B1FF0}.Release|Any CPU.Build.0 = Release|Any CPU
{776E54A7-9099-4EBD-9C62-A371DFED58E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{776E54A7-9099-4EBD-9C62-A371DFED58E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{776E54A7-9099-4EBD-9C62-A371DFED58E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{776E54A7-9099-4EBD-9C62-A371DFED58E5}.Release|Any CPU.Build.0 = Release|Any CPU
{C24A2234-AD6A-4377-9FAA-9CC58386107C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C24A2234-AD6A-4377-9FAA-9CC58386107C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C24A2234-AD6A-4377-9FAA-9CC58386107C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C24A2234-AD6A-4377-9FAA-9CC58386107C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -116,6 +140,10 @@ Global
{7CE82611-FEC1-49E9-91FB-4C3ADF5ED56F} = {AEE746EC-CEAA-4892-8C29-0CAAB97A23A8}
{29DC6661-4F0C-46F7-AC91-968700D13C11} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{16C9F383-3B58-4911-9D26-7FDB907DD0D2} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{F21A8797-89E4-4EB3-92AF-4A051C3E579A} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{76298D4D-537C-4522-91AB-0084535B1FF0} = {AEE746EC-CEAA-4892-8C29-0CAAB97A23A8}
{776E54A7-9099-4EBD-9C62-A371DFED58E5} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{C24A2234-AD6A-4377-9FAA-9CC58386107C} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA9D4C31-972B-49C2-9F63-C56ED766DAB0}
Expand Down
5 changes: 5 additions & 0 deletions src/Rules.Framework.Rql/AssemblyMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Rules.Framework.Rql.Tests")]
[assembly: InternalsVisibleTo("Rules.Framework.Rql.IntegrationTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
26 changes: 26 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/AssignmentExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System;
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal class AssignmentExpression : Expression
{
public AssignmentExpression(Expression left, Token assign, Expression right)
: base(left.BeginPosition, right.EndPosition)
{
this.Left = left;
this.Assign = assign;
this.Right = right;
}

public Token Assign { get; }

public Expression Left { get; }

public Expression Right { get; }

public override T Accept<T>(IExpressionVisitor<T> visitor) => throw new NotSupportedException("To be supported in a future release.");
}
}
25 changes: 25 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/BinaryExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Ast.Segments;

[ExcludeFromCodeCoverage]
internal class BinaryExpression : Expression
{
public BinaryExpression(Expression leftExpression, Segment operatorSegment, Expression rightExpression)
: base(leftExpression.BeginPosition, rightExpression.EndPosition)
{
this.LeftExpression = leftExpression;
this.OperatorSegment = operatorSegment;
this.RightExpression = rightExpression;
}

public Expression LeftExpression { get; }

public Segment OperatorSegment { get; }

public Expression RightExpression { get; }

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitBinaryExpression(this);
}
}
24 changes: 24 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/Expression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal abstract class Expression : IAstElement
{
protected Expression(RqlSourcePosition beginPosition, RqlSourcePosition endPosition)
{
this.BeginPosition = beginPosition;
this.EndPosition = endPosition;
}

public static Expression None { get; } = new NoneExpression();

public RqlSourcePosition BeginPosition { get; }

public RqlSourcePosition EndPosition { get; }

public abstract T Accept<T>(IExpressionVisitor<T> visitor);
}
}
29 changes: 29 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/IExpressionVisitor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
internal interface IExpressionVisitor<out T>
{
T VisitAssignmentExpression(AssignmentExpression assignmentExpression);

T VisitBinaryExpression(BinaryExpression binaryExpression);

T VisitIdentifierExpression(IdentifierExpression identifierExpression);

T VisitKeywordExpression(KeywordExpression keywordExpression);

T VisitLiteralExpression(LiteralExpression literalExpression);

T VisitMatchExpression(MatchExpression matchExpression);

T VisitNewArrayExpression(NewArrayExpression newArrayExpression);

T VisitNewObjectExpression(NewObjectExpression newObjectExpression);

T VisitNoneExpression(NoneExpression noneExpression);

T VisitPlaceholderExpression(PlaceholderExpression placeholderExpression);

T VisitSearchExpression(SearchExpression searchExpression);

T VisitUnaryExpression(UnaryExpression expression);
}
}
19 changes: 19 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/IdentifierExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal class IdentifierExpression : Expression
{
public IdentifierExpression(Token identifier)
: base(identifier.BeginPosition, identifier.EndPosition)
{
this.Identifier = identifier;
}

public Token Identifier { get; }

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitIdentifierExpression(this);
}
}
22 changes: 22 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/KeywordExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal class KeywordExpression : Expression
{
private KeywordExpression(Token keyword)
: base(keyword.BeginPosition, keyword.EndPosition)
{
this.Keyword = keyword;
}

public Token Keyword { get; }

public static KeywordExpression Create(Token keyword)
=> new(keyword);

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitKeywordExpression(this);
}
}
28 changes: 28 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/LiteralExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal class LiteralExpression : Expression
{
private LiteralExpression(LiteralType type, Token token, object value)
: base(token.BeginPosition, token.EndPosition)
{
this.Type = type;
this.Token = token;
this.Value = value;
}

public Token Token { get; }

public LiteralType Type { get; }

public object Value { get; }

public static LiteralExpression Create(LiteralType type, Token token, object value)
=> new(type, token, value);

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitLiteralExpression(this);
}
}
12 changes: 12 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/LiteralType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
internal enum LiteralType
{
Undefined = 0,
String = 1,
Integer = 2,
Decimal = 3,
Bool = 4,
DateTime = 5,
}
}
38 changes: 38 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/MatchExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Ast.Segments;

[ExcludeFromCodeCoverage]
internal class MatchExpression : Expression
{
private MatchExpression(
Segment cardinality,
Expression contentType,
Expression matchDate,
Segment inputConditions)
: base(cardinality.BeginPosition, inputConditions?.EndPosition ?? matchDate.EndPosition)
{
this.Cardinality = cardinality;
this.ContentType = contentType;
this.MatchDate = matchDate;
this.InputConditions = inputConditions;
}

public Segment Cardinality { get; }

public Expression ContentType { get; }

public Segment InputConditions { get; }

public Expression MatchDate { get; }

public static MatchExpression Create(Segment cardinality,
Expression contentType,
Expression matchDate,
Segment inputConditions)
=> new(cardinality, contentType, matchDate, inputConditions);

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitMatchExpression(this);
}
}
34 changes: 34 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/NewArrayExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal class NewArrayExpression : Expression
{
private NewArrayExpression(Token array, Token initializerBeginToken, Expression size, Expression[] values, Token initializerEndToken)
: base(array.EndPosition, initializerEndToken.EndPosition)
{
this.Array = array;
this.InitializerBeginToken = initializerBeginToken;
this.Size = size;
this.Values = values;
this.InitializerEndToken = initializerEndToken;
}

public Token Array { get; }

public Token InitializerBeginToken { get; }

public Token InitializerEndToken { get; }

public Expression Size { get; }

public Expression[] Values { get; }

public static NewArrayExpression Create(Token array, Token initializerBeginToken, Expression size, Expression[] values, Token initializerEndToken)
=> new(array, initializerBeginToken, size, values, initializerEndToken);

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitNewArrayExpression(this);
}
}
23 changes: 23 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/NewObjectExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Rules.Framework.Rql.Tokens;

[ExcludeFromCodeCoverage]
internal class NewObjectExpression : Expression
{
public NewObjectExpression(Token @object, Expression[] propertyAssignements)
: base(@object.BeginPosition, propertyAssignements.LastOrDefault()?.EndPosition ?? @object.EndPosition)
{
this.Object = @object;
this.PropertyAssignments = propertyAssignements;
}

public Token Object { get; }

public Expression[] PropertyAssignments { get; }

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitNewObjectExpression(this);
}
}
15 changes: 15 additions & 0 deletions src/Rules.Framework.Rql/Ast/Expressions/NoneExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Rules.Framework.Rql.Ast.Expressions
{
using System.Diagnostics.CodeAnalysis;

[ExcludeFromCodeCoverage]
internal class NoneExpression : Expression
{
public NoneExpression()
: base(RqlSourcePosition.Empty, RqlSourcePosition.Empty)
{
}

public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.VisitNoneExpression(this);
}
}
Loading
Loading