Article View: comp.arch
Article #155Re: Comment delimiters
From: Anton Ertl
Date: Fri, 16 Oct 2026 17:56
Date: Fri, 16 Oct 2026 17:56
71 lines
4211 bytes
4211 bytes
EricP <ThatWouldBeTelling@thevillage.com> writes: >On 2026-Oct-15 02:17, Anton Ertl wrote: >> My guess as to how this stuff was parsed: >> >> Deal with the first columns as appropriate. For the rest: Remove any >> white space. Use a backtracking parser that tries to match a rule at >> a time; for the DO statement, simply compare the start with "DO". If >> a rule does not match, look at the next rule. >> >> The result is messy, especially when you want to extend the language. > >A backtracking parser sounds like way overkill. A backtracking parser is relatively easy and the memory needs for parsing just a single statement are small, too. For an example of how short a parser generator for a backtracking parser framework can be, look at the second example in <https://bernd-paysan.de/screenful.html>. >I am under the impression that many Fortran 77 compilers used >hand written lexer and a recursive decent parser. >The parser passes some local context to the lexer to let it know, >for example, which set of keywords are active at that point. >Anyway, that is how I would do it. The reason why I think of a backtracking parser is that it seems the easiest way to be able to handle both DO101I=1.100 and DO101I=1,100 (examples given on <https://en.wikipedia.org/wiki/Fortran#Fixed_layout_and_punched_cards>) >There is a method called "Sale's Algorithm" which was published >in CACM in the 1960's which describes how to lex up to Fortran 77. Interesting, but did the FORTRAN team come up with that? According to <https://fortran-lang.discourse.group/t/has-anyone-played-with-sales-fortran-classification-algorithm-lately/7802> the algorithm was published in 1971. >After that it is pretty standard AST processing. >The only semantic difference I can think of immediately is >Fortran's parenthesis rule that forces an order of evaluation >and would interact with optimizations like common subexpressions. Searching around, I found little about "order of evaluation" when it comes to parenthesis in FORTRAN, although I remember hearing or reading about the significance of parentheses in FORTRAN several times. But does it have any relevance beyond determining that a+(b+c) is evalutated as t=b+c r=a+t rather than t=a+b r=t+c If not, that rule just disallows reassociation, but reassociation is not something I have seen in common subexpression elimination (or, more generally, partial redundancy elimination) algorithms anyway. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Oct16.195605@mips.complang.tuwien.ac.at>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<1791742457-5857@newsgrouper.org> <11aig3c$3hdcn$1@dont-email.me> <11aiqc0$3kr94$3@dont-email.me> <179190779286.25645.14465927900754526737@media.vsta.org> <179190779286.25645.14465927900754526737@media.vsta.org> <vandys@vsta.org> <jwvjynl2cg0.fsf-monnier+comp.arch@gnu.org> <808vclt9i2mso89n1itvnvos5j88g1mopl@4ax.com> <6acfc2b2.1547984@news.eternal-september.org> <HZQzS.6$TYg.3@fx21.iad> <2026Oct15.081750@mips.complang.tuwien.ac.at> <9ysAS.182538$QPx3.16043@fx17.iad>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: Comment delimiters Date: Fri, 16 Oct 2026 17:56:05 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 71 Message-ID: <2026Oct16.195605@mips.complang.tuwien.ac.at> References: <1791742457-5857@newsgrouper.org> <11aig3c$3hdcn$1@dont-email.me> <11aiqc0$3kr94$3@dont-email.me> <179190779286.25645.14465927900754526737@media.vsta.org> <179190779286.25645.14465927900754526737@media.vsta.org> <vandys@vsta.org> <jwvjynl2cg0.fsf-monnier+comp.arch@gnu.org> <808vclt9i2mso89n1itvnvos5j88g1mopl@4ax.com> <6acfc2b2.1547984@news.eternal-september.org> <HZQzS.6$TYg.3@fx21.iad> <2026Oct15.081750@mips.complang.tuwien.ac.at> <9ysAS.182538$QPx3.16043@fx17.iad> Injection-Date: Fri, 16 Oct 2026 18:26:39 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3735087"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GXDSNLgPbWD8+QAag51RU"; posting-host="eb1d16796a2f3c3c419013704a6bb9be" Cancel-Lock: sha1:9r6p2OmY/YeWwVna3s2WB17anX4= sha256:HhJSHZHhOa0qcYMfL0h9RNjyvVR8jFBxYu7UsHMV2fA= sha1:s48Hm6WNApp+K10kxzblT2wSMLc= sha256:u/LKowm/lzVRDrjmW82XhF2vcE3IXSpPXJJqhnFOeLE= X-newsreader: xrn 10.11