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


Groups > comp.compilers > #2328

Re: Regular expressions in lexing and parsing

From "Ev. Drikos" <drikosev@gmail.com>
Newsgroups comp.compilers
Subject Re: Regular expressions in lexing and parsing
Date 2019-05-23 18:42 +0300
Organization Aioe.org NNTP Server
Message-ID <19-05-097@comp.compilers> (permalink)
References <19-05-092@comp.compilers> <19-05-095@comp.compilers>

Show all headers | 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