Select this to skip to main content [CSUSB] >> [CNS] >> [Comp Sci Dept] >> [R J Botting] >> [CSci620] >> lab09 [Source]
[Index] [Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Search] [Grading]
Tue Apr 27 07:03:02 PDT 2004

Contents


    CS620 Laboratory 9 A Simple Symbol Table

    Goal: Study how a data type was defined in a language like Pascal or C.

    Process: Work in pairs:

    1. Download this program [ lab09.cpp ] which is based on part of the interpreter on pages 93-98 and partly implements a very simple symbol table using a C/Pascal style. It includes unit tests. One function is a stub.
    2. The program defines the following operations for a simple symbol table. A symbol table is a collection of pairs. Each pair has (in this case) a character and an integer.
      HeaderSpecification
      int initialize(); Afterwards no character can be obtained from table. Note. Do not use to empty the table: it does not collect the garbage.
      int obtain(char ch); Finds and returns the integer associated with the first character to match. If no character matches it prints and error message and retruns the value of constant ERROR.
      int add(char ch, int i); Places the pair (ch, i) into the table. If ch is already in the table both pairs are stored afterwards.
      int remove(char ch); Removes the first pair (if any) that matches the character ch. If there is no such pair, it does nothing.
      int print(); This is a debugging tool. It lists each pair stored in the table, in the order in which they are stored.
    3. Implement the remove(char ch) function.

    Note. Do NOT use any classes. Do NOT create header files. Preserve this program. It is likely to reappear in a future lab.

    Deliverable: Show me your remove procedure before the end of the lab. The score will be based on completeness, correctness, following the Pascal paradigm, and simplicity. Each pair-programming team gets 100% of the allocated points.

    Glossary

  1. BNF::="Backus-Naur Form", for syntax and grammar, developed by Backus and Naur.
  2. EBNF::="Extended " BNF.
  3. HTML::= "HyperText Markup Language", used on the WWW.
  4. HTML_page::syntax= "<HTML>" head body.
  5. Java::="An " OO " Language from Sun".
  6. LISP::= "LISt Processing Language".
  7. LRM::="Language Reference Manual".
  8. OO::="Object-Oriented".
  9. Prolog::="Programming in Logic".
  10. TBA::="To Be Announced".
  11. UML::="Unified Modeling Language".
  12. URL::=Universal_Resource_Locator,
  13. Universal_Resource_Locator::syntax= protocol ":" location, where
    Net
    1. protocol::= "http" | "ftp" | "mailto" | ... ,
    2. location::= O( "//" host) O(pathname).

    (End of Net)
  14. WWW::= See http://www.csci.csusb.edu/dick/cs620/, index to web site for this class.
  15. XBNF::="eXtreme" BNF, developed by the teacher from EBNF, designed to ASCII input of syntax, semantics, and other formal specifications.


Formulae and Definitions in Alphabetical Order