From: Yannick Duchêne (Hibou57) on
Le Thu, 10 Jun 2010 12:14:18 +0200, Brian Drummond
<brian_drummond(a)btconnect.com> a écrit:

> On Thu, 10 Jun 2010 03:33:11 -0400, Stephen Leake
> <stephen_leake(a)stephe-leake.org> wrote:
>
>> Marek Janukowicz <marek(a)janukowicz.net> writes:
>
>>> I understand things I ask about in the subject are most likely not
>>> possible,
>>> but is there any other way to achieve what I want?
>>
>> Renames was suggested. Writing all of those can get tedious, and
>> probably defeats the purpose of the generic.
>>
>> Using an ASIS application to generate code would be another way.
>
> Any pointers (uh, references) where to learn ASIS for this purpose?
> I've always understood ASIS as being used to analyze Ada, not generate
> it...
>
> If there is a tutorial somewhere using ASIS to generate co... <cough>
> source
> program text, I'd be interested to see it.
>
> - Brian
Not a tutorial, but the only one meaningful source about ASIS I know is
http://www.sigada.org/wg/asiswg/
It contains documentations and some examples, some rather complete.
For examples, look at
http://www.sigada.org/wg/asiswg/ASISWG_Results.html
You may want to search for the two links named “Publically available ASIS
Applications” and “How to do things in ASIS” in the latter page. Good
point to start, beside the specification files of your compiler's ASIS
library.

--
There is even better than a pragma Assert: a SPARK --# check.
--# check C and WhoKnowWhat and YouKnowWho;
--# assert Ada;
-- i.e. forget about previous premises which leads to conclusion
-- and start with new conclusion as premise.
From: sjw on
On Jun 10, 11:14 am, Brian Drummond <brian_drumm...(a)btconnect.com>
wrote:
> On Thu, 10 Jun 2010 03:33:11 -0400, Stephen Leake
>
> <stephen_le...(a)stephe-leake.org> wrote:
> >Marek Janukowicz <ma...(a)janukowicz.net> writes:
> >> I understand things I ask about in the subject are most likely not possible,
> >> but is there any other way to achieve what I want?
>
> >Renames was suggested. Writing all of those can get tedious, and
> >probably defeats the purpose of the generic.
>
> >Using an ASIS application to generate code would be another way.
>
> Any pointers (uh, references) where to learn ASIS for this purpose?
> I've always understood ASIS as being used to analyze Ada, not generate it....
>
> If there is a tutorial somewhere using ASIS to generate co... <cough> source
> program text, I'd be interested to see it.

http://www.mckae.com/avatox.html -- "Avatox (Ada, Via Asis, To Xml) is
an application that traverses one or more Ada compilation units and
outputs the ASIS representation of the unit(s) as an XML document. The
resulting XML document(s) can then have an XSL stylesheet applied in
turn." And you can use an XSL stylesheet to generate code.

Another application in the same space is my ASIS2XML --
http://gnat-asis.sourceforge.net/pmwiki.php/Main/ASIS2XML .
From: Stephen Leake on
Brian Drummond <brian_drummond(a)btconnect.com> writes:

> On Thu, 10 Jun 2010 03:33:11 -0400, Stephen Leake
> <stephen_leake(a)stephe-leake.org> wrote:
>
>>Marek Janukowicz <marek(a)janukowicz.net> writes:
>
>>> I understand things I ask about in the subject are most likely not possible,
>>> but is there any other way to achieve what I want?
>>
>>Renames was suggested. Writing all of those can get tedious, and
>>probably defeats the purpose of the generic.
>>
>>Using an ASIS application to generate code would be another way.
>
> Any pointers (uh, references) where to learn ASIS for this purpose?
> I've always understood ASIS as being used to analyze Ada, not generate it...
>
> If there is a tutorial somewhere using ASIS to generate co... <cough> source
> program text, I'd be interested to see it.

I'm not aware of any tutorials.

gnatstub (included in all GNAT distributions) is a small ASIS
application that can serve as a good starting point.

auto_text_io (which I wrote)
(http://www.stephe-leake.org/ada/auto_text_io.html) is a larger example.

--
-- Stephe
From: J-P. Rosen on
Stephen Leake a �crit :
>> If there is a tutorial somewhere using ASIS to generate co... <cough> source
>> program text, I'd be interested to see it.
>
> I'm not aware of any tutorials.
>
> gnatstub (included in all GNAT distributions) is a small ASIS
> application that can serve as a good starting point.
>
> auto_text_io (which I wrote)
> (http://www.stephe-leake.org/ada/auto_text_io.html) is a larger example.

adasubst (available from Adalog's site) can also be seen as such a
program, since it produces a modified version of its input source.

--
---------------------------------------------------------
J-P. Rosen (rosen(a)adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
From: Brian Drummond on
On Fri, 11 Jun 2010 05:08:55 -0400, Stephen Leake
<stephen_leake(a)stephe-leake.org> wrote:

>Brian Drummond <brian_drummond(a)btconnect.com> writes:
>
>> On Thu, 10 Jun 2010 03:33:11 -0400, Stephen Leake
>> <stephen_leake(a)stephe-leake.org> wrote:

>>>Using an ASIS application to generate code would be another way.
>>
>> Any pointers (uh, references) where to learn ASIS for this purpose?

>I'm not aware of any tutorials.
>
>gnatstub (included in all GNAT distributions) is a small ASIS
>application that can serve as a good starting point.
>
>auto_text_io (which I wrote)
>(http://www.stephe-leake.org/ada/auto_text_io.html) is a larger example.

Thanks to all for these suggestions, especially yourself, and JP Rosen for
adasubst. Avatox looks interesting but I'm not learning XML just for this!

So auto_text_io looks like the best starting point for me.

I have no definite purpose in mind, but some interest in the possibility of
transforming simple Ada mathematical code into behavioral VHDL.

Mostly because I am appalled at the current trends toward using C to design
hardware!

- Brian