summaryrefslogtreecommitdiff
blob: d441ee1b56c6e14dd53c4f6617c906ba78733677 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
---
menuTitle: <Instruction>
title: Instruction
weight: 2
---
This page presents all the `<Instruction>`s that can be performed in Wyrd.
`<Instruction>`s do not return values.

Unless otherwise specified, all `<Instruction>`s:
* Increment the `<State>`'s `program_counter` by 1.
* Set the `<State>`'s `last_instruction_result` to `(MUST_CONTINUE)`.

Implementing `execute(<State>)` to recurse/loop as long as the newly updated
`<State>`'s `last_instruction_result` is `(MUST_CONTINUE)` is acceptable.

**Shortcut to each `<Instruction>`:**
* [`(add_event_option! {name: String} {parameters: <Computation> List})`](#add_event_option)
* [`(add_text_option! <value: Computation>)`](#add_text_option)
* [`(assert! <condition: Computation> <message: Computation>)`](#assert)
* [`(display! <value: Computation>)`](#display)
* [`(end!)`](#end)
* [`(initialize! {type: String} <target: Computation>)`](#initialize)
* [`(prompt_command! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`](#prompt_command)
* [`(prompt_float! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`](#prompt_float)
* [`(prompt_integer! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`](#prompt_integer)
* [`(prompt_string! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`](#prompt_string)
* [`(remove! <target: Computation>)`](#remove)
* [`(resolve_choice!)`](#resolve_choice)
* [`(set_pc! <value: Computation>)`](#set_pc)
* [`(set_random! <min: Computation> <max: Computation> <target: Computation>)`](#set_random)
* [`(set_value! <target: Computation> <value: Computation>)`](#set_value)
* [`({extra_instruction: String}! {parameters: <Computation> List})`](#extra_instruction)

### add_event_option
`(add_event_option! {name: String} {parameters: <Computation> List})`

Adds an `<Option>` based on an `<Event>` for the user.

**Parameters:**
* `value` is a `{String}` indicating the name of the `<Event>`.
* `parameters` is a `{List}` of `<Computation>` that will yield the `<Value>`s
   required for this option to be chosen when the `<Event>` occurs on the next
   `(resolve_choice!)`.

**Process:**
* Compute the `<Value>` corresponding to each member of `parameters`, store them
   in a `{List}` while keeping the order.
* Create a new `<EventOption>` with name `name` and the aforementioned
  `{<Value> List}` as parameters.
* Append the newly created `<EventOption>` to the end of the `<State>`'s
  `available_options`.

### add_text_option
`(add_text_option! <value: Computation>)`

Adds an `<Option>` based on an `<TextValue>` for the user.

**Parameters:**
* `value` is a `<Computation>` that will yield the `<TextValue>` displayed to
   the user for this option on the next `(resolve_choice!)`.

**Process:**
* Compute the `<Value>` yielded by `value`.
* Create a new `<TextOption>` corresponding to the aforementioned
  `<Value>`.
* Append the newly created `<TextOption>` to the end of the `<State>`'s
  `available_options`.

### assert
`(assert! <condition: Computation> <message: Computation>)`

Checks if a condition is fulfilled and prints an error message if it is not.

**Parameters:**
* `condition` is a `<Computation>` corresponding to what needs to be tested.
* `message` is a `<Computation>` defining the error message displayed to the
   user if the condition is not verified.

**Process:**
* Compute the `<Value>` yielded by `condition`.
* Interpret this `<Value>` as `{Boolean}`.
* If it is `TRUE`, the `<Instruction>` has completed.
* Otherwise, compute the `<msg: Value>` corresponding to the `message`.
* Set the `<State>`'s `last_instruction_result` to
   `(MUST_DISPLAY_ERROR <msg: Value>)`.

### display
`(display! <value: Computation>)`

Displays text to the user.

**Parameters:**
* `value` is a `<Computation>` corresponding to what has to be displayed.

**Process:**
* Compute the `<msg: Value>` corresponding to `value`.
* Set the `<State>`'s `last_instruction_result` to
   `(MUST_DISPLAY <msg: Value>)`.

### end
`(end!)`

Ends the story.

**Process:**
* Do **not** increase the `<State>`'s `program_counter`.
* Set the `<State>`'s `last_instruction_result` to `(MUST_END)`

### initialize
`(initialize! {type: String} <target: Computation>)`

Adds an element to `memory` with a deterministic default value.

**Parameters:**
* `type` is a `{String}` corresponding to the type that will be used by
  `target`.
* `target` is `<Computation>` that will yield the address to initialize.

**Process:**
* Compute the `<Value>` resulting from `target`. This is a `<PointerValue>`.
* Interpret this `<PointerValue>` as a `{{String} List}`.
* Update the `<State>`'s `memory` so that the element pointed to by the
   `<PointerValue>` takes the default value for a `<Value>` of type `type`. Note
   that the `target` might point to an element that does not exist yet.

### prompt_command
`(prompt_command! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`

Asks the user to provide a list of strings as input.

**Parameters:**
* `min` is a `<Computation>` indicating the minimum size the user `{String}`
  input should be (in characters).
* `max` is a `<Computation>` indicating the maximum size the user `{String}`
  input should be (in characters).
* `target` is a `<Computation>` indicating where to store the result.
*  `message` is a `<Computation>` corresponding to the message displayed to the
   user for this prompt.

**Process:**
* Compute the `<Value>` corresponding to each of these parameter.
* Update the `<State>`'s `memorized_target` to be the `<Value>` resulting from
  `target`.
* Set the `<State>`'s `last_instruction_result` to
   `(MUST_PROMPT_COMMAND <min_val: Value> <max_val: Value> <msg: Value>)`.

### prompt_float
`(prompt_float! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`

Asks the user to provide a float as input.

**Parameters:**
* `min` is a `<Computation>` indicating the minimum float the user is allowed
   to input
* `max` is a `<Computation>` indicating the maximum float the user is allowed
   to input
* `target` is a `<Computation>` indicating where to store the result.
*  `message` is a `<Computation>` corresponding to the message displayed to the
   user for this prompt.

**Process:**
* Compute the `<Value>` corresponding to each of these parameter.
* Update the `<State>`'s `memorized_target` to be the `<Value>` resulting from
  `target`.
* Set the `<State>`'s `last_instruction_result` to
   `(MUST_PROMPT_FLOAT <min_val: Value> <max_val: Value> <msg: Value>)`.


### prompt_integer
`(prompt_integer! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`

Asks the user to provide an integer as input.

**Parameters:**
* `min` is a `<Computation>` indicating the minimum integer the user is allowed
   to input
* `max` is a `<Computation>` indicating the maximum integer the user is allowed
   to input
* `target` is a `<Computation>` indicating where to store the result.
*  `message` is a `<Computation>` corresponding to the message displayed to the
   user for this prompt.

**Process:**
* Compute the `<Value>` corresponding to each of these parameter.
* Update the `<State>`'s `memorized_target` to be the `<Value>` resulting from
  `target`.
* Set the `<State>`'s `last_instruction_result` to
   `(MUST_PROMPT_INTEGER <min_val: Value> <max_val: Value> <msg: Value>)`.

### prompt_string
`(prompt_string! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)`

Asks the user to provide a string as input.

**Parameters:**
* `min` is a `<Computation>` indicating the minimum size the user `{String}`
  input should be (in characters).
* `max` is a `<Computation>` indicating the maximum size the user `{String}`
  input should be (in characters).
* `target` is a `<Computation>` indicating where to store the result.
*  `message` is a `<Computation>` corresponding to the message displayed to the
   user for this prompt.

**Process:**
* Compute the `<Value>` corresponding to each of these parameter.
* Update the `<State>`'s `memorized_target` to be the `<Value>` resulting from
  `target`.
* Set the `<State>`'s `last_instruction_result` to
   `(MUST_PROMPT_STRING <min_val: Value> <max_val: Value> <msg: Value>)`.

### remove
`(remove! <target: Computation>)`

Removes an element from memory.

**Parameter:**
* `target` is a `<Computation>` indicating where the element to remove is.

**Process:**
* Compute the `<Value>` corresponding to `target`.
* Interpet this `<Value>` as an address.
* Remove the element at this address from the `<State>`'s `memory`.

### resolve_choice
`(resolve_choice!)`

Makes the user choose between all previously added options.

**Process:**
* Set the `<State>`'s `last_instruction_result` to `(MUST_PROMPT_CHOICE)`.


### set_pc
`(set_pc! <value: Computation>)`

Sets the program counter to a given value.

**Parameter:**
* `value` is a `<Computation>` indicating what to set the program counter to.

**Process:**
* Compute the `<Value>` for `value`.
* Interpret this `<Value>` as an `{Integer}`.
* Set the `<State>`'s `program_counter` to this value.
* Do **not** otherwise increase the `<State>`'s `program_counter`.

### set_random
`(set_random! <min: Computation> <max: Computation> <target: Computation>)`

Replaces the `<Value>` at a given address with a random integer. This is not
a computation as some languages will require state updates to keep generating
new random values.

**Parameters:**
* `min` is a `<Computation>` indicating the minimum integer allowed.
   to input
* `max` is a `<Computation>` indicating the maximum integer allowed.
* `target` is a `<Computation>` indicating where to store the result.

**Process:**
* Compute the `<Value>` corresponding to each of these parameter.
* Generate a random `{Integer}` between `min` and `max` (included).
* Update the `<State>`'s `memory`so that the element at `target` is to be the
  `<Value>` resulting from `target`.

### set_value
`(set_value! <target: Computation> <value: Computation>)`

Sets the value of an element in memory.

**Parameters:**
* `target` is a `<Computation>` indicating what element to set to the value.
* `value` is a `<Computation>` corresponding to the value to give the element.

**Process:**
* Compute `target` as `<addr: Value>`.
* Modify the `<State>`'s `memory` so that the element at `addr` takes the
   `<Value>` resulting from `value`'s computation.

### extra_instruction
`({extra_instruction: String}! {parameters: <Computation> List})`

Executes non-standard instruction.

**Parameters:**
* `extra_instruction` is the name of the extra instruction.
* `parameters` is a list of parameters for this instruction call.

**Process:**
* Undetermined. This is where you choose the process according to the value of
   `extra_instruction` so that you can add non-standard instructions.