A Figure Drawing Language

You are asked to design a figure drawing language. The language should provide imperative features to enable creation of drawings. It should support modularity at the level of functions. It should have extensibility features to create new shapes, which would ease the creation of complex drawings.

Here are some requirements:

  1. The program should support configuration of the following
    • an entry point (the function that does the drawing)
    • the width, height, and the stroke width of the figure
  2. The figure drawing should be done independent of scale. There should be a way of accessing the current context and accessing the width and the hight, which could be used to draw independent of scale.
  3. The language should be dynamically typed.
    • It should support the following primitive types: float, integer, string, and boolean.
    • Basic arithmetic and logical operations should be supported on these types.
    • Strings should support concatenation via the + operator and conversion from other types.
  4. The language should also support Location, Size, and Color types.
    • Location should provide access to two members: x and y.
    • Size should provide access to two members: width and height.
    • Color should provide a predefined set of constants, as well as an RGB constructor.
  5. The language should provide a number of built-in shapes.
    • These shapes should include at least the following: Line, Rectangle, and Oval.
    • There should be a common syntax for instantiating shapes. This syntax should support parameters, including optional ones.
      • A shape instance should be scale free, that is it should not reference a location or a size.
      • You can assume that any given shape can be drawn inside a bounding box. Thus, that bounding box defines its location and size, which is specified later when the shape is drawn.
      • For instance, a Line should support specifying a direction (NE (north east), NW, SE, SW), arrows (start and end), arrow sizes (relative to line stroke width), etc. However, an Oval should not specify any parameters. A Rectangle can specify a parameter about rounded corners.
  6. The language should support basic drawing statements.
    • These statements should support parameterization, which can be used to specify location, size, stroke width (relative), fill state, and fill color.
    • You can assume that some parameters are mandatory, some optional.
    • Similar to drawing shapes, drawing strings should be supported as well.
  7. The language should support loops that can ease repetitive tasks.
  8. The language should support conditionals (if and if/else) as well.
  9. The language should support a mechanism to define new shapes.
    • These shapes should be parameterizable (including optional and mandatory parameters).
    • Once a shape is defined, it should be possible to draw it as usual using the shape drawing functions.

We ask you to do the following:

Logics

Once you are done, put your deliverables under a directory named group<GroupNo>_proj1 and make an archive from that directory. It is important that your code should compile without any issues using the make command. Once complete, it should output an executable called 'lexer' that can be used to lex your sample input. For example, the following Unix commands could be used:

  mkdir group<GroupNo>_proj1    
  cd group<GroupNo>_proj1
      mkdir code      # contains Makefile, lex, and C code
      mkdir grammar   # contains the grammar
      mkdir samples   # contains the program samples
      mkdir documents # contains the tutorial and report
      (edit and test your files)
      ...
  cd ..
  tar -cvzf group<GroupNo>_proj1.tar.gz group<GroupNo>_proj1

Then e-mail this newly generated file (named group<GroupNo>_proj1.tar.gz) to your TA Doğukan Çağatay (dogukan.cagatay@bilkent.edu.tr).

Reports in formats other than .pdf and .txt are not accepted.