{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

3 fund-10

3 fund-10 - CS 242 2010 Syntax Fundamentals JohnMitchell...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Fundamentals CS 242 2010 John Mitchell Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language implementation Syntax Semantics Transform program syntax into machine instructions that can be executed to cause the correct sequence of actions to occur Interpreter vs Compiler Source Program Input Output Interpreter Source Program Compiler Input Output Target Program Typical Compiler Source Program Lexical Analyzer Syntax Analyzer Semantic Analyzer See summary in course text, compiler books Intermediate Code Generator Code Optimizer Code Generator Target Program Brief look at syntax Grammar e ::= n | e+e | e e n ::= d | nd d ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Expressions in language e e e e e+e n n+n nd d+d dd d+d 27 4+3 Grammar defines a language Expressions in language derived by sequence of productions Many of you are familiar with this to some degree Theoretical Foundations Many foundational systems Computability Theory Program Logics Lambda Calculus Denotationa Semantic Denotational Semantics Operational Semantics Type Theory Consider some of these methods Computability theory (halting problem) Lambda calculus (syntax, operational semantics) Operational semantics (not in book)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Lambda Calculus Formal system with three parts Notation for function expressions Proof system for equations Calculation rules called reduction Additional topics in lambda calculus (not covered) Mathematical semantics (=model theory) Type systems We will look at syntax, equations and reduction There is more detail in the book than we will cover in class History Original intention Formal theory of substitution (for FOL, etc.) More successful for computable functions Substitution ‐‐ > symbolic computation Church/Turing thesis Influenced design of Lisp, ML, other languages See Boost Lambda Library for C++ function objects Important part of CS history and foundations Why study this now? Basic syntactic notions Free and bound variables Functions Declarations Calculation rule Symbolic evaluation useful for discussing programs Used in optimization (in lining), macro expansion Correct macro processing requires variable renaming Illustrates some ideas about scope of binding Lisp originally departed from standard lambda calculus, returned to the fold through Scheme, Common Lisp Haskell, JavaScript reflect traditional lambda calculus Expressions and Functions Expressions x + y x + 2*y + z Functions x (x+y) z x + 2*y + z x. (x+y) z. (x +2y + z) Application ( x. (x+y)) 3 = 3 + y ( z. (x + 2*y + z)) 5 = x + 2*y + 5
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 9

3 fund-10 - CS 242 2010 Syntax Fundamentals JohnMitchell...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online