Skip to content

Commit 0ee93dc

Browse files
authored
changes
changes
1 parent 78dd496 commit 0ee93dc

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

README.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# expression-evaluator
22

3-
> Expression Evaluator is built for C# .NET and will evaluate math, string and boolean arithmetic expressions given a language template.
3+
> Expression Evaluator is built for C# .NET and will evaluate math, string and boolean arithmetic expressions given an expression configuration. This can also be used to parse HL7 V2 Messages and more.
44
55
* [Overview](#overview)
66
* [Install](#install)
77
* [Usage](#usage)
88

99
<a name="overview"></a>
1010
## Overview
11-
This is a project written in C# that will, given a math, string or boolean expression, evaluate it using built-in Language Templates. Language Templates are what the Expression Evaluator uses when defining math, string, and boolean operators like '+', '-', '||', and so on. The operations are fully customizable. Using Language Templates you can hook into operator events before and after they're evaluated or evaluate the expression yourself with custom logic. The default language template is Python.
11+
This is a project written in C# that will, given a math, string or boolean expression, evaluate it using built-in Expression Configurations. Expression Configurations are what the Expression Evaluator uses when defining math, string, and boolean operators like '+', '-', '||', and so on. The operations are fully customizable. Using Expression Configurations you can hook into operator events before and after they're evaluated or evaluate the expression yourself with custom logic. The default expression configuration is Python.
1212

1313
Not Supported:
1414
* Single quotes (') as strings. You must use double quotes (") for strings. You can still use single quotes inside strings, and escaped double quotes.
@@ -86,14 +86,14 @@ Example #3: Single boolean value
8686
// Error = null
8787
```
8888

89-
To create your own LanguageTemplate, inherit from [LanguageTemplateBase](https://github.com/jmoceri34/expression-evaluator/blob/master/ExpressionEvaluator/Io.JoeMoceri.ExpressionEvaluator/LanguageTemplate/LanguageTemplateBase.cs#L5)
89+
To create your own ExpressionConfiguration, inherit from [ExpressionConfigurationBase](https://github.com/jmoceri34/expression-evaluator/blob/master/ExpressionEvaluator/Io.JoeMoceri.ExpressionEvaluator/ExpressionConfigurations/ExpressionConfigurationBase.cs#L5)
9090

91-
Please see Io.JoeMoceri.ExpressionEvaluator.Sample project for usage.
91+
Please see Io.JoeMoceri.ExpressionEvaluator.Sample project for more.
9292

9393
App.cs
9494

9595
```csharp
96-
using Io.JoeMoceri.ExpressionEvaluator.LanguageTemplate;
96+
using Io.JoeMoceri.ExpressionEvaluator.ExpressionConfiguration;
9797
using System;
9898
using System.Collections.Generic;
9999
using System.IO;
@@ -106,24 +106,46 @@ namespace Io.JoeMoceri.ExpressionEvaluator.Sample
106106
{
107107
ParseHL7FileExample();
108108

109+
// SolveMathExample();
110+
111+
// SolveBooleanExample();
112+
109113
Console.ReadLine();
110114
}
111115

116+
public void SolveMathExample()
117+
{
118+
var evaluator = new Evaluator();
119+
120+
var result = evaluator.Evaluate("1 + 2 * (3 - 4) / 18");
121+
122+
Console.WriteLine(result.ToString());
123+
}
124+
125+
public void SolveBooleanExample()
126+
{
127+
var evaluator = new Evaluator();
128+
129+
var result = evaluator.Evaluate("1 > 2 and (3 + 4) / 2 == 5");
130+
131+
Console.WriteLine(result.ToString());
132+
}
133+
112134
public void ParseHL7FileExample()
113135
{
114136
var lines = File.ReadLines("HL7File.txt");
115137

116-
var languageTemplate = new HL7V2LanguageTemplate();
138+
var expressionConfiguration = new HL7V2ExpressionConfiguration();
117139

118-
var evaluator = new Evaluator(languageTemplate);
140+
var evaluator = new Evaluator(expressionConfiguration);
119141

120142
var messageSegments = new List<HL7V2MessageSegment>();
121143

122144
foreach (var line in lines)
123145
{
124146
evaluator.Evaluate(line);
125147

126-
var messageSegment = languageTemplate.GetHL7V2MessageSegment();
148+
var messageSegment = expressionConfiguration.GetHL7V2MessageSegment();
127149

128150
Console.WriteLine(messageSegment.ToString());
129151

@@ -140,4 +162,5 @@ namespace Io.JoeMoceri.ExpressionEvaluator.Sample
140162
}
141163
}
142164

165+
143166
```

0 commit comments

Comments
 (0)