Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | tools/smaz: add support for hash function generation |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
24be612b042c653d75a36dc7274270de |
| User & Date: | nat 2016-09-11 20:22:00.758 |
Context
|
2016-09-12
| ||
| 21:10 | smaz-original: new package providing the original Smaz dictionary check-in: 59ee9e9566 user: nat tags: trunk | |
|
2016-09-11
| ||
| 20:22 | tools/smaz: add support for hash function generation check-in: 24be612b04 user: nat tags: trunk | |
|
2016-09-10
| ||
| 14:12 | tools/smaz: add support for command-line options check-in: dd6ad78eeb user: nat tags: trunk | |
Changes
Changes to tools/smaz.adb.
| ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 | 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 | + - + + + |
with Ada.Command_Line;
with Ada.Streams;
with Ada.Strings.Unbounded;
with Ada.Text_IO.Text_Streams;
with Natools.Getopt_Long;
with Natools.S_Expressions.Parsers;
with Natools.Smaz.Tools;
with Natools.Smaz.Tools.GNAT;
procedure Smaz is
package Options is
type Id is
(Help,
|
| ︙ | |||
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | + + + + + + |
if Argument'Length > 0 then
Handler.Ada_Dictionary
:= Ada.Strings.Unbounded.To_Unbounded_String (Argument);
else
Handler.Ada_Dictionary
:= Ada.Strings.Unbounded.To_Unbounded_String ("-");
end if;
when Options.Output_Hash =>
Handler.Need_Dictionary := True;
Handler.Hash_Package
:= Ada.Strings.Unbounded.To_Unbounded_String (Argument);
end case;
end Option;
function Getopt_Config return Getopt.Configuration is
use Getopt;
use Options;
R : Getopt.Configuration;
begin
R.Add_Option ("ada-dict", 'A', Optional_Argument, Output_Ada_Dictionary);
R.Add_Option ("hash-pkg", 'H', Required_Argument, Output_Hash);
R.Add_Option ("help", 'h', No_Argument, Help);
return R;
end Getopt_Config;
procedure Print_Dictionary
|
| ︙ | |||
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | + + + + + + + |
when Options.Output_Ada_Dictionary =>
Put_Line (Output, "=[filename]");
Put_Line (Output, Indent & Indent
& "Output the current dictionary as Ada code in the given");
Put_Line (Output, Indent & Indent
& "file, or standard output if filename is ""-""");
when Options.Output_Hash =>
Put_Line (Output, " <Hash Package Name>");
Put_Line (Output, Indent & Indent
& "Build a package with a perfect hash function for the");
Put_Line (Output, Indent & Indent
& "current dictionary.");
end case;
end loop;
end Print_Help;
Opt_Config : constant Getopt.Configuration := Getopt_Config;
Handler : Callback;
|
| ︙ | |||
215 216 217 218 219 220 221 222 223 | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | + + - + + + + + |
Build_Dictionary :
declare
Dictionary : constant Natools.Smaz.Dictionary
:= Natools.Smaz.Tools.To_Dictionary (Input_List, True);
Ada_Dictionary : constant String
:= Ada.Strings.Unbounded.To_String (Handler.Ada_Dictionary);
Hash_Package : constant String
:= Ada.Strings.Unbounded.To_String (Handler.Hash_Package);
begin
if Ada_Dictionary'Length > 0 then
|