Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ using Simpleflow;
var script =
@"
# Declare and initialize variables
let text = 'Hello, World! 🌄'
let today = $GetCurrentDateTime ( timezone: 'Eastern Standard Time' )
let today = $GetCurrentDate()

# Write rules
rule when arg.UniversalId == 2 and (arg.New or arg.Verified) then
message text
rule when arg.UniversalId == 2
and (arg.New or arg.Verified) then
message 'Hello, World! 🌄'
end rule

# Output
Expand Down
9 changes: 5 additions & 4 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ class Build : NukeBuild
.SetTitle("Simpleflow")
.SetAuthors("navtech.io")
.SetCopyright("navtech.io")
.SetPackageProjectUrl("https://github.com/navtech-io/Simpleflow")
.SetPackageProjectUrl("https://navtech-io.github.io/Simpleflow/")
.SetRepositoryUrl("https://github.com/navtech-io/Simpleflow")
.AddProperty("PackageLicenseExpression", "Apache-2.0")
.AddProperty("PackageIcon", @"PackageIcon.png")
.SetPackageRequireLicenseAcceptance(true)
.SetIncludeSymbols(true)
.SetDescription("A .NET library and a runtime engine to execute dynamic rules and workflows with intuitive and simple Simpleflow scripting language.")
.SetPackageTags("Simpleflow.NET Workflow RuleEngine DynamicValidations DynamicExpressionEvaluator")
.SetDescription("A .NET library and a runtime engine to execute dynamic rules and workflows with intuitive and simple declarative Simpleflow scripting language.")
.SetPackageTags("Simpleflow.NET Workflow Rule-Engine Dynamic-Validations Dynamic-Expression-Evaluator")
.SetNoDependencies(true)
.SetOutputDirectory(ArtifactsDirectory / "nuget"));
.SetOutputDirectory(ArtifactsDirectory / "nuget")); ;
});

Target Publish => _ => _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ namespace Simpleflow.CodeGenerator
partial class SimpleflowCodeVisitor<TArg>
{

public override Expression VisitUniaryPlusExpression([NotNull] SimpleflowParser.UniaryPlusExpressionContext context)
{
return Expression.UnaryPlus(Visit(context.expression()));
}

public override Expression VisitUniaryMinusExpression([NotNull] SimpleflowParser.UniaryMinusExpressionContext context)
{
return Expression.Negate(Visit(context.expression()));
}

public override Expression VisitMultiplicativeExpression([NotNull] SimpleflowParser.MultiplicativeExpressionContext context)
{
var symbolNode = (ITerminalNode)context.GetChild(1); // exp(0) operator(1) exp(2)
Expand Down
8 changes: 4 additions & 4 deletions src/Simpleflow/CodeGenerator/SimpleflowCodeVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public SimpleflowCodeVisitor(IFunctionRegister functionRegister, ParserEventPubl
InputParam = Expression.Parameter(typeof(TArg));
OutputParam = Expression.Parameter(typeof(FlowOutput));
// use context parameter name in order to access in script
ScriptHelperContextParam = Expression.Parameter(typeof(ScriptHelperContext));
ScriptHelperContextParam = Expression.Parameter(typeof(RuntimeContext));

/* A label expression of the void type that is the target for Expression.Return(). */
TargetLabelToExitFunction = Expression.Label();
Expand All @@ -67,8 +67,8 @@ public override Expression VisitProgram(SimpleflowParser.ProgramContext context)
Expression body = Expression.Block(Variables, statementExpressions);

/* Create function with input and output parameters */
Expression<Action<TArg, FlowOutput, ScriptHelperContext>> program =
Expression.Lambda<Action<TArg /*input-context*/, FlowOutput, ScriptHelperContext>>(
Expression<Action<TArg, FlowOutput, RuntimeContext>> program =
Expression.Lambda<Action<TArg /*input-context*/, FlowOutput, RuntimeContext>>(
body,
new ParameterExpression[] { InputParam, OutputParam, ScriptHelperContextParam }
);
Expand Down Expand Up @@ -234,7 +234,7 @@ private void ReplaceVirtualSmartVariablesWithReal(List<Expression> statementExpr
private List<Expression> CreateDefaultVariablesAndAssign()
{
var argVar = Expression.Variable(typeof(TArg), "arg");
var contextVar = Expression.Variable(typeof(ScriptHelperContext), "context");
var contextVar = Expression.Variable(typeof(RuntimeContext), "context");

Variables.Add(argVar);
Variables.Add(contextVar);
Expand Down
4 changes: 2 additions & 2 deletions src/Simpleflow/CodeGenerator/SimpleflowCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Simpleflow.CodeGenerator
{
internal class SimpleflowCompiler
{
internal static Action<TArg, FlowOutput, ScriptHelperContext> Compile<TArg>(string code,
internal static Action<TArg, FlowOutput, RuntimeContext> Compile<TArg>(string code,
IFunctionRegister activityRegister,
ParserEventPublisher eventPublisher)
{
Expand All @@ -31,7 +31,7 @@ internal static Action<TArg, FlowOutput, ScriptHelperContext> Compile<TArg>(stri
var program = visitor.Visit(programContext);

// Compile
var programExpression = (Expression<Action<TArg, FlowOutput, ScriptHelperContext>>)program;
var programExpression = (Expression<Action<TArg, FlowOutput, RuntimeContext>>)program;
return programExpression.CompileFast();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Simpleflow/FlowContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void EnableTrace()

public class FlowInternals
{
public Action<TArg, FlowOutput, ScriptHelperContext> CompiledScript { get; set; }
public Action<TArg, FlowOutput, RuntimeContext> CompiledScript { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion src/Simpleflow/Parser/Grammar/SimpleflowLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Not: 'not';
// Literals
True: 'true';
False: 'false';
Number: ('+'|'-')?[0-9]+('.'[0-9]+)?;
Number: [0-9]+('.'[0-9]+)?;

String: '"' ( '\\"' | ~["\r\n] )*? '"'
| '\'' ( '\\\'' | ~['\r\n] )*? '\'' ;
Expand Down
6 changes: 4 additions & 2 deletions src/Simpleflow/Parser/Grammar/SimpleflowParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ exitStmt
;

expression
: expression (TimesOp | DivOp | ModuloOp) expression #MultiplicativeExpression
: PlusOp expression #UniaryPlusExpression
| MinusOp expression #UniaryMinusExpression
| Not expression #NotExpression
| expression (TimesOp | DivOp | ModuloOp) expression #MultiplicativeExpression
| expression (PlusOp | MinusOp) expression #AdditiveExpression
| expression ( GreaterThan
| LessThan
Expand All @@ -71,7 +74,6 @@ expression
| NotEqual
) expression #RelationalExpression
| expression (And | Or ) expression #LogicalExpression
| Not expression #NotExpression
| objectIdentifier #ObjectIdentiferExpression
| simpleLiteral #SimpleLiteralExpression
| arrayLiteral #ArrayLiteralExpression
Expand Down
Loading