diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/1.md | 40 |
1 files changed, 35 insertions, 5 deletions
@@ -131,22 +131,22 @@ For if, else, loop, and match any inputs and/or outputs are a semicolon-separate Examples: # simple if block - /; if ( <statement resolving in boolean value> ) + /; if ( <conditional> ) <statements> ;/ # if block with else and else if - /; if ( <statement (optional)> ; <statement (optional)> ; ... ; <statement resolving in boolean value> ) + /; if ( <statements (optional)> ; ... ; <conditional> ) <statements> - ;; else if ( <statement resolving in boolean value> ) + ;; else if ( <statements (optional)> ; ... ; <conditional> ) <statements> ;; else <statements> ;/ # loop block - /; loop ( <statement (optional)> ; ... ; <statement resolving in boolean value (optional)> ) - [ <statements to be evaluated on loop (optional)> ] + /; loop ( <statements (optional)> ; ... ; <conditional (optional)> ) + [ <statements (optional)> ; ... ; <conditional (optional)> ] <statements> ;/ @@ -164,6 +164,36 @@ Examples: ;/ ;/ +### Loops + +The `loop` block can be configured (based on weather or not each boolean statement is omitted) to act as any type of loop. + +The *first* conditional is the **initial run condition**. It decides weather the loop is entered at all. If omitted, defaults to `true`, creating a `do ... while` type block. + +The *second* conditional is the **subsequent run condition**. It decides weather the loop continues to loop or not. If omitted, it *mirrors* the **initial run condition** (this is equivalent to a `for` or `while` block). + +Examples: + + # Same as a do ... while block + /; loop [ <conditional> ] + <statements> + ;/ + + # Same as a while loop + /; loop ( <conditional> ) + <statements> + ;/ + + # Infinite loop + /; loop + <statements> + ;/ + + # Adding statements to mimic a for loop + /; loop (int i = 0; i < 10) [i++] + <statements> + ;/ + ## Section 3 - Statements ### TNSL Statement Notation |