Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5/src/utilities/make_tdf/syntax.sid – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
%types%
32
 
33
/*
34
    TYPES
35
 
36
    The types NAME and NUMBER are simple built-in types.  The other types
37
    correspond directly to the calculus types.
38
*/
39
 
40
NAME ;
41
NUMBER ;
42
CONS ;
43
LINK ;
44
SORT ;
45
PARAM ;
46
SPEC ;
47
CONS-LIST ;
48
LINK-LIST ;
49
PARAM-LIST ;
50
 
51
 
52
%terminals%
53
 
54
/*
55
    TERMINALS
56
 
57
    The terminals name and number correspond to identifiers and numbers
58
    read from the input file.  The only punctuation characters used are
59
    '[', ']' and ','.  Most of the other terminals are keywords.
60
*/
61
 
62
name : () -> ( :NAME ) ;
63
number : () -> ( :NUMBER ) ;
64
 
65
break ;
66
boundaries ;
67
constructs ;
68
construct-name ;
69
edge-constructor ;
70
edge-sort ;
71
encoding ;
72
encoding-bits ;
73
entity-identifier ;
74
entity-sort ;
75
graph-edges ;
76
has-extension ;
77
kinds-of-unit ;
78
linkable-entities ;
79
lists ;
80
major-version ;
81
minor-version ;
82
options ;
83
parameter-sorts ;
84
result-sort ;
85
slists ;
86
sortid ;
87
sorts ;
88
unit-elements ;
89
unit-identifier ;
90
 
91
open ;
92
close ;
93
comma ;
94
eof ;
95
!unknown ;
96
 
97
 
98
%productions%
99
 
100
 
101
/*
102
    KEYWORD NAMES
103
 
104
    In certain positions any identifier, including keywords, are allowed.
105
    This rule describes these identifiers.
106
*/
107
 
108
<keyword_name> : () -> ( :NAME ) ;
109
 
110
any-name : () -> ( n : NAME ) = {
111
	n = name ;
112
    ||
113
	n = <keyword_name> ;
114
	{
115
		break ;
116
	    ||	boundaries ;
117
	    ||	constructs ;
118
	    ||	construct-name ;
119
	    ||	edge-constructor ;
120
	    ||	edge-sort ;
121
	    ||	encoding ;
122
	    ||	encoding-bits ;
123
	    ||	entity-identifier ;
124
	    ||	entity-sort ;
125
	    ||	graph-edges ;
126
	    ||	has-extension ;
127
	    ||	kinds-of-unit ;
128
	    ||	linkable-entities ;
129
	    ||	lists ;
130
	    ||	major-version ;
131
	    ||	minor-version ;
132
	    ||	options ;
133
	    ||	parameter-sorts ;
134
	    ||	result-sort ;
135
	    ||	slists ;
136
	    ||	sortid ;
137
	    ||	sorts ;
138
	    ||	unit-elements ;
139
	    ||	unit-identifier ;
140
	} ;
141
} ;
142
 
143
 
144
/*
145
    SORT NAME
146
 
147
    These rules describe the sort names.  These consist of a simple
148
    identifier which is looked up in the list of all sorts.  They differ
149
    in that new-sort-name creates a sort if it has not previously been
150
    defined, whereas old-sort-name gives an error.
151
*/
152
 
153
<find_new_sort> : ( :NAME ) -> ( :SORT ) ;
154
<find_old_sort> : ( :NAME ) -> ( :SORT ) ;
155
 
156
new-sort-name : () -> ( s : SORT ) = {
157
	a = name ;
158
	s = <find_new_sort> ( a ) ;
159
} ;
160
 
161
old-sort-name : () -> ( s : SORT ) = {
162
	a = name ;
163
	s = <find_old_sort> ( a ) ;
164
} ;
165
 
166
 
167
/*
168
    CONSTRUCT PARAMETERS
169
 
170
    These rules describe the construct parameters.  Each parameter consists
171
    of a sort name and a parameter identifier.
172
*/
173
 
174
<make_param> : ( :NAME, :SORT ) -> ( :PARAM ) ;
175
<null_param> : () -> ( :PARAM-LIST ) ;
176
<cons_param> : ( :PARAM, :PARAM-LIST ) -> ( :PARAM-LIST ) ;
177
 
178
param-item : () -> ( a : PARAM ) = {
179
	open ; n = any-name ; comma ; s = new-sort-name ; close ;
180
	a = <make_param> ( n, s ) ;
181
} ;
182
 
183
param-list : () -> ( p : PARAM-LIST ) = {
184
	a = param-item ;
185
	{
186
		comma ; q = param-list ;
187
	    ||	q = <null_param> ;
188
	} ;
189
	p = <cons_param> ( a, q ) ;
190
} ;
191
 
192
param-pack : () -> ( p : PARAM-LIST ) = {
193
	open ;
194
	{
195
		q = param-list ;
196
	    ||	q = <null_param> ;
197
	} ;
198
	close ;
199
	p = q ;
200
} ;
201
 
202
 
203
/*
204
    OPTIONAL CONSTRUCT INFORMATION
205
 
206
    These rules give the optional break and boundary information which
207
    may be associated with a construct.
208
*/
209
 
210
<set_break> : ( :CONS, :NUMBER ) -> () ;
211
<set_boundary> : ( :CONS, :NUMBER ) -> () ;
212
 
213
break-item : ( c : CONS ) -> () = {
214
	open ; break ; comma ; a = number ; close ;
215
	<set_break> ( c, a ) ;
216
} ;
217
 
218
number-list : ( c : CONS ) -> () = {
219
	a = number ;
220
	<set_boundary> ( c, a ) ;
221
	{
222
		comma ; number-list ( c ) ;
223
	    ||	$ ;
224
	} ;
225
} ;
226
 
227
boundary-item : ( c : CONS ) -> () = {
228
	open ; boundaries ; comma ;
229
	open ; number-list ( c ) ; close ;
230
	close ;
231
} ;
232
 
233
construct-extra : ( c : CONS ) -> () = {
234
	comma ; break-item ( c ) ; comma ; boundary-item ( c ) ;
235
    ||	comma ; break-item ( c ) ;
236
    ||	comma ; boundary-item ( c ) ;
237
    ||	$ ;
238
} ;
239
 
240
 
241
/*
242
    CONSTRUCTS
243
 
244
    These rules describe the TDF constructs.  Each construct consists of a
245
    construct name, an encoding value, plus its result and parameter sorts.
246
*/
247
 
248
<make_cons> : ( :NAME, :NUMBER, :SORT, :PARAM-LIST, :SORT ) -> ( :CONS ) ;
249
<null_cons> : () -> ( :CONS-LIST ) ;
250
<cons_cons> : ( :CONS, :CONS-LIST ) -> ( :CONS-LIST ) ;
251
 
252
construct-item : ( s : SORT ) -> ( c : CONS ) = {
253
	open ; construct-name ; comma ; n = name ; close ; comma ;
254
	open ; encoding ; comma ; e = number ; close ; comma ;
255
	open ; result-sort ; comma ; r = new-sort-name ; close ; comma ;
256
	open ; parameter-sorts ; comma ; p = param-pack ; close ;
257
	c = <make_cons> ( n, e, r, p, s ) ;
258
	construct-extra ( c ) ;
259
} ;
260
 
261
construct-list : ( s : SORT ) -> ( p : CONS-LIST ) = {
262
	open ; c = construct-item ( s ) ; close ;
263
	{
264
		comma ; q = construct-list ( s ) ;
265
	    ||	q = <null_cons> ;
266
	} ;
267
	p = <cons_cons> ( c, q ) ;
268
} ;
269
 
270
construct-pack : ( s : SORT ) -> ( p : CONS-LIST ) = {
271
	open ;
272
	{
273
		q = construct-list ( s ) ;
274
	    ||	q = <null_cons> ;
275
	} ;
276
	close ;
277
	p = q ;
278
} ;
279
 
280
 
281
/*
282
    SORTS
283
 
284
    These rules describe the TDF sorts.  Each sort consists of a sort name,
285
    the number of bits used to encode this sort, a flag indicating whether
286
    extended encoding is used, plus a list of constructs for this sort.
287
*/
288
 
289
<make_sort> : ( :SORT, :NUMBER, :NUMBER, :CONS-LIST ) -> () ;
290
 
291
sort-item : () -> () = {
292
	open ; sortid ; comma ; s = new-sort-name ; close ; comma ;
293
	open ; encoding-bits ; comma ; b = number ; close ; comma ;
294
	open ; has-extension ; comma ; e = number ; close ; comma ;
295
	open ; constructs ; comma ; p = construct-pack ( s ) ; close ;
296
	<make_sort> ( s, b, e, p ) ;
297
} ;
298
 
299
sort-list : () -> () = {
300
	open ; sort-item ; close ;
301
	{
302
		comma ; sort-list ;
303
	    ||	$ ;
304
	} ;
305
} ;
306
 
307
sort-pack : () -> () = {
308
	open ;
309
	{
310
		sort-list ;
311
	    ||	$ ;
312
	} ;
313
	close ;
314
} ;
315
 
316
 
317
/*
318
    COMPLEX LISTS OF SORTS
319
 
320
    These rules describe the TDF complex list sorts.  This is a simple list
321
    of all the complex list sorts used in the specification.
322
*/
323
 
324
<make_clist> : ( :SORT ) -> () ;
325
 
326
clist-item : () -> () = {
327
	s = new-sort-name ;
328
	<make_clist> ( s ) ;
329
} ;
330
 
331
clist-list : () -> () = {
332
	clist-item ;
333
	{
334
		comma ; clist-list ;
335
	    ||	$ ;
336
	} ;
337
} ;
338
 
339
clist-pack : () -> () = {
340
	open ;
341
	{
342
		clist-list ;
343
	    ||	$ ;
344
	} ;
345
	close ;
346
} ;
347
 
348
 
349
/*
350
    SIMPLE LISTS OF SORTS
351
 
352
    These rules describe the TDF simple list sorts.  This is a simple list
353
    of all the simple list sorts used in the specification.
354
*/
355
 
356
<make_slist> : ( :SORT ) -> () ;
357
 
358
slist-item : () -> () = {
359
	s = new-sort-name ;
360
	<make_slist> ( s ) ;
361
} ;
362
 
363
slist-list : () -> () = {
364
	slist-item ;
365
	{
366
		comma ; slist-list ;
367
	    ||	$ ;
368
	} ;
369
} ;
370
 
371
slist-pack : () -> () = {
372
	open ;
373
	{
374
		slist-list ;
375
	    ||	$ ;
376
	} ;
377
	close ;
378
} ;
379
 
380
 
381
/*
382
    OPTIONAL SORTS
383
 
384
    These rules describe the TDF optional sorts.  This is a simple list of
385
    all the optional sorts used in the specification.
386
*/
387
 
388
<make_option> : ( :SORT ) -> () ;
389
 
390
option-item : () -> () = {
391
	s = new-sort-name ;
392
	<make_option> ( s ) ;
393
} ;
394
 
395
option-list : () -> () = {
396
	option-item ;
397
	{
398
		comma ; option-list ;
399
	    ||	$ ;
400
	} ;
401
} ;
402
 
403
option-pack : () -> () = {
404
	open ;
405
	{
406
		option-list ;
407
	    ||	$ ;
408
	} ;
409
	close ;
410
} ;
411
 
412
 
413
/*
414
    LINKABLE ENTITIES
415
 
416
    These rules describe the linkable TDF entities (tags, tokens, etc.).
417
    Each such entity consists of a sort plus an associated linkage name.
418
*/
419
 
420
<make_edge_link> : ( :SORT, :NAME ) -> ( :LINK ) ;
421
<make_unit_link> : ( :SORT, :NAME ) -> ( :LINK ) ;
422
<null_link> : () -> ( :LINK-LIST ) ;
423
<cons_link> : ( :LINK, :LINK-LIST ) -> ( :LINK-LIST ) ;
424
 
425
link-item : () -> ( a : LINK ) = {
426
	open ; entity-sort ; comma ; s = old-sort-name ; close ; comma ;
427
	open ; entity-identifier ; comma ; e = any-name ; close ;
428
	a = <make_edge_link> ( s, e ) ;
429
} ;
430
 
431
link-list : () -> ( p : LINK-LIST ) = {
432
	open ; a = link-item ; close ;
433
	{
434
		comma ; q = link-list ;
435
	    ||	q = <null_link> ;
436
	} ;
437
	p = <cons_link> ( a, q ) ;
438
} ;
439
 
440
link-pack : () -> ( p : LINK-LIST ) = {
441
	open ;
442
	{
443
		q = link-list ;
444
	    ||	q = <null_link> ;
445
	} ;
446
	close ;
447
	p = q ;
448
} ;
449
 
450
 
451
/*
452
    KINDS OF UNITS
453
 
454
    These rules describe the kinds of TDF unit (tag declarations, token
455
    definitions, etc.).  Each such unit consists of a sort plus an
456
    associated linkage name.
457
*/
458
 
459
kind-item : () -> ( a : LINK ) = {
460
	open ; unit-elements ; comma ; s = old-sort-name ; close ; comma ;
461
	open ; unit-identifier ; comma ; e = any-name ; close ;
462
	a = <make_unit_link> ( s, e ) ;
463
} ;
464
 
465
kind-list : () -> ( p : LINK-LIST ) = {
466
	open ; a = kind-item ; close ;
467
	{
468
		comma ; q = kind-list ;
469
	    ||	q = <null_link> ;
470
	} ;
471
	p = <cons_link> ( a, q ) ;
472
} ;
473
 
474
kind-pack : () -> ( p : LINK-LIST ) = {
475
	open ;
476
	{
477
		q = kind-list ;
478
	    ||	q = <null_link> ;
479
	} ;
480
	close ;
481
	p = q ;
482
} ;
483
 
484
 
485
/*
486
    CONSTRUCTS FOR LINKABLE ENTITIES
487
 
488
    These rules describe the basic constructs for the TDF linkable entities.
489
    Each construct consists of a sort and a construct for building that
490
    sort.
491
*/
492
 
493
<set_edge> : ( :SORT, :NAME ) -> () ;
494
 
495
edge-item : () -> () = {
496
	open ; edge-sort ; comma ; s = old-sort-name ; close ; comma ;
497
	open ; edge-constructor ; comma ; c = name ; close ;
498
	<set_edge> ( s, c ) ;
499
} ;
500
 
501
edge-list : () -> () = {
502
	open ; edge-item ; close ;
503
	{
504
		comma ; edge-list ;
505
	    ||	$ ;
506
	} ;
507
} ;
508
 
509
edge-pack : () -> () = {
510
	open ;
511
	{
512
		edge-list ;
513
	    ||	$ ;
514
	} ;
515
	close ;
516
} ;
517
 
518
 
519
/*
520
    TDF SPECIFICATION
521
 
522
    This rule describes the overall TDF specification database.  This
523
    consists of lists of all the sorts etc. defined by the specification,
524
    plus a version number.  This is the main entry point into the grammar.
525
*/
526
 
527
<make_spec> : ( :NUMBER, :NUMBER, :LINK-LIST, :LINK-LIST ) -> ( :SPEC ) ;
528
<null_spec> : () -> ( :SPEC ) ;
529
<syntax_error> : () -> () ;
530
 
531
specification : () -> ( spec : SPEC ) = {
532
	open ;
533
	open ; sorts ; comma ; sort-pack ; close ; comma ;
534
	open ; lists ; comma ; clist-pack ; close ; comma ;
535
	open ; slists ; comma ; slist-pack ; close ; comma ;
536
	open ; options ; comma ; option-pack ; close ; comma ;
537
	open ; linkable-entities ; comma ; p = link-pack ; close ; comma ;
538
	open ; kinds-of-unit ; comma ; q = kind-pack ; close ; comma ;
539
	open ; graph-edges ; comma ; edge-pack ; close ; comma ;
540
	open ; major-version ; comma ; v1 = number ; close ; comma ;
541
	open ; minor-version ; comma ; v2 = number ; close ;
542
	close ;
543
	eof ;
544
	spec = <make_spec> ( v1, v2, p, q ) ;
545
    ##
546
	<syntax_error> ;
547
	spec = <null_spec> ;
548
} ;
549
 
550
 
551
%entry% specification ;