CS471 Programming Language Structure I Fall 1997

Homework 1

  1. Monkey language consists of the terminal symbols a, b, d, · where · represents a space. Its grammar is:
  2. á 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?

    Gibbon: ba · ababadada · bad · dabbada
    Spider: abdabaadab · ada
    Rhesus: dad · ad · abaadad · badadbaad
  3. Augment or otherwise change the grammar to include the imposter, i.e. so that the quoted sentences can be generated from the same grammar.
  4. 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.
  5. Redraw you EBNF grammar in syntax diagram form.

Assignment due: Thursday, September 11th., in class.