Question
The following grammar with goal symbol describes a micro-English language of simple sentences with a very limited vocabulary: -> . -> i | A |
The following grammar with goal symbol
| A
| The
| a
| the
| rat
| mat
| likes
| am
| is
| see
| sees
Some example sentences generated by this grammar are:
The cat sees a rat .
i like the mat .
The cat likes me .
Without changing the BNF above, convert the grammar to an attribute grammar that will disallow sentences like
The cat like the rat . or
i likes the mat .
or
i is the cat .
To do this, define attributes for the grammar symbols and attach attribute rules and predicates to the BNF productions to restrict the language to the set of English language valid sentences. Do not change the BNF.
Type your answer below.
List of attributes with brief descriptions of their meanings:
BNF productions and corresponding semantic rules and predicates:
Write in C++ a recursive descent parser that uses your attribute grammar to check the correctness of sentences of the grammar.
Step 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