Re: Has anyone hand-written a scanner/parser module?

"Charles E. Bortle, Jr." <charlesb.cca@mpowercom.net>
Tue, 18 Nov 2008 09:24:36 -0800

          From comp.compilers

Related articles
[10 earlier articles]
Re: Has anyone hand-written a scanner/parser module? bill@qswtools.com (Bill Cox) (2008-11-16)
Re: Has anyone hand-written a scanner/parser module? marcov@stack.nl (Marco van de Voort) (2008-11-17)
Re: Has anyone hand-written a scanner/parser module? dmaze@mit.edu (David Z Maze) (2008-11-17)
Re: Has anyone hand-written a scanner/parser module? gene.ressler@gmail.com (Gene) (2008-11-17)
Re: Has anyone hand-written a scanner/parser module? arnold@skeeve.com (2008-11-18)
Re: Has anyone hand-written a scanner/parser module? sh006d3592@blueyonder.co.uk (Stephen Horne) (2008-11-18)
Re: Has anyone hand-written a scanner/parser module? charlesb.cca@mpowercom.net (Charles E. Bortle, Jr.) (2008-11-18)
Re: Has anyone hand-written a scanner/parser module? r3jjs@yahoo.com (Jeremy J Starcher) (2008-11-19)
Re: Has anyone hand-written a scanner/parser module? armelasselin@hotmail.com (Armel) (2008-11-19)
Re: Has anyone hand-written a scanner/parser module? bobduff@shell01.TheWorld.com (Robert A Duff) (2008-11-23)
Re: Has anyone hand-written a scanner/parser module? bobduff@shell01.TheWorld.com (Robert A Duff) (2008-11-23)
Re: Has anyone hand-written a scanner/parser module? charlesb.cca@mpowercom.net (Charles E. Bortle, Jr.) (2008-11-24)
Re: Has anyone hand-written a scanner/parser module? charlesb.cca@mpowercom.net (Charles E. Bortle, Jr.) (2008-11-24)
[3 later articles]
| List of all articles for this month |
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.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.