tabgen.1 3.2 KB

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