Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2928
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end |
|---|---|
| From | Thomas Koenig <tkoenig@netcologne.de> |
| Newsgroups | comp.compilers |
| Subject | Re: Keywords and Reserved Words in Fortran |
| Date | Thu, 10 Mar 2022 07:07:25 -0000 (UTC) |
| Organization | news.netcologne.de |
| Lines | 38 |
| Sender | news@iecc.com |
| Approved | comp.compilers@iecc.com |
| Message-ID | <22-03-024@comp.compilers> (permalink) |
| References | <22-03-004@comp.compilers> <22-03-009@comp.compilers> <22-03-015@comp.compilers> <22-03-016@comp.compilers> <22-03-017@comp.compilers> <22-03-021@comp.compilers> |
| Injection-Info | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="37264"; mail-complaints-to="abuse@iecc.com" |
| Keywords | Fortran, parse, comment |
| Posted-Date | 11 Mar 2022 14:47:29 EST |
| 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:2928 |
Show key headers only | View raw
Our moderator wrote > [Having written production Fortran compilers, I can assure you that to > do it right is quite ugly. I can confirm that. Looking at how a recent compiler does that, I can slightly rephrase https://gcc.gnu.org/wiki/GFortranHacking : The front end's action can be grouped into four phases: Parsing: This converts source code into a stream of tokens which describe the language. Because Fortran does not have reserved keywords, the gfortran runs a series of matchers against code trying to find one that matches a statement. On failing a match an error message may be queued, and another matcher tried. If all attempts at matching fail, the error queue is dumped to the user. Resolution: This resolves things left over from the parsing phase, such as types of expressions, and compile-time simplification of constants. Many errors are issued in this phase. At the end of this phase, the abstract syntax tree is finished. [...] This works (sort of) but has the drawback that cleaning up after an error is error-prone (hah!) so there are a lot of ice-after-invalid (internal compiler error after invalid code) issues that have emerged over the years. [As I recall, first I did a pass to fold continuation cards and mark quoted and hollerith strings, then a pass to look for an equal sign not inside parens and not followed by an comma, which said it was an assignment statement, and then the parsing was straightforward. Eacn non-assignment statement starts with a keyword and it is easy to tell from the syntax when to look for another keyword. Repeat for the statement that follows a logical IF with a special case for the statement numbers in an arithmetic IF. -John]
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-03 13:57 +0000
Re: How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-05 22:29 +0000
Re: How do you create a grammar for a multi-language language? "Kartik Agaram" <ak@akkartik.com> - 2022-03-05 16:55 -0800
RE: How do you create a grammar for a multi-language language? Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-03-06 15:37 +0200
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 14:36 -0800
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 16:50 -0800
RE: How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-06 23:32 +0000
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-05 21:10 -0800
Re: How do you create a grammar for a multi-language language? "Robin Vowels" <robin51@dodo.com.au> - 2022-03-07 13:39 +1100
Re: How do you create a grammar for a multi-language language? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-03-06 12:23 +0100
Re: How do you create a grammar for a multi-language language? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-03-07 05:08 +0100
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 21:22 -0800
Keywords and Reserved Words Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-03-08 21:46 +0200
Re: Keywords and Reserved Words gah4 <gah4@u.washington.edu> - 2022-03-09 00:31 -0800
Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 10:00 +1100
Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 09:55 +1100
Re: Keywords and Reserved Words in Fortran Thomas Koenig <tkoenig@netcologne.de> - 2022-03-10 07:07 +0000
Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 11:59 +1100
csiph-web