Related articles |
---|
Symbol Table problems in Pascal languages family pjmlp@students.si.fct.unl.pt (1996-10-08) |
Re: Symbol Table problems in Pascal languages family buehlman@iwf.bepr.ethz.ch (1996-10-10) |
Re: Symbol Table problems in Pascal languages family luginb_c@simultan.ch (1996-10-15) |
Re: Symbol Table problems in Pascal languages family dlmoore@ix.netcom.com (David L Moore) (1996-10-15) |
Re: Symbol Table problems in Pascal languages family josuka@inf.deusto.es (1996-10-16) |
From: | luginb_c@simultan.ch (Christian Luginbuehl) |
Newsgroups: | comp.compilers |
Date: | 15 Oct 1996 09:39:10 -0400 |
Organization: | Simultan AG, Altishofen |
References: | 96-10-022 96-10-028 |
Keywords: | Pascal |
Paulo Jose Matos Lopes Pinto <pjmlp@students.si.fct.unl.pt> wrote:
> I'm trying to do a compiler for a language that derives from Pascal
>(Oberon).
> The problem is with the symbol table for types, because the types have to
>be type-name compatible and not structured compatible, that makes a bit hard
>to manipulate the builtin names,like CHAR, REAL, among others.
buehlman@iwf.bepr.ethz.ch wrote...
>If you really look at the Pascal lined languages you realize that
>builtins are reserved and may not be used as (declarable)
In Oberon, the names of the builtin types like CHAR are not reserved
keywords the way BEGIN, IF, and so on are. They are _predefined
identifiers_; that means it looks as if they were in the symbol table
as soon as the compiler starts.
An easy way to implement this is to do it exactly like that: Insert
the entries for these predefined types into the symbol table before
you start compiling a module. Open a new scope (as you would do at the
start of a procedure) afterwards, since it is perfectly legal to
redeclare a predefined identifier as in
TYPE INTEGER = LONGINT;
or even
VAR INTEGER : LONGINT;
[ Of course, this does not mean you _should_ do that :-) ]
You can do similar things for the built in procedures (like LEN, SHORT, ORD).
Good luck, Christian.
--
Christian Luginbuehl luginb_c@simultan.ch
Simultan AG, Altishofen, Switzerland.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.