Question: Help complete code! This is what I have so far, and in the provided images you will find the instructions. There is also a pda.h

Help complete code! This is what I have so far, and in the provided images you will find the instructions. There is also a pda.h file and main.c file I will include. #include
PDA::PDA(){
// Initialize any member variables if necessary
name = "Your Name"; // Set a default name if needed
labNumber =7; // Set a default lab number if needed
description ="{w | w is a legal NASM integer constant}"; // Set a default description
// Any other initialization can go here
}
void PDA::initializeMachine(){
// State 0: Initial state, expecting start of number
machine.insert({0, TableEntry('0','x', "push", 1)}); // Hexadecimal prefix 0x
machine.insert({0, TableEntry('0','X', "push", 1)}); // Hexadecimal prefix 0X
machine.insert({0, TableEntry('0','b', "push", 2)}); // Binary prefix 0b
machine.insert({0, TableEntry('0','B', "push", 2)}); // Binary prefix 0B
machine.insert({0, TableEntry('0','o', "push", 3)}); // Octal prefix 0o
machine.insert({0, TableEntry('0','O', "push", 3)}); // Octal prefix 0O
machine.insert({0, TableEntry('0','d', "push", 4)}); // Decimal prefix 0d
machine.insert({0, TableEntry('0','D', "push", 4)}); // Decimal prefix 0D
machine.insert({0, TableEntry('0','t', "push", 4)}); // Decimal prefix 0t
machine.insert({0, TableEntry('0','T', "push", 4)}); // Decimal prefix 0T
// State 1: Reading Hexadecimal digits (after 0x or 0X)
for (char c ='0'; c ='9'; c++){
machine.insert({1, TableEntry(c,'A', "push", 1)}); // Valid hex digits 0-9
}
for (char c ='A'; c ='F'; c++){
machine.insert({1, TableEntry(c,'A', "push", 1)}); // Valid hex digits A-F
}
for (char c ='a'; c ='f'; c++){
machine.insert({1, TableEntry(c,'A', "push", 1)}); // Valid hex digits a-f
}
machine.insert({1, TableEntry('_','_', "push", 1)}); // Underscore allowed
machine.insert({1, TableEntry('','', "pop", 5)}); // End of input
// State 2: Reading Binary digits (after 0b or 0B)
machine.insert({2, TableEntry('0','A', "push", 2)}); // Valid binary digits 0
machine.insert({2, TableEntry('1','A', "push", 2)}); // Valid binary digits 1
machine.insert({2, TableEntry('_','_', "push", 2)}); // Underscore allowed
machine.insert({2, TableEntry('','', "pop", 5)}); // End of input
// State 3: Reading Octal digits (after 0o or 0O)
for (char c ='0'; c ='7'; c++){
machine.insert({3, TableEntry(c,'A', "push", 3)}); // Valid octal digits 0-7
}
machine.insert({3, TableEntry('_','_', "push", 3)}); // Underscore allowed
machine.insert({3, TableEntry('','', "pop", 5)}); // End of input
// State 4: Reading Decimal digits (after 0d,0D,0t, or 0T)
for (char c ='0'; c ='9'; c++){
machine.insert({4, TableEntry(c,'A', "push", 4)}); // Valid decimal digits 0-9
}
machine.insert({4, TableEntry('_','_', "push", 4)}); // Underscore allowed
machine.insert({4, TableEntry('','', "pop", 5)}); // End of input
// State 5: Final accepting state (valid input)
machine.insert({5, TableEntry('','', "pop", 5)}); // Allow whitespace at the end
} for whatever reason this code does not seem to be able to handle certain test cases like these > Input: 0123456789aAbBcCdDeEfFx Result: -- NOT accepted --
78c78
Input: 0123456789aAbBcCdDeEfFh Result: ** accepted **
---
> Input: 0123456789aAbBcCdDeEfFh Result: -- NOT accepted --
80c80
Input: 0123456789aAbBcCdDeEfFH Result: ** accepted **
---
> Input: 0123456789aAbBcCdDeEfFH Result: -- NOT accepted --
90c90
Input: 01234d Result: ** accepted **
---
> Input: 01234d Result: -- NOT accepted --
92c92
Input: 01234 Result: ** accepted **
---
> Input: 01234 Result: -- NOT accepted --
96c96
Input: 01234567o Result: ** accepted **
---
> Input: 01234567o Result: -- NOT accepted --
100c100
Input: 01b Result: ** accepted **
---
> Input: 01b Result: -- NOT accepted --
102c102
Input: 0_1_b Result: ** accepted **
---
> Input: 0_1_b Result: -- NOT accepted --
Help complete code! This is what I have so far,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!