0% found this document useful (0 votes)
72 views3 pages

COMPILER CONSTRUCTION Lab-Sessional 1

This document provides instructions for a lab sessional assignment on converting a non-deterministic finite automaton (NFA) to a deterministic finite automaton (DFA) using Python. Students are asked to implement a generic algorithm to convert any NFA to a DFA by taking an NFA transition table file as input. They must submit their Python source code and the NFA transition table file in a zip folder named with their registration number through the university portal. The assignment is due by March 30, 2021. No other submission method besides the portal will be accepted.

Uploaded by

areesa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views3 pages

COMPILER CONSTRUCTION Lab-Sessional 1

This document provides instructions for a lab sessional assignment on converting a non-deterministic finite automaton (NFA) to a deterministic finite automaton (DFA) using Python. Students are asked to implement a generic algorithm to convert any NFA to a DFA by taking an NFA transition table file as input. They must submit their Python source code and the NFA transition table file in a zip folder named with their registration number through the university portal. The assignment is due by March 30, 2021. No other submission method besides the portal will be accepted.

Uploaded by

areesa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

COMSATS University Islamabad, Wah

Campus
Lab Sessional 1

COMPUTER
Department of: SCIENCE

BS(7-A,C,D) Due 30 March 2021 (Online, 9:00


Class/Program: MCS-4 Date: AM to 8:00 PM)
Subject: Compiler Construction Instructor: Muhammad Nadeem

COPYING is straight forward ZERO, either from


fellow or internet. Code is your property, so DO
NOT share
VIVAS can be conducted in case of any ambiguity felt by instructor.
Q1. You are familiar there is a sub-set construction algorithm to convert an
NFA to DFA (You can consult to slides and video lecture for more
information).
You are required to implement generic algorithm to convert NFA to DFA
using Python language. Input of program will be an NFA transition table text
file, where transitions are separated by TAB, named as nfa.txt.
Consider the following NFA, and its transition table.

Here symbol set is ∑= {a,b,epsilon}.


“Generic means, I will be required to change only symbol set and NFA
source file, and algorithm will work for any NFA”
Following will be transition table for this NFA.
Here line number is NFA state, and column 1 is transitions for symbol ‘a’,
columns 2 for ‘b’ and column 3 is for epsilon transition.
e.g row 4 indicates that this is transition entry for state 3 and there is no
transition for a, b and epsilon can reach to 6,7,1,2,4
Final output should be like following. (this output is an exemplary output,
which mine program is generating after inputting NFA discussed in lecture)

(This DFA is the NFA of example, we discussed in lecture)


Here First, row means that there is a transition from {0} state with ‘a’
transition to state {1,2,3,4,8,13}
Similarly, row 3 means there is transition form {9,5} with symbol ‘a’ to {10}
And row 4 means there is a transition from {9,5} with symbol ‘o’ to {6} and
so on….

Submission.
Please follow each and every instruction very carefully. You are required to
submit two files, python source file and text file containing NFA transition
table. Python source file should be named as your “Registration Number”,
NFA file should be named as “nfa.txt”.
Zip both file and named ZIP folder as your Registration Number and upload
on portal.
Do not go to last moment for submission. No Other mode of submission is
ACCEPTABLE, other than portal.

Just for fun 😊


while( noSuccess)
{
tryAgain();
if (Dead)
break;
}

Best of Luck

You might also like