Skip to content

Commit 42567fb

Browse files
authored
Update README.md
1 parent c4d0841 commit 42567fb

File tree

1 file changed

+179
-107
lines changed

1 file changed

+179
-107
lines changed

README.md

Lines changed: 179 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,7 @@ Please see [this](#examples) example with most of the simpleflow script features
6565
<let statements>*
6666
(<rule statements> or <emitters> or <functions> or <set>)*
6767
```
68-
##### Script Instructions
69-
* All `let` statements (declare and initialize variables) must be declared in the beginning of the script.
70-
* Each statement must end with a new line and each statement can be written in single line only.
71-
* `set` statement can be used to modify the value of variable that has been declared using let statement.
72-
* All keywords should be small (case sensitive) (`let, set, message, error, output, rule, when, then, exit, end rule, partial `)
73-
* variable names and function names are not case sensitive.
74-
* `end rule` can be used to terminate the rule scope.
75-
* `exit` can be used to terminate the script execution.
76-
* Function parameters need not be ordered as it defined. And function must prefix with $.
77-
78-
68+
7969

8070
## Simpleflow Reference
8171
<a name="simpleflow-reference"></a>
@@ -91,7 +81,7 @@ Please see [this](#examples) example with most of the simpleflow script features
9181
1. [Comment](#comment)
9282

9383

94-
#### Variables <a name="variables"></a>
84+
### Variables <a name="variables"></a>
9585
$\color{skyblue}{Syntax}$
9686
```fsharp
9787
let <variablename> = expression
@@ -104,58 +94,76 @@ $\color{skyblue}{Syntax}$
10494
[partial] set <variablename> = expression
10595
```
10696

107-
#### Data Types
108-
**Simple Types:**
109-
###### Number
110-
```csharp
111-
let x = 1
112-
let y = 2.3
113-
let z = -442.33
114-
```
115-
###### String
116-
```csharp
117-
let name = "test"
118-
```
119-
###### Boolean
120-
```csharp
121-
let hasValue = true
122-
let allow = false
123-
```
124-
###### Date
125-
Use date function to declare a variable as date type.
126-
```csharp
127-
let birthday = $date(y:1980, m: 1, d: 1 )
128-
```
129-
**Complex Types:**
130-
131-
Object type can be defined using JSON format. It does not support nested object syntax, but in order to set nested object, you can set to a variable and use it.
132-
```csharp
133-
let address = {city: 'ny'}
134-
let member = {name: 'alex', address: address }
135-
```
136-
137-
#### Operators
138-
139-
Arithmetic Operators: `+,-,*,/` <br>
140-
Logical Operators: `and, or, not` <br>
141-
Relational Operators: `<, <=, >, >=, == , !=`
142-
143-
#### Expressions
97+
### Data Types
98+
99+
<table>
100+
<tr>
101+
<th> Data Type </th>
102+
<th> Description/Examples</th>
103+
</tr>
104+
<tr>
105+
<td>Number</td>
106+
<td>
107+
<div>
108+
let x = 1 <br>
109+
let y = 2.3 <br>
110+
let z = -442.33 <br>
111+
</div>
112+
</td>
113+
</tr>
114+
<tr>
115+
<td>String</td>
116+
<td>
117+
let name = "test"
118+
</td>
119+
</tr>
120+
<tr>
121+
<td>Boolean</td>
122+
<td>
123+
let hasValue = true <br>
124+
let allow = false <br>
125+
</td>
126+
</tr>
127+
<tr>
128+
<td>Date</td>
129+
<td>
130+
Use date function to declare a variable as date type. <br>
131+
let birthday = $date(y:1980, m: 1, d: 1 )
132+
</td>
133+
</tr>
134+
<tr>
135+
<td>Object Type</td>
136+
<td>
137+
Object type can be defined using JSON format. It does not support nested object syntax, but in order to set
138+
nested object, you can set to a variable and use it. <br><br>
139+
let address = {city: 'ny'} <br>
140+
let member = {name: 'alex', address: address }
141+
</td>
142+
</tr>
143+
</table>
144+
145+
146+
147+
### Operators
148+
149+
| Operator Type | Operators |
150+
|---------------|-----------------------|
151+
| Arithmetic | +,-,*,/ |
152+
| Logical | and, or, not |
153+
| Relational | <, <=, >, >=, == , != |
154+
155+
### Expressions
144156
```csharp
145157
let v = 2 + 3 * (3 * arg.value);
146158
```
147159

148-
#### Script Parameters
160+
### Script Parameters
149161
`arg` and `context`
150162
`arg` represents the input to the script.
151163

152-
Context Properties:
153-
* context.HasErrors
154-
* context.HasMessages
155-
* context.HasOutput
156-
164+
**Context Properties:** context.HasErrors, context.HasMessages context.HasOutput
157165

158-
#### Rule Control Flow
166+
### Rule Control Flow
159167
$\color{skyblue}{Syntax}$
160168
```csharp
161169
rule when <predicate> then
@@ -168,63 +176,117 @@ rule when <predicate> then
168176
> <small> condition does not allow expression. If you need to write expression
169177
declare variable and write expression and use that variable in predicate. This does not support nested rules to avoid code complexity</small>
170178
179+
### Emitters
171180

172-
#### Emitters
181+
| Emitter Type | Syntax |
182+
|--------------|-----------------------------|
183+
| message | message <string/identifier> |
184+
| error | error <string/identifier> |
185+
| output | output <identifier> |
186+
| exit | exit |
173187

174-
$\color{skyblue}{Syntax}$
175-
```
176-
message <string/identifer>
177-
error <string/identifer>
178-
output <identifer>
179-
exit /*exit will terminate the execution*/
180-
```
181-
182-
183-
#### Functions
188+
### Functions
184189
$\color{skyblue}{Syntax}$
185190
```csharp
186191
$<function_name>(param_name1: value1, param_name2: value2, ...)
187192
```
188-
Function parameters can be written in any order. and if you omit a parameter it takes a default value of that type.
189-
Function cannot be an argument to another function. Store output of a function in a variable and use it.
190-
191-
###### Date Functions
192-
193-
* $\color{#4686f2}{\$Date(y: int, m: int, d: int, [h:int, mn: int, s: int])}$
194-
```csharp
195-
// Examples
196-
let d1 = $Date(y: 2022, m: 7, d:11)
197-
let d2 = $Date(m: 10, d:25, y: 2022 )
198-
let t1 = $Date(m: 10, d:25, y: 2022, h:13, mn:30 )
199-
```
200-
201-
* $\color{#4686f2}{\$GetCurrentDate()}$
202-
* $\color{#4686f2}{\$GetCurrentTime()}$
203-
* $\color{#4686f2}{\$GetCurrentDateTime(timeZone: "")}$
204-
205-
Check available list of time zones here: <br>
206-
Windows: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones <br>
207-
Ubuntu: https://manpages.ubuntu.com/manpages/bionic/man3/DateTime::TimeZone::Catalog.3pm.html <br>
208-
209-
```csharp
210-
let today = $GetCurrentDateTime()
211-
let todayEst = $GetCurrentDateTime ( timezone: "Eastern Standard Time" )
212-
```
213-
214-
###### String Functions
215-
* $\color{#4686f2}{\$Substring(input: string, startIndex:int, length: int)}$
216-
* $\color{#4686f2}{\$IndexOf(input: string, value:string, startIndex: int) }$
217-
* $\color{#4686f2}{\$Length(input: string) }$
218-
* $\color{#4686f2}{\$Contains(input: string, value:string) }$
219-
* $\color{#4686f2}{\$StartsWith(input: string, value:string) }$
220-
* $\color{#4686f2}{\$EndsWith(input: string, value:string) }$
221-
* $\color{#4686f2}{\$Trim(input: string, value:string) }$
222-
* $\color{#4686f2}{\$Match(input: string, pattern:string) }$
223-
* $\color{#4686f2}{\$Concat(value1: string, value2:string, value3:string, value4:string, value5:string)}$
224-
```csharp
225-
let value = $Concat ( value1: "I ", value2: "got it" )
226-
```
227-
#### Comment
193+
Function parameters can be written in any order. and if you omit a parameter it takes a default value of that type.
194+
Function cannot be an argument to another function. Store output of a function in a variable and use it.
195+
196+
<table>
197+
<tr>
198+
<th> Function </th>
199+
<th> Syntax/Examples</th>
200+
</tr>
201+
<tr>
202+
<td>Date</td>
203+
<td>
204+
<div>
205+
$\color{#4686f2}{\$Date(y: int, m: int, d: int, [h:int, mn: int, s: int])}$ <br>
206+
let d1 = $Date(y: 2022, m: 7, d:11) <br>
207+
let d2 = $Date(m: 10, d:25, y: 2022 ) <br>
208+
let t1 = $Date(m: 10, d:25, y: 2022, h:13, mn:30 ) <br>
209+
</div>
210+
</td>
211+
</tr>
212+
<tr>
213+
<td>GetCurrentDate</td>
214+
<td>
215+
$\color{#4686f2}{\$GetCurrentDate()}$
216+
</td>
217+
</tr>
218+
<tr>
219+
<td>GetCurrentTime</td>
220+
<td>
221+
$\color{#4686f2}{\$GetCurrentTime()}$
222+
</td>
223+
</tr>
224+
<tr>
225+
<td>GetCurrentDateTime</td>
226+
<td>
227+
$\color{#4686f2}{\$GetCurrentDateTime(timeZone: "")}$ <br>
228+
let today = $GetCurrentDateTime() <br>
229+
let todayEst = $GetCurrentDateTime ( timezone: "Eastern Standard Time" )
230+
</td>
231+
</tr>
232+
<tr>
233+
<td>Substring</td>
234+
<td>
235+
$\color{#4686f2}{\$Substring(input: string, startIndex:int, length: int)}$
236+
</td>
237+
</tr>
238+
<tr>
239+
<td>IndexOf</td>
240+
<td>
241+
$\color{#4686f2}{\$IndexOf(input: string, value:string, startIndex: int) }$
242+
</td>
243+
</tr>
244+
<tr>
245+
<td>Length</td>
246+
<td>
247+
$\color{#4686f2}{\$Length(input: string) }$
248+
</td>
249+
</tr>
250+
<tr>
251+
<td>Contains</td>
252+
<td>
253+
$\color{#4686f2}{\$Contains(input: string, value:string) }$
254+
</td>
255+
</tr>
256+
<tr>
257+
<td>StartsWith</td>
258+
<td>
259+
$\color{#4686f2}{\$StartsWith(input: string, value:string) }$
260+
</td>
261+
</tr>
262+
<tr>
263+
<td>EndsWith</td>
264+
<td>
265+
$\color{#4686f2}{\$EndsWith(input: string, value:string) }$
266+
</td>
267+
</tr>
268+
<tr>
269+
<td>Trim</td>
270+
<td>
271+
$\color{#4686f2}{\$Trim(input: string, value:string) }$
272+
</td>
273+
</tr>
274+
<tr>
275+
<td>Match</td>
276+
<td>
277+
$\color{#4686f2}{\$Match(input: string, pattern:string) }$
278+
</td>
279+
</tr>
280+
<tr>
281+
<td>Concat</td>
282+
<td>
283+
$\color{#4686f2}{\$Concat(value1: string, value2:string, value3:string, value4:string, value5:string)}$ <br>
284+
let value = $Concat ( value1: "I ", value2: "got it" )
285+
</td>
286+
</tr>
287+
</table>
288+
289+
### Comment
228290
It supports only one style of comment can be used for single or multiline using /* .. */
229291
```csharp
230292
/* Write your comment here */
@@ -397,6 +459,16 @@ var userId = result.Output["userId"];
397459
```
398460

399461

462+
### Script Guidelines
463+
* All `let` statements (declare and initialize variables) must be declared in the beginning of the script.
464+
* Each statement must end with a new line and each statement can be written in single line only.
465+
* `set` statement can be used to modify the value of variable that has been declared using let statement.
466+
* All keywords should be small (case sensitive) (`let, set, message, error, output, rule, when, then, exit, end rule, partial `)
467+
* variable names and function names are not case sensitive.
468+
* `end rule` can be used to terminate the rule scope.
469+
* `exit` can be used to terminate the script execution.
470+
* Function parameters need not be ordered as it defined. And function must prefix with $.
471+
400472

401473
## Limitations
402474
* Each statement can only be written in singleline. Currently It does not support multiline statement.

0 commit comments

Comments
 (0)