Sep 05, 2003 ------------- - Using attribute grammars - example of propagating type information, from book - example of making procedure names match in Ada - Move on to semantics - several types - operational - denotational - axiomatic - natural - Operational semantics - also called intensional semantics - how would you explain the C construct "a ? b : c" to a person from Pascal? - Ans: explain it using lower-level primitives - this is the basic idea - More examples of operational semantics - switch statement in C - while loop in C - for loop in C - can keep decomposing, till we get some "basis" set - Denotational semantics - also called extensional semantics - only thing that matters is functional relationship from i/p to o/p - details don't matter - Basic difference - two different factorial programs can have different operational semantics - way in which they are written matters (e.g., for-loop versus recursion) - but will have same denotational semantics - since they compute the same thing - Axiomatic semantics - not really a semantics in the above sense - but oriented toward proving properties of programs - Examples of axiomatic semantics - rules for proving odd and even numbers N: is_odd when N mod 2 = 1 is_even otherwise - finding oddness or evenness of expressions e1: p1 e2: p2 -------------- e1+e2: p3 - how would you describe p3 using p1 and p2? - Another example - deriving pre-conditions from postconditions - worked out examples from textbook