Ada Source code modifications using ASIS(Ada Semantics interface specifications)

i am developing a tool for finding sub type range overflow problems in Ada source code.for this purpose i am using ASIS for finding assignment statements in Ada source code and finding type of the variables on the right side of the assignment expression.now i want to replace the variables(not of record type) of the assignment expression with 'first, 'last values of the variable type in the assignment statement so that i will get compilation error if any range overflow happens.below is an example what i am trying to convey.

procedure Example is
   subtype A_Type is integer 1 .. 10;
   subtype B_Type is integer -5 .. 5;
   subtype C_Type is integer 1 .. 12;

   A : A_Type;
   B : B_Type;
   C : C_Type;
begin
   C := A + B;
end Example;

I want modify C := A + B; with C := A_Type'Last + B_Type'Last in the source code. C := A_Type'Last + B_Type'Last assignment statement will get warning at compile time or Constraint error during run time.

Is it possible do above modifications with ASIS?

For your purpose, you shouldn't rewrite the source text you are processing. You should rather write a new program, which only contains exactly the required declarations and assignments.

So the output should be something like:

with Type_Declarations;

procedure Test_Driver is
begin
   declare
      C : Type_Declarations.C_Type;
   begin
      C := Type_Declarations."+" (Type_Declarations.A_Type'First, Type_Declarations.B_Type'First);
      C := Type_Declarations."+" (Type_Declarations.A_Type'First, Type_Declarations.B_Type'Last);
      C := Type_Declarations."+" (Type_Declarations.A_Type'Last, Type_Declarations.B_Type'First);
      C := Type_Declarations."+" (Type_Declarations.A_Type'Last, Type_Declarations.B_Type'Last);
   end;
end Test_Driver;

simonjwright/ASIS: Supports building the Ada Semantic , Supports building the Ada Semantic Interface Specification library and tools for FSF GCC variants. Tracks asis.gpr · Changes required to compile with FSF GCC 8.1.0. It includes all the sources of the ASIS-for-GNAT components. of simple ASIS-based tools or which can be reused in the code of ASIS applications 2. Welcome to Ada Semantic Interface Specification for GNAT This Project is dedicated to providing an up-to-date ASIS interface for the current GNAT. Also various tools based on ASIS are provided; these tools include the very useful gnatelim optimization tool and the adabrowse documentation generator.

ASIS was not designed to make modifications like that. You can, however take a look at libadalang from AdaCore, which supports this (and works on partial sources, so you won't have to precompile your sources)

GNAT ASIS, Welcome to Ada Semantic Interface Specification for GNAT tools have more liberal terms (e.g. GNAT Modified GPL with the generic and linking exception), the fact that the base ASIS source code is GPL means that normal  The Ada Semantic Interface Specification (ASIS) Standard has been published by the International Organization for Standardization (ISO) and is now available. ASIS provides a standard way for tools to extract data that are best collected by an Ada compiler or other source code analyzer.

GNAT includes utilities gnat2xml and xml2gnat; gnat2xml generates a representation of the source based on ASIS, and xml2gnat converts it back to Ada. You could maybe modify the XML output of the first and feed it back to the second.

Not that I’m recommending this; the XML schema isn’t documented, and is complicated.

[PDF] Building Ada Development Tools with ASIS-for-GNAT, The Ada Semantic Interface Specification (ASIS) is an interface structure semantics source code. Text Span. Text Image classification. Element_Kinds. The Ada Semantic Interface Specification (ASIS) is an interface between an Ada environment and any tool requiring information from this environment. An Ada environment includes valuable semantic and syntactic information. ASIS is an open and published callable interface that gives CASE tool and application developers access to this information.

If you want a tool that can apply modifications to Ada source code, you might be interested in our DMS Software Reengineering Toolkit with its Ada front end.

DMS parses source code to ASTs, and makes those ASTs available for modification using DMS's Abstract Syntax Tree procedural interface (direct hacking at the tree nodes) and/or DMS's rewrite rules (source-to-source transformations "if you see this replace it by that" written in [Ada] language surface syntax, that directly manipulates the trees. After your changes are made, DMS can prettyprint the source to regenerate valid Ada source code, even preserving comments and formatting in those places that have not been modified.

ASIS, ASIS, the Ada Semantic Interface Specification, is an international standard (ISO/​IEC ASIS-for-GNAT is AdaCore's implementation of the ASIS standard, for use with the Static Analysis (property verification); Code Instrumentation; Design and to CORBA IDL); Quality Assessment Tools; Source Browsers and Formatters  The following have publically available ASIS Applications with source code . Adadep and Adasubst (written by Jean-Pierre, Adalog) Ada 95 Pretty Printer (written by Armin Descloux and Jorg Kienzle, Swiss Federal Institute of Technology) ASIS 2 XML

Ada Semantic Interface Specification, Please improve this by adding secondary or tertiary sources. (October 2011) (​Learn how and when to remove this template message). Look up ASIS in Wiktionary, the free dictionary. The Ada Semantic Interface Specification (ASIS) is a layered, open architecture providing Help · About Wikipedia · Community portal · Recent changes · Contact page  Examples of tools that benefit from the ASIS interface include: automated code monitors, browsers, call tree tools, code reformators, coding standards compliance tools, correctness verifiers, debuggers, dependency tree analysis tools, design tools, document generators, metrics tools, quality assessment tools, reverse engineering tools, re-engineering tools, style checkers, test tools, timing estimators, and translators.

[PDF] Ada and ASIS, The Ada Semantic Interface Specification. (ASIS) provides the basis for implementing portable tools aimed at analysing static properties of Ada source code. The. Ada Semantic Analysis ASIS is a library that gives applications access to the complete syntactic and semantic structure of an Ada compilation unit. This library is typically used by tools that need to perform some sort of static analysis on an Ada program.

[PDF] Ada semantic interface specification (ASIS), The Ada Semantic Interface Specification (ASIS) is an interface between an Ada all the source code (which could take a long time and require the semantic analysis of interface, insulating users from changes in proprietary representations. Ada Source code modifications using ASIS(Ada Semantics interface specifications) i am developing a tool for finding sub type range overflow problems in Ada source code.for this purpose i am using ASIS for finding assignment statements in Ada source code and finding type of the

Comments
  • Does the XML preserve formatting of text and comments?
  • No: from the doc, "xml2gnat is a back-translator that translates the XML back into Ada source code. This is primarily for the purpose of testing gnat2xml, rather than for users. The Ada generated by xml2gnat has identical semantics to the original Ada code passed to gnat2xml. It is not textually identical, however — for example, no attempt is made to preserve the original indentation."
  • So this might be ok for temporarily-generated code but not for permanent code changes that one would like to have. Our experience is that if you remove comments and formatting from code, the programmers will instantly reject the result if they have to maintain it.
  • Afraid I can’t comment, because I can’t get the tool to run! But, anyway, I’d have to agree with you, I’d reject the result too. It depends really on what has to be maintained.