Flex version 2.5.3 from Vern Paxson at LBL.

This commit is contained in:
Nate Williams 1996-06-19 20:26:48 +00:00
parent 8387c24d79
commit 0a985cc317
23 changed files with 9034 additions and 6022 deletions

View file

@ -1,6 +1,7 @@
// $Header: FlexLexer.h,v 1.2 94/01/04 14:57:26 vern Exp $
// $Header: /home/daffy/u0/vern/flex/RCS/FlexLexer.h,v 1.19 96/05/25 20:43:02 vern Exp $
// FlexLexer.h -- define classes for lexical analyzers generated by flex
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
// by flex
// Copyright (c) 1993 The Regents of the University of California.
// All rights reserved.
@ -22,19 +23,26 @@
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef __FLEX_LEXER_H
#define __FLEX_LEXER_H
// This file defines two classes. The first, FlexLexer, is an abstract
// class which specifies the external interface provided to flex C++
// lexer objects. The second, yyFlexLexer, fills out most of the meat
// of the lexer class; its internals may vary from lexer to lexer
// depending on things like whether REJECT is used.
// This file defines FlexLexer, an abstract class which specifies the
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
// which defines a particular lexer class.
//
// If you want to create multiple lexer classes, you use the -P flag
// to rename each yyFlexLexer to some other xxFlexLexer.
// to rename each yyFlexLexer to some other xxFlexLexer. You then
// include <FlexLexer.h> in your other sources once per lexer class:
//
// #undef yyFlexLexer
// #define yyFlexLexer xxFlexLexer
// #include <FlexLexer.h>
//
// #undef yyFlexLexer
// #define yyFlexLexer zzFlexLexer
// #include <FlexLexer.h>
// ...
#ifndef __FLEX_LEXER_H
// Never included before - need to define base class.
#define __FLEX_LEXER_H
#include <iostream.h>
extern "C++" {
@ -58,46 +66,46 @@ public:
virtual int yylex() = 0;
// Call yylex with new input/output sources.
int yylex( istream* new_in, ostream* new_out = 0 )
{
switch_streams( new_in, new_out );
return yylex();
}
// Switch to new input/output streams. A nil stream pointer
// indicates "keep the current one".
virtual void switch_streams( istream* new_in = 0,
ostream* new_out = 0 ) = 0;
int lineno() const { return yylineno; }
int debug() const { return yy_flex_debug; }
void set_debug( int flag ) { yy_flex_debug = flag; }
protected:
char* yytext;
int yyleng;
int yylineno; // only maintained if you use %option yylineno
int yy_flex_debug; // only has effect with -d or "%option debug"
};
}
#endif
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
// Either this is the first time through (yyFlexLexerOnce not defined),
// or this is a repeated include to define a different flavor of
// yyFlexLexer, as discussed in the flex man page.
#define yyFlexLexerOnce
class yyFlexLexer : public FlexLexer {
public:
// arg_yyin and arg_yyout default to the cin and cout, but we
// only make that assignment when initializing in yylex().
yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 )
{
yyin = arg_yyin;
yyout = arg_yyout;
yy_c_buf_p = 0;
yy_init = 1;
yy_start = 0;
yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
yy_did_buffer_switch_on_eof = 0;
yy_looking_for_trail_begin = 0;
yy_more_flag = 0;
yy_more_len = 0;
yy_start_stack_ptr = yy_start_stack_depth = 0;
yy_start_stack = 0;
yy_current_buffer = 0;
#ifdef YY_USES_REJECT
yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
#else
yy_state_buf = 0;
#endif
}
virtual ~yyFlexLexer()
{
delete yy_state_buf;
}
virtual ~yyFlexLexer();
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
struct yy_buffer_state* yy_create_buffer( istream* s, int size );
@ -105,6 +113,7 @@ public:
void yyrestart( istream* s );
virtual int yylex();
virtual void switch_streams( istream* new_in, ostream* new_out );
protected:
virtual int LexerInput( char* buf, int max_size );
@ -116,6 +125,7 @@ protected:
void yy_load_buffer_state();
void yy_init_buffer( struct yy_buffer_state* b, istream* s );
void yy_flush_buffer( struct yy_buffer_state* b );
int yy_start_stack_ptr;
int yy_start_stack_depth;
@ -168,8 +178,8 @@ protected:
int yy_more_flag;
int yy_more_len;
int yy_more_offset;
int yy_prev_more_offset;
};
}
#endif

View file

@ -1,3 +1,525 @@
Changes between release 2.5.3 (29May96) and release 2.5.2:
- Some serious bugs in yymore() have been fixed. In particular,
when using AT&T-lex-compatibility or %array, you can intermix
calls to input(), unput(), and yymore(). (This still doesn't
work for %pointer, and isn't likely to in the future.)
- A bug in handling NUL's in the input stream of scanners using
REJECT has been fixed.
- The default main() in libfl.a now repeatedly calls yylex() until
it returns 0, rather than just calling it once.
- Minor tweak for Windows NT Makefile, MISC/NT/Makefile.
Changes between release 2.5.2 (25Apr95) and release 2.5.1:
- The --prefix configuration option now works.
- A bug that completely broke the "-Cf" table compression
option has been fixed.
- A major headache involving "const" declarators and Solaris
systems has been fixed.
- An octal escape sequence in a flex regular expression must
now contain only the digits 0-7.
- You can now use "--" on the flex command line to mark the
end of flex options.
- You can now specify the filename '-' as a synonym for stdin.
- By default, the scanners generated by flex no longer
statically initialize yyin and yyout to stdin and stdout.
This change is necessary because in some ANSI environments,
stdin and stdout are not compile-time constant. You can
force the initialization using "%option stdinit" in the first
section of your flex input.
- "%option nounput" now correctly omits the unput() routine
from the output.
- "make clean" now removes config.log, config.cache, and the
flex binary. The fact that it removes the flex binary means
you should take care if making changes to scan.l, to make
sure you don't wind up in a bootstrap problem.
- In general, the Makefile has been reworked somewhat (thanks
to Francois Pinard) for added flexibility - more changes will
follow in subsequent releases.
- The .texi and .info files in MISC/texinfo/ have been updated,
thanks also to Francois Pinard.
- The FlexLexer::yylex(istream* new_in, ostream* new_out) method
now does not have a default for the first argument, to disambiguate
it from FlexLexer::yylex().
- A bug in destructing a FlexLexer object before doing any scanning
with it has been fixed.
- A problem with including FlexLexer.h multiple times has been fixed.
- The alloca() chud necessary to accommodate bison has grown
even uglier, but hopefully more correct.
- A portability tweak has been added to accommodate compilers that
use char* generic pointers.
- EBCDIC contact information in the file MISC/EBCDIC has been updated.
- An OS/2 Makefile and config.h for flex 2.5 is now available in
MISC/OS2/, contributed by Kai Uwe Rommel.
- The descrip.mms file for building flex under VMS has been updated,
thanks to Pat Rankin.
- The notes on building flex for the Amiga have been updated for
flex 2.5, contributed by Andreas Scherer.
Changes between release 2.5.1 (28Mar95) and release 2.4.7:
- A new concept of "start condition" scope has been introduced.
A start condition scope is begun with:
<SCs>{
where SCs is a list of one or more start conditions. Inside
the start condition scope, every rule automatically has the
prefix <SCs> applied to it, until a '}' which matches the
initial '{'. So, for example:
<ESC>{
"\\n" return '\n';
"\\r" return '\r';
"\\f" return '\f';
"\\0" return '\0';
}
is equivalent to:
<ESC>"\\n" return '\n';
<ESC>"\\r" return '\r';
<ESC>"\\f" return '\f';
<ESC>"\\0" return '\0';
As indicated in this example, rules inside start condition scopes
(and any rule, actually, other than the first) can be indented,
to better show the extent of the scope.
Start condition scopes may be nested.
- The new %option directive can be used in the first section of
a flex scanner to control scanner-generation options. Most
options are given simply as names, optionally preceded by the
word "no" (with no intervening whitespace) to negate their
meaning. Some are equivalent to flex flags, so putting them
in your scanner source is equivalent to always specifying
the flag (%option's take precedence over flags):
7bit -7 option
8bit -8 option
align -Ca option
backup -b option
batch -B option
c++ -+ option
caseful opposite of -i option (caseful is the default);
case-sensitive same as above
caseless -i option;
case-insensitive same as above
debug -d option
default opposite of -s option
ecs -Ce option
fast -F option
full -f option
interactive -I option
lex-compat -l option
meta-ecs -Cm option
perf-report -p option
read -Cr option
stdout -t option
verbose -v option
warn opposite of -w option (so use "%option nowarn" for -w)
array equivalent to "%array"
pointer equivalent to "%pointer" (default)
Some provide new features:
always-interactive generate a scanner which always
considers its input "interactive" (no call to isatty()
will be made when the scanner runs)
main supply a main program for the scanner, which
simply calls yylex(). Implies %option noyywrap.
never-interactive generate a scanner which never
considers its input "interactive" (no call to isatty()
will be made when the scanner runs)
stack if set, enable start condition stacks (see below)
stdinit if unset ("%option nostdinit"), initialize yyin
and yyout statically to nil FILE* pointers, instead
of stdin and stdout
yylineno if set, keep track of the current line
number in global yylineno (this option is expensive
in terms of performance). The line number is available
to C++ scanning objects via the new member function
lineno().
yywrap if unset ("%option noyywrap"), scanner does not
call yywrap() upon EOF but simply assumes there
are no more files to scan
Flex scans your rule actions to determine whether you use the
REJECT or yymore features (this is not new). Two %options can be
used to override its decision, either by setting them to indicate
the feature is indeed used, or unsetting them to indicate it
actually is not used:
reject
yymore
Three %option's take string-delimited values, offset with '=':
outfile="<name>" equivalent to -o<name>
prefix="<name>" equivalent to -P<name>
yyclass="<name>" set the name of the C++ scanning class
(see below)
A number of %option's are available for lint purists who
want to suppress the appearance of unneeded routines in
the generated scanner. Each of the following, if unset,
results in the corresponding routine not appearing in the
generated scanner:
input, unput
yy_push_state, yy_pop_state, yy_top_state
yy_scan_buffer, yy_scan_bytes, yy_scan_string
You can specify multiple options with a single %option directive,
and multiple directives in the first section of your flex input file.
- The new function:
YY_BUFFER_STATE yy_scan_string( const char *str )
returns a YY_BUFFER_STATE (which also becomes the current input
buffer) for scanning the given string, which occurs starting
with the next call to yylex(). The string must be NUL-terminated.
A related function:
YY_BUFFER_STATE yy_scan_bytes( const char *bytes, int len )
creates a buffer for scanning "len" bytes (including possibly NUL's)
starting at location "bytes".
Note that both of these functions create and scan a *copy* of
the string/bytes. (This may be desirable, since yylex() modifies
the contents of the buffer it is scanning.) You can avoid the
copy by using:
YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
which scans in place the buffer starting at "base", consisting
of "size" bytes, the last two bytes of which *must* be
YY_END_OF_BUFFER_CHAR (these bytes are not scanned; thus, scanning
consists of base[0] through base[size-2], inclusive). If you
fail to set up "base" in this manner, yy_scan_buffer returns a
nil pointer instead of creating a new input buffer.
The type yy_size_t is an integral type to which you can cast
an integer expression reflecting the size of the buffer.
- Three new routines are available for manipulating stacks of
start conditions:
void yy_push_state( int new_state )
pushes the current start condition onto the top of the stack
and BEGIN's "new_state" (recall that start condition names are
also integers).
void yy_pop_state()
pops the top of the stack and BEGIN's to it, and
int yy_top_state()
returns the top of the stack without altering the stack's
contents.
The start condition stack grows dynamically and so has no built-in
size limitation. If memory is exhausted, program execution
is aborted.
To use start condition stacks, your scanner must include
a "%option stack" directive.
- flex now supports POSIX character class expressions. These
are expressions enclosed inside "[:" and ":]" delimiters (which
themselves must appear between the '[' and ']' of a character
class; other elements may occur inside the character class, too).
The expressions flex recognizes are:
[:alnum:] [:alpha:] [:blank:] [:cntrl:] [:digit:] [:graph:]
[:lower:] [:print:] [:punct:] [:space:] [:upper:] [:xdigit:]
These expressions all designate a set of characters equivalent to
the corresponding isXXX function (for example, [:alnum:] designates
those characters for which isalnum() returns true - i.e., any
alphabetic or numeric). Some systems don't provide isblank(),
so flex defines [:blank:] as a blank or a tab.
For example, the following character classes are all equivalent:
[[:alnum:]]
[[:alpha:][:digit:]
[[:alpha:]0-9]
[a-zA-Z0-9]
If your scanner is case-insensitive (-i flag), then [:upper:]
and [:lower:] are equivalent to [:alpha:].
- The promised rewrite of the C++ FlexLexer class has not yet
been done. Support for FlexLexer is limited at the moment to
fixing show-stopper bugs, so, for example, the new functions
yy_scan_string() & friends are not available to FlexLexer
objects.
- The new macro
yy_set_interactive(is_interactive)
can be used to control whether the current buffer is considered
"interactive". An interactive buffer is processed more slowly,
but must be used when the scanner's input source is indeed
interactive to avoid problems due to waiting to fill buffers
(see the discussion of the -I flag in flex.1). A non-zero value
in the macro invocation marks the buffer as interactive, a zero
value as non-interactive. Note that use of this macro overrides
"%option always-interactive" or "%option never-interactive".
yy_set_interactive() must be invoked prior to beginning to
scan the buffer.
- The new macro
yy_set_bol(at_bol)
can be used to control whether the current buffer's scanning
context for the next token match is done as though at the
beginning of a line (non-zero macro argument; makes '^' anchored
rules active) or not at the beginning of a line (zero argument,
'^' rules inactive).
- Related to this change, the mechanism for determining when a scan is
starting at the beginning of a line has changed. It used to be
that '^' was active iff the character prior to that at which the
scan started was a newline. The mechanism now is that '^' is
active iff the last token ended in a newline (or the last call to
input() returned a newline). For most users, the difference in
mechanisms is negligible. Where it will make a difference,
however, is if unput() or yyless() is used to alter the input
stream. When in doubt, use yy_set_bol().
- The new beginning-of-line mechanism involved changing some fairly
twisted code, so it may have introduced bugs - beware ...
- The macro YY_AT_BOL() returns true if the next token scanned from
the current buffer will have '^' rules active, false otherwise.
- The new function
void yy_flush_buffer( struct yy_buffer_state* b )
flushes the contents of the current buffer (i.e., next time
the scanner attempts to match a token using b as the current
buffer, it will begin by invoking YY_INPUT to fill the buffer).
This routine is also available to C++ scanners (unlike some
of the other new routines).
The related macro
YY_FLUSH_BUFFER
flushes the contents of the current buffer.
- A new "-ooutput" option writes the generated scanner to "output".
If used with -t, the scanner is still written to stdout, but
its internal #line directives (see previous item) use "output".
- Flex now generates #line directives relating the code it
produces to the output file; this means that error messages
in the flex-generated code should be correctly pinpointed.
- When generating #line directives, filenames with embedded '\'s
have those characters escaped (i.e., turned into '\\'). This
feature helps with reporting filenames for some MS-DOS and OS/2
systems.
- The FlexLexer class includes two new public member functions:
virtual void switch_streams( istream* new_in = 0,
ostream* new_out = 0 )
reassigns yyin to new_in (if non-nil) and yyout to new_out
(ditto), deleting the previous input buffer if yyin is
reassigned. It is used by:
int yylex( istream* new_in = 0, ostream* new_out = 0 )
which first calls switch_streams() and then returns the value
of calling yylex().
- C++ scanners now have yy_flex_debug as a member variable of
FlexLexer rather than a global, and member functions for testing
and setting it.
- When generating a C++ scanning class, you can now use
%option yyclass="foo"
to inform flex that you have derived "foo" as a subclass of
yyFlexLexer, so flex will place your actions in the member
function foo::yylex() instead of yyFlexLexer::yylex(). It also
generates a yyFlexLexer::yylex() member function that generates a
run-time error if called (by invoking yyFlexLexer::LexerError()).
This feature is necessary if your subclass "foo" introduces some
additional member functions or variables that you need to access
from yylex().
- Current texinfo files in MISC/texinfo, contributed by Francois
Pinard.
- You can now change the name "flex" to something else (e.g., "lex")
by redefining $(FLEX) in the Makefile.
- Two bugs (one serious) that could cause "bigcheck" to fail have
been fixed.
- A number of portability/configuration changes have been made
for easier portability.
- You can use "YYSTATE" in your scanner as an alias for YY_START
(for AT&T lex compatibility).
- input() now maintains yylineno.
- input() no longer trashes yytext.
- interactive scanners now read characters in YY_INPUT up to a
newline, a large performance gain.
- C++ scanner objects now work with the -P option. You include
<FlexLexer.h> once per scanner - see comments in <FlexLexer.h>
(or flex.1) for details.
- C++ FlexLexer objects now use the "cerr" stream to report -d output
instead of stdio.
- The -c flag now has its full glorious POSIX interpretation (do
nothing), rather than being interpreted as an old-style -C flag.
- Scanners generated by flex now include two #define's giving
the major and minor version numbers (YY_FLEX_MAJOR_VERSION,
YY_FLEX_MINOR_VERSION). These can then be tested to see
whether certain flex features are available.
- Scanners generated using -l lex compatibility now have the symbol
YY_FLEX_LEX_COMPAT #define'd.
- When initializing (i.e., yy_init is non-zero on entry to yylex()),
generated scanners now set yy_init to zero before executing
YY_USER_INIT. This means that you can set yy_init back to a
non-zero value in YY_USER_INIT if you need the scanner to be
reinitialized on the next call.
- You can now use "#line" directives in the first section of your
scanner specification.
- When generating full-table scanners (-Cf), flex now puts braces
around each row of the 2-d array initialization, to silence warnings
on over-zealous compilers.
- Improved support for MS-DOS. The flex sources have been successfully
built, unmodified, for Borland 4.02 (all that's required is a
Borland Makefile and config.h file, which are supplied in
MISC/Borland - contributed by Terrence O Kane).
- Improved support for Macintosh using Think C - the sources should
build for this platform "out of the box". Contributed by Scott
Hofmann.
- Improved support for VMS, in MISC/VMS/, contributed by Pat Rankin.
- Support for the Amiga, in MISC/Amiga/, contributed by Andreas
Scherer. Note that the contributed files were developed for
flex 2.4 and have not been tested with flex 2.5.
- Some notes on support for the NeXT, in MISC/NeXT, contributed
by Raf Schietekat.
- The MISC/ directory now includes a preformatted version of flex.1
in flex.man, and pre-yacc'd versions of parse.y in parse.{c,h}.
- The flex.1 and flexdoc.1 manual pages have been merged. There
is now just one document, flex.1, which includes an overview
at the beginning to help you find the section you need.
- Documentation now clarifies that start conditions persist across
switches to new input files or different input buffers. If you
want to e.g., return to INITIAL, you must explicitly do so.
- The "Performance Considerations" section of the manual has been
updated.
- Documented the "yy_act" variable, which when YY_USER_ACTION is
invoked holds the number of the matched rule, and added an
example of using yy_act to profile how often each rule is matched.
- Added YY_NUM_RULES, a definition that gives the total number
of rules in the file, including the default rule (even if you
use -s).
- Documentation now clarifies that you can pass a nil FILE* pointer
to yy_create_buffer() or yyrestart() if you've arrange YY_INPUT
to not need yyin.
- Documentation now clarifies that YY_BUFFER_STATE is a pointer to
an opaque "struct yy_buffer_state".
- Documentation now stresses that you gain the benefits of removing
backing-up states only if you remove *all* of them.
- Documentation now points out that traditional lex allows you
to put the action on a separate line from the rule pattern if
the pattern has trailing whitespace (ugh!), but flex doesn't
support this.
- A broken example in documentation of the difference between
inclusive and exclusive start conditions is now fixed.
- Usage (-h) report now goes to stdout.
- Version (-V) info now goes to stdout.
- More #ifdef chud has been added to the parser in attempt to
deal with bison's use of alloca().
- "make clean" no longer deletes emacs backup files (*~).
- Some memory leaks have been fixed.
- A bug was fixed in which dynamically-expanded buffers were
reallocated a couple of bytes too small.
- A bug was fixed which could cause flex to read and write beyond
the end of the input buffer.
- -S will not be going away.
Changes between release 2.4.7 (03Aug94) and release 2.4.6:
- Fixed serious bug in reading multiple files.
@ -24,7 +546,6 @@ Changes between release 2.4.6 (04Jan94) and release 2.4.5:
- The use of 'extern "C++"' in FlexLexer.h has been modified to
get around an incompatibility with g++'s header files.
Changes between release 2.4.5 (11Dec93) and release 2.4.4:
- Fixed bug breaking C++ scanners that use REJECT or variable
@ -296,9 +817,7 @@ Changes between release 2.4.1 (30Nov93) and release 2.3.8:
- The skeleton file is no longer opened at run-time, but instead
compiled into a large string array (thanks to John Gilmore and
friends at Cygnus). You can still use the -S flag to point flex
at a different skeleton file, though if you use this option let
me know, as I plan to otherwise do away with -S in the near
future.
at a different skeleton file.
- flex no longer uses a temporary file to store the scanner's
actions.

View file

@ -1,4 +1,4 @@
This is release 2.4 of flex. See "version.h" for the exact patch-level.
This is release 2.5 of flex. See "version.h" for the exact patch-level.
See the file "NEWS" to find out what is new in this Flex release.
@ -15,19 +15,12 @@ Note that flex is distributed under a copyright very similar to that of
BSD Unix, and not under the GNU General Public License (GPL), except for
the "configure" script, which is covered by the GPL.
Many thanks to the 2.4 pre-testers for finding a bunch of bugs and helping
increase/test portability: Francois Pinard, Nathan Zelle, Gavin Nicol,
Chris Thewalt, and Matthew Jacob.
Many thanks to the 2.5 beta-testers for finding bugs and helping test and
increase portability: Stan Adermann, Scott David Daniels, Charles Elliott,
Joe Gayda, Chris Meier, James Nordby, Terrence O'Kane, Karsten Pahnke,
Francois Pinard, Pat Rankin, Andreas Scherer, Marc Wiese, Nathan Zelle.
Please send bug reports and feedback to:
Vern Paxson
ICSD, 46A/1123
Lawrence Berkeley Laboratory
1 Cyclotron Rd.
Berkeley, CA 94720
vern@ee.lbl.gov
Please send bug reports and feedback to: Vern Paxson (vern@ee.lbl.gov).
The flex distribution consists of the following files:
@ -40,7 +33,8 @@ The flex distribution consists of the following files:
COPYING flex's copyright
configure.in, configure, Makefile.in, install.sh, mkinstalldirs
conf.in, configure.in, configure, Makefile.in, install.sh,
mkinstalldirs
elements of the "autoconf" auto-configuration process
flexdef.h, parse.y, scan.l, ccl.c, dfa.c, ecs.c, gen.c, main.c,
@ -51,8 +45,8 @@ The flex distribution consists of the following files:
flex.skl flex scanner skeleton
mkskel.sh script for converting flex.skl to C source file skel.c
skel.c pre-converted C version of flex.skl
liballoc.c
libmain.c flex library (-lfl) sources
libyywrap.c
@ -60,8 +54,7 @@ The flex distribution consists of the following files:
FlexLexer.h header file for C++ lexer class
flexdoc.1 full user documentation
flex.1 reference documentation
flex.1 user documentation
MISC/ a directory containing miscellaneous contributions.
See MISC/README for details.

26
usr.bin/lex/config.h Normal file
View file

@ -0,0 +1,26 @@
/* config.h. Generated automatically by configure. */
/* $Header: /home/daffy/u0/vern/flex/RCS/conf.in,v 1.2 95/01/09 12:11:51 vern Exp $ */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you have the <malloc.h> header file. */
/* #undef HAVE_MALLOC_H */
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
/* #undef HAVE_ALLOCA_H */
/* Define if platform-specific command line handling is necessary. */
/* #undef NEED_ARGV_FIXUP */

View file

@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: dfa.c,v 1.2 94/01/04 14:33:16 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/dfa.c,v 2.26 95/04/20 13:53:14 vern Exp $ */
#include "flexdef.h"
@ -60,7 +60,7 @@ int state[];
if ( backing_up_report )
{
fprintf( backing_up_file,
"State #%d is non-accepting -\n", ds );
_( "State #%d is non-accepting -\n" ), ds );
/* identify the state */
dump_associated_rules( backing_up_file, ds );
@ -101,7 +101,7 @@ int state[];
void check_trailing_context( nfa_states, num_states, accset, nacc )
int *nfa_states, num_states;
int *accset;
register int nacc;
int nacc;
{
register int i, j;
@ -127,7 +127,7 @@ register int nacc;
if ( accset[j] & YY_TRAILING_HEAD_MASK )
{
line_warning(
"dangerous trailing context",
_( "dangerous trailing context" ),
rule_linenum[ar] );
return;
}
@ -170,7 +170,7 @@ int ds;
bubble( rule_set, num_associated_rules );
fprintf( file, " associated rule line numbers:" );
fprintf( file, _( " associated rule line numbers:" ) );
for ( i = 1; i <= num_associated_rules; ++i )
{
@ -208,7 +208,7 @@ int state[];
out_char_set[i] = state[ec];
}
fprintf( file, " out-transitions: " );
fprintf( file, _( " out-transitions: " ) );
list_character_set( file, out_char_set );
@ -216,7 +216,7 @@ int state[];
for ( i = 0; i < csize; ++i )
out_char_set[i] = ! out_char_set[i];
fprintf( file, "\n jam-transitions: EOF " );
fprintf( file, _( "\n jam-transitions: EOF " ) );
list_character_set( file, out_char_set );
@ -352,7 +352,8 @@ ADD_STATE(state) \
if ( IS_MARKED(stk[stkpos]) )
UNMARK_STATE(stk[stkpos])
else
flexfatal( "consistency check failed in epsclosure()" );
flexfatal(
_( "consistency check failed in epsclosure()" ) );
}
*ns_addr = numstates;
@ -398,7 +399,7 @@ void ntod()
int num_full_table_rows; /* used only for -f */
int *nset, *dset;
int targptr, totaltrans, i, comstate, comfreq, targ;
int *epsclosure(), snstods(), symlist[CSIZE + 1];
int symlist[CSIZE + 1];
int num_start_states;
int todo_head, todo_next;
@ -435,7 +436,7 @@ void ntod()
if ( trace )
{
dumpnfa( scset[1] );
fputs( "\n\nDFA Dump:\n\n", stderr );
fputs( _( "\n\nDFA Dump:\n\n" ), stderr );
}
inittbl();
@ -510,7 +511,7 @@ void ntod()
state[i] = 0;
place_state( state, 0, 0 );
dfaacc[i].dfaacc_state = 0;
dfaacc[0].dfaacc_state = 0;
}
else if ( fulltbl )
@ -531,19 +532,18 @@ void ntod()
/* Unless -Ca, declare it "short" because it's a real
* long-shot that that won't be large enough.
*/
printf( "static const %s yy_nxt[][%d] =\n {\n",
out_str_dec( "static yyconst %s yy_nxt[][%d] =\n {\n",
/* '}' so vi doesn't get too confused */
long_align ? "long" : "short", num_full_table_rows );
outn( " {" );
/* Generate 0 entries for state #0. */
for ( i = 0; i < num_full_table_rows; ++i )
mk2data( 0 );
/* Force ',' and dataflush() next call to mk2data().*/
datapos = NUMDATAITEMS;
/* Force extra blank line next dataflush(). */
dataline = NUMDATALINES;
dataflush();
outn( " },\n" );
}
/* Create the first states. */
@ -582,7 +582,7 @@ void ntod()
{
if ( ! snstods( nset, 0, accset, 0, 0, &end_of_buffer_state ) )
flexfatal(
"could not create unique end-of-buffer state" );
_( "could not create unique end-of-buffer state" ) );
++numas;
++num_start_states;
@ -603,7 +603,7 @@ void ntod()
dsize = dfasiz[ds];
if ( trace )
fprintf( stderr, "state # %d:\n", ds );
fprintf( stderr, _( "state # %d:\n" ), ds );
sympartition( dset, dsize, symlist, duplist );
@ -677,16 +677,26 @@ void ntod()
}
}
numsnpairs = numsnpairs + totaltrans;
if ( caseins && ! useecs )
{
register int j;
for ( i = 'A', j = 'a'; i <= 'Z'; ++i, ++j )
{
if ( state[i] == 0 && state[j] != 0 )
/* We're adding a transition. */
++totaltrans;
else if ( state[i] != 0 && state[j] == 0 )
/* We're taking away a transition. */
--totaltrans;
state[i] = state[j];
}
}
numsnpairs += totaltrans;
if ( ds > num_start_states )
check_for_backing_up( ds, state );
@ -698,6 +708,8 @@ void ntod()
if ( fulltbl )
{
outn( " {" );
/* Supply array's 0-element. */
if ( ds == end_of_buffer_state )
mk2data( -end_of_buffer_state );
@ -710,11 +722,8 @@ void ntod()
*/
mk2data( state[i] ? state[i] : -ds );
/* Force ',' and dataflush() next call to mk2data().*/
datapos = NUMDATAITEMS;
/* Force extra blank line next dataflush(). */
dataline = NUMDATALINES;
dataflush();
outn( " },\n" );
}
else if ( fullspd )
@ -977,7 +986,8 @@ int ds[], dsize, transsym, nset[];
}
else if ( sym >= 'A' && sym <= 'Z' && caseins )
flexfatal( "consistency check failed in symfollowset" );
flexfatal(
_( "consistency check failed in symfollowset" ) );
else if ( sym == SYM_EPSILON )
{ /* do nothing */
@ -1030,7 +1040,7 @@ int symlist[], duplist[];
if ( tch < -lastccl || tch >= csize )
{
flexfatal(
"bad transition character detected in sympartition()" );
_( "bad transition character detected in sympartition()" ) );
}
if ( tch >= 0 )

View file

@ -1,10 +1,12 @@
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /home/daffy/u0/vern/flex/flex-2.4.7/RCS/flex.skl,v 1.2 94/08/03 11:13:24 vern Exp $
* $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.89 96/05/25 21:02:21 vern Exp $
*/
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
%-
#include <stdio.h>
@ -35,7 +37,7 @@ class istream;
#else /* ! __cplusplus */
#ifdef __STDC__
#if __STDC__
#define YY_USE_PROTOS
#define YY_USE_CONST
@ -43,16 +45,19 @@ class istream;
#endif /* __STDC__ */
#endif /* ! __cplusplus */
#ifdef __TURBOC__
#pragma warn -rch
#pragma warn -use
#include <io.h>
#include <stdlib.h>
#define YY_USE_CONST
#define YY_USE_PROTOS
#endif
#ifndef YY_USE_CONST
#ifndef const
#define const
#endif
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
@ -79,16 +84,16 @@ class istream;
#define BEGIN yy_start = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state.
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yy_start - 1) / 2)
#define YYSTATE YY_START
/* 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". Now included
* only for backward compatibility with previous versions of flex.
*/
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart( yyin )
#define YY_END_OF_BUFFER_CHAR 0
@ -103,14 +108,6 @@ extern int yyleng;
extern FILE *yyin, *yyout;
%*
#ifdef __cplusplus
extern "C" {
#endif
extern int yywrap YY_PROTO(( void ));
#ifdef __cplusplus
}
#endif
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
@ -136,6 +133,7 @@ extern "C" {
{ \
/* Undo effects of setting up yytext. */ \
*yy_cp = yy_hold_char; \
YY_RESTORE_YY_MORE_OFFSET \
yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
@ -143,6 +141,12 @@ extern "C" {
#define unput(c) yyunput( c, yytext_ptr )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
*/
typedef unsigned int yy_size_t;
struct yy_buffer_state
{
@ -158,13 +162,19 @@ struct yy_buffer_state
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
@ -172,6 +182,12 @@ struct yy_buffer_state
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@ -223,47 +239,50 @@ static int yy_start = 0; /* start state number */
*/
static int yy_did_buffer_switch_on_eof;
static void yyunput YY_PROTO(( int c, 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 ));
void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
static void yy_push_state YY_PROTO(( int new_state ));
static void yy_pop_state YY_PROTO(( void ));
static int yy_top_state YY_PROTO(( void ));
YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));
YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
%*
static void *yy_flex_alloc YY_PROTO(( unsigned int ));
static void *yy_flex_realloc YY_PROTO(( void *, unsigned int ));
static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
static void yy_flex_free YY_PROTO(( void * ));
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! yy_current_buffer ) \
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
yy_current_buffer->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! yy_current_buffer ) \
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
yy_current_buffer->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
#ifndef yytext_ptr
static void yy_flex_strncpy YY_PROTO(( char *, const char *, int ));
#endif
%- Standard (non-C++) definition
#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
%*
%- Standard (non-C++) definition
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 yy_fatal_error YY_PROTO(( const char msg[] ));
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
%*
/* Done after the current pattern has been matched and before the
@ -283,6 +302,58 @@ static void yy_fatal_error YY_PROTO(( const char msg[] ));
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif
%-
#ifndef YY_NO_UNPUT
static void yyunput YY_PROTO(( int c, char *buf_ptr ));
#endif
%*
#ifndef yytext_ptr
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen YY_PROTO(( yyconst char * ));
#endif
#ifndef YY_NO_INPUT
%- Standard (non-C++) definition
#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
%*
#endif
#if YY_STACK_USED
static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
#ifndef YY_NO_PUSH_STATE
static void yy_push_state YY_PROTO(( int new_state ));
#endif
#ifndef YY_NO_POP_STATE
static void yy_pop_state YY_PROTO(( void ));
#endif
#ifndef YY_NO_TOP_STATE
static int yy_top_state YY_PROTO(( void ));
#endif
#else
#define YY_NO_PUSH_STATE 1
#define YY_NO_POP_STATE 1
#define YY_NO_TOP_STATE 1
#endif
#ifdef YY_MALLOC_DECL
YY_MALLOC_DECL
#else
@ -373,6 +444,8 @@ YY_MALLOC_DECL
#define YY_BREAK break;
#endif
%% YY_RULE_SETUP definition goes here
YY_DECL
{
register yy_state_type yy_current_state;
@ -383,6 +456,8 @@ YY_DECL
if ( yy_init )
{
yy_init = 0;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
@ -404,15 +479,11 @@ YY_DECL
yyout = &cout;
%*
if ( yy_current_buffer )
yy_init_buffer( yy_current_buffer, yyin );
else
if ( ! yy_current_buffer )
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 */
@ -435,7 +506,7 @@ yy_find_action:
YY_DO_BEFORE_ACTION;
%% code for yylineno update goes here, if -l option
%% code for yylineno update goes here
do_action: /* This label is used only to access EOF actions. */
@ -448,10 +519,11 @@ do_action: /* This label is used only to access EOF actions. */
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1;
int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = yy_hold_char;
YY_RESTORE_YY_MORE_OFFSET
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
{
@ -574,6 +646,53 @@ do_action: /* This label is used only to access EOF actions. */
} /* end of yylex */
%+
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
{
yyin = arg_yyin;
yyout = arg_yyout;
yy_c_buf_p = 0;
yy_init = 1;
yy_start = 0;
yy_flex_debug = 0;
yylineno = 1; // this will only get updated if %option yylineno
yy_did_buffer_switch_on_eof = 0;
yy_looking_for_trail_begin = 0;
yy_more_flag = 0;
yy_more_len = 0;
yy_more_offset = yy_prev_more_offset = 0;
yy_start_stack_ptr = yy_start_stack_depth = 0;
yy_start_stack = 0;
yy_current_buffer = 0;
#ifdef YY_USES_REJECT
yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
#else
yy_state_buf = 0;
#endif
}
yyFlexLexer::~yyFlexLexer()
{
delete yy_state_buf;
yy_delete_buffer( yy_current_buffer );
}
void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
{
if ( new_in )
{
yy_delete_buffer( yy_current_buffer );
yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
}
if ( new_out )
yyout = new_out;
}
#ifdef YY_INTERACTIVE
int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
#else
@ -625,7 +744,7 @@ int yyFlexLexer::yy_get_next_buffer()
%*
{
register char *dest = yy_current_buffer->yy_ch_buf;
register char *source = yytext_ptr - 1; /* copy prev. char, too */
register char *source = yytext_ptr;
register int number_to_move, i;
int ret_val;
@ -637,7 +756,7 @@ int yyFlexLexer::yy_get_next_buffer()
{ /* Don't try to fill the buffer, so this is an EOF. */
if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
{
/* We matched a singled characater, the EOB, so
/* We matched a single character, the EOB, so
* treat this as a final EOF.
*/
return EOB_ACT_END_OF_FILE;
@ -655,7 +774,7 @@ int yyFlexLexer::yy_get_next_buffer()
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = yy_c_buf_p - yytext_ptr;
number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@ -681,12 +800,26 @@ int yyFlexLexer::yy_get_next_buffer()
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = yy_current_buffer;
int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf;
int yy_c_buf_p_offset =
(int) (yy_c_buf_p - b->yy_ch_buf);
b->yy_buf_size *= 2;
b->yy_ch_buf = (char *)
yy_flex_realloc( (void *) b->yy_ch_buf,
b->yy_buf_size );
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
else
b->yy_buf_size *= 2;
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yy_flex_realloc( (void *) b->yy_ch_buf,
b->yy_buf_size + 2 );
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = 0;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
@ -709,7 +842,7 @@ int yyFlexLexer::yy_get_next_buffer()
if ( yy_n_chars == 0 )
{
if ( number_to_move - YY_MORE_ADJ == 1 )
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
yyrestart( yyin );
@ -730,13 +863,7 @@ int yyFlexLexer::yy_get_next_buffer()
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_ptr = &yy_current_buffer->yy_ch_buf[1];
yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
return ret_val;
}
@ -789,6 +916,7 @@ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
%-
#ifndef YY_NO_UNPUT
#ifdef YY_USE_PROTOS
static void yyunput( int c, register char *yy_bp )
#else
@ -817,26 +945,25 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp )
while ( source > yy_current_buffer->yy_ch_buf )
*--dest = *--source;
yy_cp += dest - source;
yy_bp += dest - source;
yy_cp += (int) (dest - source);
yy_bp += (int) (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 = (char) c;
%% update yylineno here, if doing -l
%% update yylineno here
/* Note: the formal parameter *must* be called "yy_bp" for this
* macro to now work correctly.
*/
YY_DO_BEFORE_ACTION; /* set up yytext again */
yytext_ptr = yy_bp;
yy_hold_char = *yy_cp;
yy_c_buf_p = yy_cp;
}
%-
#endif /* ifndef YY_NO_UNPUT */
%*
%-
@ -865,7 +992,7 @@ int yyFlexLexer::yyinput()
else
{ /* need more input */
yytext_ptr = yy_c_buf_p;
int offset = yy_c_buf_p - yytext_ptr;
++yy_c_buf_p;
switch ( yy_get_next_buffer() )
@ -874,12 +1001,12 @@ int yyFlexLexer::yyinput()
{
if ( yywrap() )
{
yy_c_buf_p =
yytext_ptr + YY_MORE_ADJ;
yy_c_buf_p = yytext_ptr + offset;
return EOF;
}
YY_NEW_FILE;
if ( ! yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput();
#else
@ -888,7 +1015,7 @@ int yyFlexLexer::yyinput()
}
case EOB_ACT_CONTINUE_SCAN:
yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
yy_c_buf_p = yytext_ptr + offset;
break;
case EOB_ACT_LAST_MATCH:
@ -907,6 +1034,8 @@ int yyFlexLexer::yyinput()
*yy_c_buf_p = '\0'; /* preserve yytext */
yy_hold_char = *++yy_c_buf_p;
%% update BOL and yylineno
return c;
}
@ -996,7 +1125,6 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@ -1006,10 +1134,11 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
yy_init_buffer( b, file );
return b;
@ -1027,15 +1156,26 @@ YY_BUFFER_STATE b;
void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
%*
{
if ( ! b )
return;
if ( b == yy_current_buffer )
yy_current_buffer = (YY_BUFFER_STATE) 0;
yy_flex_free( (void *) b->yy_ch_buf );
if ( b->yy_is_our_buffer )
yy_flex_free( (void *) b->yy_ch_buf );
yy_flex_free( (void *) b );
}
%-
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#endif
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#else
@ -1043,40 +1183,167 @@ void yy_init_buffer( b, file )
YY_BUFFER_STATE b;
FILE *file;
#endif
%+
extern "C" int isatty YY_PROTO(( int ));
void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
%*
{
yy_flush_buffer( b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
/* We put in the '\n' and start reading from [1] so that an
* initial match-at-newline will be true.
*/
%-
#if YY_ALWAYS_INTERACTIVE
b->yy_is_interactive = 1;
#else
#if YY_NEVER_INTERACTIVE
b->yy_is_interactive = 0;
#else
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
#endif
#endif
%+
b->yy_is_interactive = 0;
%*
}
b->yy_ch_buf[0] = '\n';
b->yy_n_chars = 1;
%-
#ifdef YY_USE_PROTOS
void yy_flush_buffer( YY_BUFFER_STATE b )
#else
void yy_flush_buffer( b )
YY_BUFFER_STATE b;
#endif
%+
void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
%*
{
b->yy_n_chars = 0;
/* 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[0] = YY_END_OF_BUFFER_CHAR;
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_buf_pos = &b->yy_ch_buf[0];
%-
b->yy_is_interactive = file ? isatty( fileno(file) ) : 0;
%+
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == yy_current_buffer )
yy_load_buffer_state();
}
%*
b->yy_fill_buffer = 1;
#ifndef YY_NO_SCAN_BUFFER
%-
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
#else
YY_BUFFER_STATE yy_scan_buffer( base, size )
char *base;
yy_size_t size;
#endif
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
yy_switch_to_buffer( b );
return b;
}
%*
#endif
#ifndef YY_NO_SCAN_STRING
%-
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_string( yyconst char *str )
#else
YY_BUFFER_STATE yy_scan_string( str )
yyconst char *str;
#endif
{
int len;
for ( len = 0; str[len]; ++len )
;
return yy_scan_bytes( str, len );
}
%*
#endif
#ifndef YY_NO_SCAN_BYTES
%-
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
#else
YY_BUFFER_STATE yy_scan_bytes( bytes, len )
yyconst char *bytes;
int len;
#endif
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = len + 2;
buf = (char *) yy_flex_alloc( n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
for ( i = 0; i < len; ++i )
buf[i] = bytes[i];
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
b = yy_scan_buffer( buf, n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
*/
b->yy_is_our_buffer = 1;
return b;
}
%*
#endif
#ifndef YY_NO_PUSH_STATE
%-
#ifdef YY_USE_PROTOS
static void yy_push_state( int new_state )
@ -1090,7 +1357,7 @@ void yyFlexLexer::yy_push_state( int new_state )
{
if ( yy_start_stack_ptr >= yy_start_stack_depth )
{
int new_size;
yy_size_t new_size;
yy_start_stack_depth += YY_START_STACK_INCR;
new_size = yy_start_stack_depth * sizeof( int );
@ -1111,8 +1378,10 @@ void yyFlexLexer::yy_push_state( int new_state )
BEGIN(new_state);
}
#endif
#ifndef YY_NO_POP_STATE
%-
static void yy_pop_state()
%+
@ -1124,8 +1393,10 @@ void yyFlexLexer::yy_pop_state()
BEGIN(yy_start_stack[yy_start_stack_ptr]);
}
#endif
#ifndef YY_NO_TOP_STATE
%-
static int yy_top_state()
%+
@ -1134,26 +1405,30 @@ int yyFlexLexer::yy_top_state()
{
return yy_start_stack[yy_start_stack_ptr - 1];
}
#endif
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
%-
#ifdef YY_USE_PROTOS
static void yy_fatal_error( const char msg[] )
static void yy_fatal_error( yyconst char msg[] )
#else
static void yy_fatal_error( msg )
char msg[];
#endif
{
(void) fprintf( stderr, "%s\n", msg );
exit( 1 );
exit( YY_EXIT_FAILURE );
}
%+
void yyFlexLexer::LexerError( const char msg[] )
void yyFlexLexer::LexerError( yyconst char msg[] )
{
cerr << msg << '\n';
exit( 1 );
exit( YY_EXIT_FAILURE );
}
%*
@ -1166,7 +1441,7 @@ void yyFlexLexer::LexerError( const char msg[] )
{ \
/* Undo effects of setting up yytext. */ \
yytext[yyleng] = yy_hold_char; \
yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
yy_c_buf_p = yytext + n; \
yy_hold_char = *yy_c_buf_p; \
*yy_c_buf_p = '\0'; \
yyleng = n; \
@ -1178,11 +1453,11 @@ void yyFlexLexer::LexerError( const char msg[] )
#ifndef yytext_ptr
#ifdef YY_USE_PROTOS
static void yy_flex_strncpy( char *s1, const char *s2, int n )
static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
#else
static void yy_flex_strncpy( s1, s2, n )
char *s1;
const char *s2;
yyconst char *s2;
int n;
#endif
{
@ -1192,26 +1467,49 @@ int n;
}
#endif
#ifdef YY_NEED_STRLEN
#ifdef YY_USE_PROTOS
static int yy_flex_strlen( yyconst char *s )
#else
static int yy_flex_strlen( s )
yyconst char *s;
#endif
{
register int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
#ifdef YY_USE_PROTOS
static void *yy_flex_alloc( unsigned int size )
static void *yy_flex_alloc( yy_size_t size )
#else
static void *yy_flex_alloc( size )
unsigned int size;
yy_size_t size;
#endif
{
return (void *) malloc( size );
}
#ifdef YY_USE_PROTOS
static void *yy_flex_realloc( void *ptr, unsigned int size )
static void *yy_flex_realloc( void *ptr, yy_size_t size )
#else
static void *yy_flex_realloc( ptr, size )
void *ptr;
unsigned int size;
yy_size_t size;
#endif
{
return (void *) realloc( ptr, size );
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
}
#ifdef YY_USE_PROTOS
@ -1223,3 +1521,11 @@ void *ptr;
{
free( ptr );
}
#if YY_MAIN
int main()
{
yylex();
return 0;
}
#endif

View file

@ -26,21 +26,50 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* @(#) $Header: flexdef.h,v 1.2 94/01/04 14:33:14 vern Exp $ (LBL) */
/* @(#) $Header: /home/daffy/u0/vern/flex/RCS/flexdef.h,v 2.53 95/04/20 11:17:36 vern Exp $ (LBL) */
#include <stdio.h>
#include <ctype.h>
#if HAVE_STRING_H
#include "config.h"
#ifdef __TURBOC__
#define HAVE_STRING_H 1
#define MS_DOS 1
#ifndef __STDC__
#define __STDC__ 1
#endif
#pragma warn -pro
#pragma warn -rch
#pragma warn -use
#pragma warn -aus
#pragma warn -par
#pragma warn -pia
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#if __STDC__
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
/* As an aid for the internationalization patch to flex, which
* is maintained outside this distribution for copyright reasons.
*/
#define _(String) (String)
/* Always be prepared to generate an 8-bit scanner. */
#define CSIZE 256
#define Char unsigned char
@ -51,7 +80,7 @@
#endif
#ifndef PROTO
#ifdef __STDC__
#if __STDC__
#define PROTO(proto) proto
#else
#define PROTO(proto) ()
@ -59,9 +88,11 @@
#endif
#ifdef VMS
#define unlink delete
#ifndef __VMS_POSIX
#define unlink remove
#define SHORT_FILE_NAMES
#endif
#endif
#ifdef MS_DOS
#define SHORT_FILE_NAMES
@ -90,6 +121,7 @@
#define true 1
#define false 0
#define unspecified -1
/* Special chk[] values marking the slots taking by end-of-buffer and action
@ -106,8 +138,8 @@
*/
#define NUMDATALINES 10
/* Transition_struct_out() definitions. */
#define TRANS_STRUCT_PRINT_LENGTH 15
/* transition_struct_out() definitions. */
#define TRANS_STRUCT_PRINT_LENGTH 14
/* Returns true if an nfa state has an epsilon out-transition slot
* that can be used. This definition is currently not used.
@ -180,11 +212,13 @@
#define JAMSTATE -32766 /* marks a reference to the state that always jams */
/* Maximum number of NFA states. */
#define MAXIMUM_MNS 31999
/* Enough so that if it's subtracted from an NFA state number, the result
* is guaranteed to be negative.
*/
#define MARKER_DIFFERENCE 32000
#define MAXIMUM_MNS 31999
#define MARKER_DIFFERENCE (MAXIMUM_MNS+2)
/* Maximum number of nxt/chk pairs for non-templates. */
#define INITIAL_MAX_XPAIRS 2000
@ -316,6 +350,7 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
* interactive - if true (-I), generate an interactive scanner
* caseins - if true (-i), generate a case-insensitive scanner
* lex_compat - if true (-l), maximize compatibility with AT&T lex
* do_yylineno - if true, generate code to maintain yylineno
* useecs - if true (-Ce flag), use equivalence classes
* fulltbl - if true (-Cf flag), don't compress the DFA state table
* usemecs - if true (-Cm flag), use meta-equivalence classes
@ -333,6 +368,8 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
* otherwise, use fread().
* yytext_is_array - if true (i.e., %array directive), then declare
* yytext as a array instead of a character pointer. Nice and inefficient.
* do_yywrap - do yywrap() processing on EOF. If false, EOF treated as
* "no more files".
* csize - size of character set for the scanner we're generating;
* 128 for 7-bit chars and 256 for 8-bit
* yymore_used - if true, yymore() is used in input rules
@ -341,20 +378,20 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
* having "reject" set for variable trailing context)
* continued_action - true if this rule's action is to "fall through" to
* the next rule's action (i.e., the '|' action)
* yymore_really_used - has a REALLY_xxx value indicating whether a
* %used or %notused was used with yymore()
* in_rule - true if we're inside an individual rule, false if not.
* yymore_really_used - whether to treat yymore() as really used, regardless
* of what we think based on references to it in the user's actions.
* reject_really_used - same for REJECT
*/
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
extern int interactive, caseins, lex_compat, useecs, fulltbl, usemecs;
extern int fullspd, gen_line_dirs, performance_report, backing_up_report;
extern int C_plus_plus, long_align, use_read, yytext_is_array, csize;
extern int yymore_used, reject, real_reject, continued_action;
extern int interactive, caseins, lex_compat, do_yylineno;
extern int useecs, fulltbl, usemecs, fullspd;
extern int gen_line_dirs, performance_report, backing_up_report;
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
extern int csize;
extern int yymore_used, reject, real_reject, continued_action, in_rule;
#define REALLY_NOT_DETERMINED 0
#define REALLY_USED 1
#define REALLY_NOT_USED 2
extern int yymore_really_used, reject_really_used;
@ -363,12 +400,19 @@ extern int yymore_really_used, reject_really_used;
* dataline - number of contiguous lines of data in current data
* statement. Used to generate readable -f output
* linenum - current input line number
* out_linenum - current output line number
* skelfile - the skeleton file
* skel - compiled-in skeleton array
* skel_ind - index into "skel" array, if skelfile is nil
* yyin - input file
* backing_up_file - file to summarize backing-up states to
* infilename - name of input file
* outfilename - name of output file
* did_outfilename - whether outfilename was explicitly set
* prefix - the prefix used for externally visible names ("yy" by default)
* yyclass - yyFlexLexer subclass to use for YY_DECL
* do_stdinit - whether to initialize yyin/yyout to stdin/stdout
* use_stdout - the -t flag
* input_files - array holding names of input files
* num_input_files - size of input_files array
* program_name - name with which program was invoked
@ -383,11 +427,14 @@ extern int yymore_really_used, reject_really_used;
* to "action_array"
*/
extern int datapos, dataline, linenum;
extern int datapos, dataline, linenum, out_linenum;
extern FILE *skelfile, *yyin, *backing_up_file;
extern char *skel[];
extern const char *skel[];
extern int skel_ind;
extern char *infilename;
extern char *infilename, *outfilename;
extern int did_outfilename;
extern char *prefix, *yyclass;
extern int do_stdinit, use_stdout;
extern char **input_files;
extern int num_input_files;
extern char *program_name;
@ -438,8 +485,8 @@ extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
* rule_useful - true if we've determined that the rule can be matched
*/
extern int current_mns, num_rules, num_eof_rules, default_rule;
extern int current_max_rules, lastnfa;
extern int current_mns, current_max_rules;
extern int num_rules, num_eof_rules, default_rule, lastnfa;
extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
extern int *accptnum, *assoc_rule, *state_type;
extern int *rule_type, *rule_linenum, *rule_useful;
@ -513,16 +560,10 @@ extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
* scxclu - true if start condition is exclusive
* sceof - true if start condition has EOF rule
* scname - start condition name
* actvsc - stack of active start conditions for the current rule;
* a negative entry means that the start condition is *not*
* active for the current rule. Start conditions may appear
* multiple times on the stack; the entry for it closest
* to the top of the stack (i.e., actvsc[actvp]) is the
* one to use. Others are present from "<sc>{" scoping
* constructs.
*/
extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
extern int lastsc, *scset, *scbol, *scxclu, *sceof;
extern int current_max_scs;
extern char **scname;
@ -581,8 +622,8 @@ extern int end_of_buffer_state;
* ccltbl - holds the characters in each ccl - indexed by cclmap
*/
extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
extern int current_max_ccl_tbl_size;
extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
extern int current_maxccls, current_max_ccl_tbl_size;
extern Char *ccltbl;
@ -611,11 +652,11 @@ extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
extern int num_backing_up, bol_needed;
void *allocate_array PROTO((int, int));
void *reallocate_array PROTO((void*, int, int));
void *allocate_array PROTO((int, size_t));
void *reallocate_array PROTO((void*, int, size_t));
void *flex_alloc PROTO((unsigned int));
void *flex_realloc PROTO((void*, unsigned int));
void *flex_alloc PROTO((size_t));
void *flex_realloc PROTO((void*, size_t));
void flex_free PROTO((void*));
#define allocate_integer_array(size) \
@ -678,11 +719,23 @@ extern void list_character_set PROTO((FILE*, int[]));
/* from file dfa.c */
/* Check a DFA state for backing up. */
extern void check_for_backing_up PROTO((int, int[]));
/* Check to see if NFA state set constitutes "dangerous" trailing context. */
extern void check_trailing_context PROTO((int*, int, int*, int));
/* Construct the epsilon closure of a set of ndfa states. */
extern int *epsclosure PROTO((int*, int*, int[], int*, int*));
/* Increase the maximum number of dfas. */
extern void increase_max_dfas PROTO((void));
extern void ntod PROTO((void)); /* convert a ndfa to a dfa */
/* Converts a set of ndfa states into a dfa state. */
extern int snstods PROTO((int[], int, int[], int, int, int*));
/* from file ecs.c */
@ -701,17 +754,61 @@ extern void mkechar PROTO((int, int[], int[]));
/* from file gen.c */
extern void do_indent PROTO((void)); /* indent to the current level */
/* Generate the code to keep backing-up information. */
extern void gen_backing_up PROTO((void));
/* Generate the code to perform the backing up. */
extern void gen_bu_action PROTO((void));
/* Generate full speed compressed transition table. */
extern void genctbl PROTO((void));
/* Generate the code to find the action number. */
extern void gen_find_action PROTO((void));
extern void genftbl PROTO((void)); /* generate full transition table */
/* Generate the code to find the next compressed-table state. */
extern void gen_next_compressed_state PROTO((char*));
/* Generate the code to find the next match. */
extern void gen_next_match PROTO((void));
/* Generate the code to find the next state. */
extern void gen_next_state PROTO((int));
/* Generate the code to make a NUL transition. */
extern void gen_NUL_trans PROTO((void));
/* Generate the code to find the start state. */
extern void gen_start_state PROTO((void));
/* Generate data statements for the transition tables. */
extern void gentabs PROTO((void));
/* Write out a formatted string at the current indentation level. */
extern void indent_put2s PROTO((char[], char[]));
/* Write out a string + newline at the current indentation level. */
extern void indent_puts PROTO((char[]));
extern void make_tables PROTO((void)); /* generate transition tables */
/* from file main.c */
extern void check_options PROTO((void));
extern void flexend PROTO((int));
extern void usage PROTO((void));
/* from file misc.c */
/* Add a #define to the action file. */
extern void action_define PROTO(( char *defname, int value ));
/* Add the given text to the stored actions. */
extern void add_action PROTO(( char *new_text ));
@ -727,26 +824,41 @@ extern void bubble PROTO((int [], int));
/* Check a character to make sure it's in the expected range. */
extern void check_char PROTO((int c));
/* Replace upper-case letter to lower-case. */
extern Char clower PROTO((int));
/* Returns a dynamically allocated copy of a string. */
extern char *copy_string PROTO((register const char *));
/* Returns a dynamically allocated copy of a (potentially) unsigned string. */
extern Char *copy_unsigned_string PROTO((register Char *));
/* Shell sort a character array. */
extern void cshell PROTO((Char [], int, int));
/* Finish up a block of data declarations. */
extern void dataend PROTO((void));
/* Flush generated data statements. */
extern void dataflush PROTO((void));
/* Report an error message and terminate. */
extern void flexerror PROTO((char[]));
extern void flexerror PROTO((const char[]));
/* Report a fatal error message and terminate. */
extern void flexfatal PROTO((char[]));
extern void flexfatal PROTO((const char[]));
/* Convert a hexadecimal digit string to an integer value. */
extern int htoi PROTO((Char[]));
/* Report an error message formatted with one integer argument. */
extern void lerrif PROTO((char[], int));
extern void lerrif PROTO((const char[], int));
/* Report an error message formatted with one string argument. */
extern void lerrsf PROTO((char[], char[]));
extern void lerrsf PROTO((const char[], const char[]));
/* Spit out a "# line" statement. */
extern void line_directive_out PROTO((FILE*));
/* Spit out a "#line" statement. */
extern void line_directive_out PROTO((FILE*, int));
/* Mark the current position in the action array as the end of the section 1
* user defs.
@ -764,6 +876,25 @@ extern void mkdata PROTO((int)); /* generate a data statement */
/* Return the integer represented by a string of digits. */
extern int myctoi PROTO((char []));
/* Return character corresponding to escape sequence. */
extern Char myesc PROTO((Char[]));
/* Convert an octal digit string to an integer value. */
extern int otoi PROTO((Char [] ));
/* Output a (possibly-formatted) string to the generated scanner. */
extern void out PROTO((const char []));
extern void out_dec PROTO((const char [], int));
extern void out_dec2 PROTO((const char [], int, int));
extern void out_hex PROTO((const char [], unsigned int));
extern void out_line_count PROTO((const char []));
extern void out_str PROTO((const char [], const char []));
extern void out_str3
PROTO((const char [], const char [], const char [], const char []));
extern void out_str_dec PROTO((const char [], const char [], int));
extern void outc PROTO((int));
extern void outn PROTO((const char []));
/* Return a printable version of the given character, which might be
* 8-bit.
*/
@ -779,7 +910,7 @@ extern void transition_struct_out PROTO((int, int));
extern void *yy_flex_xmalloc PROTO(( int ));
/* Set a region of memory to 0. */
extern void zero_out PROTO((char *, int));
extern void zero_out PROTO((char *, size_t));
/* from file nfa.c */
@ -826,6 +957,9 @@ extern void new_rule PROTO((void)); /* initialize for a new rule */
/* from file parse.y */
/* Build the "<<EOF>>" action for the active start conditions. */
extern void build_eof_action PROTO((void));
/* Write out a message formatted with one string, pinpointing its location. */
extern void format_pinpoint_message PROTO((char[], char[]));
@ -833,15 +967,17 @@ extern void format_pinpoint_message PROTO((char[], char[]));
extern void pinpoint_message PROTO((char[]));
/* Write out a warning, pinpointing it at the given line. */
void line_warning PROTO(( char[], int ));
extern void line_warning PROTO(( char[], int ));
/* Write out a message, pinpointing it at the given line. */
void line_pinpoint PROTO(( char[], int ));
extern void line_pinpoint PROTO(( char[], int ));
/* Report a formatted syntax error. */
extern void format_synerr PROTO((char [], char[]));
extern void synerr PROTO((char [])); /* report a syntax error */
extern void format_warn PROTO((char [], char[]));
extern void warn PROTO((char [])); /* report a warning */
extern void yyerror PROTO((char [])); /* report a parse error */
extern int yyparse PROTO((void)); /* the YACC parser */
@ -859,13 +995,21 @@ extern int yywrap PROTO((void));
/* from file sym.c */
/* Add symbol and definitions to symbol table. */
extern int addsym PROTO((register char[], char*, int, hash_table, int));
/* Save the text of a character class. */
extern void cclinstal PROTO ((Char [], int));
/* Lookup the number associated with character class. */
extern int ccllookup PROTO((Char []));
/* Find symbol in symbol table. */
extern struct hash_entry *findsym PROTO((register char[], hash_table, int ));
extern void ndinstal PROTO((char[], Char[])); /* install a name definition */
extern Char *ndlookup PROTO((char[])); /* lookup a name definition */
/* Increase maximum number of SC's. */
extern void scextend PROTO((void));
extern void scinstal PROTO((char[], int)); /* make a start condition */
@ -881,6 +1025,8 @@ extern void bldtbl PROTO((int[], int, int, int, int));
extern void cmptmps PROTO((void)); /* compress template table entries */
extern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */
/* Finds a space in the table for a state to be placed. */
extern int find_table_space PROTO((int*, int));
extern void inittbl PROTO((void)); /* initialize transition tables */
/* Make the default, "jam" table entries. */
extern void mkdeftbl PROTO((void));

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/flex-2.4.7/RCS/gen.c,v 1.3 94/08/03 11:37:45 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/gen.c,v 2.56 96/05/25 20:43:38 vern Exp $ */
#include "flexdef.h"
@ -50,11 +50,11 @@ static int indent_level = 0; /* each level is 8 spaces */
* to this is that the fast table representation generally uses the
* 0 elements of its arrays, too.)
*/
static char C_int_decl[] = "static const int %s[%d] =\n { 0,\n";
static char C_short_decl[] = "static const short int %s[%d] =\n { 0,\n";
static char C_long_decl[] = "static const long int %s[%d] =\n { 0,\n";
static char C_int_decl[] = "static yyconst int %s[%d] =\n { 0,\n";
static char C_short_decl[] = "static yyconst short int %s[%d] =\n { 0,\n";
static char C_long_decl[] = "static yyconst long int %s[%d] =\n { 0,\n";
static char C_state_decl[] =
"static const yy_state_type %s[%d] =\n { 0,\n";
"static yyconst yy_state_type %s[%d] =\n { 0,\n";
/* Indent to the current level. */
@ -65,13 +65,13 @@ void do_indent()
while ( i >= 8 )
{
putchar( '\t' );
outc( '\t' );
i -= 8;
}
while ( i > 0 )
{
putchar( ' ' );
outc( ' ' );
--i;
}
}
@ -121,7 +121,7 @@ void gen_bu_action()
indent_puts( "yy_current_state = yy_last_accepting_state;" );
indent_puts( "goto yy_find_action;" );
putchar( '\n' );
outc( '\n' );
set_indent( 0 );
}
@ -135,9 +135,9 @@ void genctbl()
int end_of_buffer_action = num_rules + 1;
/* Table of verify for transition and offset to next state. */
printf( "static const struct yy_trans_info yy_transition[%d] =\n",
out_dec( "static yyconst struct yy_trans_info yy_transition[%d] =\n",
tblend + numecs + 1 );
printf( " {\n" );
outn( " {" );
/* We want the transition to be represented as the offset to the
* next state, not the actual state number, which is what it currently
@ -205,17 +205,16 @@ void genctbl()
transition_struct_out( chk[tblend + 1], nxt[tblend + 1] );
transition_struct_out( chk[tblend + 2], nxt[tblend + 2] );
printf( " };\n" );
printf( "\n" );
outn( " };\n" );
/* Table of pointers to start states. */
printf(
"static const struct yy_trans_info *yy_start_state_list[%d] =\n",
out_dec(
"static yyconst struct yy_trans_info *yy_start_state_list[%d] =\n",
lastsc * 2 + 1 );
printf( " {\n" ); /* } so vi doesn't get confused */
outn( " {" ); /* } so vi doesn't get confused */
for ( i = 0; i <= lastsc * 2; ++i )
printf( " &yy_transition[%d],\n", base[i] );
out_dec( " &yy_transition[%d],\n", base[i] );
dataend();
@ -228,11 +227,10 @@ void genctbl()
void genecs()
{
Char clower();
register int i, j;
int numrows;
printf( C_int_decl, "yy_ec", csize );
out_str_dec( C_int_decl, "yy_ec", csize );
for ( i = 1; i < csize; ++i )
{
@ -247,7 +245,7 @@ void genecs()
if ( trace )
{
fputs( "\n\nEquivalence Classes:\n\n", stderr );
fputs( _( "\n\nEquivalence Classes:\n\n" ), stderr );
numrows = csize / 8;
@ -282,7 +280,7 @@ void gen_find_action()
indent_puts( "yy_current_state = *--yy_state_ptr;" );
indent_puts( "yy_lp = yy_accept[yy_current_state];" );
puts(
outn(
"find_rule: /* we branch to this label when backing up */" );
indent_puts(
@ -354,17 +352,17 @@ void gen_find_action()
}
else
{
/* Remember matched text in case we back up due to trailing
* context plus REJECT.
*/
indent_up();
indent_puts( "{" );
indent_puts( "yy_full_match = yy_cp;" );
indent_puts( "break;" );
indent_puts( "}" );
indent_down();
}
{
/* Remember matched text in case we back up due to
* trailing context plus REJECT.
*/
indent_up();
indent_puts( "{" );
indent_puts( "yy_full_match = yy_cp;" );
indent_puts( "break;" );
indent_puts( "}" );
indent_down();
}
indent_puts( "}" );
indent_down();
@ -384,19 +382,36 @@ void gen_find_action()
}
else
/* compressed */
{ /* compressed */
indent_puts( "yy_act = yy_accept[yy_current_state];" );
if ( interactive && ! reject )
{
/* Do the guaranteed-needed backing up to figure out
* the match.
*/
indent_puts( "if ( yy_act == 0 )" );
indent_up();
indent_puts( "{ /* have to back up */" );
indent_puts( "yy_cp = yy_last_accepting_cpos;" );
indent_puts(
"yy_current_state = yy_last_accepting_state;" );
indent_puts( "yy_act = yy_accept[yy_current_state];" );
indent_puts( "}" );
indent_down();
}
}
}
/* genftbl - generates full transition table */
/* genftbl - generate full transition table */
void genftbl()
{
register int i;
int end_of_buffer_action = num_rules + 1;
printf( long_align ? C_long_decl : C_short_decl,
out_str_dec( long_align ? C_long_decl : C_short_decl,
"yy_accept", lastdfa + 1 );
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
@ -408,7 +423,7 @@ void genftbl()
mkdata( anum );
if ( trace && anum )
fprintf( stderr, "state # %d accepts: [%d]\n",
fprintf( stderr, _( "state # %d accepts: [%d]\n" ),
i, anum );
}
@ -454,7 +469,7 @@ char *char_map;
do_indent();
/* lastdfa + 2 is the beginning of the templates */
printf( "if ( yy_current_state >= %d )\n", lastdfa + 2 );
out_dec( "if ( yy_current_state >= %d )\n", lastdfa + 2 );
indent_up();
indent_puts( "yy_c = yy_meta[(unsigned int) yy_c];" );
@ -496,7 +511,7 @@ void gen_next_match()
{
indent_puts( "{" ); /* } for vi */
gen_backing_up();
putchar( '\n' );
outc( '\n' );
}
indent_puts( "++yy_cp;" );
@ -507,7 +522,7 @@ void gen_next_match()
indent_down();
putchar( '\n' );
outc( '\n' );
indent_puts( "yy_current_state = -yy_current_state;" );
}
@ -515,7 +530,7 @@ void gen_next_match()
{
indent_puts( "{" ); /* } for vi */
indent_puts(
"register const struct yy_trans_info *yy_trans_info;\n" );
"register yyconst struct yy_trans_info *yy_trans_info;\n" );
indent_puts( "register YY_CHAR yy_c;\n" );
indent_put2s( "for ( yy_c = %s;", char_map );
indent_puts(
@ -532,7 +547,7 @@ void gen_next_match()
if ( num_backing_up > 0 )
{
putchar( '\n' );
outc( '\n' );
gen_backing_up(); /* { for vi */
indent_puts( "}" );
}
@ -559,10 +574,10 @@ void gen_next_match()
do_indent();
if ( interactive )
printf( "while ( yy_base[yy_current_state] != %d );\n",
out_dec( "while ( yy_base[yy_current_state] != %d );\n",
jambase );
else
printf( "while ( yy_current_state != %d );\n",
out_dec( "while ( yy_current_state != %d );\n",
jamstate );
if ( ! reject && ! interactive )
@ -582,7 +597,7 @@ void gen_next_match()
void gen_next_state( worry_about_NULs )
int worry_about_NULs;
{ /* NOTE - changes in here should be reflected in get_next_match() */
{ /* NOTE - changes in here should be reflected in gen_next_match() */
char char_map[256];
if ( worry_about_NULs && ! nultrans )
@ -597,8 +612,8 @@ int worry_about_NULs;
}
else
strcpy( char_map, useecs ? "yy_ec[YY_SC_TO_UI(*yy_cp)]" :
"YY_SC_TO_UI(*yy_cp)" );
strcpy( char_map, useecs ?
"yy_ec[YY_SC_TO_UI(*yy_cp)]" : "YY_SC_TO_UI(*yy_cp)" );
if ( worry_about_NULs && nultrans )
{
@ -647,14 +662,19 @@ int worry_about_NULs;
/* Generate the code to make a NUL transition. */
void gen_NUL_trans()
{ /* NOTE - changes in here should be reflected in get_next_match() */
{ /* NOTE - changes in here should be reflected in gen_next_match() */
/* Only generate a definition for "yy_cp" if we'll generate code
* that uses it. Otherwise lint and the like complain.
*/
int need_backing_up = (num_backing_up > 0 && ! reject);
if ( need_backing_up )
/* We'll need yy_cp lying around for the gen_backing_up(). */
if ( need_backing_up && (! nultrans || fullspd || fulltbl) )
/* We're going to need yy_cp lying around for the call
* below to gen_backing_up().
*/
indent_puts( "register char *yy_cp = yy_c_buf_p;" );
putchar( '\n' );
outc( '\n' );
if ( nultrans )
{
@ -666,7 +686,7 @@ void gen_NUL_trans()
else if ( fulltbl )
{
do_indent();
printf( "yy_current_state = yy_nxt[yy_current_state][%d];\n",
out_dec( "yy_current_state = yy_nxt[yy_current_state][%d];\n",
NUL_ec );
indent_puts( "yy_is_jam = (yy_current_state <= 0);" );
}
@ -674,10 +694,10 @@ void gen_NUL_trans()
else if ( fullspd )
{
do_indent();
printf( "register int yy_c = %d;\n", NUL_ec );
out_dec( "register int yy_c = %d;\n", NUL_ec );
indent_puts(
"register const struct yy_trans_info *yy_trans_info;\n" );
"register yyconst struct yy_trans_info *yy_trans_info;\n" );
indent_puts(
"yy_trans_info = &yy_current_state[(unsigned int) yy_c];" );
indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" );
@ -693,12 +713,20 @@ void gen_NUL_trans()
(void) sprintf( NUL_ec_str, "%d", NUL_ec );
gen_next_compressed_state( NUL_ec_str );
if ( reject )
indent_puts( "*yy_state_ptr++ = yy_current_state;" );
do_indent();
out_dec( "yy_is_jam = (yy_current_state == %d);\n", jamstate );
printf( "yy_is_jam = (yy_current_state == %d);\n", jamstate );
if ( reject )
{
/* Only stack this state if it's a transition we
* actually make. If we stack it on a jam, then
* the state stack and yy_c_buf_p get out of sync.
*/
indent_puts( "if ( ! yy_is_jam )" );
indent_up();
indent_puts( "*yy_state_ptr++ = yy_current_state;" );
indent_down();
}
}
/* If we've entered an accepting state, back up; note that
@ -707,7 +735,7 @@ void gen_NUL_trans()
*/
if ( need_backing_up && (fullspd || fulltbl) )
{
putchar( '\n' );
outc( '\n' );
indent_puts( "if ( ! yy_is_jam )" );
indent_up();
indent_puts( "{" );
@ -723,21 +751,23 @@ void gen_NUL_trans()
void gen_start_state()
{
if ( fullspd )
indent_put2s(
"yy_current_state = yy_start_state_list[yy_start%s];",
bol_needed ? " + (yy_bp[-1] == '\\n' ? 1 : 0)" : "" );
{
if ( bol_needed )
{
indent_puts(
"yy_current_state = yy_start_state_list[yy_start + YY_AT_BOL()];" );
}
else
indent_puts(
"yy_current_state = yy_start_state_list[yy_start];" );
}
else
{
indent_puts( "yy_current_state = yy_start;" );
if ( bol_needed )
{
indent_puts( "if ( yy_bp[-1] == '\\n' )" );
indent_up();
indent_puts( "++yy_current_state;" );
indent_down();
}
indent_puts( "yy_current_state += YY_AT_BOL();" );
if ( reject )
{
@ -756,12 +786,6 @@ void gentabs()
int i, j, k, *accset, nacc, *acc_array, total_states;
int end_of_buffer_action = num_rules + 1;
/* *Everything* is done in terms of arrays starting at 1, so provide
* a null entry for the zero element of all C arrays.
*/
static char C_char_decl[] =
"static const YY_CHAR %s[%d] =\n { 0,\n"; /* } for vi */
acc_array = allocate_integer_array( current_max_dfas );
nummt = 0;
@ -788,7 +812,7 @@ void gentabs()
accsiz[end_of_buffer_state] = 1;
dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list;
printf( long_align ? C_long_decl : C_short_decl,
out_str_dec( long_align ? C_long_decl : C_short_decl,
"yy_acclist", MAX( numas, 1 ) + 1 );
j = 1; /* index into "yy_acclist" array */
@ -804,7 +828,8 @@ void gentabs()
if ( trace )
fprintf( stderr,
"state # %d accepts: ", i );
_( "state # %d accepts: " ),
i );
for ( k = 1; k <= nacc; ++k )
{
@ -875,14 +900,14 @@ void gentabs()
*/
++k;
printf( long_align ? C_long_decl : C_short_decl, "yy_accept", k );
out_str_dec( long_align ? C_long_decl : C_short_decl, "yy_accept", k );
for ( i = 1; i <= lastdfa; ++i )
{
mkdata( acc_array[i] );
if ( ! reject && trace && acc_array[i] )
fprintf( stderr, "state # %d accepts: [%d]\n",
fprintf( stderr, _( "state # %d accepts: [%d]\n" ),
i, acc_array[i] );
}
@ -905,9 +930,10 @@ void gentabs()
*/
if ( trace )
fputs( "\n\nMeta-Equivalence Classes:\n", stderr );
fputs( _( "\n\nMeta-Equivalence Classes:\n" ),
stderr );
printf( C_int_decl, "yy_meta", numecs + 1 );
out_str_dec( C_int_decl, "yy_meta", numecs + 1 );
for ( i = 1; i <= numecs; ++i )
{
@ -923,7 +949,7 @@ void gentabs()
total_states = lastdfa + numtemps;
printf( (tblend >= MAX_SHORT || long_align) ?
out_str_dec( (tblend >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_base", total_states + 1 );
@ -958,7 +984,7 @@ void gentabs()
dataend();
printf( (total_states >= MAX_SHORT || long_align) ?
out_str_dec( (total_states >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_def", total_states + 1 );
@ -967,13 +993,16 @@ void gentabs()
dataend();
printf( (total_states >= MAX_SHORT || long_align) ?
out_str_dec( (total_states >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_nxt", tblend + 1 );
for ( i = 1; i <= tblend; ++i )
{
if ( nxt[i] == 0 || chk[i] == 0 )
/* Note, the order of the following test is important.
* If chk[i] is 0, then nxt[i] is undefined.
*/
if ( chk[i] == 0 || nxt[i] == 0 )
nxt[i] = jamstate; /* new state is the JAM state */
mkdata( nxt[i] );
@ -981,7 +1010,7 @@ void gentabs()
dataend();
printf( (total_states >= MAX_SHORT || long_align) ?
out_str_dec( (total_states >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_chk", tblend + 1 );
@ -1005,8 +1034,8 @@ void indent_put2s( fmt, arg )
char fmt[], arg[];
{
do_indent();
printf( fmt, arg );
putchar( '\n' );
out_str( fmt, arg );
outn( "" );
}
@ -1018,7 +1047,7 @@ void indent_puts( str )
char str[];
{
do_indent();
puts( str );
outn( str );
}
@ -1037,26 +1066,44 @@ void make_tables()
*/
set_indent( 1 );
if ( yymore_used )
if ( yymore_used && ! yytext_is_array )
{
indent_puts( "yytext_ptr -= yy_more_len; \\" );
indent_puts( "yyleng = yy_cp - yytext_ptr; \\" );
indent_puts( "yyleng = (int) (yy_cp - yytext_ptr); \\" );
}
else
indent_puts( "yyleng = yy_cp - yy_bp; \\" );
indent_puts( "yyleng = (int) (yy_cp - yy_bp); \\" );
/* Now also deal with copying yytext_ptr to yytext if needed. */
skelout();
if ( yytext_is_array )
{
indent_puts( "if ( yyleng >= YYLMAX ) \\" );
if ( yymore_used )
indent_puts(
"if ( yyleng + yy_more_offset >= YYLMAX ) \\" );
else
indent_puts( "if ( yyleng >= YYLMAX ) \\" );
indent_up();
indent_puts(
"YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\" );
indent_down();
indent_puts(
if ( yymore_used )
{
indent_puts(
"yy_flex_strncpy( &yytext[yy_more_offset], yytext_ptr, yyleng + 1 ); \\" );
indent_puts( "yyleng += yy_more_offset; \\" );
indent_puts(
"yy_prev_more_offset = yy_more_offset; \\" );
indent_puts( "yy_more_offset = 0; \\" );
}
else
{
indent_puts(
"yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \\" );
}
}
set_indent( 0 );
@ -1064,7 +1111,8 @@ void make_tables()
skelout();
printf( "#define YY_END_OF_BUFFER %d\n", num_rules + 1 );
out_dec( "#define YY_NUM_RULES %d\n", num_rules );
out_dec( "#define YY_END_OF_BUFFER %d\n", num_rules + 1 );
if ( fullspd )
{
@ -1123,12 +1171,12 @@ void make_tables()
if ( nultrans )
{
printf( C_state_decl, "yy_NUL_trans", lastdfa + 1 );
out_str_dec( C_state_decl, "yy_NUL_trans", lastdfa + 1 );
for ( i = 1; i <= lastdfa; ++i )
{
if ( fullspd )
printf( " &yy_transition[%d],\n", base[i] );
out_dec( " &yy_transition[%d],\n", base[i] );
else
mkdata( nultrans[i] );
}
@ -1138,10 +1186,13 @@ void make_tables()
if ( ddebug )
{ /* Spit out table mapping rules to line numbers. */
indent_puts( "extern int yy_flex_debug;" );
indent_puts( "int yy_flex_debug = 1;\n" );
if ( ! C_plus_plus )
{
indent_puts( "extern int yy_flex_debug;" );
indent_puts( "int yy_flex_debug = 1;\n" );
}
printf( long_align ? C_long_decl : C_short_decl,
out_str_dec( long_align ? C_long_decl : C_short_decl,
"yy_rule_linenum", num_rules );
for ( i = 1; i < num_rules; ++i )
mkdata( rule_linenum[i] );
@ -1153,94 +1204,124 @@ void make_tables()
/* Declare state buffer variables. */
if ( ! C_plus_plus )
{
puts(
outn(
"static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;" );
puts( "static char *yy_full_match;" );
puts( "static int yy_lp;" );
outn( "static char *yy_full_match;" );
outn( "static int yy_lp;" );
}
if ( variable_trailing_context_rules )
{
if ( ! C_plus_plus )
{
puts(
outn(
"static int yy_looking_for_trail_begin = 0;" );
puts( "static int yy_full_lp;" );
puts( "static int *yy_full_state;" );
outn( "static int yy_full_lp;" );
outn( "static int *yy_full_state;" );
}
printf( "#define YY_TRAILING_MASK 0x%x\n",
out_hex( "#define YY_TRAILING_MASK 0x%x\n",
(unsigned int) YY_TRAILING_MASK );
printf( "#define YY_TRAILING_HEAD_MASK 0x%x\n",
out_hex( "#define YY_TRAILING_HEAD_MASK 0x%x\n",
(unsigned int) YY_TRAILING_HEAD_MASK );
}
puts( "#define REJECT \\" );
puts( "{ \\" ); /* } for vi */
puts(
outn( "#define REJECT \\" );
outn( "{ \\" ); /* } for vi */
outn(
"*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \\" );
puts(
outn(
"yy_cp = yy_full_match; /* restore poss. backed-over text */ \\" );
if ( variable_trailing_context_rules )
{
puts(
outn(
"yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \\" );
puts(
outn(
"yy_state_ptr = yy_full_state; /* restore orig. state */ \\" );
puts(
outn(
"yy_current_state = *yy_state_ptr; /* restore curr. state */ \\" );
}
puts( "++yy_lp; \\" );
puts( "goto find_rule; \\" );
outn( "++yy_lp; \\" );
outn( "goto find_rule; \\" );
/* { for vi */
puts( "}" );
outn( "}" );
}
else
{
puts(
outn(
"/* The intent behind this definition is that it'll catch" );
puts( " * any uses of REJECT which flex missed." );
puts( " */" );
puts( "#define REJECT reject_used_but_not_detected" );
outn( " * any uses of REJECT which flex missed." );
outn( " */" );
outn( "#define REJECT reject_used_but_not_detected" );
}
if ( yymore_used )
{
if ( ! C_plus_plus )
{
indent_puts( "static int yy_more_flag = 0;" );
indent_puts( "static int yy_more_len = 0;" );
if ( yytext_is_array )
{
indent_puts( "static int yy_more_offset = 0;" );
indent_puts(
"static int yy_prev_more_offset = 0;" );
}
else
{
indent_puts( "static int yy_more_flag = 0;" );
indent_puts( "static int yy_more_len = 0;" );
}
}
indent_puts( "#define yymore() (yy_more_flag = 1)" );
indent_puts( "#define YY_MORE_ADJ yy_more_len" );
if ( yytext_is_array )
{
indent_puts(
"#define yymore() (yy_more_offset = yy_flex_strlen( yytext ))" );
indent_puts( "#define YY_NEED_STRLEN" );
indent_puts( "#define YY_MORE_ADJ 0" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET \\" );
indent_up();
indent_puts( "{ \\" );
indent_puts( "yy_more_offset = yy_prev_more_offset; \\" );
indent_puts( "yyleng -= yy_more_offset; \\" );
indent_puts( "}" );
indent_down();
}
else
{
indent_puts( "#define yymore() (yy_more_flag = 1)" );
indent_puts( "#define YY_MORE_ADJ yy_more_len" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET" );
}
}
else
{
indent_puts( "#define yymore() yymore_used_but_not_detected" );
indent_puts( "#define YY_MORE_ADJ 0" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET" );
}
if ( ! C_plus_plus )
{
if ( yytext_is_array )
{
puts( "#ifndef YYLMAX" );
puts( "#define YYLMAX 8192" );
puts( "#endif\n" );
puts( "char yytext[YYLMAX];" );
puts( "char *yytext_ptr;" );
outn( "#ifndef YYLMAX" );
outn( "#define YYLMAX 8192" );
outn( "#endif\n" );
outn( "char yytext[YYLMAX];" );
outn( "char *yytext_ptr;" );
}
else
puts( "char *yytext;" );
outn( "char *yytext;" );
}
fputs( &action_array[defs1_offset], stdout );
out( &action_array[defs1_offset] );
line_directive_out( stdout, 0 );
skelout();
@ -1248,45 +1329,69 @@ void make_tables()
{
if ( use_read )
{
printf(
"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\\n" );
printf(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
outn(
"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
else
{
printf(
"\tif ( yy_current_buffer->yy_is_interactive ) \\\n" );
printf( "\t\t{ \\\n" );
printf( "\t\tint c = getc( yyin ); \\\n" );
printf( "\t\tresult = c == EOF ? 0 : 1; \\\n" );
printf( "\t\tbuf[0] = (char) c; \\\n" );
printf( "\t\t} \\\n" );
printf(
"\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\\n" );
printf( "\t\t && ferror( yyin ) ) \\\n" );
printf(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
outn(
"\tif ( yy_current_buffer->yy_is_interactive ) \\" );
outn( "\t\t{ \\" );
outn( "\t\tint c = '*', n; \\" );
outn( "\t\tfor ( n = 0; n < max_size && \\" );
outn( "\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\" );
outn( "\t\t\tbuf[n] = (char) c; \\" );
outn( "\t\tif ( c == '\\n' ) \\" );
outn( "\t\t\tbuf[n++] = (char) c; \\" );
outn( "\t\tif ( c == EOF && ferror( yyin ) ) \\" );
outn(
"\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
outn( "\t\tresult = n; \\" );
outn( "\t\t} \\" );
outn(
"\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\" );
outn( "\t\t && ferror( yyin ) ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
}
skelout();
indent_puts( "#define YY_RULE_SETUP \\" );
indent_up();
if ( bol_needed )
{
indent_puts( "if ( yyleng > 0 ) \\" );
indent_up();
indent_puts( "yy_current_buffer->yy_at_bol = \\" );
indent_puts( "\t\t(yytext[yyleng - 1] == '\\n'); \\" );
indent_down();
}
indent_puts( "YY_USER_ACTION" );
indent_down();
skelout();
/* Copy prolog to output file. */
fputs( &action_array[prolog_offset], stdout );
out( &action_array[prolog_offset] );
line_directive_out( stdout, 0 );
skelout();
set_indent( 2 );
if ( yymore_used )
if ( yymore_used && ! yytext_is_array )
{
indent_puts( "yy_more_len = 0;" );
indent_puts( "if ( yy_more_flag )" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_more_len = yyleng;" );
indent_puts( "yy_more_len = yy_c_buf_p - yytext_ptr;" );
indent_puts( "yy_more_flag = 0;" );
indent_puts( "}" );
indent_down();
@ -1297,7 +1402,7 @@ void make_tables()
gen_start_state();
/* Note, don't use any indentation. */
puts( "yy_match:" );
outn( "yy_match:" );
gen_next_match();
skelout();
@ -1305,7 +1410,7 @@ void make_tables()
gen_find_action();
skelout();
if ( lex_compat )
if ( do_yylineno )
{
indent_puts( "if ( yy_act != YY_END_OF_BUFFER )" );
indent_up();
@ -1331,38 +1436,76 @@ void make_tables()
indent_puts( "{" );
indent_puts( "if ( yy_act == 0 )" );
indent_up();
indent_puts(
indent_puts( C_plus_plus ?
"cerr << \"--scanner backing up\\n\";" :
"fprintf( stderr, \"--scanner backing up\\n\" );" );
indent_down();
do_indent();
printf( "else if ( yy_act < %d )\n", num_rules );
out_dec( "else if ( yy_act < %d )\n", num_rules );
indent_up();
indent_puts(
if ( C_plus_plus )
{
indent_puts(
"cerr << \"--accepting rule at line \" << yy_rule_linenum[yy_act] <<" );
indent_puts(
" \"(\\\"\" << yytext << \"\\\")\\n\";" );
}
else
{
indent_puts(
"fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
indent_puts( " yy_rule_linenum[yy_act], yytext );" );
indent_puts(
" yy_rule_linenum[yy_act], yytext );" );
}
indent_down();
do_indent();
printf( "else if ( yy_act == %d )\n", num_rules );
out_dec( "else if ( yy_act == %d )\n", num_rules );
indent_up();
indent_puts(
if ( C_plus_plus )
{
indent_puts(
"cerr << \"--accepting default rule (\\\"\" << yytext << \"\\\")\\n\";" );
}
else
{
indent_puts(
"fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," );
indent_puts( " yytext );" );
indent_puts( " yytext );" );
}
indent_down();
do_indent();
printf( "else if ( yy_act == %d )\n", num_rules + 1 );
out_dec( "else if ( yy_act == %d )\n", num_rules + 1 );
indent_up();
indent_puts(
"fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );" );
indent_puts( C_plus_plus ?
"cerr << \"--(end of buffer or a NUL)\\n\";" :
"fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );" );
indent_down();
do_indent();
printf( "else\n" );
outn( "else" );
indent_up();
indent_puts(
if ( C_plus_plus )
{
indent_puts(
"cerr << \"--EOF (start condition \" << YY_START << \")\\n\";" );
}
else
{
indent_puts(
"fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );" );
}
indent_down();
indent_puts( "}" );
@ -1373,14 +1516,16 @@ void make_tables()
skelout();
indent_up();
gen_bu_action();
fputs( &action_array[action_offset], stdout );
out( &action_array[action_offset] );
line_directive_out( stdout, 0 );
/* generate cases for any missing EOF rules */
for ( i = 1; i <= lastsc; ++i )
if ( ! sceof[i] )
{
do_indent();
printf( "case YY_STATE_EOF(%s):\n", scname[i] );
out_str( "case YY_STATE_EOF(%s):\n", scname[i] );
did_eof_rule = true;
}
@ -1398,7 +1543,7 @@ void make_tables()
* finds that it should JAM on the NUL.
*/
skelout();
set_indent( 7 );
set_indent( 4 );
if ( fullspd || fulltbl )
indent_puts( "yy_cp = yy_c_buf_p;" );
@ -1428,9 +1573,6 @@ void make_tables()
set_indent( 1 );
skelout();
if ( bol_needed )
indent_puts( "register char *yy_bp = yytext_ptr;\n" );
gen_start_state();
set_indent( 2 );
@ -1442,7 +1584,7 @@ void make_tables()
gen_NUL_trans();
skelout();
if ( lex_compat )
if ( do_yylineno )
{ /* update yylineno inside of unput() */
indent_puts( "if ( c == '\\n' )" );
indent_up();
@ -1450,11 +1592,33 @@ void make_tables()
indent_down();
}
skelout();
/* Update BOL and yylineno inside of input(). */
if ( bol_needed )
{
indent_puts( "yy_current_buffer->yy_at_bol = (c == '\\n');" );
if ( do_yylineno )
{
indent_puts( "if ( yy_current_buffer->yy_at_bol )" );
indent_up();
indent_puts( "++yylineno;" );
indent_down();
}
}
else if ( do_yylineno )
{
indent_puts( "if ( c == '\\n' )" );
indent_up();
indent_puts( "++yylineno;" );
indent_down();
}
skelout();
/* Copy remainder of input to output. */
line_directive_out( stdout );
line_directive_out( stdout, 1 );
if ( sectnum == 3 )
(void) flexscan(); /* copy remainder of input to output */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/* libmain - flex run-time support library "main" function */
/* $Header: /home/daffy/u0/vern/flex/RCS/libmain.c,v 1.3 93/04/14 22:41:55 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/libmain.c,v 1.4 95/09/27 12:47:55 vern Exp $ */
extern int yylex();
@ -8,5 +8,8 @@ int main( argc, argv )
int argc;
char *argv[];
{
return yylex();
while ( yylex() != 0 )
;
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -26,16 +26,27 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: misc.c,v 1.2 94/01/04 14:33:10 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/misc.c,v 2.47 95/04/28 11:39:39 vern Exp $ */
#include "flexdef.h"
void action_define( defname, value )
char *defname;
int value;
{
char buf[MAXLINE];
/* declare functions that have forward references */
if ( (int) strlen( defname ) > MAXLINE / 2 )
{
format_pinpoint_message( _( "name \"%s\" ridiculously long" ),
defname );
return;
}
void dataflush PROTO((void));
int otoi PROTO((Char []));
sprintf( buf, "#define %s %d\n", defname, value );
add_action( buf );
}
void add_action( new_text )
@ -45,7 +56,16 @@ char *new_text;
while ( len + action_index >= action_size - 10 /* slop */ )
{
action_size *= 2;
int new_size = action_size * 2;
if ( new_size <= 0 )
/* Increase just a little, to try to avoid overflow
* on 16-bit machines.
*/
action_size += action_size / 8;
else
action_size = new_size;
action_array =
reallocate_character_array( action_array, action_size );
}
@ -59,21 +79,16 @@ char *new_text;
/* allocate_array - allocate memory for an integer array of the given size */
void *allocate_array( size, element_size )
int size, element_size;
int size;
size_t element_size;
{
register void *mem;
size_t num_bytes = element_size * size;
/* On 16-bit int machines (e.g., 80286) we might be trying to
* allocate more than a signed int can hold, and that won't
* work. Cheap test:
*/
if ( element_size * size <= 0 )
flexfatal( "request for < 1 byte in allocate_array()" );
mem = flex_alloc( element_size * size );
if ( mem == NULL )
flexfatal( "memory allocation failed in allocate_array()" );
mem = flex_alloc( num_bytes );
if ( ! mem )
flexfatal(
_( "memory allocation failed in allocate_array()" ) );
return mem;
}
@ -151,11 +166,12 @@ void check_char( c )
int c;
{
if ( c >= CSIZE )
lerrsf( "bad character '%s' detected in check_char()",
lerrsf( _( "bad character '%s' detected in check_char()" ),
readable_form( c ) );
if ( c >= csize )
lerrsf( "scanner requires -8 flag to use the character '%s'",
lerrsf(
_( "scanner requires -8 flag to use the character %s" ),
readable_form( c ) );
}
@ -173,21 +189,24 @@ register int c;
/* copy_string - returns a dynamically allocated copy of a string */
char *copy_string( str )
register char *str;
register const char *str;
{
register char *c;
register const char *c1;
register char *c2;
char *copy;
unsigned int size;
/* find length */
for ( c = str; *c; ++c )
for ( c1 = str; *c1; ++c1 )
;
copy = (char *) flex_alloc( (c - str + 1) * sizeof( char ) );
size = (c1 - str + 1) * sizeof( char );
copy = (char *) flex_alloc( size );
if ( copy == NULL )
flexfatal( "dynamic memory failure in copy_string()" );
flexfatal( _( "dynamic memory failure in copy_string()" ) );
for ( c = copy; (*c++ = *str++); )
for ( c2 = copy; (*c2++ = *str++) != 0; )
;
return copy;
@ -210,7 +229,7 @@ register Char *str;
copy = allocate_Character_array( c - str + 1 );
for ( c = copy; (*c++ = *str++); )
for ( c = copy; (*c++ = *str++) != 0; )
;
return copy;
@ -275,7 +294,7 @@ void dataend()
dataflush();
/* add terminator for initialization; { for vi */
puts( " } ;\n" );
outn( " } ;\n" );
dataline = 0;
datapos = 0;
@ -286,14 +305,14 @@ void dataend()
void dataflush()
{
putchar( '\n' );
outc( '\n' );
if ( ++dataline >= NUMDATALINES )
{
/* Put out a blank line so that the table is grouped into
* large blocks that enable the user to find elements easily.
*/
putchar( '\n' );
outc( '\n' );
dataline = 0;
}
@ -305,7 +324,7 @@ void dataflush()
/* flexerror - report an error message and terminate */
void flexerror( msg )
char msg[];
const char msg[];
{
fprintf( stderr, "%s: %s\n", program_name, msg );
flexend( 1 );
@ -315,37 +334,14 @@ char msg[];
/* flexfatal - report a fatal error message and terminate */
void flexfatal( msg )
char msg[];
const char msg[];
{
fprintf( stderr, "%s: fatal internal error, %s\n", program_name, msg );
fprintf( stderr, _( "%s: fatal internal error, %s\n" ),
program_name, msg );
exit( 1 );
}
/* lerrif - report an error message formatted with one integer argument */
void lerrif( msg, arg )
char msg[];
int arg;
{
char errmsg[MAXLINE];
(void) sprintf( errmsg, msg, arg );
flexerror( errmsg );
}
/* lerrsf - report an error message formatted with one string argument */
void lerrsf( msg, arg )
char msg[], arg[];
{
char errmsg[MAXLINE];
(void) sprintf( errmsg, msg, arg );
flexerror( errmsg );
}
/* htoi - convert a hexadecimal digit string to an integer value */
int htoi( str )
@ -359,50 +355,82 @@ Char str[];
}
/* is_hex_digit - returns true if a character is a valid hex digit, false
* otherwise
*/
/* lerrif - report an error message formatted with one integer argument */
int is_hex_digit( ch )
int ch;
void lerrif( msg, arg )
const char msg[];
int arg;
{
if ( isdigit( ch ) )
return 1;
switch ( clower( ch ) )
{
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
return 1;
default:
return 0;
}
char errmsg[MAXLINE];
(void) sprintf( errmsg, msg, arg );
flexerror( errmsg );
}
/* line_directive_out - spit out a "# line" statement */
/* lerrsf - report an error message formatted with one string argument */
void line_directive_out( output_file )
FILE *output_file;
void lerrsf( msg, arg )
const char msg[], arg[];
{
if ( infilename && gen_line_dirs )
{
char directive[MAXLINE];
sprintf( directive, "# line %d \"%s\"\n", linenum, infilename );
char errmsg[MAXLINE];
/* If output_file is nil then we should put the directive in
* the accumulated actions.
*/
if ( output_file )
fputs( directive, output_file );
else
add_action( directive );
(void) sprintf( errmsg, msg, arg );
flexerror( errmsg );
}
/* line_directive_out - spit out a "#line" statement */
void line_directive_out( output_file, do_infile )
FILE *output_file;
int do_infile;
{
char directive[MAXLINE], filename[MAXLINE];
char *s1, *s2, *s3;
static char line_fmt[] = "#line %d \"%s\"\n";
if ( ! gen_line_dirs )
return;
if ( (do_infile && ! infilename) || (! do_infile && ! outfilename) )
/* don't know the filename to use, skip */
return;
s1 = do_infile ? infilename : outfilename;
s2 = filename;
s3 = &filename[sizeof( filename ) - 2];
while ( s2 < s3 && *s1 )
{
if ( *s1 == '\\' )
/* Escape the '\' */
*s2++ = '\\';
*s2++ = *s1++;
}
*s2 = '\0';
if ( do_infile )
sprintf( directive, line_fmt, linenum, filename );
else
{
if ( output_file == stdout )
/* Account for the line directive itself. */
++out_linenum;
sprintf( directive, line_fmt, out_linenum, filename );
}
/* If output_file is nil then we should put the directive in
* the accumulated actions.
*/
if ( output_file )
{
fputs( directive, output_file );
}
else
add_action( directive );
}
@ -439,20 +467,20 @@ int value;
{
if ( datapos >= NUMDATAITEMS )
{
putchar( ',' );
outc( ',' );
dataflush();
}
if ( datapos == 0 )
/* Indent. */
fputs( " ", stdout );
out( " " );
else
putchar( ',' );
outc( ',' );
++datapos;
printf( "%5d", value );
out_dec( "%5d", value );
}
@ -466,19 +494,19 @@ int value;
{
if ( datapos >= NUMDATAITEMS )
{
putchar( ',' );
outc( ',' );
dataflush();
}
if ( datapos == 0 )
/* Indent. */
fputs( " ", stdout );
out( " " );
else
putchar( ',' );
outc( ',' );
++datapos;
printf( "%5d", value );
out_dec( "%5d", value );
}
@ -510,7 +538,7 @@ Char array[];
case 'r': return '\r';
case 't': return '\t';
#ifdef __STDC__
#if __STDC__
case 'a': return '\a';
case 'v': return '\v';
#else
@ -526,8 +554,6 @@ Char array[];
case '5':
case '6':
case '7':
case '8':
case '9':
{ /* \<octal> */
int sptr = 1;
@ -554,7 +580,7 @@ Char array[];
int sptr = 2;
while ( isascii( array[sptr] ) &&
is_hex_digit( (char) array[sptr] ) )
isxdigit( (char) array[sptr] ) )
/* Don't increment inside loop control
* because if isdigit() is a macro it might
* expand into multiple increments ...
@ -589,6 +615,96 @@ Char str[];
}
/* out - various flavors of outputing a (possibly formatted) string for the
* generated scanner, keeping track of the line count.
*/
void out( str )
const char str[];
{
fputs( str, stdout );
out_line_count( str );
}
void out_dec( fmt, n )
const char fmt[];
int n;
{
printf( fmt, n );
out_line_count( fmt );
}
void out_dec2( fmt, n1, n2 )
const char fmt[];
int n1, n2;
{
printf( fmt, n1, n2 );
out_line_count( fmt );
}
void out_hex( fmt, x )
const char fmt[];
unsigned int x;
{
printf( fmt, x );
out_line_count( fmt );
}
void out_line_count( str )
const char str[];
{
register int i;
for ( i = 0; str[i]; ++i )
if ( str[i] == '\n' )
++out_linenum;
}
void out_str( fmt, str )
const char fmt[], str[];
{
printf( fmt, str );
out_line_count( fmt );
out_line_count( str );
}
void out_str3( fmt, s1, s2, s3 )
const char fmt[], s1[], s2[], s3[];
{
printf( fmt, s1, s2, s3 );
out_line_count( fmt );
out_line_count( s1 );
out_line_count( s2 );
out_line_count( s3 );
}
void out_str_dec( fmt, str, n )
const char fmt[], str[];
int n;
{
printf( fmt, str, n );
out_line_count( fmt );
out_line_count( str );
}
void outc( c )
int c;
{
putc( c, stdout );
if ( c == '\n' )
++out_linenum;
}
void outn( str )
const char str[];
{
puts( str );
out_line_count( str );
++out_linenum;
}
/* readable_form - return the the human-readable form of a character
*
* The returned string is in static storage.
@ -609,7 +725,7 @@ register int c;
case '\r': return "\\r";
case '\t': return "\\t";
#ifdef __STDC__
#if __STDC__
case '\a': return "\\a";
case '\v': return "\\v";
#endif
@ -638,19 +754,15 @@ register int c;
void *reallocate_array( array, size, element_size )
void *array;
int size, element_size;
int size;
size_t element_size;
{
register void *new_array;
size_t num_bytes = element_size * size;
/* Same worry as in allocate_array(): */
if ( size * element_size <= 0 )
flexfatal(
"attempt to increase array size by less than 1 byte" );
new_array = flex_realloc( array, size * element_size );
if ( new_array == NULL )
flexfatal( "attempt to increase array size failed" );
new_array = flex_realloc( array, num_bytes );
if ( ! new_array )
flexfatal( _( "attempt to increase array size failed" ) );
return new_array;
}
@ -673,7 +785,7 @@ void skelout()
*/
while ( skelfile ?
(fgets( buf, MAXLINE, skelfile ) != NULL) :
((buf = skel[skel_ind++]) != 0) )
((buf = (char *) skel[skel_ind++]) != 0) )
{ /* copy from skel array */
if ( buf[0] == '%' )
{ /* control line */
@ -696,7 +808,7 @@ void skelout()
default:
flexfatal(
"bad line in skeleton file" );
_( "bad line in skeleton file" ) );
}
}
@ -706,9 +818,9 @@ void skelout()
/* Skeleton file reads include final
* newline, skel[] array does not.
*/
fputs( buf, stdout );
out( buf );
else
printf( "%s\n", buf );
outn( buf );
}
}
}
@ -723,16 +835,16 @@ void skelout()
void transition_struct_out( element_v, element_n )
int element_v, element_n;
{
printf( "%7d, %5d,", element_v, element_n );
out_dec2( " {%4d,%4d },", element_v, element_n );
datapos += TRANS_STRUCT_PRINT_LENGTH;
if ( datapos >= 75 )
if ( datapos >= 79 - TRANS_STRUCT_PRINT_LENGTH )
{
putchar( '\n' );
outc( '\n' );
if ( ++dataline % 10 == 0 )
putchar( '\n' );
outc( '\n' );
datapos = 0;
}
@ -745,10 +857,11 @@ int element_v, element_n;
void *yy_flex_xmalloc( size )
int size;
{
void *result = flex_alloc( size );
void *result = flex_alloc( (size_t) size );
if ( ! result )
flexfatal( "memory allocation failed in yy_flex_xmalloc()" );
flexfatal(
_( "memory allocation failed in yy_flex_xmalloc()" ) );
return result;
}
@ -761,7 +874,7 @@ int size;
void zero_out( region_ptr, size_in_bytes )
char *region_ptr;
int size_in_bytes;
size_t size_in_bytes;
{
register char *rp, *rp_end;

View file

@ -1,11 +1,11 @@
#! /bin/sh
cat <<!
/* File created from flex.skel via mkskel.sh */
/* File created from flex.skl via mkskel.sh */
#include "flexdef.h"
char *skel[] = {
const char *skel[] = {
!
sed 's/\\/&&/g' $* | sed 's/"/\\"/g' | sed 's/.*/ "&",/'

View file

@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/flex-2.4.7/RCS/nfa.c,v 1.2 94/08/03 11:13:29 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/nfa.c,v 2.17 95/03/04 16:11:42 vern Exp $ */
#include "flexdef.h"
@ -97,7 +97,7 @@ int state1;
int sym, tsp1, tsp2, anum, ns;
fprintf( stderr,
"\n\n********** beginning dump of nfa with start state %d\n",
_( "\n\n********** beginning dump of nfa with start state %d\n" ),
state1 );
/* We probably should loop starting at firstst[state1] and going to
@ -109,7 +109,7 @@ int state1;
/* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
for ( ns = 1; ns <= lastnfa; ++ns )
{
fprintf( stderr, "state # %4d\t", ns );
fprintf( stderr, _( "state # %4d\t" ), ns );
sym = transchar[ns];
tsp1 = trans1[ns];
@ -124,7 +124,7 @@ int state1;
fprintf( stderr, "\n" );
}
fprintf( stderr, "********** end of dump\n" );
fprintf( stderr, _( "********** end of dump\n" ) );
}
@ -170,7 +170,7 @@ int mach;
}
if ( state == 0 )
flexfatal( "empty machine in dupmachine()" );
flexfatal( _( "empty machine in dupmachine()" ) );
state_offset = state - i + 1;
@ -222,7 +222,7 @@ int mach, variable_trail_rule, headcnt, trailcnt;
if ( performance_report > 0 )
fprintf( stderr,
"Variable trailing context rule at line %d\n",
_( "Variable trailing context rule at line %d\n" ),
rule_linenum[num_rules] );
variable_trailing_context_rules = true;
@ -265,12 +265,12 @@ int mach, variable_trail_rule, headcnt, trailcnt;
/* Okay, in the action code at this point yytext and yyleng have
* their proper final values for this rule, so here's the point
* to do any user action. But don't do it for continued actions,
* as that'll result in multiple YY_USER_ACTION's.
* as that'll result in multiple YY_RULE_SETUP's.
*/
if ( ! continued_action )
add_action( "YY_USER_ACTION\n" );
add_action( "YY_RULE_SETUP\n" );
line_directive_out( (FILE *) 0 );
line_directive_out( (FILE *) 0, 1 );
}
@ -344,7 +344,7 @@ register int mach;
default:
flexerror(
"bad state type in mark_beginning_as_normal()" );
_( "bad state type in mark_beginning_as_normal()" ) );
break;
}
}
@ -597,7 +597,7 @@ int sym;
{
if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS )
lerrif(
"input rules are too complicated (>= %d NFA states)",
_( "input rules are too complicated (>= %d NFA states)" ),
current_mns );
++num_reallocs;
@ -676,7 +676,7 @@ int statefrom, stateto;
else if ( (transchar[statefrom] != SYM_EPSILON) ||
(trans2[statefrom] != NO_TRANSITION) )
flexfatal( "found too many transitions in mkxtion()" );
flexfatal( _( "found too many transitions in mkxtion()" ) );
else
{ /* second out-transition for an epsilon state */
@ -702,7 +702,7 @@ void new_rule()
}
if ( num_rules > MAX_RULE )
lerrif( "too many rules (> %d)!", MAX_RULE );
lerrif( _( "too many rules (> %d)!" ), MAX_RULE );
rule_linenum[num_rules] = linenum;
rule_useful[num_rules] = false;

View file

@ -1,6 +1,10 @@
/* parse.y - parser for flex input */
%token CHAR NUMBER SECTEND SCDECL XSCDECL WHITESPACE NAME PREVCCL EOF_OP
%token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP
%token OPTION_OP OPT_OUTFILE OPT_PREFIX OPT_YYCLASS
%token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH
%token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT
%{
/*-
@ -29,7 +33,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/RCS/parse.y,v 2.15 93/12/09 13:57:23 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/parse.y,v 2.28 95/04/21 11:51:51 vern Exp $ */
/* Some versions of bison are broken in that they use alloca() but don't
@ -37,37 +41,63 @@
* #ifdef chud to fix the problem, courtesy of Francois Pinard.
*/
#ifdef YYBISON
/* AIX requires this to be the first thing in the file. */
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if HAVE_ALLOCA_H
#include <alloca.h>
#else /* not HAVE_ALLOCA_H */
#ifdef _AIX
/* AIX requires this to be the first thing in the file. What a piece. */
# ifdef _AIX
#pragma alloca
#else /* not _AIX */
# endif
#endif
#include "flexdef.h"
/* The remainder of the alloca() cruft has to come after including flexdef.h,
* so HAVE_ALLOCA_H is (possibly) defined.
*/
#ifdef YYBISON
# ifdef __GNUC__
# ifndef alloca
# define alloca __builtin_alloca
# endif
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef __hpux
void *alloca ();
# else
# ifdef __TURBOC__
# include <malloc.h>
# else
char *alloca ();
#endif /* not _AIX */
#endif /* not HAVE_ALLOCA_H */
#endif /* not __GNUC__ */
#endif /* YYBISON */
# endif
# endif
# endif
# endif
#endif
/* Bletch, ^^^^ that was ugly! */
#include "flexdef.h"
int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, rulelen;
int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
int *active_ss;
Char clower();
void build_eof_action();
void yyerror();
int *scon_stk;
int scon_stk_ptr;
static int madeany = false; /* whether we've made the '.' character class */
int previous_continued_action; /* whether the previous rule's action was '|' */
/* Expand a POSIX character class expression. */
#define CCL_EXPR(func) \
{ \
int c; \
for ( c = 0; c < csize; ++c ) \
if ( isascii(c) && func(c) ) \
ccladd( currccl, c ); \
}
/* While POSIX defines isblank(), it's not ANSI C. */
#define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
/* On some over-ambitious machines, such as DEC Alpha's, the default
* token type is "long" instead of "int"; this leads to problems with
* declaring yylval in flexdef.h. But so far, all the yacc's I've seen
@ -113,30 +143,21 @@ initlex :
/* Create default DFA start condition. */
scinstal( "INITIAL", false );
/* Initially, the start condition scoping is
* "no start conditions active".
*/
actvp = 0;
}
;
sect1 : sect1 startconddecl WHITESPACE namelist1 '\n'
sect1 : sect1 startconddecl namelist1
| sect1 options
|
| error '\n'
| error
{ synerr( "unknown error processing section 1" ); }
;
sect1end : SECTEND
{
/* We now know how many start conditions there
* are, so create the "activity" map indicating
* which conditions are active.
*/
active_ss = allocate_integer_array( lastsc + 1 );
for ( i = 1; i <= lastsc; ++i )
active_ss[i] = 0;
check_options();
scon_stk = allocate_integer_array( lastsc + 1 );
scon_stk_ptr = 0;
}
;
@ -147,7 +168,7 @@ startconddecl : SCDECL
{ xcluflg = true; }
;
namelist1 : namelist1 WHITESPACE NAME
namelist1 : namelist1 NAME
{ scinstal( nmstr, xcluflg ); }
| NAME
@ -157,7 +178,28 @@ namelist1 : namelist1 WHITESPACE NAME
{ synerr( "bad start condition list" ); }
;
sect2 : sect2 initforrule flexrule '\n'
options : OPTION_OP optionlist
;
optionlist : optionlist option
|
;
option : OPT_OUTFILE '=' NAME
{
outfilename = copy_string( nmstr );
did_outfilename = 1;
}
| OPT_PREFIX '=' NAME
{ prefix = copy_string( nmstr ); }
| OPT_YYCLASS '=' NAME
{ yyclass = copy_string( nmstr ); }
;
sect2 : sect2 scon initforrule flexrule '\n'
{ scon_stk_ptr = $2; }
| sect2 scon '{' sect2 '}'
{ scon_stk_ptr = $2; }
|
;
@ -168,54 +210,37 @@ initforrule :
trailcnt = headcnt = rulelen = 0;
current_state_type = STATE_NORMAL;
previous_continued_action = continued_action;
in_rule = true;
new_rule();
}
;
flexrule : scon '^' rule
flexrule : '^' rule
{
pat = $3;
pat = $2;
finish_rule( pat, variable_trail_rule,
headcnt, trailcnt );
for ( i = 1; i <= actvp; ++i )
scbol[actvsc[i]] =
mkbranch( scbol[actvsc[i]], pat );
if ( ! bol_needed )
if ( scon_stk_ptr > 0 )
{
bol_needed = true;
if ( performance_report > 1 )
pinpoint_message(
"'^' operator results in sub-optimal performance" );
for ( i = 1; i <= scon_stk_ptr; ++i )
scbol[scon_stk[i]] =
mkbranch( scbol[scon_stk[i]],
pat );
}
}
| scon rule
{
pat = $2;
finish_rule( pat, variable_trail_rule,
headcnt, trailcnt );
else
{
/* Add to all non-exclusive start conditions,
* including the default (0) start condition.
*/
for ( i = 1; i <= actvp; ++i )
scset[actvsc[i]] =
mkbranch( scset[actvsc[i]], pat );
}
| '^' rule
{
pat = $2;
finish_rule( pat, variable_trail_rule,
headcnt, trailcnt );
/* Add to all non-exclusive start conditions,
* including the default (0) start condition.
*/
for ( i = 1; i <= lastsc; ++i )
if ( ! scxclu[i] )
scbol[i] = mkbranch( scbol[i], pat );
for ( i = 1; i <= lastsc; ++i )
if ( ! scxclu[i] )
scbol[i] = mkbranch( scbol[i],
pat );
}
if ( ! bol_needed )
{
@ -233,51 +258,82 @@ flexrule : scon '^' rule
finish_rule( pat, variable_trail_rule,
headcnt, trailcnt );
for ( i = 1; i <= lastsc; ++i )
if ( ! scxclu[i] )
scset[i] = mkbranch( scset[i], pat );
}
if ( scon_stk_ptr > 0 )
{
for ( i = 1; i <= scon_stk_ptr; ++i )
scset[scon_stk[i]] =
mkbranch( scset[scon_stk[i]],
pat );
}
| scon EOF_OP
{ build_eof_action(); }
else
{
for ( i = 1; i <= lastsc; ++i )
if ( ! scxclu[i] )
scset[i] =
mkbranch( scset[i],
pat );
}
}
| EOF_OP
{
/* This EOF applies to all start conditions
* which don't already have EOF actions.
*/
actvp = 0;
if ( scon_stk_ptr > 0 )
build_eof_action();
else
{
/* This EOF applies to all start conditions
* which don't already have EOF actions.
*/
for ( i = 1; i <= lastsc; ++i )
if ( ! sceof[i] )
scon_stk[++scon_stk_ptr] = i;
for ( i = 1; i <= lastsc; ++i )
if ( ! sceof[i] )
actvsc[++actvp] = i;
if ( actvp == 0 )
warn(
if ( scon_stk_ptr == 0 )
warn(
"all start conditions already have <<EOF>> rules" );
else
build_eof_action();
else
build_eof_action();
}
}
| error
{ synerr( "unrecognized rule" ); }
;
scon : '<' namelist2 '>'
scon_stk_ptr :
{ $$ = scon_stk_ptr; }
;
scon : '<' scon_stk_ptr namelist2 '>'
{ $$ = $2; }
| '<' '*' '>'
{
actvp = 0;
$$ = scon_stk_ptr;
for ( i = 1; i <= lastsc; ++i )
actvsc[++actvp] = i;
{
int j;
for ( j = 1; j <= scon_stk_ptr; ++j )
if ( scon_stk[j] == i )
break;
if ( j > scon_stk_ptr )
scon_stk[++scon_stk_ptr] = i;
}
}
|
{ $$ = scon_stk_ptr; }
;
namelist2 : namelist2 ',' sconname
| { actvp = 0; } sconname
| sconname
| error
{ synerr( "bad start condition list" ); }
@ -291,15 +347,17 @@ sconname : NAME
nmstr );
else
{
if ( ++actvp >= current_max_scs )
/* Some bozo has included multiple
* instances of start condition names.
*/
pinpoint_message(
"too many start conditions in <> construct!" );
for ( i = 1; i <= scon_stk_ptr; ++i )
if ( scon_stk[i] == scnum )
{
format_warn(
"<%s> specified twice",
scname[scnum] );
break;
}
else
actvsc[actvp] = scnum;
if ( i > scon_stk_ptr )
scon_stk[++scon_stk_ptr] = scnum;
}
}
;
@ -666,14 +724,40 @@ ccl : ccl CHAR '-' CHAR
$$ = $1;
}
| ccl ccl_expr
{
/* Too hard to properly maintain cclsorted. */
cclsorted = false;
$$ = $1;
}
|
{
cclsorted = true;
lastchar = 0;
$$ = cclinit();
currccl = $$ = cclinit();
}
;
ccl_expr: CCE_ALNUM { CCL_EXPR(isalnum) }
| CCE_ALPHA { CCL_EXPR(isalpha) }
| CCE_BLANK { CCL_EXPR(IS_BLANK) }
| CCE_CNTRL { CCL_EXPR(iscntrl) }
| CCE_DIGIT { CCL_EXPR(isdigit) }
| CCE_GRAPH { CCL_EXPR(isgraph) }
| CCE_LOWER { CCL_EXPR(islower) }
| CCE_PRINT { CCL_EXPR(isprint) }
| CCE_PUNCT { CCL_EXPR(ispunct) }
| CCE_SPACE { CCL_EXPR(isspace) }
| CCE_UPPER {
if ( caseins )
CCL_EXPR(islower)
else
CCL_EXPR(isupper)
}
| CCE_XDIGIT { CCL_EXPR(isxdigit) }
;
string : string CHAR
{
if ( caseins && $2 >= 'A' && $2 <= 'Z' )
@ -700,23 +784,23 @@ void build_eof_action()
register int i;
char action_text[MAXLINE];
for ( i = 1; i <= actvp; ++i )
for ( i = 1; i <= scon_stk_ptr; ++i )
{
if ( sceof[actvsc[i]] )
if ( sceof[scon_stk[i]] )
format_pinpoint_message(
"multiple <<EOF>> rules for start condition %s",
scname[actvsc[i]] );
scname[scon_stk[i]] );
else
{
sceof[actvsc[i]] = true;
sceof[scon_stk[i]] = true;
sprintf( action_text, "case YY_STATE_EOF(%s):\n",
scname[actvsc[i]] );
scname[scon_stk[i]] );
add_action( action_text );
}
}
line_directive_out( (FILE *) 0 );
line_directive_out( (FILE *) 0, 1 );
/* This isn't a normal rule after all - don't count it as
* such, so we don't have any holes in the rule numbering
@ -750,6 +834,18 @@ char str[];
}
/* format_warn - write out formatted warning */
void format_warn( msg, arg )
char msg[], arg[];
{
char warn_msg[MAXLINE];
(void) sprintf( warn_msg, msg, arg );
warn( warn_msg );
}
/* warn - report a warning, unless -w was given */
void warn( str )

View file

@ -27,12 +27,18 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: scan.l,v 1.2 94/01/04 14:33:09 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/scan.l,v 2.56 95/04/24 12:17:19 vern Exp $ */
#include "flexdef.h"
#include "parse.h"
#define ACTION_ECHO add_action( yytext )
#define ACTION_IFDEF(def, should_define) \
{ \
if ( should_define ) \
action_define( def, 1 ); \
}
#define MARK_END_OF_PROLOG mark_prolog();
#define YY_DECL \
@ -59,118 +65,125 @@
yymore_used = true;
%}
%option caseless nodefault outfile="scan.c" stack noyy_top_state
%option nostdinit
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
%x FIRSTCCL CCL ACTION RECOVER BRACEERROR C_COMMENT ACTION_COMMENT
%x ACTION_STRING PERCENT_BRACE_ACTION USED_LIST CODEBLOCK_2
%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
%x OPTION LINEDIR
WS [ \t]+
OPTWS [ \t]*
NOT_WS [^ \t\n]
WS [[:blank:]]+
OPTWS [[:blank:]]*
NOT_WS [^[:blank:]\n]
NL (\n|\r\n|\n\r)
NL \r?\n
NAME ([a-z_][a-z_0-9-]*)
NOT_NAME [^a-z_*\n]+
NAME ([[:alpha:]_][[:alnum:]_-]*)
NOT_NAME [^[:alpha:]_*\n]+
SCNAME {NAME}
ESCSEQ (\\([^\n]|[0-9]{1,3}|x[0-9a-f]{1,2}))
ESCSEQ (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))
FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
CCL_CHAR ([^\\\n\]]|{ESCSEQ})
CCL_EXPR ("[:"[[:alpha:]]+":]")
LEXOPT [aceknopr]
%%
static int bracelevel, didadef, indented_code, checking_used;
static int bracelevel, didadef, indented_code;
static int doing_rule_action = false;
static int option_sense;
int doing_codeblock = false;
int i;
Char nmdef[MAXLINE], myesc();
^{WS} indented_code = true; BEGIN(CODEBLOCK);
^"/*" ACTION_ECHO; BEGIN(C_COMMENT);
^"%s"{NAME}? return SCDECL;
^"%x"{NAME}? return XSCDECL;
^"%{".*{NL} {
<INITIAL>{
^{WS} indented_code = true; BEGIN(CODEBLOCK);
^"/*" ACTION_ECHO; yy_push_state( COMMENT );
^#{OPTWS}line{WS} yy_push_state( LINEDIR );
^"%s"{NAME}? return SCDECL;
^"%x"{NAME}? return XSCDECL;
^"%{".*{NL} {
++linenum;
line_directive_out( (FILE *) 0 );
line_directive_out( (FILE *) 0, 1 );
indented_code = false;
BEGIN(CODEBLOCK);
}
{WS} return WHITESPACE;
{WS} /* discard */
^"%%".* {
^"%%".* {
sectnum = 2;
bracelevel = 0;
mark_defs1();
line_directive_out( (FILE *) 0 );
line_directive_out( (FILE *) 0, 1 );
BEGIN(SECT2PROLOG);
return SECTEND;
}
^"%pointer".*{NL} {
if ( lex_compat )
warn( "%pointer incompatible with -l option" );
else
yytext_is_array = false;
++linenum;
}
^"%array".*{NL} {
if ( C_plus_plus )
warn( "%array incompatible with -+ option" );
else
yytext_is_array = true;
++linenum;
}
^"%pointer".*{NL} yytext_is_array = false; ++linenum;
^"%array".*{NL} yytext_is_array = true; ++linenum;
^"%used" {
warn( "%used/%unused have been deprecated" );
checking_used = REALLY_USED; BEGIN(USED_LIST);
}
^"%unused" {
warn( "%used/%unused have been deprecated" );
checking_used = REALLY_NOT_USED; BEGIN(USED_LIST);
}
^"%option" BEGIN(OPTION); return OPTION_OP;
^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
^"%"[aceknopr]{OPTWS}[0-9]*{OPTWS}{NL} ++linenum; /* ignore */
^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) );
^"%"[^sxanpekotcru{}].* synerr( "unrecognized '%' directive" );
^{NAME} {
^{NAME} {
strcpy( nmstr, yytext );
didadef = false;
BEGIN(PICKUPDEF);
}
{SCNAME} RETURNNAME;
^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
{OPTWS}{NL} ++linenum; return '\n';
{SCNAME} RETURNNAME;
^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
{OPTWS}{NL} ACTION_ECHO; ++linenum; /* maybe end of comment line */
}
<C_COMMENT>"*/" ACTION_ECHO; BEGIN(INITIAL);
<C_COMMENT>"*/".*{NL} ++linenum; ACTION_ECHO; BEGIN(INITIAL);
<C_COMMENT>[^*\n]+ ACTION_ECHO;
<C_COMMENT>"*" ACTION_ECHO;
<C_COMMENT>{NL} ++linenum; ACTION_ECHO;
<COMMENT>{
"*/" ACTION_ECHO; yy_pop_state();
"*" ACTION_ECHO;
[^*\n]+ ACTION_ECHO;
[^*\n]*{NL} ++linenum; ACTION_ECHO;
}
<LINEDIR>{
\n yy_pop_state();
[[:digit:]]+ linenum = myctoi( yytext );
<CODEBLOCK>^"%}".*{NL} ++linenum; BEGIN(INITIAL);
<CODEBLOCK>"reject" ACTION_ECHO; CHECK_REJECT(yytext);
<CODEBLOCK>"yymore" ACTION_ECHO; CHECK_YYMORE(yytext);
<CODEBLOCK>{NAME}|{NOT_NAME}|. ACTION_ECHO;
<CODEBLOCK>{NL} {
\"[^"\n]*\" {
flex_free( (void *) infilename );
infilename = copy_string( yytext + 1 );
infilename[strlen( infilename ) - 1] = '\0';
}
. /* ignore spurious characters */
}
<CODEBLOCK>{
^"%}".*{NL} ++linenum; BEGIN(INITIAL);
{NAME}|{NOT_NAME}|. ACTION_ECHO;
{NL} {
++linenum;
ACTION_ECHO;
if ( indented_code )
BEGIN(INITIAL);
}
}
<PICKUPDEF>{WS} /* separates name and definition */
<PICKUPDEF>{
{WS} /* separates name and definition */
<PICKUPDEF>{NOT_WS}.* {
{NOT_WS}.* {
strcpy( (char *) nmdef, yytext );
/* Skip trailing whitespace. */
@ -185,44 +198,111 @@ CCL_CHAR ([^\\\n\]]|{ESCSEQ})
didadef = true;
}
<PICKUPDEF>{NL} {
{NL} {
if ( ! didadef )
synerr( "incomplete name definition" );
synerr( _( "incomplete name definition" ) );
BEGIN(INITIAL);
++linenum;
}
<RECOVER>.*{NL} ++linenum; BEGIN(INITIAL); RETURNNAME;
}
<USED_LIST>{NL} ++linenum; BEGIN(INITIAL);
<USED_LIST>{WS}
<USED_LIST>"reject" {
if ( all_upper( yytext ) )
reject_really_used = checking_used;
else
synerr(
"unrecognized %used/%unused construct" );
<OPTION>{
{NL} ++linenum; BEGIN(INITIAL);
{WS} option_sense = true;
"=" return '=';
no option_sense = ! option_sense;
7bit csize = option_sense ? 128 : 256;
8bit csize = option_sense ? 256 : 128;
align long_align = option_sense;
always-interactive {
action_define( "YY_ALWAYS_INTERACTIVE", option_sense );
}
<USED_LIST>"yymore" {
if ( all_lower( yytext ) )
yymore_really_used = checking_used;
else
synerr(
"unrecognized %used/%unused construct" );
array yytext_is_array = option_sense;
backup backing_up_report = option_sense;
batch interactive = ! option_sense;
"c++" C_plus_plus = option_sense;
caseful|case-sensitive caseins = ! option_sense;
caseless|case-insensitive caseins = option_sense;
debug ddebug = option_sense;
default spprdflt = ! option_sense;
ecs useecs = option_sense;
fast {
useecs = usemecs = false;
use_read = fullspd = true;
}
<USED_LIST>{NOT_WS}+ synerr( "unrecognized %used/%unused construct" );
full {
useecs = usemecs = false;
use_read = fulltbl = true;
}
input ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
interactive interactive = option_sense;
lex-compat lex_compat = option_sense;
main {
action_define( "YY_MAIN", option_sense );
do_yywrap = ! option_sense;
}
meta-ecs usemecs = option_sense;
never-interactive {
action_define( "YY_NEVER_INTERACTIVE", option_sense );
}
perf-report performance_report += option_sense ? 1 : -1;
pointer yytext_is_array = ! option_sense;
read use_read = option_sense;
reject reject_really_used = option_sense;
stack action_define( "YY_STACK_USED", option_sense );
stdinit do_stdinit = option_sense;
stdout use_stdout = option_sense;
unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense);
verbose printstats = option_sense;
warn nowarn = ! option_sense;
yylineno do_yylineno = option_sense;
yymore yymore_really_used = option_sense;
yywrap do_yywrap = option_sense;
yy_push_state ACTION_IFDEF("YY_NO_PUSH_STATE", ! option_sense);
yy_pop_state ACTION_IFDEF("YY_NO_POP_STATE", ! option_sense);
yy_top_state ACTION_IFDEF("YY_NO_TOP_STATE", ! option_sense);
yy_scan_buffer ACTION_IFDEF("YY_NO_SCAN_BUFFER", ! option_sense);
yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
outfile return OPT_OUTFILE;
prefix return OPT_PREFIX;
yyclass return OPT_YYCLASS;
\"[^"\n]*\" {
strcpy( nmstr, yytext + 1 );
nmstr[strlen( nmstr ) - 1] = '\0';
return NAME;
}
(([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {
format_synerr( _( "unrecognized %%option: %s" ),
yytext );
BEGIN(RECOVER);
}
}
<RECOVER>.*{NL} ++linenum; BEGIN(INITIAL);
<SECT2PROLOG>^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
<SECT2PROLOG>^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
<SECT2PROLOG>{
^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
<SECT2PROLOG>^{WS}.* ACTION_ECHO; /* indented code in prolog */
^{WS}.* ACTION_ECHO; /* indented code in prolog */
<SECT2PROLOG>^{NOT_WS}.* { /* non-indented code */
^{NOT_WS}.* { /* non-indented code */
if ( bracelevel <= 0 )
{ /* not in %{ ... %} */
yyless( 0 ); /* put it all back */
yy_set_bol( 1 );
mark_prolog();
BEGIN(SECT2);
}
@ -230,43 +310,55 @@ CCL_CHAR ([^\\\n\]]|{ESCSEQ})
ACTION_ECHO;
}
<SECT2PROLOG>.* ACTION_ECHO;
<SECT2PROLOG>{NL} ++linenum; ACTION_ECHO;
.* ACTION_ECHO;
{NL} ++linenum; ACTION_ECHO;
<SECT2PROLOG><<EOF>> {
<<EOF>> {
mark_prolog();
sectnum = 0;
yyterminate(); /* to stop the parser */
}
}
<SECT2>^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
<SECT2>{
^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
<SECT2>^({WS}|"%{") {
indented_code = (yytext[0] != '%');
^{OPTWS}"%{" {
indented_code = false;
doing_codeblock = true;
bracelevel = 1;
if ( indented_code )
ACTION_ECHO;
BEGIN(CODEBLOCK_2);
BEGIN(PERCENT_BRACE_ACTION);
}
<SECT2>^"<" BEGIN(SC); return '<';
<SECT2>^"^" return '^';
<SECT2>\" BEGIN(QUOTE); return '"';
<SECT2>"{"/[0-9] BEGIN(NUM); return '{';
<SECT2>"{"[^0-9\n][^}\n]* BEGIN(BRACEERROR);
<SECT2>"$"/([ \t]|{NL}) return '$';
^{OPTWS}"<" BEGIN(SC); return '<';
^{OPTWS}"^" return '^';
\" BEGIN(QUOTE); return '"';
"{"/[[:digit:]] BEGIN(NUM); return '{';
"$"/([[:blank:]]|{NL}) return '$';
<SECT2>{WS}"%{" {
{WS}"%{" {
bracelevel = 1;
BEGIN(PERCENT_BRACE_ACTION);
return '\n';
}
<SECT2>{WS}"|".*{NL} continued_action = true; ++linenum; return '\n';
<SECT2>{WS} {
if ( in_rule )
{
doing_rule_action = true;
in_rule = false;
return '\n';
}
}
{WS}"|".*{NL} continued_action = true; ++linenum; return '\n';
^{WS}"/*" {
yyless( yyleng - 2 ); /* put back '/', '*' */
bracelevel = 0;
continued_action = false;
BEGIN(ACTION);
}
^{WS} /* allow indented rules */
{WS} {
/* This rule is separate from the one below because
* otherwise we get variable trailing context, so
* we can't build the scanner using -{f,F}.
@ -274,26 +366,39 @@ CCL_CHAR ([^\\\n\]]|{ESCSEQ})
bracelevel = 0;
continued_action = false;
BEGIN(ACTION);
return '\n';
if ( in_rule )
{
doing_rule_action = true;
in_rule = false;
return '\n';
}
}
<SECT2>{OPTWS}{NL} {
{OPTWS}{NL} {
bracelevel = 0;
continued_action = false;
BEGIN(ACTION);
unput( '\n' ); /* so <ACTION> sees it */
return '\n';
if ( in_rule )
{
doing_rule_action = true;
in_rule = false;
return '\n';
}
}
<SECT2>"<<EOF>>" return EOF_OP;
^{OPTWS}"<<EOF>>" |
"<<EOF>>" return EOF_OP;
<SECT2>^"%%".* {
^"%%".* {
sectnum = 3;
BEGIN(SECT3);
yyterminate(); /* to stop the parser */
}
<SECT2>"["{FIRST_CCL_CHAR}{CCL_CHAR}* {
"["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
int cclval;
strcpy( nmstr, yytext );
@ -301,10 +406,10 @@ CCL_CHAR ([^\\\n\]]|{ESCSEQ})
/* Check to see if we've already encountered this
* ccl.
*/
if ( (cclval = ccllookup( (Char *) nmstr )) )
if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
{
if ( input() != ']' )
synerr( "bad character class" );
synerr( _( "bad character class" ) );
yylval = cclval;
++cclreuse;
@ -327,15 +432,16 @@ CCL_CHAR ([^\\\n\]]|{ESCSEQ})
}
}
<SECT2>"{"{NAME}"}" {
"{"{NAME}"}" {
register Char *nmdefptr;
Char *ndlookup();
strcpy( nmstr, yytext + 1 );
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
if ( ! (nmdefptr = ndlookup( nmstr )) )
format_synerr( "undefined definition {%s}",
if ( (nmdefptr = ndlookup( nmstr )) == 0 )
format_synerr(
_( "undefined definition {%s}" ),
nmstr );
else
@ -360,157 +466,186 @@ CCL_CHAR ([^\\\n\]]|{ESCSEQ})
}
}
<SECT2>[/|*+?.()] return (unsigned char) yytext[0];
<SECT2>. RETURNCHAR;
[/|*+?.(){}] return (unsigned char) yytext[0];
. RETURNCHAR;
}
<SC>[,*] return (unsigned char) yytext[0];
<SC>">" BEGIN(SECT2); return '>';
<SC>">"/^ BEGIN(CARETISBOL); return '>';
<SC>{SCNAME} RETURNNAME;
<SC>. {
format_synerr( "bad <start condition>: %s", yytext );
<SC>{
[,*] return (unsigned char) yytext[0];
">" BEGIN(SECT2); return '>';
">"/^ BEGIN(CARETISBOL); return '>';
{SCNAME} RETURNNAME;
. {
format_synerr( _( "bad <start condition>: %s" ),
yytext );
}
}
<CARETISBOL>"^" BEGIN(SECT2); return '^';
<QUOTE>[^"\n] RETURNCHAR;
<QUOTE>\" BEGIN(SECT2); return '"';
<QUOTE>{
[^"\n] RETURNCHAR;
\" BEGIN(SECT2); return '"';
<QUOTE>{NL} {
synerr( "missing quote" );
{NL} {
synerr( _( "missing quote" ) );
BEGIN(SECT2);
++linenum;
return '"';
}
}
<FIRSTCCL>"^"/[^-\]\n] BEGIN(CCL); return '^';
<FIRSTCCL>"^"/("-"|"]") return '^';
<FIRSTCCL>. BEGIN(CCL); RETURNCHAR;
<FIRSTCCL>{
"^"/[^-\]\n] BEGIN(CCL); return '^';
"^"/("-"|"]") return '^';
. BEGIN(CCL); RETURNCHAR;
}
<CCL>-/[^\]\n] return '-';
<CCL>[^\]\n] RETURNCHAR;
<CCL>"]" BEGIN(SECT2); return ']';
<CCL>.|{NL} {
synerr( "bad character class" );
<CCL>{
-/[^\]\n] return '-';
[^\]\n] RETURNCHAR;
"]" BEGIN(SECT2); return ']';
.|{NL} {
synerr( _( "bad character class" ) );
BEGIN(SECT2);
return ']';
}
}
<FIRSTCCL,CCL>{
"[:alnum:]" BEGIN(CCL); return CCE_ALNUM;
"[:alpha:]" BEGIN(CCL); return CCE_ALPHA;
"[:blank:]" BEGIN(CCL); return CCE_BLANK;
"[:cntrl:]" BEGIN(CCL); return CCE_CNTRL;
"[:digit:]" BEGIN(CCL); return CCE_DIGIT;
"[:graph:]" BEGIN(CCL); return CCE_GRAPH;
"[:lower:]" BEGIN(CCL); return CCE_LOWER;
"[:print:]" BEGIN(CCL); return CCE_PRINT;
"[:punct:]" BEGIN(CCL); return CCE_PUNCT;
"[:space:]" BEGIN(CCL); return CCE_SPACE;
"[:upper:]" BEGIN(CCL); return CCE_UPPER;
"[:xdigit:]" BEGIN(CCL); return CCE_XDIGIT;
{CCL_EXPR} {
format_synerr(
_( "bad character class expression: %s" ),
yytext );
BEGIN(CCL); return CCE_ALNUM;
}
}
<NUM>[0-9]+ {
<NUM>{
[[:digit:]]+ {
yylval = myctoi( yytext );
return NUMBER;
}
<NUM>"," return ',';
<NUM>"}" BEGIN(SECT2); return '}';
"," return ',';
"}" BEGIN(SECT2); return '}';
<NUM>. {
synerr( "bad character inside {}'s" );
. {
synerr( _( "bad character inside {}'s" ) );
BEGIN(SECT2);
return '}';
}
<NUM>{NL} {
synerr( "missing }" );
{NL} {
synerr( _( "missing }" ) );
BEGIN(SECT2);
++linenum;
return '}';
}
}
<BRACEERROR>"}" synerr( "bad name in {}'s" ); BEGIN(SECT2);
<BRACEERROR>{NL} synerr( "missing }" ); ++linenum; BEGIN(SECT2);
<PERCENT_BRACE_ACTION>{
{OPTWS}"%}".* bracelevel = 0;
<ACTION>"/*" ACTION_ECHO; yy_push_state( COMMENT );
<CODEBLOCK_2>"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT);
<PERCENT_BRACE_ACTION,CODEBLOCK_2>{OPTWS}"%}".* bracelevel = 0;
<PERCENT_BRACE_ACTION,CODEBLOCK_2,ACTION>"reject" {
<CODEBLOCK,ACTION>{
"reject" {
ACTION_ECHO;
CHECK_REJECT(yytext);
}
<PERCENT_BRACE_ACTION,CODEBLOCK_2,ACTION>"yymore" {
"yymore" {
ACTION_ECHO;
CHECK_YYMORE(yytext);
}
<PERCENT_BRACE_ACTION,CODEBLOCK_2>{NAME}|{NOT_NAME}|. ACTION_ECHO;
<PERCENT_BRACE_ACTION,CODEBLOCK_2>{NL} {
}
{NAME}|{NOT_NAME}|. ACTION_ECHO;
{NL} {
++linenum;
ACTION_ECHO;
if ( bracelevel == 0 ||
(doing_codeblock && indented_code) )
{
if ( ! doing_codeblock )
if ( doing_rule_action )
add_action( "\tYY_BREAK\n" );
doing_codeblock = false;
doing_rule_action = doing_codeblock = false;
BEGIN(SECT2);
}
}
}
/* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
<ACTION>"{" ACTION_ECHO; ++bracelevel;
<ACTION>"}" ACTION_ECHO; --bracelevel;
<ACTION>[^a-z_{}"'/\n]+ ACTION_ECHO;
<ACTION>{NAME} ACTION_ECHO;
<ACTION>"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT);
<ACTION>"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
<ACTION>\" ACTION_ECHO; BEGIN(ACTION_STRING);
<ACTION>{NL} {
<ACTION>{
"{" ACTION_ECHO; ++bracelevel;
"}" ACTION_ECHO; --bracelevel;
[^[:alpha:]_{}"'/\n]+ ACTION_ECHO;
{NAME} ACTION_ECHO;
"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
\" ACTION_ECHO; BEGIN(ACTION_STRING);
{NL} {
++linenum;
ACTION_ECHO;
if ( bracelevel == 0 )
{
add_action( "\tYY_BREAK\n" );
if ( doing_rule_action )
add_action( "\tYY_BREAK\n" );
doing_rule_action = false;
BEGIN(SECT2);
}
}
<ACTION>. ACTION_ECHO;
. ACTION_ECHO;
}
<ACTION_COMMENT>"*/" {
ACTION_ECHO;
if ( doing_codeblock )
BEGIN(CODEBLOCK_2);
else
BEGIN(ACTION);
}
<ACTION_STRING>{
[^"\\\n]+ ACTION_ECHO;
\\. ACTION_ECHO;
{NL} ++linenum; ACTION_ECHO;
\" ACTION_ECHO; BEGIN(ACTION);
. ACTION_ECHO;
}
<ACTION_COMMENT>"*" ACTION_ECHO;
<ACTION_COMMENT>[^*\n]+ ACTION_ECHO;
<ACTION_COMMENT>[^*\n]*{NL} ++linenum; ACTION_ECHO;
<ACTION_STRING>[^"\\\n]+ ACTION_ECHO;
<ACTION_STRING>\\. ACTION_ECHO;
<ACTION_STRING>{NL} ++linenum; ACTION_ECHO;
<ACTION_STRING>\" ACTION_ECHO; BEGIN(ACTION);
<ACTION_STRING>. ACTION_ECHO;
<ACTION,ACTION_COMMENT,ACTION_STRING><<EOF>> {
synerr( "EOF encountered inside an action" );
<COMMENT,ACTION,ACTION_STRING><<EOF>> {
synerr( _( "EOF encountered inside an action" ) );
yyterminate();
}
<SECT2,QUOTE,CCL>{ESCSEQ} {
<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
yylval = myesc( (Char *) yytext );
return CHAR;
}
<FIRSTCCL>{ESCSEQ} {
yylval = myesc( (Char *) yytext );
BEGIN(CCL);
if ( YY_START == FIRSTCCL )
BEGIN(CCL);
return CHAR;
}
<SECT3>.*(\n?) ECHO;
<SECT3><<EOF>> sectnum = 0; yyterminate();
<SECT3>{
.*(\n?) ECHO;
<<EOF>> sectnum = 0; yyterminate();
}
<*>.|\n format_synerr( "bad character: %s", yytext );
<*>.|\n format_synerr( _( "bad character: %s" ), yytext );
%%
@ -533,40 +668,43 @@ int yywrap()
void set_input_file( file )
char *file;
{
if ( file )
if ( file && strcmp( file, "-" ) )
{
infilename = file;
infilename = copy_string( file );
yyin = fopen( infilename, "r" );
if ( yyin == NULL )
lerrsf( "can't open %s", file );
lerrsf( _( "can't open %s" ), file );
}
else
{
yyin = stdin;
infilename = "<stdin>";
infilename = copy_string( "<stdin>" );
}
linenum = 1;
}
/* Wrapper routines for accessing the scanner's malloc routines. */
void *flex_alloc( size )
unsigned int size;
size_t size;
{
return yy_flex_alloc( size );
return (void *) malloc( size );
}
void *flex_realloc( ptr, size )
void *ptr;
unsigned int size;
size_t size;
{
return yy_flex_realloc( ptr, size );
return (void *) realloc( ptr, size );
}
void flex_free( ptr )
void *ptr;
{
yy_flex_free( ptr );
if ( ptr )
free( ptr );
}

View file

@ -1,15 +1,17 @@
/* File created from flex.skel via mkskel.sh */
/* File created from flex.skl via mkskel.sh */
#include "flexdef.h"
char *skel[] = {
const char *skel[] = {
"/* A lexical scanner generated by flex */",
"",
"/* Scanner skeleton version:",
" * $Header: /home/daffy/u0/vern/flex/flex-2.4.7/RCS/flex.skl,v 1.2 94/08/03 11:13:24 vern Exp $",
" * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.89 96/05/25 21:02:21 vern Exp $",
" */",
"",
"#define FLEX_SCANNER",
"#define YY_FLEX_MAJOR_VERSION 2",
"#define YY_FLEX_MINOR_VERSION 5",
"",
"%-",
"#include <stdio.h>",
@ -40,7 +42,7 @@ char *skel[] = {
"",
"#else /* ! __cplusplus */",
"",
"#ifdef __STDC__",
"#if __STDC__",
"",
"#define YY_USE_PROTOS",
"#define YY_USE_CONST",
@ -48,16 +50,19 @@ char *skel[] = {
"#endif /* __STDC__ */",
"#endif /* ! __cplusplus */",
"",
"",
"#ifdef __TURBOC__",
" #pragma warn -rch",
" #pragma warn -use",
"#include <io.h>",
"#include <stdlib.h>",
"#define YY_USE_CONST",
"#define YY_USE_PROTOS",
"#endif",
"",
"",
"#ifndef YY_USE_CONST",
"#ifndef const",
"#define const",
"#endif",
"#ifdef YY_USE_CONST",
"#define yyconst const",
"#else",
"#define yyconst",
"#endif",
"",
"",
@ -84,16 +89,16 @@ char *skel[] = {
"#define BEGIN yy_start = 1 + 2 *",
"",
"/* Translate the current start state into a value that can be later handed",
" * to BEGIN to return to the state.",
" * to BEGIN to return to the state. The YYSTATE alias is for lex",
" * compatibility.",
" */",
"#define YY_START ((yy_start - 1) / 2)",
"#define YYSTATE YY_START",
"",
"/* 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\". Now included",
" * only for backward compatibility with previous versions of flex.",
" */",
"/* Special action meaning \"start processing a new file\". */",
"#define YY_NEW_FILE yyrestart( yyin )",
"",
"#define YY_END_OF_BUFFER_CHAR 0",
@ -108,14 +113,6 @@ char *skel[] = {
"extern FILE *yyin, *yyout;",
"%*",
"",
"#ifdef __cplusplus",
"extern \"C\" {",
"#endif",
" extern int yywrap YY_PROTO(( void ));",
"#ifdef __cplusplus",
" }",
"#endif",
"",
"#define EOB_ACT_CONTINUE_SCAN 0",
"#define EOB_ACT_END_OF_FILE 1",
"#define EOB_ACT_LAST_MATCH 2",
@ -141,6 +138,7 @@ char *skel[] = {
" { \\",
" /* Undo effects of setting up yytext. */ \\",
" *yy_cp = yy_hold_char; \\",
" YY_RESTORE_YY_MORE_OFFSET \\",
" yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \\",
" YY_DO_BEFORE_ACTION; /* set up yytext again */ \\",
" } \\",
@ -148,6 +146,12 @@ char *skel[] = {
"",
"#define unput(c) yyunput( c, yytext_ptr )",
"",
"/* The following is because we cannot portably get our hands on size_t",
" * (without autoconf's help, which isn't available because we want",
" * flex-generated scanners to compile on their own).",
" */",
"typedef unsigned int yy_size_t;",
"",
"",
"struct yy_buffer_state",
" {",
@ -163,13 +167,19 @@ char *skel[] = {
" /* Size of input buffer in bytes, not including room for EOB",
" * characters.",
" */",
" int yy_buf_size;",
" yy_size_t yy_buf_size;",
"",
" /* Number of characters read into yy_ch_buf, not including EOB",
" * characters.",
" */",
" int yy_n_chars;",
"",
" /* Whether we \"own\" the buffer - i.e., we know we created it,",
" * and can realloc() it to grow it, and should free() it to",
" * delete it.",
" */",
" int yy_is_our_buffer;",
"",
" /* Whether this is an \"interactive\" input source; if so, and",
" * if we're using stdio for input, then we want to use getc()",
" * instead of fread(), to make sure we stop fetching input after",
@ -177,6 +187,12 @@ char *skel[] = {
" */",
" int yy_is_interactive;",
"",
" /* Whether we're considered to be at the beginning of a line.",
" * If so, '^' rules will be active on the next match, otherwise",
" * not.",
" */",
" int yy_at_bol;",
"",
" /* Whether to try to fill the input buffer when we reach the",
" * end of it.",
" */",
@ -228,47 +244,50 @@ char *skel[] = {
" */",
"static int yy_did_buffer_switch_on_eof;",
"",
"static void yyunput YY_PROTO(( int c, 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 ));",
"void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));",
"#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )",
"",
"static int yy_start_stack_ptr = 0;",
"static int yy_start_stack_depth = 0;",
"static int *yy_start_stack = 0;",
"static void yy_push_state YY_PROTO(( int new_state ));",
"static void yy_pop_state YY_PROTO(( void ));",
"static int yy_top_state YY_PROTO(( void ));",
"YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));",
"YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));",
"YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));",
"%*",
"",
"static void *yy_flex_alloc YY_PROTO(( unsigned int ));",
"static void *yy_flex_realloc YY_PROTO(( void *, unsigned int ));",
"static void *yy_flex_alloc YY_PROTO(( yy_size_t ));",
"static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));",
"static void yy_flex_free YY_PROTO(( void * ));",
"",
"#define yy_new_buffer yy_create_buffer",
"",
"#define yy_set_interactive(is_interactive) \\",
" { \\",
" if ( ! yy_current_buffer ) \\",
" yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \\",
" yy_current_buffer->yy_is_interactive = is_interactive; \\",
" }",
"",
"#define yy_set_bol(at_bol) \\",
" { \\",
" if ( ! yy_current_buffer ) \\",
" yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \\",
" yy_current_buffer->yy_at_bol = at_bol; \\",
" }",
"",
"#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)",
"",
"%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here",
"",
"#ifndef yytext_ptr",
"static void yy_flex_strncpy YY_PROTO(( char *, const char *, int ));",
"#endif",
"",
"%- Standard (non-C++) definition",
"#ifdef __cplusplus",
"static int yyinput YY_PROTO(( void ));",
"#else",
"static int input YY_PROTO(( void ));",
"#endif",
"%*",
"",
"%- Standard (non-C++) definition",
"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 yy_fatal_error YY_PROTO(( const char msg[] ));",
"static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));",
"%*",
"",
"/* Done after the current pattern has been matched and before the",
@ -288,6 +307,58 @@ char *skel[] = {
" * section 1.",
" */",
"",
"#ifndef YY_SKIP_YYWRAP",
"#ifdef __cplusplus",
"extern \"C\" int yywrap YY_PROTO(( void ));",
"#else",
"extern int yywrap YY_PROTO(( void ));",
"#endif",
"#endif",
"",
"%-",
"#ifndef YY_NO_UNPUT",
"static void yyunput YY_PROTO(( int c, char *buf_ptr ));",
"#endif",
"%*",
"",
"#ifndef yytext_ptr",
"static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));",
"#endif",
"",
"#ifdef YY_NEED_STRLEN",
"static int yy_flex_strlen YY_PROTO(( yyconst char * ));",
"#endif",
"",
"#ifndef YY_NO_INPUT",
"%- Standard (non-C++) definition",
"#ifdef __cplusplus",
"static int yyinput YY_PROTO(( void ));",
"#else",
"static int input YY_PROTO(( void ));",
"#endif",
"%*",
"#endif",
"",
"#if YY_STACK_USED",
"static int yy_start_stack_ptr = 0;",
"static int yy_start_stack_depth = 0;",
"static int *yy_start_stack = 0;",
"#ifndef YY_NO_PUSH_STATE",
"static void yy_push_state YY_PROTO(( int new_state ));",
"#endif",
"#ifndef YY_NO_POP_STATE",
"static void yy_pop_state YY_PROTO(( void ));",
"#endif",
"#ifndef YY_NO_TOP_STATE",
"static int yy_top_state YY_PROTO(( void ));",
"#endif",
"",
"#else",
"#define YY_NO_PUSH_STATE 1",
"#define YY_NO_POP_STATE 1",
"#define YY_NO_TOP_STATE 1",
"#endif",
"",
"#ifdef YY_MALLOC_DECL",
"YY_MALLOC_DECL",
"#else",
@ -378,6 +449,8 @@ char *skel[] = {
"#define YY_BREAK break;",
"#endif",
"",
"%% YY_RULE_SETUP definition goes here",
"",
"YY_DECL",
" {",
" register yy_state_type yy_current_state;",
@ -388,6 +461,8 @@ char *skel[] = {
"",
" if ( yy_init )",
" {",
" yy_init = 0;",
"",
"#ifdef YY_USER_INIT",
" YY_USER_INIT;",
"#endif",
@ -409,15 +484,11 @@ char *skel[] = {
" yyout = &cout;",
"%*",
"",
" if ( yy_current_buffer )",
" yy_init_buffer( yy_current_buffer, yyin );",
" else",
" if ( ! yy_current_buffer )",
" 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 */",
@ -440,7 +511,7 @@ char *skel[] = {
"",
" YY_DO_BEFORE_ACTION;",
"",
"%% code for yylineno update goes here, if -l option",
"%% code for yylineno update goes here",
"",
"do_action: /* This label is used only to access EOF actions. */",
"",
@ -453,10 +524,11 @@ char *skel[] = {
" case YY_END_OF_BUFFER:",
" {",
" /* Amount of text matched not including the EOB char. */",
" int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1;",
" int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;",
"",
" /* Undo the effects of YY_DO_BEFORE_ACTION. */",
" *yy_cp = yy_hold_char;",
" YY_RESTORE_YY_MORE_OFFSET",
"",
" if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )",
" {",
@ -579,6 +651,53 @@ char *skel[] = {
" } /* end of yylex */",
"",
"%+",
"yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )",
" {",
" yyin = arg_yyin;",
" yyout = arg_yyout;",
" yy_c_buf_p = 0;",
" yy_init = 1;",
" yy_start = 0;",
" yy_flex_debug = 0;",
" yylineno = 1; // this will only get updated if %option yylineno",
"",
" yy_did_buffer_switch_on_eof = 0;",
"",
" yy_looking_for_trail_begin = 0;",
" yy_more_flag = 0;",
" yy_more_len = 0;",
" yy_more_offset = yy_prev_more_offset = 0;",
"",
" yy_start_stack_ptr = yy_start_stack_depth = 0;",
" yy_start_stack = 0;",
"",
" yy_current_buffer = 0;",
"",
"#ifdef YY_USES_REJECT",
" yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];",
"#else",
" yy_state_buf = 0;",
"#endif",
" }",
"",
"yyFlexLexer::~yyFlexLexer()",
" {",
" delete yy_state_buf;",
" yy_delete_buffer( yy_current_buffer );",
" }",
"",
"void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )",
" {",
" if ( new_in )",
" {",
" yy_delete_buffer( yy_current_buffer );",
" yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );",
" }",
"",
" if ( new_out )",
" yyout = new_out;",
" }",
"",
"#ifdef YY_INTERACTIVE",
"int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )",
"#else",
@ -630,7 +749,7 @@ char *skel[] = {
"%*",
" {",
" register char *dest = yy_current_buffer->yy_ch_buf;",
" register char *source = yytext_ptr - 1; /* copy prev. char, too */",
" register char *source = yytext_ptr;",
" register int number_to_move, i;",
" int ret_val;",
"",
@ -642,7 +761,7 @@ char *skel[] = {
" { /* Don't try to fill the buffer, so this is an EOF. */",
" if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )",
" {",
" /* We matched a singled characater, the EOB, so",
" /* We matched a single character, the EOB, so",
" * treat this as a final EOF.",
" */",
" return EOB_ACT_END_OF_FILE;",
@ -660,7 +779,7 @@ char *skel[] = {
" /* Try to read more data. */",
"",
" /* First move last chars to start of buffer. */",
" number_to_move = yy_c_buf_p - yytext_ptr;",
" number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;",
"",
" for ( i = 0; i < number_to_move; ++i )",
" *(dest++) = *(source++);",
@ -686,12 +805,26 @@ char *skel[] = {
" /* just a shorter name for the current buffer */",
" YY_BUFFER_STATE b = yy_current_buffer;",
"",
" int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf;",
" int yy_c_buf_p_offset =",
" (int) (yy_c_buf_p - b->yy_ch_buf);",
"",
" b->yy_buf_size *= 2;",
" b->yy_ch_buf = (char *)",
" yy_flex_realloc( (void *) b->yy_ch_buf,",
" b->yy_buf_size );",
" if ( b->yy_is_our_buffer )",
" {",
" int new_size = b->yy_buf_size * 2;",
"",
" if ( new_size <= 0 )",
" b->yy_buf_size += b->yy_buf_size / 8;",
" else",
" b->yy_buf_size *= 2;",
"",
" b->yy_ch_buf = (char *)",
" /* Include room in for 2 EOB chars. */",
" yy_flex_realloc( (void *) b->yy_ch_buf,",
" b->yy_buf_size + 2 );",
" }",
" else",
" /* Can't grow it, we don't own it. */",
" b->yy_ch_buf = 0;",
"",
" if ( ! b->yy_ch_buf )",
" YY_FATAL_ERROR(",
@ -714,7 +847,7 @@ char *skel[] = {
"",
" if ( yy_n_chars == 0 )",
" {",
" if ( number_to_move - YY_MORE_ADJ == 1 )",
" if ( number_to_move == YY_MORE_ADJ )",
" {",
" ret_val = EOB_ACT_END_OF_FILE;",
" yyrestart( yyin );",
@ -735,13 +868,7 @@ char *skel[] = {
" 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_ptr = &yy_current_buffer->yy_ch_buf[1];",
" yytext_ptr = &yy_current_buffer->yy_ch_buf[0];",
"",
" return ret_val;",
" }",
@ -794,6 +921,7 @@ char *skel[] = {
"",
"",
"%-",
"#ifndef YY_NO_UNPUT",
"#ifdef YY_USE_PROTOS",
"static void yyunput( int c, register char *yy_bp )",
"#else",
@ -822,26 +950,25 @@ char *skel[] = {
" while ( source > yy_current_buffer->yy_ch_buf )",
" *--dest = *--source;",
"",
" yy_cp += dest - source;",
" yy_bp += dest - source;",
" yy_cp += (int) (dest - source);",
" yy_bp += (int) (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 = (char) c;",
"",
"%% update yylineno here, if doing -l",
"%% update yylineno here",
"",
" /* Note: the formal parameter *must* be called \"yy_bp\" for this",
" * macro to now work correctly.",
" */",
" YY_DO_BEFORE_ACTION; /* set up yytext again */",
" yytext_ptr = yy_bp;",
" yy_hold_char = *yy_cp;",
" yy_c_buf_p = yy_cp;",
" }",
"%-",
"#endif /* ifndef YY_NO_UNPUT */",
"%*",
"",
"",
"%-",
@ -870,7 +997,7 @@ char *skel[] = {
"",
" else",
" { /* need more input */",
" yytext_ptr = yy_c_buf_p;",
" int offset = yy_c_buf_p - yytext_ptr;",
" ++yy_c_buf_p;",
"",
" switch ( yy_get_next_buffer() )",
@ -879,12 +1006,12 @@ char *skel[] = {
" {",
" if ( yywrap() )",
" {",
" yy_c_buf_p =",
" yytext_ptr + YY_MORE_ADJ;",
" yy_c_buf_p = yytext_ptr + offset;",
" return EOF;",
" }",
"",
" YY_NEW_FILE;",
" if ( ! yy_did_buffer_switch_on_eof )",
" YY_NEW_FILE;",
"#ifdef __cplusplus",
" return yyinput();",
"#else",
@ -893,7 +1020,7 @@ char *skel[] = {
" }",
"",
" case EOB_ACT_CONTINUE_SCAN:",
" yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;",
" yy_c_buf_p = yytext_ptr + offset;",
" break;",
"",
" case EOB_ACT_LAST_MATCH:",
@ -912,6 +1039,8 @@ char *skel[] = {
" *yy_c_buf_p = '\\0'; /* preserve yytext */",
" yy_hold_char = *++yy_c_buf_p;",
"",
"%% update BOL and yylineno",
"",
" return c;",
" }",
"",
@ -1001,7 +1130,6 @@ char *skel[] = {
" YY_BUFFER_STATE b;",
"",
" b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );",
"",
" if ( ! b )",
" YY_FATAL_ERROR( \"out of dynamic memory in yy_create_buffer()\" );",
"",
@ -1011,10 +1139,11 @@ char *skel[] = {
" * we need to put in 2 end-of-buffer characters.",
" */",
" b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );",
"",
" if ( ! b->yy_ch_buf )",
" YY_FATAL_ERROR( \"out of dynamic memory in yy_create_buffer()\" );",
"",
" b->yy_is_our_buffer = 1;",
"",
" yy_init_buffer( b, file );",
"",
" return b;",
@ -1032,15 +1161,26 @@ char *skel[] = {
"void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )",
"%*",
" {",
" if ( ! b )",
" return;",
"",
" if ( b == yy_current_buffer )",
" yy_current_buffer = (YY_BUFFER_STATE) 0;",
"",
" yy_flex_free( (void *) b->yy_ch_buf );",
" if ( b->yy_is_our_buffer )",
" yy_flex_free( (void *) b->yy_ch_buf );",
"",
" yy_flex_free( (void *) b );",
" }",
"",
"",
"%-",
"#ifndef YY_ALWAYS_INTERACTIVE",
"#ifndef YY_NEVER_INTERACTIVE",
"extern int isatty YY_PROTO(( int ));",
"#endif",
"#endif",
"",
"#ifdef YY_USE_PROTOS",
"void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )",
"#else",
@ -1048,40 +1188,167 @@ char *skel[] = {
"YY_BUFFER_STATE b;",
"FILE *file;",
"#endif",
"",
"%+",
"extern \"C\" int isatty YY_PROTO(( int ));",
"void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )",
"%*",
"",
" {",
" yy_flush_buffer( b );",
"",
" b->yy_input_file = file;",
" b->yy_fill_buffer = 1;",
"",
" /* We put in the '\\n' and start reading from [1] so that an",
" * initial match-at-newline will be true.",
" */",
"%-",
"#if YY_ALWAYS_INTERACTIVE",
" b->yy_is_interactive = 1;",
"#else",
"#if YY_NEVER_INTERACTIVE",
" b->yy_is_interactive = 0;",
"#else",
" b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;",
"#endif",
"#endif",
"%+",
" b->yy_is_interactive = 0;",
"%*",
" }",
"",
" b->yy_ch_buf[0] = '\\n';",
" b->yy_n_chars = 1;",
"",
"%-",
"#ifdef YY_USE_PROTOS",
"void yy_flush_buffer( YY_BUFFER_STATE b )",
"#else",
"void yy_flush_buffer( b )",
"YY_BUFFER_STATE b;",
"#endif",
"",
"%+",
"void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )",
"%*",
" {",
" b->yy_n_chars = 0;",
"",
" /* 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[0] = YY_END_OF_BUFFER_CHAR;",
" 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_buf_pos = &b->yy_ch_buf[0];",
"",
"%-",
" b->yy_is_interactive = file ? isatty( fileno(file) ) : 0;",
"%+",
" b->yy_is_interactive = 0;",
" b->yy_at_bol = 1;",
" b->yy_buffer_status = YY_BUFFER_NEW;",
"",
" if ( b == yy_current_buffer )",
" yy_load_buffer_state();",
" }",
"%*",
"",
" b->yy_fill_buffer = 1;",
"",
"#ifndef YY_NO_SCAN_BUFFER",
"%-",
"#ifdef YY_USE_PROTOS",
"YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )",
"#else",
"YY_BUFFER_STATE yy_scan_buffer( base, size )",
"char *base;",
"yy_size_t size;",
"#endif",
" {",
" YY_BUFFER_STATE b;",
"",
" if ( size < 2 ||",
" base[size-2] != YY_END_OF_BUFFER_CHAR ||",
" base[size-1] != YY_END_OF_BUFFER_CHAR )",
" /* They forgot to leave room for the EOB's. */",
" return 0;",
"",
" b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );",
" if ( ! b )",
" YY_FATAL_ERROR( \"out of dynamic memory in yy_scan_buffer()\" );",
"",
" b->yy_buf_size = size - 2; /* \"- 2\" to take care of EOB's */",
" b->yy_buf_pos = b->yy_ch_buf = base;",
" b->yy_is_our_buffer = 0;",
" b->yy_input_file = 0;",
" b->yy_n_chars = b->yy_buf_size;",
" b->yy_is_interactive = 0;",
" b->yy_at_bol = 1;",
" b->yy_fill_buffer = 0;",
" b->yy_buffer_status = YY_BUFFER_NEW;",
"",
" yy_switch_to_buffer( b );",
"",
" return b;",
" }",
"%*",
"#endif",
"",
"",
"#ifndef YY_NO_SCAN_STRING",
"%-",
"#ifdef YY_USE_PROTOS",
"YY_BUFFER_STATE yy_scan_string( yyconst char *str )",
"#else",
"YY_BUFFER_STATE yy_scan_string( str )",
"yyconst char *str;",
"#endif",
" {",
" int len;",
" for ( len = 0; str[len]; ++len )",
" ;",
"",
" return yy_scan_bytes( str, len );",
" }",
"%*",
"#endif",
"",
"",
"#ifndef YY_NO_SCAN_BYTES",
"%-",
"#ifdef YY_USE_PROTOS",
"YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )",
"#else",
"YY_BUFFER_STATE yy_scan_bytes( bytes, len )",
"yyconst char *bytes;",
"int len;",
"#endif",
" {",
" YY_BUFFER_STATE b;",
" char *buf;",
" yy_size_t n;",
" int i;",
"",
" /* Get memory for full buffer, including space for trailing EOB's. */",
" n = len + 2;",
" buf = (char *) yy_flex_alloc( n );",
" if ( ! buf )",
" YY_FATAL_ERROR( \"out of dynamic memory in yy_scan_bytes()\" );",
"",
" for ( i = 0; i < len; ++i )",
" buf[i] = bytes[i];",
"",
" buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;",
"",
" b = yy_scan_buffer( buf, n );",
" if ( ! b )",
" YY_FATAL_ERROR( \"bad buffer in yy_scan_bytes()\" );",
"",
" /* It's okay to grow etc. this buffer, and we should throw it",
" * away when we're done.",
" */",
" b->yy_is_our_buffer = 1;",
"",
" return b;",
" }",
"%*",
"#endif",
"",
"",
"#ifndef YY_NO_PUSH_STATE",
"%-",
"#ifdef YY_USE_PROTOS",
"static void yy_push_state( int new_state )",
@ -1095,7 +1362,7 @@ char *skel[] = {
" {",
" if ( yy_start_stack_ptr >= yy_start_stack_depth )",
" {",
" int new_size;",
" yy_size_t new_size;",
"",
" yy_start_stack_depth += YY_START_STACK_INCR;",
" new_size = yy_start_stack_depth * sizeof( int );",
@ -1116,8 +1383,10 @@ char *skel[] = {
"",
" BEGIN(new_state);",
" }",
"#endif",
"",
"",
"#ifndef YY_NO_POP_STATE",
"%-",
"static void yy_pop_state()",
"%+",
@ -1129,8 +1398,10 @@ char *skel[] = {
"",
" BEGIN(yy_start_stack[yy_start_stack_ptr]);",
" }",
"#endif",
"",
"",
"#ifndef YY_NO_TOP_STATE",
"%-",
"static int yy_top_state()",
"%+",
@ -1139,26 +1410,30 @@ char *skel[] = {
" {",
" return yy_start_stack[yy_start_stack_ptr - 1];",
" }",
"#endif",
"",
"#ifndef YY_EXIT_FAILURE",
"#define YY_EXIT_FAILURE 2",
"#endif",
"",
"%-",
"#ifdef YY_USE_PROTOS",
"static void yy_fatal_error( const char msg[] )",
"static void yy_fatal_error( yyconst char msg[] )",
"#else",
"static void yy_fatal_error( msg )",
"char msg[];",
"#endif",
" {",
" (void) fprintf( stderr, \"%s\\n\", msg );",
" exit( 1 );",
" exit( YY_EXIT_FAILURE );",
" }",
"",
"%+",
"",
"void yyFlexLexer::LexerError( const char msg[] )",
"void yyFlexLexer::LexerError( yyconst char msg[] )",
" {",
" cerr << msg << '\\n';",
" exit( 1 );",
" exit( YY_EXIT_FAILURE );",
" }",
"%*",
"",
@ -1171,7 +1446,7 @@ char *skel[] = {
" { \\",
" /* Undo effects of setting up yytext. */ \\",
" yytext[yyleng] = yy_hold_char; \\",
" yy_c_buf_p = yytext + n - YY_MORE_ADJ; \\",
" yy_c_buf_p = yytext + n; \\",
" yy_hold_char = *yy_c_buf_p; \\",
" *yy_c_buf_p = '\\0'; \\",
" yyleng = n; \\",
@ -1183,11 +1458,11 @@ char *skel[] = {
"",
"#ifndef yytext_ptr",
"#ifdef YY_USE_PROTOS",
"static void yy_flex_strncpy( char *s1, const char *s2, int n )",
"static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )",
"#else",
"static void yy_flex_strncpy( s1, s2, n )",
"char *s1;",
"const char *s2;",
"yyconst char *s2;",
"int n;",
"#endif",
" {",
@ -1197,26 +1472,49 @@ char *skel[] = {
" }",
"#endif",
"",
"#ifdef YY_NEED_STRLEN",
"#ifdef YY_USE_PROTOS",
"static int yy_flex_strlen( yyconst char *s )",
"#else",
"static int yy_flex_strlen( s )",
"yyconst char *s;",
"#endif",
" {",
" register int n;",
" for ( n = 0; s[n]; ++n )",
" ;",
"",
" return n;",
" }",
"#endif",
"",
"",
"#ifdef YY_USE_PROTOS",
"static void *yy_flex_alloc( unsigned int size )",
"static void *yy_flex_alloc( yy_size_t size )",
"#else",
"static void *yy_flex_alloc( size )",
"unsigned int size;",
"yy_size_t size;",
"#endif",
" {",
" return (void *) malloc( size );",
" }",
"",
"#ifdef YY_USE_PROTOS",
"static void *yy_flex_realloc( void *ptr, unsigned int size )",
"static void *yy_flex_realloc( void *ptr, yy_size_t size )",
"#else",
"static void *yy_flex_realloc( ptr, size )",
"void *ptr;",
"unsigned int size;",
"yy_size_t size;",
"#endif",
" {",
" return (void *) realloc( ptr, size );",
" /* The cast to (char *) in the following accommodates both",
" * implementations that use char* generic pointers, and those",
" * that use void* generic pointers. It works with the latter",
" * because both ANSI C and C++ allow castless assignment from",
" * any pointer type to void*, and deal with argument conversions",
" * as though doing an assignment.",
" */",
" return (void *) realloc( (char *) ptr, size );",
" }",
"",
"#ifdef YY_USE_PROTOS",
@ -1228,5 +1526,13 @@ char *skel[] = {
" {",
" free( ptr );",
" }",
"",
"#if YY_MAIN",
"int main()",
" {",
" yylex();",
" return 0;",
" }",
"#endif",
0
};

View file

@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: sym.c,v 1.2 94/01/04 14:33:06 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/sym.c,v 2.19 95/03/04 16:11:04 vern Exp $ */
#include "flexdef.h"
@ -75,9 +75,9 @@ int table_size;
flex_alloc( sizeof( struct hash_entry ) );
if ( new_entry == NULL )
flexfatal( "symbol table memory allocation failed" );
flexfatal( _( "symbol table memory allocation failed" ) );
if ( (successor = table[hash_val]) )
if ( (successor = table[hash_val]) != 0 )
{
new_entry->next = successor;
successor->prev = new_entry;
@ -150,7 +150,7 @@ int table_size;
return &empty_entry;
}
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
int hashfunct( str, hash_size )
@ -185,7 +185,7 @@ Char definition[];
if ( addsym( copy_string( name ),
(char *) copy_unsigned_string( definition ), 0,
ndtbl, NAME_TABLE_HASH_SIZE ) )
synerr( "name defined twice" );
synerr( _( "name defined twice" ) );
}
@ -214,7 +214,6 @@ void scextend()
scxclu = reallocate_integer_array( scxclu, current_max_scs );
sceof = reallocate_integer_array( sceof, current_max_scs );
scname = reallocate_char_ptr_array( scname, current_max_scs );
actvsc = reallocate_integer_array( actvsc, current_max_scs );
}
@ -231,7 +230,7 @@ int xcluflg;
char *copy_string();
/* Generate start condition definition, for use in BEGIN et al. */
printf( "#define %s %d\n", str, lastsc );
action_define( str, lastsc );
if ( ++lastsc >= current_max_scs )
scextend();
@ -240,7 +239,8 @@ int xcluflg;
if ( addsym( scname[lastsc], (char *) 0, lastsc,
sctbl, START_COND_HASH_SIZE ) )
format_pinpoint_message( "start condition %s declared twice",
format_pinpoint_message(
_( "start condition %s declared twice" ),
str );
scset[lastsc] = mkstate( SYM_EPSILON );

View file

@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/RCS/tblcmp.c,v 2.10 93/12/07 10:18:30 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/tblcmp.c,v 2.11 94/11/05 17:08:28 vern Exp $ */
#include "flexdef.h"
@ -310,7 +310,7 @@ void expand_nxt_chk()
chk = reallocate_integer_array( chk, current_max_xpairs );
zero_out( (char *) (chk + old_max),
MAX_XPAIRS_INCREMENT * sizeof( int ) / sizeof( char ) );
(size_t) (MAX_XPAIRS_INCREMENT * sizeof( int )) );
}
@ -436,8 +436,7 @@ void inittbl()
{
register int i;
zero_out( (char *) chk,
current_max_xpairs * sizeof( int ) / sizeof( char ) );
zero_out( (char *) chk, (size_t) (current_max_xpairs * sizeof( int )) );
tblend = 0;
firstfree = tblend + 1;

View file

@ -1 +1 @@
#define FLEX_VERSION "2.4.7"
#define FLEX_VERSION "2.5.3"

View file

@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/RCS/yylex.c,v 2.10 93/09/16 20:31:48 vern Exp $ */
/* $Header: /home/daffy/u0/vern/flex/RCS/yylex.c,v 2.13 95/03/04 16:10:41 vern Exp $ */
#include <ctype.h>
#include "flexdef.h"
@ -39,6 +39,7 @@ int yylex()
{
int toktype;
static int beglin = false;
extern char *yytext;
if ( eofseen )
toktype = EOF;
@ -51,7 +52,7 @@ int yylex()
if ( sectnum == 1 )
{
synerr( "premature EOF" );
synerr( _( "premature EOF" ) );
sectnum = 2;
toktype = SECTEND;
}
@ -109,10 +110,6 @@ int yylex()
fputs( "%x", stderr );
break;
case WHITESPACE:
(void) putc( ' ', stderr );
break;
case SECTEND:
fputs( "%%\n", stderr );
@ -120,9 +117,8 @@ int yylex()
* writing out numbers as we echo rules.
* flexscan() has already assigned sectnum.
*/
if ( sectnum == 2 )
beglin = 1;
beglin = 1;
break;
@ -183,13 +179,34 @@ int yylex()
fprintf( stderr, "<<EOF>>" );
break;
case OPTION_OP:
fprintf( stderr, "%s ", yytext );
break;
case OPT_OUTFILE:
case OPT_PREFIX:
case CCE_ALNUM:
case CCE_ALPHA:
case CCE_BLANK:
case CCE_CNTRL:
case CCE_DIGIT:
case CCE_GRAPH:
case CCE_LOWER:
case CCE_PRINT:
case CCE_PUNCT:
case CCE_SPACE:
case CCE_UPPER:
case CCE_XDIGIT:
fprintf( stderr, "%s", yytext );
break;
case 0:
fprintf( stderr, "End Marker" );
fprintf( stderr, _( "End Marker\n" ) );
break;
default:
fprintf( stderr,
"*Something Weird* - tok: %d val: %d\n",
_( "*Something Weird* - tok: %d val: %d\n" ),
toktype, yylval );
break;
}