lecture13 - CS 143 Lecture 13 1 Operational Semantics of...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 143 Lecture 13 1 Operational Semantics of Cool Lecture 13 CS 143 Lecture 13 2 Lecture Outline COOL operational semantics Motivation Notation The rules CS 143 Lecture 13 3 Motivation We must specify for every Cool expression what happens when it is evaluated This is the meaning of an expression The definition of a programming language: The tokens lexical analysis The grammar syntactic analysis The typing rules semantic analysis The evaluation rules code generation and optimization CS 143 Lecture 13 4 Evaluation Rules So Far We have specified evaluation rules indirectly The compilation of Cool to a stack machine The evaluation rules of the stack machine This is a complete description Why isnt it good enough? CS 143 Lecture 13 5 Assembly Language Description of Semantics Assembly-language descriptions of language implementation have irrelevant detail Whether to use a stack machine or not Which way the stack grows How integers are represented The particular instruction set of the architecture We need a complete description But not an overly restrictive specification CS 143 Lecture 13 6 Programming Language Semantics A multitude of ways to specify semantics All equally powerful Some more suitable to various tasks than others Operational semantics Describes program evaluation via execution rules on an abstract machine Most useful for specifying implementations This is what we use for Cool CS 143 Lecture 13 7 Other Kinds of Semantics Denotational semantics Programs meaning is a mathematical function Elegant, but introduces complications Need to define a suitable space of functions Axiomatic semantics Program behavior described via logical formulae If execution begins in state satisfying X, then it ends in state satisfying Y X, Y formulas Foundation of many program verification systems CS 143 Lecture 13 8 Introduction to Operational Semantics Once again we introduce a formal notation Logical rules of inference, as in type checking CS 143 Lecture 13 9 Inference Rules Recall the typing judgment Context  e : C (in the given context , expression e has type C ) We try something similar for evaluation Context  e : v (in the given context , expression e evaluates to value v ) CS 143 Lecture 13 10 Example Operational Semantics Rule Example: The result of evaluating an expression can depend on the result of evaluating its subexpressions The rules specify everything that is needed to evaluate an...
View Full Document

This note was uploaded on 05/05/2010 for the course COMPILER AC 1 taught by Professor Sergio during the Spring '10 term at Institute of Management Technology.

Page1 / 39

lecture13 - CS 143 Lecture 13 1 Operational Semantics of...

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

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