Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2328

Re: Regular expressions in lexing and parsing

Path csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From "Ev. Drikos" <drikosev@gmail.com>
Newsgroups comp.compilers
Subject Re: Regular expressions in lexing and parsing
Date Thu, 23 May 2019 18:42:59 +0300
Organization Aioe.org NNTP Server
Lines 40
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <19-05-097@comp.compilers> (permalink)
References <19-05-092@comp.compilers> <19-05-095@comp.compilers>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
Injection-Info gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="80628"; mail-complaints-to="abuse@iecc.com"
Keywords parse, Fortran, comment
Posted-Date 23 May 2019 11:48:34 EDT
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
X-Notice Filtered by postfilter v. 0.9.2
Content-Language en-US
Xref csiph.com comp.compilers:2328

Show key headers only | View raw


On 21/05/2019 8:14 AM, Hans-Peter Diettrich wrote:
> ...
> OTOH I wonder how a formal (regex?) FORTRAN lexer grammar could look like?
>
> DoDi

IMHO, statement classification with a DFA isn't technically feasible
in fixed form due to the labeled DO statements. In all other cases I
think that a ")=" or "]=" outside a literal character constant implies
an assignment statement, which can be matched by a DFA.

In addition, fixed form requires some filtering for spaces and each
form distinct filtering for continuation patterns. Of course, there are
more details. That explained see ie the file OMP_Fortran_Scanner.txt at:
https://github.com/drikosev/Fortran

Ev. Drikos

-----------------------------------------------------------------------
PS: still, the generated tool fails ie to parse the following code:

$ cat doi.f
        do 10  J =(((((1))))),2
        do 10 (I)=1,2
10        print *, "hello world"
        end



> [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
   Still, we've the hard to parse optional commas in format items.

> DO 10 I = 1.23   (oops)
>
> Modern Fortran no longer ignores spaces which makes lexing a lot easier.
> -John]

Back to comp.compilers | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Regular expressions in lexing and parsing Ed Davis <ed_davis2@yahoo.com.dmarc.email> - 2019-05-17 13:18 +0000
  Regular expressions in lexing and parsing Ben Hanson <jamin.hanson@googlemail.com> - 2019-05-18 13:24 +0100
  Re: Regular expressions in lexing and parsing Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2019-05-21 07:14 +0200
    Re: Regular expressions in lexing and parsing Fortran steve kargl <sgk@troutmask.apl.washington.edu> - 2019-05-22 04:12 +0000
    Re: Regular expressions in lexing and parsing "Ev. Drikos" <drikosev@gmail.com> - 2019-05-23 18:42 +0300

csiph-web