In this chapter, we started to develop a DSL that generates a sequence of actions creating graphical objects, which are viewed in a widget. Our DSL supports instructions for drawing graphical objects such as lines, rectangles, ellipses, and text, and for setting the color, style, and alignment of the objects. It also supports expressions with arithmetic operators.
The language of our DSL is defined by grammar and is made up by a scanner that scans the text for meaningful parts, the parser checks that the source code complies with the grammar and generates a sequence of actions, which is read and executed by the viewer.
In the next chapter, we will continue to develop our DSL. The DSL of this chapter only supports code executed in straight sequence. However, in the next chapter, we will add function calls as well as selection and iteration (the if
and while
instructions).