CS 541 Lecture -*- Outline -*- * design using grammars back and forth between examples and grammar grammar gives generality and elegance examples used to judge aesthetics ** FORTRAN IV identifiers a sequence of at most 6 alphanumeric characters, starting with an alphabetic character Try writing a regular expression or regular grammar for that ** if statements stmt ::= var := exp | if exp then stmt else exp | if exp then stmt this is ambiguous if b then if b2 then x := 3 else x := 4 How to eliminate the ambiguity? require blocks always ending for else (fi) eliminate the lack of else (add a skip stmt) ** syntax of ML break the class into groups, have each group scan a chapter (2-7) for syntax of ML, write down page numbers write down a grammar for what you find ** ADTs for Pascal design syntax (as in CLU) for an abstract data type mechanism in Pascal start with a Stack example. ** add exception handling to C want to be able to raise exceptions have handler attached to any statement exceptions become part of the type of a procedure