Software language engineering (SLE) is the subfield of computer science and software engineering concerned with implementing software languages, with domain-specific languages (DSLs) as a subfield. It connects language concepts to practical DSL construction and tooling. section 15.0 section 15.5
A practical SLE path teaches enough language engineering to build an actual DSL without assuming specialist knowledge. It favors thorough treatment of selected topics, concrete examples, and skills that can be applied immediately. section 1.2.3
Core implementation topics include:
- Abstract syntax trees and working with structured language content. section 1.2.3
- Projectional editing and code generation. section 1.2.3
- Expressions with binary operators, including precedence, priority, and associativity. section 1.2.3
- Type systems and DSL evolution. section 1.2.3
SLE also distinguishes approaches and supporting infrastructure:
- Parsing extracts structured data from text that conforms to a grammar and supports external textual DSLs. section 15.5
- Language workbenches implement software languages, especially DSLs, efficiently through meta-DSLs; JetBrains MPS is identified as a prominent example. section 15.5
- A metamodel describes the structure of a DSL, while model-driven development uses models to encode a software system’s specification. section 15.5
Textual Rental DSL
A car-rental record can be represented textually with attributes such as rental period, rental price, discount, and an initial value referencing another attribute. An EBNF grammar then defines strings, types, values, attributes, and record types that can parse this representation. section 15.1
Listing 15.1 A textual variant of the example Rental record type
record type "Rental" having attributes:
"rental period": date range
"rental price before discount": amount initially 0.0
"discount": percentage initially 0
"rental price after discount": amount
initially -> "rental price before discount"
Shows a concrete textual representation of a Rental record type, including typed attributes, initial values, and an attribute reference. section 15.1
Listing 15.2 A grammar in EBNF that can parse listing 15.1
STRING: '"' [A-Za-z0-9 ]+ '"' ; #1
type: 'amount' | 'date range' | 'percentage' ; #2
WS: (' ' | '\t' | '\n')+ ; #3
attributeReference: '->' WS? STRING ;
number: [0-9]+ ('.' [0-9]+)? ;
value: attributeReference | number ;
attribute: STRING WS? ':' WS? type (WS 'initially' WS? value)? ;
recordType: WS? 'record type' WS? STRING WS?
'having attributes:' (WS? attribute)* WS? ;
Shows an EBNF grammar for parsing the textual Rental record representation. section 15.1
