From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.212.3 with SMTP id l3mr828074iog.35.1516679383468; Mon, 22 Jan 2018 19:49:43 -0800 (PST) X-Received: by 10.157.44.232 with SMTP id e37mr431067otd.11.1516679383389; Mon, 22 Jan 2018 19:49:43 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g80no2198724itg.0!news-out.google.com!b73ni7496ita.0!nntp.google.com!g80no2198722itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 22 Jan 2018 19:49:43 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:ac96:8bad:a9f7:3ee6; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:ac96:8bad:a9f7:3ee6 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: stopping a loop iteration without exiting it From: Robert Eachus Injection-Date: Tue, 23 Jan 2018 03:49:43 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:50064 Date: 2018-01-22T19:49:43-08:00 List-Id: I probably shouldn't wake up this topic, and that is not my intent. Just t= o bring up some history. When the original ANSI standarization was going o= n, Pat Prange and I were supporting/maintaining a program called LALR on Mu= ltics. LALR would generate LALR(k)--look ahead left-to-right with k symbol = lookahead--grammars. It would generate a (very compact) set of tables, and= (from source with embedded CFG (context free grammar) productions which de= fined the LALR(k) grammar. We used it for a compiler that started out as G= REEN, and evolved into a subset of Ada. (No tasking, and restrictions on ge= nerics.) Robert Dewar preferred LL(1) grammars for Ada compilers since they allowed = for better syntax error recovery. LALR had a neat recovery method which r= equired some fairly tiny tables (less than a hundred 32 or 36 bit words lon= g). The tables were generated along with the rest of the grammar tables, a= nd were used for several Multics compilers, including the PL/I compiler and= MRDS the Multics relational database. Anyway... If you are going to use a program that needs to generate code containing an= d using finite state machine (FSM)* tables, you need to have gotos. So the= y are necessary in Ada. Neither Robert Dewar or I ever found a use other th= an implementing FSMs and PDAs that required gotos--all the logic constructs= argued above, whether simple or complex, can be turned into FSMs and imple= mented by a FSM tool. Not that I recommend it for the simple cases. For a= lexical scanner? Your choice. For complex flight control software? The t= ime spent by the avionics designers working over those tables will make the= coding effort seem trivial. * Technically, a parser generator tool generates a pushdown automaton PDA).= This is an FSM with a stack, and certain inputs cause pushing the current= state on the stack, or processing the current CFG production then popping = the stack. Pushdown automata can recognize any deterministic language with = a context free grammar, but most tools are restricted to produce smaller an= d faster compilers. (Doesn't cause any grief for language designers. As l= ong as the language is deterministic (not ambiguous) you can choose your to= ol. Early's Algorithm will parse any CFG, but it sometimes takes time O(n^= 3) where n is the length of the input. Most good grammars result in parser= s which run in O(n log2 n) time or some such. LL(1) grammars are also know= n as recursive descent grammars. Most compiler programmers don't think abo= ut what they are writing as a PDA. Oh, and regular expressions (RE), which are often used to describe the lexi= cal symbols can be parsed without a stack--and again specialized tools make= things much faster.