From fb05f52e8e1f33dda1f3e1986c133326a39b827b Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 16 Mar 2026 11:40:07 +0100 Subject: [PATCH] Mon 16 Mar 11:39:34 CET 2026 --- doc/control.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 doc/control.md diff --git a/doc/control.md b/doc/control.md new file mode 100644 index 0000000..a0d1ff8 --- /dev/null +++ b/doc/control.md @@ -0,0 +1,60 @@ +## Program Control + +### Statement block + +A statement block binds single statements enclosed in a curled paranthesis pair. +``` +{ Φ Φ Φ .. } +``` + +### Conditional Branches + +There is only a `if then else` statement branching to conditional statements. Conditional statements can be replaced by statement blocks, too. + +| Statement | Description | +|:--|:--| +| `if ε:Φ:Φ:.. ` | If expression ε is true (not equal 0), then the following line statements are executed. | +| `if ε then Φ:Φ:.. ` | If expression ε is true (not equal 0), then the following line statements are executed. | +| `if ε { Φ }` | If expression ε is true (not equal 0), then the following block statement is executed. | +| `if ε then { Φ }` | If expression ε is true (not equal 0), then the following block statement is executed. | +| `if ε Φ1 else Φ2` | If expression ε is true (not equal 0), then the following statement Φ1 is executed else Φ2. | +| `if ε { Φ1 } else { Φ1 }` | If expression ε is true (not equal 0), then the following block statement Φ1 is executed, else Φ2. | + + +### Loops + +There are conuting, conditional, and unconditional loops. Body statements can be replaced by statement blocks, too. + +| Statement | Description | F-Stack Frame | +|:--|:--| +| `for i = a,b: Φ: Φ: ..` | Counting loop starting with *i*=*a* and terminating with i=b. The default increment value is one. | F(b,control address,end address,'F') | +| `for i = a,b do Φ: Φ: ..` | Counting loop starting with *i*=*a* and terminating with i=b. The default increment value is one. | F(b,control address,end address,'F') | +| `for i = a,b,s: Φ: Φ: ..` | Counting loop starting with *i*=*a* and looping as long as *i*<=*b*. The increment value (step size) is *s*. | F(b,step,control address,end address,'F') | +| `while ε: Φ: Φ: ..` | Conditional loop checking the expression ε at start. | F(start address,end address, 'W') | +| `while ε do Φ: Φ: ..` | Conditional loop checking the expression ε at start. | F(start address,end address, 'W') | +| `do Φ: Φ: .. while ε` | Conditional loop checking the expression ε at end. | F(start address,end address, 'D') | +| `repeat Φ` | Endless (service) loop, but breakable. | F(start address,end address, 'D') | +| `break` | Leave current (innerst) loop | - | +| `continue` | Branch to end of loop body (starting new loop iteration) | - | + +### Functions and Procedures + +| Statement | Description | F-Stack Frame | +|:--|:--| +| `proc pname { Φ } ` | Defines a procedure (no arguments, no return value) | - | +| `func fname(a,b,c) { Φ } ` | Defines a function with arguments (a,b,c) and a return value. | - | +| `return` | Return from procedure call (no return value) | - | +| `return ε` | Return from function call with return value ε | - | +| `call pname` | Call procedure | F() | +| `call fname(ε,..)` | Call function without return value | F() | +| `x=call fname(ε,..)` | Call function (in expression) with return value | F() | + + +### Program Flow Control + +| Statement | Description | F-Stack Frame | +|:--|:--| +| `go` | Resume program | - | +| `stop` | Suspend program | - | + +