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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4cb1f8d1c17d39a8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.0.170 with SMTP id 10mr5666270pbf.2.1320280654327; Wed, 02 Nov 2011 17:37:34 -0700 (PDT) Path: p6ni64514pbn.0!nntp.google.com!news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 03 Nov 2011 01:37:20 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada 'hello world' for Android; success! References: <8239efcjuw.fsf@stephe-leake.org> <98ca5430-aa52-4e39-b789-70d0dd6adb46@d33g2000prb.googlegroups.com> <824nyrq5p6.fsf@stephe-leake.org> <4eac1ca1$0$7625$9b4e6d93@newsspool1.arcor-online.net> <82mxciogt0.fsf@stephe-leake.org> <4eafbc25$0$6575$9b4e6d93@newsspool3.arcor-online.net> <82mxcemscg.fsf@stephe-leake.org> In-Reply-To: <82mxcemscg.fsf@stephe-leake.org> Message-ID: <4eb1e241$0$7627$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 03 Nov 2011 01:37:21 CET NNTP-Posting-Host: 82855777.newsspool1.arcor-online.net X-Trace: DXC=9fb4cCQOXD@2jYf>V4L0gLic==]BZ:afN4Fo<]lROoRA<`=YMgDjhgB37^C65XD;UEPCY\c7>ejVH:ZlYL>;kLCDenjSgMFhADH X-Complaints-To: usenet-abuse@arcor.de Xref: news2.google.com comp.lang.ada:14281 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-11-03T01:37:21+01:00 List-Id: On 02.11.11 16:55, Stephen Leake wrote: >>> http://www.stephe-leake.org/ada/access_vs_object.html). >> >> (When the problem domain is grammars, my goal of an application is to allow >> the user to build a structure of subprograms that represent a grammar, >> so the application can then call the subprogram matching the start symbol >> (or other symbols) to parse input strings. > > I'd love to see your solution to this problem. It's easy to talk about > general principles and design goals; only complete actual solutions > flesh out all the problems and details. http://home.arcor.de/bauhaus/Ada/recdecnoptr.ada This example features: - a hierarchy of "tokens", though barely: Terminal and Non_Terminal, with some info in each, derived from abstract Token. - a handler derived from an abstract handler type, overriding a primitive operation. The operation, On_Token, receives an object of type Token'Class when some "grammatical event" happens. procedure On_Token (Manager : in out Handler; Found : in Tokens.Token'Class) is abstract; - a recursive descent parser (exhaustive). The parser is structured just as the grammar, which in this demo is S -> a S | a A similar program using the same parsing technique was built around 28 productions. It also had the necessary level of abstraction that is absent from the above demo, such as functions that would query the state of a token (Image etc.). No token is ever stored, though the handler types are free to do whatever they want with the tokens, including storing them. There are no allocators for tokens. The program uses access, but for different purposes. In a different program, I had used objects separate from tokens for keeping more information about the tokens. The tokens and the info objects were then associated in a has-a relationship, using pointers to 'Class. But I could have passed these additional objects without using pointers, too, just for the record. In summary, then, I do not see that it is necessity to add pointers to a parser interface. Storing polymorphic objects of polymorphic components seems a different subject of a very general nature.