[CSUSB]
>> [CNS]
>> [Comp Sci Dept]
>> [R J Botting]
>> [CSci620]
>>
07
[Source]
. . . . . . . . . ( end of section Notes) <<Contents | Index>>
Questions
In some languages functions are supposed to have no side-effects. This is difficult to enforce, and makes it harder to write some things. For example the code in this chapter relies on boolean functions that read data, and also push and pop data onto a stack.
In this class,
do not use the C/C++/Java terminology of void function vs nonvoid function
unless you say that you are using the C/C++/Java terminology.
On page 88 figure 4.3 side bar has a pointer to the second part of the box!
When we draw data structures it does not matter which edge of the box
an arrow is attached! Even if it points at the end, it is actually
the address of the first byte in the box.
If the arrow ends inside a box then the pointer may be referring to part of the data. If it touches the edge, it refers to the whole.
On page 91 Where is the second item pushed on the stack in t1.
Function t1 calls function f (in an if) before it gets to
popping 2 items off the stack. Function f pushes more data
onto the stack as a side effect.
On page 98 at the bottom is P" correct?
Yes. Also near the top of page 78.
What is the difference between a compiler and an interpreter?
A compiler produces a complete program and stops. The program
is stored in a file -- an executable. This file can be executed.
It can be run many times without recompiling.
An interpreter executes a program directly. Each statement in turn is lexed, parsed, and executed in turn. No new translation of the program is stored. In a single run of the program some statements are parsed many times!
In a hybrid compiler/interpreter the source code is translated into an intermediate code (byte code for example) and a separate interpreter (a virtual machine) executes the code.
Compilers tend to be slow in translating code, but produce fast running programs. Interpreters tend to execute slower than compiled code.
Most languages have had both interpreters and compilers. Most languages are typically either interpreted or compiled. For example C was compiled, but there was a CTERP program shared by readers of a magazine. LISP is traditionally executed by an interpreter, and yet modern interpreters do a form of compilation when presented with function definitions.
The difference between compiling and interpreting is practical and not theoretical. So there is no connection between them and types of machines (TM, PDA, FSA,...). However -- Turing constructed a single universal TM that interprets a programs stored on the TM's tape.
What is a symbol table?
A symbol table stores pairs: a symbol and a value. It has
operations to add and remove pairs, and the ability to find
the value associated with a given symbol.
How does a symbol table work?
There are many ways to make a symbol table work.
Hash tables, tree structures, linear lists, can all be
used.
If you need one in a C++ program use the STL map and pair templates. In Java use a Dictionary.
You will meet a simple symbol table future labs.
In Pascal what does forward mean?
The symbol forward is use in Pascal to stand in for the
body of a subprogram that is completely defined later
in the program. The C++ equivalent is a function header,
and in C a prototype:
| Pascal | C/C++ |
|---|---|
| function e:boolean; forward; | bool e(); |
| procedure push(i:int); forward; | void push(int); |
. . . . . . . . . ( end of section Questions) <<Contents | Index>>
Exercises
. . . . . . . . . ( end of section Exercises) <<Contents | Index>>
Laboratory
Lexical and syntactic analysis:
[ lab07.html ]
Next
Chapter 5 pp99-116: imperative, Von Neumann, FORTRAN,...
Prepare some notes and at least one question you need to ask on it.
[ 08.html ]
. . . . . . . . . ( end of section CSCI620 Session 7) <<Contents | Index>>
Glossary