2020CS428 (LabManual)
2020CS428 (LabManual)
LAB - Manual
Page | 1
Table of Contents
Lab 1: ............................................................................................................................................................ 3
Code: ......................................................................................................................................................... 5
Lab 2: ............................................................................................................................................................ 6
Code: ......................................................................................................................................................... 9
Lab 3:........................................................................................................................................................... 11
Task1: Infinite Token Regocnizer ........................................................................................................... 11
Code: ....................................................................................................................................................... 11
Task2: Exhaustive control language of the lexer generator ................................................................. 13
Code: ....................................................................................................................................................... 13
Lab 5: Semester Project Assignment-1 ...................................................................................................... 15
Language Creation of B++ ...................................................................................................................... 15
Sigma Infusion ........................................................................................................................................ 15
Token Recognition .................................................................................................................................. 16
Control Language.................................................................................................................................... 27
Uppaal XML Code 1: ............................................................................................................................... 44
Uppaal XML Code 2: ............................................................................................................................... 45
Token Recognizer Code: ......................................................................................................................... 47
Lab 7:........................................................................................................................................................... 48
Code: ....................................................................................................................................................... 48
Lab 9:........................................................................................................................................................... 50
Code: of persistent stack storing data in file: ........................................................................................ 50
Code: of persistent list storing data in file: ........................................................................................... 51
Code: of imperative stack storing data in file: ...................................................................................... 53
Code: of imperative list storing data in file: .......................................................................................... 54
Lab 11:......................................................................................................................................................... 55
Lab 14:......................................................................................................................................................... 56
Project Assignment 2: ................................................................................................................................ 58
Symbol Table using DTM’s ..................................................................................................................... 58
Tapes (Of Symbol Table) ........................................................................................................................ 83
Page | 2
Lab 1:
Page | 3
Page | 4
Code:
#include <iostream>
#include <string>
#include <unordered_set>
int main() {
unordered_set<string> validStrings = { "aba", "aaabb", "aabbb", "baa", "bab", "aab",
"abb",
"aaa", "bbb", "aa", "ab", "ba", "bb" };
char check;
do {
cout << "Enter a string of alphabets: ";
string input;
cin >> input;
if (validStrings.find(input) != validStrings.end()) {
cout << "Input is a valid combination." << endl;
cout << "Enter 'y' to try again: ";
cin >> check;
}
else {
cout << "Error ( Input is not a valid combination )." << endl;
cout << "Enter 'y' to try again: ";
cin >> check;
}
} while (check == 'y');
return 0;
}
Page | 5
Lab 2:
Page | 6
Page | 7
Page | 8
Code:
#include <iostream>
#include <iostream>
#include <string>
#include <unordered_set>
void include() {
unordered_set<string> validStrings = { "ababbaaaaabaabbbbab" };
cout << "Enter a string of alphabets: ";
string input;
cin >> input;
if (validStrings.find(input) != validStrings.end()) {
cout << "#include<> is reconganized." << endl;
}
else {
cout << "Error ( #include<> is not reconganized)." << endl;
}
}
void prin() {
unordered_set<string> validStrings = { "bbabbbbabbaaabbaabaaabbb" };
cout << "Enter a string of alphabets: ";
string input;
cin >> input;
if (validStrings.find(input) != validStrings.end()) {
cout << "printf(); is reconganized." << endl;
}
Page | 9
else {
cout << "Error ( printf(); is not reconganized)." << endl;
}
}
void scan() {
unordered_set<string> validStrings = { "aaaabbabbbbababbaabaaabbbaabb" };
cout << "Enter a string of alphabets: ";
string input;
cin >> input;
if (validStrings.find(input) != validStrings.end()) {
cout << "scanf(); is reconganized." << endl;
}
else {
cout << "Error ( scanf(); is not reconganized)." << endl;
}
}
void cinfu() {
unordered_set<string> validStrings = { "bababbaaabbaabbbaaabb" };
cout << "Enter a string of alphabets: ";
string input;
cin >> input;
if (validStrings.find(input) != validStrings.end()) {
cout << "cin>>""; is reconganized." << endl;
}
else {
cout << "Error ( cin>>""; is not reconganized)." << endl;
}
}
void coute() {
unordered_set<string> validStrings = { "bbabbbbabbaaabbaabaaabbb" };
cout << "Enter a string of alphabets: ";
string input;
cin >> input;
if (validStrings.find(input) != validStrings.end()) {
cout << "cout<<""; is reconganized." << endl;
}
else {
cout << "Error ( cout<<""; is not reconganized)." << endl;
}
}
int main() {
char check;
int choice;
do {
cout << "Enter your choice from 1 to 5: ";
cin >> choice; // Read user's choice
switch (choice) {
case 1:
Page | 10
cout << "#include<> Token ";
include();
break;
case 2:
cout << "prntf(); Token ";
prin();
break;
case 3:
cout << "scanf(); Token ";
scan();
break;
case 4:
cout << "cin>>; Token "; // Remove extra quotation marks
cinfu();
break;
case 5:
cout << "cout<<; Token "; // Remove extra quotation marks
coute();
break;
default:
cout << "Invalid choice." << endl;
break;
}
cout << "Do you want to verify another token (y/n): ";
cin >> check;
} while (check == 'y' || check == 'Y'); // Allow for both 'y' and 'Y' for yes
return 0;
}
Lab 3:
Task1: Infinite Token Regocnizer
Code:
#include <iostream>
#include <string>
void checkInput() {
int flag;
std::string input;
std::cout << "Enter a string: ";
std::cin >> input;
if (input == "y") {
flag = 1;
}
{
for (char ch : input) {
if (ch != 'a' && ch != 'b') {
flag = 0;
}
else {
flag = 1;
}
Page | 11
}
}
if (flag == 1) {
std::cout << "Given Token string is vaild." << std::endl;
}
else {
std::cout << "Given token string is not valid" << std::endl;
}
}
int main() {
char check;
int choice;
do {
std::cout << "Enter your choice from 1 to 5: ";
std::cin >> choice; // Read user's choice
switch (choice) {
case 1:
std::cout << "if() Token: \n";
checkInput();
break;
case 2:
std::cout << "elseif Token: \n";
checkInput();
break;
case 3:
std::cout << "while Token: \n";
checkInput();
break;
case 4:
std::cout << "int Token: \n"; // Remove extra quotation marks
checkInput();
break;
case 5:
std::cout << "main() Token: \n"; // Remove extra quotation marks
checkInput();
break;
default:
std::cout << "Invalid choice.";
break;
}
std::cout << "Do you want to verify another token (y/n): ";
std::cin >> check;
} while (check == 'y' || check == 'Y'); // Allow for both 'y' and 'Y' for yes
return 0;
}
Page | 12
Task2: Exhaustive control language of the lexer generator
Code:
#include <iostream>
#include <string>
using namespace std;
int checkSetMembership(const std::string& input) {
if (input.empty()) {
return -1;
}
if (ch == '0') {
foundA = true;
}
else if (ch == '1') {
foundB = true;
}
}
if (!valid) {
return -1;
}
if (input.find("0") != std::string::npos) {
cout << "1 - 2";
cout << endl;
}
if (input.find("0") != std::string::npos || input.find("1") != std::string::npos) {
cout << "1 - 3";
cout << endl;
}
if (input.find("11") != std::string::npos) {
cout << "1 - 4";
cout << endl;
}
if (input.find("11") != std::string::npos) {
cout << "2 - 3";
cout << endl;
}
if (foundA && foundB) {
if (input.find("0") != std::string::npos) {
cout << "1 - 2";
cout << endl;
}
Page | 13
if (input.find("0") != std::string::npos || input.find("1") != std::string::npos)
{
cout << "1 - 3";
cout << endl;
}
if (input.find("11") != std::string::npos) {
cout << "1 - 4";
cout << endl;
}
if (input.find("00") != std::string::npos) {
cout << "1 - 5, 2 - 4, 2 - 5";
cout << endl;
}
if (input.find("11") != std::string::npos) {
cout << "2 - 3";
cout << endl;
}
if (input.find("000") != std::string::npos) {
cout << "3 - 4";
cout << endl;
}
if (input.find("001") != std::string::npos) {
cout << "3 - 5";
cout << endl;
}
if (input.find("110") != std::string::npos) {
cout << "4 - 5";
cout << endl;
}
else {
return -1;
}
}
else {
return -1;
}
}
int main() {
std::string input;
std::cout << "Enter a string: ";
std::cin >> input;
if (result != -1) {
std::cout << "This belongs to Control Language." << std::endl;
}
else {
std::cout << " " << std::endl;
}
return 0;
}
Page | 14
Lab 5: Semester Project Assignment-1
Language Creation of B++
Sigma Infusion
Page | 15
t a*(a+b)*a* o a*a*b*(a+b)*
r b*(a+b)*b* g a*b*a*(a+b)*
. a+
Token Recognition
1) Token: #id.
Trace: {a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
2) Token: nameui.
Trace: {a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
3) Token: imain.
Trace: {a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
4) Token: strbri
Page | 16
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
5) Token: endbri
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
6) Token: print
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
7) Token: semi
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
8) Token: strin
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
Page | 17
9) Token: endin
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, ba, bb, aaa, abb, aba, aab, baa, bab, bba, bbb,…}
DFSA:
12) Token: i
RE: a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 18
14) Token: dli
RE: a*(a+b)*.b*a*(a+b)*.a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
RE: a*(a+b)*a*b*.(a+b)*a*.a*b*
Page | 19
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
19) Token: in
RE: a*b*.b*(a+b)*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
22) Token: fi
RE: (a+b)*b*a*.a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 20
23) Token: ils
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
Page | 21
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 22
RE: a*(a+b)*b*. a*a*(a+b)*. b*(a+b)*b*. a*b*. a*b*(a+b)*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 23
37) Token: iref
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 24
RE: a*(a+b)*.(a+b)*a*b*b*. a*b*. b*a*(a+b)*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 25
46) Token: eiei
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
RE: b*(a+b)*.(a+b)*.a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
RE: b*a*(a+b)*.(a+b)*.a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
RE: a*b*a*(a+b)*.(a+b)*.a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
RE: b*b*(a+b)*.(a+b)*.a*b*
Trace: {λ, a, b, ab, aa, bb, aab, abb, aaa, bbb, aab, abb, aaaa, aaab, aabb, abbb, bbbb,…}
DFSA:
Page | 26
Control Language
Page | 27
(0+1)*00110
1-32 (0+1)*1111 2-29 3-27 (0+1)*11011
0
(0+1)*00110
1-33 (0+1)*00000 2-30 3-28 (0+1)*11100
1
(0+1)*00111
1-34 (0+1)*00001 2-31 3-29 (0+1)*11101
0
(0+1)*00111
1-35 (0+1)*00010 2-32 3-30 (0+1)*11110
1
1-36 (0+1)*00011 2-33 (0+1)*01110 3-31 (0+1)*11111
1-37 (0+1)*00100 2-34 (0+1)*01111 3-32 (0+1)*000000
1-38 (0+1)*00101 2-35 (0+1)*10000 3-33 (0+1)*000001
1-39 (0+1)*00110 2-36 (0+1)*10001 3-34 (0+1)*000010
1-40 (0+1)*00111 2-37 (0+1)*10010 3-35 (0+1)*000011
1-41 (0+1)*01000 2-38 (0+1)*10011 3-36 (0+1)*000100
1-42 (0+1)*01001 2-39 (0+1)*10100 3-37 (0+1)*000101
1-43 (0+1)*01010 2-40 (0+1)*10101 3-38 (0+1)*000110
1-44 (0+1)*01011 2-41 (0+1)*10110 3-39 (0+1)*000111
1-45 (0+1)*01100 2-42 (0+1)*10111 3-40 (0+1)*001000
1-46 (0+1)*01101 2-43 (0+1)*11000 3-41 (0+1)*001001
(0+1)*10000
3-42 (0+1)*001010 4-41 5-41 (0+1)*110000
0
(0+1)*10000
3-43 (0+1)*001011 4-42 5-42s (0+1)*110001
1
(0+1)*10001
3-44 (0+1)*001100 4-43 5-43 (0+1)*110010
0
(0+1)*10001
3-45 (0+1)*001101 4-44 5-44 (0+1)*110011
1
(0+1)*10010
3-46 (0+1)*001110 4-45 5-45 (0+1)*110100
0
(0+1)*10010
3-47 (0+1)*001111 4-46 5-46 (0+1)*110101
1
(0+1)*10011
3-48 (0+1)*010000 4-47 5-47 (0+1)*110110
0
(0+1)*10011
3-49 (0+1)*010001 4-48 5-48 (0+1)*110111
1
(0+1)*10100
3-50 (0+1)*010010 4-49 5-49 (0+1)*111000
0
(0+1)*10100
4-5 (0+1)*010011 4-50 5-50 (0+1)*111001
1
(0+1)*10101
4-6 (0+1)*010100 5-6 6-7 (0+1)*111010
0
(0+1)*10101
4-7 (0+1)*010101 5-7 6-8 (0+1)*111011
1
(0+1)*10110
4-8 (0+1)*010110 5-8 6-9 (0+1)*111100
0
Page | 28
Combination R.E. Combination R.E. Combination R.E.
(0+1)*10110
4-9 (0+1)*010111 5-9 6-10 (0+1)*111101
1
(0+1)*10111
4-10 (0+1)*011000 5-10 6-11 (0+1)*111110
0
(0+1)*10111
4-11 (0+1)*011001 5-11 6-12 (0+1)*111111
1
(0+1)*11000
4-12 (0+1)*011010 5-12 6-13 (0+1)*0000000
0
(0+1)*11000
4-13 (0+1)*011011 5-13 6-14 (0+1)*0000001
1
(0+1)*11001
4-14 (0+1)*011100 5-14 6-15 (0+1)*0000010
0
(0+1)*11001
4-15 (0+1)*011101 5-15 6-16 (0+1)*0000011
1
(0+1)*11010
4-16 (0+1)*011110 5-16 6-17 (0+1)*0000100
0
(0+1)*11010
4-17 (0+1)*011111 5-17 6-18 (0+1)*0000101
1
(0+1)*11011
4-18 (0+1)*100000 5-18 6-19 (0+1)*0000110
0
(0+1)*11011
4-19 (0+1)*001010 5-19 6-20 (0+1)*0000111
1
(0+1)*11100
4-20 (0+1)*001011 5-20 6-21 (0+1)*0001000
0
(0+1)*11100
4-21 (0+1)*001100 5-21 6-22 (0+1)*0001001
1
(0+1)*11101
4-22 (0+1)*001101 5-22 6-23 (0+1)*0001010
0
(0+1)*11101
4-23 (0+1)*001110 5-23 6-24 (0+1)*0001011
1
(0+1)*11110
4-24 (0+1)*001111 5-24 6-25 (0+1)*0001100
0
(0+1)*10000
4-25 (0+1)*010000 5-25 6-26 (0+1)*110000
0
(0+1)*10000
4-26 (0+1)*010001 5-26 6-27 (0+1)*110001
1
(0+1)*10001
4-27 (0+1)*010010 5-27 6-28 (0+1)*110010
0
(0+1)*10001
4-28 (0+1)*010011 5-28 6-29 (0+1)*110011
1
(0+1)*10010
4-29 (0+1)*010100 5-29 6-30 (0+1)*110100
0
(0+1)*10010
4-30 (0+1)*010101 5-30 6-31 (0+1)*110101
1
(0+1)*10011
4-31 (0+1)*010110 5-31 6-32 (0+1)*110110
0
Page | 29
Combination R.E. Combination R.E. Combination R.E.
(0+1)*10011
4-32 (0+1)*010111 5-32 6-33 (0+1)*110111
1
(0+1)*10100
4-33 (0+1)*011000 5-33 6-34 (0+1)*111000
0
(0+1)*10100
4-34 (0+1)*011001 5-34 6-35 (0+1)*111001
1
(0+1)*10101
4-35 (0+1)*011010 5-35 6-36 (0+1)*111010
0
(0+1)*10101
4-36 (0+1)*011011 5-36 6-37 (0+1)*111011
1
(0+1)*10110
4-37 (0+1)*011100 5-37 6-38 (0+1)*111100
0
(0+1)*10110
4-38 (0+1)*011101 5-38 6-39 (0+1)*111101
1
(0+1)*10111
4-39 (0+1)*011110 5-39 6-40 (0+1)*111110
0
(0+1)*10111
4-40 (0+1)*011111 5-40 6-41 (0+1)*111111
1
(0+1)*00100
6-42 (0+1)*0000000 7-44 8-47 (0+1)*0100110
11
(0+1)*00101
6-43 (0+1)*0000001 7-45 8-48 (0+1)*0100111
00
(0+1)*00101
6-44 (0+1)*0000010 7-46 8-49 (0+1)*0101000
01
(0+1)*00101
6-45 (0+1)*0000011 7-47 8-50 (0+1)*0101001
10
(0+1)*00101
6-46 (0+1)*0000100 7-48 9-10 (0+1)*0101010
11
(0+1)*00110
6-47 (0+1)*0000101 7-49 9-11 (0+1)*0101011
00
(0+1)*00110
6-48 (0+1)*0000110 7-50 9-12 (0+1)*0101100
01
(0+1)*00110
6-49 (0+1)*0000111 8-9 9-13 (0+1)*0101101
10
(0+1)*00110
6-50 (0+1)*0001000 8-10 9-14 (0+1)*0101110
11
(0+1)*00111
7-8 (0+1)*0001001 8-11 9-15 (0+1)*0101111
00
(0+1)*00111
7-9 (0+1)*0001010 8-12 9-16 (0+1)*0110000
01
(0+1)*00111
7-10 (0+1)*0001011 8-13 9-17 (0+1)*0110001
10
(0+1)*00111
7-11 (0+1)*0001100 8-14 9-18 (0+1)*0110010
11
(0+1)*01000
7-12 (0+1)*0001101 8-15 9-19 (0+1)*0110011
00
Page | 30
Combination R.E. Combination R.E. Combination R.E.
(0+1)*01000
7-13 (0+1)*0001110 8-16 9-20 (0+1)*0110100
01
(0+1)*01000
7-14 (0+1)*0001111 8-17 9-21 (0+1)*0110101
10
(0+1)*01000
7-15 (0+1)*0010000 8-18 9-22 (0+1)*0110110
11
(0+1)*01001
7-16 (0+1)*0010001 8-19 9-23 (0+1)*0110111
00
(0+1)*01001
7-17 (0+1)*0010010 8-20 9-24 (0+1)*0111000
01
(0+1)*01001
7-18 (0+1)*0010011 8-21 9-25 (0+1)*0111001
10
(0+1)*01001
7-19 (0+1)*0010100 8-22 9-26 (0+1)*0111010
11
(0+1)*01010
7-20 (0+1)*0010101 8-23 9-27 (0+1)*0111011
00
(0+1)*01010
7-21 (0+1)*0010110 8-24 9-28 (0+1)*0111100
01
(0+1)*01010
7-22 (0+1)*0010111 8-25 9-29 (0+1)*0100110
10
(0+1)*01010
7-23 (0+1)*0011000 8-26 9-30 (0+1)*0100111
11
(0+1)*01011
7-24 (0+1)*0011001 8-27 9-31 (0+1)*0101000
00
(0+1)*00100
7-25 (0+1)*0000000 8-28 9-32 (0+1)*0101001
11
(0+1)*00101
7-26 (0+1)*0000001 8-29 9-33 (0+1)*0101010
00
(0+1)*00101
7-27 (0+1)*0000010 8-30 9-34 (0+1)*0101011
01
(0+1)*00101
7-28 (0+1)*0000011 8-31 9-35 (0+1)*0101100
10
(0+1)*00101
7-29 (0+1)*0000100 8-32 9-36 (0+1)*0101101
11
(0+1)*00110
7-30 (0+1)*0000101 8-33 9-37 (0+1)*0101110
00
(0+1)*00110
7-31 (0+1)*0000110 8-34 9-38 (0+1)*0101111
01
(0+1)*00110
7-32 (0+1)*0000111 8-35 9-39 (0+1)*0110000
10
(0+1)*00110
7-33 (0+1)*0001000 8-36 9-40 (0+1)*0110001
11
(0+1)*00111
7-34 (0+1)*0001001 8-37 9-41 (0+1)*0110010
00
(0+1)*00111
7-35 (0+1)*0001010 8-38 9-42 (0+1)*0110011
01
Page | 31
Combination R.E. Combination R.E. Combination R.E.
(0+1)*00111
7-36 (0+1)*0001011 8-39 9-43 (0+1)*0110100
10
(0+1)*00111
7-37 (0+1)*0001100 8-40 9-44 (0+1)*0110101
11
(0+1)*01000
7-38 (0+1)*0001101 8-41 9-45 (0+1)*0110110
00
(0+1)*01000
7-39 (0+1)*0001110 8-42 9-46 (0+1)*0110111
01
(0+1)*01000
7-40 (0+1)*0001111 8-43 9-47 (0+1)*0111000
10
(0+1)*01000
7-41 (0+1)*0010000 8-44 9-48 (0+1)*0111001
11
(0+1)*01001
7-42 (0+1)*0010001 8-45 9-49 (0+1)*0111010
00
(0+1)*01001
7-43 (0+1)*0010010 8-46 9-50 (0+1)*0111011
01
(0+1)*10011
10-11 (0+1)*0111100 11-17 12-24 (0+1)*1100011
11
(0+1)*10100
10-12 (0+1)*0111101 11-18 12-25 (0+1)*1100100
00
(0+1)*10100
10-13 (0+1)*0111110 11-19 12-26 (0+1)*1100101
01
(0+1)*10100
10-14 (0+1)*0111111 11-20 12-27 (0+1)*1100110
10
(0+1)*10100
10-15 (0+1)*1000000 11-21 12-28 (0+1)*1100111
11
(0+1)*10101
10-16 (0+1)*1000001 11-22 12-29 (0+1)*1101000
00
(0+1)*10101
10-17 (0+1)*1000010 11-23 12-30 (0+1)*1101001
01
(0+1)*10101
10-18 (0+1)*1000011 11-24 12-31 (0+1)*1101010
10
(0+1)*10101
10-19 (0+1)*1000100 11-25 12-32 (0+1)*1101011
11
(0+1)*10110
10-20 (0+1)*1000101 11-26 12-33 (0+1)*1101100
00
(0+1)*10110
10-21 (0+1)*1000110 11-27 12-34 (0+1)*1101101
01
(0+1)*10110
10-22 (0+1)*1000111 11-28 12-35 (0+1)*1101110
10
(0+1)*10110
10-23 (0+1)*1001000 11-29 12-36 (0+1)*1101111
11
(0+1)*10111
10-24 (0+1)*1001001 11-30 12-37 (0+1)*1110000
00
(0+1)*10111
10-25 (0+1)*1001010 11-31 12-38 (0+1)*1110001
01
Page | 32
Combination R.E. Combination R.E. Combination R.E.
(0+1)*10111
10-26 (0+1)*1001011 11-32 12-39 (0+1)*1110010
10
(0+1)*10111
10-27 (0+1)*1001100 11-33 12-40 (0+1)*1110011
11
(0+1)*11000
10-28 (0+1)*1001101 11-34 12-41 (0+1)*1110100
00
(0+1)*11000
10-29 (0+1)*1001110 11-35 12-42 (0+1)*1110101
01
(0+1)*11000
10-30 (0+1)*1001111 11-36 12-43 (0+1)*1110110
10
(0+1)*11000
10-31 (0+1)*1010000 11-37 12-44 (0+1)*1110111
11
(0+1)*11001
10-32 (0+1)*1010001 11-38 12-45 (0+1)*1100011
00
(0+1)*11001
10-33 (0+1)*1010010 11-39 12-46 (0+1)*1100100
01
(0+1)*11001
10-34 (0+1)*1010011 11-40 12-47 (0+1)*1100101
10
(0+1)*11001
10-35 (0+1)*1010100 11-41 12-48 (0+1)*1100110
11
(0+1)*10011
10-36 (0+1)*1010101 11-42 12-49 (0+1)*1100111
11
(0+1)*10100
10-37 (0+1)*0111100 11-43 12-50 (0+1)*1101000
00
(0+1)*10100
10-38 (0+1)*0111101 11-44 13-14 (0+1)*1101001
01
(0+1)*10100
10-39 (0+1)*0111110 11-45 13-15 (0+1)*1101010
10
(0+1)*10100
10-40 (0+1)*0111111 11-46 13-16 (0+1)*1101011
11
(0+1)*10101
10-41 (0+1)*1000000 11-47 13-17 (0+1)*1101100
00
(0+1)*10101
10-42 (0+1)*1000001 11-48 13-18 (0+1)*1101101
01
(0+1)*10101
10-43 (0+1)*1000010 11-49 13-19 (0+1)*1101110
10
(0+1)*10101
10-44 (0+1)*1000011 11-50 13-20 (0+1)*1101111
11
(0+1)*10110
10-45 (0+1)*1000100 12-13 13-21 (0+1)*1110000
00
(0+1)*10110
10-46 (0+1)*1000101 12-14 13-22 (0+1)*1110001
01
(0+1)*10110
10-47 (0+1)*1000110 12-15 13-23 (0+1)*1110010
10
(0+1)*10110
10-48 (0+1)*1000111 12-16 13-24 (0+1)*1110011
11
Page | 33
Combination R.E. Combination R.E. Combination R.E.
(0+1)*10111
10-49 (0+1)*1001000 12-17 13-25 (0+1)*1110100
00
(0+1)*10111
10-50 (0+1)*1001001 12-18 13-26 (0+1)*1110101
01
(0+1)*10111
11-12 (0+1)*1001010 12-19 13-27 (0+1)*1110110
10
(0+1)*10111
11-13 (0+1)*1001011 12-20 13-28 (0+1)*1110111
11
(0+1)*11000
11-14 (0+1)*1001100 12-21 13-29 (0+1)*1100011
00
(0+1)*11000
11-15 (0+1)*1001101 12-22 13-30 (0+1)*1100100
01
(0+1)*11000
11-16 (0+1)*1001110 12-23 13-31 (0+1)*1100101
10
(0+1)*11010
13-32 (0+1)*1100110 14-41 16-17 (0+1)*1101110
11
(0+1)*11011
13-33 (0+1)*1100111 14-42 16-18 (0+1)*1101111
00
(0+1)*11011
13-34 (0+1)*1101000 14-43 16-19 (0+1)*1110000
01
(0+1)*11011
13-35 (0+1)*1101001 14-44 16-20 (0+1)*1110001
10
(0+1)*11011
13-36 (0+1)*1101010 14-45 16-21 (0+1)*1110010
11
(0+1)*11100
13-37 (0+1)*1101011 14-46 16-22 (0+1)*1110011
00
(0+1)*11100
13-38 (0+1)*1101100 14-47 16-23 (0+1)*1110100
01
(0+1)*11100
13-39 (0+1)*1101101 14-48 16-24 (0+1)*1110101
10
(0+1)*11100
13-40 (0+1)*1101110 14-49 16-25 (0+1)*1110110
11
(0+1)*11101
13-41 (0+1)*1101111 14-50 16-26 (0+1)*1110111
00
(0+1)*11101
13-42 (0+1)*1110000 15-16 16-27 (0+1)*1111000
01
(0+1)*11101
13-43 (0+1)*1110001 15-17 16-28 (0+1)*1111001
10
(0+1)*11101
13-44 (0+1)*1110010 15-18 16-29 (0+1)*1111010
11
(0+1)*11110
13-45 (0+1)*1110011 15-19 16-30 (0+1)*1111011
00
(0+1)*11110
13-46 (0+1)*1110100 15-20 16-31 (0+1)*1111100
01
(0+1)*11110
13-47 (0+1)*1110101 15-21 16-32 (0+1)*1111101
10
Page | 34
Combination R.E. Combination R.E. Combination R.E.
(0+1)*11110
13-48 (0+1)*1110110 15-22 16-33 (0+1)*1111110
11
(0+1)*11111
13-49 (0+1)*1110111 15-23 16-34 (0+1)*1111111
00
(0+1)*11111
13-50 (0+1)*1111000 15-24 16-35 (0+1)*00000000
01
(0+1)*11111
14-15 (0+1)*1111001 15-25 16-36 (0+1)*00000001
10
(0+1)*11111
14-16 (0+1)*1100110 15-26 16-37 (0+1)*00000010
11
(0+1)*11010
14-17 (0+1)*1100111 15-27 16-38 (0+1)*1101110
11
(0+1)*11011
14-18 (0+1)*1101000 15-28 16-39 (0+1)*1101111
00
(0+1)*11011
14-19 (0+1)*1101001 15-29 16-40 (0+1)*1110000
01
(0+1)*11011
14-20 (0+1)*1101010 15-30 16-41 (0+1)*1110001
10
(0+1)*11011
14-21 (0+1)*1101011 15-31 16-42 (0+1)*1110010
11
(0+1)*11100
14-22 (0+1)*1101100 15-32 16-43 (0+1)*1110011
00
(0+1)*11100
14-23 (0+1)*1101101 15-33 16-44 (0+1)*1110100
01
(0+1)*11100
14-24 (0+1)*1101110 15-34 16-45 (0+1)*1110101
10
(0+1)*11100
14-25 (0+1)*1101111 15-35 16-46 (0+1)*1110110
11
(0+1)*11101
14-26 (0+1)*1110000 15-36 16-47 (0+1)*1110111
00
(0+1)*11101
14-27 (0+1)*1110001 15-37 16-48 (0+1)*1111000
01
(0+1)*11101
14-28 (0+1)*1110010 15-38 16-49 (0+1)*1111001
10
(0+1)*11101
14-29 (0+1)*1110011 15-39 16-50 (0+1)*1111010
11
(0+1)*11110
14-30 (0+1)*1110100 15-40 17-18 (0+1)*1111011
00
(0+1)*11110
14-31 (0+1)*1110101 15-41 17-19 (0+1)*1111100
01
(0+1)*11110
14-32 (0+1)*1110110 15-42 17-20 (0+1)*1111101
10
(0+1)*11110
14-33 (0+1)*1110111 15-43 17-21 (0+1)*1111110
11
(0+1)*11111
14-34 (0+1)*1111000 15-44 17-22 (0+1)*1111111
00
Page | 35
Combination R.E. Combination R.E. Combination R.E.
(0+1)*11111
14-35 (0+1)*1111001 15-45 17-23 (0+1)*00000000
01
(0+1)*11111
14-36 (0+1)*1100110 15-46 17-24 (0+1)*00000001
10
(0+1)*11111
14-37 (0+1)*1100111 15-47 17-25 (0+1)*00000010
11
(0+1)*11010
14-38 (0+1)*1101000 15-48 17-26 (0+1)*1101110
11
(0+1)*11011
14-39 (0+1)*1101001 15-49 17-27 (0+1)*1101111
00
(0+1)*11011
14-40 (0+1)*1101010 15-50 17-28 (0+1)*1110000
01
(0+1)*00000
17-29 (0+1)*1110001 18-43 20-27 (0+1)*00101001
100
(0+1)*00000
17-30 (0+1)*1110010 18-44 20-28 (0+1)*00101010
101
(0+1)*00000
17-31 (0+1)*1110011 18-45 20-29 (0+1)*00101011
110
(0+1)*00000
17-32 (0+1)*1110100 18-46 20-30 (0+1)*00101100
111
(0+1)*00001
17-33 (0+1)*1110101 18-47 20-31 (0+1)*00101101
000
(0+1)*00001
17-34 (0+1)*1110110 18-48 20-32 (0+1)*00101110
001
(0+1)*00001
17-35 (0+1)*1110111 18-49 20-33 (0+1)*00101111
010
(0+1)*00001
17-36 (0+1)*1111000 18-50 20-34 (0+1)*00110000
011
(0+1)*00001
17-37 (0+1)*1111001 19-20 20-35 (0+1)*00110001
100
(0+1)*00001
17-38 (0+1)*1111010 19-21 20-36 (0+1)*00110010
101
(0+1)*00001
17-39 (0+1)*1111011 19-22 20-37 (0+1)*00110011
110
(0+1)*00001
17-40 (0+1)*1111100 19-23 20-38 (0+1)*00110100
111
(0+1)*00010
17-41 (0+1)*1111101 19-24 20-39 (0+1)*00110101
000
(0+1)*00010
17-42 (0+1)*1111110 19-25 20-40 (0+1)*00110110
001
(0+1)*00010
17-43 (0+1)*1111111 19-26 20-41 (0+1)*00110111
010
(0+1)*0000000 (0+1)*00010
17-44 19-27 20-42 (0+1)*00111000
0 011
(0+1)*0000000 (0+1)*00010
17-45 19-28 20-43 (0+1)*00111001
1 100
Page | 36
Combination R.E. Combination R.E. Combination R.E.
(0+1)*0000001 (0+1)*00010
17-46 19-29 20-44 (0+1)*00111010
0 101
(0+1)*0000001 (0+1)*00010
17-47 19-30 20-45 (0+1)*00111011
1 110
(0+1)*0000010 (0+1)*00010
17-48 19-31 20-46 (0+1)*00111100
0 111
(0+1)*0000010 (0+1)*00011
17-49 19-32 20-47 (0+1)*00111101
1 000
(0+1)*0000011 (0+1)*00011
17-50 19-33 20-48 (0+1)*00111110
0 001
(0+1)*0000011 (0+1)*00011
18-19 19-34 20-49 (0+1)*00111111
1 010
(0+1)*0000100 (0+1)*00011
18-20 19-35 20-50 (0+1)*01000000
0 011
(0+1)*0000100 (0+1)*00011
18-21 19-36 21-22 (0+1)*01000001
1 100
(0+1)*0000101 (0+1)*00011
18-22 19-37 21-23 (0+1)*01000010
0 101
(0+1)*00011
18-23 (0+1)*1110001 19-38 21-24 (0+1)*01000011
110
(0+1)*00011
18-24 (0+1)*1110010 19-39 21-25 (0+1)*00101001
111
(0+1)*00100
18-25 (0+1)*1110011 19-40 21-26 (0+1)*00101010
000
(0+1)*00100
18-26 (0+1)*1110100 19-41 21-27 (0+1)*00101011
001
(0+1)*00100
18-28 (0+1)*1110101 19-42 21-28 (0+1)*00101100
010
(0+1)*00100
18-29 (0+1)*1110110 19-43 21-29 (0+1)*00101101
011
(0+1)*00100
18-30 (0+1)*1110111 19-44 21-30 (0+1)*00101110
100
(0+1)*00100
18-31 (0+1)*1111000 19-45 21-31 (0+1)*00101111
101
(0+1)*00100
18-32 (0+1)*1111001 19-46 21-32 (0+1)*00110000
110
(0+1)*00100
18-33 (0+1)*1111010 19-47 21-33 (0+1)*00110001
111
(0+1)*00101
18-34 (0+1)*1111011 19-48 21-34 (0+1)*00110010
000
(0+1)*00101
18-35 (0+1)*1111100 19-49 21-35 (0+1)*00110011
001
(0+1)*00101
18-36 (0+1)*1111101 19-50 21-36 (0+1)*00110100
010
(0+1)*00101
18-37 (0+1)*1111110 20-21 21-37 (0+1)*00110101
011
Page | 37
Combination R.E. Combination R.E. Combination R.E.
(0+1)*00000
18-38 (0+1)*1111111 20-22 21-38 (0+1)*00110110
100
(0+1)*0000000 (0+1)*00000
18-39 20-23 21-39 (0+1)*00110111
0 101
(0+1)*0000000 (0+1)*00000
18-40 20-24 21-40 (0+1)*00111000
1 110
(0+1)*0000001 (0+1)*00000
18-41 20-25 21-41 (0+1)*00111001
0 111
(0+1)*0000001 (0+1)*00001
18-42 20-26 21-42 (0+1)*00111010
1 000
(0+1)*0011101 (0+1)*01001
21-43 23-33 25-27 (0+1)*01011110
1 100
(0+1)*0011110 (0+1)*01001
21-44 23-34 25-28 (0+1)*01011111
0 101
(0+1)*0011110 (0+1)*01001
21-45 23-35 25-29 (0+1)*01100000
1 110
(0+1)*0011111 (0+1)*01001
21-46 23-36 25-30 (0+1)*01100001
0 111
(0+1)*0011111 (0+1)*01010
21-47 23-37 25-31 (0+1)*01100010
1 000
(0+1)*0100000 (0+1)*01010
21-48 23-38 25-32 (0+1)*01100011
0 001
(0+1)*0100000 (0+1)*01010
21-49 23-39 25-33 (0+1)*01100100
1 010
(0+1)*0100001 (0+1)*01010
21-50 23-40 25-34 (0+1)*01100101
0 011
(0+1)*0100001 (0+1)*01010
22-23 23-41 25-35 (0+1)*01100110
1 100
(0+1)*0100010 (0+1)*01010
22-24 23-42 25-36 (0+1)*01100111
0 101
(0+1)*0100010 (0+1)*01010
22-25 23-43 25-37 (0+1)*01101000
1 110
(0+1)*0100011 (0+1)*01010
22-26 23-44 25-38 (0+1)*01101001
0 111
(0+1)*0100011 (0+1)*01011
22-27 23-45 25-39 (0+1)*01101010
1 000
(0+1)*0100100 (0+1)*01011
22-28 23-46 25-40 (0+1)*01101011
0 001
(0+1)*0100100 (0+1)*01011
22-29 23-47 25-41 (0+1)*01101100
1 010
(0+1)*0100101 (0+1)*01011
22-30 23-48 25-42 (0+1)*01101101
0 011
(0+1)*0100101 (0+1)*01011
22-31 23-49 25-43 (0+1)*01101110
1 100
(0+1)*0100110 (0+1)*01011
22-32 23-50 25-44 (0+1)*01101111
0 101
Page | 38
Combination R.E. Combination R.E. Combination R.E.
(0+1)*0100110 (0+1)*01011
22-33 24-25 25-47 (0+1)*01110000
1 110
(0+1)*0100111 (0+1)*01011
22-34 24-26 25-48 (0+1)*01110001
0 111
(0+1)*0100111 (0+1)*01100
22-35 24-27 25-49 (0+1)*01110010
1 000
(0+1)*0101000 (0+1)*01100
22-36 24-28 26-27 (0+1)*01110011
0 001
(0+1)*0011101 (0+1)*01100
22-37 24-29 26-28 (0+1)*01110100
1 010
(0+1)*0011110 (0+1)*01100
22-38 24-30 26-29 (0+1)*01110101
0 011
(0+1)*0011110 (0+1)*01100
22-39 24-31 26-30 (0+1)*01110110
1 100
(0+1)*0011111 (0+1)*01100
22-40 24-32 26-31 (0+1)*01110111
0 101
(0+1)*0011111 (0+1)*01100
22-41 24-33 26-32 (0+1)*01111000
1 110
(0+1)*0100000 (0+1)*01001
22-42 24-34 26-33 (0+1)*01011110
0 100
(0+1)*0100000 (0+1)*01001
22-43 24-35 26-34 (0+1)*01011111
1 101
(0+1)*0100001 (0+1)*01001
22-44 24-36 26-35 (0+1)*01100000
0 110
(0+1)*0100001 (0+1)*01001
22-45 24-37 26-36 (0+1)*01100001
1 111
(0+1)*0100010 (0+1)*01010
22-46 24-38 26-37 (0+1)*01100010
0 000
(0+1)*0100010 (0+1)*01010
22-47 24-39 26-38 (0+1)*01100011
1 001
(0+1)*0100011 (0+1)*01010
22-48 24-40 26-39 (0+1)*01100100
0 010
(0+1)*0100011 (0+1)*01010
22-49 24-41 26-40 (0+1)*01100101
1 011
(0+1)*0100100 (0+1)*01010
22-50 24-42 26-41 (0+1)*01100110
0 100
(0+1)*0100100 (0+1)*01010
23-24 24-43 26-42 (0+1)*01100111
1 101
(0+1)*0100101 (0+1)*01010
23-25 24-44 26-43 (0+1)*01101000
0 110
(0+1)*0100101 (0+1)*01010
23-26 24-45 26-44 (0+1)*01101001
1 111
(0+1)*0100110 (0+1)*01011
23-27 24-46 26-45 (0+1)*01101010
0 000
(0+1)*0100110 (0+1)*01011
23-28 24-47 26-46 (0+1)*01101011
1 001
Page | 39
Combination R.E. Combination R.E. Combination R.E.
(0+1)*0100111 (0+1)*01011
23-29 24-48 26-47 (0+1)*01101100
0 010
(0+1)*0100111 (0+1)*01011
23-30 24-49 26-48 (0+1)*01101101
1 011
(0+1)*0101000 (0+1)*01011
23-31 24-50 26-49 (0+1)*01101110
0 100
(0+1)*0011101 (0+1)*01011
23-32 25-26 26-50 (0+1)*01101111
1 101
(0+1)*0111000 (0+1)*01110
27-28 29-30 31-36 (0+1)*10100010
0 101
(0+1)*0111000 (0+1)*01110
27-29 29-31 31-37 (0+1)*10100011
1 110
(0+1)*0111001 (0+1)*01110
27-30 29-32 31-38 (0+1)*10100100
0 111
(0+1)*0111001 (0+1)*01111
27-31 29-33 31-39 (0+1)*10100101
1 000
(0+1)*0111010 (0+1)*01111
27-32 29-34 31-40 (0+1)*10100110
0 001
(0+1)*0111010 (0+1)*01111
27-33 29-35 31-41 (0+1)*10100111
1 010
(0+1)*0111011 (0+1)*01111
27-34 29-36 31-42 (0+1)*10101000
0 011
(0+1)*0111011 (0+1)*01111
27-35 29-37 31-43 (0+1)*10101001
1 100
(0+1)*0111100 (0+1)*01111
27-36 29-38 31-44 (0+1)*10101010
0 101
(0+1)*0111100 (0+1)*01111
27-37 29-39 31-45 (0+1)*10101011
1 110
(0+1)*0111101 (0+1)*01111
27-38 29-40 31-46 (0+1)*10101100
0 111
(0+1)*0111101 (0+1)*10000
27-39 29-41 31-47 (0+1)*10101101
1 000
(0+1)*0111110 (0+1)*10000
27-40 29-42 31-48 (0+1)*10101110
0 001
(0+1)*0111110 (0+1)*10000
27-41 29-43 31-49 (0+1)*10101111
1 010
(0+1)*0111111 (0+1)*10000
27-42 29-44 31-50 (0+1)*10110000
0 011
(0+1)*0111111 (0+1)*10000
27-43 29-45 32-33 (0+1)*10110001
1 100
(0+1)*1000000 (0+1)*10000
27-44 29-46 32-34 (0+1)*10110010
0 101
(0+1)*1000000 (0+1)*10000
27-45 29-47 32-35 (0+1)*10110011
1 110
(0+1)*1000001 (0+1)*10000
27-46 29-48 32-36 (0+1)*10110100
0 111
Page | 40
Combination R.E. Combination R.E. Combination R.E.
(0+1)*1000001 (0+1)*10001
27-47 29-49 32-37 (0+1)*10110101
1 000
(0+1)*1000010 (0+1)*10001
27-48 29-50 32-38 (0+1)*10110110
0 001
(0+1)*1000010 (0+1)*10001
27-49 30-31 32-39 (0+1)*10110111
1 010
(0+1)*1000011 (0+1)*10001
27-50 30-32 32-40 (0+1)*10111000
0 011
(0+1)*1000011 (0+1)*10001
28-29 30-33 32-41 (0+1)*10111001
1 100
(0+1)*1000100 (0+1)*10001
28-30 30-34 32-42 (0+1)*10111010
0 101
(0+1)*1000100 (0+1)*10001
28-31 30-35 32-43 (0+1)*10111011
1 110
(0+1)*1000101 (0+1)*10001
28-32 30-36 32-44 (0+1)*10111100
0 111
(0+1)*1000101 (0+1)*10010
28-33 30-37 32-45 (0+1)*10111101
1 000
(0+1)*1000110 (0+1)*10010
28-34 30-38 32-46 (0+1)*10111110
0 001
(0+1)*1000110 (0+1)*10010
28-35 30-39 32-47 (0+1)*10111111
1 010
(0+1)*1000111 (0+1)*10010
28-36 30-40 32-48 (0+1)*11000000
0 011
(0+1)*1000111 (0+1)*10010
28-37 30-41 32-49 (0+1)*11000001
1 100
(0+1)*1001000 (0+1)*10010
28-38 30-42 32-50 (0+1)*11000010
0 101
(0+1)*1001000 (0+1)*10010
28-39 30-43 33-34 (0+1)*11000011
1 110
(0+1)*1001001 (0+1)*10010
28-40 30-44 33-35 (0+1)*11000100
0 111
(0+1)*1001001 (0+1)*10011
28-41 30-45 33-36 (0+1)*11000101
1 000
(0+1)*1001010 (0+1)*10011
28-42 30-46 33-37 (0+1)*10100010
0 001
(0+1)*1001010 (0+1)*10011
28-43 30-47 33-38 (0+1)*10100011
1 010
(0+1)*1001011 (0+1)*10011
28-44 30-48 33-39 (0+1)*10100100
0 011
(0+1)*1001011 (0+1)*10011
28-45 30-49 33-40 (0+1)*10100101
1 100
(0+1)*0111000 (0+1)*10011
28-46 30-50 33-41 (0+1)*10100110
0 101
(0+1)*0111000 (0+1)*10011
28-47 31-32 33-42 (0+1)*10100111
1 110
Page | 41
Combination R.E. Combination R.E. Combination R.E.
(0+1)*0111001 (0+1)*10011
28-48 31-33 33-43 (0+1)*10101000
0 111
(0+1)*0111001 (0+1)*10100
28-49 31-34 33-44 (0+1)*10101001
1 000
(0+1)*0111010 (0+1)*10100
28-50 31-35 33-45 (0+1)*10101010
0 001
(0+1)*1010101 (0+1)*11011 (0+1)*00000010
33-46 36-46 40-45
1 000 1
(0+1)*1010110 (0+1)*11011 (0+1)*00000011
33-47 36-47 40-46
0 001 0
(0+1)*1010110 (0+1)*11011 (0+1)*00000011
33-48 36-48 40-47
1 010 1
(0+1)*1010111 (0+1)*11011 (0+1)*00000100
33-49 36-49 40-48
0 011 0
(0+1)*1010111 (0+1)*11011 (0+1)*00000100
33-50 36-50 40-49
1 100 1
(0+1)*1011000 (0+1)*11011 (0+1)*00000101
34-35 37-38 40-50
0 101 0
(0+1)*1011000 (0+1)*11011 (0+1)*00000101
34-36 37-39 41-42
1 110 1
(0+1)*1011001 (0+1)*11011 (0+1)*00000110
34-37 37-40 41-43
0 111 0
(0+1)*1011001 (0+1)*11100 (0+1)*00000110
34-38 37-41 41-44
1 000 1
(0+1)*1011010 (0+1)*11100 (0+1)*00000111
34-39 37-42 41-45
0 001 0
(0+1)*1011010 (0+1)*11100 (0+1)*00000111
34-40 37-43 41-46
1 010 1
(0+1)*1011011 (0+1)*11100 (0+1)*00001000
34-41 37-44 41-47
0 011 0
(0+1)*1011011 (0+1)*11100 (0+1)*00001000
34-42 37-45 41-48
1 100 1
(0+1)*1011100 (0+1)*11100 (0+1)*00001001
34-43 37-46 41-49
0 101 0
(0+1)*1011100 (0+1)*11100 (0+1)*00001001
34-44 37-47 41-50
1 110 1
(0+1)*1011101 (0+1)*11100 (0+1)*00001010
34-45 37-48 42-43
0 111 0
(0+1)*1011101 (0+1)*11101 (0+1)*00001010
34-46 37-49 42-44
1 000 1
(0+1)*1011110 (0+1)*11101 (0+1)*00001011
34-47 37-50 42-45
0 001 0
(0+1)*1011110 (0+1)*11101 (0+1)*00001011
34-48 38-39 42-46
1 010 1
(0+1)*1011111 (0+1)*11101 (0+1)*00001100
34-49 38-40 42-47
0 011 0
Page | 42
Combination R.E. Combination R.E. Combination R.E.
(0+1)*1011111 (0+1)*11101 (0+1)*00001100
34-50 38-41 42-48
1 100 1
(0+1)*1100000 (0+1)*11101 (0+1)*00001101
35-36 38-42 42-49
0 101 0
(0+1)*1100000 (0+1)*11101 (0+1)*00001101
35-37 38-43 42-50
1 110 1
(0+1)*1100001 (0+1)*11101 (0+1)*00001110
35-38 38-44 43-44
0 111 0
(0+1)*1100001 (0+1)*11110 (0+1)*00001110
35-39 38-45 43-45
1 000 1
(0+1)*1100010 (0+1)*11110 (0+1)*00001111
35-40 38-46 43-46
0 001 0
(0+1)*1100010 (0+1)*11110 (0+1)*00001111
35-41 38-47 43-47
1 010 1
(0+1)*1100011 (0+1)*11110 (0+1)*00010000
35-42 38-48 43-48
0 011 0
(0+1)*1100011 (0+1)*11110 (0+1)*00010000
35-43 38-49 43-49
1 100 1
(0+1)*1100100 (0+1)*11110 (0+1)*00010001
35-44 38-50 43-50
0 101 0
(0+1)*1100100 (0+1)*11110 (0+1)*00010001
35-45 39-40 44-45
1 110 1
(0+1)*1100101 (0+1)*11110 (0+1)*00010010
35-46 39-41 44-46
0 111 0
(0+1)*1100101 (0+1)*11111 (0+1)*00010010
35-47 39-42 44-47
1 000 1
(0+1)*1100110 (0+1)*11111 (0+1)*00010011
35-48 39-43 44-48
0 001 0
(0+1)*1100110 (0+1)*11111 (0+1)*00010011
35-49 39-44 44-49
1 010 1
(0+1)*1100111 (0+1)*11111 (0+1)*00010100
35-50 39-45 44-50
0 011 0
(0+1)*1100111 (0+1)*11111 (0+1)*00010100
36-37 39-46 45-46
1 100 1
(0+1)*1101000 (0+1)*11111 (0+1)*00010101
36-38 39-47 45-47
0 101 0
(0+1)*1101000 (0+1)*11111 (0+1)*00010101
36-39 39-48 45-48
1 110 1
(0+1)*1101001 (0+1)*11111 (0+1)*00010110
36-40 39-49 45-49
0 111 0
(0+1)*1101001 (0+1)*00000 (0+1)*00010110
36-41 39-50 45-50
1 0000 1
(0+1)*1101010 (0+1)*00000 (0+1)*00010111
36-42 40-41 46-47
0 0001 0
(0+1)*1101010 (0+1)*00000 (0+1)*00010111
36-43 40-42 46-48
1 0010 1
Page | 43
(0+1)*1101011 (0+1)*00000 (0+1)*00011000
36-44 40-43 46-49
0 0011 0
(0+1)*1101011 (0+1)*00000 (0+1)*00011000
36-45 40-44 46-50
1 0100 1
(0+1)*0001100 (0+1)*00011 (0+1)*00011011
47-48 47-50 48-50
11 0101 1
(0+1)*0001101 (0+1)*00011 (0+1)*00011100
47-49 48-49 49-50
00 0110 0
<nta>
<template>
</location>
<init ref="id0"/>
<transition>
<source ref="id0"/>
<target ref="id0"/>
</transition>
</template>
Page | 44
Process = Template();
system Process;
</system>
<queries>
</queries>
</nta>
<nta>
<template>
</location>
</location>
<init ref="id1"/>
<transition>
<source ref="id0"/>
<target ref="id1"/>
</transition>
Page | 45
<transition>
<source ref="id0"/>
<target ref="id0"/>
</transition>
<transition>
<source ref="id1"/>
<target ref="id1"/>
</transition>
<transition>
<source ref="id1"/>
<target ref="id0"/>
</transition>
</template>
Process = Template();
system Process;
</system>
<queries>
</queries>
Page | 46
Token Recognizer Code:
#include <iostream>
#include <string>
#include <map>
int main() {
std::map<std::string, std::string> commandMapping;
// Populate the command mapping
commandMapping["#id."] = "#include<iostream>";
commandMapping["nameui."] = "using namespace std;";
commandMapping["imain."] = "int main()";
commandMapping["endbri"] = "}";
commandMapping["strbri"] = "{";
commandMapping["ritsemi"] = "return 0;";
commandMapping["brsemi"] = "break;";
commandMapping["psemi"] = ";";
commandMapping["abrik"] = "array[]";
commandMapping["pic"] = "public:";
commandMapping["pri"] = "private:";
commandMapping["csemi"] = "class MyClass{};";
commandMapping["istr"] = "int*";
commandMapping["iref"] = "int&";
commandMapping["mcobj"] = "Myclass obj";
commandMapping["is"] = "this->";
commandMapping["fin."] = "func()";
commandMapping["dwil"] = "do{}while();";
commandMapping["sfi"] = "/*";
commandMapping["cmi"] = "//";
commandMapping["eli"] = "endl";
commandMapping["ain"] = "&&";
commandMapping["ire"] = "||";
Page | 47
commandMapping["eiei"] = "==";
commandMapping["nei"] = "!=";
commandMapping["lei"] = "<=";
commandMapping["gei"] = ">=";
commandMapping["pei"] = "+=";
std::string userInput;
std::cout << "Enter a command abbreviation: ";
std::cin >> userInput;
// Check if the user input exists in the mapping
if (commandMapping.find(userInput) != commandMapping.end()) {
std::cout << "Relative command: " << commandMapping[userInput] << std::endl;
} else {
std::cout << "Command not found." << std::endl;
}
return 0;
}
Lab 7:
Code:
#include <iostream>
#include <string>
using namespace std;
class Command {
public:
string commandName;
string regularExpression;
string controlLanguage;
string bindCommand;
string controlString;
Command(string cName, string rExp, string cLang, string bCommand, string cString)
: commandName(cName), regularExpression(rExp), controlLanguage(cLang),
bindCommand(bCommand), controlString(cString) {}
};
int main() {
Command commands[] = {
Command("#include<iostream>", "(a+b)*", "(0+1)*0(0+1)*", "#id.", "0"),
Command("using namespace std;", "(a+b)*", "(0+1)*1(0+1)*", "nameui.", "1"),
Command("int main()", "(a+b)*", "(0+1)*00(0+1)*", "imain.", "00"),
Command("{", "(a+b)*", "(0+1)*01(0+1)*", "strbri", "01"),
Command("}", "(a+b)*", "(0+1)*10(0+1)*", "endbri", "10"),
Command("cout<<", "(a+b)*", "(0+1)*11(0+1)*", "print", "11"),
Command(";", "(a+b)*", "(0+1)*000(0+1)*", "semi", "000"),
Page | 48
Command("\"", "a(a+b)*", "(0+1)*001(0+1)*", "strin", "001"),
Command("\"", "(a+b)*", "(0+1)*010(0+1)*", "endin", "010"),
Command("'", "a(a+b)*b", "(0+1)*011(0+1)*", "strlin", "011"),
Command("'", "b(a+b)*a", "(0+1)*100(0+1)*", "endlin", "100"),
Command("int", "(a+b)*", "(0+1)*101(0+1)*", "i", "101"),
Command("float", "(a+b)*", "(0+1)*110(0+1)*", "fli", "110"),
Command("double", "(a+b)*", "(0+1)*111(0+1)*", "dli", "111"),
Command("char", "(a+b)*", "(0+1)*0000(0+1)*", "chi", "0000"),
Command("bool", "(a+b)*", "(0+1)*0001(0+1)*", "bli", "0001"),
Command("string", "(a+b)*", "(0+1)*0010(0+1)*", "sri", "0010"),
Command("//", "(a+b)*", "(0+1)*0011(0+1)*", "cmi", "0011"),
Command("cin>>", "(a+b)*", "(0+1)*0100(0+1)*", "in", "0100"),
Command("const", "(a+b)*", "(0+1)*0101(0+1)*", "cist", "0101"),
Command("static", "(a+b)*", "(0+1)*0110(0+1)*", "sti", "0110"),
Command("if()", "(a+b)*", "(0+1)*0111(0+1)*", "fi", "0111"),
Command("else", "(a+b)*", "(0+1)*1000(0+1)*", "ils", "1000"),
Command("while()", "(a+b)*", "(0+1)*1001(0+1)*", "wil", "1001"),
Command("for()", "(a+b)*", "(0+1)*1010(0+1)*", "fire", "1010"),
Command("switch", "(a+b)*", "(0+1)*1011(0+1)*", "site", "1011"),
Command("case 1:", "(a+b)*", "(0+1)*1100(0+1)*", "size", "1100"),
Command("break;", "(a+b)*", "(0+1)*1101(0+1)*", "brsemi", "1101"),
Command("return 0;", "(a+b)*", "(0+1)*1110(0+1)*", "ritsemi", "1110"),
Command("x++;", "(a+b)*", "(0+1)*1111(0+1)*", "psemi", "1111"),
Command("x--;", "(a+b)*", "(0+1)*00000(0+1)*", "nsemi", "00000"),
Command("array[]", "(a+b)*", "(0+1)*00001(0+1)*", "abrik", "00001"),
Command("public:", "(a+b)*", "(0+1)*00010(0+1)*", "pic", "00010"),
Command("private:", "(a+b)*", "(0+1)*00011(0+1)*", "pri", "00011"),
Command("class MyClass{};", "(a+b)*", "(0+1)*00100(0+1)*", "csemi", "00100"),
Command("int*", "(a+b)*", "(0+1)*00101(0+1)*", "istr", "00101"),
Command("int&", "(a+b)*", "(0+1)*00110(0+1)*", "iref", "00110"),
Command("Myclass obj", "(a+b)*", "(0+1)*00111(0+1)*", "mcobj", "00111"),
Command("this->", "(a+b)*", "(0+1)*01000(0+1)*", "is", "01000"),
Command("func()", "(a+b)*", "(0+1)*01001(0+1)*", "fin.", "01001"),
Command("do{}while();", "(a+b)*", "(0+1)*01010(0+1)*", "dwil", "01010"),
Command("/*", "(a+b)*", "(0+1)*01011(0+1)*", "sfi", "01011"),
Command("endl", "(a+b)*", "(0+1)*01100(0+1)*", "eli", "01100"),
Command("&&", "(a+b)*", "(0+1)*01101(0+1)*", "ain", "01101"),
Command("||", "(a+b)*", "(0+1)*01110(0+1)*", "ire", "01110"),
Command("==", "(a+b)*", "(0+1)*01111(0+1)*", "eiei", "01111"),
Command("!=", "(a+b)*", "(0+1)*10000(0+1)*", "nei", "10000"),
Command("<=", "(a+b)*", "(0+1)*10001(0+1)*", "lei", "10001"),
Command(">=", "(a+b)*", "(0+1)*10010(0+1)*", "gei", "10010"),
Command("+=", "(a+b)*", "(0+1)*10011(0+1)*", "pei", "10011"),
};
string searchControlString;
while (true) {
cout << "Enter a control string to search (or type 'exit' to quit): ";
cin >> searchControlString;
if (searchControlString == "exit") {
break;
}
bool found = false;
for (int i = 0; i < sizeof(commands) / sizeof(commands[0]); i++) {
if (commands[i].controlString == searchControlString) {
found = true;
cout << "Command Name: " << commands[i].commandName << endl;
cout << "Regular Expression: " <<
commands[i].regularExpression << endl;
Page | 49
cout << "Control Language: " << commands[i].controlLanguage <<
endl;
cout << "Binding Command: " << commands[i].bindCommand <<
endl;
cout << "Control Strings: " << commands[i].controlString <<
endl;
break;
}
}
if (!found) {
cout << "Control string not found." << endl;
}
}
return 0;
}
Lab 9:
Code: of persistent stack storing data in file:
#include <iostream>
#include <string>
#include <stack>
int main() {
std::stack<std::string> validTokensStack;
while (true) {
std::string input;
std::cout << "Enter a string (or enter 'q' to quit): ";
std::cin >> input;
if (input == "q") {
break;
}
if (isValidToken(input)) {
// Check if the string already exists in the stack
bool isStringInStack = false;
std::stack<std::string> tempStack;
Page | 50
while (!validTokensStack.empty()) {
if (validTokensStack.top() == input) {
isStringInStack = true;
break;
}
tempStack.push(validTokensStack.top());
validTokensStack.pop();
}
while (!tempStack.empty()) {
validTokensStack.push(tempStack.top());
tempStack.pop();
}
if (isStringInStack) {
std::cout << "String already exists in the stack: " << input
<< std::endl;
}
else {
if (validTokensStack.size() < 50) {
validTokensStack.push(input);
std::cout << "String added to the stack: " << input <<
std::endl;
}
else {
std::cout << "Stack is full. Cannot add more strings."
<< std::endl;
}
}
}
else {
std::cout << "Invalid string. Doesn't belong to the specified list."
<< std::endl;
}
}
return 0;
}
Page | 51
"lei", "gei", "pei" };
int main() {
std::ofstream outputFile;
outputFile.open("output.txt");
if (!outputFile.is_open()) {
std::cerr << "Error: Unable to open the file." << std::endl;
return 1;
}
std::string input;
std::vector<std::string> validTokensArray;
while (true) {
std::cout << "Enter a string (or enter 'q' to quit): ";
std::cin >> input;
if (input == "q") {
break;
}
if (isValidToken(input)) {
// Check if the string already exists in the array
if (std::find(validTokensArray.begin(), validTokensArray.end(),
input) != validTokensArray.end()) {
std::cout << "String already exists in the array: " << input
<< std::endl;
}
else {
if (validTokensArray.size() < 50) {
validTokensArray.push_back(input);
std::cout << "String added to the array: " << input <<
std::endl;
outputFile << input << std::endl;
}
else {
std::cout << "Array is full. Cannot add more strings."
<< std::endl;
}
}
}
else {
std::cout << "Invalid string. Doesn't belong to the specified list."
<< std::endl;
}
}
return 0;
}
Page | 52
Code: of imperative stack storing data in file:
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
bool isValidToken(const std::string& input) {
std::string validTokens[] = { "#id.", "nameui.", "imain.", "strbri", "endbri",
"print", "semi", "strin",
"endin", "strlin", "endlin", "i", "fli", "dli", "chi", "bli", "sri", "cmi",
"in", "cist", "sti", "fi", "ils", "wil", "fire", "site", "size", "brsemi",
"ritsemi", "psemi", "nsemi", "abrik", "pic", "pri", "csemi", "istr", "iref",
"mcobj", "is", "fin.", "dwil", "sfi", "eli", "ain", "ire", "eiei", "nei",
"lei", "gei", "pei" };
return std::find(std::begin(validTokens), std::end(validTokens), input) !=
std::end(validTokens);
}
int main() {
std::string input;
std::stack<std::string> validTokensStack;
while (true) {
std::cout << "Enter a string (or enter 'q' to quit): ";
std::cin >> input;
if (input == "q") {
break;
}
if (isValidToken(input)) {
// Check if the string already exists in the stack
bool isStringInStack = false;
std::stack<std::string> tempStack;
while (!validTokensStack.empty()) {
if (validTokensStack.top() == input) {
isStringInStack = true;
break;
}
tempStack.push(validTokensStack.top());
validTokensStack.pop();
}
while (!tempStack.empty()) {
validTokensStack.push(tempStack.top());
tempStack.pop();
}
if (isStringInStack) {
std::cout << "String already exists in the stack: " << input
<<
std::endl;
}
else {
if (validTokensStack.size() < 50) {
validTokensStack.push(input);
std::cout << "String added to the stack: " << input <<
std::endl;
}
else {
std::cout << "Stack is full. Cannot add more strings."
<<
std::endl;
Page | 53
}
}
}
else {
std::cout << "Invalid string. Doesn't belong to the specified list."
<<
std::endl;
}
}
return 0;
}
Page | 54
}
}
}
else {
std::cout << "Invalid string. Doesn't belong to the specified list."
<<
std::endl;
}
}
return 0;
}
Lab 11:
Code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// For this example, assume the regex pattern contains only 'y', 'z', '|', '*', and
'()'
// Break down the regular expression into CFG rules (simplified)
int main() {
string inputRegex = "y(y|z)+ + (y|z)*z";
generateCFG(inputRegex);
return 0;
}
Page | 55
Lab 14:
Page | 56
Page | 57
Project Assignment 2:
Page | 58
Page | 59
Page | 60
Page | 61
Page | 62
Page | 63
Page | 64
Page | 65
Page | 66
Page | 67
Page | 68
Page | 69
Page | 70
Page | 71
Page | 72
Page | 73
Page | 74
Page | 75
Page | 76
Page | 77
Page | 78
Page | 79
Page | 80
Page | 81
Page | 82
Tapes (Of Symbol Table)
Page | 83
Page | 84
Page | 85
Page | 86
Page | 87
Page | 88
Page | 89