Natools

Check-in [d40564ef6b]
Login
Overview
Comment:generate_static_hash_map: new tool that provides a CLI to Natools.Static_Hash_Maps
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d40564ef6b11f838ec95a396f6434c6764873e3f
User & Date: nat on 2014-05-23 18:44:05
Other Links: manifest | tags
Context
2014-05-24
13:03
static_hash_maps: retry perfect hash generation when it fails check-in: ddc10181a8 user: nat tags: trunk
2014-05-23
18:44
generate_static_hash_map: new tool that provides a CLI to Natools.Static_Hash_Maps check-in: d40564ef6b user: nat tags: trunk
2014-05-22
20:14
natools: add Meaningless_Type to help instantiation of interpreters without meaningful context or state check-in: dd0bb46ace user: nat tags: trunk
Changes

Modified tools.gpr from [69e0606d25] to [a7527b07a8].

1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
with "natools";

project Tools is
   for Source_Dirs use ("tools");

   for Main use ("hmac-md5", "hmac-sha1", "hmac-sha256");

   for Object_Dir use Natools'Object_Dir;
   for Exec_Dir use Natools'Exec_Dir;

   package Compiler is
      for Default_Switches use Natools.Compiler'Default_Switches;
   end Compiler;

   package Linker is
      for Default_Switches use Natools.Linker'Default_Switches;
   end Linker;
end Tools;




>
|












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
with "natools";

project Tools is
   for Source_Dirs use ("tools");
   for Main use
     ("generate_static_hash_map", "hmac-md5", "hmac-sha1", "hmac-sha256");

   for Object_Dir use Natools'Object_Dir;
   for Exec_Dir use Natools'Exec_Dir;

   package Compiler is
      for Default_Switches use Natools.Compiler'Default_Switches;
   end Compiler;

   package Linker is
      for Default_Switches use Natools.Linker'Default_Switches;
   end Linker;
end Tools;

Added tools/generate_static_hash_map.adb version [977ec5056f].











































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-- Generate_Static_Hash_Map is a command-line interface to the static hash  --
-- map package generator, using a description from S-expression files.      --
-- It also provides bootstrap for the S-expression description interpreter. --
------------------------------------------------------------------------------

with Ada.Command_Line;
with Ada.Text_IO;
with Natools.Static_Hash_Maps.S_Expressions;
with Natools.S_Expressions.File_Readers;
with Natools.S_Expressions.Lockable;

procedure Generate_Static_Hash_Map is
begin
   if Ada.Command_Line.Argument_Count = 0 then
      Ada.Text_IO.Put_Line
        (Ada.Text_IO.Current_Error,
         "Usage: " & Ada.Command_Line.Command_Name
         & " input.sx [other-input.sx ...]");
      Ada.Text_IO.Put_Line
        (Ada.Text_IO.Current_Error,
         "   special argument ""--"" instead of input file bootstraps the");
      Ada.Text_IO.Put_Line
        (Ada.Text_IO.Current_Error,
         "   descriptor interpreter hash map.");
      Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
      return;
   end if;

   for I in 1 .. Ada.Command_Line.Argument_Count loop
      if Ada.Command_Line.Argument (I) = "--" then
         declare
            use Natools.Static_Hash_Maps;
         begin
            Generate_Package
              ("Natools.Static_Hash_Maps.S_Expressions.Command_Maps",
               (Map
                 (Element_Type => "Package_Command",
                  Hash_Package_Name =>
                    "Natools.Static_Hash_Maps.S_Expressions.Command_Pkg",
                  Function_Name => "To_Package_Command",
                  Nodes =>
                    (Node ("private", "Private_Child"),
                     Node ("public", "Public_Child"))),
                Map
                 (Element_Type => "Map_Command",
                  Hash_Package_Name =>
                    "Natools.Static_Hash_Maps.S_Expressions.Command_Map",
                  Function_Name => "To_Map_Command",
                  Nodes =>
                    (Node ("hash-package", "Hash_Package"),
                     Node ("nodes", "Nodes"),
                     Node ("function", "Function_Name"),
                     Node ("not-found", "Not_Found")))),
               Private_Child => True);
         end;
      else
         declare
            Input : Natools.S_Expressions.Lockable.Descriptor'Class
              := Natools.S_Expressions.File_Readers.Reader
                  (Ada.Command_Line.Argument (I));
         begin
            Natools.Static_Hash_Maps.S_Expressions.Generate_Packages
              (Input,
               "from " & Ada.Command_Line.Argument (I));
         end;
      end if;
   end loop;
end Generate_Static_Hash_Map;