Com S 541 -- Programming Languages I Handed out: Mar. 5, 1993 HOMEWORK 11: Syntax and Concurrency Primitives (Syntax & Semantics, Chapter 2; Concepts and Paradigms, Chapter 9) Due: March 19, 1993 (extra credit due March 24) This homework is a "warm-up" for concurrency and a design problem for syntax. Read chapter 9 in Watt's Programming Language Concepts and Paradigms. 1. The parbegin example given on page 171 doesn't have the greatest syntax. The use of semicolons to separate the parallel commands is confusing with semicolons meaning sequential composition of commands. Give a grammar for the macrosyntax of an improved version of parbegin. You should also show how parbegin fits in with the grammar for commands (but don't give all the productions for commands). 2. Give a grammar for the macrosyntax of conditional critical regions (see section 9.6.1). 3. Give a grammar for the macrosyntax of monitors (see section 9.6.2). If you like you may work in groups for the last 2 problems. EXTRA CREDIT 1. Designing syntax is somewhat like programming. Write out a list of analogies that relate what you know about good design of programs to good design of grammars. For example, one rule is that if a sequence of code appears in more than one place, it should be made into a subroutine. The analogous rule for grammars would be that if some sequence of symbols appears in more than one place in the grammar, it should be made into a nonterminal. 2. Take any of the previous homeworks in which you designed language features without using grammars, and redo them with a grammar. Reconsider the meaning (semantics) of your proposal in light of the grammar, trying to explain each production of the grammar individually. Does this help clarify your proposal? 3. Change the grammar for C to eliminate semi-colons. You may have to make other changes to prevent ambiguity. Also consider whether the compiler will be able to give good error messages for syntax errors.