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 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!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Parsing Ada? References: <87pp5es5u4.fsf@adaheads.sparre-andersen.dk> <85mw0hte8w.fsf@stephe-leake.org> <8738282c2a.fsf@adaheads.sparre-andersen.dk> Date: Fri, 05 Jun 2015 04:34:00 -0500 Message-ID: <85mw0ea48n.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) Cancel-Lock: sha1:zc2bll6SbpjqnFXr1hcv6Z8LuIs= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 796ca55716d0ae97f808401604 X-Received-Bytes: 3444 X-Received-Body-CRC: 3896537802 Xref: news.eternal-september.org comp.lang.ada:26192 Date: 2015-06-05T04:34:00-05:00 List-Id: Jacob Sparre Andersen writes: > I want to write a program, which can take a package specification, > and generate a driver program for calling all the procedures declared > in the public part of the package. > > The intent is that which procedure is called should depend only on > the command line arguments passed to the driver program. The > selection should happen by matching names and (apparent) types of > command line arguments with names and types of formal parameters of > the procedures. > > An imagined example: > > package An_Application is > procedure Show_Help (Help : Boolean); > procedure Run_Interactive; > end An_Application; > > If the generated driver is executed with a single command line argument > "--help=true" (or maybe just "--help"?), An_Application.Show_Help should > be called. If the driver is executed without any command line > arguments, An_Application.Run_Interactive should be called. Otherwise > the driver should terminate with an appropriate error message. What if there are more than two procedures? I should thing the driver command line would be: driver "" > As command line arguments technically always are strings, it is possible > to have some impractical situations, but I hope to find a sensible way > to detect this kind of formal parameter "overloading". Hmm. Unclear requirements are always a problem. > What I really need is: > > + To check that no functions are declared in the public part of the > package specification. > > + To check that no procedures with "out" or "access" parameters are > declared in the public part of the package specification. > > + A list of the procedures declared in the public part of the package > specification. Including a list of the formal parameters for each > procedure containing: > > - The name of the formal parameter. > - The functions to call for converting the formal parameter type to > and from type String. > - The default value of the formal parameter (if any). > - The type of the formal parameter (for generating a useful help/error > message). This is clearly a job for ASIS. > Using ASIS sounds like an excellent idea. It would avoid some > unnecessary restrictions on the input data. My only argument against > using ASIS is that I would have to learn it first. Yes, that can take a while. As an extended example, I suggest SAL auto_text_io (which I wrote); it does a similar job (examines a package spec, writes another package spec to do Text_IO for the types in the first). See http://stephe-leake.org/ada/auto_text_io.html -- -- Stephe