Welcome, Guest! Sign Up RSS

Edu Profile

Sunday, 04.30.2017
Compiler Design Course Mini Project By: Ismail Al-jubbah
Supervised By : Dr. Mhd Ammar Salka

Bookmark and Share

Project Report :

Project Requirements :

Create and design a simple imperative programming language, then use your favorite programming language and IDE
to develop a working compiler for this language. You have absolute freedom in choosing the lexical, syntactic, and
semantic features of the language. Although you can borrow keywords and constructs from existing languages
(such as C, PASCAL, BASIC, or even FORTRAN), you are encouraged to be creative and explore different possibilities,
including those which may look extreme. Give your programming language a unique attractive name. 

The PL you create should satisfy the following minimum requirements:

Comments
The language should have a mechanism for inserting comments into the source file.

Primitive Data Types
The language should support a minimum of three primitive data types: 
1. Integers
2. Characters
3. Booleans
4. String
You may wish to include more primitive data types such as real numbers and long integers, but this is not an essential requirement.

Aggregate Data Types
The language should have constructs for defining at least two aggregate data types:
1. Arrays of any dimension
2. Records or Structures (you may like to call them classes)

Variables
Your language should allow the declaration of names for variables of any type. Variables should be declared before they are used.
The language must have at least two levels of scope(Ultimate Scope). A global scope, which applies to names declared outside procedures/functions,
and local scopes which apply to names declared inside procedures/functions.

Constants
The language should have a statement for defining constants of any primitive type. Constants differ from variables in
that their value cannot be changed after they have been defined. 

Expressions
The language should have the ability to evaluate expressions. 
Operators used in expressions should include addition, subtraction, multiplication, and integer division, as well as
the unary – (negative) operator, and parenthesized factors. Expressions should accept the following relational operators:
Equal, greater than, less than, greater than or equal, less than or equal, not equal
Expressions should also accept the Boolean AND, OR, and NOT operators

Assignment
The language should have some form of an assignment statement which assigns the value of any expression to a variable.
If a variable is used in the RHS of an assignment before initialization the compiler should issue a warning message. 

Functions and procedures
The language should have a facility to define functions which take any number and type of arguments (parameters),
and return a single value of any primitive type. It should be possible to pass arguments either by value or by reference
The language may have functions only, as is the case in c-like languages, or it can support both functions and procedures (procedures do not return any value).
It should be possible to pass an expression as an actual argument to a function, provided that the argument is passed by value.
 It should be possible to call functions within functions, and to call a function from within itself (recursion).

Control of flow
The language should support the following control of flow constructs
1. Conditional execution (an if-then-else statement)
2. Iteration (some kind of a while or do statement)

 Input/output
The language should have some facility (either a built-in command or a predefined function) for outputting data to
the standard output, and inputting data from the standard input.

Target Code
The compiler should generate assembly code for any real or virtual machine you prefer (provided you have to an
implementation of this machine). For example, the compiler could generate IA-32 assembly code, JVM assembly code,
or.NET IL. You can also invent your own virtual machine together with its IL, and make your compiler generate executable code for this machine.

Testing
Your compiler should be tested by means of a set of simple programs written in the language you have designed.
The set of test programs should include the following:
1. A program to find the maximum and minimum number in a list of integer numbers.
2. A program to sort an array of integers by the bubble sorting algorithm.
3. A program to find the sum and product of two matrices.
4. A recursive program to solve the towers of Hanoi problem.
5. A very simple and naive implementation of an academic database that keeps a record of every student name,
number, and scores in a number of subjects. The DB should be able to calculate the average score of every student
and display a report (transcript) of the student.

Compiler Design


Compiler Design