Quiz for the course "Model based software development" 2025, based on Mikkel Albrechtsens reading.
Click the button to start the quiz
What does embedded DSL mean?
Internal DSL
What is DSL's often used to?
Configuration of systems
Code generation
Is compiling code recomended without a semantic model?
No, it is not recommended
Yes, but only if it very simple
What are the three man categories of DSL?
Internal DSL
External DSL
Language Workbenches
What defines a DSL in accordance with Fowler?
Limited expressiveness
It is not turing complete
Fluency
Human readable syntax
Does "domain language" denote human language or computer language?
Human language
Does "DSL" denote human language or computer language?
Computer language
What are some of the benefits of using DSL?
Imrpvoed developer productivity
Communication with domain experts
Change in execution context
Alternative computation model
What are some of the problems with DSL?
Language cacophony
Cost of building
Ghetto language
Blinkered abstraction
What is a 'blinkered abstraction' in the context of DSLs?
An abstraction that limits your thinking and makes you fit the world into it rather than adapting the abstraction
Why can DSLs make the problem of blinkered abstractions worse?
Because DSLs provide a comfortable way to manipulate an abstraction, making people more reluctant to change it
What is the overall goal for a DSL according to Fowler?
Clarity for the reader
Why should you avoid making a DSL read like natural language?
It leads to syntactic sugar that complicates understanding of the semantics
What is one of the main downsides to do error detection in the semantic model?
It is not possible to link the error to the source code
What is incremental migration strategy?
A strategy where you gradually upgrade parts of the DSL
The author provides a migration script to change the DSL script to the new version
What is model-based migration strategy?
Supporting multiple parsers for the DSL
Different parser versions compiles to one version of the semantic-model, which can be upgraded
Why can't regular expressions be used to parse DSLs?
Because regular expressions cannot handle nested structures
Because regular expressions are not expressive enough for complex DSLs
What grammars can parse nested structures?
Context-free grammars
Context-sensitive grammars
What grammars can handle having variables declared after they are used?
Context-sensitive grammars
What can Parsing Expression Grammar (PEG) handle?
ANTLR incorporates many ideas from PEGs.
PEGs can handle nested structures
PEGs can handle variables declared after they are used
How does a top-down parser work?
Often reffered to as LL parsers.
Starts with the highest level rule in the grammar
How does a bottom-up parser work?
Often reffered to as LR parsers.
Starts with the lowest level rule in the grammar
Uses shifting to set aside the token
What is one advantages of a top-down parser?
It is easier to understand and debug
What are some aspects that you should consider when choosing a either internal or external DSL?
Learning curve
Cost of building
Programmer familiarity
Communication with domain experts
Mixing in the host language
Strong expressiveness boundary
Runtime configuration
What would be the main parsing problem of the following code?
Exp: Number | Plus
Plus: left=Exp '+' right=Exp
Ambiguity
What would be the main parsing problem of the following code?
Exp: Number | Plus
Plus: left=Exp ('+' right=Number)?
Left recursive
What would be the main parsing problem of the following code?
Exp: Number ({Plus.left=current} '+' right=Exp)?
Associativity
What would be the main parsing problem of the following code?
Exp: Number (({Plus.left=current} '+' | {Mult.left=current} '*') right=Number)?
Precedence
What type of internal DSL is the following code?
.processor()
.cores()
.speed(2500)
.i386()
.disk()
.size(150)
.end()
Method chaining
What type of internal DSL is the following code?
processor();
cores();
speed(2500);
i386();
disk();
size(150);
Function sequence
What type of internal DSL is the following code?
processor(
cores()
speed(2500)
i386()
),
disk(
size(150)
)
)
Nested function
What type of internal DSL is the following code?
Litteral list
What type of internal DSL is the following code?
Litteral map