graphgram is a library for generating graphs using a transformative graph grammar.
32 | This is useful if you want random graphs that have predictable structural motifs or patterns in them.
33 | The motivating use case is procedural generation of story paths or maps in interactive fiction (i.e. games),
34 | and the pioneering example of this is Joris Dormans' roguelike Unexplored
35 | as described in this RPS article.
36 | (A formal mathematical introduction to graph grammars can be found in these slides by Matilde Marcolli.)
37 |
The way that graphgram works is as follows. A basic graph grammar consists of a set of transformation rules.
38 | Each such rule contains, at minimum, a left-hand side and a right-hand side: the rule has the form LHS → RHS.
The right-hand side specifies a subgraph that will be pasted in as a replacement for the matching subgraph.
42 |
43 |
Beyond simply matching subgraph topologies, graphgram offers considerable flexibility in the way that the LHS pattern-matching occurs.
44 | Each node and edge in the graph can have a label which can be a string or an arbitrary JSON object.
45 | There is a simple query language for matching labels (or the user can define their own label-matching function).
46 | The grammar specification also allows for constraints limiting the number and type of transformation rules that can be applied to generate any single graph.
47 |
The library can be called via the API of the Grammar class, or using the command-line tool bin/transform.js.
All graphs generated by graphgram are directed.
50 | Undirected edges can be represented using two directed edges, one pointing forwards and one backwards.
51 |
Dungeon grammar
52 |
The default grammar for the CLI, for demo purposes, is a dungeon-generation grammar that is fairly close to the following:
The full flexibility of matching any subgraph and replacing it with another subgraph of arbitrary topology (possibly with some overlap/reuse of nodes and/or edges from the matched subgraph) can be quite daunting and is probably overkill for most purposes.
83 | In recognition of this, graphgram offers a few syntactical shortcuts for common types of transformation rule and graph
84 | (corresponding to sequence grammars, context-free grammars, and so on).
85 | These are fully described in the documentation for the JSON schema for the `Grammar`` class.
86 |
One of these syntactical shortcuts is heavily used by the above dungeon grammar:
87 | all the transformation rules in that grammar have a single node on the left-hand side.
88 | This means that the subgraph matching algorithm is not being heavily exercised by this grammar;
89 | it is effectively a context-free node replacement grammar.
90 |
The simplest kind of rule in this grammar has the form:
91 |
{ lhs: 'chest_contents', rhs: 'weapon' },
92 |
93 |
This simply means "replace a node whose label is chest_contents with a node whose label is weapon".
This replaces the node labeled START with a sequence of three nodes:
98 | entrance→x→boss.
99 |
The edges connecting consecutive nodes are added by default when an array of node labels is given.
100 | This corresponds to inserting a sequence of nodes at a particular point (as in a string transformation grammar).
101 | For an example of a rule where the replacement subgraph is not just a linear chain, so that its topology must be specified explicitly,
102 | consider the following:
This replaces a node labeled x with a subgraph containing four nodes labeled (respectively)
106 | fork (node 0), x (node 1), die (node 2) and x (node 3).
107 | The edge clause in the rhs of this rule contains three tuples of the form [v,w] where v and w represent the indices of
108 | (respectively) the source and target nodes in the replacement subgraph.
109 | Thus, the subgraph contains a fork node that has edges to two new x nodes, the first of which then leads to a die node.
110 | The first node on the RHS inherits the edges that are incoming to the LHS node, and the last node on the RHS inherits its outgoing edges
111 | (this behavior can be overridden, as described in the JSON schema).
112 |
The actual rule that appears in the example grammar is slightly different from this:
The type and limit fields indicate that this rule has type "ending" and can only be used if fewer than 3 rules with that type have already been applied.
116 |
For examples of more sophisticated subgraph replacement rules that include context and nontrivial topology on the LHS,
117 | as well as compound expressions for matching/replacing node and edge labels,
118 | see the level.js example grammar
119 | which generates levels for the "roguelike snakelike" game nemato.de.
120 |
121 |
122 |
123 |
124 |
125 |
126 |
129 |
130 |
131 |
132 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/grammars/dungeon.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dungeon-grammar",
3 | "start": "START",
4 | "stages": [
5 | {
6 | "name": "generation-stage",
7 | "rules": [
8 | {
9 | "lhs": "START",
10 | "rhs": [
11 | "entrance",
12 | "x",
13 | "boss"
14 | ]
15 | },
16 | {
17 | "lhs": "x",
18 | "rhs": [
19 | "x",
20 | "x"
21 | ],
22 | "limit": 3
23 | },
24 | {
25 | "lhs": "x",
26 | "rhs": {
27 | "node": [
28 | "fork",
29 | "x",
30 | "die",
31 | "x"
32 | ],
33 | "edge": [
34 | [
35 | 0,
36 | 1
37 | ],
38 | [
39 | 1,
40 | 2
41 | ],
42 | [
43 | 0,
44 | 3
45 | ]
46 | ]
47 | },
48 | "type": "ending",
49 | "limit": 3
50 | },
51 | {
52 | "lhs": "x",
53 | "rhs": {
54 | "node": [
55 | "fork",
56 | "x",
57 | "live",
58 | "x"
59 | ],
60 | "edge": [
61 | [
62 | 0,
63 | 1
64 | ],
65 | [
66 | 1,
67 | 2
68 | ],
69 | [
70 | 0,
71 | 3
72 | ]
73 | ]
74 | },
75 | "type": "ending",
76 | "limit": 3
77 | },
78 | {
79 | "lhs": "x",
80 | "rhs": {
81 | "node": [
82 | "fork",
83 | "x",
84 | "x",
85 | "x"
86 | ],
87 | "edge": [
88 | [
89 | 0,
90 | 1
91 | ],
92 | [
93 | 0,
94 | 2
95 | ],
96 | [
97 | 1,
98 | 3
99 | ],
100 | [
101 | 2,
102 | 3
103 | ]
104 | ]
105 | },
106 | "type": "fork",
107 | "limit": 2,
108 | "delay": 2
109 | },
110 | {
111 | "lhs": "x",
112 | "rhs": {
113 | "node": [
114 | "crossroads",
115 | "x",
116 | "x",
117 | "x",
118 | "x"
119 | ],
120 | "edge": [
121 | [
122 | 0,
123 | 1
124 | ],
125 | [
126 | 0,
127 | 2
128 | ],
129 | [
130 | 0,
131 | 3
132 | ],
133 | [
134 | 1,
135 | 4
136 | ],
137 | [
138 | 2,
139 | 4
140 | ],
141 | [
142 | 3,
143 | 4
144 | ]
145 | ]
146 | },
147 | "type": "fork",
148 | "limit": 1,
149 | "delay": 2
150 | },
151 | {
152 | "lhs": "x",
153 | "rhs": {
154 | "node": [
155 | "door",
156 | "x1",
157 | "x"
158 | ],
159 | "edge": [
160 | [
161 | 0,
162 | 1,
163 | "enter"
164 | ],
165 | [
166 | 1,
167 | 2,
168 | "exit"
169 | ],
170 | [
171 | 0,
172 | 2,
173 | "bypass"
174 | ]
175 | ]
176 | },
177 | "limit": 3
178 | },
179 | {
180 | "lhs": "x",
181 | "rhs": {
182 | "node": [
183 | "fork",
184 | "x",
185 | "x",
186 | "x",
187 | "rescue",
188 | "x",
189 | "x"
190 | ],
191 | "edge": [
192 | [
193 | 0,
194 | 1
195 | ],
196 | [
197 | 1,
198 | 2
199 | ],
200 | [
201 | 2,
202 | 3
203 | ],
204 | [
205 | 0,
206 | 3
207 | ],
208 | [
209 | 3,
210 | 4
211 | ],
212 | [
213 | 4,
214 | 5
215 | ],
216 | [
217 | 5,
218 | 6
219 | ],
220 | [
221 | 3,
222 | 6
223 | ],
224 | [
225 | 1,
226 | 4,
227 | "rumor"
228 | ]
229 | ]
230 | },
231 | "type": "rescue",
232 | "limit": 1
233 | },
234 | {
235 | "lhs": "x",
236 | "rhs": {
237 | "node": [
238 | "door",
239 | "x1",
240 | "x",
241 | "rescue",
242 | "x",
243 | "x"
244 | ],
245 | "edge": [
246 | [
247 | 0,
248 | 1,
249 | "enter"
250 | ],
251 | [
252 | 1,
253 | 2,
254 | "exit"
255 | ],
256 | [
257 | 0,
258 | 2,
259 | "bypass"
260 | ],
261 | [
262 | 2,
263 | 3
264 | ],
265 | [
266 | 3,
267 | 4
268 | ],
269 | [
270 | 4,
271 | 5
272 | ],
273 | [
274 | 2,
275 | 5
276 | ],
277 | [
278 | 1,
279 | 3,
280 | "rumor"
281 | ]
282 | ]
283 | },
284 | "type": "rescue",
285 | "limit": 1
286 | },
287 | {
288 | "lhs": "x",
289 | "rhs": {
290 | "node": [
291 | "chest",
292 | "chest_contents",
293 | "x"
294 | ],
295 | "edge": [
296 | [
297 | 0,
298 | 1,
299 | "open"
300 | ],
301 | [
302 | 1,
303 | 2
304 | ],
305 | [
306 | 0,
307 | 2,
308 | "ignore"
309 | ]
310 | ]
311 | },
312 | "limit": 3
313 | },
314 | {
315 | "lhs": "chest_contents",
316 | "rhs": "trap",
317 | "weight": 2
318 | },
319 | {
320 | "lhs": "chest_contents",
321 | "rhs": "treasure"
322 | },
323 | {
324 | "lhs": "chest_contents",
325 | "rhs": "weapon"
326 | },
327 | {
328 | "lhs": "x",
329 | "rhs": {
330 | "node": [
331 | "vial",
332 | "vial_contents",
333 | "x"
334 | ],
335 | "edge": [
336 | [
337 | 0,
338 | 1,
339 | "drink"
340 | ],
341 | [
342 | 1,
343 | 2
344 | ],
345 | [
346 | 0,
347 | 2,
348 | "ignore"
349 | ]
350 | ]
351 | },
352 | "limit": 3
353 | },
354 | {
355 | "lhs": "vial_contents",
356 | "rhs": "potion"
357 | },
358 | {
359 | "lhs": "vial_contents",
360 | "rhs": "poison"
361 | },
362 | {
363 | "lhs": "x",
364 | "rhs": "x1",
365 | "delay": 10
366 | },
367 | {
368 | "lhs": "x1",
369 | "rhs": "trap"
370 | },
371 | {
372 | "lhs": "x1",
373 | "rhs": "monster"
374 | },
375 | {
376 | "lhs": "x1",
377 | "rhs": "weapon",
378 | "limit": 2
379 | },
380 | {
381 | "lhs": "x1",
382 | "rhs": "treasure",
383 | "limit": 3
384 | },
385 | {
386 | "lhs": "x1",
387 | "rhs": "scenery",
388 | "weight": 2
389 | }
390 | ]
391 | },
392 | {
393 | "name": "decoration-stage",
394 | "rules": [
395 | {
396 | "name": "dot-rumor-edge",
397 | "lhs": {
398 | "node": [
399 | {
400 | "id": "a"
401 | },
402 | {
403 | "id": "b"
404 | }
405 | ],
406 | "edge": [
407 | [
408 | "a",
409 | "b",
410 | "rumor"
411 | ]
412 | ]
413 | },
414 | "rhs": {
415 | "node": [
416 | {
417 | "id": "a"
418 | },
419 | {
420 | "id": "b"
421 | }
422 | ],
423 | "edge": [
424 | [
425 | "a",
426 | "b",
427 | {
428 | "dot": {
429 | "label": "rumor",
430 | "style": "dotted"
431 | }
432 | }
433 | ]
434 | ]
435 | }
436 | },
437 | {
438 | "name": "flag-endpoints",
439 | "lhs": "(die|live|boss)",
440 | "rhs": {
441 | "node": [
442 | {
443 | "label": {
444 | "endpoint": "${a.match[1]}"
445 | }
446 | }
447 | ]
448 | }
449 | },
450 | {
451 | "name": "make-endpoints-rectangular",
452 | "lhs": {
453 | "node": [
454 | {
455 | "id": "a",
456 | "label": {
457 | "$equals": {
458 | "endpoint": ".*"
459 | }
460 | }
461 | }
462 | ]
463 | },
464 | "rhs": {
465 | "node": [
466 | {
467 | "id": "a",
468 | "update": {
469 | "dot": {
470 | "label": "${a.match.endpoint[0]}",
471 | "shape": "rect"
472 | }
473 | }
474 | }
475 | ]
476 | }
477 | }
478 | ]
479 | }
480 | ]
481 | }
482 |
--------------------------------------------------------------------------------
/out/scripts/prettify/Apache-License-2.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/docs/jsdoc/scripts/prettify/Apache-License-2.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/grammars/level.js:
--------------------------------------------------------------------------------
1 | {
2 | name: 'level-grammar',
3 | stages:
4 | [{ name: 'init',
5 | limit: 1,
6 | rules: [
7 | // replace init--node with start-->end
8 | { lhs: { node: [{ id: "init", label: { name: "init" } },
9 | { id: "node", label: { name: "node" } }],
10 | edge: [{ v: "init", w: "node", label: { name: "edge" } },
11 | { v: "node", w: "init", label: { name: "edge" } }] },
12 | rhs: { node: [{ id: "start", head:["init"], tail:["init"], label: { $merge: [ { $eval: '$init.label' },
13 | { name: "start" }] } },
14 | { id: "end", head:["node"], tail:["node"], label: { $merge: [ { $eval: '$node.label' },
15 | { name: "end",
16 | endpoint: true }] } }],
17 | edge: [{ v: "start", w: "end", label: { name: "path" } }] } }
18 | ] },
19 |
20 | { name: 'extend',
21 | rules: [
22 | // replace b--x with mid-->end where b is an endpoint
23 | { weight: 2,
24 | lhs: { node: [{ id: "b", label: { endpoint: true } },
25 | { id: "x", label: { name: "node" } }],
26 | edge: [{ v: "b", w: "x", label: { name: "edge" } },
27 | { v: "x", w: "b", label: { name: "edge" } }] },
28 | rhs: { node: [{ id: "mid", head:["b"], tail:["b"], label: { $merge: [ { $eval: '$b.label' },
29 | { name: "room" } ] } },
30 | { id: "end", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
31 | { name: '${b.label.name}' } ] } }],
32 | edge: [{ v: "mid", w: "end", label: { name: "path" } }] } },
33 |
34 | // replace x--a-->... with herring<--a-->...
35 | { weight: .25,
36 | limit: 2,
37 | lhs: { node: [{ id: "a", label: { $and: [{ $not: { name: "node" } },
38 | { $not: { endpoint: true } }] } },
39 | { id: "x", label: { name: "node" } }],
40 | edge: [{ v: "a", w: "x", label: { name: "edge" } },
41 | { v: "x", w: "a", label: { name: "edge" } }] },
42 | rhs: { node: [{ id: "a" },
43 | { id: "side", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
44 | { name: 'herring',
45 | endpoint: true } ] } }],
46 | edge: [{ v: "a", w: "side", label: { name: "path" } }] } },
47 |
48 | // replace a->d with a->d
49 | // | | | ^
50 | // | | v |
51 | // x--y b->c
52 |
53 | // wrinkle in path (no a->d connection on rhs)
54 | { lhs: { node: [{ id: "a", label: { $not: { name: "node" } } },
55 | { id: "d", label: { $not: { name: "node" } } },
56 | { id: "x", label: { name: "node" } },
57 | { id: "y", label: { name: "node" } }],
58 | edge: [{ v: "a", w: "d", label: { name: "path" } },
59 | { v: "a", w: "x", label: { name: "edge" } },
60 | { v: "x", w: "a", label: { name: "edge" } },
61 | { v: "x", w: "y", label: { name: "edge" } },
62 | { v: "y", w: "x", label: { name: "edge" } },
63 | { v: "y", w: "d", label: { name: "edge" } },
64 | { v: "d", w: "y", label: { name: "edge" } }] },
65 | rhs: { node: [{ id: "a" },
66 | { id: "d" },
67 | { id: "b", head:["x"], tail:["x"], label: { $merge: [{ $eval: '$x.label' },
68 | { name: "room" }] } },
69 | { id: "c", head:["y"], tail:["y"], label: { $merge: [{ $eval: '$y.label' },
70 | { name: "room" }] } }],
71 | edge: [{ v: "a", w: "b", label: { name: "path" } },
72 | { v: "b", w: "c", label: { name: "path" } },
73 | { v: "c", w: "d", label: { name: "path" } }] } },
74 |
75 | // fork: a->d splits to a->d->c and a->b->c. endpoint moves from d to c
76 | { weight: .1,
77 | limit: 4,
78 | lhs: { node: [{ id: "a", label: { $not: { name: "node" } } },
79 | { id: "d", label: { endpoint: true } },
80 | { id: "x", label: { name: "node" } },
81 | { id: "y", label: { name: "node" } }],
82 | edge: [{ v: "a", w: "d", label: { name: "path" } },
83 | { v: "a", w: "x", label: { name: "edge" } },
84 | { v: "x", w: "a", label: { name: "edge" } },
85 | { v: "x", w: "y", label: { name: "edge" } },
86 | { v: "y", w: "x", label: { name: "edge" } },
87 | { v: "y", w: "d", label: { name: "edge" } },
88 | { v: "d", w: "y", label: { name: "edge" } }] },
89 | rhs: { node: [{ id: "a" },
90 | { id: "d2", head:["d"], tail:["d"], label: { $merge: [ { $eval: '$d.label' },
91 | { name: "room" } ] } },
92 | { id: "b", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
93 | { name: "room" } ] } },
94 | { id: "c", head:["y"], tail:["y"], label: { $merge: [ { $eval: '$y.label' },
95 | { name: '${d.label.name}' } ] } }],
96 | edge: [{ v: "a", w: "b", label: { name: "fork", dot: { style: "dotted" } } },
97 | { v: "b", w: "c", label: { name: "path" } },
98 | { v: "a", w: "d2", label: { name: "fork", dot: { style: "dotted" } } },
99 | { v: "d2", w: "c", label: { name: "path" } }] } },
100 |
101 |
102 | // cave: a->b->c adds a corner d
103 | { weight: 1,
104 | limit: 4,
105 | lhs: { node: [{ id: "a", label: { $not: { name: "node" } } },
106 | { id: "b", label: { $not: { name: "node" } } },
107 | { id: "c", label: { $not: { name: "node" } } },
108 | { id: "x", label: { name: "node" } }],
109 | edge: [{ v: "a", w: "b", label: { $or: [ { name: "path" }, { name: "cave" } ] } },
110 | { v: "b", w: "c", label: { $or: [ { name: "path" }, { name: "cave" } ] } },
111 | { v: "a", w: "x", label: { name: "edge" } },
112 | { v: "x", w: "a", label: { name: "edge" } },
113 | { v: "c", w: "x", label: { name: "edge" } },
114 | { v: "x", w: "c", label: { name: "edge" } }] },
115 | rhs: { node: [{ id: "a" },
116 | { id: "b" },
117 | { id: "c" },
118 | { id: "d", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
119 | { name: "room" } ] } }],
120 | edge: [{ v: "a", w: "b", label: { name: "cave", dot: { style: "dotted" } } },
121 | { v: "b", w: "c", label: { name: "cave", dot: { style: "dotted" } } },
122 | { v: "a", w: "d", label: { name: "cave", dot: { style: "dotted" } } },
123 | { v: "d", w: "c", label: { name: "cave", dot: { style: "dotted" } } },
124 | { v: "a", w: "c", label: { dot: { style: "dotted" } } },
125 | { v: "b", w: "d", label: { dot: { style: "dotted" } } }] } },
126 |
127 | // shortcut
128 | { limit: 3,
129 | lhs: { node: [{ id: "a", label: { $not: { name: "node" } } },
130 | { id: "d", label: { $not: { name: "node" } } },
131 | { id: "x", label: { name: "node" } },
132 | { id: "y", label: { name: "node" } }],
133 | edge: [{ v: "a", w: "d", label: { name: "path" } },
134 | { v: "a", w: "x", label: { name: "edge" } },
135 | { v: "x", w: "a", label: { name: "edge" } },
136 | { v: "x", w: "y", label: { name: "edge" } },
137 | { v: "y", w: "x", label: { name: "edge" } },
138 | { v: "y", w: "d", label: { name: "edge" } },
139 | { v: "d", w: "y", label: { name: "edge" } }] },
140 | rhs: { node: [{ id: "a" },
141 | { id: "d" },
142 | { id: "b", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
143 | { name: "room" } ] } },
144 | { id: "c", head:["y"], tail:["y"], label: { $merge: [ { $eval: '$y.label' },
145 | { name: "room" } ] } }],
146 | edge: [{ v: "a", w: "d", label: { name: "shortcut", dot: { style: "dotted" } } },
147 | { v: "a", w: "b", label: { name: "path" } },
148 | { v: "b", w: "c", label: { name: "path" } },
149 | { v: "c", w: "d", label: { name: "path" } }] } },
150 |
151 | // valves to side quest
152 | { limit: 3,
153 | lhs: { node: [{ id: "a", label: { $not: { name: "node" } } },
154 | { id: "d", label: { $not: { name: "node" } } },
155 | { id: "x", label: { name: "node" } },
156 | { id: "y", label: { name: "node" } }],
157 | edge: [{ v: "a", w: "d", label: { name: "path" } },
158 | { v: "a", w: "x", label: { name: "edge" } },
159 | { v: "x", w: "a", label: { name: "edge" } },
160 | { v: "x", w: "y", label: { name: "edge" } },
161 | { v: "y", w: "x", label: { name: "edge" } },
162 | { v: "y", w: "d", label: { name: "edge" } },
163 | { v: "d", w: "y", label: { name: "edge" } }] },
164 | rhs: { node: [{ id: "a" },
165 | { id: "d" },
166 | { id: "b", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
167 | { name: "room" } ] } },
168 | { id: "c", head:["y"], tail:["y"], label: { $merge: [ { $eval: '$y.label' },
169 | { name: "room" } ] } }],
170 | edge: [{ v: "a", w: "d", label: { name: "path" } },
171 | { v: "a", w: "b", label: { name: "valve", dot: { style: "dotted" } } },
172 | { v: "b", w: "c", label: { name: "path" } },
173 | { v: "c", w: "d", label: { name: "valve", dot: { style: "dotted" } } }] } },
174 |
175 | // key-door
176 | { limit: 1,
177 | weight: .5,
178 | lhs: { node: [{ id: "a", label: { $not: { name: "node" } } },
179 | { id: "d", label: { $not: { name: "node" } } },
180 | { id: "x", label: { name: "node" } },
181 | { id: "y", label: { name: "node" } }],
182 | edge: [{ v: "a", w: "d", label: { name: "path" } },
183 | { v: "a", w: "x", label: { name: "edge" } },
184 | { v: "x", w: "a", label: { name: "edge" } },
185 | { v: "x", w: "y", label: { name: "edge" } },
186 | { v: "y", w: "x", label: { name: "edge" } },
187 | { v: "y", w: "d", label: { name: "edge" } },
188 | { v: "d", w: "y", label: { name: "edge" } }] },
189 | rhs: { node: [{ id: "a" },
190 | { id: "d" },
191 | { id: "b", head:["x"], tail:["x"], label: { $merge: [ { $eval: '$x.label' },
192 | { name: "room" } ] } },
193 | { id: "c", head:["y"], tail:["y"], label: { $merge: [ { $eval: '$y.label' },
194 | { name: "room" } ] } }],
195 | edge: [{ v: "a", w: "d", label: { name: "lock", dot: { style: "dotted" } } },
196 | { v: "a", w: "c", label: { name: "key", dot: { style: "dotted" } } },
197 | { v: "a", w: "b", label: { name: "path" } },
198 | { v: "b", w: "c", label: { name: "path" } },
199 | { v: "c", w: "a", label: { name: "valve", dot: { style: "dashed" } } }] } },
200 |
201 | ] },
202 |
203 | { name: 'trim',
204 | rules: [
205 | { lhs: { node: [{ id: "a" },
206 | { id: "b" }],
207 | edge: [{ v: "a", w: "b", label: { name: "edge" } }] },
208 | rhs: { node: [{ id: "a" },
209 | { id: "b" }],
210 | edge: [] } }
211 | ] }
212 | ]
213 | }
214 |
--------------------------------------------------------------------------------
/out/scripts/prettify/prettify.js:
--------------------------------------------------------------------------------
1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]+/],["dec",/^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^