Recovery, Convergence and Documentation of Languages

Contents
Acknowledgements
i
Contents
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List of Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ii
ix
x
xi
1
Introduction
1.1 Research context . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Motivation and objectives . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Example scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Thesis outline and contributions . . . . . . . . . . . . . . . . . . . .
1.4.1 Chapter 2 overview: additional background . . . . . . . . . .
1.4.2 Chapter 3 overview: case study on language recovery . . . . .
1.4.3 Chapter 4 overview: language convergence . . . . . . . . . .
1.4.4 Chapter 5 overview: case study on recovery and convergence .
1.4.5 Chapter 6 overview: language documentation . . . . . . . . .
1.4.6 Chapter 7 overview: XBGF language manual . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
2
3
10
10
11
12
13
14
15
2
Additional background
2.1 Terminology . . . . . . . . . . . . . . . . . . .
2.2 Grammarware . . . . . . . . . . . . . . . . . .
2.3 Techniques for grammars . . . . . . . . . . . .
2.4 Language evolution: versions and dialects . . .
2.5 Grammar levels . . . . . . . . . . . . . . . . .
2.6 Grammar recovery methodology . . . . . . . .
2.7 Grammar definition formalism . . . . . . . . .
2.8 Grammar idiosyncrasies and parsing technology
2.9 Grammarware and tool generation . . . . . . .
2.10 Language documentation qualities . . . . . . .
2.11 Standardisation bodies . . . . . . . . . . . . .
2.12 Languages used in the thesis . . . . . . . . . .
2.13 Transformations used in the thesis . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
17
17
18
19
20
22
22
23
24
25
27
28
31
34
3
Case study on recovery
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
37
ii
Contents
3.1
3.2
3.3
3.4
4
iii
Contributions . . . . . . . . . . . . . . . . . . . . . . . . .
Semi-automated recovery of C# grammar . . . . . . . . . .
3.2.1 Step 1: Obtaining the standard . . . . . . . . . . . .
3.2.2 Step 2: Extracting the grammar . . . . . . . . . . .
3.2.3 Step 3: Fixing misprints . . . . . . . . . . . . . . .
3.2.4 Step 4: Completing a formal part . . . . . . . . . .
3.2.5 Step 5: Relaxation . . . . . . . . . . . . . . . . . .
3.2.6 Step 6: Removing idiosyncrasies from the grammar .
3.2.7 Step 7: Resolving conflicts . . . . . . . . . . . . . .
3.2.8 Step 8: Improving the grammar . . . . . . . . . . .
3.2.9 Step 9: Generating the parser . . . . . . . . . . . . .
Proposed solution generalisation and evaluation . . . . . . .
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4.1 Discussion on the method automation . . . . . . . .
3.4.2 Research objectives revisited . . . . . . . . . . . . .
Language convergence
4.1 Motivation . . . . . . . . . . . . . . . . . .
4.2 Contributions . . . . . . . . . . . . . . . .
4.3 The domain . . . . . . . . . . . . . . . . .
4.3.1 Sources of convergence . . . . . . .
4.3.2 Targets of convergence . . . . . . .
4.3.3 BGF — BNF-like Grammar Format
4.4 Grammar extraction . . . . . . . . . . . . .
4.4.1 Abstraction by extraction . . . . . .
4.4.2 Grammar extractors . . . . . . . .
4.5 Grammar comparison . . . . . . . . . . . .
4.6 Grammar transformation . . . . . . . . . .
4.7 Convergence process . . . . . . . . . . . .
4.8 Programmable grammar transformations . .
4.8.1 Transformation properties . . . . .
4.8.2 Grammar refactoring . . . . . . . .
4.8.3 Grammar editing . . . . . . . . . .
4.9 Transformation generators . . . . . . . . .
4.10 Language Convergence Infrastructure . . .
4.10.1 Main configuration elements . . . .
4.10.2 Shortcuts . . . . . . . . . . . . . .
4.10.3 Generators . . . . . . . . . . . . .
4.10.4 Sources . . . . . . . . . . . . . . .
4.10.5 Targets . . . . . . . . . . . . . . .
4.10.6 Phases . . . . . . . . . . . . . . . .
4.10.7 Test sets . . . . . . . . . . . . . . .
4.10.8 Tools . . . . . . . . . . . . . . . .
4.10.9 xstring . . . . . . . . . . . . . . .
4.11 Related work . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
37
38
38
39
40
40
40
44
48
49
49
50
54
54
55
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
57
58
58
59
61
61
63
65
65
66
68
73
76
79
79
79
81
83
86
86
87
87
87
88
89
89
90
90
91
iv
Contents
4.11.1 Interoperability . . . . . . . .
4.11.2 Testing grammarware . . . . .
4.11.3 Generators and synchronisers
4.11.4 Grammar recovery . . . . . .
4.11.5 Grammar transformation . . .
4.11.6 Grammar convergence . . . .
4.12 Concluding remarks . . . . . . . . . .
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
91
91
91
92
92
92
93
Case study on recovery and convergence
5.1 Java is not syntax-safe—apparently . . . . . . . .
5.2 Contributions . . . . . . . . . . . . . . . . . . . .
5.3 The JLS corpus . . . . . . . . . . . . . . . . . . .
5.3.1 JLS1 . . . . . . . . . . . . . . . . . . . .
5.3.2 JLS2 . . . . . . . . . . . . . . . . . . . .
5.3.3 JLS3 . . . . . . . . . . . . . . . . . . . .
5.3.4 Grammar data . . . . . . . . . . . . . . . .
5.4 Automated grammar extraction . . . . . . . . . . .
5.4.1 Assumed grammar format . . . . . . . . .
5.4.2 Phase 1 — Preprocessing . . . . . . . . . .
5.4.3 Phase 2 — Error recovery . . . . . . . . .
5.4.4 Phase 3 — Removal of doubles . . . . . .
5.4.5 Phase 4 — Precise parsing . . . . . . . . .
5.4.6 Extraction data . . . . . . . . . . . . . . .
5.5 The convergence graph . . . . . . . . . . . . . . .
5.6 Grammar transformation . . . . . . . . . . . . . .
5.6.1 Semantics-preserving operators . . . . . .
5.6.2 Semantics-in/decreasing operators . . . . .
5.6.3 Semantics-revising operators . . . . . . . .
5.6.4 Grammar refactoring . . . . . . . . . . . .
5.7 Grammar convergence phases . . . . . . . . . . .
5.7.1 Preparation phase: semantic error recovery
5.7.2 Preparation phase: fixing known bugs . . .
5.7.3 Preparation phase: initial correction . . . .
5.7.4 Nominal matching phase . . . . . . . . . .
5.7.5 Structural matching phase . . . . . . . . .
5.7.6 Resolution phase: extension . . . . . . . .
5.7.7 Resolution phase: relaxation . . . . . . . .
5.7.8 Resolution phase: correction . . . . . . . .
5.8 Measuring grammars and transformations . . . . .
5.9 Related work . . . . . . . . . . . . . . . . . . . .
5.9.1 Grammar recovery . . . . . . . . . . . . .
5.9.2 Programmable grammar transformations .
5.9.3 Grammar engineering . . . . . . . . . . .
5.9.4 Schema/metamodel comparison . . . . . .
5.9.5 Coupled transformations . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
95
95
97
98
98
99
99
99
100
101
102
104
107
107
108
108
109
109
110
112
114
117
117
117
118
119
119
119
120
120
121
122
123
124
127
128
128
Contents
v
5.10 Concluding remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6
Language documentation
6.1 Motivation . . . . . . . . . . . . . . . . . . . . . . .
6.2 Contributions . . . . . . . . . . . . . . . . . . . . .
6.3 Grammar definition formalisms . . . . . . . . . . . .
6.3.1 Defining and separating symbols . . . . . . .
6.3.2 Optionality metasymbols . . . . . . . . . . .
6.3.3 Iteration metasymbols . . . . . . . . . . . .
6.3.4 Grouping symbols . . . . . . . . . . . . . .
6.3.5 Distinguishing terminals . . . . . . . . . . .
6.3.6 Distinguishing nonterminals . . . . . . . . .
6.3.7 Breaking up long lines . . . . . . . . . . . .
6.3.8 Documenting the grammar . . . . . . . . . .
6.3.9 Beyond BNF . . . . . . . . . . . . . . . . .
6.4 Unified language document data model . . . . . . .
6.4.1 Combining existing practices into one model
6.4.2 LDF benefits . . . . . . . . . . . . . . . . .
6.4.3 Alternative approaches . . . . . . . . . . . .
6.5 LDF description . . . . . . . . . . . . . . . . . . . .
6.5.1 Title page . . . . . . . . . . . . . . . . . . .
6.5.2 Standardisation bodies . . . . . . . . . . . .
6.5.3 Placeholders for generated content . . . . . .
6.5.4 Front and back matter sections . . . . . . . .
6.5.5 Simple sections . . . . . . . . . . . . . . . .
6.5.6 Simple text . . . . . . . . . . . . . . . . . .
6.5.7 Simple figures . . . . . . . . . . . . . . . .
6.5.8 Simple tables . . . . . . . . . . . . . . . . .
6.5.9 Simple lists . . . . . . . . . . . . . . . . . .
6.5.10 Front matter lists . . . . . . . . . . . . . . .
6.5.11 Lexical part . . . . . . . . . . . . . . . . . .
6.5.12 Main sections . . . . . . . . . . . . . . . . .
6.5.13 Normative sections . . . . . . . . . . . . . .
6.5.14 Informative sections . . . . . . . . . . . . .
6.5.15 Formulæ . . . . . . . . . . . . . . . . . . .
6.5.16 Keywords, links and plain text . . . . . . . .
6.6 Transforming a language document . . . . . . . . .
6.6.1 evolutionSequence . . . . . . . . . . . . . .
6.6.2 documentTransformation . . . . . . . . . . .
6.6.3 addFigure . . . . . . . . . . . . . . . . . . .
6.6.4 addSection . . . . . . . . . . . . . . . . . .
6.6.5 addSubsection . . . . . . . . . . . . . . . .
6.6.6 append . . . . . . . . . . . . . . . . . . . .
6.6.7 combine . . . . . . . . . . . . . . . . . . . .
6.6.8 changeRole . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
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
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
162
162
162
163
163
163
164
164
164
165
165
165
167
167
170
170
XBGF language manual
7.1 Foreword . . . . . . . . . . . . . . .
7.2 Normative references . . . . . . . . .
7.3 Design goals . . . . . . . . . . . . . .
7.4 Notation . . . . . . . . . . . . . . . .
7.5 List of definitions . . . . . . . . . . .
7.6 Folding and unfolding transformations
7.6.1 unfold . . . . . . . . . . . . .
7.6.2 fold . . . . . . . . . . . . . .
7.6.3 inline . . . . . . . . . . . . .
7.6.4 extract . . . . . . . . . . . . .
7.6.5 abridge . . . . . . . . . . . .
7.6.6 detour . . . . . . . . . . . . .
7.6.7 unchain . . . . . . . . . . . .
7.6.8 chain . . . . . . . . . . . . .
7.7 Other refactoring transformations . . .
7.7.1 massage . . . . . . . . . . . .
7.7.2 distribute . . . . . . . . . . .
7.7.3 factor . . . . . . . . . . . . .
7.7.4 deyaccify . . . . . . . . . . .
7.7.5 yaccify . . . . . . . . . . . .
7.7.6 eliminate . . . . . . . . . . .
7.7.7 introduce . . . . . . . . . . .
7.7.8 import . . . . . . . . . . . . .
7.7.9 vertical . . . . . . . . . . . .
7.7.10 horizontal . . . . . . . . . . .
7.7.11 rassoc . . . . . . . . . . . . .
7.7.12 lassoc . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
173
173
174
174
175
176
178
178
180
181
182
183
184
185
186
187
187
189
190
191
193
194
195
196
197
198
199
199
6.7
7
6.6.9 drop . . . . . . . . .
6.6.10 extractSubsection . .
6.6.11 hyperlinkify . . . . .
6.6.12 importGrammar . . .
6.6.13 importSample . . . .
6.6.14 insert . . . . . . . .
6.6.15 place . . . . . . . .
6.6.16 retitle . . . . . . . .
6.6.17 removeSection . . .
6.6.18 transformDocument
6.6.19 transformGrammar .
XBGF case study . . . . . .
6.7.1 Extraction . . . . . .
6.7.2 Transformation . . .
6.7.3 Presentation . . . . .
6.7.4 Conclusion . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Contents
7.8
7.9
7.10
7.11
7.12
7.13
7.14
7.15
7.16
8
vii
7.7.13 equate . . . . . . . . . . . . . .
Language increasing transformations . .
7.8.1 add . . . . . . . . . . . . . . .
7.8.2 appear . . . . . . . . . . . . . .
7.8.3 widen . . . . . . . . . . . . . .
7.8.4 upgrade . . . . . . . . . . . . .
7.8.5 unite . . . . . . . . . . . . . .
Language decreasing transformations .
7.9.1 remove . . . . . . . . . . . . .
7.9.2 disappear . . . . . . . . . . . .
7.9.3 narrow . . . . . . . . . . . . .
7.9.4 downgrade . . . . . . . . . . .
Refactorings in term-oriented semantics
7.10.1 abstractize . . . . . . . . . . .
7.10.2 concretize . . . . . . . . . . . .
7.10.3 permute . . . . . . . . . . . . .
Semantics revising transformations . . .
7.11.1 define . . . . . . . . . . . . . .
7.11.2 undefine . . . . . . . . . . . . .
7.11.3 redefine . . . . . . . . . . . . .
7.11.4 inject . . . . . . . . . . . . . .
7.11.5 project . . . . . . . . . . . . .
7.11.6 replace . . . . . . . . . . . . .
Decorative transformations . . . . . . .
7.12.1 designate . . . . . . . . . . . .
7.12.2 unlabel . . . . . . . . . . . . .
7.12.3 deanonymize . . . . . . . . . .
7.12.4 anonymize . . . . . . . . . . .
dump . . . . . . . . . . . . . . . . . .
7.13.1 Syntax . . . . . . . . . . . . .
rename . . . . . . . . . . . . . . . . . .
7.14.1 renameL . . . . . . . . . . . .
7.14.2 renameN . . . . . . . . . . . .
7.14.3 renameS . . . . . . . . . . . . .
7.14.4 renameT . . . . . . . . . . . .
reroot . . . . . . . . . . . . . . . . . .
7.15.1 Syntax . . . . . . . . . . . . .
Compatibility . . . . . . . . . . . . . .
Conclusion
8.1 Summary . . . . . . . .
8.2 Research contributions .
8.3 Engineering deliverables
8.3.1 Grammars . . . .
8.3.2 Languages . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.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
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
231
231
232
233
233
234
viii
Contents
8.4
8.3.3 Language documents .
8.3.4 Grammar relationships
8.3.5 Tools . . . . . . . . .
Future work . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
235
236
236
238
Samenvatting
243
Bibliography
245
List of Tables
2.1
Languages used in the thesis, LOC . . . . . . . . . . . . . . . . . . . . .
31
4.1
4.2
4.3
4.4
Effort metrics and categorisation of the convergence transformations for FL.
XBGF operators usage for FL convergence. . . . . . . . . . . . . . . . .
Metrics for the FL grammars. . . . . . . . . . . . . . . . . . . . . . . . .
Metrics for the transformed grammars. . . . . . . . . . . . . . . . . . . .
83
84
84
85
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
Basic properties of the JLS grammars. . . . . . . . . . . . . . . . . . . .
Basic metrics of the JLS grammars. . . . . . . . . . . . . . . . . . . . .
Decision table of the extractor’s scanner . . . . . . . . . . . . . . . . . .
Irregularities resolved by grammar extraction. . . . . . . . . . . . . . . .
Transformation of the JLS grammars: effort metrics and categorisation. .
XBGF operators usage for JLS convergence. . . . . . . . . . . . . . . . .
Simple metrics for the derived JLS grammars. . . . . . . . . . . . . . . .
Systematic comparison of grammar transformation operators provided by
different frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . .
99
100
103
107
115
116
122
6.1
6.2
BNF dialects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Comparison of eight existing language definitions against the presented
model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
ix
126
List of Figures
1.1
Tag cloud of the text of this thesis. . . . . . . . . . . . . . . . . . . . . .
16
2.1
2.2
Code example of a transformation caused by changes in the language. . .
Dependency graph showing all language transformations . . . . . . . . .
26
34
3.1
A number parsed as an expression. . . . . . . . . . . . . . . . . . . . . .
45
4.1
4.2
4.3
4.4
4.5
4.6
4.7
The overall convergence graph for the Factorial Language . . . .
The detailed convergence graph for the Factorial Language . . .
Two similar grammar excerpts from different versions of the JLS
Transforming the grammar and proving equality . . . . . . . . .
An activity diagram for the grammar convergence workflow . .
Operators for grammar refactoring . . . . . . . . . . . . . . . .
Operators for grammar editing . . . . . . . . . . . . . . . . . .
59
60
69
74
76
81
82
5.1
5.2
Binary convergence tree for the JLS grammars . . . . . . . . . . . . . . . 96
Difference reduction for read2 and jls2 . . . . . . . . . . . . . . . . . . . 121
6.1
6.2
6.3
Railroad tracks from Micro Focus COBOL language manual . . . . . . . 141
The grammar life cycle in the transformational environment . . . . . . . 166
The language document life cycle in the prototype infrastructure . . . . . 166
7.1
Full convergence diagram for BNF and BGF . . . . . . . . . . . . . . . . 230
x
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
List of Listings
1.1
1.2
1.3
1.4
1.5
Class declaration section from JLS 1
LDF as extracted . . . . . . . . . .
LDF as intended . . . . . . . . . .
Class declaration section from JLS 2
Class declaration section from JLS 3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4
5
6
7
8
3.1
3.2
3.3
3.4
3.5
EBNF of LLL grammar format in LLL notation . . . . . . . .
Lexical part of C# grammar in SDF, part 1: lexical syntax . .
Lexical part of C# grammar in SDF, part 2: restrictions . . . .
Lexical part of C# grammar in SDF, part 3: comments . . . .
The priorities for the C# grammar externally specified by SDF
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
39
41
42
43
47
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
SDF grammar for FL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Definite Clause Grammar for FL . . . . . . . . . . . . . . . . . . . . . . . .
Ecore model for FL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
BGF — BNF-like Grammar Format . . . . . . . . . . . . . . . . . . . . . .
BGF extracted from an ANTLR front end for FL . . . . . . . . . . . . . . .
BGF extracted from the DCG for FL . . . . . . . . . . . . . . . . . . . . . .
BGF extracted from the SDF for FL . . . . . . . . . . . . . . . . . . . . . .
BGF extracted from an Ecore model for FL . . . . . . . . . . . . . . . . . .
BGF extracted from an Ecore model generated from an XML schema for FL
BGF extracted from an XML schema for FL . . . . . . . . . . . . . . . . .
BGF extracted from a manually created Java object model . . . . . . . . . .
BGF extracted from a Java object model generated by JAXB . . . . . . . . .
62
62
63
65
67
67
68
70
70
71
71
72
5.1
Self-description of relevant grammar expressiveness . . . . . . . . . . . . . 101
6.1
6.2
6.3
BNF in Full BASIC standard . . . . . . . . . . . . . . . . . . . . . . . . . . 136
BNF in Fortran standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
BGF: a sample production in XML and pretty-printed forms . . . . . . . . . 137
xi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.