Draw the syntax diagrams for each of grammar elements

Assignment Help Computer Engineering
Reference no: EM131230508

Assume we start with a simple "sentence" grammar as follows:

<S> ::= <NP><V><NP>
<NP> ::= <A><N>
<V> ::= loves | hates | eats
<A> ::= a | the
<N> ::= dog | cat | rat

Part A:

Show the BNF above with the following additional grammar elements:

• Adjectives: (0 or more Adjectives separated by commas may precede any Noun. A comma may or may not be preceded by a space.)

o furry
o fast
o slow
o delicious

• Adverbs: (0 or 1 Adverb may precede any Verb)

o quickly
o secretly

• Conjunctions: (0 or more may appear in any sentence

o and
o or

• Sentence terminator (The terminator may or may not be preceded by a space.)

o . (a single period)
o ! (a single period)

Part B:

Show/Draw the syntax diagrams for each of the grammar elements above. Hyperlink reference not valid.

Part C:

Show the parse trees (which can be generated in ANTLRWorks) for each of the following sentences:

Examples of SYNTACTICALLY VALID Input Strings:

a dog loves the cat.
the cat eats the slow rat and the slow , furry dog secretly hates the cat and a dog loves the rat !

Examples of SYNTACTICALLY INVALID Input Strings (where do they fail):

a dog barks at the cat.
the fast furry cat eats quickly

NOTE: You can generate the full parse treesfrom ANTLRWorks (as can be done with the attached sample for the base grammar) or simply draw out the cooresponding AST's (Abstract Syntax Trees) "by hand" on paper or with a simple drawing tool. The point of this is to have something that you can then verify against the parse trees generated by your own code (in the next part).

Part D:

Modify the (attached) sample code to accept valid sentences based upon the newly defined grammar above. The parser should also "reject" invalid sentences with a descriptive error message. Note that the program should still accept a filename from the "Command Line" as illustrated in the example. Please no HARD-CODED file paths in the source.

Attachment:- Attachmwnts.rar

Reference no: EM131230508

Questions Cloud

Psychological-social influences on buying decision process : Discuss with your class situational, psychological, and social influences on the buying decision process. Think about times when you purchased a product online. What cultural or personal factors influenced your decision? What do you know about your p..
Medical office tended to hoard certain kinds of supplies : From your experience with hospitals or medical offices and/or from your readings/research: Discuss where you have seen tendencies for misuse or over-use of resources. For example, whether the hospital or medical office tended to hoard certain kinds o..
Develop a single view iphone project using swift : Create a Single View iPhone project using Swift that contains two entry text fields with descriptive labels. These entry fields will allow the user to enter a numerator and denominator value.
Find the rms value of the output voltage : The input to an envelope detector is an ergodic bandpass Gaussian noise process. The RMS value of the input is 2 V and the mean value is 0 V. The envelope detector has a voltage gain of 10.
Draw the syntax diagrams for each of grammar elements : Show/Draw the syntax diagrams for each of the grammar elements above. Hyperlink reference not valid. Show the parse trees (which can be generated in ANTLRWorks) for each of the given sentences.
What makes good advertising : What makes good advertising. By now, you should realize that the promotion "P" (among the 4Ps) is part of the "art of marketing," but that it takes a process referred to as the "science of marketing" to create great advertising campaigns. What target..
What actions we need to implement : IT security personnel need to not only know what actions we need to implement, we need to understand why we need to take them and well as the any related background topics.
Mandatory benefits and voluntary benefits : If you were to oversee the design of a benefits program of a large organization what issues would you consider? mandatory benefits? (paid'time off,miscellous benefits,vacation pay,holiday pay , leaves of absence.) voluntary benefits? how would the be..
How to estimate the beta of a stock : Beta Explain : -  How to estimate the beta of a stock. - Explain why beta serves as a measure of the stock's risk.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What is csma/cd

What do you feel is the future for Token Ring? What are its advantages or disadvantages.

  Write down a 2 page proposal for the backhaul connecting

write a 2 page proposal for the backhaul connecting several campuses for your company in one metropolitan area. all of

  Build appropriate functions for these classes

A CollegeCourse class includes fields representing department, course number, credit hours, and tuition. Its child, LabCourse, includes one more field that holds a lab fee charged in addition to the tuition.

  Dissolve method

It does this by incrementing (by 1) all the three color elements (utilizing the above accessor and mutator methods) as well as alpha component value. Write down the dissolve method.

  Sections of currency conversion development documentation

The Currency Conversion application is a menu-driven program that allows users to select one of five international currency types, input the amount of a foreign currency, and then convert the foreign currency to dollars. The program displays the e..

  What are the advantages of using voip

Conduct an Internet search to locate a case study that shows how VoIP was beneficial to the organization.

  How to use ms access and create a database

How to use MS Access and create a database

  What is the value displayed by system.out.println statement

What is the value displayed by the System.out.println statement?

  What stages of computation does garbage collection

For a list with n Nodes, what is the maximum number of nodes that are "live" (i.e., accessible from a "root set" of variables) during the method inverse(), and when does this atmost occur.

  1 you have been hired by a bank to help them harden their

1. you have been hired by a bank to help them harden their online banking service against phishing attacks. explain

  By using various internet sources find an article or

using various internet sources find an article or website about website security. show your personal content mastery by

  Questionin this assignment you will plan and write a gui

questionin this assignment you will plan and write a gui program to calculate pay for different types of employees.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd