For declara9ons what informa9on needs to be captured

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: that propagation, a subsequent folding phase could then eliminate the division. Winter 2013 UW CSE 401 (Michael Ringenburg) 10 Some Kinds of Seman9c Informa9on CSE341: Programming CSE341: Programming Languages Languages Lecture 1 Lecture 1 From Generated Used to process Course Course Mechanics Mechanics Symbol names Variable Bindings Declarations Expressions, ML Variable Bindings ML Information (variables, methods) statements D Type information Dan Declarations, an Grossman Operations Grossman expressions Fall 2011 Fall 2011 Memory layout Assigned by compiler Target code information generation Values Winter 2013 Constants Expressions UW CSE 401 (Michael Ringenburg) 11 What do we need for seman9c checking? CSE341: Programming CSE341: Programming Languages Languages •  For each language construct we want to know: Lecture hould be checked –  What seman9c rules s1 Lecture 1 Course •  Specified by language defini9on (type compa9bility, Course Mechanics Mechanics required Variable Bindings ini9aliza9on, etc.) ML Variable Bindings ML –  For an expression, what is its type (used to check whether the expression is Dan Grossmancurrent context) Dan Grossman legal in the Fall 2011 •  Compu9ng the all 2011 an expression is some9mes referred F type of to as “inferring the type” (although this an overloaded term). –  For declara9ons, what informa9on needs to be captured to use elsewhere Winter 2013 UW CSE 401 (Michael Ringenburg) 12 A Sampling of Seman9c Checks and Computa9ons CSE341: Programming CSE341: Programming Languages Languages •  Appearance of a name in an expression: id Lecture 1 Lecture 1 –  Check: Symbol has been declared and is in scope Course Course Mechanics Mechanics –  Compute: Inferred Bindings declared type of type is the Bindings ML Variable ML Variable symbol •  Constant: v Dan Grossman Fall 2011 Dan Grossman Fall 2011 –  Compute: Inferred type and value are explicit –  Example: 42.0 has type double and value 42.0 Winter 2013 UW CSE 401 (Michael Ringenburg) 13 A Sampling of Seman9c Checks and Computa9ons CSE341: Programming CSE341: Programming Languages Languages •  Binary operator: exp1 op exp2 Lecture 1 Course Mechanics •  Either iden9cal, or well- defined conversion to...
View Full Document

Ask a homework question - tutors are online