Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have already created finite automata and grammar. i just need this to be implemented in C++ (im not sure how to do this without

image text in transcribedimage text in transcribed

I have already created finite automata and grammar. i just need this to be implemented in C++ (im not sure how to do this without the if-else statements)

Homework 5-UMBC-CMSC331- FALL 2018 Due on November 1, 2018 11:59 PM We need to implement a lexical analyzer which is able to recognize octal and decimal numbers with the following requirements. e An input number starts with a+ or - sign. e An octal number starts with a 0 and can continue with an arbitrarily number of digits. An octal number started with more than one 0 is not an acceptable number. Note: digits used in an octal number are between 0 and 7 e A decimal number starts with any digit except 0 and can continue with an arbitrarily number of digits. Note: digits used in a decimal number are between0 and 9. 0 is an acceptable number, no matter whether we accept it as a decimal or as an octal number 1. You wrote a grammar and created a finite automaton for such language in homework 4 2. Write C++ code to implement your finite automata. You compile your program on UMBC GL servers using g++ compiler Your program receives a string of numbers separated by space character. It analyzes every number and outputs whether that number is accepted or rejected. Here is the sample input: +0-03489-00 +9803467-184-04650-034-21 Here is the sample output: Accepted:+0 Rejected: -03489 Rejected:-00 Accepted: +9803467 Accepted: -184 Accepted:-04650 Rejected: Rejected: -034-21 Your program reads the strings of numbers from a text file called "test-data.txt and you can simply hard code the name of the data file in your program. Homework 5-UMBC-CMSC331- FALL 2018 Due on November 1, 2018 11:59 PM We need to implement a lexical analyzer which is able to recognize octal and decimal numbers with the following requirements. e An input number starts with a+ or - sign. e An octal number starts with a 0 and can continue with an arbitrarily number of digits. An octal number started with more than one 0 is not an acceptable number. Note: digits used in an octal number are between 0 and 7 e A decimal number starts with any digit except 0 and can continue with an arbitrarily number of digits. Note: digits used in a decimal number are between0 and 9. 0 is an acceptable number, no matter whether we accept it as a decimal or as an octal number 1. You wrote a grammar and created a finite automaton for such language in homework 4 2. Write C++ code to implement your finite automata. You compile your program on UMBC GL servers using g++ compiler Your program receives a string of numbers separated by space character. It analyzes every number and outputs whether that number is accepted or rejected. Here is the sample input: +0-03489-00 +9803467-184-04650-034-21 Here is the sample output: Accepted:+0 Rejected: -03489 Rejected:-00 Accepted: +9803467 Accepted: -184 Accepted:-04650 Rejected: Rejected: -034-21 Your program reads the strings of numbers from a text file called "test-data.txt and you can simply hard code the name of the data file in your program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions