Markdown fixes for README.
Cat's Eye Technologies
11 years ago
0 | 0 | Zzrk - Adventures in the Great Unsaturated Grammar |
1 | ==== | |
1 | ================================================== | |
2 | 2 | |
3 | 3 | What is it? |
4 | 4 | ----------- |
21 | 21 | |
22 | 22 | First, you need an implementation of Zz. The only one I've found, and |
23 | 23 | subsequently the one I've written Zzrk around, is OpenZz. It can be |
24 | gotten from http://openzz.sourceforge.net/. | |
24 | gotten from [http://openzz.sourceforge.net/](http://openzz.sourceforge.net/). | |
25 | 25 | |
26 | 26 | Although OpenZz does have an interactive mode, it unfortunately assumes |
27 | 27 | you're using Zz to describe a compiler. Since I assume you'll want to |
30 | 30 | happens), here's a guide to working around some of OpenZz's drawbacks. |
31 | 31 | |
32 | 32 | First, you can't just specify zzrk.zz as the input to ozz. Instead, |
33 | start OpenZz, then at the "ozz>" prompt, type | |
33 | start OpenZz, then at the `ozz>` prompt, type | |
34 | 34 | |
35 | 35 | /include "zzrk.zz" |
36 | 36 | |
37 | You can then treat the "ozz>" prompt as the prompt for the adventure | |
37 | You can then treat the `ozz>` prompt as the prompt for the adventure | |
38 | 38 | game parser. Try the usual actions, and see what happens. Be forewarned |
39 | 39 | that any unrecognizable command on your part -- an unknown verb, noun, or |
40 | 40 | other part of speech -- will trigger a syntax error. And, because OpenZz |
49 | 49 | puzzles just to demonstrate that the standard adventure game furniture can |
50 | 50 | be concocted in Zz. Collecting treasures will get you points, and |
51 | 51 | obtaining 50 points will win the game (that is, if you have 50 points and |
52 | you type "score", you will get a message telling you that you have won. | |
52 | you type `score`, you will get a message telling you that you have won. | |
53 | 53 | You will still need to quit OpenZz through some other manual action, such |
54 | 54 | as typing Ctrl-D, or causing syntax errors.) |
55 | 55 | |
57 | 57 | Comments |
58 | 58 | -------- |
59 | 59 | |
60 | I originally wrote zzrk.zz on November 21st, 2003. I gave it actual | |
60 | I originally wrote `zzrk.zz` on November 21st, 2003. I gave it actual | |
61 | 61 | puzzles, wrote this readme, and released it under a BSD license on |
62 | 62 | May 6, 2007. |
63 | 63 | |
64 | 64 | A couple of annoying things about Zz... |
65 | 65 | |
66 | The documentation for OpenZz doesn't mention that the /if { } construct | |
67 | has a variant that takes an else clause. And, /return does not actually | |
66 | The documentation for OpenZz doesn't mention that the `/if { }` construct | |
67 | has a variant that takes an `else` clause. And, `/return` does not actually | |
68 | 68 | cause an immediate return, it only assigns a value to the nonterminal |
69 | 69 | under consideration. For these reasons, I was originally writing many of |
70 | my tests twice (like /if a == b {} /if a != b {}). Then I noticed, in | |
71 | examining the results of /krules, that the kernel does in fact support | |
72 | else. The fact that curly braces actually denote lists means they're not | |
70 | my tests twice (like `/if a == b {} /if a != b {}`). Then I noticed, in | |
71 | examining the results of `/krules`, that the kernel does in fact support | |
72 | `else`. The fact that curly braces actually denote lists means they're not | |
73 | 73 | optional in tests though, and the nesting is still pretty annoying. |
74 | 74 | |
75 | 75 | The other annoying thing is that there's no way to prioritize selection |
76 | 76 | of nonterminals. For example, I feel very strongly that it ought to be |
77 | possible to write the score_of production like this: | |
77 | possible to write the `score_of` production like this: | |
78 | 78 | |
79 | /$num_t -> "score_of" coin { /return 5 } | |
80 | /$num_t -> "score_of" jewel { /return 10 } | |
81 | /$num_t -> "score_of" sceptre { /return 15 } | |
82 | /$num_t -> "score_of" crown { /return 20 } | |
83 | /$num_t -> "score_of" object^$ { /return 0 } | |
79 | /$num_t -> "score_of" coin { /return 5 } | |
80 | /$num_t -> "score_of" jewel { /return 10 } | |
81 | /$num_t -> "score_of" sceptre { /return 15 } | |
82 | /$num_t -> "score_of" crown { /return 20 } | |
83 | /$num_t -> "score_of" object^$ { /return 0 } | |
84 | 84 | |
85 | On the basis that coin et al. are more specific than object^$, and should | |
85 | On the basis that `coin` et al. are more specific than `object^$`, and should | |
86 | 86 | be selected before it. But, it's not possible to set this up, at least as |
87 | 87 | far as I can see. Which is a pity, because this sort of "catch-all" |
88 | 88 | mechanism would also enable much better error handling. |
101 | 101 | magic word is, you can't even use it without causing a syntax error. |
102 | 102 | But afterward it is a full-fledged part of the parser's vocabulary. |
103 | 103 | Note also that this is how the properties of an object are updated: |
104 | the production which handles "e_exit square_room" is replaced by one | |
104 | the production which handles `e_exit square_room` is replaced by one | |
105 | 105 | that returns a different value, once the door is open. |
106 | 106 | |
107 | 107 | Some of the action productions are a bit clumsy because they contain |
108 | 108 | logic that should probably be associated with the object instead. |
109 | 109 | Putting lists of statements in a property of the object, and using |
110 | Zz's /execute facility, would probably allow a "method-like" style | |
110 | Zz's `/execute` facility, would probably allow a "method-like" style | |
111 | 111 | that permits this, but I haven't played with it. |
112 | 112 | |
113 | 113 | Lastly, it's interesting to note that internal helper functions (not |
128 | 128 | |
129 | 129 | Happy adventuring! |
130 | 130 | |
131 | -Chris Pressey | |
132 | May 6, 2007 | |
131 | -Chris Pressey | |
132 | May 6, 2007 | |
133 | 133 | Vancouver, BC |