• :00Days
• :00Hours
• :00Mins
• 00Seconds
A new era for learning is coming soon

### Select your language

Suggested languages for you:

Americas

Europe

Q32E

Expert-verified
Found in: Page 857

### Discrete Mathematics and its Applications

Book edition 7th
Author(s) Kenneth H. Rosen
Pages 808 pages
ISBN 9780073383095

# Give production rules in Backus–Naur form for the name of a person if this name consists of a first name, which is a string of letters, where only the first letter is uppercase; a middle initial; and a last name, which can be any string of letters.

The production rules in Backus–Naur form for the name of a person.

$$\begin{array}{l}{\bf{ < first name > < middle name > < last name > }}\\{\bf{ < uppercase letter > letter string < middle name > < last name > }}\\{\bf{J < letter string > < middle name > < last name > }}\\{\bf{James < middle name > < last name > }}\\{\bf{James k < last name > }}\\{\bf{James k roggs}}{\bf{.}}\end{array}$$

See the step by step solution

## Step 1: About Backus-Nour form

A type-2 grammar is designated by the notation known as Backus-Naur form.

The left side of a type 2 grammar's production is one non-terminal symbol.

It can merge all of the productions into a single statement using the same left non-terminal symbol à rather than listing each one separately in production,

It use the symbol:: =

Enclose all non-terminal symbols in brackets <>, and it list all right-hand sides of productions in the same statement, separating them by bars.

## Step 2: Backus-Naur form of productions of the grammar.

It ignores the spaces between names and assume that the name is not empty. The grammar can be written as:

$$\begin{array}{c}{\bf{ < person > :: = < first name > < middle name > < last name > }}\\{\bf{ < last name > :: = < letter string > }}\\{\bf{ < middle name > :: = < letter > }}\\{\bf{ < first name > :: = < uppercase letter > | < uppercase letter > letter string }}\\{\bf{ < letter string > :: = < letter > | < letter string > < letter > }}\\{\bf{ < letter > :: = < lowercase letter > I < uppercase letter > }}\\{\bf{ < lowercase letter > :: = a|b|c|}}...{\bf{|z}}\\{\bf{ < uppercase letter > :: = A|B|C|}}...{\bf{|Z }}\end{array}$$

## Step 3: Let’s describe all production,

The first production tells that a person has a first name, middle name and last name.

The second production shows that the last name is a letter string.

The third production shows that the middle name can be any letter that is an uppercase letter or lowercase letter.

The fourth production shows that the first name consists of a string of one or more letters with the first letter being an uppercase letter.

The fifth production shows that a letter string can be a letter or a letter string followed by a letter.

The sixth production shows that a letter can be in lowercase or uppercase.

The seventh and eighth productions define the non-terminal lowercase letter and uppercase letters.

## Step 4: For example, James k roggs can be produced using the following steps,

Using first production, it replaces < person > with

< first name >< middle name >< last name >

Using fourth production, it gets

< uppercase letter > letter string < middle name >< last name >

Using Eighth production, it gets

J < letter string >< middle name >< last name >

Fifth, sixth and seventh production gives us

James < middle name >< last name>

From third, sixth and seventh production,

James k < last name>

From 2nd, 5th, 6th & 7th production, it gets

James k roggs.

Hence, the production rules in Backus–Naur form for the name of a person.