questmark 0.0.37 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/docs.yml +56 -0
- package/bin/questmark +1 -1
- package/dist/browser/bundle.js +15575 -18661
- package/dist/node/QuestVM.d.ts +1 -2
- package/dist/node/QuestVM.js +81 -83
- package/dist/node/QuestVM.js.map +1 -1
- package/dist/node/cli.js +32 -48
- package/dist/node/cli.js.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +2 -14
- package/dist/node/index.js.map +1 -1
- package/dist/node/parseMarkdown.d.ts +18 -7
- package/dist/node/parseMarkdown.js +81 -77
- package/dist/node/parseMarkdown.js.map +1 -1
- package/docs/explanation/how-questmark-works.md +123 -0
- package/docs/explanation/why-questmark.md +72 -0
- package/docs/how-to/compile-to-bytecode.md +62 -0
- package/docs/how-to/play-a-document.md +57 -0
- package/docs/how-to/use-the-library.md +98 -0
- package/docs/index.md +61 -0
- package/docs/reference/api.md +135 -0
- package/docs/reference/cli.md +66 -0
- package/docs/reference/language.md +213 -0
- package/docs/tutorials/first-conversation.md +219 -0
- package/package.json +30 -33
- package/readme.md +55 -80
- package/tsconfig.json +7 -3
- package/tsconfig.webpack.json +0 -2
- package/{webpack.config.js → webpack.config.cjs} +4 -10
|
@@ -1,52 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const unist_util_find_all_between_1 = __importDefault(require("unist-util-find-all-between"));
|
|
12
|
-
const unist_util_visit_parents_1 = __importDefault(require("unist-util-visit-parents"));
|
|
13
|
-
const unist_util_visit_1 = __importDefault(require("unist-util-visit"));
|
|
14
|
-
const unist_builder_1 = __importDefault(require("unist-builder"));
|
|
15
|
-
require("array-flat-polyfill");
|
|
16
|
-
const tzo_1 = require("tzo");
|
|
17
|
-
var NoLinkBehaviour;
|
|
1
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
2
|
+
import { findAfter } from "unist-util-find-after";
|
|
3
|
+
import { removePosition } from "unist-util-remove-position";
|
|
4
|
+
import { findAllAfter } from "unist-util-find-all-after";
|
|
5
|
+
import { visitParents } from "unist-util-visit-parents";
|
|
6
|
+
import { visit } from "unist-util-visit";
|
|
7
|
+
import { u } from "unist-builder";
|
|
8
|
+
import 'array-flat-polyfill';
|
|
9
|
+
import { Tokenizer, pushString, pushNumber, invokeFunction } from "tzo";
|
|
10
|
+
export var NoLinkBehaviour;
|
|
18
11
|
(function (NoLinkBehaviour) {
|
|
19
12
|
NoLinkBehaviour[NoLinkBehaviour["EXIT"] = 0] = "EXIT";
|
|
20
13
|
NoLinkBehaviour[NoLinkBehaviour["LOOPBACK_TO_OPTIONS"] = 1] = "LOOPBACK_TO_OPTIONS"; // DEFAULT: Loopback to the options section if no link is found for an option and an option does not explicitly call an `exit` or `goto` effect.
|
|
21
|
-
})(NoLinkBehaviour
|
|
14
|
+
})(NoLinkBehaviour || (NoLinkBehaviour = {}));
|
|
15
|
+
function childrenBetween(parent, start, end) {
|
|
16
|
+
const children = parent.children || [];
|
|
17
|
+
const startIndex = children.indexOf(start);
|
|
18
|
+
if (startIndex === -1) {
|
|
19
|
+
throw new Error("Expected child node");
|
|
20
|
+
}
|
|
21
|
+
const endIndex = end ? children.indexOf(end) : children.length;
|
|
22
|
+
if (end && endIndex === -1) {
|
|
23
|
+
throw new Error("Expected child node");
|
|
24
|
+
}
|
|
25
|
+
return children.slice(startIndex + 1, endIndex);
|
|
26
|
+
}
|
|
22
27
|
var EmitOn;
|
|
23
28
|
(function (EmitOn) {
|
|
24
29
|
EmitOn[EmitOn["CLASSIC"] = 0] = "CLASSIC";
|
|
25
30
|
EmitOn[EmitOn["END_OF_LINE"] = 1] = "END_OF_LINE";
|
|
26
31
|
})(EmitOn || (EmitOn = {}));
|
|
27
|
-
function parseMarkdown(file_contents) {
|
|
28
|
-
const tree =
|
|
29
|
-
const tokenizer = new
|
|
30
|
-
const root =
|
|
32
|
+
export function parseMarkdown(file_contents) {
|
|
33
|
+
const tree = fromMarkdown(file_contents);
|
|
34
|
+
const tokenizer = new Tokenizer();
|
|
35
|
+
const root = u('questmarkDocument', { options: {} }, []);
|
|
31
36
|
let last_once_directive_nr = 0;
|
|
32
37
|
let noLinkBehaviour = NoLinkBehaviour.LOOPBACK_TO_OPTIONS;
|
|
33
38
|
let retainWhitespace = false;
|
|
34
39
|
let emitOn = EmitOn.CLASSIC;
|
|
35
40
|
let missed_emits = 0;
|
|
36
41
|
let strip_leading_newlines = false;
|
|
37
|
-
|
|
42
|
+
visitParents(tree, 'heading', (x, ancestors) => {
|
|
38
43
|
if (ancestors.length > 1) {
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
46
|
// capture name
|
|
42
47
|
let name = "";
|
|
43
|
-
|
|
48
|
+
visitParents(x, 'text', t => {
|
|
44
49
|
name = `${name} ${t.value}`;
|
|
45
50
|
});
|
|
46
51
|
name = name.trim();
|
|
47
52
|
// capture children belonging to this heading group
|
|
48
|
-
const nextHeading =
|
|
49
|
-
const children = nextHeading
|
|
53
|
+
const nextHeading = findAfter(tree, x, 'heading');
|
|
54
|
+
const children = nextHeading ? childrenBetween(tree, x, nextHeading) : findAllAfter(tree, x);
|
|
50
55
|
if (name === "QUESTMARK-OPTIONS-HEADER") {
|
|
51
56
|
root.options = getQuestmarkOptions(children);
|
|
52
57
|
}
|
|
@@ -56,14 +61,14 @@ function parseMarkdown(file_contents) {
|
|
|
56
61
|
});
|
|
57
62
|
function getQuestmarkOptions(children) {
|
|
58
63
|
let code = '';
|
|
59
|
-
|
|
64
|
+
visit(u('bla', children), 'code', (n) => {
|
|
60
65
|
code = `${code} ${n.value}`;
|
|
61
66
|
});
|
|
62
67
|
return JSON.parse(code.trim());
|
|
63
68
|
}
|
|
64
69
|
function createStateNode(name, children) {
|
|
65
70
|
// create new state node
|
|
66
|
-
const stateNode =
|
|
71
|
+
const stateNode = u('state', { name, options: [] }, []);
|
|
67
72
|
let found = false;
|
|
68
73
|
let stateChildren = [];
|
|
69
74
|
let remainingChildren = [];
|
|
@@ -102,13 +107,13 @@ function parseMarkdown(file_contents) {
|
|
|
102
107
|
const options = remainingChildren.map((li) => {
|
|
103
108
|
// li's `link` / `text` children are the main links / options, but only the first item is considered (the others are effect nodes)
|
|
104
109
|
// li's `inlineCode` children are either precondition or effect code blocks
|
|
105
|
-
const optionNode =
|
|
110
|
+
const optionNode = u("option", { preconditionChildren: null, effectChildren: null, text: null, link: null, directives: null });
|
|
106
111
|
let effectNodes = [];
|
|
107
112
|
let preconditionNodes = [];
|
|
108
113
|
let text = [];
|
|
109
114
|
let link = [];
|
|
110
115
|
let directives = [];
|
|
111
|
-
|
|
116
|
+
visit(li, (n) => {
|
|
112
117
|
if (text.length > 0 && n.type !== "paragraph") {
|
|
113
118
|
if (n.type === "text" && n.value && n.value.trim().length === 0) {
|
|
114
119
|
// whitespace only node!
|
|
@@ -163,7 +168,7 @@ function parseMarkdown(file_contents) {
|
|
|
163
168
|
stateNode.options = options;
|
|
164
169
|
return stateNode;
|
|
165
170
|
}
|
|
166
|
-
const qvmState =
|
|
171
|
+
const qvmState = u("questmarkVMState", {
|
|
167
172
|
stack: [],
|
|
168
173
|
context: {},
|
|
169
174
|
programList: [],
|
|
@@ -209,18 +214,18 @@ function parseMarkdown(file_contents) {
|
|
|
209
214
|
if (node.options["initial-context"]) {
|
|
210
215
|
Object.entries(node.options["initial-context"]).forEach(entry => {
|
|
211
216
|
if (typeof entry[1] === "string") {
|
|
212
|
-
q(
|
|
217
|
+
q(pushString(entry[1]));
|
|
213
218
|
}
|
|
214
219
|
else if (typeof entry[1] === "number") {
|
|
215
|
-
q(
|
|
220
|
+
q(pushNumber(entry[1]));
|
|
216
221
|
}
|
|
217
|
-
q(
|
|
218
|
-
q(
|
|
222
|
+
q(pushString(entry[0]));
|
|
223
|
+
q(invokeFunction("setContext"));
|
|
219
224
|
});
|
|
220
225
|
}
|
|
221
226
|
if (node.options["initial-state"]) {
|
|
222
|
-
q(
|
|
223
|
-
q(
|
|
227
|
+
q(pushString(node.options["initial-state"]));
|
|
228
|
+
q(invokeFunction("goto"));
|
|
224
229
|
}
|
|
225
230
|
if (node.options["options"]) {
|
|
226
231
|
if (node.options["options"]["no_link_behaviour"]) {
|
|
@@ -256,15 +261,15 @@ function parseMarkdown(file_contents) {
|
|
|
256
261
|
const nodeLabel = node.name;
|
|
257
262
|
const nodeOptionsLabel = node.name + "__options";
|
|
258
263
|
qvmState.labelMap[nodeLabel] = qvmState.programList.length;
|
|
259
|
-
|
|
264
|
+
visit(node, visitorFunc); // parse children immediately, before we parse the node's options
|
|
260
265
|
// if there are any missing emits, perform them now
|
|
261
266
|
if (missed_emits > 0) {
|
|
262
267
|
while (missed_emits > 1) {
|
|
263
|
-
q(
|
|
268
|
+
q(invokeFunction("rconcat"));
|
|
264
269
|
missed_emits -= 1;
|
|
265
270
|
}
|
|
266
271
|
missed_emits = 0;
|
|
267
|
-
q(
|
|
272
|
+
q(invokeFunction("emit")); // need to still emit!
|
|
268
273
|
}
|
|
269
274
|
qvmState.labelMap[nodeOptionsLabel] = qvmState.programList.length; // add a label immediately after the node's options to be able to shortcut jump to in certain cases
|
|
270
275
|
node.options.forEach(option => {
|
|
@@ -277,10 +282,10 @@ function parseMarkdown(file_contents) {
|
|
|
277
282
|
last_once_directive_nr += 1;
|
|
278
283
|
}
|
|
279
284
|
if (has_once_directive) {
|
|
280
|
-
q(
|
|
281
|
-
q(
|
|
282
|
-
q(
|
|
283
|
-
q(
|
|
285
|
+
q(pushString(once_directive_name));
|
|
286
|
+
q(invokeFunction("hasContext"));
|
|
287
|
+
q(invokeFunction("jz"));
|
|
288
|
+
q(invokeFunction("{")); // once directive block start
|
|
284
289
|
}
|
|
285
290
|
if (option.preconditionChildren !== null) {
|
|
286
291
|
has_precondition = true;
|
|
@@ -294,25 +299,25 @@ function parseMarkdown(file_contents) {
|
|
|
294
299
|
});
|
|
295
300
|
}
|
|
296
301
|
if (has_precondition) {
|
|
297
|
-
q(
|
|
298
|
-
q(
|
|
302
|
+
q(invokeFunction("jgz"));
|
|
303
|
+
q(invokeFunction("{")); // precondition block start
|
|
299
304
|
}
|
|
300
305
|
if (option.text !== null) {
|
|
301
306
|
if (option.text.includes("`")) {
|
|
302
307
|
// TODO: support inlineCode in options. Can do via `concat`.
|
|
303
308
|
console.warn("WARN: Option text contains a backtick. Inline code elements in option blocks is currently not supported!");
|
|
304
309
|
}
|
|
305
|
-
q(
|
|
310
|
+
q(pushString(option.text));
|
|
306
311
|
}
|
|
307
|
-
q(
|
|
308
|
-
q(
|
|
309
|
-
q(
|
|
310
|
-
q(
|
|
312
|
+
q(invokeFunction("ppc")); // push address of effect body to stack
|
|
313
|
+
q(pushNumber(4));
|
|
314
|
+
q(invokeFunction("+"));
|
|
315
|
+
q(invokeFunction("{")); // effect body start
|
|
311
316
|
if (has_once_directive) {
|
|
312
317
|
// set the once directive context variable immediatley
|
|
313
|
-
q(
|
|
314
|
-
q(
|
|
315
|
-
q(
|
|
318
|
+
q(pushNumber(1));
|
|
319
|
+
q(pushString(once_directive_name));
|
|
320
|
+
q(invokeFunction("setContext"));
|
|
316
321
|
}
|
|
317
322
|
if (option.effectChildren !== null) {
|
|
318
323
|
option.effectChildren.forEach(child => {
|
|
@@ -327,13 +332,13 @@ function parseMarkdown(file_contents) {
|
|
|
327
332
|
}
|
|
328
333
|
else {
|
|
329
334
|
let t = getText(child);
|
|
330
|
-
q(
|
|
335
|
+
q(pushString(fixText(child), t));
|
|
331
336
|
if (emitOn === EmitOn.CLASSIC || (emitOn === EmitOn.END_OF_LINE && t.replace(/[\t\f\v ]+$/, "").endsWith('\n'))) {
|
|
332
337
|
while (missed_emits > 0) {
|
|
333
|
-
q(
|
|
338
|
+
q(invokeFunction("rconcat"));
|
|
334
339
|
missed_emits -= 1;
|
|
335
340
|
}
|
|
336
|
-
q(
|
|
341
|
+
q(invokeFunction("emit"));
|
|
337
342
|
}
|
|
338
343
|
else {
|
|
339
344
|
missed_emits += 1;
|
|
@@ -344,36 +349,36 @@ function parseMarkdown(file_contents) {
|
|
|
344
349
|
// if there are any missing emits, perform them now before we close off this option effect body
|
|
345
350
|
if (missed_emits > 0) {
|
|
346
351
|
while (missed_emits > 1) {
|
|
347
|
-
q(
|
|
352
|
+
q(invokeFunction("rconcat"));
|
|
348
353
|
missed_emits -= 1;
|
|
349
354
|
}
|
|
350
355
|
missed_emits = 0;
|
|
351
|
-
q(
|
|
356
|
+
q(invokeFunction("emit")); // need to still emit!
|
|
352
357
|
}
|
|
353
358
|
if (option.link !== null) {
|
|
354
|
-
q(
|
|
355
|
-
q(
|
|
359
|
+
q(pushString(option.link.substr(1)));
|
|
360
|
+
q(invokeFunction("goto"));
|
|
356
361
|
}
|
|
357
362
|
if (noLinkBehaviour === NoLinkBehaviour.LOOPBACK_TO_OPTIONS) {
|
|
358
|
-
q(
|
|
359
|
-
q(
|
|
363
|
+
q(pushString(nodeOptionsLabel)); // ensure that options with no link or "goto" effect loop back to the options
|
|
364
|
+
q(invokeFunction("goto"));
|
|
360
365
|
}
|
|
361
366
|
else if (noLinkBehaviour === NoLinkBehaviour.EXIT) {
|
|
362
|
-
q(
|
|
367
|
+
q(invokeFunction("exit")); // ensure that options with no effect or link cause the VM to exit
|
|
363
368
|
}
|
|
364
|
-
q(
|
|
365
|
-
q(
|
|
369
|
+
q(invokeFunction("}")); // effect body end
|
|
370
|
+
q(invokeFunction("response"));
|
|
366
371
|
if (has_once_directive) {
|
|
367
372
|
// when there was a once directive, ensure we close its block
|
|
368
|
-
q(
|
|
373
|
+
q(invokeFunction("}")); // once directive block end
|
|
369
374
|
}
|
|
370
375
|
if (has_precondition) {
|
|
371
376
|
// when there was a precondition, ensure we close the precondition block
|
|
372
|
-
q(
|
|
377
|
+
q(invokeFunction("}")); // precondition block end
|
|
373
378
|
}
|
|
374
379
|
});
|
|
375
|
-
q(
|
|
376
|
-
q(
|
|
380
|
+
q(invokeFunction("getResponse")); // getResponse is expected to pause the VM and push the relevant programlist index onto the stack
|
|
381
|
+
q(invokeFunction("goto")); // goto whatever was pushed onto the stack by getResponse
|
|
377
382
|
return "skip";
|
|
378
383
|
// children have been parsed earlier
|
|
379
384
|
break;
|
|
@@ -386,13 +391,13 @@ function parseMarkdown(file_contents) {
|
|
|
386
391
|
break;
|
|
387
392
|
case "text":
|
|
388
393
|
let t = getText(node);
|
|
389
|
-
q(
|
|
394
|
+
q(pushString(fixText(node), t));
|
|
390
395
|
if (emitOn === EmitOn.CLASSIC || (emitOn === EmitOn.END_OF_LINE && t.replace(/[\t\f\v ]+$/, "").endsWith('\n'))) {
|
|
391
396
|
while (missed_emits > 0) {
|
|
392
|
-
q(
|
|
397
|
+
q(invokeFunction("rconcat"));
|
|
393
398
|
missed_emits -= 1;
|
|
394
399
|
}
|
|
395
|
-
q(
|
|
400
|
+
q(invokeFunction("emit"));
|
|
396
401
|
}
|
|
397
402
|
else {
|
|
398
403
|
missed_emits += 1;
|
|
@@ -402,12 +407,11 @@ function parseMarkdown(file_contents) {
|
|
|
402
407
|
break;
|
|
403
408
|
}
|
|
404
409
|
};
|
|
405
|
-
|
|
406
|
-
q(
|
|
410
|
+
visit(root, visitorFunc);
|
|
411
|
+
q(invokeFunction("exit")); // ensure we always exit at the end
|
|
407
412
|
return {
|
|
408
|
-
parsedMDFile:
|
|
413
|
+
parsedMDFile: removePosition(root, { force: true }),
|
|
409
414
|
qvmState
|
|
410
415
|
};
|
|
411
416
|
}
|
|
412
|
-
exports.parseMarkdown = parseMarkdown;
|
|
413
417
|
//# sourceMappingURL=parseMarkdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseMarkdown.js","sourceRoot":"","sources":["../../src/parseMarkdown.ts"],"names":[],"mappings":";;;;;;AACA,wFAAoD;AACpD,kFAA8C;AAC9C,4FAAwD;AACxD,0FAAqD;AAC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AC;oBAChH,OAAO,YAAY,GAAG,CAAC,EAAE,CAAC;wBACxB,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;wBAC7B,YAAY,IAAI,CAAC,CAAC;oBACpB,CAAC;oBACD,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5B,CAAC;qBAAM,CAAC;oBACN,YAAY,IAAI,CAAC,CAAC;gBACpB,CAAC;gBACD,MAAM;YACR;gBACE,MAAM;QACV,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,mCAAmC;IAE9D,OAAO;QACL,YAAY,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnD,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# How Questmark works
|
|
2
|
+
|
|
3
|
+
Questmark is a compiler and an interpreter. A document goes through a
|
|
4
|
+
pipeline:
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
Markdown document
|
|
8
|
+
│ mdast-util-from-markdown
|
|
9
|
+
▼
|
|
10
|
+
mdast AST (generic Markdown tree)
|
|
11
|
+
│ visit headings, collect children
|
|
12
|
+
▼
|
|
13
|
+
Questmark tree (states, options, headers)
|
|
14
|
+
│ visit nodes, tokenize Tzo code
|
|
15
|
+
▼
|
|
16
|
+
Tzo bytecode (VMState: programList + labelMap)
|
|
17
|
+
│ QuestVM (a Tzo VM)
|
|
18
|
+
▼
|
|
19
|
+
A running conversation
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 1. From Markdown to a Questmark tree
|
|
23
|
+
|
|
24
|
+
The compiler first parses the document with
|
|
25
|
+
[`mdast-util-from-markdown`](https://www.npmjs.com/package/mdast-util-from-markdown),
|
|
26
|
+
producing a standard Markdown abstract syntax tree.
|
|
27
|
+
|
|
28
|
+
It then walks that tree. Every top-level `# heading` starts a **state**, and
|
|
29
|
+
everything between one heading and the next belongs to that state. One heading
|
|
30
|
+
is special: `QUESTMARK-OPTIONS-HEADER`. Its indented code block is parsed as
|
|
31
|
+
JSON and supplies the document's configuration — the initial state, the initial
|
|
32
|
+
context, and interpreter behaviour flags.
|
|
33
|
+
|
|
34
|
+
Each state's children are split into two parts:
|
|
35
|
+
|
|
36
|
+
- the **text**, everything before the first list, and
|
|
37
|
+
- the **options**, the list items themselves.
|
|
38
|
+
|
|
39
|
+
Each option is decomposed further: backticked code *before* the option's text
|
|
40
|
+
becomes a **precondition** or a **directive** (like `@once`); the option's text
|
|
41
|
+
and link are kept as the label and target; backticked code *after* the text,
|
|
42
|
+
and paragraphs following the option line, become its **effect** and its
|
|
43
|
+
**post-option text**.
|
|
44
|
+
|
|
45
|
+
The result is a small custom tree of `state` and `option` nodes, built with
|
|
46
|
+
[`unist-builder`](https://www.npmjs.com/package/unist-builder) so that it
|
|
47
|
+
benefits from the unist ecosystem's visitor utilities.
|
|
48
|
+
|
|
49
|
+
## 2. From the tree to Tzo bytecode
|
|
50
|
+
|
|
51
|
+
The compiler visits that tree with [`unist-util-visit`](https://www.npmjs.com/package/unist-util-visit)
|
|
52
|
+
and emits instructions into a flat program list, using Tzo's `Tokenizer` to
|
|
53
|
+
turn each snippet of backticked code into instructions.
|
|
54
|
+
|
|
55
|
+
Text nodes become `pushString` + `emit`. Inline code becomes the tokenized
|
|
56
|
+
instructions directly. Each state registers two positions in the program's
|
|
57
|
+
`labelMap`: one for the state itself, and one for its `__options` menu (used to
|
|
58
|
+
loop back to the options after an effect).
|
|
59
|
+
|
|
60
|
+
An option compiles to roughly this shape:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
pushString "Order a drink" ; the label, shown in the menu
|
|
64
|
+
ppc 4 + { ...effect... } ; the effect body, entered when chosen
|
|
65
|
+
response ; register the choice with the player
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Preconditions and the `@once` directive wrap the option in a conditional block:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
...precondition code... jgz { ...option... }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The block delimiters `{` and `}` are real instructions: `jgz` (and `jz`) skip
|
|
75
|
+
the *next* instruction when their test passes, and `{` scans forward and jumps
|
|
76
|
+
past its matching `}`. So a precondition leaves a value on the stack; if it is
|
|
77
|
+
greater than zero the `jgz` skips the `{` and the option body runs, otherwise
|
|
78
|
+
the `{` jumps to the end of the block and the option is never offered. `@once`
|
|
79
|
+
works the same way, keyed on an internal `__once__N` context variable.
|
|
80
|
+
|
|
81
|
+
The whole document compiles to a **VMState**: the `programList`, the
|
|
82
|
+
`labelMap`, and the initial `context`, which is populated from
|
|
83
|
+
`initial-context` by a sequence of `setContext` instructions at the top of the
|
|
84
|
+
program.
|
|
85
|
+
|
|
86
|
+
## 3. Interpreting with QuestVM
|
|
87
|
+
|
|
88
|
+
[`QuestVM`](../reference/api.md) extends Tzo's `VM`. It registers the three
|
|
89
|
+
opcodes that make a conversation interactive:
|
|
90
|
+
|
|
91
|
+
- **`emit`** calls the host's text callback. A single state can emit several
|
|
92
|
+
chunks — text, a number from `getContext`, more text — which is why a host
|
|
93
|
+
typically concatenates them.
|
|
94
|
+
- **`response`** records the position of an option's effect body, along with
|
|
95
|
+
its label, as a candidate choice.
|
|
96
|
+
- **`getResponse`** suspends the VM and hands the collected choices to the
|
|
97
|
+
host. When the host returns the chosen option's id, the VM pushes the saved
|
|
98
|
+
program position and resumes — executing that option's effect and following
|
|
99
|
+
its `goto`/`exit`.
|
|
100
|
+
|
|
101
|
+
Because choices are only recorded inside their precondition blocks, options
|
|
102
|
+
that are hidden by preconditions never reach the host. The interpreter never
|
|
103
|
+
needs to know *why* an option is hidden; the compiled bytecode handles it.
|
|
104
|
+
|
|
105
|
+
## The two behaviours worth knowing about
|
|
106
|
+
|
|
107
|
+
- **No-link options.** When a chosen option has no link and no effect, the
|
|
108
|
+
compiled code either jumps back to the state's `__options` label
|
|
109
|
+
(`loopback_to_options`, the default) or exits the conversation (`exit`),
|
|
110
|
+
depending on the header flag. With loopback, an option that is always
|
|
111
|
+
available and always chosen will loop forever — which is correct, but can
|
|
112
|
+
surprise new authors.
|
|
113
|
+
- **Persistence.** The compiled VMState is plain JSON. It can be written out
|
|
114
|
+
and reloaded later, which is how the CLI's `--output`/`--no-run` flow works:
|
|
115
|
+
compile once, ship the JSON, interpret it in a game or a web page without
|
|
116
|
+
needing the compiler at runtime.
|
|
117
|
+
|
|
118
|
+
## See also
|
|
119
|
+
|
|
120
|
+
- [Why Questmark?](why-questmark.md) — the problem this design is answering.
|
|
121
|
+
- [Language reference](../reference/language.md) — what you can write.
|
|
122
|
+
- [Tzo](https://github.com/jorisvddonk/tzo) — the bytecode and VM Questmark
|
|
123
|
+
is built on.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Why Questmark?
|
|
2
|
+
|
|
3
|
+
Questmark exists to solve a specific problem in game dialogue and interactive
|
|
4
|
+
fiction production.
|
|
5
|
+
|
|
6
|
+
## The problem
|
|
7
|
+
|
|
8
|
+
Dialogue systems in modern games need to do two very different things at once:
|
|
9
|
+
|
|
10
|
+
- represent a **conversation graph** — the branching structure of what can be
|
|
11
|
+
said, and
|
|
12
|
+
- trigger **side effects** in the game world — flags, items, faction changes —
|
|
13
|
+
when the player chooses something.
|
|
14
|
+
|
|
15
|
+
That means the people writing dialogue prose need to know how to *write prose*,
|
|
16
|
+
and the people implementing side effects need to know how to *program*. These
|
|
17
|
+
are rarely the same people, and the tools tend to favour one or the other:
|
|
18
|
+
|
|
19
|
+
- A scripting language with an associated editor attracts programmers. Prose
|
|
20
|
+
authors either learn to program, or keep writing in Word documents.
|
|
21
|
+
- Proprietary, editor-bound dialogue tools make dialogue hard or impossible to
|
|
22
|
+
merge, diff, and version in source control.
|
|
23
|
+
|
|
24
|
+
## The shared language: Markdown
|
|
25
|
+
|
|
26
|
+
Almost every writer and every programmer already knows Markdown, or one of its
|
|
27
|
+
modern dialects. Questmark leans on that shared knowledge: **every
|
|
28
|
+
properly-structured Markdown document with headers and in-document links is
|
|
29
|
+
already a Questmark document.**
|
|
30
|
+
|
|
31
|
+
- Dialogue trees and quests are expressed with ordinary Markdown — headings,
|
|
32
|
+
lists, and links.
|
|
33
|
+
- Questmark-specific behaviour is added with small, backticked snippets of code
|
|
34
|
+
where authors and programmers agree it's needed.
|
|
35
|
+
- Comments and annotations from writers and reviewers are simply Markdown that
|
|
36
|
+
the Questmark compiler ignores.
|
|
37
|
+
|
|
38
|
+
## The workflow Questmark enables
|
|
39
|
+
|
|
40
|
+
1. **Authors** write dialogue trees in Markdown, which can be demoed
|
|
41
|
+
interactively — by interpreting it as HTML, by running it in a simple
|
|
42
|
+
Questmark runner, or by running it inside a game engine.
|
|
43
|
+
2. **Reviewers** add comments and feedback in the same document, without
|
|
44
|
+
affecting what the interpreter produces.
|
|
45
|
+
3. **Gameplay programmers** add interactivity where it's needed — no more than
|
|
46
|
+
where it's needed.
|
|
47
|
+
4. **Authors** can edit prose freely without disturbing the dialogue's
|
|
48
|
+
interactivity, and programmers can adjust logic without touching the prose.
|
|
49
|
+
5. The game ships.
|
|
50
|
+
|
|
51
|
+
Because Questmark documents are plain text, they sit happily under revision
|
|
52
|
+
control, where they can be reviewed, merged, and diffed like any other code.
|
|
53
|
+
|
|
54
|
+
## Where Questmark stands today
|
|
55
|
+
|
|
56
|
+
Questmark is a proof of concept implemented in TypeScript. The spec is still
|
|
57
|
+
informal and the feature set is still settling. The repository includes
|
|
58
|
+
compiler, interpreter, CLI, and a test suite; the companion
|
|
59
|
+
[questmark-webrenderer](https://github.com/jorisvddonk/questmark-webrenderer)
|
|
60
|
+
renders and plays documents in the browser.
|
|
61
|
+
|
|
62
|
+
Open questions the project is still working through:
|
|
63
|
+
|
|
64
|
+
- How should inline HTML be treated?
|
|
65
|
+
- How can the compiler be extended with custom directives and macros?
|
|
66
|
+
- How can a document be translated to another language while keeping its
|
|
67
|
+
scripting logic intact and easy to modify?
|
|
68
|
+
|
|
69
|
+
## See also
|
|
70
|
+
|
|
71
|
+
- [How Questmark works](how-questmark-works.md) — the pipeline from Markdown to
|
|
72
|
+
bytecode to a running conversation.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# How to compile a Questmark document to bytecode
|
|
2
|
+
|
|
3
|
+
Questmark compiles to [Tzo](https://github.com/jorisvddonk/tzo) bytecode. A
|
|
4
|
+
compiled document is a JSON file describing a complete VM state, which you can
|
|
5
|
+
store, inspect, or ship in a game.
|
|
6
|
+
|
|
7
|
+
## Compile a document to JSON
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx questmark --input path/to/document.md --output path/to/vmstate.json --no-run
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- `--input` — the Questmark document (local path or `http(s)://` URL).
|
|
14
|
+
- `--output` — where to write the compiled JSON.
|
|
15
|
+
- `--no-run` — parse and compile only; do not interpret the document.
|
|
16
|
+
|
|
17
|
+
The output is a JSON serialization of a Tzo `VMState`, containing the compiled
|
|
18
|
+
program, its label map, and the initial context. No interpreter is required to
|
|
19
|
+
produce or read this file.
|
|
20
|
+
|
|
21
|
+
## Compile without writing a file
|
|
22
|
+
|
|
23
|
+
Omit `--output`. The CLI parses the document but discards the compiled state —
|
|
24
|
+
handy for checking that a document parses cleanly:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx questmark --input path/to/document.md --no-run
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Play a compiled document
|
|
31
|
+
|
|
32
|
+
You can interpret a compiled `.json` the same way you play a source document:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx questmark --input path/to/vmstate.json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## From the project directory
|
|
39
|
+
|
|
40
|
+
Inside a checkout of the repository the same commands are available via
|
|
41
|
+
`npm start`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm start -- --input path/to/document.md --output path/to/vmstate.json --no-run
|
|
45
|
+
npm start -- --input path/to/vmstate.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## What the compiled output looks like
|
|
49
|
+
|
|
50
|
+
A compiled VM state has these top-level fields:
|
|
51
|
+
|
|
52
|
+
| Field | Description |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `programList` | The array of instructions in the compiled program. |
|
|
55
|
+
| `labelMap` | Maps state names (and state `__options` labels) to positions in `programList`. |
|
|
56
|
+
| `context` | The initial context bag of variables. |
|
|
57
|
+
| `stack` | The interpreter stack (empty at compile time). |
|
|
58
|
+
| `programCounter` | Where execution starts (0 at compile time). |
|
|
59
|
+
| `exit` / `pause` | Interpreter flags (both `false` at compile time). |
|
|
60
|
+
|
|
61
|
+
See the [explanation of how Questmark works](../explanation/how-questmark-works.md)
|
|
62
|
+
for what these instructions mean.
|