1 .TH FLEX 1 "April 1995" "Version 2.5"
3 flex \- fast lexical analyzer generator
6 .B [\-bcdfhilnpstvwBFILTV78+? \-C[aefFmr] \-ooutput \-Pprefix \-Sskeleton]
7 .B [\-\-help \-\-version]
12 a tool for generating programs that perform pattern-matching on text. The
13 manual includes both tutorial and reference sections:
17 a brief overview of the tool
21 Format Of The Input File
24 the extended regular expressions used by flex
26 How The Input Is Matched
27 the rules for determining what has been matched
30 how to specify what to do when a pattern is matched
33 details regarding the scanner that flex produces;
34 how to control the input source
37 introducing context into your scanners, and
38 managing "mini-scanners"
40 Multiple Input Buffers
41 how to manipulate multiple input sources; how to
42 scan from strings instead of files
45 special rules for matching the end of the input
48 a summary of macros available to the actions
50 Values Available To The User
51 a summary of values available to the actions
54 connecting flex scanners together with yacc parsers
57 flex command-line options, and the "%option"
60 Performance Considerations
61 how to make your scanner go as fast as possible
63 Generating C++ Scanners
64 the (experimental) facility for generating C++
67 Incompatibilities With Lex And POSIX
68 how flex differs from AT&T lex and the POSIX lex
72 those error messages produced by flex (or scanners
73 it generates) whose meanings might not be apparent
79 known problems with flex
82 other documentation, related tools
85 includes contact information
90 is a tool for generating
92 programs which recognized lexical patterns in text.
95 the given input files, or its standard input if no file names are given,
96 for a description of a scanner to generate. The description is in
98 of regular expressions and C code, called
100 generates as output a C source file,
102 which defines a routine
104 This file is compiled and linked with the
106 library to produce an executable. When the executable is run,
107 it analyzes its input for occurrences
108 of the regular expressions. Whenever it finds one, it executes
109 the corresponding C code.
110 .SH SOME SIMPLE EXAMPLES
112 First some simple examples to get the flavor of how one uses
116 input specifies a scanner which whenever it encounters the string
117 "username" will replace it with the user's login name:
121 username printf( "%s", getlogin() );
124 By default, any text not matched by a
127 is copied to the output, so the net effect of this scanner is
128 to copy its input file to its output with each occurrence
129 of "username" expanded.
130 In this input, there is just one rule. "username" is the
132 and the "printf" is the
134 The "%%" marks the beginning of the rules.
136 Here's another simple example:
139 int num_lines = 0, num_chars = 0;
142 \\n ++num_lines; ++num_chars;
149 printf( "# of lines = %d, # of chars = %d\\n",
150 num_lines, num_chars );
154 This scanner counts the number of characters and the number
155 of lines in its input (it produces no output other than the
156 final report on the counts). The first line
157 declares two globals, "num_lines" and "num_chars", which are accessible
162 routine declared after the second "%%". There are two rules, one
163 which matches a newline ("\\n") and increments both the line count and
164 the character count, and one which matches any character other than
165 a newline (indicated by the "." regular expression).
167 A somewhat more complicated example:
170 /* scanner for a toy Pascal-like language */
173 /* need this for the call to atof() below */
183 printf( "An integer: %s (%d)\\n", yytext,
187 {DIGIT}+"."{DIGIT}* {
188 printf( "A float: %s (%g)\\n", yytext,
192 if|then|begin|end|procedure|function {
193 printf( "A keyword: %s\\n", yytext );
196 {ID} printf( "An identifier: %s\\n", yytext );
198 "+"|"-"|"*"|"/" printf( "An operator: %s\\n", yytext );
200 "{"[^}\\n]*"}" /* eat up one-line comments */
202 [ \\t\\n]+ /* eat up whitespace */
204 . printf( "Unrecognized character: %s\\n", yytext );
212 ++argv, --argc; /* skip over program name */
214 yyin = fopen( argv[0], "r" );
222 This is the beginnings of a simple scanner for a language like
223 Pascal. It identifies different types of
225 and reports on what it has seen.
227 The details of this example will be explained in the following
229 .SH FORMAT OF THE INPUT FILE
232 input file consists of three sections, separated by a line with just
246 section contains declarations of simple
248 definitions to simplify the scanner specification, and declarations of
250 which are explained in a later section.
252 Name definitions have the form:
258 The "name" is a word beginning with a letter or an underscore ('_')
259 followed by zero or more letters, digits, '_', or '-' (dash).
260 The definition is taken to begin at the first non-white-space character
261 following the name and continuing to the end of the line.
262 The definition can subsequently be referred to using "{name}", which
263 will expand to "(definition)". For example,
270 defines "DIGIT" to be a regular expression which matches a
272 "ID" to be a regular expression which matches a letter
273 followed by zero-or-more letters-or-digits.
274 A subsequent reference to
286 and matches one-or-more digits followed by a '.' followed
287 by zero-or-more digits.
293 input contains a series of rules of the form:
299 where the pattern must be unindented and the action must begin
302 See below for a further description of patterns and actions.
304 Finally, the user code section is simply copied to
307 It is used for companion routines which call or are called
308 by the scanner. The presence of this section is optional;
309 if it is missing, the second
311 in the input file may be skipped, too.
313 In the definitions and rules sections, any
315 text or text enclosed in
319 is copied verbatim to the output (with the %{}'s removed).
320 The %{}'s must appear unindented on lines by themselves.
322 In the rules section,
323 any indented or %{} text appearing before the
324 first rule may be used to declare variables
325 which are local to the scanning routine and (after the declarations)
326 code which is to be executed whenever the scanning routine is entered.
327 Other indented or %{} text in the rule section is still copied to the output,
328 but its meaning is not well-defined and it may well cause compile-time
329 errors (this feature is present for
331 compliance; see below for other such features).
333 In the definitions section (but not in the rules section),
334 an unindented comment (i.e., a line
335 beginning with "/*") is also copied verbatim to the output up
338 The patterns in the input are written using an extended set of regular
339 expressions. These are:
342 x match the character 'x'
343 . any character (byte) except newline
344 [xyz] a "character class"; in this case, the pattern
345 matches either an 'x', a 'y', or a 'z'
346 [abj-oZ] a "character class" with a range in it; matches
347 an 'a', a 'b', any letter from 'j' through 'o',
349 [^A-Z] a "negated character class", i.e., any character
350 but those in the class. In this case, any
351 character EXCEPT an uppercase letter.
352 [^A-Z\\n] any character EXCEPT an uppercase letter or
354 r* zero or more r's, where r is any regular expression
356 r? zero or one r's (that is, "an optional r")
357 r{2,5} anywhere from two to five r's
358 r{2,} two or more r's
360 {name} the expansion of the "name" definition
363 the literal string: [xyz]"foo
364 \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v',
365 then the ANSI-C interpretation of \\x.
366 Otherwise, a literal 'X' (used to escape
367 operators such as '*')
368 \\0 a NUL character (ASCII code 0)
369 \\123 the character with octal value 123
370 \\x2a the character with hexadecimal value 2a
371 (r) match an r; parentheses are used to override
372 precedence (see below)
375 rs the regular expression r followed by the
376 regular expression s; called "concatenation"
379 r|s either an r or an s
382 r/s an r but only if it is followed by an s. The
383 text matched by s is included when determining
384 whether this rule is the "longest match",
385 but is then returned to the input before
386 the action is executed. So the action only
387 sees the text matched by r. This type
388 of pattern is called trailing context".
389 (There are some combinations of r/s that flex
390 cannot match correctly; see notes in the
391 Deficiencies / Bugs section below regarding
392 "dangerous trailing context".)
393 ^r an r, but only at the beginning of a line (i.e.,
394 which just starting to scan, or right after a
395 newline has been scanned).
396 r$ an r, but only at the end of a line (i.e., just
397 before a newline). Equivalent to "r/\\n".
399 Note that flex's notion of "newline" is exactly
400 whatever the C compiler used to compile flex
401 interprets '\\n' as; in particular, on some DOS
402 systems you must either filter out \\r's in the
403 input yourself, or explicitly use r/\\r\\n for "r$".
406 <s>r an r, but only in start condition s (see
407 below for discussion of start conditions)
409 same, but in any of start conditions s1,
411 <*>r an r in any start condition, even an exclusive one.
414 <<EOF>> an end-of-file
416 an end-of-file when in start condition s1 or s2
419 Note that inside of a character class, all regular expression operators
420 lose their special meaning except escape ('\\') and the character class
421 operators, '-', ']', and, at the beginning of the class, '^'.
423 The regular expressions listed above are grouped according to
424 precedence, from highest precedence at the top to lowest at the bottom.
425 Those grouped together have equal precedence. For example,
437 since the '*' operator has higher precedence than concatenation,
438 and concatenation higher than alternation ('|'). This pattern
443 the string "ba" followed by zero-or-more r's.
444 To match "foo" or zero-or-more "bar"'s, use:
450 and to match zero-or-more "foo"'s-or-"bar"'s:
457 In addition to characters and ranges of characters, character classes
458 can also contain character class
460 These are expressions enclosed inside
464 delimiters (which themselves must appear between the '[' and ']' of the
465 character class; other elements may occur inside the character class, too).
466 The valid expressions are:
469 [:alnum:] [:alpha:] [:blank:]
470 [:cntrl:] [:digit:] [:graph:]
471 [:lower:] [:print:] [:punct:]
472 [:space:] [:upper:] [:xdigit:]
475 These expressions all designate a set of characters equivalent to
476 the corresponding standard C
478 function. For example,
480 designates those characters for which
482 returns true - i.e., any alphabetic or numeric.
483 Some systems don't provide
489 For example, the following character classes are all equivalent:
498 If your scanner is case-insensitive (the
507 Some notes on patterns:
509 A negated character class such as the example "[^A-Z]"
511 .I will match a newline
512 unless "\\n" (or an equivalent escape sequence) is one of the
513 characters explicitly present in the negated character class
514 (e.g., "[^A-Z\\n]"). This is unlike how many other regular
515 expression tools treat negated character classes, but unfortunately
516 the inconsistency is historically entrenched.
517 Matching newlines means that a pattern like [^"]* can match the entire
518 input unless there's another quote in the input.
520 A rule can have at most one instance of trailing context (the '/' operator
521 or the '$' operator). The start condition, '^', and "<<EOF>>" patterns
522 can only occur at the beginning of a pattern, and, as well as with '/' and '$',
523 cannot be grouped inside parentheses. A '^' which does not occur at
524 the beginning of a rule or a '$' which does not occur at the end of
525 a rule loses its special properties and is treated as a normal character.
527 The following are illegal:
534 Note that the first of these, can be written "foo/bar\\n".
536 The following will result in '$' or '^' being treated as a normal character:
543 If what's wanted is a "foo" or a bar-followed-by-a-newline, the following
544 could be used (the special '|' action is explained below):
548 bar$ /* action goes here */
551 A similar trick will work for matching a foo or a
552 bar-at-the-beginning-of-a-line.
553 .SH HOW THE INPUT IS MATCHED
554 When the generated scanner is run, it analyzes its input looking
555 for strings which match any of its patterns. If it finds more than
556 one match, it takes the one matching the most text (for trailing
557 context rules, this includes the length of the trailing part, even
558 though it will then be returned to the input). If it finds two
559 or more matches of the same length, the
560 rule listed first in the
562 input file is chosen.
564 Once the match is determined, the text corresponding to the match
567 is made available in the global character pointer
569 and its length in the global integer
573 corresponding to the matched pattern is then executed (a more
574 detailed description of actions follows), and then the remaining
575 input is scanned for another match.
577 If no match is found, then the
579 is executed: the next character in the input is considered matched and
580 copied to the standard output. Thus, the simplest legal
588 which generates a scanner that simply copies its input (one character
589 at a time) to its output.
593 can be defined in two different ways: either as a character
597 You can control which definition
599 uses by including one of the special directives
603 in the first (definitions) section of your flex input. The default is
607 lex compatibility option, in which case
610 The advantage of using
612 is substantially faster scanning and no buffer overflow when matching
613 very large tokens (unless you run out of dynamic memory). The disadvantage
614 is that you are restricted in how your actions can modify
616 (see the next section), and calls to the
618 function destroys the present contents of
620 which can be a considerable porting headache when moving between different
626 is that you can then modify
628 to your heart's content, and calls to
632 (see below). Furthermore, existing
634 programs sometimes access
636 externally using declarations of the form:
638 extern char yytext[];
640 This definition is erroneous when used with
650 characters, which defaults to a fairly large value. You can change
651 the size by simply #define'ing
653 to a different value in the first section of your
655 input. As mentioned above, with
657 yytext grows dynamically to accommodate large tokens. While this means your
659 scanner can accommodate very large tokens (such as matching entire blocks
660 of comments), bear in mind that each time the scanner must resize
662 it also must rescan the entire token from the beginning, so matching such
663 tokens can prove slow.
667 dynamically grow if a call to
669 results in too much text being pushed back; instead, a run-time error results.
671 Also note that you cannot use
673 with C++ scanner classes
678 Each pattern in a rule has a corresponding action, which can be any
679 arbitrary C statement. The pattern ends at the first non-escaped
680 whitespace character; the remainder of the line is its action. If the
681 action is empty, then when the pattern is matched the input token
682 is simply discarded. For example, here is the specification for a program
683 which deletes all occurrences of "zap me" from its input:
690 (It will copy all other characters in the input to the output since
691 they will be matched by the default rule.)
693 Here is a program which compresses multiple blanks and tabs down to
694 a single blank, and throws away whitespace found at the end of a line:
698 [ \\t]+ putchar( ' ' );
699 [ \\t]+$ /* ignore this token */
703 If the action contains a '{', then the action spans till the balancing '}'
704 is found, and the action may cross multiple lines.
706 knows about C strings and comments and won't be fooled by braces found
707 within them, but also allows actions to begin with
709 and will consider the action to be all the text up to the next
711 (regardless of ordinary braces inside the action).
713 An action consisting solely of a vertical bar ('|') means "same as
714 the action for the next rule." See below for an illustration.
716 Actions can include arbitrary C code, including
718 statements to return a value to whatever routine called
722 is called it continues processing tokens from where it last left
723 off until it either reaches
724 the end of the file or executes a return.
726 Actions are free to modify
728 except for lengthening it (adding
729 characters to its end--these will overwrite later characters in the
730 input stream). This however does not apply when using
732 (see above); in that case,
734 may be freely modified in any way.
736 Actions are free to modify
738 except they should not do so if the action also includes use of
742 There are a number of special directives which can be included within
746 copies yytext to the scanner's output.
749 followed by the name of a start condition places the scanner in the
750 corresponding start condition (see below).
753 directs the scanner to proceed on to the "second best" rule which matched the
754 input (or a prefix of the input). The rule is chosen as described
755 above in "How the Input is Matched", and
759 set up appropriately.
760 It may either be one which matched as much text
761 as the originally chosen rule but came later in the
763 input file, or one which matched less text.
764 For example, the following will both count the
765 words in the input and call the routine special() whenever "frob" is seen:
771 frob special(); REJECT;
772 [^ \\t\\n]+ ++word_count;
777 any "frob"'s in the input would not be counted as words, since the
778 scanner normally executes only one action per token.
781 are allowed, each one finding the next best choice to the currently
782 active rule. For example, when the following scanner scans the token
783 "abcd", it will write "abcdabcaba" to the output:
791 .|\\n /* eat up any unmatched character */
794 (The first three rules share the fourth's action since they use
795 the special '|' action.)
797 is a particularly expensive feature in terms of scanner performance;
800 of the scanner's actions it will slow down
802 of the scanner's matching. Furthermore,
804 cannot be used with the
810 Note also that unlike the other special actions,
814 code immediately following it in the action will
819 tells the scanner that the next time it matches a rule, the corresponding
822 onto the current value of
824 rather than replacing it. For example, given the input "mega-kludge"
825 the following will write "mega-mega-kludge" to the output:
829 mega- ECHO; yymore();
833 First "mega-" is matched and echoed to the output. Then "kludge"
834 is matched, but the previous "mega-" is still hanging around at the
839 for the "kludge" rule will actually write "mega-kludge".
841 Two notes regarding use of
845 depends on the value of
847 correctly reflecting the size of the current token, so you must not
852 Second, the presence of
854 in the scanner's action entails a minor performance penalty in the
855 scanner's matching speed.
858 returns all but the first
860 characters of the current token back to the input stream, where they
861 will be rescanned when the scanner looks for the next match.
865 are adjusted appropriately (e.g.,
869 ). For example, on the input "foobar" the following will write out
874 foobar ECHO; yyless(3);
880 will cause the entire current input string to be scanned again. Unless you've
881 changed how the scanner will subsequently process its input (using
883 for example), this will result in an endless loop.
887 is a macro and can only be used in the flex input file, not from
893 back onto the input stream. It will be the next character scanned.
894 The following action will take the current token and cause it
895 to be rescanned enclosed in parentheses.
900 /* Copy yytext because unput() trashes yytext */
901 char *yycopy = strdup( yytext );
903 for ( i = yyleng - 1; i >= 0; --i )
912 puts the given character back at the
914 of the input stream, pushing back strings must be done back-to-front.
916 An important potential problem when using
918 is that if you are using
920 (the default), a call to
925 starting with its rightmost character and devouring one character to
926 the left with each call. If you need the value of yytext preserved
929 (as in the above example),
930 you must either first copy it elsewhere, or build your scanner using
932 instead (see How The Input Is Matched).
934 Finally, note that you cannot put back
936 to attempt to mark the input stream with an end-of-file.
939 reads the next character from the input stream. For example,
940 the following is one way to eat up C comments:
949 while ( (c = input()) != '*' &&
951 ; /* eat up text of comment */
955 while ( (c = input()) == '*' )
958 break; /* found the end */
963 error( "EOF in comment" );
970 (Note that if the scanner is compiled using
974 is instead referred to as
976 in order to avoid a name clash with the
978 stream by the name of
982 flushes the scanner's internal buffer
983 so that the next time the scanner attempts to match a token, it will
984 first refill the buffer using
986 (see The Generated Scanner, below). This action is a special case
989 function, described below in the section Multiple Input Buffers.
992 can be used in lieu of a return statement in an action. It terminates
993 the scanner and returns a 0 to the scanner's caller, indicating "all done".
996 is also called when an end-of-file is encountered. It is a macro and
998 .SH THE GENERATED SCANNER
1003 which contains the scanning routine
1005 a number of tables used by it for matching tokens, and a number
1006 of auxiliary routines and macros. By default,
1008 is declared as follows:
1013 ... various definitions and the actions in here ...
1017 (If your environment supports function prototypes, then it will
1018 be "int yylex( void )".) This definition may be changed by defining
1019 the "YY_DECL" macro. For example, you could use:
1022 #define YY_DECL float lexscan( a, b ) float a, b;
1025 to give the scanning routine the name
1027 returning a float, and taking two floats as arguments. Note that
1028 if you give arguments to the scanning routine using a
1029 K&R-style/non-prototyped function declaration, you must terminate
1030 the definition with a semi-colon (;).
1034 is called, it scans tokens from the global input file
1036 (which defaults to stdin). It continues until it either reaches
1037 an end-of-file (at which point it returns the value 0) or
1038 one of its actions executes a
1042 If the scanner reaches an end-of-file, subsequent calls are undefined
1045 is pointed at a new input file (in which case scanning continues from
1050 takes one argument, a
1052 pointer (which can be nil, if you've set up
1054 to scan from a source other than
1058 for scanning from that file. Essentially there is no difference between
1061 to a new input file or using
1063 to do so; the latter is available for compatibility with previous versions
1066 and because it can be used to switch input files in the middle of scanning.
1067 It can also be used to throw away the current input buffer, by calling
1068 it with an argument of
1070 but better is to use
1077 reset the start condition to
1079 (see Start Conditions, below).
1083 stops scanning due to executing a
1085 statement in one of the actions, the scanner may then be called again and it
1086 will resume scanning where it left off.
1088 By default (and for purposes of efficiency), the scanner uses
1089 block-reads rather than simple
1091 calls to read characters from
1093 The nature of how it gets its input can be controlled by defining the
1096 YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its
1097 action is to place up to
1099 characters in the character array
1101 and return in the integer variable
1104 number of characters read or the constant YY_NULL (0 on Unix systems)
1105 to indicate EOF. The default YY_INPUT reads from the
1106 global file-pointer "yyin".
1108 A sample definition of YY_INPUT (in the definitions
1109 section of the input file):
1113 #define YY_INPUT(buf,result,max_size) \\
1115 int c = getchar(); \\
1116 result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\
1121 This definition will change the input processing to occur
1122 one character at a time.
1124 When the scanner receives an end-of-file indication from YY_INPUT,
1129 returns false (zero), then it is assumed that the
1130 function has gone ahead and set up
1132 to point to another input file, and scanning continues. If it returns
1133 true (non-zero), then the scanner terminates, returning 0 to its
1134 caller. Note that in either case, the start condition remains unchanged;
1140 If you do not supply your own version of
1142 then you must either use
1144 (in which case the scanner behaves as though
1146 returned 1), or you must link with
1148 to obtain the default version of the routine, which always returns 1.
1150 Three routines are available for scanning from in-memory buffers rather
1152 .B yy_scan_string(), yy_scan_bytes(),
1154 .B yy_scan_buffer().
1155 See the discussion of them below in the section Multiple Input Buffers.
1157 The scanner writes its
1161 global (default, stdout), which may be redefined by the user simply
1162 by assigning it to some other
1165 .SH START CONDITIONS
1167 provides a mechanism for conditionally activating rules. Any rule
1168 whose pattern is prefixed with "<sc>" will only be active when
1169 the scanner is in the start condition named "sc". For example,
1172 <STRING>[^"]* { /* eat up the string body ... */
1177 will be active only when the scanner is in the "STRING" start
1181 <INITIAL,STRING,QUOTE>\\. { /* handle an escape ... */
1186 will be active only when the current start condition is
1187 either "INITIAL", "STRING", or "QUOTE".
1190 are declared in the definitions (first) section of the input
1191 using unindented lines beginning with either
1195 followed by a list of names.
1198 start conditions, the latter
1200 start conditions. A start condition is activated using the
1202 action. Until the next
1204 action is executed, rules with the given start
1205 condition will be active and
1206 rules with other start conditions will be inactive.
1207 If the start condition is
1209 then rules with no start conditions at all will also be active.
1214 rules qualified with the start condition will be active.
1215 A set of rules contingent on the same exclusive start condition
1216 describe a scanner which is independent of any of the other rules in the
1218 input. Because of this,
1219 exclusive start conditions make it easy to specify "mini-scanners"
1220 which scan portions of the input that are syntactically different
1221 from the rest (e.g., comments).
1223 If the distinction between inclusive and exclusive start conditions
1224 is still a little vague, here's a simple example illustrating the
1225 connection between the two. The set of rules:
1231 <example>foo do_something();
1233 bar something_else();
1242 <example>foo do_something();
1244 <INITIAL,example>bar something_else();
1248 .B <INITIAL,example>
1251 pattern in the second example wouldn't be active (i.e., couldn't match)
1252 when in start condition
1258 though, then it would only be active in
1262 while in the first example it's active in both, because in the first
1265 startion condition is an
1270 Also note that the special start-condition specifier
1272 matches every start condition. Thus, the above example could also
1279 <example>foo do_something();
1281 <*>bar something_else();
1285 The default rule (to
1287 any unmatched character) remains active in start conditions. It
1296 returns to the original state where only the rules with
1297 no start conditions are active. This state can also be
1298 referred to as the start-condition "INITIAL", so
1302 (The parentheses around the start condition name are not required but
1303 are considered good style.)
1306 actions can also be given as indented code at the beginning
1307 of the rules section. For example, the following will cause
1308 the scanner to enter the "SPECIAL" start condition whenever
1310 is called and the global variable
1319 if ( enter_special )
1322 <SPECIAL>blahblahblah
1323 ...more rules follow...
1327 To illustrate the uses of start conditions,
1328 here is a scanner which provides two different interpretations
1329 of a string like "123.456". By default it will treat it as
1330 three tokens, the integer "123", a dot ('.'), and the integer "456".
1331 But if the string is preceded earlier in the line by the string
1333 it will treat it as a single token, the floating-point number
1343 expect-floats BEGIN(expect);
1345 <expect>[0-9]+"."[0-9]+ {
1346 printf( "found a float, = %f\\n",
1350 /* that's the end of the line, so
1351 * we need another "expect-number"
1352 * before we'll recognize any more
1359 printf( "found an integer, = %d\\n",
1363 "." printf( "found a dot\\n" );
1366 Here is a scanner which recognizes (and discards) C comments while
1367 maintaining a count of the current input line.
1374 "/*" BEGIN(comment);
1376 <comment>[^*\\n]* /* eat anything that's not a '*' */
1377 <comment>"*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */
1378 <comment>\\n ++line_num;
1379 <comment>"*"+"/" BEGIN(INITIAL);
1382 This scanner goes to a bit of trouble to match as much
1383 text as possible with each rule. In general, when attempting to write
1384 a high-speed scanner try to match as much possible in each rule, as
1387 Note that start-conditions names are really integer values and
1388 can be stored as such. Thus, the above could be extended in the
1398 comment_caller = INITIAL;
1405 comment_caller = foo;
1409 <comment>[^*\\n]* /* eat anything that's not a '*' */
1410 <comment>"*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */
1411 <comment>\\n ++line_num;
1412 <comment>"*"+"/" BEGIN(comment_caller);
1415 Furthermore, you can access the current start condition using
1418 macro. For example, the above assignments to
1420 could instead be written
1423 comment_caller = YY_START;
1430 (since that is what's used by AT&T
1433 Note that start conditions do not have their own name-space; %s's and %x's
1434 declare names in the same fashion as #define's.
1436 Finally, here's an example of how to match C-style quoted strings using
1437 exclusive start conditions, including expanded escape sequences (but
1438 not including checking for a string that's too long):
1444 char string_buf[MAX_STR_CONST];
1445 char *string_buf_ptr;
1448 \\" string_buf_ptr = string_buf; BEGIN(str);
1450 <str>\\" { /* saw closing quote - all done */
1452 *string_buf_ptr = '\\0';
1453 /* return string constant token type and
1459 /* error - unterminated string constant */
1460 /* generate error message */
1463 <str>\\\\[0-7]{1,3} {
1464 /* octal escape sequence */
1467 (void) sscanf( yytext + 1, "%o", &result );
1469 if ( result > 0xff )
1470 /* error, constant is out-of-bounds */
1472 *string_buf_ptr++ = result;
1476 /* generate error - bad escape sequence; something
1477 * like '\\48' or '\\0777777'
1481 <str>\\\\n *string_buf_ptr++ = '\\n';
1482 <str>\\\\t *string_buf_ptr++ = '\\t';
1483 <str>\\\\r *string_buf_ptr++ = '\\r';
1484 <str>\\\\b *string_buf_ptr++ = '\\b';
1485 <str>\\\\f *string_buf_ptr++ = '\\f';
1487 <str>\\\\(.|\\n) *string_buf_ptr++ = yytext[1];
1489 <str>[^\\\\\\n\\"]+ {
1490 char *yptr = yytext;
1493 *string_buf_ptr++ = *yptr++;
1498 Often, such as in some of the examples above, you wind up writing a
1499 whole bunch of rules all preceded by the same start condition(s). Flex
1500 makes this a little easier and cleaner by introducing a notion of
1503 A start condition scope is begun with:
1511 is a list of one or more start conditions. Inside the start condition
1512 scope, every rule automatically has the prefix
1514 applied to it, until a
1516 which matches the initial
1522 "\\\\n" return '\\n';
1523 "\\\\r" return '\\r';
1524 "\\\\f" return '\\f';
1525 "\\\\0" return '\\0';
1532 <ESC>"\\\\n" return '\\n';
1533 <ESC>"\\\\r" return '\\r';
1534 <ESC>"\\\\f" return '\\f';
1535 <ESC>"\\\\0" return '\\0';
1538 Start condition scopes may be nested.
1540 Three routines are available for manipulating stacks of start conditions:
1542 .B void yy_push_state(int new_state)
1543 pushes the current start condition onto the top of the start condition
1544 stack and switches to
1546 as though you had used
1548 (recall that start condition names are also integers).
1550 .B void yy_pop_state()
1551 pops the top of the stack and switches to it via
1554 .B int yy_top_state()
1555 returns the top of the stack without altering the stack's contents.
1557 The start condition stack grows dynamically and so has no built-in
1558 size limitation. If memory is exhausted, program execution aborts.
1560 To use start condition stacks, your scanner must include a
1562 directive (see Options below).
1563 .SH MULTIPLE INPUT BUFFERS
1564 Some scanners (such as those which support "include" files)
1565 require reading from several input streams. As
1567 scanners do a large amount of buffering, one cannot control
1568 where the next input will be read from by simply writing a
1570 which is sensitive to the scanning context.
1572 is only called when the scanner reaches the end of its buffer, which
1573 may be a long time after scanning a statement such as an "include"
1574 which requires switching the input source.
1576 To negotiate these sorts of problems,
1578 provides a mechanism for creating and switching between multiple
1579 input buffers. An input buffer is created by using:
1582 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1587 pointer and a size and creates a buffer associated with the given
1588 file and large enough to hold
1590 characters (when in doubt, use
1592 for the size). It returns a
1594 handle, which may then be passed to other routines (see below). The
1596 type is a pointer to an opaque
1597 .B struct yy_buffer_state
1598 structure, so you may safely initialize YY_BUFFER_STATE variables to
1599 .B ((YY_BUFFER_STATE) 0)
1600 if you wish, and also refer to the opaque structure in order to
1601 correctly declare input buffers in source files other than that
1602 of your scanner. Note that the
1604 pointer in the call to
1606 is only used as the value of
1612 so it no longer uses
1614 then you can safely pass a nil
1617 .B yy_create_buffer.
1618 You select a particular buffer to scan from using:
1621 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1624 switches the scanner's input buffer so subsequent tokens will
1628 .B yy_switch_to_buffer()
1629 may be used by yywrap() to set things up for continued scanning, instead
1630 of opening a new file and pointing
1632 at it. Note also that switching input sources via either
1633 .B yy_switch_to_buffer()
1638 change the start condition.
1641 void yy_delete_buffer( YY_BUFFER_STATE buffer )
1644 is used to reclaim the storage associated with a buffer. (
1646 can be nil, in which case the routine does nothing.)
1647 You can also clear the current contents of a buffer using:
1650 void yy_flush_buffer( YY_BUFFER_STATE buffer )
1653 This function discards the buffer's contents,
1654 so the next time the scanner attempts to match a token from the
1655 buffer, it will first fill the buffer anew using
1660 .B yy_create_buffer(),
1661 provided for compatibility with the C++ use of
1665 for creating and destroying dynamic objects.
1668 .B YY_CURRENT_BUFFER
1671 handle to the current buffer.
1673 Here is an example of using these features for writing a scanner
1674 which expands include files (the
1676 feature is discussed below):
1679 /* the "incl" state is used for picking up the name
1680 * of an include file
1685 #define MAX_INCLUDE_DEPTH 10
1686 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
1687 int include_stack_ptr = 0;
1691 include BEGIN(incl);
1694 [^a-z\\n]*\\n? ECHO;
1696 <incl>[ \\t]* /* eat the whitespace */
1697 <incl>[^ \\t\\n]+ { /* got the include file name */
1698 if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
1700 fprintf( stderr, "Includes nested too deeply" );
1704 include_stack[include_stack_ptr++] =
1707 yyin = fopen( yytext, "r" );
1712 yy_switch_to_buffer(
1713 yy_create_buffer( yyin, YY_BUF_SIZE ) );
1719 if ( --include_stack_ptr < 0 )
1726 yy_delete_buffer( YY_CURRENT_BUFFER );
1727 yy_switch_to_buffer(
1728 include_stack[include_stack_ptr] );
1733 Three routines are available for setting up input buffers for
1734 scanning in-memory strings instead of files. All of them create
1735 a new input buffer for scanning the string, and return a corresponding
1737 handle (which you should delete with
1738 .B yy_delete_buffer()
1739 when done with it). They also switch to the new buffer using
1740 .B yy_switch_to_buffer(),
1743 will start scanning the string.
1745 .B yy_scan_string(const char *str)
1746 scans a NUL-terminated string.
1748 .B yy_scan_bytes(const char *bytes, int len)
1751 bytes (including possibly NUL's)
1752 starting at location
1755 Note that both of these functions create and scan a
1757 of the string or bytes. (This may be desirable, since
1759 modifies the contents of the buffer it is scanning.) You can avoid the
1762 .B yy_scan_buffer(char *base, yy_size_t size)
1763 which scans in place the buffer starting at
1767 bytes, the last two bytes of which
1770 .B YY_END_OF_BUFFER_CHAR
1772 These last two bytes are not scanned; thus, scanning
1779 If you fail to set up
1781 in this manner (i.e., forget the final two
1782 .B YY_END_OF_BUFFER_CHAR
1785 returns a nil pointer instead of creating a new input buffer.
1789 is an integral type to which you can cast an integer expression
1790 reflecting the size of the buffer.
1791 .SH END-OF-FILE RULES
1792 The special rule "<<EOF>>" indicates
1793 actions which are to be taken when an end-of-file is
1794 encountered and yywrap() returns non-zero (i.e., indicates
1795 no further files to process). The action must finish
1796 by doing one of four things:
1800 to a new input file (in previous versions of flex, after doing the
1801 assignment you had to call the special action
1803 this is no longer necessary);
1809 executing the special
1813 or, switching to a new buffer using
1814 .B yy_switch_to_buffer()
1815 as shown in the example above.
1817 <<EOF>> rules may not be used with other
1818 patterns; they may only be qualified with a list of start
1819 conditions. If an unqualified <<EOF>> rule is given, it
1822 start conditions which do not already have <<EOF>> actions. To
1823 specify an <<EOF>> rule for only the initial start condition, use
1830 These rules are useful for catching things like unclosed comments.
1837 ...other rules for dealing with quotes...
1840 error( "unterminated quote" );
1845 yyin = fopen( *filelist, "r" );
1851 .SH MISCELLANEOUS MACROS
1854 can be defined to provide an action
1855 which is always executed prior to the matched rule's action. For example,
1856 it could be #define'd to call a routine to convert yytext to lower-case.
1859 is invoked, the variable
1861 gives the number of the matched rule (rules are numbered starting with 1).
1862 Suppose you want to profile how often each of your rules is matched. The
1863 following would do the trick:
1866 #define YY_USER_ACTION ++ctr[yy_act]
1871 is an array to hold the counts for the different rules. Note that
1874 gives the total number of rules (including the default rule, even if
1877 so a correct declaration for
1882 int ctr[YY_NUM_RULES];
1888 may be defined to provide an action which is always executed before
1889 the first scan (and before the scanner's internal initializations are done).
1890 For example, it could be used to call a routine to read
1891 in a data table or open a logging file.
1894 .B yy_set_interactive(is_interactive)
1895 can be used to control whether the current buffer is considered
1897 An interactive buffer is processed more slowly,
1898 but must be used when the scanner's input source is indeed
1899 interactive to avoid problems due to waiting to fill buffers
1900 (see the discussion of the
1902 flag below). A non-zero value
1903 in the macro invocation marks the buffer as interactive, a zero
1904 value as non-interactive. Note that use of this macro overrides
1905 .B %option always-interactive
1907 .B %option never-interactive
1908 (see Options below).
1909 .B yy_set_interactive()
1910 must be invoked prior to beginning to scan the buffer that is
1911 (or is not) to be considered interactive.
1914 .B yy_set_bol(at_bol)
1915 can be used to control whether the current buffer's scanning
1916 context for the next token match is done as though at the
1917 beginning of a line. A non-zero macro argument makes rules anchored with
1918 '^' active, while a zero argument makes '^' rules inactive.
1922 returns true if the next token scanned from the current buffer
1923 will have '^' rules active, false otherwise.
1925 In the generated scanner, the actions are all gathered in one large
1926 switch statement and separated using
1928 which may be redefined. By default, it is simply a "break", to separate
1929 each rule's action from the following rule's.
1932 allows, for example, C++ users to
1933 #define YY_BREAK to do nothing (while being very careful that every
1934 rule ends with a "break" or a "return"!) to avoid suffering from
1935 unreachable statement warnings where because a rule's action ends with
1939 .SH VALUES AVAILABLE TO THE USER
1940 This section summarizes the various values available to the user
1941 in the rule actions.
1944 holds the text of the current token. It may be modified but not lengthened
1945 (you cannot append characters to the end).
1947 If the special directive
1949 appears in the first section of the scanner description, then
1952 .B char yytext[YYLMAX],
1955 is a macro definition that you can redefine in the first section
1956 if you don't like the default value (generally 8KB). Using
1958 results in somewhat slower scanners, but the value of
1960 becomes immune to calls to
1964 which potentially destroy its value when
1966 is a character pointer. The opposite of
1970 which is the default.
1974 when generating C++ scanner classes
1980 holds the length of the current token.
1983 is the file which by default
1985 reads from. It may be redefined but doing so only makes sense before
1986 scanning begins or after an EOF has been encountered. Changing it in
1987 the midst of scanning will have unexpected results since
1989 buffers its input; use
1992 Once scanning terminates because an end-of-file
1993 has been seen, you can assign
1995 at the new input file and then call the scanner again to continue scanning.
1997 .B void yyrestart( FILE *new_file )
1998 may be called to point
2000 at the new input file. The switch-over to the new file is immediate
2001 (any previously buffered-up input is lost). Note that calling
2005 as an argument thus throws away the current input buffer and continues
2006 scanning the same input file.
2009 is the file to which
2011 actions are done. It can be reassigned by the user.
2013 .B YY_CURRENT_BUFFER
2016 handle to the current buffer.
2019 returns an integer value corresponding to the current start
2020 condition. You can subsequently use this value with
2022 to return to that start condition.
2023 .SH INTERFACING WITH YACC
2024 One of the main uses of
2026 is as a companion to the
2030 parsers expect to call a routine named
2032 to find the next input token. The routine is supposed to
2033 return the type of the next token as well as putting any associated
2044 to instruct it to generate the file
2046 containing definitions of all the
2050 input. This file is then included in the
2052 scanner. For example, if one of the tokens is "TOK_NUMBER",
2053 part of the scanner might look like:
2062 [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER;
2067 has the following options:
2070 Generate backing-up information to
2072 This is a list of scanner states which require backing up
2073 and the input characters on which they do so. By adding rules one
2074 can remove backing-up states. If
2076 backing-up states are eliminated and
2080 is used, the generated scanner will run faster (see the
2082 flag). Only users who wish to squeeze every last cycle out of their
2083 scanners need worry about this option. (See the section on Performance
2084 Considerations below.)
2087 is a do-nothing, deprecated option included for POSIX compliance.
2090 makes the generated scanner run in
2092 mode. Whenever a pattern is recognized and the global
2094 is non-zero (which is the default),
2095 the scanner will write to
2100 --accepting rule at line 53 ("the matched text")
2103 The line number refers to the location of the rule in the file
2104 defining the scanner (i.e., the file that was fed to flex). Messages
2105 are also generated when the scanner backs up, accepts the
2106 default rule, reaches the end of its input buffer (or encounters
2107 a NUL; at this point, the two look the same as far as the scanner's concerned),
2108 or reaches an end-of-file.
2113 No table compression is done and stdio is bypassed.
2114 The result is large but fast. This option is equivalent to
2119 generates a "help" summary of
2135 scanner. The case of letters given in the
2138 be ignored, and tokens in the input will be matched regardless of case. The
2139 matched text given in
2141 will have the preserved case (i.e., it will not be folded).
2144 turns on maximum compatibility with the original AT&T
2146 implementation. Note that this does not mean
2148 compatibility. Use of this option costs a considerable amount of
2149 performance, and it cannot be used with the
2150 .B \-+, -f, -F, -Cf,
2153 options. For details on the compatibilities it provides, see the section
2154 "Incompatibilities With Lex And POSIX" below. This option also results
2156 .B YY_FLEX_LEX_COMPAT
2157 being #define'd in the generated scanner.
2160 is another do-nothing, deprecated option included only for
2164 generates a performance report to stderr. The report
2165 consists of comments regarding features of the
2167 input file which will cause a serious loss of performance in the resulting
2168 scanner. If you give the flag twice, you will also get comments regarding
2169 features that lead to minor performance losses.
2171 Note that the use of
2173 .B %option yylineno,
2174 and variable trailing context (see the Deficiencies / Bugs section below)
2175 entails a substantial performance penalty; use of
2182 flag entail minor performance penalties.
2187 (that unmatched scanner input is echoed to
2189 to be suppressed. If the scanner encounters input that does not
2190 match any of its rules, it aborts with an error. This option is
2191 useful for finding holes in a scanner's rule set.
2196 to write the scanner it generates to standard output instead
2205 a summary of statistics regarding the scanner it generates.
2206 Most of the statistics are meaningless to the casual
2208 user, but the first line identifies the version of
2210 (same as reported by
2212 and the next line the flags used when generating the scanner, including
2213 those that are on by default.
2216 suppresses warning messages.
2223 scanner, the opposite of
2225 scanners generated by
2227 (see below). In general, you use
2231 that your scanner will never be used interactively, and you want to
2234 more performance out of it. If your goal is instead to squeeze out a
2236 more performance, you should be using the
2240 options (discussed below), which turn on
2242 automatically anyway.
2248 scanner table representation should be used (and stdio
2249 bypassed). This representation is
2250 about as fast as the full table representation
2252 and for some sets of patterns will be considerably smaller (and for
2253 others, larger). In general, if the pattern set contains both "keywords"
2254 and a catch-all, "identifier" rule, such as in the set:
2257 "case" return TOK_CASE;
2258 "switch" return TOK_SWITCH;
2260 "default" return TOK_DEFAULT;
2261 [a-z]+ return TOK_ID;
2264 then you're better off using the full table representation. If only
2265 the "identifier" rule is present and you then use a hash table or some such
2266 to detect the keywords, you're better off using
2269 This option is equivalent to
2271 (see below). It cannot be used with
2279 scanner. An interactive scanner is one that only looks ahead to decide
2280 what token has been matched if it absolutely must. It turns out that
2281 always looking one extra character ahead, even if the scanner has already
2282 seen enough text to disambiguate the current token, is a bit faster than
2283 only looking ahead when necessary. But scanners that always look ahead
2284 give dreadful interactive performance; for example, when a user types
2285 a newline, it is not recognized as a newline token until they enter
2287 token, which often means typing in another whole line.
2296 table-compression options (see below). That's because if you're looking
2297 for high-performance you should be using one of these options, so if you
2300 assumes you'd rather trade off a bit of run-time performance for intuitive
2301 interactive behavior. Note also that you
2309 Thus, this option is not really needed; it is on by default for all those
2310 cases in which it is allowed.
2312 You can force a scanner to
2314 be interactive by using
2323 directives. Without this option,
2325 peppers the generated scanner
2326 with #line directives so error messages in the actions will be correctly
2327 located with respect to either the original
2329 input file (if the errors are due to code in the input file), or
2333 fault -- you should report these sorts of errors to the email address
2341 mode. It will generate a lot of messages to
2344 the form of the input and the resultant non-deterministic and deterministic
2345 finite automata. This option is mostly for use in maintaining
2349 prints the version number to
2359 to generate a 7-bit scanner, i.e., one which can only recognized 7-bit
2360 characters in its input. The advantage of using
2362 is that the scanner's tables can be up to half the size of those generated
2365 option (see below). The disadvantage is that such scanners often hang
2366 or crash if their input contains an 8-bit character.
2368 Note, however, that unless you generate your scanner using the
2372 table compression options, use of
2374 will save only a small amount of table space, and make your scanner
2375 considerably less portable.
2377 default behavior is to generate an 8-bit scanner unless you use the
2383 defaults to generating 7-bit scanners unless your site was always
2384 configured to generate 8-bit scanners (as will often be the case
2385 with non-USA sites). You can tell whether flex generated a 7-bit
2386 or an 8-bit scanner by inspecting the flag summary in the
2388 output as described above.
2390 Note that if you use
2394 (those table compression options, but also using equivalence classes as
2395 discussed see below), flex still defaults to generating an 8-bit
2396 scanner, since usually with these compression options full 8-bit tables
2397 are not much more expensive than 7-bit tables.
2402 to generate an 8-bit scanner, i.e., one which can recognize 8-bit
2403 characters. This flag is only needed for scanners generated using
2407 as otherwise flex defaults to generating an 8-bit scanner anyway.
2409 See the discussion of
2411 above for flex's default behavior and the tradeoffs between 7-bit
2415 specifies that you want flex to generate a C++
2416 scanner class. See the section on Generating C++ Scanners below for
2420 controls the degree of table compression and, more generally, trade-offs
2421 between small scanners and fast scanners.
2424 ("align") instructs flex to trade off larger tables in the
2425 generated scanner for faster performance because the elements of
2426 the tables are better aligned for memory access and computation. On some
2427 RISC architectures, fetching and manipulating longwords is more efficient
2428 than with smaller-sized units such as shortwords. This option can
2429 double the size of the tables used by your scanner.
2435 .I equivalence classes,
2436 i.e., sets of characters
2437 which have identical lexical properties (for example, if the only
2438 appearance of digits in the
2440 input is in the character class
2441 "[0-9]" then the digits '0', '1', ..., '9' will all be put
2442 in the same equivalence class). Equivalence classes usually give
2443 dramatic reductions in the final table/object file sizes (typically
2444 a factor of 2-5) and are pretty cheap performance-wise (one array
2445 look-up per character scanned).
2450 scanner tables should be generated -
2452 should not compress the
2453 tables by taking advantages of similar transition functions for
2457 specifies that the alternate fast scanner representation (described
2461 should be used. This option cannot be used with
2468 .I meta-equivalence classes,
2469 which are sets of equivalence classes (or characters, if equivalence
2470 classes are not being used) that are commonly used together. Meta-equivalence
2471 classes are often a big win when using compressed tables, but they
2472 have a moderate performance impact (one or two "if" tests and one
2473 array look-up per character scanned).
2476 causes the generated scanner to
2478 use of the standard I/O library (stdio) for input. Instead of calling
2482 the scanner will use the
2484 system call, resulting in a performance gain which varies from system
2485 to system, but in general is probably negligible unless you are also using
2491 can cause strange behavior if, for example, you read from
2493 using stdio prior to calling the scanner (because the scanner will miss
2494 whatever text your previous reads left in the stdio input buffer).
2497 has no effect if you define
2499 (see The Generated Scanner above).
2503 specifies that the scanner tables should be compressed but neither
2504 equivalence classes nor meta-equivalence classes should be used.
2512 do not make sense together - there is no opportunity for meta-equivalence
2513 classes if the table is not being compressed. Otherwise the options
2514 may be freely mixed, and are cumulative.
2516 The default setting is
2518 which specifies that
2520 should generate equivalence classes
2521 and meta-equivalence classes. This setting provides the highest
2522 degree of table compression. You can trade off
2523 faster-executing scanners at the cost of larger tables with
2524 the following generally being true:
2538 Note that scanners with the smallest tables are usually generated and
2539 compiled the quickest, so
2540 during development you will usually want to use the default, maximal
2544 is often a good compromise between speed and size for production
2548 directs flex to write the scanner to the file
2556 option, then the scanner is written to
2562 option above) refer to the file
2570 for all globally-visible variable and function names to instead be
2578 It also changes the name of the default output file from
2582 Here are all of the names affected:
2590 yy_load_buffer_state
2602 (If you are using a C++ scanner, then only
2607 Within your scanner itself, you can still refer to the global variables
2608 and functions using either version of their name; but externally, they
2609 have the modified name.
2611 This option lets you easily link together multiple
2613 programs into the same executable. Note, though, that using this
2619 provide your own (appropriately-named) version of the routine for your
2621 .B %option noyywrap,
2624 no longer provides one for you by default.
2627 overrides the default skeleton file from which
2629 constructs its scanners. You'll never need this option unless you are doing
2631 maintenance or development.
2634 also provides a mechanism for controlling options within the
2635 scanner specification itself, rather than from the flex command-line.
2636 This is done by including
2638 directives in the first section of the scanner specification.
2639 You can specify multiple options with a single
2641 directive, and multiple directives in the first section of your flex input
2644 Most options are given simply as names, optionally preceded by the
2645 word "no" (with no intervening whitespace) to negate their meaning.
2646 A number are equivalent to flex flags or their negation:
2657 case-sensitive opposite of -i (default)
2663 default opposite of -s option
2667 interactive -I option
2668 lex-compat -l option
2670 perf-report -p option
2674 warn opposite of -w option
2675 (use "%option nowarn" for -w)
2677 array equivalent to "%array"
2678 pointer equivalent to "%pointer" (default)
2683 provide features otherwise not available:
2685 .B always-interactive
2686 instructs flex to generate a scanner which always considers its input
2687 "interactive". Normally, on each new input file the scanner calls
2689 in an attempt to determine whether
2690 the scanner's input source is interactive and thus should be read a
2691 character at a time. When this option is used, however, then no
2695 directs flex to provide a default
2697 program for the scanner, which simply calls
2703 .B never-interactive
2704 instructs flex to generate a scanner which never considers its input
2705 "interactive" (again, no call made to
2707 This is the opposite of
2708 .B always-interactive.
2711 enables the use of start condition stacks (see Start Conditions above).
2724 instead of the default of
2728 programs depend on this behavior, even though it is not compliant with
2729 ANSI C, which does not require
2733 to be compile-time constant.
2738 to generate a scanner that maintains the number of the current line
2739 read from its input in the global variable
2741 This option is implied by
2742 .B %option lex-compat.
2746 .B %option noyywrap),
2747 makes the scanner not call
2749 upon an end-of-file, but simply assume that there are no more
2750 files to scan (until the user points
2752 at a new file and calls
2757 scans your rule actions to determine whether you use the
2765 options are available to override its decision as to whether you use the
2766 options, either by setting them (e.g.,
2768 to indicate the feature is indeed used, or
2769 unsetting them to indicate it actually is not used
2771 .B %option noyymore).
2773 Three options take string-delimited values, offset with '=':
2776 %option outfile="ABC"
2784 %option prefix="XYZ"
2792 %option yyclass="foo"
2795 only applies when generating a C++ scanner (
2799 that you have derived
2805 will place your actions in the member function
2808 .B yyFlexLexer::yylex().
2810 .B yyFlexLexer::yylex()
2811 member function that emits a run-time error (by invoking
2812 .B yyFlexLexer::LexerError())
2814 See Generating C++ Scanners, below, for additional information.
2816 A number of options are available for lint purists who want to suppress
2817 the appearance of unneeded routines in the generated scanner. Each of the
2821 ), results in the corresponding routine not appearing in
2822 the generated scanner:
2826 yy_push_state, yy_pop_state, yy_top_state
2827 yy_scan_buffer, yy_scan_bytes, yy_scan_string
2832 and friends won't appear anyway unless you use
2834 .SH PERFORMANCE CONSIDERATIONS
2835 The main design goal of
2837 is that it generate high-performance scanners. It has been optimized
2838 for dealing well with large sets of rules. Aside from the effects on
2839 scanner speed of the table compression
2841 options outlined above,
2842 there are a number of options/actions which degrade performance. These
2843 are, from most expensive to least:
2848 arbitrary trailing context
2850 pattern sets that require backing up
2853 %option always-interactive
2855 '^' beginning-of-line operator
2859 with the first three all being quite expensive and the last two
2860 being quite cheap. Note also that
2862 is implemented as a routine call that potentially does quite a bit of
2865 is a quite-cheap macro; so if just putting back some excess text you
2870 should be avoided at all costs when performance is important.
2871 It is a particularly expensive option.
2873 Getting rid of backing up is messy and often may be an enormous
2874 amount of work for a complicated scanner. In principal, one begins
2879 file. For example, on the input
2883 foo return TOK_KEYWORD;
2884 foobar return TOK_KEYWORD;
2887 the file looks like:
2890 State #6 is non-accepting -
2891 associated rule line numbers:
2893 out-transitions: [ o ]
2894 jam-transitions: EOF [ \\001-n p-\\177 ]
2896 State #8 is non-accepting -
2897 associated rule line numbers:
2899 out-transitions: [ a ]
2900 jam-transitions: EOF [ \\001-` b-\\177 ]
2902 State #9 is non-accepting -
2903 associated rule line numbers:
2905 out-transitions: [ r ]
2906 jam-transitions: EOF [ \\001-q s-\\177 ]
2908 Compressed tables always back up.
2911 The first few lines tell us that there's a scanner state in
2912 which it can make a transition on an 'o' but not on any other
2913 character, and that in that state the currently scanned text does not match
2914 any rule. The state occurs when trying to match the rules found
2915 at lines 2 and 3 in the input file.
2916 If the scanner is in that state and then reads
2917 something other than an 'o', it will have to back up to find
2918 a rule which is matched. With
2919 a bit of headscratching one can see that this must be the
2920 state it's in when it has seen "fo". When this has happened,
2921 if anything other than another 'o' is seen, the scanner will
2922 have to back up to simply match the 'f' (by the default rule).
2924 The comment regarding State #8 indicates there's a problem
2925 when "foob" has been scanned. Indeed, on any character other
2926 than an 'a', the scanner will have to back up to accept "foo".
2927 Similarly, the comment for State #9 concerns when "fooba" has
2928 been scanned and an 'r' does not follow.
2930 The final comment reminds us that there's no point going to
2931 all the trouble of removing backing up from the rules unless
2936 since there's no performance gain doing so with compressed scanners.
2938 The way to remove the backing up is to add "error" rules:
2942 foo return TOK_KEYWORD;
2943 foobar return TOK_KEYWORD;
2948 /* false alarm, not really a keyword */
2954 Eliminating backing up among a list of keywords can also be
2955 done using a "catch-all" rule:
2959 foo return TOK_KEYWORD;
2960 foobar return TOK_KEYWORD;
2962 [a-z]+ return TOK_ID;
2965 This is usually the best solution when appropriate.
2967 Backing up messages tend to cascade.
2968 With a complicated set of rules it's not uncommon to get hundreds
2969 of messages. If one can decipher them, though, it often
2970 only takes a dozen or so rules to eliminate the backing up (though
2971 it's easy to make a mistake and have an error rule accidentally match
2972 a valid token. A possible future
2974 feature will be to automatically add rules to eliminate backing up).
2976 It's important to keep in mind that you gain the benefits of eliminating
2977 backing up only if you eliminate
2979 instance of backing up. Leaving just one means you gain nothing.
2982 trailing context (where both the leading and trailing parts do not have
2983 a fixed length) entails almost the same performance loss as
2985 (i.e., substantial). So when possible a rule like:
2989 mouse|rat/(cat|dog) run();
2996 mouse/cat|dog run();
3004 mouse|rat/cat run();
3005 mouse|rat/dog run();
3008 Note that here the special '|' action does
3010 provide any savings, and can even make things worse (see
3011 Deficiencies / Bugs below).
3013 Another area where the user can increase a scanner's performance
3014 (and one that's easier to implement) arises from the fact that
3015 the longer the tokens matched, the faster the scanner will run.
3016 This is because with long tokens the processing of most input
3017 characters takes place in the (short) inner scanning loop, and
3018 does not often have to go through the additional work of setting up
3019 the scanning environment (e.g.,
3021 for the action. Recall the scanner for C comments:
3028 "/*" BEGIN(comment);
3031 <comment>"*"+[^*/\\n]*
3032 <comment>\\n ++line_num;
3033 <comment>"*"+"/" BEGIN(INITIAL);
3036 This could be sped up by writing it as:
3043 "/*" BEGIN(comment);
3046 <comment>[^*\\n]*\\n ++line_num;
3047 <comment>"*"+[^*/\\n]*
3048 <comment>"*"+[^*/\\n]*\\n ++line_num;
3049 <comment>"*"+"/" BEGIN(INITIAL);
3052 Now instead of each newline requiring the processing of another
3053 action, recognizing the newlines is "distributed" over the other rules
3054 to keep the matched text as long as possible. Note that
3058 slow down the scanner! The speed of the scanner is independent
3059 of the number of rules or (modulo the considerations given at the
3060 beginning of this section) how complicated the rules are with
3061 regard to operators such as '*' and '|'.
3063 A final example in speeding up a scanner: suppose you want to scan
3064 through a file containing identifiers and keywords, one per line
3065 and with no other extraneous characters, and recognize all the
3066 keywords. A natural first approach is:
3075 while /* it's a keyword */
3077 .|\\n /* it's not a keyword */
3080 To eliminate the back-tracking, introduce a catch-all rule:
3089 while /* it's a keyword */
3092 .|\\n /* it's not a keyword */
3095 Now, if it's guaranteed that there's exactly one word per line,
3096 then we can reduce the total number of matches by a half by
3097 merging in the recognition of newlines with that of the other
3107 while\\n /* it's a keyword */
3110 .|\\n /* it's not a keyword */
3113 One has to be careful here, as we have now reintroduced backing up
3114 into the scanner. In particular, while
3116 know that there will never be any characters in the input stream
3117 other than letters or newlines,
3119 can't figure this out, and it will plan for possibly needing to back up
3120 when it has scanned a token like "auto" and then the next character
3121 is something other than a newline or a letter. Previously it would
3122 then just match the "auto" rule and be done, but now it has no "auto"
3123 rule, only a "auto\\n" rule. To eliminate the possibility of backing up,
3124 we could either duplicate all rules but without final newlines, or,
3125 since we never expect to encounter such an input and therefore don't
3126 how it's classified, we can introduce one more catch-all rule, this
3127 one which doesn't include a newline:
3136 while\\n /* it's a keyword */
3140 .|\\n /* it's not a keyword */
3145 this is about as fast as one can get a
3147 scanner to go for this particular problem.
3151 is slow when matching NUL's, particularly when a token contains
3153 It's best to write rules which match
3155 amounts of text if it's anticipated that the text will often include NUL's.
3157 Another final note regarding performance: as mentioned above in the section
3158 How the Input is Matched, dynamically resizing
3160 to accommodate huge tokens is a slow process because it presently requires that
3161 the (huge) token be rescanned from the beginning. Thus if performance is
3162 vital, you should attempt to match "large" quantities of text but not
3163 "huge" quantities, where the cutoff between the two is at about 8K
3165 .SH GENERATING C++ SCANNERS
3167 provides two different ways to generate scanners for use with C++. The
3168 first way is to simply compile a scanner generated by
3170 using a C++ compiler instead of a C compiler. You should not encounter
3171 any compilations errors (please report any you find to the email address
3172 given in the Author section below). You can then use C++ code in your
3173 rule actions instead of C code. Note that the default input source for
3174 your scanner remains
3176 and default echoing is still done to
3178 Both of these remain
3180 variables and not C++
3185 to generate a C++ scanner class, using the
3187 option (or, equivalently,
3189 which is automatically specified if the name of the flex
3190 executable ends in a '+', such as
3192 When using this option, flex defaults to generating the scanner to the file
3196 The generated scanner includes the header file
3198 which defines the interface to two C++ classes.
3202 provides an abstract base class defining the general scanner class
3203 interface. It provides the following member functions:
3205 .B const char* YYText()
3206 returns the text of the most recently matched token, the equivalent of
3210 returns the length of the most recently matched token, the equivalent of
3213 .B int lineno() const
3214 returns the current input line number
3216 .B %option yylineno),
3223 .B void set_debug( int flag )
3224 sets the debugging flag for the scanner, equivalent to assigning to
3226 (see the Options section above). Note that you must build the scanner
3229 to include debugging information in it.
3231 .B int debug() const
3232 returns the current setting of the debugging flag.
3234 Also provided are member functions equivalent to
3235 .B yy_switch_to_buffer(),
3236 .B yy_create_buffer()
3237 (though the first argument is an
3239 object pointer and not a
3241 .B yy_flush_buffer(),
3242 .B yy_delete_buffer(),
3245 (again, the first argument is a
3249 The second class defined in
3253 which is derived from
3255 It defines the following additional member functions:
3258 yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 )
3261 object using the given streams for input and output. If not specified,
3262 the streams default to
3268 .B virtual int yylex()
3269 performs the same role is
3271 does for ordinary flex scanners: it scans the input stream, consuming
3272 tokens, until a rule's action returns a value. If you derive a subclass
3276 and want to access the member functions and variables of
3280 then you need to use
3281 .B %option yyclass="S"
3284 that you will be using that subclass instead of
3286 In this case, rather than generating
3287 .B yyFlexLexer::yylex(),
3291 (and also generates a dummy
3292 .B yyFlexLexer::yylex()
3294 .B yyFlexLexer::LexerError()
3298 virtual void switch_streams(istream* new_in = 0,
3300 ostream* new_out = 0)
3310 (ditto), deleting the previous input buffer if
3315 int yylex( istream* new_in, ostream* new_out = 0 )
3316 first switches the input streams via
3317 .B switch_streams( new_in, new_out )
3318 and then returns the value of
3323 defines the following protected virtual functions which you can redefine
3324 in derived classes to tailor the scanner:
3327 virtual int LexerInput( char* buf, int max_size )
3332 and returns the number of characters read. To indicate end-of-input,
3333 return 0 characters. Note that "interactive" scanners (see the
3337 flags) define the macro
3341 and need to take different actions depending on whether or not
3342 the scanner might be scanning an interactive input source, you can
3343 test for the presence of this name via
3347 virtual void LexerOutput( const char* buf, int size )
3350 characters from the buffer
3352 which, while NUL-terminated, may also contain "internal" NUL's if
3353 the scanner's rules can match text with NUL's in them.
3356 virtual void LexerError( const char* msg )
3357 reports a fatal error message. The default version of this function
3358 writes the message to the stream
3366 scanning state. Thus you can use such objects to create reentrant
3367 scanners. You can instantiate multiple instances of the same
3369 class, and you can also combine multiple C++ scanner classes together
3370 in the same program using the
3372 option discussed above.
3374 Finally, note that the
3376 feature is not available to C++ scanner classes; you must use
3380 Here is an example of a simple C++ scanner:
3383 // An example of using the flex C++ scanner class.
3389 string \\"[^\\n"]+\\"
3395 name ({alpha}|{dig}|\\$)({alpha}|{dig}|[_.\\-/$])*
3396 num1 [-+]?{dig}+\\.?([eE][-+]?{dig}+)?
3397 num2 [-+]?{dig}*\\.{dig}+([eE][-+]?{dig}+)?
3398 number {num1}|{num2}
3402 {ws} /* skip blanks and tabs */
3407 while((c = yyinput()) != 0)
3414 if((c = yyinput()) == '/')
3422 {number} cout << "number " << YYText() << '\\n';
3426 {name} cout << "name " << YYText() << '\\n';
3428 {string} cout << "string " << YYText() << '\\n';
3432 int main( int /* argc */, char** /* argv */ )
3434 FlexLexer* lexer = new yyFlexLexer;
3435 while(lexer->yylex() != 0)
3440 If you want to create multiple (different) lexer classes, you use the
3444 option) to rename each
3448 You then can include
3450 in your other sources once per lexer class, first renaming
3456 #define yyFlexLexer xxFlexLexer
3457 #include <FlexLexer.h>
3460 #define yyFlexLexer zzFlexLexer
3461 #include <FlexLexer.h>
3464 if, for example, you used
3465 .B %option prefix="xx"
3466 for one of your scanners and
3467 .B %option prefix="zz"
3470 IMPORTANT: the present form of the scanning class is
3472 and may change considerably between major releases.
3473 .SH INCOMPATIBILITIES WITH LEX AND POSIX
3475 is a rewrite of the AT&T Unix
3477 tool (the two implementations do not share any code, though),
3478 with some extensions and incompatibilities, both of which
3479 are of concern to those who wish to write scanners acceptable
3480 to either implementation. Flex is fully compliant with the POSIX
3482 specification, except that when using
3484 (the default), a call to
3486 destroys the contents of
3488 which is counter to the POSIX specification.
3490 In this section we discuss all of the known areas of incompatibility
3491 between flex, AT&T lex, and the POSIX specification.
3495 option turns on maximum compatibility with the original AT&T
3497 implementation, at the cost of a major loss in the generated scanner's
3498 performance. We note below which incompatibilities can be overcome
3504 is fully compatible with
3506 with the following exceptions:
3510 scanner internal variable
3512 is not supported unless
3519 should be maintained on a per-buffer basis, rather than a per-scanner
3520 (single global variable) basis.
3523 is not part of the POSIX specification.
3527 routine is not redefinable, though it may be called to read characters
3528 following whatever has been matched by a rule. If
3530 encounters an end-of-file the normal
3532 processing is done. A ``real'' end-of-file is returned by
3537 Input is instead controlled by defining the
3545 cannot be redefined is in accordance with the POSIX specification,
3546 which simply does not specify any way of controlling the
3547 scanner's input other than by making an initial assignment to
3552 routine is not redefinable. This restriction is in accordance with POSIX.
3555 scanners are not as reentrant as
3557 scanners. In particular, if you have an interactive scanner and
3558 an interrupt handler which long-jumps out of the scanner, and
3559 the scanner is subsequently called again, you may get the following
3563 fatal flex scanner internal error--end of buffer missed
3566 To reenter the scanner, first use
3572 Note that this call will throw away any buffered input; usually this
3573 isn't a problem with an interactive scanner.
3575 Also note that flex C++ scanner classes
3577 reentrant, so if using C++ is an option for you, you should use
3578 them instead. See "Generating C++ Scanners" above for details.
3584 macro is done to the file-pointer
3590 is not part of the POSIX specification.
3593 does not support exclusive start conditions (%x), though they
3594 are in the POSIX specification.
3596 When definitions are expanded,
3598 encloses them in parentheses.
3599 With lex, the following:
3604 foo{NAME}? printf( "Found it\\n" );
3608 will not match the string "foo" because when the macro
3609 is expanded the rule is equivalent to "foo[A-Z][A-Z0-9]*?"
3610 and the precedence is such that the '?' is associated with
3613 the rule will be expanded to
3614 "foo([A-Z][A-Z0-9]*)?" and so the string "foo" will match.
3616 Note that if the definition begins with
3622 expanded with parentheses, to allow these operators to appear in
3623 definitions without losing their special meanings. But the
3627 operators cannot be used in a
3635 behavior of no parentheses around the definition.
3637 The POSIX specification is that the definition be enclosed in parentheses.
3639 Some implementations of
3641 allow a rule's action to begin on a separate line, if the rule's pattern
3642 has trailing whitespace:
3647 { foobar_action(); }
3651 does not support this feature.
3656 (generate a Ratfor scanner) option is not supported. It is not part
3657 of the POSIX specification.
3662 is undefined until the next token is matched, unless the scanner
3665 This is not the case with
3667 or the POSIX specification. The
3669 option does away with this incompatibility.
3671 The precedence of the
3673 (numeric range) operator is different.
3675 interprets "abc{1,3}" as "match one, two, or
3676 three occurrences of 'abc'", whereas
3678 interprets it as "match 'ab'
3679 followed by one, two, or three occurrences of 'c'". The latter is
3680 in agreement with the POSIX specification.
3682 The precedence of the
3684 operator is different.
3686 interprets "^foo|bar" as "match either 'foo' at the beginning of a line,
3687 or 'bar' anywhere", whereas
3689 interprets it as "match either 'foo' or 'bar' if they come at the beginning
3690 of a line". The latter is in agreement with the POSIX specification.
3692 The special table-size declarations such as
3705 is #define'd so scanners may be written for use with either
3709 Scanners also include
3710 .B YY_FLEX_MAJOR_VERSION
3712 .B YY_FLEX_MINOR_VERSION
3713 indicating which version of
3715 generated the scanner
3716 (for example, for the 2.5 release, these defines would be 2 and 5
3721 features are not included in
3723 or the POSIX specification:
3728 start condition scopes
3729 start condition stacks
3730 interactive/non-interactive scanners
3731 yy_scan_string() and friends
3733 yy_set_interactive()
3743 %{}'s around actions
3744 multiple actions on a line
3747 plus almost all of the flex flags.
3748 The last feature in the list refers to the fact that with
3750 you can put multiple actions on the same line, separated with
3751 semi-colons, while with
3756 foo handle_foo(); ++num_foos_seen;
3759 is (rather surprisingly) truncated to
3766 does not truncate the action. Actions that are not enclosed in
3767 braces are simply terminated at the end of the line.
3770 .I warning, rule cannot be matched
3771 indicates that the given rule
3772 cannot be matched because it follows other rules that will
3773 always match the same text as it. For
3774 example, in the following "foo" cannot be matched because it comes after
3775 an identifier "catch-all" rule:
3778 [a-z]+ got_identifier();
3784 in a scanner suppresses this warning.
3789 option given but default rule can be matched
3790 means that it is possible (perhaps only in a particular start condition)
3791 that the default rule (match any single character) is the only one
3792 that will match a particular input. Since
3794 was given, presumably this is not intended.
3796 .I reject_used_but_not_detected undefined
3798 .I yymore_used_but_not_detected undefined -
3799 These errors can occur at compile time. They indicate that the
3806 failed to notice the fact, meaning that
3808 scanned the first two sections looking for occurrences of these actions
3809 and failed to find any, but somehow you snuck some in (via a #include
3810 file, for example). Use
3814 to indicate to flex that you really do use these features.
3816 .I flex scanner jammed -
3817 a scanner compiled with
3819 has encountered an input string which wasn't matched by
3820 any of its rules. This error can also occur due to internal problems.
3822 .I token too large, exceeds YYLMAX -
3825 and one of its rules matched a string longer than the
3827 constant (8K bytes by default). You can increase the value by
3830 in the definitions section of your
3834 .I scanner requires \-8 flag to
3835 .I use the character 'x' -
3836 Your scanner specification includes recognizing the 8-bit character
3838 and you did not specify the \-8 flag, and your scanner defaulted to 7-bit
3839 because you used the
3843 table compression options. See the discussion of the
3847 .I flex scanner push-back overflow -
3850 to push back so much text that the scanner's buffer could not hold
3851 both the pushed-back text and the current token in
3853 Ideally the scanner should dynamically resize the buffer in this case, but at
3854 present it does not.
3857 input buffer overflow, can't enlarge buffer because scanner uses REJECT -
3858 the scanner was working on matching an extremely large token and needed
3859 to expand the input buffer. This doesn't work with scanners that use
3864 fatal flex scanner internal error--end of buffer missed -
3865 This can occur in an scanner which is reentered after a long-jump
3866 has jumped out (or over) the scanner's activation frame. Before
3867 reentering the scanner, use:
3873 or, as noted above, switch to using the C++ scanner class.
3875 .I too many start conditions in <> construct! -
3876 you listed more start conditions in a <> construct than exist (so
3877 you must have listed at least one of them twice).
3881 library with which scanners must be linked.
3884 generated scanner (called
3889 generated C++ scanner class, when using
3893 header file defining the C++ scanner base class,
3895 and its derived class,
3899 skeleton scanner. This file is only used when building flex, not when
3903 backing-up information for
3908 .SH DEFICIENCIES / BUGS
3910 Some trailing context
3911 patterns cannot be properly matched and generate
3912 warning messages ("dangerous trailing context"). These are
3913 patterns where the ending of the
3914 first part of the rule matches the beginning of the second
3915 part, such as "zx*/xy*", where the 'x*' matches the 'x' at
3916 the beginning of the trailing context. (Note that the POSIX draft
3917 states that the text matched by such patterns is undefined.)
3919 For some trailing context rules, parts which are actually fixed-length are
3920 not recognized as such, leading to the abovementioned performance loss.
3921 In particular, parts using '|' or {n} (such as "foo{3}") are always
3922 considered variable-length.
3924 Combining trailing context with the special '|' action can result in
3926 trailing context being turned into the more expensive
3928 trailing context. For example, in the following:
3939 invalidates yytext and yyleng, unless the
3944 option has been used.
3946 Pattern-matching of NUL's is substantially slower than matching other
3949 Dynamic resizing of the input buffer is slow, as it entails rescanning
3950 all the text matched so far by the current (generally huge) token.
3952 Due to both buffering of input and read-ahead, you cannot intermix
3953 calls to <stdio.h> routines, such as, for example,
3957 rules and expect it to work. Call
3961 The total table entries listed by the
3963 flag excludes the number of table entries needed to determine
3964 what rule has been matched. The number of entries is equal
3965 to the number of DFA states if the scanner does not use
3967 and somewhat greater than the number of states if it does.
3970 cannot be used with the
3978 internal algorithms need documentation.
3981 lex(1), yacc(1), sed(1), awk(1).
3983 John Levine, Tony Mason, and Doug Brown,
3985 O'Reilly and Associates. Be sure to get the 2nd edition.
3987 M. E. Lesk and E. Schmidt,
3988 .I LEX \- Lexical Analyzer Generator
3990 Alfred Aho, Ravi Sethi and Jeffrey Ullman,
3991 .I Compilers: Principles, Techniques and Tools,
3992 Addison-Wesley (1986). Describes the pattern-matching techniques used by
3994 (deterministic finite automata).
3996 Vern Paxson, with the help of many ideas and much inspiration from
3997 Van Jacobson. Original version by Jef Poskanzer. The fast table
3998 representation is a partial implementation of a design done by Van
3999 Jacobson. The implementation was done by Kevin Gong and Vern Paxson.
4003 beta-testers, feedbackers, and contributors, especially Francois Pinard,
4006 Stan Adermann, Terry Allen, David Barker-Plummer, John Basrai,
4007 Neal Becker, Nelson H.F. Beebe, benson@odi.com,
4008 Karl Berry, Peter A. Bigot, Simon Blanchard,
4009 Keith Bostic, Frederic Brehm, Ian Brockbank, Kin Cho, Nick Christopher,
4010 Brian Clapper, J.T. Conklin,
4011 Jason Coughlin, Bill Cox, Nick Cropper, Dave Curtis, Scott David
4012 Daniels, Chris G. Demetriou, Theo Deraadt,
4013 Mike Donahue, Chuck Doucette, Tom Epperly, Leo Eskin,
4014 Chris Faylor, Chris Flatters, Jon Forrest, Jeffrey Friedl,
4015 Joe Gayda, Kaveh R. Ghazi, Wolfgang Glunz,
4016 Eric Goldman, Christopher M. Gould, Ulrich Grepel, Peer Griebel,
4017 Jan Hajic, Charles Hemphill, NORO Hideo,
4018 Jarkko Hietaniemi, Scott Hofmann,
4019 Jeff Honig, Dana Hudes, Eric Hughes, John Interrante,
4020 Ceriel Jacobs, Michal Jaegermann, Sakari Jalovaara, Jeffrey R. Jones,
4021 Henry Juengst, Klaus Kaempf, Jonathan I. Kamens, Terrence O Kane,
4022 Amir Katz, ken@ken.hilco.com, Kevin B. Kenny,
4023 Steve Kirsch, Winfried Koenig, Marq Kole, Ronald Lamprecht,
4024 Greg Lee, Rohan Lenard, Craig Leres, John Levine, Steve Liddle,
4025 David Loffredo, Mike Long,
4026 Mohamed el Lozy, Brian Madsen, Malte, Joe Marshall,
4027 Bengt Martensson, Chris Metcalf,
4028 Luke Mewburn, Jim Meyering, R. Alexander Milowski, Erik Naggum,
4029 G.T. Nicol, Landon Noll, James Nordby, Marc Nozell,
4030 Richard Ohnemus, Karsten Pahnke,
4031 Sven Panne, Roland Pesch, Walter Pelissero, Gaumond
4032 Pierre, Esmond Pitt, Jef Poskanzer, Joe Rahmeh, Jarmo Raiha,
4033 Frederic Raimbault, Pat Rankin, Rick Richardson,
4034 Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, Alberto Santini,
4035 Andreas Scherer, Darrell Schiebel, Raf Schietekat,
4036 Doug Schmidt, Philippe Schnoebelen, Andreas Schwab,
4037 Larry Schwimmer, Alex Siegel, Eckehard Stolz, Jan-Erik Strvmquist,
4038 Mike Stump, Paul Stuart, Dave Tallman, Ian Lance Taylor,
4039 Chris Thewalt, Richard M. Timoney, Jodi Tsai,
4040 Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams, Ken
4041 Yap, Ron Zellar, Nathan Zelle, David Zuhn,
4042 and those whose names have slipped my marginal
4043 mail-archiving skills but whose contributions are appreciated all the
4046 Thanks to Keith Bostic, Jon Forrest, Noah Friedman,
4047 John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T.
4048 Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various
4049 distribution headaches.
4051 Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to
4052 Benson Margulies and Fred Burke for C++ support; to Kent Williams and Tom
4053 Epperly for C++ class support; to Ove Ewerlid for support of NUL's; and to
4054 Eric Hughes for support of multiple buffers.
4056 This work was primarily done when I was with the Real Time Systems Group
4057 at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks to all there
4058 for the support I received.
4060 Send comments to vern@ee.lbl.gov.