home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / compcomp / tpyacc / kwtbl.cod < prev    next >
Text File  |  1991-06-07  |  664b  |  28 lines

  1.  
  2. (* KWTBL keyword table lookup procedure V1.0 6-7-91 AG *)
  3.  
  4. function kwlookup( kw : String; var code : Integer ) : Boolean;
  5.   (* checks whether kw is in the keyword table; if so, returns the
  6.      corresponding integer code *)
  7.   var m, n, k : integer;
  8.   begin
  9.     (* binary search: *)
  10.     m := 1; n := nkws;
  11.     while m<=n do
  12.       begin
  13.         k := m+(n-m) div 2;
  14.         if kw=kwtbl[k] then
  15.           begin
  16.             kwlookup := true;
  17.             code := kwcod[k];
  18.             exit
  19.           end
  20.         else if kw>kwtbl[k] then
  21.           m := k+1
  22.         else
  23.           n := k-1
  24.       end;
  25.     kwlookup := false
  26.   end(*kwlookup*);
  27.  
  28.