关于tex.web以及WEB编程

今天捣鼓了一下tex.web。有一点基础的同学可能知道.web文件通过两个命令可以得到两种不同类型,即:

  1. tangle tex.web 得到 tex.p (pascal程序文件)
  2. weave tex.web 得到 tex.tex (tex文件)

一般情况下,得到的pascal文件会非常怪异,比如:

{4:}{9:}{$C-,A+,D-}{[$C+,D+]}{:9}program TEX;label{6:}1,9998,9999;
{:6}const{11:}memmax=30000;memmin=0;bufsize=500;errorline=72;
halferrorline=42;maxprintline=79;stacksize=200;maxinopen=6;fontmax=75;
fontmemsize=20000;paramsize=60;nestsize=40;maxstrings=3000;
stringvacancies=8000;poolsize=32000;savesize=600;triesize=8000;
trieopsize=500;dvibufsize=800;filenamesize=40;
poolname='TeXformats:TEX.POOL                     ';
{:11}type{18:}ASCIIcode=0..255;{:18}{25:}eightbits=0..255;
alphafile=packed file of char;bytefile=packed file of eightbits;
{:25}{38:}poolpointer=0..poolsize;strnumber=0..maxstrings;
packedASCIIcode=0..255;{:38}{101:}scaled=integer;
nonnegativeinteger=0..2147483647;smallnumber=0..63;
{:101}{109:}glueratio=real;{:109}{113:}quarterword=0..255;
halfword=0..65535;twochoices=1..2;fourchoices=1..4;
twohalves=packed record rh:halfword;case twochoices of 1:(lh:halfword);
2:(b0:quarterword;b1:quarterword);end;
fourquarters=packed record b0:quarterword;b1:quarterword;b2:quarterword;
b3:quarterword;end;
memoryword=record case fourchoices of 1:(int:integer);2:(gr:glueratio);
3:(hh:twohalves);4:(qqqq:fourquarters);end;wordfile=file of memoryword;
{:113}{150:}glueord=0..3;

这个就是 Plain 的 Pacal 源文件,用free pascal稍微整理一下得到下面的代码:

ptop -i tex.p tex_out.p

得到如下代码:

{4:}{9:}{$C-,A+,D-}{[$C+,D+]}{:9}

Program TEX;

Label {6:}1,9998,9999;
{:6}

Const {11:}memmax = 30000;
  memmin = 0;
  bufsize = 500;
  errorline = 72;
  halferrorline = 42;
  maxprintline = 79;
  stacksize = 200;
  maxinopen = 6;
  fontmax = 75;
  fontmemsize = 20000;
  paramsize = 60;
  nestsize = 40;
  maxstrings = 3000;
  stringvacancies = 8000;
  poolsize = 32000;
  savesize = 600;
  triesize = 8000;
  trieopsize = 500;
  dvibufsize = 800;
  filenamesize = 40;
  poolname = 'TeXformats:TEX.POOL                     ';
{:11}

Type {18:}ASCIIcode = 0..255;{:18}{25:}
  eightbits = 0..255;
  alphafile = packed file Of char;
  bytefile = packed file Of eightbits;
{:25}{38:}
  poolpointer = 0..poolsize;
  strnumber = 0..maxstrings;
  packedASCIIcode = 0..255;{:38}{101:}
  scaled = integer;
  nonnegativeinteger = 0..2147483647;
  smallnumber = 0..63;
{:101}{109:}
  glueratio = real;{:109}{113:}
  quarterword = 0..255;
  halfword = 0..65535;
  twochoices = 1..2;
  fourchoices = 1..4;
  twohalves = packed Record
    rh: halfword;
    Case twochoices Of 
      1: (lh:halfword);
      2: (b0:quarterword;b1:quarterword);
  End;
  fourquarters = packed Record
    b0: quarterword;
    b1: quarterword;
    b2: quarterword;
    b3: quarterword;
  End;
  memoryword = Record
    Case fourchoices Of 
      1: (int:integer);
      2: (gr:glueratio);
      3: (hh:twohalves);
      4: (qqqq:fourquarters);
  End;
  wordfile = file Of memoryword;
{:113}{150:}
  glueord = 0..3;

代码可读许多。

你可能感兴趣的:(关于tex.web以及WEB编程)