Lecture 11 Notes

9 233 procedural representation the environment

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: # ' ©  © ¡ §    ¦ ¨¦  ¥ ¦¥ ' ¦   #  ¦ ' ¡   ¦ '  ¨¦ § ¡  ¦¥    ¥  ¡ § ¦¡  ¢   §  ¢ ¡  ©   ¢  ¦ ¨¦  ¥ ¦¥ ' ¢  ¥  ¤ ¥ ©   © ¤ ¥  ¢   ¢  ¦¤ © ¥ ¢  ¤ © ¥ ¥ ¢ © ¤ ¥ ©   ¤ ¢ ¥¢  ¢  ¢   ¥ ¦¥ ¡ ¢ ¤ ¥  ¥¢ ¢  ¥ ¨ ¥  £ §    ¡¡ § ¦¡  ¢ ¨ §   ¢    ¢ ¥¦¥ ¡ ¢ ¤ ¥ ¥¢ ¢ ¥§ ¦ # ' © ¦¥  ¢  £ ¥  ¦ ¨¦   ¥¦¥ ' §¥ ©¦¥  ¢ ¡ ¡ ¥ ¦¥  ¥ ¦¦ ¥ §¥¦ ¦¥  ¤ ¥ ©   ¥ ¦¥  #'©  ¥# © ¦¥ ¦  ¥    ¥ ' ¦  ¦ ¤ © ¥¦¥ ¥ ¥ #  ¦ ¥ ¥  ¥ ¨# § '   ¥ ¥   ¢ # $  ¢  ¥    ¢ apply-env § ¡  ©  ¢ ¢ % ©  # ' ¢ £ $ ¢  ¥   %   ¥    ¢ ©¢ extend-env ¡ ¦§¦¥¦ ¥¦¥     #  ¦ # ' ¢ ¢ £ $ ¢ ¦    ¥    ' # ¢ ¢ ¥ ¦¥ ¦ ¦¥  ¥  # © ¥ '  ¦ ¥    %¢¦ ¥ ¥ ¥ ¦¥    ¦ ¢ ¦ ¦¥ ¦   #   ¥ ' ¢ empty-env ¤¢ ¢ ¥ ¥¡£¦¥  ¡ Can use the same grammar to describe a set of lists. This gives the following implementation: This is a very common pattern of code. We call it the interpreter recipe: The Interpreter Recipe 1. Look at a piece of data. 2. Decide what kind of data it represents. 3. Extract the components of the datum and do the right thing with them. We call this dead-simple data structure representation the abstract syntax tree or AST representation because it represents the syntax of the expression that built the environment. Of course we could use lots of different data structures instead. For example, we could say ¦ ¦¥  ¡ ¥  # © ¥ '¢¦ ¦ ¢ ¤¢ ¢ ¥ ¥¡£¦¥  In this representation, we’d write: ¥ ¦¥ ¥ ¥  ¦ ¦¦ §¥¦ ¦  ¢ £  ' # ¦¥¥¦¥¦ ¥¦¥ ¦¢ ¥ ©  ¥ ¦ #' ¦ ¦ ¤ © ¥¦¥ ¥ ¥ #'©  ¦ ¥  ¥ ¦¥  ¦ '  ¨¦ ¢ # $  ¢  ¥    ¢ ¡ ©¥§ ¢ © ©¥§ ¢ # ¢ £ $ ¢  ¥    ...
View Full Document

This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online