-------------------------------------------------------------------- -- a3.ads -- This file is the specification file for the types -- and functions used in the environment simulation -- of Assignment 3, CS 152, Spring 2000. -------------------------------------------------------------------- with TEXT_IO; use TEXT_IO; package a3 is -- These are the record types and access types -- used by the test program. Note that the -- implementation of the "binding" type must -- be public in order to allow the test program -- to convert integer literals to this type. -- Also "frame_ptr" must be identified as an -- access type so that the test program can -- verify that NULL is a permissible value -- for that type. type binding is new integer; type environment_ptr is private; type frame is private; type frame_ptr is access frame; -- These are the procedures and functions used -- in the test program -- These two functions substitute for constructors, giving -- a little more control over the initialization, etc. -- The first function creates an empty environment. -- The second creates a frame (with no bindings), given its -- static link. function new_environment return environment_ptr; function new_frame(fr:frame_ptr) return frame_ptr; -- These three functions modify frames or environments -- The first adds a given binding to a given frame -- The second adds (i.e., pushes) a given frame to a given environment. -- The third removes a frame from (the front of) an -- environment. procedure add_binding(f:frame_ptr; bb:binding); procedure add_frame(e:environment_ptr; fr:frame_ptr); procedure delete_frame(e:environment_ptr); -- This function returns the (value of) the binding found -- in environment e, at position j in the frame found -- at i links down the chain of static links from the -- top frame. procedure lookup_and_print(e:environment_ptr; i,j:integer); private -- YOUR CONTRIBUTION GOES HERE. -- You will also have to provide a package body in a -- separate file (e.g., a3.adb) end a3;