Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The text gives a simple grammar for English, that recognizes sentences such as birds fly. and birds swim but fish fly In other words, it

image text in transcribed
image text in transcribed
The text gives a simple grammar for English, that recognizes sentences such as "birds fly". and "birds swim but fish fly" In other words, it allows simple sentences, connected by conjunctions, where the simple sentences are of the form "noun verb". Exercise 6.6 of the text a C++ program that parses this grammar. The author also provides a solution to this exercise on his website, which means that it's no longer suitable for a graded programming project. Here's a sample run of his code: sks for a agw@home :proj4s proj4-orig Enter a sentence of the grammar (terminated by a : Try again: people rules. OK Try again: people rule . not ok fish swim OK Try again: fish swim but birds fly OK Try again: AD Note that a period ends the sentence (no surprise there). However, the period is separated from the preceding word by whitespace; this means that we don't need to do any tokenizing, thereby simplifying the code. Also note that we end input with control-D, which ends a Unix input stream coming from the terminal. So let's make this a bit more realistic, by allowing adjectives and adverbs. One way to do this is to make our simple sentences consist of a noun phrase followed by a verb phrase. Here, a noun phrase consists of )sequence of adjectives, followed by a noun; a verb phrase consists of a (possibly empty) sequence of adverbs, followed by a verb. This allows sentences such as "ill-tempered green fish slowly fly and people rules". Since we're changing the language, we need to change the grammar to reflect theses changes. We'll use the grammar at the top of the next page. Your task is to write a program that parses this grammar I am again providing you with a share directory (-agw/class/programming-c++/share/proj4) that contains some useful goodies,which you should copy to your working directory . proj4-orig.cc: This contains the author's solution code to Exercise 6.6. I have refactored it a bit. proj4-agw: My solution (Linux executable) that you can try out Makefile: Used by the make program (see below)

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

9. I can overcome my guilt by actively fighting against it.

Answered: 1 week ago

Question

Question What are the requirements for a safe harbor 401(k) plan?30

Answered: 1 week ago