Related articles |
---|
Regular expressions in lexing and parsing ed_davis2@yahoo.com.dmarc.email (Ed Davis) (2019-05-17) |
Regular expressions in lexing and parsing jamin.hanson@googlemail.com (Ben Hanson) (2019-05-18) |
Re: Regular expressions in lexing and parsing DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-05-21) |
Re: Regular expressions in lexing and parsing drikosev@gmail.com (Ev. Drikos) (2019-05-23) |
Re: Regular expressions in lexing and parsing christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-06-17) |
Re: Regular expressions in lexing and parsing quinn.jackson@ieee.org (Quinn Jackson) (2019-06-18) |
Re: Regular expressions in lexing and parsing quinn.jackson@ieee.org (Quinn Jackson) (2019-06-18) |
Re: Regular expressions in lexing and parsing 847-115-0292@kylheku.com (Kaz Kylheku) (2019-06-18) |
Re: Regular expressions in lexing and parsing christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-06-18) |
From: | "Ev. Drikos" <drikosev@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Thu, 23 May 2019 18:42:59 +0300 |
Organization: | Aioe.org NNTP Server |
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="80628"; mail-complaints-to="abuse@iecc.com" |
Keywords: | parse, Fortran, comment |
Posted-Date: | 23 May 2019 11:48:34 EDT |
X-Notice: | Filtered by postfilter v. 0.9.2 |
Content-Language: | en-US |
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]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.