asis_2019.0.0_3ca32fa2/tools/gnat2xml/test/vatox-axf_points-terminal_nomenclature-ada_terms.adb

 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
------------------------------------------------------------------------------
--                                                                          --
--                           AVATOX COMPONENTS                              --
--                                                                          --
--                        VATOX (Via Asis To Xml)                           --
--                                                                          --
--                                                                          --
--                Copyright (c) 2006, McKae Technologies.                   --
--                                                                          --
-- Avatox 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. Avatox 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.                                              --
--                                                                          --
-- Avatox is now maintained by McKae Technologies (http://www.mckae.com)    --                                               --
------------------------------------------------------------------------------

with Ada.Containers.Indefinite_Ordered_Maps;
with Asis.Declarations;
with Asis.Elements;
with Mckae.Text.Lexicals;

package body Vatox.Axf_Points.Terminal_Nomenclature.Ada_Terms is

   package Operators_Mapping is new Ada.Containers.Indefinite_Ordered_Maps
     (String, Operator_Names);
   Operators_Map : Operators_Mapping.Map;

   ------------------------------------------------------------------------------

   function Lookup_Operator
     (S : String
     ) return String is

      use Mckae.Text;
      use type Operators_Mapping.Cursor;

      Operator_Cursor : Operators_Mapping.Cursor;
   begin
      Operator_Cursor := Operators_Mapping.Find (Operators_Map, S);
      if Operator_Cursor /= Operators_Mapping.No_Element then
         return Lexicals.Transform
           (Operator_Names'Image (Operators_Mapping.Element (Operator_Cursor)),
            Lexicals.Xml_Attrs, Remove_Underscores => True);
      else
         raise Unknown_Operator;
      end if;
   end Lookup_Operator;

   ------------------------------------------------------------------------------

   function Based_Representation
     (N : String
     ) return String is
   begin
      return N;
   end Based_Representation;

   -----------------------------------------------------------------------------

begin
   Operators_Mapping.Insert (Operators_Map, "+", Axf_Plus);
   Operators_Mapping.Insert (Operators_Map, "-",  Axf_Minus);
   Operators_Mapping.Insert (Operators_Map, "*", Axf_Multiply);
   Operators_Mapping.Insert (Operators_Map, "/", Axf_Divide);
   Operators_Mapping.Insert (Operators_Map, "&", Axf_Concat);
   Operators_Mapping.Insert (Operators_Map, "mod", Axf_Mod);
   Operators_Mapping.Insert (Operators_Map, "rem", Axf_Rem);
   Operators_Mapping.Insert (Operators_Map, "=", Axf_Eq);
   Operators_Mapping.Insert (Operators_Map, "/=", Axf_NE);
   Operators_Mapping.Insert (Operators_Map, "<", Axf_LT);
   Operators_Mapping.Insert (Operators_Map, ">", Axf_GT);
   Operators_Mapping.Insert (Operators_Map, "<=", Axf_LE);
   Operators_Mapping.Insert (Operators_Map, ">=", Axf_GE);
   Operators_Mapping.Insert (Operators_Map, "and", Axf_And);
   Operators_Mapping.Insert (Operators_Map, "or", Axf_Or);
   Operators_Mapping.Insert (Operators_Map, "not", Axf_Not);
   Operators_Mapping.Insert (Operators_Map, "abs", Axf_Abs);
   Operators_Mapping.Insert (Operators_Map, "xor", Axf_Xor);
   Operators_Mapping.Insert (Operators_Map, "and then", Axf_And_Short);
   Operators_Mapping.Insert (Operators_Map, "or else", Axf_Or_Short);
   Operators_Mapping.Insert (Operators_Map, "**", Axf_Exponent);

end Vatox.Axf_Points.Terminal_Nomenclature.Ada_Terms;