Re: Visual Basic as an Implementation Language (Dwight VandenBerghe)
29 Sep 1998 15:38:56 -0400

          From comp.compilers

Related articles
Visual Basic as an Implementation Language (Steven Salter) (1998-09-26)
Re: Visual Basic as an Implementation Language (Quinn Tyler Jackson) (1998-09-29)
Re: Visual Basic as an Implementation Language (Michael J. Brennan) (1998-09-29)
Re: Visual Basic as an Implementation Language (1998-09-29)
| List of all articles for this month |

From: (Dwight VandenBerghe)
Newsgroups: comp.compilers
Date: 29 Sep 1998 15:38:56 -0400
Organization:, The World's Usenet: Discussions Start Here
References: 98-09-145
Keywords: Basic

On 26 Sep 1998 01:46:07 -0400, Steven Salter <>
>- A pre-processor, or something, because an expression may contain a
>reference to another expression, such as:
> A = B + C
> B = C * D
> E = A * 2
>which must be expanded to E = ((C*D) + C) * 2 for analysis
>(optimization?). All of the expressions are stored in the database.

Just make a symbol table that has one entry for each defined variable,
and that contains the expression for that variable in source form.
Then have one of the types of entries in your expression tree (or
however you store it) be a reference to a symbol table entry.

>- A way of making sure that there are no circular dependencies, such as
> A = B + C
> B = 40 - A

This is easy to do at runtime - just mark all the variables empty,
then start executing the expressions one at a time. When you begin
the computation of a variable, mark it (set a flag) saying that it is
currently being computed. Then, if you ever try to compute the value
of a variable that is currently being computed, you have a loop.

It's a little trickier at compile time, but not that bad. The idea is
assign a sequential number to each leaf of the tree that you find, in
a recursive walk of the tree, then go back and check to see if there
are any level inconsistencies. "Foundations of Computer Science"
(Aho+Ullman) has a great description of the process.

>- A way of getting a set of things that need to be looked up, rather
>than the list that is currently used.

Here a bitfield would be a good choice - one bit or'ed in for each
thing to look up that you discover. Then, pick off the leading bit
and look it up, and do that until you're out of bits. (Or, you could
use a character array in the same way, one element reserved for each
database element.)


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.