compile lab final report writing
TRANSCRIPT
LAB REPORT
Regular Expression
Course Code: CSE 331
Course Title: Compiler Design
Submitted By
Umme Habiba
Id:142-15-3677
Section -B
Submitted To
Mr. Seraj Al Mahmud Mostafa
Senior Lecturer
Dept. Of Computer Science and Engineering
Daffodil International University
Submission Date: 17/04/2017
Problem Statement:
In this lab task, we will work on regular expressions. For simplicity, we will assume that there is a
fixed set of regular expressions. We will not consider out of these. But we must not use any built-in
method or package in our implementation .The selected Regular Expressions are:
1. a(bc)*de
2. a(bc)+de
3. a(bc)?de
4. [a-m]*
5. [^aeiou]
6. [^aeiou]{6}
Here,
'*' means occurrence of zero of more characters,
'+' indicates happening of one or more characters,
'?' means only once or not at all occurrence,
'[ ]' indicates happening of inclusive characters,
'^' indicates that next characters will not be used in the pattern,
'[a-d]{3}' indicates that valid string will be exactly of length 3 inclusively using a, b, c, d.
The program has to show “Accepted” if a given string is supported by a RE, otherwise, it will
show “Not Accepted”.
Input & Output Format:
Here we work with a fixed set of regular expressions and will not consider out of these. Per RE will
generate an individual answer and the given format is like that….
When we run our program, command prompt tells how many string we want to input and after
input the 1st string it shows the individual output of the RE. The Input-Output format of our
program is like…
Variable Description:
In our whole program we use some variables.The most important variables that used in our
program are string,flag,flag2,flag3,I and n.
String:This variable is a character array type variable that is used to store the string that user is
given.
Flag: This is a integer type variable. It helps our program to give output easier and accts as a
status.
Others: Here we also use some integer type variable and they helps for looping and keeping
number. These are i,n.
Algorithm Description:
Algorithm that is used In our program to solve the problem more easier is given below:
Algorithm:
1. Number input
2. For: Take input till number
3. String input
4. For : Take string till null character
5. Check if the characters exists
6. If: exists
7. Print : Accepted
8. Else:
9. Print : Not Accepted
10. Return.
The program starts with taking the string as input. Then, the program calls 6 function
individually. The functions are:
1. zero_or_more(string)
2. one_or_more(string)
3. once_or_notAtAll(string)
4. character_class(string)
5. negationOf_character_class(string)
6.exactly_N_times(string)
These all functions catch the input string parameters. Each function works with their own
algorithm according to the problem domain to justify the input string is valid or not.
Structure Diagram:
Here we show a structure diagram as well as flow chart of our project is:
Start
Input a number,n
(i=0)
i
Call the functions
yes Not Accepted Satisfy
RE??
Input a string
i<n
End
i++
yes no
i++
Correctness Arguments:
As my algorithm works 100% properly to solve the RE problem and showing the expected
output format result for the requirement, I honestly and truly can claim about it.There are some
reasons why I claim about it-
1.Here in testing description section, I shall show the proof of my work that it
can show output properly.
2.It shows the exact output what is wanted to show.
3.As I didn’t find any bug.
Test Description:
A few Testing Screenshots of command prompt is shown in below:
Known Bugs:
I didn’t find any kind of bugs in my program.
Comment:
In the compiler, the most important topic is RE and I am happy for completing my final lab
project according with this topic.I enjoy my code as some portion make me thoughtful.
Contribution:
As I complete the given project myself, there is no contribution of any partner.