From 3a83ffb3665c508f1e5d23f7c39209eb76b1b62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Tue, 22 May 2018 19:48:09 +0300 Subject: [PATCH] Apparently I don't know Gogs' Markdown dialect --- ir.md | 61 ++++++++++++++++++++++++++++++++++-------------- optimizations.md | 24 +++++++++---------- 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/ir.md b/ir.md index 78d5714..bb586de 100644 --- a/ir.md +++ b/ir.md @@ -6,35 +6,48 @@ This is produced by `parse`. Each subsection shows the properties the command object of that type has in IR without offsets ### add -type | `add` -value | The number to add to current cell +property | value +---------|------ +type | `add` +value | The number to add to current cell Generated on `+` and `-` ### moveHead -type | `moveHead` -value | The number of steps to move the tape head right +property | value +---------|------ +type | `add` +type | `moveHead` +value | The number of steps to move the tape head right Generated on `<` and `>` ### writeByte -type | `writeByte` +property | value +---------|------ +type | `writeByte` Generated on `.` ### readByte -type | `readByte` +property | value +---------|------ +type | `readByte` Generated on `,` ### loop +property | value +---------|------ type | `loop` contents | An array of the commands making up the loop body Generated on `[`…`]` ### clear -type | `clear` +property | value +---------|------ +type | `clear` Not generated by the parser directly, but generated by optimizations @@ -46,27 +59,39 @@ subsection shows the properties the command object of that type has in IR with offsets ### add -type | `add` -value | The number to add to the cell -offfset | The location of the cell relative to current tape position +property | value +---------|------ +type | `add` +value | The number to add to the cell +offfset | The location of the cell relative to current tape position ### moveHead -type | `moveHead` -value | The number of steps to move the tape head right +property | value +---------|------ +type | `moveHead` +value | The number of steps to move the tape head right ### writeByte -type | `writeByte` -offset | The location of the cell relative to current tape position +property | value +---------|------ +type | `writeByte` +offset | The location of the cell relative to current tape position ### readByte -type | `readByte` -offset | The location of the cell relative to current tape position +property | value +---------|------ +type | `readByte` +offset | The location of the cell relative to current tape position ### loop +property | value +-----------|------ type | `loop` contents | An array of the commands making up the loop body isBalanced | Whether execution of the loop body ends in same cell it started in ### clear -type | `clear` -offset | The location of the cell relative to current tape position +property | value +---------|------ +type | `clear` +offset | The location of the cell relative to current tape position diff --git a/optimizations.md b/optimizations.md index 7e81057..b8d25bf 100644 --- a/optimizations.md +++ b/optimizations.md @@ -2,10 +2,10 @@ Gir has three optimization passes. joinAdjacentOps --------------- -consumes | commands without offsets -produces | commands without offsets -unknown commands | passed through unmodified -acts on | `moveHead`, `add` +* *consumes*: commands without offsets +* *produces*: commands without offsets +* *unknown commands*: passed through unmodified +* *acts on*: `moveHead`, `add` `joinAdjacentOps` joins adjacent `moveHead`s and `add`s together. Normally `parse` joins runs of `<>` or `+-` into one command, but if the runs are @@ -15,20 +15,20 @@ joins `add`s. transformClearLoops ------------------- -consumes | commands without offsets -produces | commands without offsets -unknown commands | passed through unmodified -acts on | `loop` with one command, which is `add 1` or `add -1` +* *consumes*: commands without offsets +* *produces*: commands without offsets +* *unknown commands*: passed through unmodified +* *acts on*: `loop` with one command, which is `add 1` or `add -1` `transformClearLoops` changes loops of the form `[-]` or `[+]` into a single `clear` command. addOffsetProperties ------------------- -consumes | commands without offsets -produces | commands with offsets -unknown commands | raise UnknownIRError -acts on | `moveHead`, `add`, `clear`, `writeByte`, `readByte`, `loop` +* *consumes*: commands without offsets +* *produces*: commands with offsets +* *unknown commands*: raise UnknownIRError +* *acts on*: `moveHead`, `add`, `clear`, `writeByte`, `readByte`, `loop` `addOffsetProperties` adds an `offset` property to `add`, `clear`, `writeByte`, and `readByte`. The `offset` tells the offset at which from the