libadalang2xml

v1.0.0

Generates XML for Ada source, using libadalang.

Libadalang2XML is a tool to extract syntatic aspects of Ada source code into XML.

The Ada source is initially read using Libadalang. The resulting tree is then traversed, and its structure output in an XML form.

The document type definition isn't explicit; it's simply derived from the tree elements created by Libadalang. Note that Libadalang includes much more semantic information than the surface structure generated by this tool, but nevertheless there's enough there to --- for example --- create a scriptable body for a package spec.

macOS

For reasons explained here, the tool can't be built on macOS using Alire's gnat_native compiler; you need to have a full compiler suite on your PATH, like that obtainable for GCC 12.2.0 (x86 64) or GCC 12.2.0 (aarch64). Having set that up, alr build will built the tool.

Example

As an example of the output, this code

ada
package Demo is
   procedure Square (X : in out Integer);
end Demo;

generates

xml
<CompilationUnit>
  <AdaNodeList/>
  <LibraryItem>
    <PrivateAbsent/>
    <PackageDecl>
      <DefiningName>
        <Id>Demo</Id>
      </DefiningName>
      <PublicPart>
        <AdaNodeList>
          <SubpDecl>
            <OverridingUnspecified/>
            <SubpSpec>
              <SubpKindProcedure>procedure</SubpKindProcedure>
              <DefiningName>
                <Id>Square</Id>
              </DefiningName>
              <Params>
                <ParamSpecList>
                  <ParamSpec>
                    <DefiningNameList>
                      <DefiningName>
                        <Id>X</Id>
                      </DefiningName>
                    </DefiningNameList>
                    <AliasedAbsent/>
                    <ModeInOut>in out</ModeInOut>
                    <SubtypeIndication>
                      <NotNullAbsent/>
                      <Id>Integer</Id>
                    </SubtypeIndication>
                  </ParamSpec>
                </ParamSpecList>
              </Params>
            </SubpSpec>
          </SubpDecl>
        </AdaNodeList>
      </PublicPart>
      <EndName>
        <Id>Demo</Id>
      </EndName>
    </PackageDecl>
  </LibraryItem>
  <PragmaNodeList/>
</CompilationUnit>

Install

Globally install this crate:

alr install libadalang2xml

Add to your project:

alr with libadalang2xml

Crate Information

Authors

  1. Simon Wright

Maintainers

Maintainers (GitHub pseudo)

Release Date

2 years ago

First Release

5/2/2023

Statistics

Dependencies: 0

Dependents: 0

Versions: 2