>> [Comp Sci Dept]
>> [R J Botting]
Tue Apr 27 07:03:02 PDT 2004
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:
- 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.
- 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.
||Afterwards no character can be obtained from table.
Note. Do not use to empty the table: it does not collect the
|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.
||This is a debugging tool. It lists each pair stored in the table,
in the order in which they are stored.
- 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.
- BNF::="Backus-Naur Form", for syntax and grammar, developed by Backus and Naur.
- EBNF::="Extended " BNF.
- HTML::= "HyperText Markup Language", used on the WWW.
- HTML_page::syntax= "<HTML>" head body.
- Java::="An " OO " Language from Sun".
- LISP::= "LISt Processing Language".
- LRM::="Language Reference Manual".
- Prolog::="Programming in Logic".
- TBA::="To Be Announced".
- UML::="Unified Modeling Language".
- Universal_Resource_Locator::syntax= protocol ":" location, where
- protocol::= "http" | "ftp" | "mailto" | ... ,
- location::= O( "//" host) O(pathname).
(End of Net)
- WWW::= See http://www.csci.csusb.edu/dick/cs620/,
index to web site for this class.
- 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