camfort / fortran-src

Fortran parsing and static analysis infrastructure
https://hackage.haskell.org/package/fortran-src
Other
48 stars 20 forks source link

parse REAL literals to convenient form #193

Closed raehik closed 2 years ago

raehik commented 3 years ago

We decompose REALs to their respective parts (significand & exponent), but keep the numeric parts as strings to allow the user to select how to represent the value. Along with a printer and parser, we also export a "reader" to convert parsed REAL literals to any compatible Fortran type, so for most uses users will only need that function to turn a Fortran REAL literal into a Haskell value. (Previously, everyone had to implement their own parsing.)

raehik commented 3 years ago

This e.g. lets Camfort support the various Fortran-style real literals (instead of trying to read as a Haskell real), and fortran-vars not do any extra parsing work.

raehik commented 3 years ago

@dominic would you be able to give this a quick look over? I'll bring it on Mon otherwise. It's largely adapted from some other code I wrote before but now gets called during parsing (actually, during lexing for free form, parsing for fixed form -- I stuck with the existing patterns)

raehik commented 3 years ago

Oops, I'd already said I wasn't around Monday. I'm preparing other changes around this so it can all merge quick and smooth when we've discussed it.

raehik commented 2 years ago

Discussed, giving it a merge.