Preface |
|
xix | |
|
|
1 | (144) |
|
Chapter 1 An Introductory Example |
|
|
3 | (24) |
|
|
3 | (2) |
|
|
4 | (1) |
|
|
5 | (4) |
|
Programming Miss Grant's Controller |
|
|
9 | (7) |
|
Languages and Semantic Model |
|
|
16 | (3) |
|
|
19 | (3) |
|
Using Language Workbenches |
|
|
22 | (2) |
|
|
24 | (3) |
|
Chapter 2 Using Domain-Specific Languages |
|
|
27 | (16) |
|
Defining Domain-Specific Languages |
|
|
27 | (6) |
|
|
29 | (3) |
|
Fragmentary and Stand-alone DSLs |
|
|
32 | (1) |
|
|
33 | (3) |
|
Improving Development Productivity |
|
|
33 | (1) |
|
Communication with Domain Experts |
|
|
34 | (1) |
|
Change in Execution Context |
|
|
35 | (1) |
|
Alternative Computational Model |
|
|
36 | (1) |
|
|
36 | (3) |
|
|
37 | (1) |
|
|
37 | (1) |
|
|
38 | (1) |
|
|
39 | (1) |
|
Wider Language Processing |
|
|
39 | (1) |
|
|
40 | (2) |
|
What Makes a Good DSL Design? |
|
|
42 | (1) |
|
Chapter 3 Implementing DSLs |
|
|
43 | (24) |
|
Architecture of DSL Processing |
|
|
43 | (4) |
|
|
47 | (2) |
|
Grammars, Syntax, and Semantics |
|
|
49 | (1) |
|
|
50 | (2) |
|
|
52 | (1) |
|
|
53 | (9) |
|
Testing the Semantic Model |
|
|
53 | (4) |
|
|
57 | (4) |
|
|
61 | (1) |
|
|
62 | (2) |
|
|
64 | (3) |
|
Chapter 4 Implementing an Internal DSL |
|
|
67 | (22) |
|
Fluent and Command-Query APIs |
|
|
68 | (3) |
|
The Need for a Parsing Layer |
|
|
71 | (1) |
|
|
72 | (5) |
|
|
77 | (2) |
|
Using Grammars to Choose Internal Elements |
|
|
79 | (1) |
|
|
80 | (2) |
|
|
82 | (2) |
|
|
84 | (1) |
|
|
85 | (1) |
|
Reducing the Syntactic Noise |
|
|
85 | (1) |
|
|
86 | (1) |
|
Providing Some Type Checking |
|
|
87 | (2) |
|
Chapter 5 Implementing an External DSL |
|
|
89 | (16) |
|
Syntactic Analysis Strategy |
|
|
89 | (3) |
|
Output Production Strategy |
|
|
92 | (2) |
|
|
94 | (6) |
|
|
94 | (1) |
|
|
95 | (1) |
|
Regular, Context-Free, and Context-Sensitive Grammars |
|
|
96 | (2) |
|
Top-Down and Bottom-Up Parsing |
|
|
98 | (2) |
|
Mixing-in Another Language |
|
|
100 | (1) |
|
|
101 | (4) |
|
Chapter 6 Choosing between Internal and External DSLs |
|
|
105 | (8) |
|
|
105 | (1) |
|
|
106 | (1) |
|
|
107 | (1) |
|
Communication with Domain Experts |
|
|
108 | (1) |
|
Mixing in the Host Language |
|
|
108 | (1) |
|
Strong Expressiveness Boundary |
|
|
109 | (1) |
|
|
110 | (1) |
|
|
110 | (1) |
|
|
111 | (1) |
|
|
111 | (2) |
|
Chapter 7 Alternative Computational Models |
|
|
113 | (8) |
|
|
116 | (5) |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
119 | (1) |
|
|
120 | (1) |
|
Chapter 8 Code Generation |
|
|
121 | (8) |
|
Choosing What to Generate |
|
|
122 | (2) |
|
|
124 | (2) |
|
Mixing Generated and Handwritten Code |
|
|
126 | (1) |
|
|
127 | (1) |
|
|
128 | (1) |
|
|
128 | (1) |
|
Chapter 9 Language Workbenches |
|
|
129 | (16) |
|
Elements of Language Workbenches |
|
|
130 | (1) |
|
Schema Definition Languages and Meta-Models |
|
|
131 | (5) |
|
Source and Projectional Editing |
|
|
136 | (2) |
|
|
138 | (1) |
|
|
138 | (2) |
|
|
140 | (1) |
|
Language Workbenches and CASE tools |
|
|
141 | (1) |
|
Should You Use a Language Workbench? |
|
|
142 | (3) |
|
|
145 | (54) |
|
|
147 | (12) |
|
|
147 | (2) |
|
|
149 | (1) |
|
|
150 | (1) |
|
Hibernate Query Language (HQL) |
|
|
151 | (1) |
|
|
152 | (3) |
|
|
155 | (1) |
|
|
156 | (3) |
|
Chapter 11 Semantic Model |
|
|
159 | (6) |
|
|
159 | (3) |
|
|
162 | (1) |
|
The Introductory Example (Java) |
|
|
163 | (2) |
|
|
165 | (10) |
|
|
166 | (2) |
|
|
167 | (1) |
|
|
168 | (1) |
|
|
168 | (1) |
|
Dependency Network in an External DSL (Java and ANTLR) |
|
|
168 | (2) |
|
Using Symbolic Keys in an Internal DSL (Ruby) |
|
|
170 | (2) |
|
Using Enums for Statically Typed Symbols (Java) |
|
|
172 | (3) |
|
Chapter 13 Context Variable |
|
|
175 | (4) |
|
|
175 | (1) |
|
|
176 | (1) |
|
|
176 | (3) |
|
Chapter 14 Construction Builder |
|
|
179 | (4) |
|
|
179 | (1) |
|
|
180 | (1) |
|
Building Simple Flight Data (C#) |
|
|
180 | (3) |
|
|
183 | (10) |
|
|
184 | (8) |
|
|
184 | (4) |
|
|
188 | (4) |
|
|
192 | (1) |
|
|
193 | (6) |
|
|
194 | (1) |
|
|
194 | (1) |
|
A Very Simple Notification (C#) |
|
|
194 | (1) |
|
Parsing Notification (Java) |
|
|
195 | (4) |
|
Part III External DSL Topics |
|
|
199 | (142) |
|
Chapter 17 Delimiter-Directed Translation |
|
|
201 | (18) |
|
|
201 | (3) |
|
|
204 | (1) |
|
Frequent Customer Points (C#) |
|
|
205 | (6) |
|
|
205 | (2) |
|
|
207 | (4) |
|
Parsing Nonautonomous Statements with Miss Grant's Controller (Java) |
|
|
211 | (8) |
|
Chapter 18 Syntax-Directed Translation |
|
|
219 | (10) |
|
|
220 | (7) |
|
|
221 | (2) |
|
|
223 | (3) |
|
|
226 | (1) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
227 | (2) |
|
|
229 | (10) |
|
|
229 | (9) |
|
Multiplicity Symbols (Kleene Operators) |
|
|
231 | (1) |
|
Some Other Useful Operators |
|
|
232 | (1) |
|
Parsing Expression Grammars |
|
|
233 | (1) |
|
Converting EBNF to Basic BNF |
|
|
234 | (2) |
|
|
236 | (2) |
|
|
238 | (1) |
|
Chapter 20 Regex Table Lexer (by Rebecca Parsons) |
|
|
239 | (6) |
|
|
240 | (1) |
|
|
241 | (1) |
|
Lexing Miss Grant's Controller (Java) |
|
|
241 | (4) |
|
Chapter 21 Recursive Descent Parser (by Rebecca Parsons) |
|
|
245 | (10) |
|
|
246 | (3) |
|
|
249 | (1) |
|
|
249 | (1) |
|
Recursive Descent and Miss Grant's Controller (Java) |
|
|
250 | (5) |
|
Chapter 22 Parser Combinator (by Rebecca Parsons) |
|
|
255 | (14) |
|
|
256 | (5) |
|
|
259 | (1) |
|
Functional Style of Combinators |
|
|
260 | (1) |
|
|
261 | (1) |
|
Parser Combinators and Miss Grant's Controller (Java) |
|
|
261 | (8) |
|
Chapter 23 Parser Generator |
|
|
269 | (12) |
|
|
269 | (3) |
|
|
270 | (2) |
|
|
272 | (1) |
|
Hello World (Java and ANTLR) |
|
|
272 | (9) |
|
Writing the Basic Grammar |
|
|
272 | (2) |
|
Building the Syntactic Analyzer |
|
|
274 | (2) |
|
Adding Code Actions to the Grammar |
|
|
276 | (2) |
|
|
278 | (3) |
|
Chapter 24 Tree Construction |
|
|
281 | (18) |
|
|
281 | (3) |
|
|
284 | (1) |
|
Using ANTLR's Tree Construction Syntax (Java and ANTLR) |
|
|
284 | (8) |
|
|
285 | (1) |
|
|
286 | (2) |
|
Populating the Semantic Model |
|
|
288 | (4) |
|
Tree Construction Using Code Actions (Java and ANTLR) |
|
|
292 | (7) |
|
Chapter 25 Embedded Translation |
|
|
299 | (6) |
|
|
299 | (1) |
|
|
300 | (1) |
|
Miss Grant's Controller (Java and ANTLR) |
|
|
300 | (5) |
|
Chapter 26 Embedded Interpretation |
|
|
305 | (4) |
|
|
305 | (1) |
|
|
306 | (1) |
|
A Calculator (ANTLR and Java) |
|
|
306 | (3) |
|
|
309 | (10) |
|
|
309 | (2) |
|
|
311 | (1) |
|
Embedding Dynamic Code (ANTLR, Java, and Javascript) |
|
|
311 | (8) |
|
|
312 | (3) |
|
|
315 | (4) |
|
Chapter 28 Alternative Tokenization |
|
|
319 | (8) |
|
|
319 | (7) |
|
|
320 | (2) |
|
|
322 | (2) |
|
|
324 | (1) |
|
|
325 | (1) |
|
|
326 | (1) |
|
Chapter 29 Nested Operator Expression |
|
|
327 | (6) |
|
|
327 | (4) |
|
|
328 | (1) |
|
|
329 | (2) |
|
|
331 | (2) |
|
Chapter 30 Newline Separators |
|
|
333 | (4) |
|
|
333 | (2) |
|
|
335 | (2) |
|
Chapter 31 External DSL Miscellany |
|
|
337 | (4) |
|
|
337 | (2) |
|
|
339 | (2) |
|
Part IV Internal DSL Topics |
|
|
341 | (144) |
|
Chapter 32 Expression Builder |
|
|
343 | (8) |
|
|
344 | (1) |
|
|
344 | (1) |
|
A Fluent Calendar with and without a Builder (Java) |
|
|
345 | (3) |
|
Using Multiple Builders for the Calendar (Java) |
|
|
348 | (3) |
|
Chapter 33 Function Sequence |
|
|
351 | (6) |
|
|
351 | (1) |
|
|
352 | (1) |
|
Simple Computer Configuration (Java) |
|
|
352 | (5) |
|
Chapter 34 Nested Function |
|
|
357 | (16) |
|
|
357 | (2) |
|
|
359 | (1) |
|
The Simple Computer Configuration Example (Java) |
|
|
360 | (1) |
|
Handling Multiple Different Arguments with Tokens (C#) |
|
|
361 | (2) |
|
Using Subtype Tokens for IDE Support (Java) |
|
|
363 | (2) |
|
Using Object Initializers (C#) |
|
|
365 | (1) |
|
|
366 | (7) |
|
|
366 | (3) |
|
|
369 | (4) |
|
Chapter 35 Method Chaining |
|
|
373 | (12) |
|
|
373 | (4) |
|
|
375 | (1) |
|
|
375 | (1) |
|
|
376 | (1) |
|
|
377 | (1) |
|
|
377 | (1) |
|
The Simple Computer Configuration Example (Java) |
|
|
378 | (3) |
|
Chaining with Properties (C#) |
|
|
381 | (1) |
|
Progressive Interfaces (C#) |
|
|
382 | (3) |
|
Chapter 36 Object Scoping |
|
|
385 | (12) |
|
|
386 | (1) |
|
|
386 | (1) |
|
|
387 | (5) |
|
|
387 | (3) |
|
|
390 | (2) |
|
Using Instance Evaluation (Ruby) |
|
|
392 | (2) |
|
Using an Instance Initializer (Java) |
|
|
394 | (3) |
|
|
397 | (6) |
|
|
397 | (5) |
|
|
402 | (1) |
|
Chapter 38 Nested Closure |
|
|
403 | (14) |
|
|
403 | (2) |
|
|
405 | (1) |
|
Wrapping a Function Sequence in a Nested Closure (Ruby) |
|
|
405 | (3) |
|
|
408 | (1) |
|
Using Method Chaining (Ruby) |
|
|
409 | (2) |
|
Function Sequence with Explicit Closure Arguments (Ruby) |
|
|
411 | (1) |
|
Using Instance Evaluation (Ruby) |
|
|
412 | (5) |
|
|
417 | (2) |
|
|
417 | (1) |
|
|
417 | (2) |
|
|
419 | (8) |
|
|
419 | (1) |
|
|
420 | (1) |
|
The Computer Configuration Using Lists and Maps (Ruby) |
|
|
420 | (2) |
|
Evolving to Greenspun Form (Ruby) |
|
|
422 | (5) |
|
Chapter 41 Dynamic Reception |
|
|
427 | (18) |
|
|
428 | (1) |
|
|
429 | (1) |
|
Promotion Points Using Parsed Method Names (Ruby) |
|
|
430 | (4) |
|
|
431 | (2) |
|
|
433 | (1) |
|
Promotion Points Using Chaining (Ruby) |
|
|
434 | (4) |
|
|
435 | (1) |
|
|
435 | (3) |
|
Removing Quoting in the Secret Panel Controller (JRuby) |
|
|
438 | (7) |
|
|
445 | (10) |
|
|
446 | (3) |
|
|
446 | (1) |
|
|
447 | (2) |
|
|
449 | (1) |
|
Custom Syntax with Runtime Processing (Java) |
|
|
449 | (2) |
|
Using a Class Method (Ruby) |
|
|
451 | (1) |
|
Dynamic Code Generation (Ruby) |
|
|
452 | (3) |
|
Chapter 43 Parse Tree Manipulation |
|
|
455 | (12) |
|
|
455 | (1) |
|
|
456 | (1) |
|
Generating IMAP Queries from C# Conditions (C#) |
|
|
457 | (10) |
|
|
458 | (2) |
|
|
460 | (5) |
|
|
465 | (2) |
|
Chapter 44 Class Symbol Table |
|
|
467 | (10) |
|
|
468 | (1) |
|
|
469 | (1) |
|
Statically Typed Class Symbol Table (Java) |
|
|
469 | (8) |
|
Chapter 45 Textual Polishing |
|
|
477 | (4) |
|
|
477 | (1) |
|
|
478 | (1) |
|
Polished Discount Rules (Ruby) |
|
|
478 | (3) |
|
Chapter 46 Literal Extension |
|
|
481 | (4) |
|
|
481 | (1) |
|
|
482 | (1) |
|
|
483 | (2) |
|
Part V Alternative Computational Models |
|
|
485 | (46) |
|
Chapter 47 Adaptive Model |
|
|
487 | (8) |
|
|
488 | (4) |
|
Incorporating Imperative Code into an Adaptive Model |
|
|
489 | (2) |
|
|
491 | (1) |
|
|
492 | (3) |
|
Chapter 48 Decision Table |
|
|
495 | (10) |
|
|
495 | (2) |
|
|
497 | (1) |
|
Calculating the Fee for an Order (C#) |
|
|
497 | (8) |
|
|
497 | (5) |
|
|
502 | (3) |
|
Chapter 49 Dependency Network |
|
|
505 | (8) |
|
|
506 | (2) |
|
|
508 | (1) |
|
|
508 | (5) |
|
|
509 | (2) |
|
|
511 | (2) |
|
Chapter 50 Production Rule System |
|
|
513 | (14) |
|
|
514 | (3) |
|
|
515 | (1) |
|
|
515 | (1) |
|
Patterns in Rule Structure |
|
|
516 | (1) |
|
|
517 | (1) |
|
Validations for club membership (C#) |
|
|
517 | (4) |
|
|
518 | (1) |
|
|
519 | (1) |
|
|
520 | (1) |
|
Eligibility Rules: extending the club membership (C#) |
|
|
521 | (6) |
|
|
523 | (2) |
|
|
525 | (2) |
|
|
527 | (4) |
|
|
527 | (2) |
|
|
529 | (1) |
|
Secret Panel Controller (Java) |
|
|
530 | (1) |
|
|
531 | (48) |
|
Chapter 52 Transformer Generation |
|
|
533 | (6) |
|
|
533 | (2) |
|
|
535 | (1) |
|
Secret Panel Controller (Java generating C) |
|
|
535 | (4) |
|
Chapter 53 Templated Generation |
|
|
539 | (8) |
|
|
539 | (2) |
|
|
541 | (1) |
|
Generating the Secret Panel State Machine with Nested Conditionals (Velocity and Java generating C) |
|
|
541 | (6) |
|
Chapter 54 Embedment Helper |
|
|
547 | (8) |
|
|
548 | (1) |
|
|
549 | (1) |
|
Secret Panel States (Java and ANTLR) |
|
|
549 | (3) |
|
Should a Helper Generate HTML? (Java and Velocity) |
|
|
552 | (3) |
|
Chapter 55 Model-Aware Generation |
|
|
555 | (12) |
|
|
556 | (1) |
|
|
556 | (1) |
|
Secret Panel State Machine (C) |
|
|
557 | (7) |
|
Loading the State Machine Dynamically (C) |
|
|
564 | (3) |
|
Chapter 56 Model Ignorant Generation |
|
|
567 | (4) |
|
|
567 | (1) |
|
|
568 | (1) |
|
Secret Panel State Machine as Nested Conditionals (C) |
|
|
568 | (3) |
|
Chapter 57 Generation Gap |
|
|
571 | (8) |
|
|
571 | (2) |
|
|
573 | (1) |
|
Generating Classes from a Data Schema (Java and a Little Ruby) |
|
|
573 | (6) |
Bibliography |
|
579 | (2) |
Index |
|
581 | |