Go to the first, previous, next, last section, table of contents.

Translation Table

In the name of POSIX compliance, flex supports a translation table for mapping input characters into groups. The table is specified in the first section, and its format looks like:

%t
1        abcd
2        ABCDEFGHIJKLMNOPQRSTUVWXYZ
52       0123456789
6        \t\ \n
%t

This example specifies that the characters `a', `b', `c', and `d' are to all be lumped into group #1, upper-case letters in group #2, digits in group #52, tabs, blanks, and newlines into group #6, and no other characters will appear in the patterns. The group numbers are actually disregarded by flex; %t serves, though, to lump characters together. Given the above table, for example, the pattern `a(AA)*5' is equivalent to `d(ZQ)*0'. They both say, "match any character in group #1, followed by zero or more pairs of characters from group #2, followed by a character from group #52." Thus `%t' provides a crude way for introducing equivalence classes into the scanner specification.

Note that the `-i' option (see below) coupled with the equivalence classes which flex automatically generates take care of virtually all the instances when one might consider using `%t'. But what the hell, it's there if you want it.


Go to the first, previous, next, last section, table of contents.