[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing identification on SableCC ASTs

Hi Fidel,

> Well, if that is the case, then this is how you solve
> your problem

Well, that will really not solve the problem. It simply moves the
problem around (and also make the problem harder).

To make your solution work, it would be necessary to define a
SymbolTable class that "remembers" everything. I.e. when the so called
SemanticAnalyser class goes through the AST and opens scopes, enters
identifiers and closes scopes - everything has to be stored in the

Normally, the symbol table "forgets" about identifiers declared in a
scope when the scope is closed.

Making a SymbolTable that "remembers" is trivial when using a program
with a flat block structure. It's more complicated with a programming
language with nested block structure.

Also you would need for the CodeGenerator to know where to open and
close scopes for identifiers. I.e. this destroys the separation of

It's much simpler to use the HashMap technique already employed in
AnalysisAdapter, and simply pass that around. I.e. the solution I
mention last in my email. I'm using that, and it works -- but it doesn't
seem completely "elegant" to me.

Jens Kristian Søgaard, jks@cs.auc.dk