🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #950

Re: Intermediate format of FP numbers

#950
From: Preston Briggs
Date: Fri, 20 Jul 1990 15:40
35 lines
1884 bytes
In article <josef.648309655@peun11> josef@nixpbe.UUCP (Moellers) writes:
>I'm about to start to write a Modula-2 compiler

Sounds good.

>I want to build a highly modular, multi-stage compiler, much like Per
>Brinch Hansen's Edison compiler published in his book "Programming a
>personal computer".

Check also the book "A concurrent pascal compiler for minicomputers",
by Hartmann (Brinch Hansen's student).  It's published in the Springer
lecture notes in computer science series, #50.


>The first stage, lexical analysis, transforms the character string
>making up the source file into an intermediate file consisting of tokens

>Question: what format should I use for floating point numbers?
>I do not want to loose precision during this phase.
>On the other hand, I would like to use some standard format!
>Would IEEE double precision be enough?

One reasonable way to proceed is to *not* convert the numbers.
Instead, keep the string representation and pass it along from phase
to phase.  This has the advantages of never losing precision,
saving FP arithmetic, making your intermediate code simpler
to debug by humans, and increasing portability.

So, the 1st pass (the lexical analyser) would examine the number and
make sure it has a legal format, but never bother converting it
into an internal form.

--
Preston Briggs				looking for the great leap forward
preston@titan.rice.edu
Technical Details
Message-ID: <10068@brazos.Rice.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!rice!titan.rice.edu!preston
References: <josef.648309655@peun11>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!rice!titan.rice.edu!preston
From: preston@titan.rice.edu (Preston Briggs)
Newsgroups: comp.lang.modula2
Subject: Re: Intermediate format of FP numbers
Keywords: compiler, lexical analyzer, floating point numbers
Message-ID: <10068@brazos.Rice.edu>
Date: 20 Jul 90 15:40:49 GMT
References: <josef.648309655@peun11>
Sender: root@rice.edu
Distribution: comp
Organization: Rice University, Houston
Lines: 35