-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathxbgf.xsd
1387 lines (1326 loc) · 54.2 KB
/
xbgf.xsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bgf="http://planet-sl.org/bgf"
xmlns:ldf="http://planet-sl.org/ldf"
xmlns:xbgf="http://planet-sl.org/xbgf"
targetNamespace="http://planet-sl.org/xbgf">
<xsd:annotation>
<xsd:documentation>
BGF transformation operator suite
</xsd:documentation>
<xsd:documentation>
This chapter describes the transformational suite for BGF.
Most of the information present here is located in the XML Schema definition of the
language, part of the SLPS project. The rest was introduced by the language documentation
transformation commands in the process of automated generation of the manual in its
present form.
</xsd:documentation>
</xsd:annotation>
<xsd:import namespace="http://planet-sl.org/bgf" schemaLocation="bgf.xsd"/>
<xsd:element name="sequence">
<xsd:annotation>
<xsd:documentation>
Sequential composition of multiple transformations.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group ref="xbgf:transformation"/>
<xsd:element ref="xbgf:atomic"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="atomic">
<xsd:annotation>
<xsd:documentation>
Multiple transformations that must be for some reason perceived as one step.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:group ref="xbgf:transformation" maxOccurs="unbounded"/>
</xsd:complexType>
</xsd:element>
<xsd:group name="transformation">
<xsd:annotation>
<xsd:documentation>
A list of all the XBGF transformations is grouped in seven categories:
<ldf:keyword>folding-unfolding-transformation</ldf:keyword> collects those commands
that perform the well-known folding/unfolding operations in slightly varied
circumstances; <ldf:keyword>refactoring-transformation</ldf:keyword> contains
transformations that perform factoring and reorganising procedures that
do not alter the language generated by the grammar; <ldf:keyword>increasing-transformation</ldf:keyword>
increase the semantics of the language by adding new options and alternatives to it;
<ldf:keyword>decreasing-transformation</ldf:keyword> similarly decrease the semantics;
<ldf:keyword>concrete-revising-transformation</ldf:keyword> are refactorings if we use term-oriented
semantics (abstract syntax) but they are neither semantic preserving, increasing nor decreasing
transformations if we use string-oriented semantics (concrete syntax); transformations from
<ldf:keyword>abstract-revising-transformation</ldf:keyword> change the language
generated by the grammar in a way that they cannot be a priori classified as any of
the above; <ldf:keyword>decorative-transformation</ldf:keyword> are special refactorings
that are used to make or destroy labels and selectors in BGF.
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:group ref="xbgf:folding-unfolding-transformation"/>
<xsd:group ref="xbgf:refactoring-transformation"/>
<xsd:group ref="xbgf:increasing-transformation"/>
<xsd:group ref="xbgf:decreasing-transformation"/>
<xsd:group ref="xbgf:concrete-revising-transformation"/>
<xsd:group ref="xbgf:abstract-revising-transformation"/>
<xsd:group ref="xbgf:decorative-transformation"/>
<!-- semantics unclear -->
<xsd:element ref="xbgf:rename"/>
<!-- status unclear -->
<xsd:element ref="xbgf:reroot"/>
<!-- deprecated -->
<xsd:element ref="xbgf:strip"/>
<!-- debug -->
<xsd:element ref="xbgf:dump"/>
<xsd:element ref="xbgf:bypass"/>
</xsd:choice>
</xsd:group>
<xsd:group name="folding-unfolding-transformation">
<xsd:annotation>
<xsd:documentation>
Folding and unfolding activities are the most basic ones in grammar
transformation and the most used ones in grammar convergence. Since
grammar comparison is done in such a way that only applies very basic
algebraic laws in its endeavours to match the two grammars, many
more sophisticated manipulations need to be executed semi-automatically
in a programmable fashion. These manual steps help to establish a
stronger link between the convergence point and the original grammar
artifact since they aid to reveal some unapparent properties of those
grammars.
</xsd:documentation>
<xsd:documentation>
All these transformations are provably correct in the sense that
it is possible to prove that the languages generated by the grammars
before the transformation and after it are indeed the same. All
refactorings are easily reversible and introduced below in pairs.
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:unfold"/>
<xsd:element ref="xbgf:fold"/>
<xsd:element ref="xbgf:inline"/>
<xsd:element ref="xbgf:extract"/>
<xsd:element ref="xbgf:abridge"/>
<xsd:element ref="xbgf:detour"/>
<xsd:element ref="xbgf:unchain"/>
<xsd:element ref="xbgf:chain"/>
</xsd:choice>
</xsd:group>
<xsd:group name="refactoring-transformation">
<xsd:annotation>
<xsd:documentation>
Here is a list of the XBGF transformations that perform
other provably semantic-preserving refactorings
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:massage"/>
<xsd:element ref="xbgf:distribute"/>
<xsd:element ref="xbgf:factor"/>
<xsd:element ref="xbgf:deyaccify"/>
<xsd:element ref="xbgf:yaccify"/>
<xsd:element ref="xbgf:eliminate"/>
<xsd:element ref="xbgf:introduce"/>
<xsd:element ref="xbgf:import"/>
<xsd:element ref="xbgf:vertical"/>
<xsd:element ref="xbgf:horizontal"/>
<xsd:element ref="xbgf:equate"/>
<xsd:element ref="xbgf:rassoc"/>
<xsd:element ref="xbgf:lassoc"/>
<xsd:element ref="xbgf:iterate"/>
<xsd:element ref="xbgf:splitT"/>
</xsd:choice>
</xsd:group>
<xsd:group name="increasing-transformation">
<xsd:annotation>
<xsd:documentation>
Here is a list of the XBGF transformations that
lengthen the grammar (increase semantics).
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:add"/>
<xsd:element ref="xbgf:appear"/>
<xsd:element ref="xbgf:widen"/>
<xsd:element ref="xbgf:upgrade"/>
<xsd:element ref="xbgf:unite"/>
</xsd:choice>
</xsd:group>
<xsd:group name="decreasing-transformation">
<xsd:annotation>
<xsd:documentation>
Here is a list of the XBGF transformations that
shorten the grammar (decrease semantics).
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:remove"/>
<xsd:element ref="xbgf:disappear"/>
<xsd:element ref="xbgf:narrow"/>
<xsd:element ref="xbgf:downgrade"/>
<xsd:element ref="xbgf:split"/>
</xsd:choice>
</xsd:group>
<xsd:group name="concrete-revising-transformation">
<xsd:annotation>
<xsd:documentation>
We may refer to the semantics of a grammar as the language (set of strings)
generated by the grammar, as it is common for formal languages --- for
context-free grammars, in particular. With the string-oriented semantics
in mind, all transformations mentioned above in folding and refactoring
sections are semantics-preserving. To give an example where different
semantics are needed consider the scenario of aligning a concrete and
an abstract syntax.
</xsd:documentation>
<xsd:documentation>
When necessary, we may apply the algebraic interpretation of a grammar, where
grammar productions constitute an algebraic signature subject to a term-algebraic model.
In this case, the terminal occurrences in any given production do no longer carry
semantic meaning; they are part of the function symbol. (Hence, abstract and concrete
syntaxes can be aligned now.)
</xsd:documentation>
<xsd:documentation>
Some transformations that were effortlessly semantics-preserving w.r.t.
the string-oriented semantics, require designated bijective mappings
w.r.t. the term-oriented semantics, e.g., fold/unfold manipulations,
but generally, the term-oriented semantics admits a larger class of
semantics-preserving transformations than the string-oriented one.
</xsd:documentation>
<xsd:documentation>
The following section gathers those transformations that would have been
considered refactorings if we only used term-oriented semantics. From
the string-oriented point of view they revise semantics and can be deemed
as neither grammar lengthening nor grammar shortening transformations.
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:abstractize"/>
<xsd:element ref="xbgf:concretize"/>
<xsd:element ref="xbgf:permute"/>
</xsd:choice>
</xsd:group>
<xsd:group name="abstract-revising-transformation">
<xsd:annotation>
<xsd:documentation>
Some grammar differences may require more arbitrary replacements,
that cannot be expressed as semantics-preserving even in abstract
syntax. These include projections or injections of non-optional
nonterminals, adding definitions for bottom nonterminals,
performing volatile replacements.
</xsd:documentation>
<xsd:documentation>
Whenever a transformation from this group is used in a convergence
path, it signals either about a construction point where the grammar
engineer is having a temporary shortcut to be substituted later
with a longer sequence of more accurate manipulations, or an inevitable
error in the BGF that needs fixing (preferably in the original
artifact---specification, compiler sources, etc).
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:define"/>
<xsd:element ref="xbgf:undefine"/>
<xsd:element ref="xbgf:redefine"/>
<xsd:element ref="xbgf:inject"/>
<xsd:element ref="xbgf:project"/>
<xsd:element ref="xbgf:replace"/>
</xsd:choice>
</xsd:group>
<xsd:group name="decorative-transformation">
<xsd:annotation>
<xsd:documentation>
Last but not least, there are four refactorings that are
very specific to the BGF itself. Not all grammar definition formalisms
have labelled productions, but since we do, we also need two transformation
steps made possible: to <ldf:keyword>designate</ldf:keyword> an already
available production with a label, and to <ldf:keyword>unlabel</ldf:keyword>
an existing labelled production.
We strip selectors from subexpressions with
<ldf:keyword>anonymize</ldf:keyword> and add
them, naturally, with <ldf:keyword>deanonymize</ldf:keyword>.
</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element ref="xbgf:designate"/>
<xsd:element ref="xbgf:unlabel"/>
<xsd:element ref="xbgf:deanonymize"/>
<xsd:element ref="xbgf:anonymize"/>
</xsd:choice>
</xsd:group>
<xsd:element name="add">
<xsd:annotation>
<xsd:documentation>
Nonterminal definitions can be extended ("added to") vertically
and horizontally. In the former case, a given production is added
to an existing definition. In the latter case, a given branch is
added to a given expression. The
horizontal mode is there for convenience only because it could be
simulated by a sequence of extraction, vertical addition, and
inlining. There are two operators that are very similar to the
(vertical) add operator: <ldf:keyword>define</ldf:keyword> and <ldf:keyword>introduce</ldf:keyword>. The define operator
should be used when an the definition of an undefined nonterminal
is added. The introduce operator should be used when a fresh
nonterminal is to be defined.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element name="vertical">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="horizontal">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="appear">
<xsd:annotation>
<xsd:documentation>
The purpose of this transformation operator is to insert an nillable symbol (i.e.,
reducible to an empty sequence) at any place in any existing grammar production.
It takes a production as an input. Inside that production, one nillable subexpression
should be marked.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="bypass">
<xsd:annotation>
<xsd:documentation>
This is a special operator that does exactly nothing.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType/>
</xsd:element>
<xsd:element name="chain">
<xsd:annotation>
<xsd:documentation>
Just like <ldf:keyword>unchain</ldf:keyword> is a specific form of <ldf:keyword>inline</ldf:keyword>,
chaining is a disciplined form of
<ldf:link>
<text>extraction</text>
<reference>extract</reference>
</ldf:link>. The argument
production will be part of the resulting grammar; it is a chain
production, i.e., a production with a nonterminal as its defining
expression. That nonterminal is the one whose definition is to be
extracted. That definition is the defining expression of the
production (from the input grammar) whose defined nonterminal and
label (if any) matches with the argument production.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="deanonymize">
<xsd:annotation>
<xsd:documentation>
While labels are only used to name individual productions,
selectors can name arbitrary parts of any BGF expression.
This command allows to add a selector to the existing production.
To avoid disambiguations, the whole production is required
as an argument, with the newly introduced part being marked.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="define">
<xsd:annotation>
<xsd:documentation>
An undefined nonterminal is resolved by this operator. The nonterminal must be in
use. The introduce operator should be used when a fresh nonterminal
is to be defined. The add operator should be used when an existing
definition is to be extended.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="disappear">
<xsd:annotation>
<xsd:documentation>
This operator behaves like <ldf:keyword>project</ldf:keyword>, but only allows for nillable elements (optional, star) to disappear.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="downgrade">
<xsd:annotation>
<xsd:documentation>
Replaces a nonterminal with one of its definitions.
The first parameter is the scope production with one of the nonterminals marked.
The second parameter is one of that nonterminal's definitions,
which right hand side will be used for replacement.
</xsd:documentation>
<xsd:documentation>
The XBGF processor looks for the first production with the marked part (but without the markers).
If it is found, the marked part is replaced with the right hand side of the second argument
production.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="designate">
<xsd:annotation>
<xsd:documentation>
An unlabeled production is labeled. The argument production is
the intended result, i.e., the labeled production---the transformation
refuses to work if the argument production contains no label.
</xsd:documentation>
<xsd:documentation>
Labelling transformations serve two roles usually: they can be used
directly to make the labels in both grammars agree so that they can
converge; or they are used to mark the target for the transformations
that follow them and perform local manipulations.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="unlabel">
<xsd:annotation>
<xsd:documentation>
This is a reverse of <ldf:keyword>designate</ldf:keyword> that strips an existing production from a label.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="label" type="bgf:label"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="deyaccify">
<xsd:annotation>
<xsd:documentation>
Deyaccification is a widely used term that means converting recursive
definitions to iterative ones where possible. The name comes from
YACC, or Yet Another Compiler Compiler, a tool which underlying parsing
technology limits were enforcing the usage of recursive definitions back in the 1970s.
However, it somehow became common practice to remain within them
even when grammar engineers do not use yacc as such at all.
</xsd:documentation>
<xsd:documentation>
The name of a nonterminal must be provided as an argument, then
the transformation engine checks if the grammar productions for this
nonterminal fit into one of the yaccified patterns. If not, the error
is reported, otherwise the definition is replaced by one that uses
regular expression operators instead of epsilon, choice,
and recursion.
</xsd:documentation>
<xsd:documentation>
Both left- and right-recursive forms can be factored with this transformation.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="nonterminal" type="bgf:nonterminal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="distribute">
<xsd:annotation>
<xsd:documentation>
Distribute sequential composition over choices so that choices
are pulled out of sequences. The transformation
is either attempted for all productions of a nonterminal or for a
specific one appointed by its label.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="dump">
<xsd:annotation>
<xsd:documentation>
This is a debugging tool for XBGF. When the <ldf:keyword>dump</ldf:keyword> command is encountered,
the transformation sequence stops and the grammar in its
current state is dumped to the file xbgf.log.
</xsd:documentation>
<xsd:documentation>
The contents of xbgf.log can be used as an input for grammar
comparator or for copy-pasting productions and expressions
from the grammar to the construction point of the XBGF sequence.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType/>
</xsd:element>
<xsd:element name="eliminate">
<xsd:annotation>
<xsd:documentation>
An unused definition (at most used within the definition itself)
is removed. The <ldf:keyword>undefine</ldf:keyword> operator
should be utilised instead when the definition must be removed despite
remaining uses. The <ldf:keyword>remove</ldf:keyword> operator
should be utilised instead when only part of the definition (i.e.,
a production of a vertical definition) is to be removed.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="nonterminal" type="bgf:nonterminal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="extract">
<xsd:annotation>
<xsd:documentation>
A new definition is introduced by extraction. The argument provided for this
transformation
is a production that identifies both the fresh nonterminal to be introduced and the
expression that is used both as a pattern for folding and as a right hand side of
the added definition.
An optional scope can limit the application
of the folding part of the extraction transformation to a
specific production or a specific nonterminal.
</xsd:documentation>
<xsd:documentation>
If the nonterminal defined by the argument production is
already mentioned (i.e., defined or referenced) in the current
grammar, the transformation refuses to work and reports an
error. This usually signals an error in the language engineer's
logic because the existing traces of a possibly similar nonterminal
conflict with the definition that is being introduced.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
<xsd:element name="in" minOccurs="0">
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="factor">
<xsd:annotation>
<xsd:documentation>
Massage modulo factorisation over choices. The transformation
is either attempted for all productions of a nonterminal or for a
specific one appointed by its label.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:expression"/>
<xsd:element ref="bgf:expression"/>
<xsd:element name="in" minOccurs="0">
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="fold">
<xsd:annotation>
<xsd:documentation>
Folding replaces every expression that matches with the right hand
side of the given nonterminal's definition with the nonterminal
itself. As with <ldf:keyword>unfold</ldf:keyword>,
<ldf:keyword>fold</ldf:keyword> works on the scope of the grammar,
and its impact can be limited to one labelled production or to
all the productions belonging to one nonterminal. Regardless
of the specified scope, folding is not applied to the definition
of the argument nonterminal.
</xsd:documentation>
<xsd:documentation>
Since this transformation strives to preserve the language, it needs
a horizontal definition to work. When only one of several existing
definitions is used for folding, it would actually increase the semantics
of the language after transformation---the corresponding XBGF command
is called <ldf:keyword>upgrade</ldf:keyword>.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="nonterminal" type="bgf:nonterminal"/>
<xsd:element name="in" minOccurs="0">
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="horizontal">
<xsd:annotation>
<xsd:documentation>
Turn a definition based on multiple productions into a top choice-based one.
The action is a reverse of <ldf:keyword>vertical</ldf:keyword>.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="nonterminal" type="bgf:nonterminal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="inject">
<xsd:annotation>
<xsd:documentation>
The argument production defines the intended result of the
transformation --- a production that has additional components
in the sequential composition, when compared to the corresponding
production in the input grammar with the same defined nonterminal
and the same label, if any.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element ref="bgf:production"/>
</xsd:choice>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="inline" type="bgf:nonterminal">
<xsd:annotation>
<xsd:documentation>
When this transformation is performed, an existing definition is eliminated by inlining.
This means that the argument nonterminal identifies the (horizontal) definition
that is to be unfolded and stripped away from the grammar.
</xsd:documentation>
<xsd:documentation>
The semantics of <ldf:keyword>inline</ldf:keyword> is that of a sequential composition of
<ldf:keyword>unfold</ldf:keyword> and <ldf:keyword>eliminate</ldf:keyword>.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="introduce">
<xsd:annotation>
<xsd:documentation>
A definition of a fresh nonterminal is added. The <ldf:keyword>add</ldf:keyword>
operator should be used instead, if the nonterminal is already defined,
is to be merely extended. The <ldf:keyword>define</ldf:keyword> operator
should be used instead, if the nonterminal is readily in use, but merely
lacks a definition.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="import">
<xsd:annotation>
<xsd:documentation>
Allows to import another grammar: the nonterminals within it can
refer to one another, but none of the existing productions are allowed
to refer to them before this transformation takes place.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="iterate">
<xsd:annotation>
<xsd:documentation>
The reverse of <ldf:keyword>rassoc</ldf:keyword>/<ldf:keyword>lassoc</ldf:keyword>.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element ref="bgf:production"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="lassoc">
<xsd:annotation>
<xsd:documentation>
The same as <ldf:keyword>rassoc</ldf:keyword>, but replaces an iterative production found in the grammar
by a left associative repeating equivalent. The ``l'' in ``lassoc'' refers to the
intended effect at the level of derivation trees: the list of
subtrees is to be converted into a nested binary tree in a
left-associative manner.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element ref="bgf:production"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="massage">
<xsd:annotation>
<xsd:documentation>
The grammar is rewritten by local transformations such that
the language generated by the grammar (or the denotation according
to any other semantics for that matter) is preserved. The known
rewriting rules affect the use of selectors and regular expression
operators: e.g., any symbol will always generate the same set of strings
that the same symbol wrapped in a selector.
</xsd:documentation>
<xsd:documentation>
There are two expression arguments: one to be matched,
and another one that replaces the matched expression.
One of them must be in a ``massage relation'' to the other.
</xsd:documentation>
<xsd:documentation>
The scope of
the transformation can be limited.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:expression"/>
<xsd:element ref="bgf:expression"/>
<xsd:element name="in" minOccurs="0">
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="narrow">
<xsd:annotation>
<xsd:documentation>
The grammar is rewritten by local transformations such that
the language generated by the grammar (or the denotation according
to any other semantics for that matter) is decreased. The known
rewriting rules affect the use of epsilon and regular expression
operators. There are two expression arguments: one to be matched,
and another one that replaces the matched expression. The scope of
the transformation can be limited.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:expression"/>
<xsd:element ref="bgf:expression"/>
<xsd:element name="in" minOccurs="0">
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="permute">
<xsd:annotation>
<xsd:documentation>
The argument production defines the intended result of the
transformation --- a production that has the same components
in the sequential composition, but in a different order, when
compared to the corresponding production in the input grammar
with the same defined nonterminal and the same label, if any.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element ref="bgf:production"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="project">
<xsd:annotation>
<xsd:documentation>
The argument production defines the intended result of the
transformation --- a production that has fewer components
in the sequential composition, when compared to the corresponding
production in the input grammar with the same defined nonterminal
and the same label, if any.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element ref="bgf:production"/>
</xsd:choice>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="rassoc">
<xsd:annotation>
<xsd:documentation>
This transformation operator replaces an iterative production found in the grammar
by the argument production, which is a right associative repeating equivalent of
the former. Its defining expression involves a pattern of binary recursion
with regard to the defined nonterminal. The ``r'' in ``rassoc'' refers to the
intended effect at the level of derivation trees: the list of subtrees is to be
converted into a nested binary tree in a right-associative manner.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element ref="bgf:production"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="redefine">
<xsd:annotation>
<xsd:documentation>
Redefine is a <ldf:keyword>replace</ldf:keyword> variant that works on production level. When this
transformation is executed, all current productions for the
nonterminal are dropped, and all the given ones are added
to the grammar.
</xsd:documentation>
<xsd:documentation>
This transformation is nothing more than syntactic sugar
for an <ldf:keyword>undefine</ldf:keyword> followed directly
with <ldf:keyword>define</ldf:keyword>. Having it as a separate
type of transformation allows to more clearly distinguish
completing the grammar with absent definitions (usually as
initial correction step) and brutal nonterminal-level replacements
(semantic revising).
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="remove">
<xsd:annotation>
<xsd:documentation>
Productions can be removed from existing, vertical definitions.
The remaining definition must not become empty, i.e., undefined.
There is the undefine operator that can be applied in that case.
There is also a horizontal mode of removing branches from choices.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element name="vertical">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="horizontal">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="rename">
<xsd:annotation>
<xsd:documentation>
Labels, nonterminals, selectors and terminals can be renamed.
Being in line with the fundamental notion of renaming, such
renaming must be done consistently throughout the entire grammar,
without introducing any clashes. There is one justifiable
exception. That is, arguably, the scope of selectors is the
level of production as opposed to necessarily the entire grammar.
Hence, selectors can be renamed in such a scope, optionally.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice>
<xsd:element name="label">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from" type="bgf:label"/>
<xsd:element name="to" type="bgf:label"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="nonterminal">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from" type="bgf:nonterminal"/>
<xsd:element name="to" type="bgf:nonterminal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="selector">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" minOccurs="0" type="bgf:label"/>
<xsd:element name="from" type="bgf:selector"/>
<xsd:element name="to" type="bgf:selector"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="terminal">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from" type="bgf:terminal"/>
<xsd:element name="to" type="bgf:terminal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="replace">
<xsd:annotation>
<xsd:documentation>
This operator provides a last resort to grammar editing. It
basically provides access to free editing without any semantically
meaningful preconditions. There are two expression arguments:
one to be matched, and another one that replaces the matched
expression. The scope of the transformation can be limited.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:expression"/>
<xsd:element ref="bgf:expression"/>
<xsd:element name="in" minOccurs="0">
<xsd:complexType>
<xsd:group ref="xbgf:scope"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="reroot">
<xsd:annotation>
<xsd:documentation>
Redefine the roots (start symbols) of the grammar.
The empty set of roots is interpreted to abbreviate the
complete set of nonterminals used or defined by a grammar.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="root" type="bgf:nonterminal" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="abridge">
<xsd:annotation>
<xsd:documentation>
Given a reflexive chain production, i.e., a production whose
defined nonterminal equals its body, this production is simply
removed from the grammar, even if it contains some potentially
valuable information (like labels and selectors).
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="detour">
<xsd:annotation>
<xsd:documentation>
A reverse of <ldf:keyword>abridge</ldf:keyword> that can introduce
a reflexive chain production.
</xsd:documentation>
</xsd:annotation>