Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / pass1 / names / nazwy.pas
1 program nazwy(input,output,names,result,fhash);\r
2 (* program czyta ciag identyfikatorow z pliku names *)\r
3 (* na plik result wypisuje pary (nazwa, numer z hash'u ) *)\r
4 (* na plik fhash wypisuje ciag podstawien tworzacy zmodyfikowana tablice hash *)\r
5 const dl = 10;\r
6 type tname = array[1..10] of integer;\r
7      thash = array[1..8000] of integer;\r
8 var name:tname;\r
9     hash : thash;\r
10     nlast : integer;\r
11     a1,b1,i,j,n:integer;\r
12     a,b:char;\r
13     names,fhash,result:text;\r
14     str:lstring(20);\r
15 function search(vars k:integer; vars name:tname; vars hash:thash; \r
16                   vars nlast:integer):integer [fortran];extern;    \r
17 procedure init(vars hash:thash) [fortran];extern;\r
18 begin\r
19    (* inicjalizacja *) \r
20    reset(names);\r
21    rewrite(result);\r
22    rewrite(fhash);\r
23    for i := 1 to 8000 do hash[i] := 0;\r
24    nlast := 8001;\r
25    (* inicjalizacja tablicy hash *)\r
26    init(hash);\r
27    writeln('  koniec inicjalizacji tablicy hash ');\r
28    \r
29    while not eof(names) do\r
30    begin\r
31    i := 0;\r
32    j := 0;\r
33    str.len := wrd(20);\r
34      while not eoln(names) do\r
35      begin\r
36         read(names,a);\r
37         j := j+1;\r
38         str[j] := a;\r
39         if a<'a'then a1 := ord(a) - ord('0') else\r
40             a1 := ord(a) - ord('a')+10;\r
41         if not eoln(names) then\r
42         begin\r
43           read(names,b);\r
44           j := j+1;\r
45           str[j] := b;\r
46           i := i+1;\r
47           if b<'a' then b1 := ord(b) - ord('0') else\r
48              b1 := ord(b) - ord('a')+10;\r
49           if a1 = 0 then a1 := 60;                \r
50           name[i] := a1*64+b1;\r
51         end else\r
52         begin\r
53           i := i+1;\r
54           name[i] := a1;\r
55         end;\r
56       end;\r
57       (* koniec nazwy *)\r
58       n := search(i,name,hash,nlast);\r
59       str.len := wrd(j);\r
60       writeln(result,'   ',str, '   ',n);\r
61       readln(names);\r
62     end;\r
63    \r
64     (* wypisanie tablicy hash *)\r
65     for i := 1 to 8000 do\r
66     begin\r
67       if hash[i] <> 0 then\r
68       writeln(fhash,'      ','HASH (',i:6,' ) =',hash[i]:6);\r
69     end;\r
70   end.    \r
71         \r
72                \r