Skip to content

TNO/Rewriters-Ada

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rewriters-Ada

The Rewriters-Ada library enables automatic rewriting of Ada code based on concrete syntax. The Rewriters-Ada library is build on top of the Rejuvenation-Ada library and smoothens the manipulation process by functionality that combines and repeats rewrites and enables post processing of manipulated code, such as simplifications and pretty printing.

The example tool Code Reviewer shows how the Rewriters-Ada library can be used.

Rewriters-Ada is part of the Renaissance-Ada project that develops tooling for analysis and manipulation of Ada code.

Examples

Snippets from diff made with Code Reviewer

   function Release_Only (Mode : Operation_Mode) return Boolean is
-     (case Mode is when Release_Size_Mode | Release_Speed_Mode => True, when others => False);
+     (Mode in Release_Size_Mode | Release_Speed_Mode);
- if Valid then
-    Add (Value, 0, 0, 0);
- else
-    Add ("", 0, 0, 0);
- end if;
+ Add ((if Valid then Value else ""), 0, 0, 0);
- for Acf of Acfs loop
-    if Acf = null then
-       return False;
-    end if;
- end loop;
- return True;
+ return (for all Acf of Acfs => Acf /= null);

Example based on aws code

-   Max_Overhead : Stream_Element_Count range 0 .. 2**15 := 81 with Atomic;
-   for Max_Overhead'Size use 16;
+   Max_Overhead : Stream_Element_Count range 0 .. 2**15 := 81 with
+      Atomic,
+      Size => 16;

Alire