Com S 342 meeting -*- Outline -*- * Tools for symbolic programming (EOPL 1) ** Motivation In your career, you're likely to define some "extension language", such as macros for a spreadsheet, etc. How to describe such a thing? Let's try it. ------------------------------------------ FOR YOU TO DO IN GROUPS Write down on a piece of paper, a description of the C (or C++) "for" statement. Make it clear and unambiguous. ------------------------------------------ I.e., someone who has never used it before should be able to write a program with it, different complier writers would all produce the same behavior from it. After this, have them describe theirs out loud. Then have groups exchange their solutions. ------------------------------------------ FOR YOU TO DO IN GROUPS Take the description from another group. 1. Write down as many things about it as you can find that are unclear or ambiguous. 2. What makes it unclear or ambiguous? 3. What would make it more clear or unambiguous? ------------------------------------------ ** why use programs? In this course we'll use programs to describe the semantics of languages, because it's precise. ------------------------------------------ WHY USE PROGRAMS? Why do we care about being unambiguous when describing languages? How can a program *not* be clear? ------------------------------------------ ... so user's don't have to flounder so we have portable programs it keeps us honest ... side-effects on globals, implicit arguments, prohibit these (mostly) wierd transfers of control don't do that too much detail use abstraction, hence want a language in which can abstract at will hence Scheme ** syntax and semantics The basic way we subdivide the study of languages is... ------------------------------------------ SYNTAX AND SEMANTICS def: the *syntax* of a language says Usually given by a context-free grammar. ::= | | ::= | | | ::= ( {}+ ) def: the *semantics* of a language tells Can be given by describing interpreter. ------------------------------------------ ... what strings are well-formed. ... the meaning of (syntactically legal) strings.