File: ada_trees-pp.adb

package info (click to toggle)
asis 2014-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,064 kB
  • ctags: 37
  • sloc: ada: 146,541; makefile: 364; sh: 50; xml: 48; csh: 10
file content (90 lines) | stat: -rw-r--r-- 3,783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
------------------------------------------------------------------------------
--                                                                          --
--                            GNAT2XML COMPONENTS                           --
--                                                                          --
--                    G N A T 2 X M L . A D A _ T R E E S                   --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--                  Copyright (C) 2012-2014, AdaCore, Inc.                  --
--                                                                          --
-- Gnat2xml is free software; you can redistribute it and/or modify it      --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software Foundation;  either version 2,  or  (at your option)  any later --
-- version. Gnat2xml is distributed  in the hope  that it will be useful,   --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MER-      --
-- CHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General  --
-- Public License for more details. You should have received a copy of the  --
-- GNU General Public License distributed with GNAT; see file COPYING. If   --
-- not, write to the Free Software Foundation, 59 Temple Place Suite 330,   --
-- Boston, MA 02111-1307, USA.                                              --
-- The gnat2xml tool was derived from the Avatox sources.                   --
------------------------------------------------------------------------------

pragma Ada_2012;

with Ada_Trees;                use Ada_Trees;
with Ada_Trees.Self_Rep;
with Ada_Trees.Asis_To_Tree;   use Ada_Trees.Asis_To_Tree;
with Ada_Trees.Buffers;        use Ada_Trees.Buffers;
with ASIS_UL.Formatted_Output; use ASIS_UL.Formatted_Output;

package body Ada_Trees.PP is

   Source_Buf : Buffer;
   --  Buffer containing the text of the original source file

   Write_BOM : Boolean;
   --  True if BOM should be written to the output

   procedure To_Ada
     (CU : Asis.Compilation_Unit;
      Options : Formatting_Options;
      Output_Name : String;
      Form_String : String;
      Do_Diff : Boolean;
      Output_Written : out Boolean);
   --  Helper for Asis_To_Ada

   procedure To_Ada
     (CU      : Asis.Compilation_Unit;
      Options : Formatting_Options;
      Output_Name : String;
      Form_String : String;
      Do_Diff : Boolean;
      Output_Written : out Boolean)
   is
      Tree : constant Ada_Tree_Base := Compilation_Unit_To_Tree (CU);
      --  In case Free_Tree is changed to null-out its parameter, we don't want
      --  to check the predicate of Tree afterward.
   begin
      if Ada_Trees.Debug_Mode then
         Ada_Trees.Self_Rep.Put_Ada_Tree (Tree);
         Put ("\n");
      end if;

      Tree_To_Ada
        (Tree, Source_Buf, Write_BOM, Options, Output_Name,
         Form_String, Do_Diff, Output_Written);
      Free_Tree (Tree);
   end To_Ada;

   procedure Asis_To_Ada
     (CU          : Asis.Compilation_Unit;
      Source_Name : String;
      Options     : Formatting_Options;
      Output_Name : String;
      Form_String : String;
      Do_Diff : Boolean;
      Output_Written : out Boolean)
   is
   begin
      Read_Ada_File (Source_Buf, Source_Name, Write_BOM, Expand_Tabs => True);
      --  Expand tabs unconditionally. This differs from the behavior of the
      --  old gnatpp, which has an option for that (but only for comments).

      To_Ada (CU, Options, Output_Name, Form_String,
              Do_Diff, Output_Written);
   end Asis_To_Ada;

end Ada_Trees.PP;