$30
Programming Language for Drawing Group size
1. Overview
Several programming languages can be used to draw pictures. For example, some generalpurpose languages (e.g., C++ and Java) support drawing functions by calling library functions. On the other hand, specialized programming languages (e.g., Logo) contain builtin keywords and syntax for drawing.
In this project, your group will design and implement a new programming language to draw pictures. Figure 1 shows an example of program and the drawing produced by your program. In addition, you will need to highlight the features of your programming language and convince users why they should use your programming language (instead of existing programming languages).
DRAW LINE COLOR … AT …
…
…
…
è
a program
the drawing produced by your program
Figure 1: Example of your programming language
2. The Compilation Process
Figure 2 shows the compilation process for this project. It has three layers.
Layer 1: Design a grammar file for your programming language;
Use SableCC to compile them into compiler classes
Layer 2: Modify compiler classes to implement semantic analysis and code generation; Compile a drawing X (written in your language) into a Java drawing class
Layer 3: Compile the Java drawing class with the “Draw Engine”
Note that the components shown in blue color are given to you (e.g., the “Draw Engine” written in Java).
Figure 6: Compilation process
Your task is to develop the components shown in black:
(i) your programming language for writing any drawing X
a. Design a grammar file (with lexical rules & syntax rules)
(ii) the compiler for converting the drawing X into a Java class (in red color) such that it can be integrated with the “Draw Engine”
a. Convert the grammar file into compiler classes [by using SableCC]
b. Modify compiler classes to implement semantic analysis and code generation
3. Tasks and Schedule for the Project
In this project, you should form a group of 2-3 students to design and implement the above programming language. Your group needs to submit a progress report, a final project report (and source codes) and a demo video at the end of this course. Throughout the course, we will guide you on essential knowledge, skills, and tools for the project.
Task 1. Form groups
• Find your classmates to form a group (by using Teams, Whatsapp, Wechat)
• Elect the group leader and discuss the role of each member
Task 2. Analyze the problem and requirements
• Compare existing programming languages on drawing by using language evaluation criteria (e.g., readability, writability, reliability)
• Identify the main requirements and features of your programming language
Task 3. Design the language
• Use your language to write a few small sample programs
• Design the data types supported by your language
• Design the syntax (i.e., grammar) of your language
• Design the semantics of your language (e.g., attribute grammar, scope rules, typing)
• Check your sample program with the syntax and semantics of your language; revise your language if necessary
Task 4. Implement the language
• Use a compiler tool (SableCC)
• Select the core features of your language to be implemented
• Prepare the grammar file (with lexical rules & syntax rules)
• Modify compiler classes to implement semantic analysis and code generation
Task 5. Testing
• This task proceeds in parallel with the task 4
• Design test cases (several sample programs written in your language)
• Test whether your sample programs can be compiled successfully
• Test whether your drawing classes work correctly
Task 6. Iterative development
• Your group should have completed the previous iteration of tasks 4 and 5
• Decide the next important feature to be implemented in the current iteration
• Add this feature to your language by repeating tasks 4 and 5
• Repeat this development process until the compiler classes become ready
Task 7. Write report
• This task proceeds in parallel with all the tasks shown above
Don’t start writing the report at the end of this semester! Start early!
• Each time when you complete a task (e.g., analyzing requirements), try to summarize what you have done in a document
• Circulate the document among your group members for their comments
• Refine the chapters and combine them into a report at the end of semester
1. A Simple Introduction
2. Requirement / Problem Analysis
• Summarize what you have done in task 2
• Show the main requirements of your programming language
3. Design
• Summarize what you have done in task 3
• Show the data types, syntax, and semantics of your language (designed so far) • Show some sample programs written in your language