Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site loral.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcc6!loral!ian From: ian@loral.UUCP Newsgroups: net.lang.mod2 Subject: Re: one pass compiler - (nf) Message-ID: <478@loral.UUCP> Date: Sat, 8-Sep-84 23:50:49 EDT Article-I.D.: loral.478 Posted: Sat Sep 8 23:50:49 1984 Date-Received: Sun, 16-Sep-84 06:58:26 EDT References: <1748@inmet.UUCP> Organization: Loral Instruments, San Diego Lines: 63 Mark Friedman submitted the following note in reference to my claim that a two pass compiler on a micro could not store the symbol table in memory. > One has the same problem of fitting the symbol table into memory near > the end of a one pass compilation as keeping it in memory for the second > pass of a two pass compiler. I think that compilation speed is really the > issue here, though it does interact with the limited space problem. Micro > based compilers generally have to make so many concessions to compilation > speed (mostly in order to get the largest symbol table possible) that to > add another pass would make the compiler unreasonably slow. Mr. Friedman is, of course, correct in saying that compiler speed a major consideration in the design of a micro based compiler. The statement that "One has the same problem fitting the symbol table into memory near the end of a one pass compilations as keeping it in memory for the second pass of a two pass compiler." is not entirely correct. In a one pass compiler for languages like Pascal or Modula, symbol table space can be recycled when the compiler finishes compiling a scope. For example, when the compiler finishes compiling a procedure, all information about the procedure's local variables can be disposed of. Using this scheme the symbol table will only contain information about procedures, modules and global variables when the last statement is compiled. A two pass compiler capable of resolving Modula's forward references will be forced to save more information in its first pass. Consider what must be saved to resolve the references in the procedure shown below. PROCEDURE OuterScope; PROCEDURE InnerScope; BEGIN OuterScopeVar := -1; END InnerScope; VAR OuterScopeVar : INTEGER; BEGIN (* OuterScope *) InnerScope; END OuterScope; In a well written Modula program most of the identifiers will be enclosed in the scope of a module or procedure. This will minimize the amount of global information which must be kept on hand in a one pass compiler. Of course there will also be many procedures, but some of these will also be nested. Ian Kaplan Loral Data Flow Group Loral Instrumentation 8401 Aero Dr. San Diego, CA 92123 (619) 560-5888 x4812 ucbvax!sdcsvax!sdcc6!loral!ian