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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Indefinite type while writing a recursive descent parser Date: Thu, 02 Nov 2017 21:29:28 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: AXbaCSC1gsQOwLBV12d/+A.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:48710 Date: 2017-11-02T21:29:28+02:00 List-Id: Victor Porton wrote: > Victor Porton wrote: > >> I am writing a recursive descent parser. (It parses RDF relations rather >> than a text file, but that's not very important for my question, except >> for the fact that I cannot use an existing text parser package.) >> >> While parsing I need to extract data (numbers, booleans, arrays, etc.) >> >> My first idea was: >> >> generic >> type Data_Type(<>) is private; >> package Base_Predicate is >> type Base_Predicate_Parser is tagged >> record >> Predicate: URI_Type; >> Data: access Data_Type; >> end record; >> not overriding >> procedure Parse (Parser: Base_Predicate_Parser; Node: Node_Type) is >> null; >> end Base_Predicate; >> >> I wanted my node parsers to assign to Data.all if Data/=null. >> >> But then I realized that this won't work for an indefinite Data_Type. >> >> So I have an Ada (2012) specific issue on possible ways to assign data >> while parsing. Please give advice. >> >> I could use Indefinite_Holders everywhere but this would be a step into >> the direction of being like a dynamic language instead of strong typing >> system which Ada offers. I don't like to make a step in this direction. > > It seems for me the right idea to: > > - restrict Data_Type only to definite types as a record member where we > are to store the data is anyway not supporting indefinite types > > - whenever we need an indefinite type, replace it with an indefinite > holder defined specifically for this type However, this seems a suboptimal solution for lists of indefinite objects: this way of work would lead to a definite vector of indefinite holders rather than to indefinite vector of indefinite objects. -- Victor Porton - http://portonvictor.org