From: | "Charles E. Bortle, Jr." <charlesb.cca@mpowercom.net> |
Newsgroups: | comp.compilers |
Date: | Tue, 18 Nov 2008 09:24:36 -0800 |
Organization: | Compilers Central |
References: | 08-11-061 |
Keywords: | parse, Fortran |
Posted-Date: | 18 Nov 2008 19:13:29 EST |
> [I hand-wrote a scanner for Fortran 77 about 30 years ago. It worked but
> it was pretty gross because Fortran's lexical structure is so
> strange. -John]
Note: I am not a "compiler professional" nor expert. (At present, I'm
a Sound & Computer Tech at my church, and the Web Servant (read
Webmaster) of the church web site, and our IT and Network
Administrator...as well as a few other hats ;-)
Yes, back in the 80's. Similarly to John, I hand-wrote a scanner for
Fortran IV. It was written in Pascal on a Z80-based S100 computer
with 64k (yes, k) running the CP/M operating system on 8" floppies :-0
The core of the scanner was a Pascal Case statement (al la the bastard
algol modle in Gries). The Pascal compiler I was using did not
support files of Char but only block reads. I had to write the char
by char read routines, reading a sector sized block at a time from the
floppy.
The scanner was written as a seperate Pass...its output was a token
stream file and a symbol table in memory. The hand-written recersive
descent parser read the token stream file and produced an RPN
intermediate file, which was passed to the Code generator, which
produced assembly code.
I had eventually ported the scanner to an OSBORNE I (yes, the Adaquit
(sp?) machine with the tiny screen ;-), and then, eventually to an IBM
PC and Turbo Pascal (eventually the OOP version 7). The code
generator produced assembly code for 80x80 under PC/MS DOS and used
the 8087 math coprocessor instructions (this was in the days before
the math coprocessors were standard features...not all machines had
them)
My compiler even handled Complex types. I had to hand-write the RTP
in assembly code. I never completely finished the compiler, but it
did produce non-trivial working programs. I never got time to
impliment Subroutines, though, but did have Formatted output.
All in all, I think the hand-coded scanner worked well.
Since then, I wrote an LL(1) parse table generator and the parser.
The parser now calles the scanner for each token, instead of making
the scanner a seperate pass. I started to use it to write a Pascal
compiler, but have not had time to finish it. I also started using it
to write a Scanner generator, with the intent of bootstrapping its own
scanner into a table driven one, but alas, time fails me.
Nowadays, I would probably write the scanner, parser, etc as seperate
*.dll's under Windows, so that different source code files could be
compiled at the same time with only one copy of the compiler routines
resident.
As to implementation language, I would still pick a Pascal-like
language. (I know...That was then, This is Now ;-) (I exclude ADA,
which just gutted and emasculated Pascal) and personally I don't care
for C (or even C++).
Any way, that's my story, and I'm sticking to it ;-)
Happy Holidays,
Charles E. Bortle, Jr.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.