viv-compiler 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

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.
@@ -1,228 +1,460 @@
1
- // This is a specification of the syntax of the Viv action language, declared in a variant of extended Backus--Naur
2
- // form (EBNF) that is associated with the parsing expression grammar (PEG) formalism. More specifically, it is in
3
- // the format expected by the Arpeggio Python library (version 2.0.0).
4
-
5
-
6
- // The top-level nonterminal combines include declarations with action and trope definitions, in any order
7
-
8
- file = (include / trope / action)* EOF
9
-
10
-
11
- // Include declaration
12
-
13
- include = "include" filename
14
- filename = '"' (!'"' ((r'(\w+)' / r'.')))* '"' /
15
- "'" (!"'" ((r'(\w+)' / r'.')))* "'"
16
-
17
-
18
- // Action definition
19
-
20
- action = action_header action_body
21
- action_header = special_action_tag? "action" name parent_action_declaration? ":"
22
- parent_action_declaration = "from" name
23
- action_body = (
24
- (&"gloss" gloss)? /
25
- (&"report" report)? /
26
- (&"saliences" saliences)? /
27
- (&"associations" associations)? /
28
- (&"embargoes" embargoes)? /
29
- (&"tags" tags_field / &"join" tags_field)? /
30
- (&"roles" roles / &"join" roles)? /
31
- (&"preconditions" preconditions / &"join" preconditions)? /
32
- (&"scratch" scratch / &"join" scratch)? /
33
- (&"effects" effects / &"join" effects)? /
34
- (&"reactions" reactions / &"join" reactions)?
35
- )#
36
-
37
- // Trope definition
38
-
39
- trope = "trope" name trope_role_names? ":" statements
40
- trope_role_names = "with" name ("," name)*
41
-
42
-
43
- // Main components of Viv definitions
44
-
45
- special_action_tag = "special"
46
- gloss = "gloss" ":" string
47
- report = "report" ":" templated_text
48
- tags_field = child_join_operator? "tags" ":" tags
49
- tags = tag ("," tag)*
50
- tag = token
51
- roles = child_join_operator? "roles" ":" role+
52
- role = role_renaming / (number_range? binding_rate_directive? role_name binding_pool_directive? ":" role_labels)
53
- role_renaming = role_name "<<" role_name
54
- number_range = number ("-" number)?
55
- role_name = name ""
56
- binding_pool_directive = binding_pool_from_directive / binding_pool_is_directive
57
- binding_pool_from_directive = "from" expression
58
- binding_pool_is_directive = "is" expression
59
- role_labels = role_label ("," role_label)*
60
- role_label = "initiator" / "partner" / "recipient" / "bystander" / "subject" / "location" /
61
- "symbol" / "absent" / "action" / "item" / "precast" / build_directive
62
- build_directive = "build" "(" build_directive_entity_recipe ")"
63
- build_directive_entity_recipe = object
64
- binding_rate_directive = chance_directive / mean_directive
65
- chance_directive = "[" "-"? r"[0-9]+(\.[0-9]+)?" "%" "]"
66
- mean_directive = "[" "~" "-"? r"[0-9]+(\.[0-9]+)?" "]"
67
- preconditions = child_join_operator? "preconditions" ":" statements
68
- child_join_operator = "join"
69
- scratch = child_join_operator? "scratch" ":" statements
70
- effects = child_join_operator? "effects" ":" statements
71
- reactions = child_join_operator? "reactions" ":" (conditional / loop / reaction)+
72
- reaction = "queue" reaction_action_name ":" reaction_options
73
- reaction_action_name = name
74
- reaction_options = (bindings / urgent? / priority? / kill_code? / when? / where? / abandonment_conditions?)#
75
- bindings = "bindings" ":" binding+
76
- binding = (name ":" reference) / loop
77
- urgent = "urgent" ":" expression
78
- priority = "priority" ":" expression
79
- kill_code = "kill_code" ":" expression
80
- where = "where" ":" expression
81
- when = "when" (when_action_timestamp_anchor / when_hearing_timestamp_anchor) ":" time_expression
82
- when_action_timestamp_anchor = "from action"
83
- when_hearing_timestamp_anchor = "from hearing"
84
- time_expression = time_statement ("," time_statement)?
85
- time_statement = before_time_statement / after_time_statement / between_time_statement
86
- before_time_statement = "before" (time_period / time)
87
- after_time_statement = "after" (time_period / time)
88
- between_time_statement = "between" time_period "and" time_period / "between" time "and" time
89
- time_period = (number / number_word) ("minutes" / "hours" / "days" / "weeks" / "months" / "years" /
90
- "minute" / "hour" / "day" / "week" / "month" / "year" )
91
- number_word = "one" / "two" / "three" / "four" / "five" / "six" / "seven" / "eight" / "nine" /
92
- "ten" / "eleven" / "twelve"
93
- time = hh (":" mm)? ("pm" / "am" / "PM" / "AM")
94
- hh = r"[0-9]{1,2}"
95
- mm = r"[0-9]{2}"
96
- abandonment_conditions = "abandon" ":" statements
97
- saliences = child_join_operator? "saliences" saliences_default_value saliences_body?
98
- saliences_default_value = "default" (enum / number)
99
- saliences_body = ":" statement+
100
-
101
- associations = child_join_operator? "associations" associations_default_value associations_body?
102
- associations_default_value = "default" tags
103
- associations_body = ":" associations_statements
104
- associations_statements = associations_statement+
105
- associations_statement = associations_conditional / associations_loop / tags
1
+ // This is a specification of the syntax of the Viv action language, declared in a variant
2
+ // of extended Backus--Naur form (EBNF) that is associated with the parsing expression grammar
3
+ // (PEG) formalism. More specifically, it is in the format expected by the Arpeggio Python
4
+ // library (version `2.0.0`).
5
+
6
+ // // //
7
+ // Grammar root: includes, tropes, actions (in any order)
8
+ // // //
9
+
10
+ file =
11
+ (include / trope / action)* EOF
12
+
13
+
14
+ // // //
15
+ // Include declarations
16
+ // // //
17
+
18
+ include =
19
+ "include" filename
20
+ filename =
21
+ '"' (!'"' ((r'(\w+)' / r'.')))* '"' /
22
+ "'" (!"'" ((r'(\w+)' / r'.')))* "'"
23
+
24
+
25
+ // // //
26
+ // Trope headers
27
+ // // //
28
+
29
+ trope =
30
+ "trope" name trope_params? ":" statements
31
+ trope_params =
32
+ "with" trope_param ("," trope_param)*
33
+ trope_param = binding_type name
34
+
35
+
36
+ // // //
37
+ // Action headers
38
+ // // //
39
+
40
+ action =
41
+ action_header action_body
42
+ action_header =
43
+ special_action_tag? "action" name parent_action_declaration? ":"
44
+ special_action_tag =
45
+ "special"
46
+ parent_action_declaration =
47
+ "from" name
48
+ action_body =
49
+ (
50
+ (&"gloss" gloss)? /
51
+ (&"report" report)? /
52
+ (&"saliences" saliences)? /
53
+ (&"associations" associations)? /
54
+ (&"embargoes" embargoes)? /
55
+ (&"tags" tags_field / &"join" tags_field)? /
56
+ (&"roles" roles / &"join" roles)? /
57
+ (&"preconditions" preconditions / &"join" preconditions)? /
58
+ (&"scratch" scratch / &"join" scratch)? /
59
+ (&"effects" effects / &"join" effects)? /
60
+ (&"reactions" reactions / &"join" reactions)?
61
+ )#
62
+ child_join_operator =
63
+ "join"
64
+
65
+
66
+ // // //
67
+ // Glosses, reports, tags
68
+ // // //
69
+
70
+ gloss =
71
+ "gloss" ":" string
72
+ report =
73
+ "report" ":" templated_text
74
+ tags_field =
75
+ child_join_operator? "tags" ":" tags
76
+ tags =
77
+ tag ("," tag)*
78
+ tag =
79
+ !reserved r"[A-Za-z_][A-Za-z0-9\-_]*"
80
+
81
+
82
+ // // //
83
+ // Roles
84
+ // // //
85
+
86
+ roles =
87
+ child_join_operator? "roles" ":" role+
88
+ role =
89
+ role_renaming /
90
+ number_range? binding_rate_directive? binding_type role_name binding_pool_directive? ":" role_labels
91
+ binding_type =
92
+ entity_sigil / symbol_sigil
93
+ role_renaming =
94
+ role_name "<<" role_name
95
+ number_range =
96
+ number ("-" number)?
97
+ role_name =
98
+ name ''
99
+ binding_pool_directive =
100
+ binding_pool_from_directive / binding_pool_is_directive
101
+ binding_pool_from_directive =
102
+ "from" expression
103
+ binding_pool_is_directive =
104
+ "is" expression
105
+ role_labels =
106
+ role_label ("," role_label)*
107
+ role_label =
108
+ "initiator" / "partner" / "recipient" / "bystander" / "location" /
109
+ "symbol" / "absent" / "action" / "item" / "precast" / build_directive
110
+ build_directive =
111
+ "build" "(" build_directive_entity_recipe ")"
112
+ build_directive_entity_recipe =
113
+ object
114
+ binding_rate_directive =
115
+ chance_directive / mean_directive
116
+ chance_directive =
117
+ "[" "-"? r"[0-9]+(\.[0-9]+)?" "%" "]"
118
+ mean_directive =
119
+ "[" "~" "-"? r"[0-9]+(\.[0-9]+)?" "]"
120
+ preconditions =
121
+ child_join_operator? "preconditions" ":" statements
122
+
123
+
124
+ // // //
125
+ // Scratch and effects
126
+ // // //
127
+
128
+ scratch =
129
+ child_join_operator? "scratch" ":" statements
130
+ effects =
131
+ child_join_operator? "effects" ":" statements
132
+
133
+
134
+ // // //
135
+ // Reactions
136
+ // // //
137
+
138
+ reactions =
139
+ child_join_operator? "reactions" ":" (conditional / loop / reaction)+
140
+ reaction =
141
+ "queue" reaction_action_name ":" reaction_options
142
+ reaction_action_name =
143
+ name ''
144
+ reaction_options =
145
+ (bindings / urgent? / priority? / kill_code? / when? / where? / abandonment_conditions?)#
146
+ bindings =
147
+ "bindings" ":" binding+
148
+ binding =
149
+ (binding_type name ":" reference)
150
+ urgent =
151
+ "urgent" ":" expression
152
+ priority =
153
+ "priority" ":" expression
154
+ kill_code =
155
+ "kill_code" ":" expression
156
+ where =
157
+ "where" ":" expression
158
+ when =
159
+ "when" (when_action_timestamp_anchor / when_hearing_timestamp_anchor) ":" time_expression
160
+ when_action_timestamp_anchor =
161
+ "from action"
162
+ when_hearing_timestamp_anchor =
163
+ "from hearing"
164
+ time_expression =
165
+ time_statement ("," time_statement)?
166
+ time_statement =
167
+ before_time_statement / after_time_statement / between_time_statement
168
+ before_time_statement =
169
+ "before" (time_period / time)
170
+ after_time_statement =
171
+ "after" (time_period / time)
172
+ between_time_statement =
173
+ "between" time_period "and" time_period / "between" time "and" time
174
+ time_period =
175
+ (number / number_word) (
176
+ "minutes" / "hours" / "days" / "weeks" / "months" / "years" /
177
+ "minute" / "hour" / "day" / "week" / "month" / "year"
178
+ )
179
+ number_word =
180
+ "one" / "two" / "three" / "four" / "five" / "six" /
181
+ "seven" / "eight" / "nine" / "ten" / "eleven" / "twelve"
182
+ time =
183
+ hh (":" mm)? ("pm" / "am" / "PM" / "AM")?
184
+ hh =
185
+ r"[0-9]{1,2}"
186
+ mm =
187
+ r"[0-9]{2}"
188
+ abandonment_conditions =
189
+ "abandon" ":" statements
190
+
191
+
192
+ // // //
193
+ // Saliences
194
+ // // //
195
+
196
+ saliences =
197
+ child_join_operator? "saliences" saliences_default_value /
198
+ child_join_operator? "saliences" "for" local_variable saliences_default_value saliences_body?
199
+ saliences_default_value =
200
+ "default" (enum / number)
201
+ saliences_body =
202
+ ":" statement+
203
+
204
+
205
+ // // //
206
+ // Associations
207
+ // // //
208
+
209
+ associations =
210
+ child_join_operator? "associations" associations_default_value /
211
+ child_join_operator? "associations" "for" local_variable associations_default_value associations_body?
212
+ associations_default_value =
213
+ "default" tags
214
+ associations_body =
215
+ ":" associations_statements
216
+ associations_statements =
217
+ associations_statement+
218
+ associations_statement =
219
+ associations_conditional / associations_loop / tags
106
220
  associations_conditional =
107
- "if" condition ":"
108
- associations_conditional_consequent
109
- ("else:" associations_conditional_alternative)?
110
- "end"
111
- associations_conditional_consequent = associations_scoped_statements ""
112
- associations_conditional_alternative = associations_scoped_statements ""
221
+ associations_conditional_branches ("else:" associations_conditional_alternative)? "end"
222
+ associations_conditional_branches =
223
+ "if" associations_conditional_branch ("elif" associations_conditional_branch)*
224
+ associations_conditional_branch =
225
+ condition ":" associations_conditional_consequent
226
+ associations_conditional_consequent =
227
+ associations_scoped_statements ''
228
+ associations_conditional_alternative =
229
+ associations_scoped_statements ''
113
230
  associations_loop =
114
- "loop" unary_expression "as" local_variable_reference ":"
115
- associations_scoped_statements
116
- "end"
117
- associations_scoped_statements = (!"end" !"else:" associations_statement)+
118
-
119
- embargoes = child_join_operator? "embargoes" ":" embargo+
120
- embargo = embargo_roles? embargo_time_period embargo_location?
121
- embargo_roles = !embargo_time_period role_name ("," role_name)*
122
- embargo_time_period = ("for" time_period) / "forever"
123
- embargo_location = "here" ""
124
- trope_fit_expression = trope_fit_expression_args &"fits" "fits" name
125
- trope_fit_expression_args = reference ("," reference)*
126
- name = (!reserved r"[A-Za-z_][A-Za-z0-9\-_]*")
127
- reserved = "loop" / "gloss" / "roles" / "preconditions" / "effects" / "reactions" / "saliences" /
128
- "priority" / "kill_code" / "abandon" / "if" / "else" / "end" / "action" / "when" /
129
- "where" / "associations" / "special" / "default" / "urgent" / "type" / "__causes__" /
130
- "__groups__" / "__action__" / "join" / "tags" / "embargoes" / "here" / "include" /
131
- "report" / "trope" / "fits" / "with" / "scratch"
231
+ "loop" unary_expression "as" local_variable ":" associations_scoped_statements "end"
232
+ associations_scoped_statements =
233
+ (!"end" !"else:" associations_statement)+
234
+
235
+
236
+ // // //
237
+ // Embargoes
238
+ // // //
239
+
240
+ embargoes =
241
+ child_join_operator? "embargoes" ":" embargo+
242
+ embargo =
243
+ embargo_roles? embargo_time_period embargo_location?
244
+ embargo_roles =
245
+ !embargo_time_period role_name ("," role_name)*
246
+ embargo_time_period =
247
+ ("for" time_period) / "forever"
248
+ embargo_location =
249
+ "here"
250
+
251
+
252
+ // // //
253
+ // Trope-fit expressions
254
+ // // //
255
+
256
+ trope_fit_expression =
257
+ trope_fit_expression_args &"fits" "fits" name
258
+ trope_fit_expression_args =
259
+ reference ("," reference)*
132
260
 
133
261
 
262
+ // // //
134
263
  // High-level language features
264
+ // // //
135
265
 
136
- comment = r"\/\/[^\n]*"
137
- role_reference = role_reference_sigil name
138
- role_reference_sigil = "@"
139
- local_variable_reference = local_variable_sigil name
140
- local_variable_sigil = "$$"
141
- global_variable_reference = global_variable_sigil name
142
- global_variable_sigil = "$"
143
- role_unpacking = role_unpacking_sigil name
144
- role_unpacking_sigil = "*"
145
- adapter_function_call = "~" name "(" args? ")" eval_fail_safe_marker?
146
- args = expression ("," expression)*
147
- statements = statement+
148
- statement = conditional / loop / reaction / expression / literal
149
- conditional = "if" condition ":" consequent ("else:" alternative)? "end"
150
- condition = expression
151
- consequent = scoped_statements ""
152
- alternative = scoped_statements ""
153
- scoped_statements = (!"end" !"else:" statement)+
154
- loop = "loop" unary_expression "as" local_variable_reference ":" scoped_statements "end"
155
-
156
-
157
- // General expressions
158
-
159
- expression = assignment_expression / arithmetic_expression / logical_expression / unary_expression
160
- assignment_expression = &"{" &assignment_lvalue_start "{" assignment_lvalue assignment_operator expression "}" /
161
- assignment_lvalue assignment_operator expression
162
- assignment_lvalue = role_anchored_reference / local_variable_anchored_reference
163
- assignment_lvalue_start = role_reference_sigil / local_variable_sigil / global_variable_sigil
164
- arithmetic_expression = "{" unary_expression arithmetic_operator expression "}" /
165
- unary_expression arithmetic_operator expression
166
- logical_expression = disjunction ''
167
- disjunction = conjunction ("||" conjunction)* /
168
- negation? "{" conjunction ("||" conjunction)+ "}" !"&&"
169
- conjunction = ("{" expression "}" / relational_expression) ("&&" logical_expression)* /
170
- negation? "{" ("{" expression "}" / relational_expression) ("&&" logical_expression)+ "}"
171
- relational_expression = negation? "{" unary_expression relational_operator unary_expression "}" /
172
- unary_expression relational_operator unary_expression /
173
- unary_expression
174
- unary_expression = negation? "{" simple_unary_expression "}" / negation? simple_unary_expression
175
- simple_unary_expression = object / chance_expression / trope_fit_expression / adapter_function_call /
176
- list / role_anchored_reference / local_variable_anchored_reference /
177
- role_unpacking / literal
178
- chance_expression = "-"? r"[0-9]+(\.[0-9]+)?" "%"
179
- negation = "!"
180
- assignment_operator = "+=" / "-=" / "*=" / "/=" / "=" / "append" / "remove"
181
- relational_operator = "==" / "!=" / "<=" / ">=" / "<" / ">" / "in"
182
- arithmetic_operator = "+" / "-" !">" / "*" / "/"
183
- literal = enum / string / number / boolean / null_type
266
+ adapter_function_call =
267
+ "~" name "(" args? ")" eval_fail_safe_marker?
268
+ args =
269
+ expression ("," expression)*
270
+ statements =
271
+ statement+
272
+ statement =
273
+ conditional / loop / reaction / expression / literal
274
+ conditional =
275
+ conditional_branches ("else:" alternative)? "end"
276
+ conditional_branches =
277
+ "if" conditional_branch ("elif" conditional_branch)*
278
+ conditional_branch =
279
+ condition ":" consequent
280
+ condition =
281
+ expression ''
282
+ consequent =
283
+ scoped_statements ''
284
+ alternative =
285
+ scoped_statements ''
286
+ scoped_statements =
287
+ (!"end" !"else:" statement)+
288
+ loop =
289
+ "loop" unary_expression "as" local_variable ":" scoped_statements "end"
290
+ local_variable = local_variable_sigil binding_type name
184
291
 
185
292
 
293
+ // // //
294
+ // Expressions
295
+ // // //
296
+
297
+ expression =
298
+ assignment_expression / arithmetic_expression / logical_expression / unary_expression
299
+ assignment_expression =
300
+ &"{" &assignment_lvalue_start "{" assignment_lvalue assignment_operator expression "}" /
301
+ assignment_lvalue assignment_operator expression
302
+ assignment_lvalue =
303
+ reference ''
304
+ assignment_lvalue_start =
305
+ entity_sigil / symbol_sigil / scratch_variable_sigil / local_variable_sigil
306
+ arithmetic_expression =
307
+ "{" unary_expression arithmetic_operator expression "}" /
308
+ unary_expression arithmetic_operator expression
309
+ logical_expression =
310
+ disjunction ''
311
+ disjunction =
312
+ conjunction ("||" conjunction)* /
313
+ negation? "{" conjunction ("||" conjunction)+ "}" !"&&"
314
+ conjunction =
315
+ ("{" expression "}" / relational_expression) ("&&" logical_expression)* /
316
+ negation? "{" ("{" expression "}" / relational_expression) ("&&" logical_expression)+ "}"
317
+ relational_expression =
318
+ negation? "{" unary_expression relational_operator unary_expression "}" /
319
+ unary_expression relational_operator unary_expression /
320
+ unary_expression
321
+ unary_expression =
322
+ negation? "{" simple_unary_expression "}" / negation? simple_unary_expression
323
+ simple_unary_expression =
324
+ object / chance_expression / trope_fit_expression / adapter_function_call /
325
+ list / reference / role_unpacking / literal
326
+ chance_expression =
327
+ "-"? r"[0-9]+(\.[0-9]+)?" "%"
328
+ negation =
329
+ "!"
330
+ assignment_operator =
331
+ "+=" / "-=" / "*=" / "/=" / "=" / "append" / "remove"
332
+ relational_operator =
333
+ "==" / "!=" / "<=" / ">=" / "<" / ">" / "in"
334
+ arithmetic_operator =
335
+ "+" / "-" !">" / "*" / "/"
336
+ literal =
337
+ enum / string / number / boolean / null_type
338
+
339
+
340
+ // // //
341
+ // Sigils
342
+ // // //
343
+
344
+ entity_sigil =
345
+ "@"
346
+ symbol_sigil =
347
+ "&"
348
+ scratch_variable_sigil =
349
+ "$"
350
+ local_variable_sigil =
351
+ "_"
352
+ role_unpacking_sigil =
353
+ "*"
354
+
355
+
356
+ // // //
186
357
  // References
358
+ // // //
359
+
360
+ reference =
361
+ (scratch_variable_sigil / local_variable_sigil)? entity_sigil name reference_path? /
362
+ (scratch_variable_sigil / local_variable_sigil)? symbol_sigil name reference_path?
363
+ reference_path =
364
+ (reference_path_property_name / reference_path_pointer / reference_path_lookup)+
365
+ reference_path_property_name =
366
+ "." property_name eval_fail_safe_marker?
367
+ reference_path_pointer =
368
+ "->" property_name eval_fail_safe_marker?
369
+ reference_path_lookup =
370
+ "[" expression "]" eval_fail_safe_marker?
371
+ property_name =
372
+ r"[a-zA-Z0-9_]+"
373
+ eval_fail_safe_marker =
374
+ "?"
375
+ role_unpacking =
376
+ role_unpacking_sigil name
377
+
378
+
379
+ // // //
380
+ // Templated text
381
+ // // //
382
+
383
+ templated_text =
384
+ '"' (!'"' template_gap / template_frame_component_double_quote)+ '"' /
385
+ "'" (!"'" template_gap / template_frame_component_single_quote)+ "'"
386
+ template_frame_component_double_quote =
387
+ r'[^"{]+'
388
+ template_frame_component_single_quote =
389
+ r"[^'{]+"
390
+ template_gap =
391
+ "{" (reference / role_unpacking) "}"
392
+
393
+
394
+ // // //
395
+ // Enums
396
+ // // //
397
+
398
+ enum =
399
+ ('-' / '+')? enum_token
400
+ enum_token =
401
+ r'(##|#)[A-Za-z_][A-Za-z0-9\-_]*'
402
+
403
+
404
+ // // //
405
+ // Objects
406
+ // // //
407
+
408
+ object =
409
+ &"{" &object_key_start "{" (key_value_pair ("," key_value_pair)*)? "}"
410
+ object_key_start =
411
+ '"' / "'" / r"[A-Za-z_]"
412
+ key_value_pair =
413
+ key ":" value
414
+ key =
415
+ string / bare_key
416
+ bare_key =
417
+ r"[A-Za-z_][A-Za-z0-9_\-]*"
418
+ value =
419
+ expression ''
420
+
421
+
422
+ // // //
423
+ // Other literals
424
+ // // //
425
+
426
+ list =
427
+ "[" (expression ("," expression)*)? "]"
428
+ number =
429
+ sign? r"[0-9]*" point r"[0-9]+" / sign? r"[0-9]+" point?
430
+ sign =
431
+ '-' / '+'
432
+ point =
433
+ "." / "." // There must be multiple rules to get the point itself to surface
434
+ string =
435
+ '"' (!'"' (reference / space / character))* '"' /
436
+ "'" (!"'" (reference / space / character))* "'"
437
+ character =
438
+ r'[^"\'{@*$]+'
439
+ space =
440
+ r"[ \t]+"
441
+ boolean =
442
+ "true" / "false"
443
+ null_type =
444
+ "null"
445
+
446
+
447
+ // // //
448
+ // Miscellaneous
449
+ // // //
187
450
 
188
- reference = role_anchored_reference / local_variable_anchored_reference
189
- role_anchored_reference = (role_reference / global_variable_reference) reference_path?
190
- local_variable_anchored_reference = local_variable_reference reference_path?
191
- reference_path = (reference_path_property_name / reference_path_pointer / reference_path_lookup)+
192
- reference_path_property_name = "." property_name eval_fail_safe_marker?
193
- reference_path_pointer = "->" property_name eval_fail_safe_marker?
194
- reference_path_lookup = "[" expression "]" eval_fail_safe_marker?
195
- property_name = r"[a-zA-Z0-9_]+"
196
- eval_fail_safe_marker = "?" ""
197
-
198
-
199
- // Data structures
200
-
201
- list = "[" (expression ("," expression)*)? "]"
202
- object = &"{" &object_key_start "{" (key_value_pair ("," key_value_pair)*)? "}"
203
- object_key_start = '"' / "'" / r"[A-Za-z_]"
204
- key_value_pair = key ":" value
205
- key = string / bare_key
206
- bare_key = r"[A-Za-z_][A-Za-z0-9_\-]*"
207
- value = expression ''
208
-
209
-
210
- // Literals
211
-
212
- number = sign? r"[0-9]*" point r"[0-9]+" / sign? r"[0-9]+" point?
213
- sign = '-' / '+'
214
- point = "." / "." // There must be multiple rules to get the point itself to surface
215
- string = '"' (!'"' (reference / space / character))* '"' /
216
- "'" (!"'" (reference / space / character))* "'"
217
- character = r'[^"\'{@*$]+'
218
- space = r"[ \t]+"
219
- token = !reserved r"[A-Za-z_][A-Za-z0-9\-_]*"
220
- boolean = "true" / "false"
221
- null_type = "null"
222
- enum = ('-' / '+')? enum_token
223
- enum_token = r'(##|#)[A-Za-z_][A-Za-z0-9\-_]*'
224
- templated_text = '"' (!'"' template_gap / template_frame_component_double_quote)+ '"' /
225
- "'" (!"'" template_gap / template_frame_component_single_quote)+ "'"
226
- template_frame_component_double_quote = r'[^"{]+'
227
- template_frame_component_single_quote = r"[^'{]+"
228
- template_gap = "{" (reference / role_unpacking) "}"
451
+ name =
452
+ (!reserved r"[A-Za-z_][A-Za-z0-9\-_]*")
453
+ reserved =
454
+ "loop" / "gloss" / "roles" / "preconditions" / "effects" / "reactions" / "saliences" /
455
+ "priority" / "kill_code" / "abandon" / "if" / "else" / "end" / "action" / "when" /
456
+ "where" / "associations" / "special" / "default" / "urgent" / "type" / "__causes__" /
457
+ "__groups__" / "__action__" / "join" / "tags" / "embargoes" / "here" / "include" /
458
+ "report" / "trope" / "fits" / "with" / "scratch"
459
+ comment =
460
+ r"\/\/[^\n]*"