summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'content/fate_v1/instructions')
-rw-r--r--content/fate_v1/instructions/_index.md48
-rw-r--r--content/fate_v1/instructions/collections/_index.md72
-rw-r--r--content/fate_v1/instructions/conditionals/_index.md27
-rw-r--r--content/fate_v1/instructions/loops/_index.md34
-rw-r--r--content/fate_v1/instructions/player_choices/_index.md31
-rw-r--r--content/fate_v1/instructions/references/_index.md7
6 files changed, 219 insertions, 0 deletions
diff --git a/content/fate_v1/instructions/_index.md b/content/fate_v1/instructions/_index.md
new file mode 100644
index 0000000..51066d1
--- /dev/null
+++ b/content/fate_v1/instructions/_index.md
@@ -0,0 +1,48 @@
+---
+title: Instructions
+---
+Instructions do not return values, but modify the memory in some way or
+interact with the interpreter. Computations are valid instructions, and will be
+automatically converted into `[TEXT]` to be displayed.
+
+### ASSERT
+{{< fatecode >}}(assert [BOOL] [TEXT]){{< /fatecode >}}
+
+Raises the exception `[TEXT]` to the interpreter if `[BOOL]` yields
+false.
+
+### DONE
+{{< fatecode >}}(done){{< /fatecode >}}
+
+Completes the execution of the current sequence.
+
+### END
+{{< fatecode >}}(end){{< /fatecode >}}
+
+Completes the execution of the script.
+
+### SET VALUE
+{{< fatecode >}}(set [REFERENCE] [COMPUTATION]){{< /fatecode >}}
+
+Gives the value `[COMPUTATION]` to `[REFERENCE]`.
+
+### VISIT SEQUENCE
+{{< fatecode >}}(visit {String} [C0 = COMPUTATION] ... [CN = COMPUTATION]){{< /fatecode >}}
+
+Visits the sequence named `{String}`, with `C0` ... `CN` as arguments. That
+sequence does not need to already have been defined. Visiting a sequence means
+that the execution of the current sequence continues once the visited sequence
+has completed.
+
+### JUMP TO SEQUENCE
+{{< fatecode >}}(jump_to {String} [C0 = COMPUTATION] ... [CN = COMPUTATION]){{< /fatecode >}}
+
+Jumps to the sequence named `{String}`, with `C0` ... `CN` as arguments. That
+sequence does not need to already have been defined. Jumping to a sequence means
+that the execution of the current sequence is replaced by that of the target
+sequence.
+
+### INSTRUCTION LIST
+{{< fatecode >}}([C0 = INSTRUCTION] ... [CN = INSTRUCTION]){{< /fatecode >}}
+
+Instruction corresponding to the execution of `[C0]` ... `[CN]` in order.
diff --git a/content/fate_v1/instructions/collections/_index.md b/content/fate_v1/instructions/collections/_index.md
new file mode 100644
index 0000000..8d646ee
--- /dev/null
+++ b/content/fate_v1/instructions/collections/_index.md
@@ -0,0 +1,72 @@
+---
+title: Collections
+---
+Fate supports two types of collections: `[LIST]`, which are basic, unordered
+lists; and `[SET]`, which are ordered lists, but only useable with
+`[COMPARABLE]` elements.
+
+### ADDING A MEMBER
+{{< fatecode >}}(add_element! [COMPUTATION*] [COLLECTION VAR]){{< /fatecode >}}
+
+Adds `[COMPUTATION*]` to `[COLLECTION VAR]`. If `[COLLECTION VAR]` is a
+`[LIST]`, the new member is added at the end of the list. Note that
+`[COMPUTATION*]` does not support use of the variable shorthand.
+
+### ADDING A MEMBER AT INDEX
+{{< fatecode >}}(add_element_at! [INT] [COMPUTATION*] [LIST VAR]){{< /fatecode >}}
+
+Adds `[COMPUTATION*]` to `[LIST VAR]` at index `[INT]`. If `[INT]` is less than
+0, the element is added at the start of the list, and if `[INT]` is greater or
+equal to the size of the list, the element is added at the end of the list. Note
+that `[COMPUTATION*]` does not support use of the variable shorthand.
+
+### ADDING MEMBERS
+{{< fatecode >}}(add_all_elements! [COLLECTION] [COLLECTION VAR]){{< /fatecode >}}
+
+Adds all the elements of `[COLLECTION]` to `[COLLECTION VAR]`. If
+`[COLLECTION VAR]` is a `[LIST]`, the new members are added at the end of the
+list.
+
+### EMPTYING COLLECTIONS
+{{< fatecode >}}(clear [COLLECTION]){{< /fatecode >}}
+
+Removes all members of `[COLLECTION]`.
+
+### REMOVING MEMBER
+{{< fatecode >}}(remove [COMPUTATION] [COLLECTION]){{< /fatecode >}}
+
+Removes the first member of `[COLLECTION]` equal to `[COMPUTATION]`.
+
+### REMOVING MEMBERS
+{{< fatecode >}}(remove_all [COMPUTATION] [COLLECTION]){{< /fatecode >}}
+
+Removes all instances of `[COMPUTATION]` from `[COLLECTION]`.
+
+### REMOVING AT INDEX
+{{< fatecode >}}(remove_at [INT] [COLLECTION]){{< /fatecode >}}
+
+Removes the element of `[COLLECTION]` at `[INT]`.
+
+### REVERSING LISTS
+{{< fatecode >}}(reverse [LIST]){{< /fatecode >}}
+
+Reverses the order of the members of `[LIST]`.
+
+### FILTER ELEMENTS
+{{< fatecode >}}(filter! <LAMBDA BOOL (X)> [X COLLECTION VAR]){{< /fatecode >}}
+{{< fatecode >}}(filter! <LAMBDA BOOL (X Y0 ... YN)> [X COLLECTION VAR] [Y0 COMPUTATION*] ... [YN COMPUTATION*]){{< /fatecode >}}
+Modifies `[X COLLECTION VAR]` so that only the elements for which
+`<LAMBDA BOOL (X)>` returns `true` remain. If the lambda function needs extra
+parameters, use the second syntax, which adds those parameters at the end of the
+`(filter! ...)` call. Note that the variable shorthand cannot be used for these
+extra parameters.
+
+### FILTER ELEMENTS (INDEXED)
+{{< fatecode >}}(indexed_filter! <LAMBDA BOOL (INT X)> [X COLLECTION VAR]){{< /fatecode >}}
+{{< fatecode >}}(indexed_filter! <LAMBDA BOOL (INT X Y0 ... YN)> [X COLLECTION VAR] [Y0 COMPUTATION*] ... [YN COMPUTATION*]){{< /fatecode >}}
+Modifies `[X COLLECTION VAR]` so that only the elements for which
+`<LAMBDA BOOL (INT X)>` (with the `INT` being the element's index) returns
+`true` remain. If the lambda function needs extra parameters, use the second
+syntax, which adds those parameters at the end of the `(indexed_filter! ...)`
+call. Note that the variable shorthand cannot be used for these extra
+parameters.
diff --git a/content/fate_v1/instructions/conditionals/_index.md b/content/fate_v1/instructions/conditionals/_index.md
new file mode 100644
index 0000000..e129b1b
--- /dev/null
+++ b/content/fate_v1/instructions/conditionals/_index.md
@@ -0,0 +1,27 @@
+---
+title: Conditionals
+---
+Allow the control of whether to execute instructions or not according to a
+computation. Every conditional branch defines its hierarchy level, from the
+local variables' point of view.
+
+### IF
+{{< fatecode >}}(if [BOOL] [INSTRUCTION]){{< /fatecode >}}
+
+Executes `[INSTRUCTION]` if, and only if, `[BOOL]` yields true.
+
+### IF-ELSE
+{{< fatecode >}}(if_else [BOOL] <IF_TRUE = INSTRUCTION> <IF_FALSE = INSTRUCTION>){{< /fatecode >}}
+
+Executes `<IF_TRUE>` if `[BOOL]` yields true, but `<IF_FALSE>` if it does not.
+
+### COND
+{{< fatecode >}}(cond ([C0 = BOOL] [I0 = INSTRUCTION]) ... ([CN = BOOL] [IN = INSTRUCTION])){{< /fatecode >}}
+
+Executes `[II]`, such that `[CI]` is the first listed boolean to yield true.
+
+### SWITCH
+{{< fatecode >}}(switch [T = COMPUTATION] ([C0 = COMPUTATION] [I0 = INSTRUCTION]) ... ([CN = COMPUTATION] [IN = INSTRUCTION]) [DEFAULT = INSTRUCTION]){{< /fatecode >}}
+
+Executes `[II]`, such that `[CI]` is the first listed computation to be equal
+to `[T]`. Executes `[DEFAULT]` if there is no such `[CI]`.
diff --git a/content/fate_v1/instructions/loops/_index.md b/content/fate_v1/instructions/loops/_index.md
new file mode 100644
index 0000000..03c0f3b
--- /dev/null
+++ b/content/fate_v1/instructions/loops/_index.md
@@ -0,0 +1,34 @@
+---
+title: Loops
+---
+Allow the repetition of a group of instructions according to a computation.
+Every loop body defines its hierarchy level, from the local variables' point of
+view.
+
+### WHILE
+{{< fatecode >}}(while [BOOL] [I0 = INSTRUCTION] ... [IM = INSTRUCTION]){{< /fatecode >}}
+
+Executes `[I0]` ... `[IM]` if, and as long as, `[BOOL]` yields true.
+
+### DO WHILE
+{{< fatecode >}}(do_while [BOOL] [I0 = INSTRUCTION] ... [IM = INSTRUCTION]){{< /fatecode >}}
+
+Executes `[I0]` ... `[IM]`, and does so again as long as, `[BOOL]` yields
+true.
+
+### FOR
+{{< fatecode >}}(for <pre = INSTRUCTION> [BOOL] <post = INSTRUCTION> [I0 = INSTRUCTION] ... [IM = INSTRUCTION]){{< /fatecode >}}
+
+Executes `<pre>`, then, if and as long as `[BOOL]` yields true, executes
+`[I0]` ... `[IM]` followed by `<post>`.
+
+### FOR EACH
+{{< fatecode >}}(foreach [COLLECTION] {String} [I0 = INSTRUCTION] ... [IM = INSTRUCTION]){{< /fatecode >}}
+
+Executes `[I0]` ... `[IM]` for each member of `[COLLECTION]`, in order. The current
+member is stored in a new local variable named `{String}`.
+
+### BREAK
+{{< fatecode >}}(break){{< /fatecode >}}
+
+Exits the current loop.
diff --git a/content/fate_v1/instructions/player_choices/_index.md b/content/fate_v1/instructions/player_choices/_index.md
new file mode 100644
index 0000000..a0dba20
--- /dev/null
+++ b/content/fate_v1/instructions/player_choices/_index.md
@@ -0,0 +1,31 @@
+---
+title: Player Choices
+---
+Player choices are the main way to interact with the user, by presenting them
+with a list of `[RICH TEXT]` choices, and executing a list of instructions
+associated to the choice they have made.
+
+### CHOICE OPTION
+{{< fatecode >}}([TEXT] [I0 = INSTRUCTION] ... [IN = INSTRUCTION]){{< /fatecode >}}
+
+Adds a choice showing `[RICH TEXT]` to the user, and executing `[I0]` ... `[IN]`
+if chosen.
+
+### CHOICE PROMPT
+{{< fatecode >}}(player_choice [C0 = CHOICE] ... [C1 = CHOICE]){{< /fatecode >}}
+
+Prompts the user to choose between `C0` ... `C1`. `[CHOICE]`. `[CHOICE]` is
+either an option as shown above, a [conditional](../conditionals), or a
+`for_each` (see [loops](../loops)) with `[CHOICE]` instead of `[INSTRUCTION]`.
+
+### INTEGER PROMPT
+{{< fatecode >}}(prompt_integer [INT REFERENCE] [MIN = INT] [MAX = INT] [TEXT]){{< /fatecode >}}
+
+Prompts the user for an integer between `[MIN]` and `[MAX]` by displaying the
+message `[TEXT]`. The result is stored in `[INT REFERENCE]`.
+
+### STRING PROMPT
+{{< fatecode >}}(prompt_string [STRING REFERENCE] [MIN = INT] [MAX = INT] [TEXT]){{< /fatecode >}}
+
+Prompts the user for a string of size between `[MIN]` and `[MAX]` by displaying
+the message `[TEXT]`. The result is stored in `[STRING REFERENCE]`.
diff --git a/content/fate_v1/instructions/references/_index.md b/content/fate_v1/instructions/references/_index.md
new file mode 100644
index 0000000..9beb132
--- /dev/null
+++ b/content/fate_v1/instructions/references/_index.md
@@ -0,0 +1,7 @@
+---
+title: References
+---
+### DE-ALLOCATION
+{{< fatecode >}}(free [POINTER]){{< /fatecode >}}
+
+Removes the memory element at `[POINTER]` from the memory.