Path: csiph.com!goblin3!goblin.stu.neva.ru!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: steve kargl Newsgroups: comp.compilers Subject: Re: Regular expressions in lexing and parsing Fortran Date: Wed, 22 May 2019 04:12:12 -0000 (UTC) Organization: A noiseless patient Spider Lines: 21 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-05-096@comp.compilers> References: <19-05-092@comp.compilers> <19-05-095@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit 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 X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:2327 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