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.78.8 with SMTP id c8mr1234037iob.32.1514088455704; Sat, 23 Dec 2017 20:07:35 -0800 (PST) X-Received: by 10.157.19.100 with SMTP id q33mr197632otq.13.1514088455627; Sat, 23 Dec 2017 20:07:35 -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!g80no2036124itg.0!news-out.google.com!s63ni3489itb.0!nntp.google.com!i6no2036307itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 23 Dec 2017 20:07:35 -0800 (PST) In-Reply-To: <2d87298a-4d1f-446a-9d46-d4f03879246b@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:5985:2c17:9409:aa9c References: <2d87298a-4d1f-446a-9d46-d4f03879246b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3eb3c336-fcb5-432d-a79d-cd52021301de@googlegroups.com> Subject: Re: Writing a scanner and parser in Ada From: Robert Eachus Injection-Date: Sun, 24 Dec 2017 04:07:35 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:49620 Date: 2017-12-23T20:07:35-08:00 List-Id: On Saturday, December 23, 2017 at 8:15:05 PM UTC-5, Yves Cloutier wrote: > Hi there,=20 >=20 > I'm new to Ada, but not to programming. >=20 > I'd like to know if there are any examples of how to write a scanner and = parser in Ada. Welcome! You don't really need to worry about learning Ada, and even Ada 83 texts wi= ll get you started. Going beyond Ada 95 really requires reading this newsg= roup or the equivalent. What has been going on is providing support for sp= ecialized areas of programming. (Some of the extensions like the container= library are more general.) For example, if you don't deal with complex nu= mbers, you can pretty much skip Annex G. (Well, if you need accuracy bound= s for trig functions they are there as well.) There are plenty of books out there on software engineering, or on various = subfields like proofs of correctness. If you want to do that in Ada, you p= robably want to download some SPARK documentation. But SPARK is essentiall= y an Ada subset plus a prover, and all that is integrated into GNAT. As for parsing examples, you can get the GNAT source code, and I think it s= till uses a recursive descent parser. I may be able to dig up a simple cal= culator program I wrote mostly to check the (fixed-point) arithmetic and nu= meric I/O on our compiler. Again recursive descent about two pages. If you want to get into other types of parsing, I was one of two people who= supported and extended the LALR(k) tool on Multics. Parsing seems to be o= ne of those areas which was solved once, and all the experts are now retire= d. Not as dumb as it seems. Writing a recursive descent (LL(1)) compiler = is fairly easy even without supporting tools. If you do have tools? Look-= ahead LR (LALR) allows for better recovery from syntax errors, but there is= no particular reason today to design a language which cannot be parsed by = an LL(1) parser.