Draw parse trees for the given expressions using the following grammar. Note that [number] is a terminal that has a numeric value.

[E] -] [E] + [T]
| [E] – [T]
| [T]

[T] -] [T] * [F]
| [T] / [F]
| [F]

[F] -] [number] | ( [E] )
  • 2 + 3 * 5
  • 2 + (3 * 5)

What does the following grammar produce? Describe the list. How many elements will such a list have? Does anything appear after the elements or in-between the elements?

Note that [empty], [number], and [identifier] are terminals defined as follows: [empty] is an empty string, [number] is a numeric value, and [identifier] is like an identifier name in C/Java.

[constants] -] [const-decl] | [empty]
[const-decl] -] const [name] = [constant];
| [const-decl] [name] = [constant];
[constant] -] [number]
[name] -] [identifier]

Convert the following EBNF to BNF.

S -> A { bA }
A -> a [b]A

Prove that the following grammar is ambiguous.

[S] -] [A]
[A] -] [A] + [A] | [id]
[id] -] a | b | c
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.