Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. Write C++ code to implement your finite automata. We need to implement a lexical analyzer which is able to recognize octal and decimal numbers
3. Write C++ code to implement your finite automata.
We need to implement a lexical analyzer which is able to recognize octal and decimal numbers with the following requirements. An input number starts with a +or - sign. 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 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. Write a context free grammar or a regular grammar to satisfy the requirements. Note: the alphabet of this language is (+, , 0, 1,2,3,4,5, 6, 7, 8,9). 2. Create a finite automaton for the grammar We need to implement a lexical analyzer which is able to recognize octal and decimal numbers with the following requirements. An input number starts with a +or - sign. 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 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. Write a context free grammar or a regular grammar to satisfy the requirements. Note: the alphabet of this language is (+, , 0, 1,2,3,4,5, 6, 7, 8,9). 2. Create a finite automaton for the grammarStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started