tabgen.1 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. .TH TABGEN 1ACK
  2. .ad
  3. .SH NAME
  4. tabgen \- table generator for C-programs
  5. .SH SYNOPSYS
  6. .B tabgen \fIarguments\fP
  7. .SH DESCRIPTION
  8. .I Tabgen
  9. is a handy tool for generating tables for C-programs from a compact
  10. description. The current version is only suitable for generating character
  11. tables. The output is produced on standard output.
  12. It works by maintaining an internal table of values, printing this table
  13. when this is requested.
  14. .PP
  15. Each argument given to
  16. .I tabgen
  17. is either a command or a description. Descriptions are discussed first.
  18. .PP
  19. A description consists of a value (a string), directly followed by a semicolon,
  20. directly followed by a list of indices for which the table to be generated
  21. has this value. This list of indices must be in a certain \fBinputformat\fP,
  22. characterized by a charactet.
  23. Currently, there is only one inputformat, "c". In this format, the indices
  24. are characters. There are two special characters: '\e' and '-'. The '\e'
  25. behaves like in a C-string, and the '-' describes a range, unless
  26. it starts the list of indices.
  27. .PP
  28. Some examples of descriptions:
  29. .nf
  30. STIDF:a-zA-Z_
  31. STSKIP:\er \et\e013\ef
  32. .fi
  33. .PP
  34. These descriptions have the effect that the internal table values for
  35. 'a' through 'z', 'A' through 'Z', and '_' are set to STIDF, and that the
  36. internal table values for carriage-return, space, tab, vertical-tab, and
  37. form-feed are set to STSKIP.
  38. .PP
  39. A command is introduced by a special character. On the command line,
  40. a command is introduced by a '-'. The following commands are
  41. recognized:
  42. .IP I\fIchar\fP
  43. switch to a different input format. This command is only there for future
  44. extensions.
  45. .IP f\fIfile\fP
  46. read input from the file \fIfile\fP. In a file, each line is an argument
  47. to \fItabgen\fP. Each line is either a command or a description. In a file,
  48. commands are introduced by a '%'.
  49. .IP F\fIformat\fP
  50. Values are printed in a printf format. The default value for this format
  51. is \fB"%s,\en"\fP. This can be changed with this command.
  52. .IP T\fItext\fP
  53. Print \fItext\fP literally at this point.
  54. .IP p
  55. Print the table as it is built at this point.
  56. .IP C
  57. Clear the table. This sets all internal table values to 0.
  58. .IP i\fIstr\fP
  59. Initialize all internal table values to \fIstr\fP. if \fIstr\fP is not
  60. given, this command is equivalent to the C command.
  61. .IP S\fInum\fP
  62. Set the table size to \fInum\fP entries. The default size is 128.
  63. .SH "AN EXAMPLE"
  64. .PP
  65. The next example is a part of the \fItabgen\fP description of the
  66. character tables used by the lexical analyser of the ACK Modula-2 compiler.
  67. This description resides in a file called char.tab.
  68. .I
  69. Tabgen
  70. is called as follows:
  71. .nf
  72. tabgen -fchar.tab > char.c
  73. .fi
  74. .PP
  75. The description as given here generates 2 tables: one indicating a class
  76. according to which token a character can be a start of, and one indicating
  77. whether a character may occur in an identifier.
  78. .nf
  79. % Comments are introduced with space or tab after the %
  80. %S129
  81. %F %s,
  82. % CHARACTER CLASSES
  83. %iSTGARB
  84. STSKIP: \et\e013\e014\e015
  85. STNL:\e012
  86. STSIMP:-#&()*+,/;=[]^{|}~
  87. STCOMP:.:<>
  88. STIDF:a-zA-Z
  89. STSTR:"'
  90. STNUM:0-9
  91. STEOI:\e200
  92. %T#include "class.h"
  93. % class.h contains #defines for STSKIP, STNL, ...
  94. %Tchar tkclass[] = {
  95. %p
  96. %T};
  97. % INIDF
  98. %C
  99. 1:a-zA-Z0-9
  100. %Tchar inidf[] = {
  101. %F %s,
  102. %p
  103. %T};
  104. .fi
  105. .SH BUGS
  106. .PP
  107. .I Tabgen
  108. assumes that characters are 8 bits wide.