comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Implementing an Ada compiler and libraries.
Date: Thu, 10 May 2007 21:30:33 +0200
Date: 2007-05-10T21:30:25+02:00	[thread overview]
Message-ID: <tiqve4q3uxg7$.1ustqpy4n0js.dlg@40tude.net> (raw)
In-Reply-To: 1178820387.916393.238070@y80g2000hsf.googlegroups.com

On 10 May 2007 11:06:28 -0700, Lucretia wrote:

> The parser matches a with statement, it then has to check to make sure
> this package has not already been with'd. If it hasn't, check to see
> if the package exists in binary form. If not, the compiler needs to
> start another compilation - this library unit just with'd then with
> the symbol table and go back to the original compilation.

Yes, this is roughly how I did it.
 
> Now this would make either a recursive compiler, or a compiler with
> multiple tasks (if developed in Ada ;D).

I did it recursively. There was a stack of contexts, so I put a stub on
that stack(s) and called the compiler again, quite simple.

> Also, allowing multiple compilation units in the same file can be
> problematic, e.g.
> 
> package one is ...;
> package two is ...;
> procedure three is ...;
> package body one is ...;
> package body two is ...;
> 
> What if the body of one or two require the subprogram three? Is this a
> form of forward declaration? Would interleaving specs and body's cause
> problems? Probably.

The context of either body cannot include the body of three, only the
declaration of. (I don't consider inlining here)

> I now think that I understand why GNAT chooses the model it has done,
> although I don't know whether the compiler handles dependency checking
> or if gnatmake does - it looks like gnatmake does, but underneath it
> could be the compiler.
> 
> Another area I've thought about is the symbol table:
> 
> 1) For a package spec, there is a public (is this the limited view?)
> and a private part, this can be compiled to symbol table.

These are two different contexts. The private one refers to the public one.
If you kept them apart, you could reduce the number of recompilations.

> 2) For the package body, there is another private part which cannot be
> accessed outside of the spec unless exported in the public part of the
> spec, this can be compiled into the spec's symbol table or a separate
> one.

This is a third context which is needed for separate bodies.

> 3) All other compilation units compile down to 1 symbol table.

Wait a minute (:-)), there also exist task and protected types, and, well
generics. Though the pattern is same.

Also, you will probably need special contexts for matching prefix notation
(be it damned (:-)), keyed associations, qualified names, aggregates. I
mean if you wanted to take the advantage of the approach. In my case I
postponed all this stuff until the semantic analysis, but the contexts were
needed anyway.

> For a final build, only the public area of the package spec needs to
> be in the symbol table, in a debug build, the whole lot needs to be
> there.

Well, contexts could serve as source of symbolic information, but the
debugger needs a lot more stuff. I am not sure if the format should be
preserved as-is. Clearly it could be a great advantage, but I cannot say
how realistic is that.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-05-10 19:30 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-09 14:37 Implementing an Ada compiler and libraries Lucretia
2007-05-09 16:51 ` Dmitry A. Kazakov
2007-05-09 17:21   ` Lucretia
2007-05-10  7:59     ` Dmitry A. Kazakov
2007-05-10  8:51       ` Duncan Sands
2007-05-10 17:39       ` Lucretia
2007-05-10 18:06         ` Lucretia
2007-05-10 19:30           ` Dmitry A. Kazakov [this message]
2007-05-11  7:14           ` Gautier
2007-05-11 17:39             ` Lucretia
2007-05-11 17:43               ` Lucretia
2007-05-11 18:20                 ` Robert A Duff
2007-05-11 18:49                   ` Lucretia
2007-05-11 20:34                     ` Georg Bauhaus
2007-05-11 22:37                       ` Lucretia
2007-05-11 22:06                     ` Robert A Duff
2007-05-11 22:41                       ` Lucretia
2007-05-16 19:40                 ` Randy Brukardt
2007-05-09 20:48 ` Robert A Duff
2007-05-10  3:38   ` Lucretia
2007-05-16 19:58   ` Randy Brukardt
2007-05-09 21:15 ` Gautier
2007-05-10  3:39   ` Lucretia
2007-05-10 15:34   ` Stefan Bellon
2007-05-10 16:25     ` Jean-Pierre Rosen
2007-05-10 17:07       ` Ludovic Brenta
2007-05-10 17:14         ` Stefan Bellon
2007-05-10 16:37     ` Ludovic Brenta
2007-05-10 16:43       ` Stefan Bellon
2007-05-10 16:49         ` Ludovic Brenta
2007-05-10 17:02           ` Stefan Bellon
2007-05-10 19:57             ` Jacob Sparre Andersen
2007-05-10 20:31             ` Simon Wright
2007-05-10 17:37       ` Pascal Obry
2007-05-11 10:09         ` Ludovic Brenta
2007-05-11 16:33           ` Pascal Obry
2007-05-10 17:36     ` Pascal Obry
2007-05-10 17:42     ` Lucretia
2007-05-10 17:34 ` Pascal Obry
2007-05-10 17:48   ` Lucretia
2007-05-10 20:01   ` Duncan Sands
2007-05-10 21:00     ` Pascal Obry
2007-05-10 21:00     ` Pascal Obry
2007-05-11 11:04       ` Duncan Sands
2007-05-13 12:03         ` Ludovic Brenta
2007-05-11  8:39   ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox