Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a context free grammar or a regular grammar to satisfy the requirements. We need to implement a lexical analyzer which is able to recognize

Write a context free grammar or a regular grammar to satisfy the requirements. 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 between 0 and 9.

  • 0 is an acceptable number, no matter whether we accept it as a decimal or as an octal number.

    Note: the alphabet of this language is {+, -, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. You can also use epsilon or empty string character in your grammar. Remember, your grammar in addition to generating valid strings should not allow the generation of invalid strings such as the following rejected strings.

    Here are some examples of accepted strings: {+0, +9803467, -184, -04650, ...} Here are some examples of rejected or invalid strings: {-03489, -00, +, -034-21, 146802, ...}

For the requirements in question 3 create a finite automaton. Remember, the automaton or state machine, in addition to accepting the valid strings, should not accept the invalid strings. That means, you need also to include one or more non-accepting states in your machine to redirect wrong strings to them.

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions