亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? kwtbl.pas

?? 編譯原理基礎
?? PAS
字號:

(* KWTBL - prepare keyword tables for use in lexical analyzers

   USAGE: kwtbl [<input-file] [>output-file]

   DESCRIPTION

   KWTBL is a tiny utility that helps you prepare keyword tables for use
   in lexical analyzers, such as yylex routines prepared with the TP Lex
   program.

   In languages with a large number of keywords it is often more efficient
   to analyze the reserved words using a general pattern, and then use a
   table lookup procedure to determine the actual code for the keyword.
   Also, large keyword tables in a Lex grammar can easily cause TP Lex to
   overflow; in such cases the KWTBL utility is useful.

   KWTBL reads in a list of (keyword, code) pairs, sorts keywords alpha-
   betically, and writes out two typed array constants, one containing
   the keyword strings and the other containing the corresponding codes.
   These tables may be accessed through a binary table lookup procedure
   which is appended to the end of the output file. The code for the
   table lookup procedure is assumed to be in the file 'KWTBL.COD' which
   must be present either in the current directory or in the directory
   from which KWTBL was executed; without this file, KWTBL does not
   generate the table lookup procedure.

   Consider a typical programming language with identifiers and certain
   reserved words which look like identifiers. The corresponding rules
   of your TP Lex program might look like:

   if		return( _IF_ );
   while	return( _WHILE_ );
   ...
   [A-Za-z]+	return( ID );

   Alternatively, you can use KWTBL to produce a keyword table lookup
   procedure. The input to KWTBL will be something like:

   if		_IF_
   while	_WHILE_
   ...

   Each keyword entry is on a separate line, and keyword and corresponding
   code are separated by whitespace (blanks and/or tabs). Empty lines are
   ignored. You do not have to sort the keyword entries; KWTBL will do that
   for you. The code for a keyword can actually be any character sequence
   which denotes a legal constant integer expression.

   From the keyword table, KWTBL produces two typed array constants:

   const

   nkws = ...;   { number of different keywords }
   kwsize = ...; { maximum size of keywords }

   kwtbl : array [ 1..nkws ] of String[ kwsize ] = (
     ..., 'if', ..., 'while', ...
   );

   kwcod : array [ 1..nkws ] of Integer = (
     ..., _IF_, ..., _WHILE_, ...
   );

   These tables may be accessed through the table lookup procedure (named
   kwlookup in the standard version of the KWTBL.COD file). The corresponding
   Lex code will now be:

   [A-Za-z]+	if kwlookup( yytext, code ) then
   		  return( code )
                else
                  return( ID );
*)

uses Dos;

(* Quicksort: *)

type

OrderPredicate = function (i, j : Integer) : Boolean;
SwapProc = procedure (i, j : Integer);

procedure quicksort(lo, hi: Integer;
                    less : OrderPredicate;
                    swap : SwapProc);
  (* derived from the quicksort routine in QSORT.PAS in the Turbo Pascal
     distribution *)
  procedure sort(l, r: Integer);
    var i, j, k : Integer;
    begin
      i := l; j := r; k := (l+r) DIV 2;
      repeat
        while less(i, k) do inc(i);
        while less(k, j) do dec(j);
        if i<=j then
          begin
            swap(i, j);
            if k=i then k := j (* pivot element swapped! *)
            else if k=j then k := i;
            inc(i); dec(j);
          end;
      until i>j;
      if l<j then sort(l,j);
      if i<r then sort(i,r);
    end(*sort*);
  begin
    if lo<hi then sort(lo,hi);
  end(*quicksort*);

const

maxkws = 100;	 (* maximum number of keywords *)
maxkwsize = 40;	 (* maximum keyword size; longer keywords are truncated *)
maxcodsize = 40; (* maximum code size; longer keyword codes are truncated *)

type

KwString = String[ maxkwsize ];
CodString = String [ maxcodsize ];

var

(* the keyword table: *)

nkws, kwsize : Integer;

kwtbl : array [ 1..maxkws ] of KwString;
kwcod : array [ 1..maxkws ] of CodString;

var stderr : Text;

procedure error( msg : String );
  (* write out an error message *)
  begin
    writeln( stderr, '*** ', msg );
  end(*error*);

procedure fatal( msg : String );
  (* write error message and halt program *)
  begin
    error( 'fatal: '+msg );
    halt ( 1 );
  end(*fatal*);

procedure split( line : String; var kw : KwString; var cod : CodString );
  (* split a line in keyword and code part *)
  const tab = ^I;
  var i : Integer;
  begin
    kw := ''; i := 1;
    while (i<=length(line)) and (line[i]<>' ') and (line[i]<>tab) do
      begin
        if length(kw)<maxkwsize then kw := kw+line[i];
        inc(i);
      end;
    while (i<=length(line)) and ((line[i]=' ') or (line[i]=tab)) do inc(i);
    cod := copy( line, i, length(line) );
  end(*split*);

function path( filename : String ) : String;
  (* return the drive/directory part of a filename *)
  var d : DirStr; n : NameStr; e : ExtStr;
  begin
    fsplit( filename, d, n, e );
    path := d;
  end(*path*);

function intStr( i : Integer ) : String;
  (* convert an integer to a string *)
  var s : String;
  begin
    Str( i, s );
    intStr := s;
  end(*intStr*);

(* Routines to sort the keyword table: *)

{$F+}
function less( i, j : Integer ) : Boolean;
  begin
    less := kwtbl[i]<kwtbl[j];
  end(*less*);
procedure swap( i, j : Integer );
  var kw : KwString; cod : CodString;
  begin
    kw := kwtbl[i]; cod := kwcod[i];
    kwtbl[i] := kwtbl[j]; kwcod[i] := kwcod[j];
    kwtbl[j] := kw; kwcod[j] := cod;
  end(*swap*);
{$F-}

var line : String; i, lineno, actcol : Integer; codfile : Text;

begin
  (* open stderr device: *)
  assign( stderr, '' ); rewrite( stderr );
  TextRec(stderr).handle := 2;
  TextRec(stderr).bufSize := 1;
  (* read in the keyword table from standard input: *)
  nkws := 0; kwsize := 0; lineno := 0;
  while not eof do
    begin
      readln( line ); inc( lineno );
      if line<>'' then
        begin
          inc( nkws );
          if nkws>maxkws then fatal( 'too many keywords' );
          split( line, kwtbl[ nkws ], kwcod[ nkws ] );
          if ( kwtbl[ nkws ]='' ) or ( kwcod[ nkws ] = '' ) then
            begin
              error( 'error in line '+intStr( lineno ) );
              dec( nkws );
            end
	  else if length(kwtbl[nkws])>kwsize then
	    kwsize := length(kwtbl[nkws]);
        end;
    end;
  (* sort the keyword table: *)
  quicksort( 1, nkws, less, swap );
  (* produce output code: *)
  if nkws=0 then fatal( 'nothing to do' );
  writeln;
  writeln( 'const' );
  writeln;
  writeln('nkws = ', nkws, ';' );
  writeln('kwsize = ', kwsize, ';' );
  writeln;
  writeln('kwtbl : array [ 1..nkws ] of String[ kwsize ] = (' );
  write( '  ' ); actcol := 3;
  for i := 1 to nkws do
    begin
      if actcol+length(kwtbl[i])>79 then
        begin
          writeln; write( '  ' ); actcol := 3;
        end;
      write( '''', kwtbl[i], '''' ); inc( actcol, length( kwtbl[i] )+2 );
      if i<nkws then
        begin
          write( ', ' ); inc( actcol, 2 );
        end;
    end;
  writeln;
  writeln( ');' );
  writeln;
  writeln('kwcod : array [ 1..nkws ] of Integer = (' );
  write( '  ' ); actcol := 3;
  for i := 1 to nkws do
    begin
      if actcol+length(kwcod[i])>79 then
        begin
          writeln; write( '  ' ); actcol := 3;
        end;
      write( kwcod[i] ); inc( actcol, length( kwcod[i] ) );
      if i<nkws then
        begin
          write( ', ' ); inc( actcol, 2 );
        end;
    end;
  writeln;
  writeln( ');' );
  writeln;
  (* copy KWTBL.COD file to the output: *)
  {$I-}
  assign( codfile, 'KWTBL.COD' ); reset( codfile );
  if ioresult<>0 then
    begin
      assign( codfile, path( paramStr(0) )+'KWTBL.COD' ); reset( codfile );
      if ioresult<>0 then halt;
    end;
  while not eof( codfile ) do
    begin
      readln( codfile, line );
      writeln( line );
    end;
  close( codfile );
end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩高清在线不卡| 99久久婷婷国产综合精品电影| 精品国产伦一区二区三区观看方式 | 6080国产精品一区二区| 日本高清无吗v一区| 99久久er热在这里只有精品66| 99久久精品国产观看| av亚洲精华国产精华| 99re这里只有精品视频首页| k8久久久一区二区三区| 成人精品免费视频| 成人av影视在线观看| 99国产精品国产精品久久| 99久精品国产| 91美女蜜桃在线| 欧美日韩一区二区在线视频| 欧美视频在线一区二区三区| 欧美美女一区二区| 欧美成人猛片aaaaaaa| 久久久精品国产免费观看同学| 久久精品一区二区三区不卡牛牛| 国产视频一区在线观看| 亚洲素人一区二区| 亚洲国产成人精品视频| 美国欧美日韩国产在线播放| 激情丁香综合五月| 顶级嫩模精品视频在线看| 成人18精品视频| 91国偷自产一区二区三区观看 | 国产女人水真多18毛片18精品视频 | 国产精品色哟哟网站| 亚洲欧洲在线观看av| 一区二区三区电影在线播| 午夜精彩视频在线观看不卡| 精品一区二区综合| 成人av免费在线观看| 欧美日韩综合在线免费观看| 日韩欧美国产一区在线观看| 欧美激情中文不卡| 亚洲在线成人精品| 黑人巨大精品欧美一区| 91视频免费观看| 欧美一级一级性生活免费录像| 国产日韩v精品一区二区| 亚洲欧美二区三区| 久久99国产精品久久99| 91美女福利视频| 91精品国产手机| 中文字幕亚洲成人| 蜜桃视频第一区免费观看| 国产成人午夜99999| 欧美色爱综合网| 久久久久久97三级| 午夜精品免费在线观看| 国产成人av一区二区| 欧美亚洲综合网| 久久综合九色欧美综合狠狠| 一级日本不卡的影视| 国产乱码精品一区二区三区忘忧草| 91亚洲精品一区二区乱码| 日韩精品专区在线影院重磅| 中文字幕日韩精品一区| 久久激情五月婷婷| 色琪琪一区二区三区亚洲区| 精品国产3级a| 亚洲第一久久影院| www.在线欧美| 精品三级av在线| 一级做a爱片久久| 成人白浆超碰人人人人| 亚洲精品一区二区三区影院 | 日精品一区二区三区| www.视频一区| 久久色视频免费观看| 亚洲第一二三四区| 色综合一区二区三区| 久久久午夜电影| 免费成人在线观看| 欧美日韩国产首页| 亚洲欧美区自拍先锋| 国产福利精品导航| 欧美成人性战久久| 视频精品一区二区| 欧美视频一区二区| 亚洲精品乱码久久久久久| 豆国产96在线|亚洲| 26uuu亚洲| 美腿丝袜亚洲三区| 欧美一区二区网站| 亚洲国产日产av| 在线视频欧美区| 亚洲久草在线视频| bt7086福利一区国产| 中文字幕精品在线不卡| 国产成人在线免费观看| 久久久亚洲精品石原莉奈| 看国产成人h片视频| 欧美一区二区在线不卡| 琪琪一区二区三区| 欧美一级艳片视频免费观看| 日韩精品1区2区3区| 欧美猛男男办公室激情| 五月综合激情网| 欧美午夜一区二区| 性感美女极品91精品| 欧美日韩国产综合一区二区| 亚洲一区二区三区在线| 欧美在线免费观看亚洲| 亚洲成av人片一区二区| 欧美精品欧美精品系列| 日韩电影在线看| 这里是久久伊人| 毛片基地黄久久久久久天堂| 日韩女优制服丝袜电影| 国产精品一区二区x88av| 国产欧美日韩视频一区二区 | 久久伊人中文字幕| 国产成人精品免费| 国产欧美1区2区3区| 99久久免费视频.com| 一区二区三区中文在线| 欧美日韩国产综合草草| 青青草国产精品97视觉盛宴| 精品日韩一区二区| 国产精品99久久久久久似苏梦涵 | 欧美成人三级在线| 国产精品夜夜爽| 国产精品国产三级国产普通话蜜臀 | 国产一区二区三区日韩| 国产精品免费观看视频| 波多野结衣中文字幕一区| 亚洲激情网站免费观看| 欧美一区二区精品| 国产成人高清在线| 亚洲永久免费av| 精品人伦一区二区色婷婷| 国产91在线看| 亚洲综合免费观看高清完整版 | 精品国产一区二区三区忘忧草| 精品夜夜嗨av一区二区三区| 国产日产欧美一区二区三区| 色婷婷狠狠综合| 日本不卡视频一二三区| 中文字幕精品一区| 欧美自拍偷拍午夜视频| 韩国在线一区二区| 一区二区在线观看视频| 91精品国产综合久久精品app| 国产精品一区二区在线观看不卡| 亚洲欧美日韩国产中文在线| 欧美一区二视频| av电影在线不卡| 免费成人你懂的| 亚洲天堂久久久久久久| 精品日韩一区二区三区免费视频| av电影天堂一区二区在线观看| 午夜久久久久久| 国产精品国产自产拍在线| 日韩亚洲欧美在线| a在线播放不卡| 精品一区二区成人精品| 夜夜精品视频一区二区 | 中文字幕中文乱码欧美一区二区| 欧美日韩激情在线| 床上的激情91.| 美女一区二区视频| 伊人夜夜躁av伊人久久| 久久久精品天堂| 欧美日韩国产高清一区二区三区| 成人高清视频在线观看| 老司机一区二区| 午夜精品久久久久久久久久久| 国产精品免费看片| 久久亚区不卡日本| 欧美一区国产二区| 欧美日韩在线免费视频| www.日韩av| 国产成人精品综合在线观看| 久热成人在线视频| 亚洲国产精品欧美一二99| 亚洲欧洲无码一区二区三区| 精品国产三级a在线观看| 在线电影院国产精品| 色综合天天视频在线观看| 国产不卡一区视频| 久久91精品国产91久久小草| 婷婷开心激情综合| 亚洲一区二区三区国产| 国产精品乱码人人做人人爱| 久久亚洲一区二区三区四区| 日韩欧美国产成人一区二区| 欧美日韩中文字幕一区二区| 91美女在线视频| 99精品视频在线免费观看| 国产成人免费在线视频| 精品伊人久久久久7777人| 免费看欧美美女黄的网站| 免费久久精品视频| 免费成人小视频| 狠狠色丁香九九婷婷综合五月|