home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / doc / token2MS.awk < prev   
Encoding:
AWK Script  |  1996-09-27  |  2.2 KB  |  86 lines

  1. BEGIN {
  2.   #{{{}}}
  3. #  {{{  init internal vars
  4.   start=256
  5.   i=start
  6.   SMALL_VT= ".sp .3";
  7. #  }}}
  8.  
  9. #  {{{  init fixed cmd arg range
  10.   cmd_range=8
  11. #  }}}
  12.  
  13. #  {{{  print auto-gen tag
  14.   printf(".\\%c generated automatically, containing OCL token table\n",34)
  15. #  }}}
  16. #  {{{  start table
  17.   printf(".TS\n")
  18.   printf("center tab(@);\n")
  19.   printf("l r l.\n")
  20. #  }}}
  21. #  {{{  entry for NOP
  22.   printf("\\fBO_NOP\\fP@%d@COM\n",i)
  23.   printf(" no operation@@*\n")
  24.   printf("%s\n",SMALL_VT);
  25. #  }}}
  26. }
  27. #{{{  set fixed cmd arg range
  28. /^#define +FIXED_COMMAND_RANGE/ {
  29.   cmd_range=$3
  30. }
  31. #}}}
  32. #{{{  set types for command and fixed command
  33. $3=="COM" || $3=="COM_I" || $3=="COM_II" || $3=="COM_P" || $3=="COM_IP" || $3=="COM_IIP" { typ=$3;fix_typ="";arg="" }
  34. $3=="COM_A" { typ="COM_A";fix_typ="COM";arg=" +arg" }
  35. $3=="COM_ID" { typ="COM_II";fix_typ="COM_I";arg="arg1" }
  36. #}}}
  37. substr($1,1,1)!="#" && $3!="OCL-KEY" && $3!="OPP-KEY" {
  38. #  {{{  decode permission
  39.   perm=""
  40.   if ($2=="KT_DUMMY")
  41.      perm="*"
  42.   else if ($2=="KT_NONE")
  43.      perm="-"
  44.   else {
  45.      for (l=3;l<=length($2);l++) {
  46.         if (substr($2,l,1)=="B")
  47.            perm= perm "V"
  48.         else if (substr($2,l,1)=="P")
  49.            perm= perm "P"
  50.         else if (substr($2,l,1)=="S")
  51.            perm= perm "F"
  52.         else if (substr($2,l,1)=="s")
  53.            perm= perm "f"
  54.      }
  55.   }
  56. #  }}}
  57. #  {{{  get text for table entry
  58.   if ($5!="" || $4=="NONE") {
  59.      txt=""
  60.      for (t=5;t<=NF;t++)
  61.         txt=txt " " $t
  62.   } else
  63.      txt=" \\fB"$4"\\fP"
  64. #  }}}
  65. #  {{{  get additional arg and type, maybe print auto commands
  66.   if ($3=="COM_ID" || $3=="COM_A" || $3=="COM_D") {
  67.      print("\\fB"$1"_M\\fP\\fIx\\fP@"++i+cmd_range"-\\fIx\\fP,0<\\fIx\\fP<="cmd_range"@"fix_typ)
  68.      print(txt" \-\\fIx\\fP@@"perm)
  69.      i+=cmd_range-1
  70.      print("\\fB"$1"_\\fP\\fIx\\fP@"++i"+\\fIx\\fP,0<=\\fIx\\fP<="cmd_range"@"fix_typ)
  71.      print(txt" \\fIx\\fP@@"perm)
  72.      i+=cmd_range
  73.   }
  74. #  }}}
  75.   print("\\fB"$1"\\fP@"++i"@"typ)
  76.   print(txt arg"@@"perm)
  77.   print(SMALL_VT)
  78. }
  79. END {
  80.   print("\\fBO_CALL_FIX\\fP \\fIx\\fP@\\fIx\\fP+"i",\\fIx\\fP>=0@COM")
  81.   print(" call the OCL-macro \\fIx\\fP@@*")
  82.   print(".TE")
  83.   print(".LP")
  84.   print("Tokens lower than "start" represent the corresponding characters.")
  85. }
  86.