From 6d2610ebcd25ce12a2c9e22717a20d7772f991f0 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 19 Jan 2022 19:55:42 +0100 Subject: ... --- content/wyrd_v1/computation/_index.md | 125 ++++++++++++++++++++++++++- content/wyrd_v1/input/_index.md | 68 +++++++++++++++ content/wyrd_v1/instruction_result/_index.md | 35 ++++++++ content/wyrd_v1/value/_index.md | 15 ++-- dia/wyrd_values.drawio | 1 + static/images/wyrd_values.drawio.svg | 4 + 6 files changed, 240 insertions(+), 8 deletions(-) create mode 100755 dia/wyrd_values.drawio create mode 100755 static/images/wyrd_values.drawio.svg diff --git a/content/wyrd_v1/computation/_index.md b/content/wyrd_v1/computation/_index.md index d0462a0..af00546 100644 --- a/content/wyrd_v1/computation/_index.md +++ b/content/wyrd_v1/computation/_index.md @@ -5,6 +5,7 @@ weight: 3 --- This page presents all the ``s that can be performed in Wyrd. ``s do not modify the memory, but they always return a ``. +Be careful not to modify the memory through reference when computing values. **Shortcut to each ``:** * [`(add_text_effect {name: String} {parameters: List} {values: list})`](#add_text_effect) @@ -103,77 +104,195 @@ The following conversions are expected to be available: ### constant `(constant {type: String} {value: String})` +Constant value. + **Parameters:** +* `type` is a `{String}` indicating the type the other parameter should be + converted to. +* `value` is a `{String}` representation of the value that should be returned. **Process:** +* Parse the value of `value` according to `type`. +* Return the corresponding ``. + +**Notes:** +The `type` parameter can take the following values: `"string"`, `"float"`, + `"int"`, and `"bool"`. ### get_allocable_address `(get_allocable_address)` +Get an allocable address. + **Process:** +* Return an `` corresponding to an unused address. + +**Notes:** +Process when using the suggested `` definition: +* If the ``'s `freed_addresses` collection has elements, return a +`` corresponding to one of its elements. +* Otherwise, create a string `addr` corresponding to `".alloc."` to which the + ``'s `allocated_data` integer has been added then return a new + `` with a singleton list containing `addr`. +As a reminder, `` is not modified by the procedure. ### if_else `(if_else )` **Parameters:** +* `condition` is a `` that will indicate which other computation to + consider. +* `if_true` is a `` that will be considered only if the `condition` + is verified. +* `if_false` is a `` that will be considered only if the `condition` + is not verified. **Process:** +* Compute the `` resulting from `condition`. +* Interpret this `` as a `{Boolean}`. +* If it yielded `TRUE`, compute and return the `` resulting from + `if_true`, otherwise, compute and return the `` resulting from + `if_false`. ### last_choice_index `(last_choice_index)` +Get the index of the user's last chosen option. + **Process:** +* Return an `` corresponding to the ``'s `last_choice_index`. ### newline `(newline)` +Return a newline value. + **Process:** +* Return a `` corresponding to a newline. ### Unary operation `(operation {operator: String} )` -**Parameters:** - -**Process:** +Interpret as `(operation operator x (BoolValue FALSE))`. It is recommended to +have the parser do that conversion automatically. ### operation `(operation {operator: String} )` +Performs a basic operation. + **Parameters:** +* `operator` is the name of the operation. +* `x` is the first operand. +* `y` is the second operand. **Process:** +* Compute `` and ``, the `` corresponding to + `x` and `y`, respectively. +* See the *Notes* below for which operators are expected. +* Return the result of the operation. + +**Notes:** +`val_x` and `val_y` always have the same type. If the returned value is a +number, it has the same type as `val_x` and `val_y`. Number types are +`` and ``. Comparable types are ``, +``, ``, ``, and ``. + +*Operands are numbers, returns number*: +* `divide`, returning the value corresponding to `val_x` divided by `val_y`. + This is an integer division if and only if `val_x` is an integer. +* `minus`, returning the value corresponding to `val_x` minus `val_y`. +* `plus`, returning the value corresponding to `val_x` plus `val_y`. +* `power`, returning the value corresponding to `val_x` to the power `val_y`. +* `times`, returning the value corresponding to `val_x` times `val_y`. + +*Operands are ``s, returns ``:* +* `modulo`, returning the value corresponding to `val_x` modulo `val_y`. + +*Operands are ``s, returns ``:* +* `and`, returning `(BoolValue TRUE)` if both `val_x` and `val_y` are + `(BoolValue TRUE)`, `(BoolValue FALSE)` otherwise. Do not evaluate `val_y` if + `val_x` yielded `(BoolBalue FALSE)` (lazy evaluation). +* `not`, returning `(BoolValue TRUE)` if `val_x` is `(BoolValue FALSE)`. + Otherwise, return `(BoolValue FALSE)`. + +*Operands are comparable, returns ``:* +* `less_than` returning `(BoolValue TRUE)` if `val_x` is less than `val_y` and + `(BoolType FALSE)` otherwise. `(BoolType FALSE)` is less than + `(BoolType TRUE)`. ``s can be compared by comparing the strings + corresponding to having joined all elements in their respective string lists. + +*Operands can be any type, returns ``:* +* `equals` returns `(BoolValue TRUE)` if `val_x` has the same value as `val_y`, + `(BoolType FALSE)` otherwise. Be sure to compare values and not identity + (value vs reference). ### relative_address `(relative_address )` +Appends to an address. + **Parameters:** +* `target` is a `` that will yield the base address to extend. +* `extra` is a `` corresponding to the `` element to + add to the address. **Process:** +* Compute the `` corresponding to `target`. +* Compute the `` corresponding to `extra`. +* Return a new `` corresponding to the previous ``, + but with its list of strings now having been extended by the addition of the + string equivalent to that ``. ### size `(size )` +Computes the size of a list. + **Parameters:** +* `target` is a `` that will yield a `` pointing to + a ``. **Process:** +* Compute the `` yielded by `target`. +* Return a new `` corresponding to the number of elements in the + `` pointed to by that ``. ### text `(text {values: List})` +Merges a list of text values into a single one. + **Parameters:** +* `values` is a list of ``s that will yield ``s. **Process:** +* Compute the `` corresponding ot each element of `values`. +* Return a new `` corresponding to these `` appended one + after the next. ### value_of `(value_of )` +Retries the value from memory. + **Parameters:** +* `target` is a `` that will yield the address of the memory + element to get the value of. **Process:** +* Compute the value of `target`. +* Return the `` pointed to by `target` in the ``'s `memory`. ### extra_computation `({extra_computation} {parameters: List})` +Performs non-standard computation. + **Parameters:** +* `extra_computation` is the name of the extra computation. +* `parameters` is a list of parameters for this computation call. **Process:** +* Undetermined. This is where you choose the process according to the value of + `extra_computation` so that you can add non-standard computations. diff --git a/content/wyrd_v1/input/_index.md b/content/wyrd_v1/input/_index.md index d6bbc87..bc5b22f 100644 --- a/content/wyrd_v1/input/_index.md +++ b/content/wyrd_v1/input/_index.md @@ -3,3 +3,71 @@ menuTitle: title: Input weight: 6 --- + +Following an `` having set the ``'s +`last_instruction_effect` to +`(MUST_PROMPT_COMMAND )`, +`(MUST_PROMPT_INTEGER )`, +`(MUST_PROMPT_FLOAT )`, +`(MUST_PROMPT_STRING )`, +or `(MUST_INPUT_CHOICE)`, it is necessary +for the user to provide an input prior to further ``s being +executed. The information provided in the `` is expected +to be sufficient for the interpreter to ensure the user input is valid. +Providing invalid inputs to the `` will result in undefined (and most +likely problematic) behaviors. + +Thus, the `` should expect to accept the following types of inputs: +### An `{Integer}` prompt answer +This follows a +`(MUST_PROMPT_INTEGER )` +``. +* Interpret the ``'s `memorized_target` as a + `` address. +* Update the `` pointed to by this address in the ``'s memory + so that it becomes an `` corresponding to the user's input. +* Set the ``'s `last_instruction_effect` to `(MUST_CONTINUE)`. +* Proceed with the execution. + +### A `{Float}` prompt answer +This follows a +`(MUST_PROMPT_FLOAT )` +``. +* Interpret the ``'s `memorized_target` as a + `` address. +* Update the `` pointed to by this address in the ``'s memory + so that it becomes an `` corresponding to the user's input. +* Set the ``'s `last_instruction_effect` to `(MUST_CONTINUE)`. +* Proceed with the execution. + +### A `{String}` prompt answer +This follows a +`(MUST_PROMPT_STRING )` +``. +* Interpret the ``'s `memorized_target` as a + `` address. +* Update the `` pointed to by this address in the ``'s memory + so that it becomes an `` corresponding to the user's input. +* Set the ``'s `last_instruction_effect` to `(MUST_CONTINUE)`. +* Proceed with the execution. + +### A `{{String} List}` prompt answer +This follows a +`(MUST_PROMPT_COMMAND )` ``. +* Interpret the ``'s `memorized_target` as a + `` address. +* Convert the user input to a ``: For each element of value +`{s: String}` and index `{i: Integer}`, the `` contains +`{{c_i: String} -> }` where `c_i` is a `{String}` +corresponding to `i` and `c_s` a `` corresponding to `s`. +* Update the `` pointed to by this address in the ``'s memory + so that it becomes the aforementioned ``. +* Set the ``'s `last_instruction_effect` to `(MUST_CONTINUE)`. +* Proceed with the execution. + +### An `{Integer}` choice answer +This follows a `(MUST_INPUT_CHOICE)` ``. +* Set the ``'s `last_choice_index` to the input `{Integer}`. +* Empty the ``'s `available_options` list. +* Set the ``'s `last_instruction_effect` to `(MUST_CONTINUE)`. +* Proceed with the execution. diff --git a/content/wyrd_v1/instruction_result/_index.md b/content/wyrd_v1/instruction_result/_index.md index b77b496..ac585fc 100644 --- a/content/wyrd_v1/instruction_result/_index.md +++ b/content/wyrd_v1/instruction_result/_index.md @@ -3,3 +3,38 @@ menuTitle: title: Instruction Result weight: 5 --- +Following the execution of an ``, the `` will see its +`last_instruction_effect` be set to one of the following values: + +* `(MUST_CONTINUE)`, indicating that the next `` should be + executed. +* `(MUST_END)`, indicating that the story has ended. No further ``s + should be executed. +* `(MUST_PROMPT_COMMAND )`, + indicating that an input should be given before executing further + ``s. In this case, the execution should be done only after the + user has seen `msg` and input a command (space separated list of strings) + totaling between `min` and `max` characters (spaces included). +* `(MUST_PROMPT_FLOAT ))`, + indicating that an input should be given before executing further + ``s. In this case, the execution should be done only after the + user has seen `msg` and input a float value included between `min` and `max`. +* `(MUST_PROMPT_INTEGER ))`, + indicating that an input should be given before executing further + ``s. In this case, the execution should be done only after the + user has seen `msg` and input an integer value included between `min` and + `max`. +* `(MUST_PROMPT_STRING )` + indicating that an input should be given before executing further + ``s. In this case, the execution should be done only after the + user has seen `msg` and input a string totaling between `min` and `max` + characters. +* `(MUST_PROMPT_CHOICE)` + indicating that an input should be given before executing further + ``s. In this case, the execution should be done only after the + user has chosen an option between the ones listed in the ``'s + `available_options`. +* `(MUST_DISPLAY )`, indicating that `msg` should be displayed + before further ``s are executed. +* `(MUST_DISPLAY_ERROR )`, indicating that `msg` should be + displayed as an error message before further ``s are executed. diff --git a/content/wyrd_v1/value/_index.md b/content/wyrd_v1/value/_index.md index 18e2a6a..8ff8290 100644 --- a/content/wyrd_v1/value/_index.md +++ b/content/wyrd_v1/value/_index.md @@ -4,8 +4,13 @@ title: Value weight: 4 --- -`{Integer}` and `{Float}` are meant to represent the largest available integer -and float point value types available in the interpreter's language. This is not -mandatory, but be especially wary of using too small a type for `{Integer}`, as -the `` `program_counter` value will need to be able to be as big as there -are instructions in the program. +This page describes the types of values used in Wyrd. + +Note that `{Integer}` and `{Float}` are meant to represent the largest available +integer and float point value types available in the interpreter's language. +This is not mandatory, but be especially wary of using too small a type for +`{Integer}`, as the `` `program_counter` value will need to be able to +be as big as there are instructions in the program. + +{{< svg "static/images/wyrd_values.drawio.svg" "500px" >}} + diff --git a/dia/wyrd_values.drawio b/dia/wyrd_values.drawio new file mode 100755 index 0000000..40c2625 --- /dev/null +++ b/dia/wyrd_values.drawio @@ -0,0 +1 @@ +7V1tc5s4EP41/pgb3rE/xkmTtpfrpE0vbe/LjWJkmwQjH8i13V9/yzsIMJZfMK41k+lYi5CE9lntsytQe+rNbHXvofn0L2Jhp6dI1qqn3vYUxTD78G8gWEeCwUCKBBPPtiKRnAme7F84FibVFraF/UJFSohD7XlROCKui0e0IEOeR5bFamPiFHudowkuCZ5GyClLv9kWnUbSvmJm8vfYnkyTnmVjEF2ZoaRy/CT+FFlkmROp73rqjUcIjX7NVjfYCeYumZdvH9bfnIc34/7jZ/8/9Pfwz6+fnq+ixu54bkkfwcMu3bnpX2/ju/fP2uv3+ePd56V0f/3y8Sq+RfqJnEU8Xz3FcKCT4XMoUoxJUIgngK6TWfWX9sxBLpSGY+LSp/gKzMkQOfbEhd8jGCz2QPATe9QGhVzHFyiZg3Q0tR3rAa3JIngkn6LRW1IaToln/4JmkQOXZBDAZY/G2FKMQo2n4E4QSyD1sA91HpN5klPRA/JpXGdEHAfNffslHHBQZYa8ie0OCaVkljREFq6FrbiUKj4sUI+8pVCS08lp1E6sxWA28CqHzVhb95jMMPXWUCW+mgIvtjw5KS8zHMtGLJvmMKzFMhSbziRtOu3tC5gacicwB1l3KtOdtmV3oJBCd8gBvbuI4mEwi34elPAj96SZKIQqB2xltRa3Q1hcdsKuJLB7OOyq/SKYFGlLMBk7YVfVit2l3ee7MzuCXa2E3fjnNUh7ZohgjNyeeVuCLsw+zcHUwWNaC1J/jka2O3kI69xqmeRL/PiBiMC9YycEyNS2LOyGAKKIopfUKObEdmk4P/oQ/mAWb6Q/9J4OA7qBspyV4S+o7tEb4gLWkB2CCgOAl9inlXDbbN7NeFsX9ci7VuXhVVA0t1b1ihWJ0Z5jh4vOlM6ytYE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UPVbHWVVjd2qvF6E3evFZBYgz9oZxCIzcEgQsy4ghVAOVmmlPKwGO6H4nFIDajm3NQI4hNOdJAfqV+RskwlGrq6uA1oyHsOM/OuiGa56sZytB6qFmvCYfqm/5r5K1nS5OYhoNeLJQVQCXj9WDkIVZ6AcQa0VC0ulWuUN69h+ahXHoGynsCOESFcm49ZU9UBZiAHL3o51ToOkbw5K2CdMpq4+qGLqm5vr62z9xqCtWD+huccNkupPjviEl8GiKWhmF2imyqB1UEX7DhcrnRXLFMcN7OT9D3OIxNG8f4LAs/H+eGXT3JstUPqRtAS/s/dagkJbr7XUKbmFbQtZGXSdMbBZzAYCwO5byDLnxoIsq3w7F7KscfbQymlTWtNRBYIzdJEzyFJFaupC31rRyglWcV5BE2XQOn5egSbOKziCWk/9LoomzivYTl/HIHUlftH1NFC6rZI6vSYKpdV4ydo8TamHhkSQymZ2pKZMENuDvF8qCIrZf0gVVc/+Vy/13f8= \ No newline at end of file diff --git a/static/images/wyrd_values.drawio.svg b/static/images/wyrd_values.drawio.svg new file mode 100755 index 0000000..2d00a62 --- /dev/null +++ b/static/images/wyrd_values.drawio.svg @@ -0,0 +1,4 @@ + + + +<Value><BoolValue>value: {Boolean}<FloatValue>value: {Float}<IntValue>value: {Integer}<StringValue>value: {String}<ListValue>value: {{String} -> <Value>}<PointerValue>value: {{String} List}<StructureValue>value: {{String} -> <Value>}<TextValue><AugmentedTextValue>content: {<TextValue> List}effect_name: {String}effect_parameters: {<Value> List}<NewlineTextValue><StringTextValue>value: {String} \ No newline at end of file -- cgit v1.2.3-70-g09d2