Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/simonjwright/asis2xml

Converts Ada sources’ ASIS representation to XML, so as to make it easier to develop reporting and transformational tools using (for example) XSLT.
https://github.com/simonjwright/asis2xml

Last synced: 2 months ago
JSON representation

Converts Ada sources’ ASIS representation to XML, so as to make it easier to develop reporting and transformational tools using (for example) XSLT.

Lists

README

        

# ASIS2XML #

ASIS is the
[Ada Semantic Interface Specification](http://www.acm.org/sigada/WG/asiswg/).

This program converts a unit's ASIS representation into XML, so as to make it easier to develop reporting and transformational tools using (for example) XSLT.

Not every ASIS feature is supported, and in particular

* What you get corresponds to a straightforward navigation through the tree, there's no cross-linking.
* There's no attempt to relate the structure to the source text.
* Comments aren't preserved.

There is no XML Schema as yet. The output's structure is quite close to that of ASIS, at least in overall terms; for example, an `A_Defining_Name` element in ASIS is represented as a `` element in XML. This is hardly surprising since the default strategy, faced with an ASIS Element, is to translate it to an XML element with the indicated substitution!

In turn, ASIS's structure is largely that of the Ada RM.

## Example ##

The source unit `demo.adb`,
```ada
procedure Demo (X : in out Integer) is
begin
X := X + 1;
end Demo;
```
results, after using _tidy_, in
```





Demo

X
Integer


X


X

"+"

1






```
This project was originally hosted on SourceForge as part of [ASIS for GNAT](https://sourceforge.net/projects/gnat-asis/), and releases up to 20130413 can be found there.

Later, it moved to [ASIS2XML](https://sourceforge.net/projects/asis2xml/), also on SourceForge, and releases up to 20190426 can be found there.

## Copyright ##

This work is derived from the Node\_Trav component of Display\_Source, which used to be distributed as a part of the ASIS implementation for GNAT and is Copyright (c) 1995-1999, Free Software Foundation, Inc.

The original work in the program is Copyright (c) Simon Wright ``.

## Licensing ##

The work is distributed under the terms of the [GPL, version 2](http://www.gnu.org/copyleft/gpl.html).

## Prerequisites ##

* GNAT: GPL 2012 or later, or GCC 4.8 or later

* The corresponding GNAT ASIS

* [XML/Ada](https://github.com/AdaCore/xmlada) 1.0 or later

## Use ##

`asis2xml` will accept a tree file (`.adt`), or a directory which is a GNAT object directory containing a set of `.adt` files. The GNAT ASIS implementation doesn't understand Project files, so if you have any sort of complex path setup the way to go is to generate the tree files using the Project:
```sh
$ gprbuild -Pbuild -c -u -f -gnatct example.ads
```
creates `example.adt` in your project (`build.gpr`)'s `Object_Dir` -- in the case of `asis2xml`'s `asis2xml.gpr`, this is `./.build`.
```sh
$ asis2xml .build/example.adt >example.xml
```
The output is in "packed" XML; to get a more legible view, you can
use [HTML Tidy](http://www.html-tidy.org):
```sh
$ asis2xml .build/example.adt | tidy -xml -i -utf8 >example.tidy.xml
```
or variations.

## Differences from GNAT ASIS structure ##

If you want to perform analysis on the generated XML, the best way (absent a schema) is to write sample code and see what _asis2xml_ makes of it. That said,

### Attributes ###

Extensive use is made of attributes (for example, `mode="inout"` above).

### Visible/private parts ###

For the kinds of element that have visible/private parts (normal and generic packages, tasks and protected types) the visible and private parts are enclosed in `` and `` elements respectively.

### Pragmas ###

Pragmas are represented more naturally:
```xml

Storage_Size

2048

```

### Compound identifiers ###

Compound identifiers are hard to deal with: `with
Ada.Characters.Handling;` becomes, in the default ASIS structure,
```xml



Ada
Characters

Handling

```
ASIS2XML modifies this by inserting an `` element:
```xml

Ada.Characters.Handling


Ada
Characters

Handling

```
This is similar to the GNAT ASIS ``, used for
compound program unit names.

Note that both these structures require changes to the way you would normally expect to process the XML:

* `` appears in the places where, if unqualified, you'd expect to find an ``, an ``, or a `.

* `` appears in the places where, if unqualified, you'd expect to find a ``.

In either case, the XML contains further child elements, so you need to extract the text of just this node:
```xsl

```