Re: Regular expressions in lexing and parsing Fortran

steve kargl <sgk@troutmask.apl.washington.edu>
Wed, 22 May 2019 04:12:12 -0000 (UTC)

          From comp.compilers

Related articles
Regular expressions in lexing and parsing ed_davis2@yahoo.com.dmarc.email (Ed Davis) (2019-05-17)
Re: Regular expressions in lexing and parsing DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-05-21)
Re: Regular expressions in lexing and parsing Fortran sgk@troutmask.apl.washington.edu (steve kargl) (2019-05-22)
| List of all articles for this month |

From: steve kargl <sgk@troutmask.apl.washington.edu>
Newsgroups: comp.compilers
Date: Wed, 22 May 2019 04:12:12 -0000 (UTC)
Organization: A noiseless patient Spider
References: 19-05-092 19-05-095
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="74760"; mail-complaints-to="abuse@iecc.com"
Keywords: lex, Fortran
Posted-Date: 22 May 2019 11:15:52 EDT

Hans-Peter Diettrich wrote:


> OTOH I wonder how a formal (regex?) FORTRAN lexer grammar could look like?
>
> [I've written Fortran 77 parsers. It was quite context sensitive, particularly
> deciding whether a statement was an assignment or something else. e.g.
>
> FORMAT(I4) = 42
> DO 10 I = 1.23 (oops)
>
> Modern Fortran no longer ignores spaces which makes lexing a lot easier. -John]


Fortran supports two forms. Fixed source form is what might be called
the legacy form, where spaces are ignored. Spaces are significant for
free source form. See Section 6.3 of the Fortran 2018 standard (ie,
N2146.pdf).


So, yes, a Fortran compiler has two lexer/parsers.


--
steve


Post a followup to this message

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