Question: amming Execise 2 Implement the state machine you created in the previous problem a Python (3+) or Java (8+) program. Your program will reeive a

 amming Execise 2 Implement the state machine you created in the

previous problem a Python (3+) or Java (8+) program. Your program will

amming Execise 2 Implement the state machine you created in the previous problem a Python (3+) or Java (8+) program. Your program will reeive a single line of text as input. As your program processes each character, it prints each character that it recognizes as part of the token, one character per line. If it reads a character that it doesn't expect or if it reaches the end of input, stop processing and print either ACCEPT if the machine is in an accept state, or REJECT if it is not. 3 Example 1: if the input is 3.14, your program would print 4 ACCEPT Example 2: if the input is 1.2.3, your program would print 2 ACCEPT Notice that the machine stops processing when it sees the second ", because it was not expecting to see a"." in that state. However the state that it was in when it stopped is an accepting state. So it prints ACCEPT. This makes sense because the characters that it has processed so far comprise a valid float token. Example 3: if the input is .. (two dots), your program would print REJECT In this case, your state machine halts when it sees the second".", because it is in a state in which it is looking for a digit. However, the characters it has processed so far (a single dot) is not a valid float token, so your program prints REJECT. Example 4: if the input is 123, your program would print 2 REJECT In this case, your program reaches the end of input in a non-accepting state (the number has no decimal point, so is not a float token)

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 Databases Questions!