TABGEN(1ACK)

NAME
tabgen - table generator for C-programs

SYNOPSYS
tabgen arguments

DESCRIPTION
Tabgen is a handy tool for generating tables for C-programs from a compact description. The current version is only suitable for generating character tables. The output is produced on standard output. It works by maintaining an internal table of values, printing this table when this is requested.

Each argument given to tabgen is either a command or a description. Descriptions are discussed first.

A description consists of a value (a string), directly followed by a semicolon, directly followed by a list of indices for which the table to be generated has this value. This list of indices must be in a certain inputformat, characterized by a charactet. Currently, there is only one inputformat, "c". In this format, the indices are characters. There are two special characters: '\' and '-'. The '\' behaves like in a C-string, and the '-' describes a range, unless it starts the list of indices.

Some examples of descriptions:
	STIDF:a-zA-Z_
	STSKIP:\r \t\013\f

These descriptions have the effect that the internal table values for internal table values for carriage-return, space, tab, vertical-tab, and form-feed are set to STSKIP.

A command is introduced by a special character. On the command line, a command is introduced by a '-'. The following commands are recognized:

Ichar
    switch to a different input format. This command is only there for future extensions.

ffile
    read input from the file file. In a file, each line is an argument to tabgen. Each line is either a command or a description. In a file, commands are introduced by a '%'.

Fformat
    Values are printed in a printf format. The default value for this format is "%s,\n". This can be changed with this command.

Ttext
    Print text literally at this point.

p   Print the table as it is built at this point.

C   Clear the table. This sets all internal table values to 0.

istr
    Initialize all internal table values to str. if str is not given, this command is equivalent to the C command.

Snum
    Set the table size to num entries. The default size is 128.

Hfilename
    Create tables which can be indexed by the full range of characters, rather than 0..127. As this depends on the implementation of 'char' in C (signed or unsigned), this also generates a file filename, with a #define for the constant "CharOffset". The generated tables can be indexed by first adding "CharOffset" to the base of the table. If filename is not given, "charoffset.h" is used.

AN EXAMPLE

The next example is a part of the tabgen description of the character tables used by the lexical analyser of the ACK Modula-2 compiler. This description resides in a file called char.tab. Tabgen is called as follows:
	tabgen -fchar.tab > char.c

The description as given here generates 2 tables: one indicating a class according to which token a character can be a start of, and one indicating whether a character may occur in an identifier.
%	Comments are introduced with space or tab after the %
%S129
%F	%s,
%	CHARACTER CLASSES
%iSTGARB
STSKIP: \t\013\014\015
STNL:\012
STSIMP:-#&()*+,/;=[]^{|}~
STCOMP:.:<>
STIDF:a-zA-Z
STSTR:"'
STNUM:0-9
STEOI:\200
%T#include "class.h"
%	class.h contains #defines for STSKIP, STNL, ...
%Tchar tkclass[] = {
%p
%T};
%	INIDF
%C
1:a-zA-Z0-9
%Tchar inidf[] = {
%F	%s,
%p
%T};

BUGS

Tabgen assumes that characters are 8 bits wide.