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


Groups > comp.compilers > #2326

Re: Regular expressions in lexing and parsing

From Hans-Peter Diettrich <DrDiettrich1@netscape.net>
Newsgroups comp.compilers
Subject Re: Regular expressions in lexing and parsing
Date 2019-05-21 07:14 +0200
Organization Compilers Central
Message-ID <19-05-095@comp.compilers> (permalink)
References <19-05-092@comp.compilers>

Show all headers | View raw


Am 17.05.2019 um 15:18 schrieb Ed Davis:

> So don't write lexers and parsers with regular expressions as the starting
> point. Your code will be faster, cleaner, and much easier to understand and to
> maintain.

I think that regular expressions are primarily usable in *formal* token
grammars. In contrast to parsers I'm missing *complete* formal grammars
for the tokens, including whitespace, comments, strings and other
special language elements, and how these fit together.

Here regular expressions are easier to understand and maintain than DFA
or NFA code for all those token types. The equivalent lexer
*implementation* finally is up to the compiler writer.

OTOH I wonder how a formal (regex?) FORTRAN lexer grammar could look like?

DoDi
[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]

Back to comp.compilers | Previous | Next — Previous in thread | Next 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