Clean up deleted files.

This commit is contained in:
mycroft 1993-12-02 19:18:07 +00:00
parent 5bf99b7657
commit 228a208016
2 changed files with 0 additions and 1669 deletions

View File

@ -1,833 +0,0 @@
.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)lex.1 5.13 (Berkeley) 7/24/91
.\" $Id: lex.1,v 1.4 1993/08/06 19:41:44 mycroft Exp $
.\"
.Dd July 24, 1991
.Dt LEX 1
.Os
.Sh NAME
.Nm lex
.Nd fast lexical analyzer generator
.Sh SYNOPSIS
.Nm lex
.Oo
.Op Fl bcdfinpstvFILT8
.Fl C Ns Ns Op Cm efmF
.Fl S Ns Ns Ar skeleton
.Oc
.Op Ar
.Sh DESCRIPTION
.Nm Lex
is a tool for generating
.Ar scanners :
programs which recognized lexical patterns in text.
.Nm Lex
reads
the given input files, or its standard input if no file names are given,
for a description of a scanner to generate. The description is in
the form of pairs
of regular expressions and C code, called
.Em rules .
.Nm Lex
generates as output a C source file,
.Pa lex.yy.c ,
which defines a routine
.Fn yylex .
This file is compiled and linked with the
.Fl lfl
library to produce an executable. When the executable is run,
it analyzes its input for occurrences
of the regular expressions. Whenever it finds one, it executes
the corresponding C code.
.Pp
For full documentation, see
.Em Lexdoc .
This manual entry is intended for use as a quick reference.
.Sh OPTIONS
.Nm Lex
has the following options:
.Bl -tag -width Ds
.It Fl b
Generate backtracking information to
.Va lex.backtrack .
This is a list of scanner states which require backtracking
and the input characters on which they do so. By adding rules one
can remove backtracking states. If all backtracking states
are eliminated and
.Fl f
or
.Fl F
is used, the generated scanner will run faster.
.It Fl c
is a do-nothing, deprecated option included for
.Tn POSIX
compliance.
.Pp
.Ar NOTE :
in previous releases of
.Nm Lex
.Op Fl c
specified table-compression options. This functionality is
now given by the
.Fl C
flag. To ease the the impact of this change, when
.Nm lex
encounters
.Fl c,
it currently issues a warning message and assumes that
.Fl C
was desired instead. In the future this "promotion" of
.Fl c
to
.Fl C
will go away in the name of full
.Tn POSIX
compliance (unless
the
.Tn POSIX
meaning is removed first).
.It Fl d
Makes the generated scanner run in
.Ar debug
mode. Whenever a pattern is recognized and the global
.Va yy_Lex_debug
is non-zero (which is the default), the scanner will
write to
.Li stderr
a line of the form:
.Pp
.Dl --accepting rule at line 53 ("the matched text")
.Pp
The line number refers to the location of the rule in the file
defining the scanner (i.e., the file that was fed to lex). Messages
are also generated when the scanner backtracks, accepts the
default rule, reaches the end of its input buffer (or encounters
a
.Tn NUL ;
the two look the same as far as the scanner's concerned),
or reaches an end-of-file.
.It Fl f
Specifies (take your pick)
.Em full table
or
.Em fast scanner .
No table compression is done. The result is large but fast.
This option is equivalent to
.Fl Cf
(see below).
.It Fl i
Instructs
.Nm lex
to generate a
.Em case-insensitive
scanner. The case of letters given in the
.Nm lex
input patterns will
be ignored, and tokens in the input will be matched regardless of case. The
matched text given in
.Va yytext
will have the preserved case (i.e., it will not be folded).
.It Fl n
Is another do-nothing, deprecated option included only for
.Tn POSIX
compliance.
.It Fl p
Generates a performance report to stderr. The report
consists of comments regarding features of the
.Nm lex
input file which will cause a loss of performance in the resulting scanner.
.It Fl s
Causes the
.Ar default rule
(that unmatched scanner input is echoed to
.Ar stdout )
to be suppressed. If the scanner encounters input that does not
match any of its rules, it aborts with an error.
.It Fl t
Instructs
.Nm lex
to write the scanner it generates to standard output instead
of
.Pa lex.yy.c .
.It Fl v
Specifies that
.Nm lex
should write to
.Li stderr
a summary of statistics regarding the scanner it generates.
.It Fl F
Specifies that the
.Em fast
scanner table representation should be used. This representation is
about as fast as the full table representation
.Pq Fl f ,
and for some sets of patterns will be considerably smaller (and for
others, larger). See
.Em Lexdoc
for details.
.Pp
This option is equivalent to
.Fl CF
(see below).
.It Fl I
Instructs
.Nm lex
to generate an
.Em interactive
scanner, that is, a scanner which stops immediately rather than
looking ahead if it knows
that the currently scanned text cannot be part of a longer rule's match.
Again, see
.Em Lexdoc
for details.
.Pp
Note,
.Fl I
cannot be used in conjunction with
.Em full
or
.Em fast tables ,
i.e., the
.Fl f , F , Cf ,
or
.Fl CF
flags.
.It Fl L
Instructs
.Nm lex
not to generate
.Li #line
directives in
.Pa lex.yy.c .
The default is to generate such directives so error
messages in the actions will be correctly
located with respect to the original
.Nm lex
input file, and not to
the fairly meaningless line numbers of
.Pa lex.yy.c .
.It Fl T
Makes
.Nm lex
run in
.Em trace
mode. It will generate a lot of messages to
.Li stdout
concerning
the form of the input and the resultant non-deterministic and deterministic
finite automata. This option is mostly for use in maintaining
.Nm lex .
.It Fl 8
Instructs
.Nm lex
to generate an 8-bit scanner.
On some sites, this is the default. On others, the default
is 7-bit characters. To see which is the case, check the verbose
.Pq Fl v
output for "equivalence classes created". If the denominator of
the number shown is 128, then by default
.Nm lex
is generating 7-bit characters. If it is 256, then the default is
8-bit characters.
.It Fl C Ns Op Cm efmF
Controls the degree of table compression. The default setting is
.Fl Cem .
.Pp
.Bl -tag -width Ds
.It Fl C
A lone
.Fl C
specifies that the scanner tables should be compressed but neither
equivalence classes nor meta-equivalence classes should be used.
.It Fl \&Ce
Directs
.Nm lex
to construct
.Em equivalence classes ,
i.e., sets of characters
which have identical lexical properties.
Equivalence classes usually give
dramatic reductions in the final table/object file sizes (typically
a factor of 2-5) and are pretty cheap performance-wise (one array
look-up per character scanned).
.It Fl \&Cf
Specifies that the
.Em full
scanner tables should be generated -
.Nm lex
should not compress the
tables by taking advantages of similar transition functions for
different states.
.It Fl \&CF
Specifies that the alternate fast scanner representation (described in
.Em Lexdoc )
should be used.
.It Fl \&Cm
Directs
.Nm lex
to construct
.Em meta-equivalence classes ,
which are sets of equivalence classes (or characters, if equivalence
classes are not being used) that are commonly used together. Meta-equivalence
classes are often a big win when using compressed tables, but they
have a moderate performance impact (one or two "if" tests and one
array look-up per character scanned).
.It Fl Cem
(Default)
Generate both equivalence classes
and meta-equivalence classes. This setting provides the highest
degree of table compression.
.El
.Pp
Faster-executing scanners can be traded off at the
cost of larger tables with
the following generally being true:
.Bd -ragged -offset center
slowest & smallest
-Cem
-Cm
-Ce
-C
-C{f,F}e
-C{f,F}
fastest & largest
.Ed
.Pp
.Fl C
options are not cumulative; whenever the flag is encountered, the
previous -C settings are forgotten.
.Pp
The options
.Fl \&Cf
or
.Fl \&CF
and
.Fl \&Cm
do not make sense together - there is no opportunity for meta-equivalence
classes if the table is not being compressed. Otherwise the options
may be freely mixed.
.It Fl S Ns Ar skeleton_file
Overrides the default skeleton file from which
.Nm lex
constructs its scanners. Useful for
.Nm lex
maintenance or development.
.El
.Sh SUMMARY OF LEX REGULAR EXPRESSIONS
The patterns in the input are written using an extended set of regular
expressions. These are:
.Pp
.Bl -tag -width 10n -compact
.It Li x
Match the character 'x'.
.It Li \&.
Any character except newline.
.It Op Li xyz
A "character class"; in this case, the pattern
matches either an 'x', a 'y', or a 'z'.
.It Op Li abj-oZ
A "character class" with a range in it; matches
an 'a', a 'b', any letter from 'j' through 'o',
or a 'Z'.
.It Op Li ^A-Z
A "negated character class", i.e., any character
but those in the class. In this case, any
character
.Em except
an uppercase letter.
.It Op Li ^A-Z\en
Any character
.Em except
an uppercase letter or
a newline.
.It Li r*
Zero or more r's, where r is any regular expression.
.It Li r+
One or more r's.
.It Li r?
Zero or one r's (that is, "an optional r").
.It Li r{2,5}
Anywhere from two to five r's.
.It Li r{2,}
Two or more r's.
.It Li r{4}
Exactly 4 r's.
.It Li {name}
The expansion of the "name" definition
(see above).
.It Xo
.Oo Li xyz Oc Ns Li "\e\&\*qfoo"
.Xc
The literal string:
[xyz]\*qfoo.
.It Li \&\eX
If X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v',
then the
.Tn ANSI-C
interpretation of \ex.
Otherwise, a literal 'X' (used to escape
operators such as '*').
.It Li \&\e123
The character with octal value 123.
.It Li \&\ex2a
The character with hexadecimal value 2a.
.It Li (r)
Match an r; parentheses are used to override
precedence (see below).
.It Li rs
The regular expression r followed by the
regular expression s; called "concatenation".
.It Li rs
Either an r or an s.
.It Li r/s
An r but only if it is followed by an s. The
s is not part of the matched text. This type
of pattern is called as "trailing context".
.It Li \&^r
An r, but only at the beginning of a line.
.It Li r$
An r, but only at the end of a line. Equivalent
to "r/\en".
.It Li <s>r
An r, but only in start condition s (see
below for discussion of start conditions).
.It Li <s1,s2,s3>r
Same, but in any of start conditions s1,
s2, or s3.
.It Li <<EOF>>
An end-of-file.
.It Li <s1,s2><<EOF>>
An end-of-file when in start condition s1 or s2.
.El
The regular expressions listed above are grouped according to
precedence, from highest precedence at the top to lowest at the bottom.
Those grouped together have equal precedence.
.Pp
Some notes on patterns:
.Pp
Negated character classes
.Ar match newlines
unless "\en" (or an equivalent escape sequence) is one of the
characters explicitly present in the negated character class
(e.g., " [^A-Z\en] ").
.Pp
A rule can have at most one instance of trailing context (the '/' operator
or the '$' operator). The start condition, '^', and "<<EOF>>" patterns
can only occur at the beginning of a pattern, and, as well as with '/' and '$',
cannot be grouped inside parentheses. The following are all illegal:
.Pp
.Bd -literal -offset indent
foo/bar$
foo(bar$)
foo^bar
<sc1>foo<sc2>bar
.Ed
.Sh SUMMARY OF SPECIAL ACTIONS
In addition to arbitrary C code, the following can appear in actions:
.Bl -tag -width Fl
.It Ic ECHO
Copies
.Va yytext
to the scanner's output.
.It Ic BEGIN
Followed by the name of a start condition places the scanner in the
corresponding start condition.
.It Ic REJECT
Directs the scanner to proceed on to the "second best" rule which matched the
input (or a prefix of the input).
.Va yytext
and
.Va yyleng
are set up appropriately. Note that
.Ic REJECT
is a particularly expensive feature in terms scanner performance;
if it is used in
.Em any
of the scanner's actions it will slow down
.Em all
of the scanner's matching. Furthermore,
.Ic REJECT
cannot be used with the
.Fl f
or
.Fl F
options.
.Pp
Note also that unlike the other special actions,
.Ic REJECT
is a
.Em branch ;
code immediately following it in the action will
.Em not
be executed.
.It Fn yymore
tells the scanner that the next time it matches a rule, the corresponding
token should be
.Em appended
onto the current value of
.Va yytext
rather than replacing it.
.It Fn yyless \&n
returns all but the first
.Ar n
characters of the current token back to the input stream, where they
will be rescanned when the scanner looks for the next match.
.Va yytext
and
.Va yyleng
are adjusted appropriately (e.g.,
.Va yyleng
will now be equal to
.Ar n ) .
.It Fn unput c
puts the character
.Ar c
back onto the input stream. It will be the next character scanned.
.It Fn input
reads the next character from the input stream (this routine is called
.Fn yyinput
if the scanner is compiled using
.Em C \&+\&+ ) .
.It Fn yyterminate
can be used in lieu of a return statement in an action. It terminates
the scanner and returns a 0 to the scanner's caller, indicating "all done".
.Pp
By default,
.Fn yyterminate
is also called when an end-of-file is encountered. It is a macro and
may be redefined.
.It Ic YY_NEW_FILE
is an action available only in <<EOF>> rules. It means "Okay, I've
set up a new input file, continue scanning".
.It Fn yy_create_buffer file size
takes a
.Ic FILE
pointer and an integer
.Ar size .
It returns a YY_BUFFER_STATE
handle to a new input buffer large enough to accomodate
.Ar size
characters and associated with the given file. When in doubt, use
.Ar YY_BUF_SIZE
for the size.
.It Fn yy_switch_to_buffer new_buffer
switches the scanner's processing to scan for tokens from
the given buffer, which must be a YY_BUFFER_STATE.
.It Fn yy_delete_buffer buffer
deletes the given buffer.
.El
.Sh VALUES AVAILABLE TO THE USER
.Bl -tag -width Fl
.It Va char \&*yytext
holds the text of the current token. It may not be modified.
.It Va int yyleng
holds the length of the current token. It may not be modified.
.It Va FILE \&*yyin
is the file which by default
.Nm lex
reads from. It may be redefined but doing so only makes sense before
scanning begins. Changing it in the middle of scanning will have
unexpected results since
.Nm lex
buffers its input. Once scanning terminates because an end-of-file
has been seen,
.Fn "void yyrestart" "FILE *new_file"
may be called to point
.Va yyin
at the new input file.
.It Va FILE \&*yyout
is the file to which
.Ar ECHO
actions are done. It can be reassigned by the user.
.It Va YY_CURRENT_BUFFER
returns a
YY_BUFFER_STATE
handle to the current buffer.
.El
.Sh MACROS THE USER CAN REDEFINE
.Bl -tag -width Fl
.It Va YY_DECL
controls how the scanning routine is declared.
By default, it is "int yylex()", or, if prototypes are being
used, "int yylex(void)". This definition may be changed by redefining
the "YY_DECL" macro. Note that
if you give arguments to the scanning routine using a
K&R-style/non-prototyped function declaration, you must terminate
the definition with a semi-colon (;).
.It Va YY_INPUT
The nature of how the scanner
gets its input can be controlled by redefining the
YY_INPUT
macro.
YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its
action is to place up to
.Ar max _size
characters in the character array
.Ar buf
and return in the integer variable
.Ar result
either the
number of characters read or the constant YY_NULL (0 on Unix systems)
to indicate EOF. The default YY_INPUT reads from the
global file-pointer "yyin".
A sample redefinition of YY_INPUT (in the definitions
section of the input file):
.Bd -literal -offset indent
%{
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \e
result = ((buf[0] = getchar()) == EOF) ? YY_NULL : 1;
%}
.Ed
.It Va YY_INPUT
When the scanner receives an end-of-file indication from YY_INPUT,
it then checks the
.Fn yywrap
function. If
.Fn yywrap
returns false (zero), then it is assumed that the
function has gone ahead and set up
.Va yyin
to point to another input file, and scanning continues. If it returns
true (non-zero), then the scanner terminates, returning 0 to its
caller.
.It Va yywrap
The default
.Fn yywrap
always returns 1. Presently, to redefine it you must first
"#undef yywrap", as it is currently implemented as a macro. It is
likely that
.Fn yywrap
will soon be defined to be a function rather than a macro.
.It Va YY_USER_ACTION
can be redefined to provide an action
which is always executed prior to the matched rule's action.
.It Va YY_USER_INIT
The macro
.Va YY _USER_INIT
may be redefined to provide an action which is always executed before
the first scan.
.It Va YY_BREAK
In the generated scanner, the actions are all gathered in one large
switch statement and separated using
.Va YY _BREAK ,
which may be redefined. By default, it is simply a "break", to separate
each rule's action from the following rule's.
.El
.Sh FILES
.Bl -tag -width lex.backtrack -compact
.It Pa lex.skel
skeleton scanner.
.It Pa lex.yy.c
generated scanner
(called
.Pa lexyy.c
on some systems).
.It Pa lex.backtrack
backtracking information for
.Fl b
.It Pa flag
(called
.Pa lex.bck
on some systems).
.El
.Sh SEE ALSO
.Xr lex 1 ,
.Xr yacc 1 ,
.Xr sed 1 ,
.Xr awk 1 .
.Rs
.%T "lexdoc"
.Re
.Rs
.%A M. E. Lesk
.%A E. Schmidt
.%T "LEX \- Lexical Analyzer Generator"
.Re
.Sh DIAGNOSTICS
.Bl -tag -width Fl
.It Li reject_used_but_not_detected undefined
or
.It Li yymore_used_but_not_detected undefined
These errors can occur at compile time.
They indicate that the
scanner uses
.Ic REJECT
or
.Fn yymore
but that
.Nm lex
failed to notice the fact,
meaning that
.Nm lex
scanned the first two sections looking for occurrences of these actions
and failed to find any,
but somehow you snuck some in via a #include
file,
for example .
Make an explicit reference to the action in your
.Nm lex
input file.
Note that previously
.Nm lex
supported a
.Li %used/%unused
mechanism for dealing with this problem;
this feature is still supported
but now deprecated,
and will go away soon unless the author hears from
people who can argue compellingly that they need it.
.It Li lex scanner jammed
a scanner compiled with
.Fl s
has encountered an input string which wasn't matched by
any of its rules.
.It Li lex input buffer overflowed
a scanner rule matched a string long enough to overflow the
scanner's internal input buffer 16K bytes - controlled by
.Va YY_BUF_MAX
in
.Pa lex.skel .
.It Li scanner requires \&\-8 flag
Your scanner specification includes recognizing 8-bit characters and
you did not specify the -8 flag and your site has not installed lex
with -8 as the default .
.It Li too many \&%t classes!
You managed to put every single character into its own %t class.
.Nm Lex
requires that at least one of the classes share characters.
.El
.Sh HISTORY
A
.Nm lex
appeared in
.At v6 .
The version this man page describes is
derived from code contributed by Vern Paxson.
.Sh AUTHOR
Vern Paxson, with the help of many ideas and much inspiration from
Van Jacobson. Original version by Jef Poskanzer.
.Pp
See
.%T "Lexdoc"
for additional credits and the address to send comments to.
.Sh BUGS
.Pp
Some trailing context
patterns cannot be properly matched and generate
warning messages ("Dangerous trailing context"). These are
patterns where the ending of the
first part of the rule matches the beginning of the second
part, such as "zx*/xy*", where the 'x*' matches the 'x' at
the beginning of the trailing context. (Note that the
.Tn POSIX
draft
states that the text matched by such patterns is undefined.)
.Pp
For some trailing context rules, parts which are actually fixed-length are
not recognized as such, leading to the abovementioned performance loss.
In particular, parts using '\&|' or {n} (such as "foo{3}") are always
considered variable-length.
.Pp
Combining trailing context with the special '\&|' action can result in
.Em fixed
trailing context being turned into the more expensive
.Em variable
trailing context. This happens in the following example:
.Bd -literal -offset indent
%%
abc \&|
xyz/def
.Ed
.Pp
Use of
.Fn unput
invalidates yytext and yyleng.
.Pp
Use of
.Fn unput
to push back more text than was matched can
result in the pushed-back text matching a beginning-of-line ('^')
rule even though it didn't come at the beginning of the line
(though this is rare!).
.Pp
Pattern-matching of
.Tn NUL Ns 's
is substantially slower than matching other
characters.
.Pp
.Nm Lex
does not generate correct #line directives for code internal
to the scanner; thus, bugs in
.Pa lex.skel
yield bogus line numbers.
.Pp
Due to both buffering of input and read-ahead, you cannot intermix
calls to
.Aq Pa stdio.h
routines, such as, for example,
.Fn getchar ,
with
.Nm lex
rules and expect it to work. Call
.Fn input
instead.
.Pp
The total table entries listed by the
.Fl v
flag excludes the number of table entries needed to determine
what rule has been matched. The number of entries is equal
to the number of
.Tn DFA
states if the scanner does not use
.Ic REJECT ,
and somewhat greater than the number of states if it does.
.Pp
.Ic REJECT
cannot be used with the
.Fl f
or
.Fl F
options.
.Pp
Some of the macros, such as
.Fn yywrap ,
may in the future become functions which live in the
.Fl lfl
library. This will doubtless break a lot of code, but may be
required for
.Tn POSIX Ns \-compliance .
.Pp
The
.Nm lex
internal algorithms need documentation.

View File

@ -1,836 +0,0 @@
/* A lexical scanner generated by flex */
/* scanner skeleton version:
* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/lex.skel,v 1.3 1993/11/19 05:11:46 cgd Exp $
*/
#define FLEX_SCANNER
#include <stdio.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif
#ifdef __cplusplus
#include <stdlib.h>
#include <osfcn.h>
/* use prototypes in function declarations */
#define YY_USE_PROTOS
/* the "const" storage-class-modifier is valid */
#define YY_USE_CONST
#else /* ! __cplusplus */
#ifdef __STDC__
#ifdef __GNUC__
#include <stddef.h>
void *malloc( size_t );
void free( void* );
#else
#include <stdlib.h>
#endif /* __GNUC__ */
#define YY_USE_PROTOS
#define YY_USE_CONST
#endif /* __STDC__ */
#endif /* ! __cplusplus */
#ifdef __TURBOC__
#define YY_USE_CONST
#endif
#ifndef YY_USE_CONST
#define const
#endif
#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
#else
#define YY_PROTO(proto) ()
/* we can't get here if it's an ANSI C compiler, or a C++ compiler,
* so it's got to be a K&R compiler, and therefore there's no standard
* place from which to include these definitions
*/
char *malloc();
int free();
#endif
/* amount of stuff to slurp up with each read */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif
/* returned upon end-of-file */
#define YY_END_TOK 0
/* copy whatever the last rule matched to the standard output */
/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
/* this used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite()
*/
#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
/* gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
#define YY_INPUT(buf,result,max_size) \
if ( ((result = fread( (char *) buf, 1, max_size, yyin )) == 0 ) && \
ferror(yyin) ) \
YY_FATAL_ERROR( "fread() in flex scanner failed" );
#define YY_NULL 0
/* no semi-colon after return; correct usage is to write "yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
*/
#define yyterminate() return ( YY_NULL )
/* report a fatal error */
/* The funky do-while is used to turn this macro definition into
* a single C statement (which needs a semi-colon terminator).
* This avoids problems with code like:
*
* if ( something_happens )
* YY_FATAL_ERROR( "oops, the something happened" );
* else
* everything_okay();
*
* Prior to using the do-while the compiler would get upset at the
* "else" because it interpreted the "if" statement as being all
* done when it reached the ';' after the YY_FATAL_ERROR() call.
*/
#define YY_FATAL_ERROR(msg) \
do \
{ \
(void) fputs( msg, stderr ); \
(void) putc( '\n', stderr ); \
exit( 1 ); \
} \
while ( 0 )
/* default yywrap function - always treat EOF as an EOF */
#define yywrap() 1
/* enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN
*/
#define BEGIN yy_start = 1 + 2 *
/* action number for EOF rule of a given start state */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* special action meaning "start processing a new file" */
#define YY_NEW_FILE \
do \
{ \
yy_init_buffer( yy_current_buffer, yyin ); \
yy_load_buffer_state(); \
} \
while ( 0 )
/* default declaration of generated scanner - a define so the user can
* easily add parameters
*/
#define YY_DECL int yylex YY_PROTO(( void ))
/* code executed at the end of each rule */
#define YY_BREAK break;
#define YY_END_OF_BUFFER_CHAR 0
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
#endif
typedef struct yy_buffer_state *YY_BUFFER_STATE;
%% section 1 definitions go here
/* done after the current pattern has been matched and before the
* corresponding action - sets up yytext
*/
#define YY_DO_BEFORE_ACTION \
yytext = yy_bp; \
%% code to fiddle yytext and yyleng for yymore() goes here
yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yy_c_buf_p = yy_cp;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
/* return all but the first 'n' matched characters back to the input stream */
#define yyless(n) \
do \
{ \
/* undo effects of setting up yytext */ \
*yy_cp = yy_hold_char; \
yy_c_buf_p = yy_cp = yy_bp + n; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
#define unput(c) yyunput( c, yytext )
struct yy_buffer_state
{
FILE *yy_input_file;
YY_CHAR *yy_ch_buf; /* input buffer */
YY_CHAR *yy_buf_pos; /* current position in input buffer */
/* size of input buffer in bytes, not including room for EOB characters */
int yy_buf_size;
/* number of characters read into yy_ch_buf, not including EOB characters */
int yy_n_chars;
int yy_eof_status; /* whether we've seen an EOF on this buffer */
#define EOF_NOT_SEEN 0
/* "pending" happens when the EOF has been seen but there's still
* some text process
*/
#define EOF_PENDING 1
#define EOF_DONE 2
};
static YY_BUFFER_STATE yy_current_buffer;
/* we provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state"
*/
#define YY_CURRENT_BUFFER yy_current_buffer
/* yy_hold_char holds the character lost when yytext is formed */
static YY_CHAR yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
#ifndef YY_USER_INIT
#define YY_USER_INIT
#endif
extern YY_CHAR *yytext;
extern int yyleng;
extern FILE *yyin, *yyout;
YY_CHAR *yytext;
int yyleng;
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
%% data tables for the DFA go here
/* these variables are all declared out here so that section 3 code can
* manipulate them
*/
/* points to current character in buffer */
static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
static int yy_init = 1; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
/* flag which is used to allow yywrap()'s to do buffer switches
* instead of setting up a fresh yyin. A bit of a hack ...
*/
static int yy_did_buffer_switch_on_eof;
static yy_state_type yy_get_previous_state YY_PROTO(( void ));
static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
static int yy_get_next_buffer YY_PROTO(( void ));
static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
void yyrestart YY_PROTO(( FILE *input_file ));
void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
void yy_load_buffer_state YY_PROTO(( void ));
YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
#define yy_new_buffer yy_create_buffer
#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
YY_DECL
{
register yy_state_type yy_current_state;
register YY_CHAR *yy_cp, *yy_bp;
register int yy_act;
%% user's declarations go here
if ( yy_init )
{
YY_USER_INIT;
if ( ! yy_start )
yy_start = 1; /* first start state */
if ( ! yyin )
yyin = stdin;
if ( ! yyout )
yyout = stdout;
if ( yy_current_buffer )
yy_init_buffer( yy_current_buffer, yyin );
else
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
yy_load_buffer_state();
yy_init = 0;
}
while ( 1 ) /* loops until end-of-file is reached */
{
%% yymore()-related code goes here
yy_cp = yy_c_buf_p;
/* support of yytext */
*yy_cp = yy_hold_char;
/* yy_bp points to the position in yy_ch_buf of the start of the
* current run.
*/
yy_bp = yy_cp;
%% code to set up and find next match goes here
yy_find_action:
%% code to find the action number goes here
YY_DO_BEFORE_ACTION;
YY_USER_ACTION;
do_action: /* this label is used only to access EOF actions */
%% debug code goes here
switch ( yy_act )
{
%% actions go here
case YY_END_OF_BUFFER:
{
/* amount of text matched not including the EOB char */
int yy_amount_of_matched_text = yy_cp - yytext - 1;
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = yy_hold_char;
/* note that here we test for yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the end-
* of-buffer state). Contrast this with the test in yyinput().
*/
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
/* this was really a NUL */
{
yy_state_type yy_next_state;
yy_c_buf_p = yytext + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state();
/* okay, we're now positioned to make the
* NUL transition. We couldn't have
* yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we
* don't want to build jamming into it because
* then it will run more slowly)
*/
yy_next_state = yy_try_NUL_trans( yy_current_state );
yy_bp = yytext + YY_MORE_ADJ;
if ( yy_next_state )
{
/* consume the NUL */
yy_cp = ++yy_c_buf_p;
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
%% code to do backtracking for compressed tables and set up yy_cp goes here
goto yy_find_action;
}
}
else switch ( yy_get_next_buffer() )
{
case EOB_ACT_END_OF_FILE:
{
yy_did_buffer_switch_on_eof = 0;
if ( yywrap() )
{
/* note: because we've taken care in
* yy_get_next_buffer() to have set up yytext,
* we can now set up yy_c_buf_p so that if some
* total hoser (like flex itself) wants
* to call the scanner after we return the
* YY_NULL, it'll still work - another YY_NULL
* will get returned.
*/
yy_c_buf_p = yytext + YY_MORE_ADJ;
yy_act = YY_STATE_EOF((yy_start - 1) / 2);
goto do_action;
}
else
{
if ( ! yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
}
}
break;
case EOB_ACT_CONTINUE_SCAN:
yy_c_buf_p = yytext + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state();
yy_cp = yy_c_buf_p;
yy_bp = yytext + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
yy_c_buf_p =
&yy_current_buffer->yy_ch_buf[yy_n_chars];
yy_current_state = yy_get_previous_state();
yy_cp = yy_c_buf_p;
yy_bp = yytext + YY_MORE_ADJ;
goto yy_find_action;
}
break;
}
default:
#ifdef FLEX_DEBUG
printf( "action # %d\n", yy_act );
#endif
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
}
}
}
/* yy_get_next_buffer - try to read in a new buffer
*
* synopsis
* int yy_get_next_buffer();
*
* returns a code representing an action
* EOB_ACT_LAST_MATCH -
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
static int yy_get_next_buffer()
{
register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
register int number_to_move, i;
int ret_val;
if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
/* try to read more data */
/* first move last chars to start of buffer */
number_to_move = yy_c_buf_p - yytext;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
yy_n_chars = 0;
else
{
int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
else if ( num_to_read <= 0 )
YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
/* read in more data */
YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
yy_n_chars, num_to_read );
}
if ( yy_n_chars == 0 )
{
if ( number_to_move - YY_MORE_ADJ == 1 )
{
ret_val = EOB_ACT_END_OF_FILE;
yy_current_buffer->yy_eof_status = EOF_DONE;
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
yy_current_buffer->yy_eof_status = EOF_PENDING;
}
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
yy_n_chars += number_to_move;
yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
/* yytext begins at the second character in yy_ch_buf; the first
* character is the one which preceded it before reading in the latest
* buffer; it needs to be kept around in case it's a newline, so
* yy_get_previous_state() will have with '^' rules active
*/
yytext = &yy_current_buffer->yy_ch_buf[1];
return ( ret_val );
}
/* yy_get_previous_state - get the state just before the EOB char was reached
*
* synopsis
* yy_state_type yy_get_previous_state();
*/
static yy_state_type yy_get_previous_state()
{
register yy_state_type yy_current_state;
register YY_CHAR *yy_cp;
%% code to get the start state into yy_current_state goes here
for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
{
%% code to find the next state goes here
}
return ( yy_current_state );
}
/* yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
#ifdef YY_USE_PROTOS
static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
#else
static yy_state_type yy_try_NUL_trans( yy_current_state )
register yy_state_type yy_current_state;
#endif
{
register int yy_is_jam;
%% code to find the next state, and perhaps do backtracking, goes here
return ( yy_is_jam ? 0 : yy_current_state );
}
#ifdef YY_USE_PROTOS
static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
#else
static void yyunput( c, yy_bp )
YY_CHAR c;
register YY_CHAR *yy_bp;
#endif
{
register YY_CHAR *yy_cp = yy_c_buf_p;
/* undo effects of setting up yytext */
*yy_cp = yy_hold_char;
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
register YY_CHAR *dest =
&yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
register YY_CHAR *source =
&yy_current_buffer->yy_ch_buf[number_to_move];
while ( source > yy_current_buffer->yy_ch_buf )
*--dest = *--source;
yy_cp += dest - source;
yy_bp += dest - source;
yy_n_chars = yy_current_buffer->yy_buf_size;
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
yy_cp[-2] = '\n';
*--yy_cp = c;
/* note: the formal parameter *must* be called "yy_bp" for this
* macro to now work correctly
*/
YY_DO_BEFORE_ACTION; /* set up yytext again */
}
#ifdef __cplusplus
static int yyinput()
#else
static int input()
#endif
{
int c;
YY_CHAR *yy_cp = yy_c_buf_p;
*yy_cp = yy_hold_char;
if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
/* this was really a NUL */
*yy_c_buf_p = '\0';
else
{ /* need more input */
yytext = yy_c_buf_p;
++yy_c_buf_p;
switch ( yy_get_next_buffer() )
{
case EOB_ACT_END_OF_FILE:
{
if ( yywrap() )
{
yy_c_buf_p = yytext + YY_MORE_ADJ;
return ( EOF );
}
YY_NEW_FILE;
#ifdef __cplusplus
return ( yyinput() );
#else
return ( input() );
#endif
}
break;
case EOB_ACT_CONTINUE_SCAN:
yy_c_buf_p = yytext + YY_MORE_ADJ;
break;
case EOB_ACT_LAST_MATCH:
#ifdef __cplusplus
YY_FATAL_ERROR( "unexpected last match in yyinput()" );
#else
YY_FATAL_ERROR( "unexpected last match in input()" );
#endif
}
}
}
c = *yy_c_buf_p;
yy_hold_char = *++yy_c_buf_p;
return ( c );
}
#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
#else
void yyrestart( input_file )
FILE *input_file;
#endif
{
yy_init_buffer( yy_current_buffer, input_file );
yy_load_buffer_state();
}
#ifdef YY_USE_PROTOS
void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
#else
void yy_switch_to_buffer( new_buffer )
YY_BUFFER_STATE new_buffer;
#endif
{
if ( yy_current_buffer == new_buffer )
return;
if ( yy_current_buffer )
{
/* flush out information for old buffer */
*yy_c_buf_p = yy_hold_char;
yy_current_buffer->yy_buf_pos = yy_c_buf_p;
yy_current_buffer->yy_n_chars = yy_n_chars;
}
yy_current_buffer = new_buffer;
yy_load_buffer_state();
/* we don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yy_did_buffer_switch_on_eof = 1;
}
#ifdef YY_USE_PROTOS
void yy_load_buffer_state( void )
#else
void yy_load_buffer_state()
#endif
{
yy_n_chars = yy_current_buffer->yy_n_chars;
yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
yyin = yy_current_buffer->yy_input_file;
yy_hold_char = *yy_c_buf_p;
}
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
#else
YY_BUFFER_STATE yy_create_buffer( file, size )
FILE *file;
int size;
#endif
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
yy_init_buffer( b, file );
return ( b );
}
#ifdef YY_USE_PROTOS
void yy_delete_buffer( YY_BUFFER_STATE b )
#else
void yy_delete_buffer( b )
YY_BUFFER_STATE b;
#endif
{
if ( b == yy_current_buffer )
yy_current_buffer = (YY_BUFFER_STATE) 0;
free( (char *) b->yy_ch_buf );
free( (char *) b );
}
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#else
void yy_init_buffer( b, file )
YY_BUFFER_STATE b;
FILE *file;
#endif
{
b->yy_input_file = file;
/* we put in the '\n' and start reading from [1] so that an
* initial match-at-newline will be true.
*/
b->yy_ch_buf[0] = '\n';
b->yy_n_chars = 1;
/* we always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[1];
b->yy_eof_status = EOF_NOT_SEEN;
}