CS471 Programming Language Structure I
Spring 2002

Assignment 1

  1. Monkey language consists of the terminal symbols a, b, d, ·, where · represents a space. Its grammar is:

ástopñ ::= b | d
áplosiveñ ::= ástopñ a
ásyllableñ ::= áplosiveñ | áplosiveñ ástopñ | a áplosiveñ | a ástopñ
áwordñ ::= ásyllableñ | ásyllableñ áwordñ ásyllableñ
ásentenceñ ::= áwordñ | ásentenceñ · áwordñ

Which of the following speakers is a monkey in disguise? i.e. which of the following utterances cannot be generated by the grammar? Draw parse trees in order to show your answer.

Gibbon: ba · ababadada · bad · dabbada
Spider: abdabaadab · ada
Rhesus: dad · ad · abaadad · badadbaad

  1. Augment or otherwise change the grammar to include the imposter, i.e. so that all the sentences can be generated from the same grammar. There are many correct solutions, but you should aim for a solution that changes as little as possible in the grammar without admitting other sentences that are too far from the ones given.
  2. Rewrite the original monkey grammar (not your changed version) in EBNF form, by replacing all possible recursions by repetitions, and using grouping and optional forms as appropriate.
  3. Redraw you EBNF grammar in syntax diagram form.

 

Grading

This assignment is worth 50 points. Questions 1 and 2 are worth 15 points each, and Questions 3 and 4 are worth 10 points each.

Submission

This assignment must be submitted through WebCT, so it must be prepared electronically. Read the drop box information page before submitting it. Pay close attention to the availability “window” of the assignment. When the window closes, you will not be able to submit an answer.