import vanilla flex version 2.5.35

Reviewed by:	cognet
Approved by:	cognet
This commit is contained in:
Baptiste Daroussin 2011-11-28 14:58:51 +00:00
parent 112e4e871c
commit 6916e47018
93 changed files with 63805 additions and 17726 deletions

625
ABOUT-NLS Normal file
View File

@ -0,0 +1,625 @@
Notes on the Free Translation Project
*************************************
Free software is going international! The Free Translation Project
is a way to get maintainers of free software, translators, and users all
together, so that will gradually become able to speak many languages.
A few packages already provide translations for their messages.
If you found this `ABOUT-NLS' file inside a distribution, you may
assume that the distributed package does use GNU `gettext' internally,
itself available at your nearest GNU archive site. But you do _not_
need to install GNU `gettext' prior to configuring, installing or using
this package with messages translated.
Installers will find here some useful hints. These notes also
explain how users should proceed for getting the programs to use the
available translations. They tell how people wanting to contribute and
work at translations should contact the appropriate team.
When reporting bugs in the `intl/' directory or bugs which may be
related to internationalization, you should tell about the version of
`gettext' which is used. The information can be found in the
`intl/VERSION' file, in internationalized packages.
Quick configuration advice
==========================
If you want to exploit the full power of internationalization, you
should configure it using
./configure --with-included-gettext
to force usage of internationalizing routines provided within this
package, despite the existence of internationalizing capabilities in the
operating system where this package is being installed. So far, only
the `gettext' implementation in the GNU C library version 2 provides as
many features (such as locale alias, message inheritance, automatic
charset conversion or plural form handling) as the implementation here.
It is also not possible to offer this additional functionality on top
of a `catgets' implementation. Future versions of GNU `gettext' will
very likely convey even more functionality. So it might be a good idea
to change to GNU `gettext' as soon as possible.
So you need _not_ provide this option if you are using GNU libc 2 or
you have installed a recent copy of the GNU gettext package with the
included `libintl'.
INSTALL Matters
===============
Some packages are "localizable" when properly installed; the
programs they contain can be made to speak your own native language.
Most such packages use GNU `gettext'. Other packages have their own
ways to internationalization, predating GNU `gettext'.
By default, this package will be installed to allow translation of
messages. It will automatically detect whether the system already
provides the GNU `gettext' functions. If not, the GNU `gettext' own
library will be used. This library is wholly contained within this
package, usually in the `intl/' subdirectory, so prior installation of
the GNU `gettext' package is _not_ required. Installers may use
special options at configuration time for changing the default
behaviour. The commands:
./configure --with-included-gettext
./configure --disable-nls
will respectively bypass any pre-existing `gettext' to use the
internationalizing routines provided within this package, or else,
_totally_ disable translation of messages.
When you already have GNU `gettext' installed on your system and run
configure without an option for your new package, `configure' will
probably detect the previously built and installed `libintl.a' file and
will decide to use this. This might be not what is desirable. You
should use the more recent version of the GNU `gettext' library. I.e.
if the file `intl/VERSION' shows that the library which comes with this
package is more recent, you should use
./configure --with-included-gettext
to prevent auto-detection.
The configuration process will not test for the `catgets' function
and therefore it will not be used. The reason is that even an
emulation of `gettext' on top of `catgets' could not provide all the
extensions of the GNU `gettext' library.
Internationalized packages have usually many `po/LL.po' files, where
LL gives an ISO 639 two-letter code identifying the language. Unless
translations have been forbidden at `configure' time by using the
`--disable-nls' switch, all available translations are installed
together with the package. However, the environment variable `LINGUAS'
may be set, prior to configuration, to limit the installed set.
`LINGUAS' should then contain a space separated list of two-letter
codes, stating which languages are allowed.
Using This Package
==================
As a user, if your language has been installed for this package, you
only have to set the `LANG' environment variable to the appropriate
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
and `CC' is an ISO 3166 two-letter country code. For example, let's
suppose that you speak German and live in Germany. At the shell
prompt, merely execute `setenv LANG de_DE' (in `csh'),
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
This can be done from your `.login' or `.profile' file, once and for
all.
You might think that the country code specification is redundant.
But in fact, some languages have dialects in different countries. For
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
country code serves to distinguish the dialects.
The locale naming convention of `LL_CC', with `LL' denoting the
language and `CC' denoting the country, is the one use on systems based
on GNU libc. On other systems, some variations of this scheme are
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
locales supported by your system for your country by running the command
`locale -a | grep '^LL''.
Not all programs have translations for all languages. By default, an
English message is shown in place of a nonexistent translation. If you
understand other languages, you can set up a priority list of languages.
This is done through a different environment variable, called
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
for the purpose of message handling, but you still need to have `LANG'
set to the primary language; this is required by other parts of the
system libraries. For example, some Swedish users who would rather
read translations in German than English for when Swedish is not
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
In the `LANGUAGE' environment variable, but not in the `LANG'
environment variable, `LL_CC' combinations can be abbreviated as `LL'
to denote the language's main dialect. For example, `de' is equivalent
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
(Portuguese as spoken in Portugal) in this context.
Translating Teams
=================
For the Free Translation Project to be a success, we need interested
people who like their own language and write it well, and who are also
able to synergize with other translators speaking the same language.
Each translation team has its own mailing list. The up-to-date list of
teams can be found at the Free Translation Project's homepage,
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
area.
If you'd like to volunteer to _work_ at translating messages, you
should become a member of the translating team for your own language.
The subscribing address is _not_ the same as the list itself, it has
`-request' appended. For example, speakers of Swedish can send a
message to `sv-request@li.org', having this message body:
subscribe
Keep in mind that team members are expected to participate
_actively_ in translations, or at solving translational difficulties,
rather than merely lurking around. If your team does not exist yet and
you want to start one, or if you are unsure about what to do or how to
get started, please write to `translation@iro.umontreal.ca' to reach the
coordinator for all translator teams.
The English team is special. It works at improving and uniformizing
the terminology in use. Proven linguistic skill are praised more than
programming skill, here.
Available Packages
==================
Languages are not equally supported in all packages. The following
matrix shows the current state of internationalization, as of May 2003.
The matrix shows, in regard of each package, for which languages PO
files have been submitted to translation coordination, with a
translation percentage of at least 50%.
Ready PO files am az be bg ca cs da de el en en_GB eo es
+-------------------------------------------+
a2ps | [] [] [] [] |
aegis | () |
anubis | |
ap-utils | |
bash | [] [] [] |
batchelor | |
bfd | [] [] |
binutils | [] [] |
bison | [] [] [] |
bluez-pin | [] [] |
clisp | |
clisp | [] [] [] |
coreutils | [] [] [] [] |
cpio | [] [] [] |
darkstat | () [] |
diffutils | [] [] [] [] [] [] [] |
e2fsprogs | [] [] |
enscript | [] [] [] [] |
error | [] [] [] [] [] |
fetchmail | [] () [] [] [] [] |
fileutils | [] [] [] |
findutils | [] [] [] [] [] [] |
flex | [] [] [] [] |
gas | [] |
gawk | [] [] [] [] |
gcal | [] |
gcc | [] [] |
gettext | [] [] [] [] [] |
gettext-runtime | [] [] [] [] [] |
gettext-tools | [] [] |
gimp-print | [] [] [] [] [] |
gliv | |
glunarclock | [] [] [] |
gnucash | () [] |
gnucash-glossary | [] () [] |
gnupg | [] () [] [] [] [] |
gpe-calendar | [] |
gpe-conf | [] |
gpe-contacts | [] |
gpe-edit | |
gpe-login | [] |
gpe-ownerinfo | [] |
gpe-sketchbook | [] |
gpe-timesheet | |
gpe-today | [] |
gpe-todo | [] |
gphoto2 | [] [] [] [] |
gprof | [] [] |
gpsdrive | () () () |
grep | [] [] [] [] [] |
gretl | [] |
hello | [] [] [] [] [] [] |
id-utils | [] [] |
indent | [] [] [] [] |
jpilot | [] [] [] [] |
jwhois | [] |
kbd | [] [] [] [] [] |
ld | [] [] |
libc | [] [] [] [] [] [] |
libgpewidget | [] |
libiconv | [] [] [] [] [] |
lifelines | [] () |
lilypond | [] |
lingoteach | |
lingoteach_lessons | () () |
lynx | [] [] [] [] |
m4 | [] [] [] [] |
mailutils | [] [] |
make | [] [] [] |
man-db | [] () [] [] () |
mysecretdiary | [] [] [] |
nano | [] () [] [] [] |
nano_1_0 | [] () [] [] [] |
opcodes | [] [] |
parted | [] [] [] [] [] |
ptx | [] [] [] [] [] |
python | |
radius | |
recode | [] [] [] [] [] [] |
screem | |
sed | [] [] [] [] [] |
sh-utils | [] [] [] |
sharutils | [] [] [] [] [] [] |
sketch | [] () [] |
soundtracker | [] [] [] |
sp | [] |
tar | [] [] [] [] |
texinfo | [] [] [] [] |
textutils | [] [] [] [] |
tin | () () |
util-linux | [] [] [] [] [] |
vorbis-tools | [] [] [] |
wastesedge | () |
wdiff | [] [] [] [] |
wget | [] [] [] [] [] [] [] |
xchat | [] [] [] |
xpad | |
+-------------------------------------------+
am az be bg ca cs da de el en en_GB eo es
0 1 4 2 31 17 54 60 14 1 4 12 56
et fa fi fr ga gl he hr hu id it ja ko
+----------------------------------------+
a2ps | [] [] [] () () |
aegis | |
anubis | [] |
ap-utils | [] |
bash | [] [] |
batchelor | [] |
bfd | [] [] |
binutils | [] [] |
bison | [] [] [] [] |
bluez-pin | [] [] [] [] |
clisp | |
clisp | [] |
coreutils | [] [] [] [] |
cpio | [] [] [] [] |
darkstat | () [] [] [] |
diffutils | [] [] [] [] [] [] [] |
e2fsprogs | |
enscript | [] [] |
error | [] [] [] [] |
fetchmail | [] |
fileutils | [] [] [] [] [] |
findutils | [] [] [] [] [] [] [] [] [] [] [] |
flex | [] [] |
gas | [] |
gawk | [] [] |
gcal | [] |
gcc | [] |
gettext | [] [] [] |
gettext-runtime | [] [] [] [] |
gettext-tools | [] |
gimp-print | [] [] |
gliv | () |
glunarclock | [] [] [] [] |
gnucash | [] |
gnucash-glossary | [] |
gnupg | [] [] [] [] [] [] [] |
gpe-calendar | [] |
gpe-conf | |
gpe-contacts | [] |
gpe-edit | [] [] |
gpe-login | [] |
gpe-ownerinfo | [] [] [] |
gpe-sketchbook | [] |
gpe-timesheet | [] [] [] |
gpe-today | [] [] |
gpe-todo | [] [] |
gphoto2 | [] [] [] |
gprof | [] [] |
gpsdrive | () [] () () |
grep | [] [] [] [] [] [] [] [] [] [] [] |
gretl | [] |
hello | [] [] [] [] [] [] [] [] [] [] [] [] [] |
id-utils | [] [] [] |
indent | [] [] [] [] [] [] [] [] |
jpilot | [] () |
jwhois | [] [] [] [] |
kbd | [] |
ld | [] |
libc | [] [] [] [] [] [] |
libgpewidget | [] [] [] |
libiconv | [] [] [] [] [] [] [] [] |
lifelines | () |
lilypond | [] |
lingoteach | [] [] |
lingoteach_lessons | |
lynx | [] [] [] [] |
m4 | [] [] [] [] |
mailutils | |
make | [] [] [] [] [] [] |
man-db | [] () () |
mysecretdiary | [] [] |
nano | [] [] [] [] |
nano_1_0 | [] [] [] [] |
opcodes | [] [] |
parted | [] [] [] |
ptx | [] [] [] [] [] [] [] |
python | |
radius | |
recode | [] [] [] [] [] [] |
screem | |
sed | [] [] [] [] [] [] [] [] |
sh-utils | [] [] [] [] [] [] |
sharutils | [] [] [] [] [] |
sketch | [] |
soundtracker | [] [] [] |
sp | [] () |
tar | [] [] [] [] [] [] [] [] [] |
texinfo | [] [] [] [] |
textutils | [] [] [] [] [] |
tin | [] () |
util-linux | [] [] [] [] () [] |
vorbis-tools | [] |
wastesedge | () |
wdiff | [] [] [] [] [] |
wget | [] [] [] [] [] [] [] [] |
xchat | [] [] [] |
xpad | |
+----------------------------------------+
et fa fi fr ga gl he hr hu id it ja ko
20 1 15 73 14 24 8 10 30 31 19 31 9
lg lt lv ms nb nl nn no pl pt pt_BR ro
+----------------------------------------+
a2ps | [] [] () () () [] [] |
aegis | () |
anubis | [] [] |
ap-utils | () |
bash | [] |
batchelor | |
bfd | |
binutils | |
bison | [] [] [] [] |
bluez-pin | [] |
clisp | |
clisp | [] |
coreutils | [] |
cpio | [] [] [] |
darkstat | [] [] [] [] |
diffutils | [] [] [] |
e2fsprogs | |
enscript | [] [] |
error | [] [] |
fetchmail | () () |
fileutils | [] |
findutils | [] [] [] [] |
flex | [] |
gas | |
gawk | [] |
gcal | |
gcc | |
gettext | [] |
gettext-runtime | [] |
gettext-tools | |
gimp-print | [] |
gliv | [] |
glunarclock | [] |
gnucash | |
gnucash-glossary | [] [] |
gnupg | |
gpe-calendar | [] [] |
gpe-conf | [] [] |
gpe-contacts | [] |
gpe-edit | [] [] |
gpe-login | [] [] |
gpe-ownerinfo | [] [] |
gpe-sketchbook | [] [] |
gpe-timesheet | [] [] |
gpe-today | [] [] |
gpe-todo | [] [] |
gphoto2 | |
gprof | [] |
gpsdrive | () () () |
grep | [] [] [] [] |
gretl | |
hello | [] [] [] [] [] [] [] [] [] |
id-utils | [] [] [] |
indent | [] [] [] |
jpilot | () () |
jwhois | [] [] [] |
kbd | |
ld | |
libc | [] [] [] [] |
libgpewidget | [] [] |
libiconv | [] [] |
lifelines | |
lilypond | [] |
lingoteach | |
lingoteach_lessons | |
lynx | [] [] |
m4 | [] [] [] [] |
mailutils | |
make | [] [] |
man-db | [] |
mysecretdiary | [] |
nano | [] [] [] [] |
nano_1_0 | [] [] [] [] |
opcodes | [] [] [] |
parted | [] [] [] |
ptx | [] [] [] [] [] [] [] |
python | |
radius | |
recode | [] [] [] |
screem | |
sed | [] [] |
sh-utils | [] |
sharutils | [] |
sketch | [] |
soundtracker | |
sp | |
tar | [] [] [] [] [] [] |
texinfo | [] |
textutils | [] |
tin | |
util-linux | [] [] |
vorbis-tools | [] [] |
wastesedge | |
wdiff | [] [] [] [] |
wget | [] [] [] |
xchat | [] [] |
xpad | [] |
+----------------------------------------+
lg lt lv ms nb nl nn no pl pt pt_BR ro
0 0 2 11 7 26 3 4 18 15 34 34
ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW
+-------------------------------------------+
a2ps | [] [] [] [] [] | 16
aegis | () | 0
anubis | [] [] | 5
ap-utils | () | 1
bash | [] | 7
batchelor | | 1
bfd | [] [] [] | 7
binutils | [] [] [] | 7
bison | [] [] | 13
bluez-pin | | 7
clisp | | 0
clisp | | 5
coreutils | [] [] [] [] [] | 14
cpio | [] [] [] | 13
darkstat | [] () () | 9
diffutils | [] [] [] [] | 21
e2fsprogs | [] | 3
enscript | [] [] [] | 11
error | [] [] [] | 14
fetchmail | [] | 7
fileutils | [] [] [] [] [] [] | 15
findutils | [] [] [] [] [] [] | 27
flex | [] [] [] | 10
gas | [] | 3
gawk | [] [] | 9
gcal | [] [] | 4
gcc | [] | 4
gettext | [] [] [] [] [] [] | 15
gettext-runtime | [] [] [] [] [] [] | 16
gettext-tools | [] [] | 5
gimp-print | [] [] | 10
gliv | | 1
glunarclock | [] [] [] | 11
gnucash | [] [] | 4
gnucash-glossary | [] [] [] | 8
gnupg | [] [] [] [] | 16
gpe-calendar | [] | 5
gpe-conf | | 3
gpe-contacts | [] | 4
gpe-edit | [] | 5
gpe-login | [] | 5
gpe-ownerinfo | [] | 7
gpe-sketchbook | [] | 5
gpe-timesheet | [] | 6
gpe-today | [] | 6
gpe-todo | [] | 6
gphoto2 | [] [] | 9
gprof | [] [] | 7
gpsdrive | [] [] | 3
grep | [] [] [] [] | 24
gretl | | 2
hello | [] [] [] [] [] | 33
id-utils | [] [] [] | 11
indent | [] [] [] [] | 19
jpilot | [] [] [] [] [] | 10
jwhois | () () [] [] | 10
kbd | [] [] | 8
ld | [] [] | 5
libc | [] [] [] [] | 20
libgpewidget | | 6
libiconv | [] [] [] [] [] [] | 21
lifelines | [] | 2
lilypond | [] | 4
lingoteach | | 2
lingoteach_lessons | () | 0
lynx | [] [] [] [] | 14
m4 | [] [] [] | 15
mailutils | | 2
make | [] [] [] [] | 15
man-db | [] | 6
mysecretdiary | [] [] | 8
nano | [] [] [] | 15
nano_1_0 | [] [] [] | 15
opcodes | [] [] | 9
parted | [] [] | 13
ptx | [] [] [] | 22
python | | 0
radius | | 0
recode | [] [] [] [] | 19
screem | [] | 1
sed | [] [] [] [] [] | 20
sh-utils | [] [] [] | 13
sharutils | [] [] [] [] | 16
sketch | [] | 5
soundtracker | [] | 7
sp | [] | 3
tar | [] [] [] [] [] | 24
texinfo | [] [] [] [] | 13
textutils | [] [] [] [] [] | 15
tin | | 1
util-linux | [] [] | 14
vorbis-tools | [] | 7
wastesedge | | 0
wdiff | [] [] [] [] | 17
wget | [] [] [] [] [] [] [] | 25
xchat | [] [] [] | 11
xpad | | 1
+-------------------------------------------+
50 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW
97 domains 32 19 16 0 56 0 48 10 1 1 12 23 913
Some counters in the preceding matrix are higher than the number of
visible blocks let us expect. This is because a few extra PO files are
used for implementing regional variants of languages, or language
dialects.
For a PO file in the matrix above to be effective, the package to
which it applies should also have been internationalized and
distributed as such by its maintainer. There might be an observable
lag between the mere existence a PO file and its wide availability in a
distribution.
If May 2003 seems to be old, you may fetch a more recent copy of
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
matrix with full percentage details can be found at
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
Using `gettext' in new packages
===============================
If you are writing a freely available program and want to
internationalize it you are welcome to use GNU `gettext' in your
package. Of course you have to respect the GNU Library General Public
License which covers the use of the GNU `gettext' library. This means
in particular that even non-free programs can use `libintl' as a shared
library, whereas only free software can use `libintl' as a static
library or use modified versions of `libintl'.
Once the sources are changed appropriately and the setup can handle
the use of `gettext' the only thing missing are the translations. The
Free Translation Project is also available for packages which are not
developed inside the GNU project. Therefore the information given above
applies also for every other Free Software Project. Contact
`translation@iro.umontreal.ca' to make the `.pot' files available to
the translation teams.

16
AUTHORS Normal file
View File

@ -0,0 +1,16 @@
In 2001, Will Estes took over as maintainer of flex.
John Millaway is a co-author of the current version of flex. He has
contributed a large number of new features, fixed a large number of
outstanding bugs and has made significant contributions to the flex
documentation.
Aaron Stone has contributed several bug fixes to the flex codebase.
Vern Paxson wrote flex with the help of many ideas and much
inspiration from Van Jacobson. Original version by Jef Poskanzer.
The fast table representation is a partial implementation of a design
done by Van Jacobson. The implementation was done by Kevin Gong and
Vern Paxson.

42
COPYING Normal file
View File

@ -0,0 +1,42 @@
Flex carries the copyright used for BSD software, slightly modified
because it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
which operates under a contract with the Department of Energy:
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Flex Project.
Copyright (c) 1990, 1997 The Regents of the University of California.
All rights reserved.
This code is derived from software contributed to Berkeley by
Vern Paxson.
The United States Government has rights in this work pursuant
to contract no. DE-AC03-76SF00098 between the United States
Department of Energy and the University of California.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
This basically says "do whatever you please with this software except
remove this notice or take advantage of the University's (or the flex
authors') name".
Note that the "flex.skl" scanner skeleton carries no copyright notice.
You are free to do whatever you please with scanners generated using flex;
for them, you are not even bound by the above copyright.

7439
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
// $Header: /home/daffy/u0/vern/flex/RCS/FlexLexer.h,v 1.19 96/05/25 20:43:02 vern Exp $
// -*-C++-*-
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
// by flex
// by flex
// Copyright (c) 1993 The Regents of the University of California.
// All rights reserved.
@ -9,19 +8,24 @@
// This code is derived from software contributed to Berkeley by
// Kent Williams and Tom Epperly.
//
// Redistribution and use in source and binary forms are permitted provided
// that: (1) source distributions retain this entire copyright notice and
// comment, and (2) distributions including binaries display the following
// acknowledgement: ``This product includes software developed by the
// University of California, Berkeley and its contributors'' in the
// documentation or other materials provided with the distribution and in
// all advertising materials mentioning features or use of this software.
// Neither the name of the University nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the University nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE.
// This file defines FlexLexer, an abstract class which specifies the
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
@ -43,7 +47,11 @@
#ifndef __FLEX_LEXER_H
// Never included before - need to define base class.
#define __FLEX_LEXER_H
#include <iostream.h>
#include <iostream>
# ifndef FLEX_STD
# define FLEX_STD std::
# endif
extern "C++" {
@ -54,20 +62,20 @@ class FlexLexer {
public:
virtual ~FlexLexer() { }
const char* YYText() { return yytext; }
int YYLeng() { return yyleng; }
const char* YYText() const { return yytext; }
int YYLeng() const { return yyleng; }
virtual void
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
virtual struct yy_buffer_state*
yy_create_buffer( istream* s, int size ) = 0;
yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
virtual void yyrestart( istream* s ) = 0;
virtual void yyrestart( FLEX_STD istream* s ) = 0;
virtual int yylex() = 0;
// Call yylex with new input/output sources.
int yylex( istream* new_in, ostream* new_out = 0 )
int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
{
switch_streams( new_in, new_out );
return yylex();
@ -75,8 +83,8 @@ class FlexLexer {
// 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;
virtual void switch_streams( FLEX_STD istream* new_in = 0,
FLEX_STD ostream* new_out = 0 ) = 0;
int lineno() const { return yylineno; }
@ -91,29 +99,35 @@ class FlexLexer {
};
}
#endif
#endif // FLEXLEXER_H
#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.
// yyFlexLexer, as discussed in the flex manual.
#define yyFlexLexerOnce
extern "C++" {
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 );
yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
virtual ~yyFlexLexer();
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
struct yy_buffer_state* yy_create_buffer( istream* s, int size );
struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
void yy_delete_buffer( struct yy_buffer_state* b );
void yyrestart( istream* s );
void yyrestart( FLEX_STD istream* s );
void yypush_buffer_state( struct yy_buffer_state* new_buffer );
void yypop_buffer_state();
virtual int yylex();
virtual void switch_streams( istream* new_in, ostream* new_out );
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
virtual int yywrap();
protected:
virtual int LexerInput( char* buf, int max_size );
@ -124,7 +138,7 @@ class yyFlexLexer : public FlexLexer {
int yyinput();
void yy_load_buffer_state();
void yy_init_buffer( struct yy_buffer_state* b, istream* s );
void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
void yy_flush_buffer( struct yy_buffer_state* b );
int yy_start_stack_ptr;
@ -139,10 +153,8 @@ class yyFlexLexer : public FlexLexer {
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
int yy_get_next_buffer();
istream* yyin; // input source for default LexerInput
ostream* yyout; // output sink for default LexerOutput
struct yy_buffer_state* yy_current_buffer;
FLEX_STD istream* yyin; // input source for default LexerInput
FLEX_STD ostream* yyout; // output sink for default LexerOutput
// yy_hold_char holds the character lost when yytext is formed.
char yy_hold_char;
@ -160,6 +172,12 @@ class yyFlexLexer : public FlexLexer {
// instead of setting up a fresh yyin. A bit of a hack ...
int yy_did_buffer_switch_on_eof;
size_t yy_buffer_stack_top; /**< index of top of stack. */
size_t yy_buffer_stack_max; /**< capacity of stack. */
struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
void yyensure_buffer_stack(void);
// The following are not always needed, but may be depending
// on use of certain flex features (like REJECT or yymore()).
@ -182,4 +200,7 @@ class yyFlexLexer : public FlexLexer {
int yy_prev_more_offset;
};
#endif
}
#endif // yyFlexLexer || ! yyFlexLexerOnce

236
INSTALL Normal file
View File

@ -0,0 +1,236 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

208
Makefile.am Normal file
View File

@ -0,0 +1,208 @@
# This file is part of flex.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# Notes on building:
# Possible values for DEFS:
#
# By default, flex generates 8-bit scanners when using table compression,
# and 7-bit scanners when using uncompressed tables (-f or -F options).
# For flex to always generate 8-bit scanners, add "-DDEFAULT_CSIZE=256"
# to DEFS.
#
# For Vax/VMS, add "-DVMS" to DEFS.
#
# For MS-DOS, add "-DMS_DOS" to DEFS. See the directory MISC/MSDOS for
# additional info.
AM_YFLAGS = -d
ACLOCAL_AMFLAGS = -I m4
m4 = @M4@
indent = @INDENT@
bin_PROGRAMS = flex
lib_LIBRARIES = \
libfl.a \
libfl_pic.a
flex_SOURCES = \
ccl.c \
dfa.c \
ecs.c \
scanflags.c \
gen.c \
main.c \
misc.c \
nfa.c \
parse.y \
scan.l \
skel.c \
sym.c \
tblcmp.c \
yylex.c \
options.c \
scanopt.c \
buf.c \
tables.c \
tables_shared.c \
filter.c \
regex.c
libfl_a_SOURCES = \
libmain.c \
libyywrap.c
libfl_pic_a_SOURCES = \
libmain.c \
libyywrap.c
libfl_pic_a_CFLAGS = \
-fPIC \
$(AM_CFLAGS)
noinst_HEADERS = \
flexdef.h \
flexint.h \
version.h \
options.h \
scanopt.h \
tables.h \
tables_shared.h
include_HEADERS = \
FlexLexer.h
EXTRA_DIST = \
.indent.pro \
AUTHORS \
COPYING \
INSTALL \
NEWS \
ONEWS \
README \
README.cvs \
THANKS \
TODO \
autogen.sh \
flex.skl \
mkskel.sh \
ABOUT-NLS \
config.rpath \
gettext.h
BUILT_SOURCES = \
skel.c
SUBDIRS = \
. \
doc \
m4 \
examples \
po \
tools \
tests
localedir = $(datadir)/locale
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/intl
LIBS = @LIBINTL@ @LIBS@
skel.c: flex.skl mkskel.sh flexint.h tables_shared.h
sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' $(srcdir)/flex.skl | $(m4) -P -DFLEX_MAJOR_VERSION=`echo $(VERSION)|cut -f 1 -d .` -DFLEX_MINOR_VERSION=`echo $(VERSION)|cut -f 2 -d .` -DFLEX_SUBMINOR_VERSION=`echo $(VERSION)|cut -f 3 -d .` | sed 's/m4postproc_/m4_/g' | $(SHELL) $(srcdir)/mkskel.sh >skel.c
# Explicitly describe dependencies.
# You can recreate this with `gcc -I. -MM *.c'
buf.o: buf.c flexdef.h flexint.h
ccl.o: ccl.c flexdef.h flexint.h
dfa.o: dfa.c flexdef.h flexint.h tables.h tables_shared.h
ecs.o: ecs.c flexdef.h flexint.h
scanflags.o: scanflags.c flexdef.h flexint.h
gen.o: gen.c flexdef.h flexint.h tables.h tables_shared.h
libmain.o: libmain.c
libyywrap.o: libyywrap.c
main.o: main.c flexdef.h flexint.h version.h options.h scanopt.h \
tables.h tables_shared.h
misc.o: misc.c flexdef.h flexint.h tables.h tables_shared.h
nfa.o: nfa.c flexdef.h flexint.h
options.o: options.c options.h scanopt.h flexdef.h flexint.h
parse.o: parse.c flexdef.h flexint.h tables.h tables_shared.h
scan.o: scan.c flexdef.h flexint.h parse.h
scanopt.o: scanopt.c flexdef.h flexint.h scanopt.h
skel.o: skel.c flexdef.h flexint.h
sym.o: sym.c flexdef.h flexint.h
tables.o: tables.c flexdef.h flexint.h tables.h tables_shared.h
tables_shared.o: tables_shared.c flexdef.h flexint.h tables.h \
tables_shared.h
tblcmp.o: tblcmp.c flexdef.h flexint.h
yylex.o: yylex.c flexdef.h flexint.h parse.h
filter.o: filter.c flexdef.h flexint.h
# Create the ChangeLog, but only if we're inside a cvs working directory
ChangeLog: $(srcdir)/tools/cvsauthors $(srcdir)/tools/cvs2cl.pl
if [ -d CVS ] ; then \
sh $(srcdir)/tools/cvs2cl.pl -F trunk -U $(srcdir)/tools/cvsauthors \
; fi
# Run GNU indent on sources. Don't run this unless all the sources compile cleanly.
#
# Whole idea:
# 1. Check for .indent.pro, otherwise indent will use unknown
# settings, or worse, the GNU defaults.)
# 2. Check that this is GNU indent.
# 3. Make sure to process only the NON-generated .c and .h files.
# 4. Run indent twice per file. The first time is a test.
# Otherwise, indent overwrites your file even if it fails!
indentfiles = \
buf.c \
ccl.c \
dfa.c \
ecs.c \
scanflags.c \
filter.c \
flexdef.h \
gen.c \
libmain.c \
libyywrap.c \
main.c \
misc.c \
nfa.c \
options.c \
options.h \
regex.c \
scanopt.c \
scanopt.h \
sym.c \
tables.c \
tables.h \
tables_shared.c \
tables_shared.h \
tblcmp.c
indent:
if [ -f .indent.pro ] ; then \
for f in $(indentfiles);\
do\
echo indenting $$f ;\
$(indent) < $$f >/dev/null && indent $$f || echo $$f FAILED to indent ;\
done \
fi
.PHONY: ChangeLog tags indent

1096
Makefile.in Normal file

File diff suppressed because it is too large Load Diff

488
NEWS Normal file
View File

@ -0,0 +1,488 @@
This is the file NEWS for the flex package. It records user -visible
changes between releases of flex.
See the file COPYING for copying conditions.
* version 2.5.35 released 2008-02-26
** fixed bug that prevented flex from accepting certain comments in the
scanner file (resolves bugs #1849809 and #1849805)
** fix bug that prevented headers for all functions from being generated
(resolves bug #1628314)
** change yy_size_t to be size_t (resolves bug #1849812)
** new de, nl, pl, pt_br, vi translations from the translation project
* version 2.5.34 released 2007-12-12
** introduce yylex_init_extra; see the manual for details
** introduce %option extra-type="your_type *" (resolves bug #1744505)
** The flex program now parses multiple short concatenated options (resolves bug
#1619820). Thanks to Petr Machata of Red Hat on this issue.
** better checking after yyalloc/yyrealloc (resolves bug #1595967)
** flex now provides for a libfl_pic.a compiled with position
independent code. Particularly useful when including a flex scanner
in a shared library and with more recent versions of gcc. Thanks to the Debian project for the idea.
** SourceForge feature request #1658379: Expose YY_BUF_SIZE in the
header file.
** flex better escapes filenames with special characters in them
(resolves bug #1623600)
** a memory leak was plugged(resolves bug #1601111)
** pattern language expanded; see the manual for details on the below
highlights
*** pattern options added to specify patterns as case-insensitive or
case-sensitive
*** pattern options to specify whether the "." character should match
the newline character
*** pattern options added to allow ignoring of whitespace in patterns
*** POSIX character classes may be negated in patterns
*** patterns may now use set difference, union operators
** the manual now contains an appendix listing various common patterns
which may be useful when writing scanners
** some memory leaks were removed from the C++ scanner (but the C++
scanner is still experimental and may change radically without
notice)
** c++ scanners can now use yywrap
** added new unit test for c++ and yywrap
** portability fixes to some unit tests
** flex man page and flex manual in pdf now distributed in the flex
distribution
** new ca, vi, ga, nl translations from the translation project
** flex no longer comes with an rpm spec file
** flex development now happens with automake 1.9.6
* version 2.5.33 released 2006-2-20
** all flex resources are now to be found from the website at
http://flex.sourceforge.net/
** there was no release 2.5.32 published
** numerous bug and security fixes
** new nl, vi, sv, ro, po, ga, ca, fr, tr translations from the translation project
** upgrade to use gettext 0.12 (this now makes the "pdf" and "ps"
targets in the build system able to be run successfully)
* version 2.5.31 released 2003-4-1
** remove --enable-maintainer-mode configure option; none of the
Makefiles were using it and it can be unduely confusing
* version 2.5.30 released 2003-4-1
** yylineno is per-buffer in reentrant scanners
** added %top directive for placing code at the top of the generated
scanner; see manual for details
** flex now uses m4 to generate scanners; while this means that
scanners are more readable, it means that flex requires m4 to be
installed; see manual for details
* version 2.5.29 released 2003-3-5
** Automatic stack management for multiple input buffers in C and C++ scanners
** moved the flex documentation to a new doc/ subdirectory
** cleanups to the yy namespace
* version 2.5.28 released 2003-2-12
** flex is now hosted at sourceforge
** Fixed trailing slash bug in YY_INPUT macro def
** Flex now warns if always-interactive is specified with fast or full
* version 2.5.27 released 2003-1-21
** flex now works with recent bison versions
** new pt_br translation from the translation project
* version 2.5.26 released 2003-1-14
** Fixed table deserialization bug on big-endian archs. Patch sent from Bryce Nichols <bryce@bnichols.org>
** yyleng has proper declarations now; this caused flex to generate
unusable scanners for some programs
** the flex distribution now includes a spec file suitable for use
with rpm
** some more c++ fixes
** new es translation from the translation project
** slight tweeks to the flex_int*_t types
** flex now warns about pattern ranges that might be ambiguous when
generating a case-insensitive scanner
* version 2.5.25 released 2002-12-2
** flex now uses flex_int*_t types. For C99 systems, they are just the
int*_t types; for non-C99 systems, we just make some typedefs
** new pt_br translation from the translation project
* version 2.5.24 released 2002-11-25
* more portability fixes
** the manual continues to be updated and edited, but it's still got a
ways to go
** it is possible to have multiple c++ scanners in the same program again
** new turkish translation from the translation project
* version 2.5.23 released 2002-10-21
** more portability fixes
** the manual includes a title page and a table-of-contents when printed
** the test suite can be run with "make check" from the top-level
directory
** configure now accepts the --enable-maintainer-mode option
** gettext functionality is now only available externally
** the constant FLEX_BETA is defined if flex is a beta release
** the script create-test was not included in the distribution and it
should have been
* version 2.5.22 released 2002-10-10
** more portability fixes around how we get ahold of the integral
types; there is a constant FLEX_NEED_INTEGRAL_TYPE_DEFINITIONS
which you should define if you don't have the <inttypes.h> header
file (after you complain to your C vendor for not providing a
reasonable C environment)
** more test suite cleanups; in particular, the test suite should run
correctly when build from a different directory
** upgraded automake to 1.7 and consequently autoconf to 2.54; this
means, among other things, that there is some support for
formatting the manual in postscript and pdf in the distributed
Makefile.in (and therefore in the Makefile built by configure)
** the flex.1 manpage is generated by help2man; (this has been true
for quite a while but was not listed here)
** flex now includes three defined constants to indicate which version
of flex generated a scanner (YY_FLEX_{MAJOR,MINOR,SUBMINOR}_VERSION)
** flex tries its best to output only the relevant portions of the
skeleton when generating a scanner, thus avoiding as much
conditional compilation as possible
* version 2.5.21 released 2002-9-17
** one of the tests in the test suite broke the dist target
* version 2.5.20 released 2002-9-16
** A flex scanner has the ability to save the DFA tables to a file,
and load them at runtime when needed; see the manual for details
** Added %option bison-bridge (--bison-bridge)
** Removed %option reentrant-bison/--reentrant-bison/-Rb
** yylineno is present in all scanners; Modified nasty performance
penalty warning with yylineno in documentation
** test-table-opts is now run last in the test suite because it's so fat
** flex can, to some extent, diagnose where internal problems occur
** new translations from the translation project: fr, ca, de, ru, sv
**Flex generates C99 defs now; see YY_TRADITIONAL_FUNC_DEFS in the
manual if that's not a good thing for you
* version 2.5.19 released 2002-9-5
** prevent segfault on input lines which are longer than the allocated
space (problem report from Manoj Srivastava
<srivasta@golden-gryphon.com>)
** Changed option 'header' to 'header-file'
* version 2.5.18 released 2002-9-4
** portability fixes for integer constants and in the way the test
suite reports its results
** the test for bison was reporting bison missing when it was, in
fact, found
** if we don't find GNU indent, we're more careful when we're not
finding it
* version 2.5.17 released 2002-8-29
** more portability fixes
** updated config.sub and config.guess
** flex is indented by GNU indent (this was done earlier but not
explicitly documented)
* version 2.5.16 released 2002-8-28
** c++ scanners compile again
** there is now an indent target in the top-level Makefile; configure
checks for GNU indent which is required for proper operation of the
indent target
** some more portability fixes were made
** %options and invocation sections of manual merged
** a c++ test was added to the test suite
** we're trying to clean up more files in the test suite's make clean
targets
* version 2.5.15 released 2002-8-21
** reject-state buffer is now dynamically allocated and REJECT buffer
variables are reentrant-safe
** manual now discusses memory usage
** skeleton now processed by m4 before mkskel.sh; (this only matters
if you want to change the skeleton or if you're doing flex development)
** zh_cn translation added from translation project
** a bug that caused a segfault has now been fixed
** the test suite now respects the usual CFLAGS, etc. variables
** removed some warnings which some tests trigggered with the -s option
** the flex-generated header file now tries to be smarter about
conditionally including start conditions
** tables code omitted from generated scanner when not used
* version 2.5.14 released 2002-8-15
** the tests using the reentrant c scanner as c++ were reworked
slightly to be sure that the c++ was enforced
** de translation now included in the distribution
** various portability fixes regarding nls support, c++ include
headers, etc.
* version 2.5.13 released 2002-8-15
** the header file output with %option header is now much smaller
** Fixed type mismatch in printf in scanner skeleton
** yylex_init now reports errors
* version 2.5.12 released 2002-8-8
** updated gettext support to 0.11.5
** new fr translation from the translation project
** bison is no longer needed to build flex; If you are building flex
from a release (i.e., not from a cvs snapshot), then you don't need
to have a pre-built lex around either (unless you modify scan.l, of
course); (This has been true for some time, but was not mentioned
here.)
* version 2.5.11 released 2002-7-31
** Fixed bug where yyless did not consider yylineno
** the yylineno performance hit is now gone
** fixed some typos in the manual and we now include texinfo.tex in
the distribution
** traditional prototypes output for C scanners, controlled by a
preprocessor symbol; see documentation for details
* version 2.5.10 released 2002-7-24
** yy_globals renamed to yyscanner and yy_globals_t renamed to
yy_guts_t
** added dist-bzip2 option to Makefile.am so we now produce a bzip2'd
archive in addition to the standard gzip archive
* version 2.5.9
** new tests in test suite: test-mem-{nr,r}, test-posix,
test-posixly-correct, test-debug-{nr,r}
** made changes to work with gcc-3.2 development code
** ability to choose which memory functions are used in flex
** new yylex_destroy() function for the non-reentrant scanner
** new handling of POSIXLY_CORRECT environment variable
** the test suite now has its copyrights explicitly described
** new ca, de, fr, ru, sv, tr translations
* version 2.5.8
** a new --posix option generates scanners with posix-style abc{1,3}
compatible parsing, see manual for the screwy details
* version 2.5.7
** configure.in now includes a call to AC_PREREQ to enforce the
requirement for autoconf at least 2.50 (This only effects you if
you're doing flex development.)
** configure now uses autoconf's versioning information and configure
--help reports the bug-reporting address for flex
** test suite now only reports success versus failure; reporting
skipped is problematic under the current setup
** compilation with --disable-nls now works
** flex can now be built in a separate directory
* version 2.5.6
** gettext support added (from gettext 0.11)
*** translations for ca, da, de, es, fr, ko, ru, sv, tr included
** distribution now built under automake 1.6 and autoconf 2.53
** command-line option parsing happens differently now:
*** Added long option parsing
*** Options -n and -c, previously deprecated, now simply do nothing
*** Options are now parsed left to right
** added a number of new options
*** All positive %options are now accessible from the command line
*** Added option -D, to define a preprocessor symbol
*** Added option --header=FILE to specify a C .h file to generate
*** added option --yywrap to call yywrap on EOF
*** added option --yylineno to track line count in yylineno
*** --yyclass=NAME name of C++ class when generating c++ scanners
*** for long option names which are associated with existing short
options, see accompanying documentation
*** new %option nounistd or command-line --nounistd added to prevent
flex from generating #include <unistd.h> on systems that don't
have that include file
** Support for reentrant C scanners has been added
*** Updated the manual with the new reentrant API
*** Two new options %option reentrant (-R) and
%option reentrant-bison (-Rb)
*** All globals optionally placed into struct yyglobals_t
*** All access to globals replaced by macro invocations
*** All functions optionally take one additional
argument, yy_globals
*** New style for invoking reentrant scanner:
yylex_init(void** scanner );
yylex( scanner );
yylex_destroy( scanner );
*** Added get/set functions for members of struct yy_globals_t
e.g., yyget_text, yyget_leng, etc
*** Prefix substitution added for new functions
*** Macro shortcuts to the lengthy get/set functions
provided for use in actions, e.g., yytext, yyleng, etc
*** Arbitrary, user-defined data, "yyextra", may be added to scanner
** %option nomain no longer implies %option yywrap
But the inverse is still true
** Developer test suite added
*** TESTS/ directory has been added. Users can
'make test' in the TESTS directory to execute the test suite
** Support for bison variables yylval and yylloc added
** automake support for the build process
** manual is now in texinfo/info format
*** flex.1 removed from distribution
** flex no longer generates C-language scanners with C++-style
comments
** flex now generates scanners in c++ which are compatible with
recent c++ compilers
** flex input scanner now recognizes '\r' as an EOL character
See the file ONEWS for changes in earlier releases.
Local Variables:
mode: text
mode: outline-minor
end:

View File

@ -936,7 +936,7 @@ Changes between 2.3 Patch #2 (02Aug90) and original 2.3 release:
Changes between 2.3 (full) release of 28Jun90 and 2.2 (alpha) release:
User-visible:
User-visible:
- A lone <<EOF>> rule (that is, one which is not qualified with
a list of start conditions) now specifies the EOF action for
@ -974,7 +974,7 @@ Changes between 2.3 (full) release of 28Jun90 and 2.2 (alpha) release:
be the most common source of headaches.
Things which didn't used to be documented but now are:
Things which didn't used to be documented but now are:
- flex interprets "^foo|bar" differently from lex. flex interprets
it as "match either a 'foo' or a 'bar', providing it comes at the
@ -998,7 +998,7 @@ Changes between 2.3 (full) release of 28Jun90 and 2.2 (alpha) release:
with a suggestion on how to convert scanners which rely on it.
Other changes:
Other changes:
- Prototypes and proper declarations of void routines have
been added to the flex source code, courtesy of Kevin B. Kenny.
@ -1050,7 +1050,7 @@ Changes between 2.2 Patch #1 (23Mar90) and 2.2 (alpha) release:
Changes between 2.2 (alpha) release of March '90 and previous release:
User-visible:
User-visible:
- Full user documentation now available.
@ -1105,7 +1105,7 @@ Changes between 2.2 (alpha) release of March '90 and previous release:
may go away soon.
Other changes:
Other changes:
- Makefile enhanced for easier testing and installation.
- The parser has been tweaked to detect some erroneous
@ -1136,7 +1136,7 @@ Changes between 2.2 (alpha) release of March '90 and previous release:
Changes between 2.1 beta-test release of June '89 and previous release:
User-visible:
User-visible:
- -p flag generates a performance report to stderr. The report
consists of comments regarding features of the scanner rules
@ -1216,7 +1216,7 @@ Changes between 2.1 beta-test release of June '89 and previous release:
Other changes:
Other changes:
- Some portability-related bugs fixed, in particular for machines
with unsigned characters or sizeof( int* ) != sizeof( int ).

79
README Normal file
View File

@ -0,0 +1,79 @@
This is flex, the fast lexical analyzer generator.
flex is a tool for generating scanners: programs which recognize
lexical patterns in text.
More information about flex as well as the latest official release of
flex can be found at:
http://flex.sourceforge.net/
Bug reports should be submitted using the SourceForge Bug Tracker
facilities which can be found from flex's SourceForge project page at:
http://sourceforge.net/projects/flex
There are several mailing lists available as well:
flex-announce@lists.sourceforge.net - where posts will be made
announcing new releases of flex.
flex-help@lists.sourceforge.net - where you can post questions about
using flex
flex-devel@lists.sourceforge.net - where you can discuss development of
flex itself
Note that flex is distributed under a copyright very similar to that of
BSD Unix, and not under the GNU General Public License (GPL).
This file is part of flex.
This code is derived from software contributed to Berkeley by
Vern Paxson.
The United States Government has rights in this work pursuant
to contract no. DE-AC03-76SF00098 between the United States
Department of Energy and the University of California.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
The flex distribution contains the following files which may be of interest:
README - This file.
NEWS - current version number and list of user-visible changes.
INSTALL - basic installation information.
ABOUT-NLS - description of internationalization support in flex.
COPYING - flex's copyright and license.
doc/ - user documentation.
examples/ - containing examples of some possible flex scanners and a
few other things. See the file examples/README for more details.
TODO - outstanding bug reports, desired features, etc.
tests/ - regression tests. See TESTS/README for details.
po/ - internationalization support files.

2
README-alpha Normal file
View File

@ -0,0 +1,2 @@
Beta versions and cvs snapshots of flex can be had at
ftp://ftp.uncg.edu/people/wlestes/.

46
README.cvs Normal file
View File

@ -0,0 +1,46 @@
This file gives information regarding the cvs tree of flex. The cvs
tree of flex contains the files which are under version control by
the flex maintainers for the flex project.
You can learn about the details of retrieving a copy of the cvs flex
tree from flex's SourceForge project page at:
http://sourceforge.net/projects/flex
If you are not interested in flex development or you are not in need
of the latest bleeding-edge features, then the cvs flex tree is
not for you.
When you get a distribution of flex, a large number of intermediate
files needed to make building flex easy are included. You don't have
that in the cvs tree.
You will need various external tools in order to build the distribution. Here is
a (hopefully complete and correct) list of the required tools. Always get the latest
version of each tool; we list the versions used in development of
flex, but the listed versions may not work for you.
compiler suite; e.g., gcc
bash or some other fairly robust sh-style shell
GNU bison; to generate parse.c from parse.y
GNU m4 1.4; required by GNU autoconf (yes, it *must* be GNU m4)
GNU autoconf 2.59 and GNU automake 1.9.6; for generating Makefiles etc.
GNU gettext 0.14.5; for i18n
flex (latest beta release); for bootstrap of scan.l
help2man 1.36; to generate the flex man page
tar, gzip, etc.; for packaging of the source distribution
GNU texinfo 4.8; to build and test the flex manual
perl; GNU automake and GNU autoconf now depend on perl to run
GNU indent 2.8; for indenting the flex source the way we want it done
Once you have all the necessary tools installed, life becomes
simple. To prepare the flex tree for building, run the script:
$ ./autogen.sh
in the top level of the flex source tree.
This script calls the various tools needed to get flex ready for the
GNU-style configure script to be able to work.
From this point on, building flex follows the usual configure, make,
make install routine.

53
THANKS Normal file
View File

@ -0,0 +1,53 @@
Vern had the following things to say:
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.
Thanks to the many flex beta-testers, feedbackers, and contributors,
especially Francois Pinard, Casey Leedom, Robert Abramovitz, Stan
Adermann, Terry Allen, David Barker-Plummer, John Basrai, Neal Becker,
Nelson H.F. Beebe, benson@odi.com, Karl Berry, Peter A. Bigot, Simon
Blanchard, Keith Bostic, Frederic Brehm, Ian Brockbank, Kin Cho, Nick
Christopher, Brian Clapper, J.T. Conklin, Jason Coughlin, Bill Cox,
Nick Cropper, Dave Curtis, Scott David Daniels, Chris G. Demetriou,
Theo Deraadt, Mike Donahue, Chuck Doucette, Tom Epperly, Leo Eskin,
Chris Faylor, Chris Flatters, Jon Forrest, Jeffrey Friedl, Joe Gayda,
Kaveh R. Ghazi, Wolfgang Glunz, Eric Goldman, Christopher M. Gould,
Ulrich Grepel, Peer Griebel, Jan Hajic, Charles Hemphill, NORO Hideo,
Jarkko Hietaniemi, Scott Hofmann, Jeff Honig, Dana Hudes, Eric Hughes,
John Interrante, Ceriel Jacobs, Michal Jaegermann, Sakari Jalovaara,
Jeffrey R. Jones, Henry Juengst, Klaus Kaempf, Jonathan I. Kamens,
Terrence O Kane, Amir Katz, ken@ken.hilco.com, Kevin B. Kenny, Steve
Kirsch, Winfried Koenig, Marq Kole, Ronald Lamprecht, Greg Lee, Rohan
Lenard, Craig Leres, John Levine, Steve Liddle, David Loffredo, Mike
Long, Mohamed el Lozy, Brian Madsen, Malte, Joe Marshall, Bengt
Martensson, Chris Metcalf, Luke Mewburn, Jim Meyering, R. Alexander
Milowski, Erik Naggum, G.T. Nicol, Landon Noll, James Nordby, Marc
Nozell, Richard Ohnemus, Karsten Pahnke, Sven Panne, Roland Pesch,
Walter Pelissero, Gaumond Pierre, Esmond Pitt, Jef Poskanzer, Joe
Rahmeh, Jarmo Raiha, Frederic Raimbault, Pat Rankin, Rick Richardson,
Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, Alberto Santini, Andreas
Scherer, Darrell Schiebel, Raf Schietekat, Doug Schmidt, Philippe
Schnoebelen, Andreas Schwab, Larry Schwimmer, Alex Siegel, Eckehard
Stolz, Jan-Erik Strvmquist, Mike Stump, Paul Stuart, Dave Tallman, Ian
Lance Taylor, Chris Thewalt, Richard M. Timoney, Jodi Tsai, Paul
Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams,
Ken Yap, Ron Zellar, Nathan Zelle, David Zuhn, and those whose names
have slipped my marginal mail-archiving skills but whose contributions
are appreciated all the same.
Thanks to Keith Bostic, Jon Forrest, Noah Friedman,
John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T.
Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various
distribution headaches.
Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to
Benson Margulies and Fred Burke for C++ support; to Kent Williams and Tom
Epperly for C++ class support; to Ove Ewerlid for support of NUL's; and to
Eric Hughes for support of multiple buffers.
This work was primarily done when I was with the Real Time Systems Group
at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks to all there
for the support I received.

101
TODO Normal file
View File

@ -0,0 +1,101 @@
* sourceforge migration
** Move CVS to sourceforge (estes) %%
** test the mailing lists (estes) %%
** inform GNU folks about changeover (estes) %%
* resolve the items in the to.do directory
** expand the above into individual requests and handle those requests
** transfer to.do/Wishlist contents to top level TODO file
* the manual:
** do an end-to-end proofread of the manual (this is under way, but is
going slowly)
** pretty up the dvi output; overflows, etc.
** faq
*** clean up the faqs section. The information is good; the texinfo
could use some touching up.
*** index the faq entries
*** mention that it's possible to use a variable to scan matching
brackets, nested comments etc.
*** include something about lexing/parsing fortran
** create a section on flex design, features, etc.
* address lex-replacement: document or provide an option through
configure for creating lex and libl.a files (but remember this has
posix implications)
* getext
** make sure all flex modules use gettext translation facilities
*subdirectories
** in examples/manual, integrate the Makefile.examples into the
Makefile.am
* test suite
** integrate the test suite into automake's framework (note that the
test suite can be run from the top level directory with "make
check". Still, we want to get it completely under automake's control.)
** make test suite more complete
* generic coding
** move as much skeleton code as possible out of gen.c and into
flex.skl
** figure out whether we want to add the capability to have
auto-generated backout rules
** token-type and token buffer support
** check if we still need to #undef macros at the end of a header
** merge yylineno into support for location tracking
** bug where yylineno is not decremented on REJECT
** bug where yylineno is counted in trailing context
* C++
** have a separate skeleton for c++
** c++ is getting so broken and different from C, that we need to
reevaluate the usefuleness of c++ in flex
** revisit the C++ API. We get requests to make it more complete.
* distribution
** use bootstrapper
** remove texinfo.tex from the cvs tree; it only needs to be present
on the system where the flex release is put together
** use clcommit to manage ChangeLog
Legend:
*, **, ***: outline depth
%% at end of item: must be adressed before next major release
Local Variables:
Mode: text
mode: outline-minor
End:

32
autogen.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
# This file is part of flex.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# If you see no configure script, then run ./autogen.sh to create it
# and procede with the "normal" build procedures.
#if we pretend to have a ChangeLog, then automake is less
#worried. (Don't worry, we *do* have a ChangeLog, we just need the
#Makefile first.)
touch ChangeLog
autoreconf --install --verbose

258
buf.c Normal file
View File

@ -0,0 +1,258 @@
/* flex - tool to generate fast lexical analyzers */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
/* Take note: The buffer object is sometimes used as a String buffer (one
* continuous string), and sometimes used as a list of strings, usually line by
* line.
*
* The type is specified in buf_init by the elt_size. If the elt_size is
* sizeof(char), then the buffer should be treated as string buffer. If the
* elt_size is sizeof(char*), then the buffer should be treated as a list of
* strings.
*
* Certain functions are only appropriate for one type or the other.
*/
/* global buffers. */
struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */
struct Buf defs_buf; /**< for #define's autogenerated. List of strings. */
struct Buf yydmap_buf; /**< string buffer to hold yydmap elements */
struct Buf m4defs_buf; /**< m4 definitions. List of strings. */
struct Buf top_buf; /**< contains %top code. String buffer. */
struct Buf *buf_print_strings(struct Buf * buf, FILE* out)
{
int i;
if(!buf || !out)
return buf;
for (i=0; i < buf->nelts; i++){
const char * s = ((char**)buf->elts)[i];
if(s)
fprintf(out, "%s", s);
}
return buf;
}
/* Append a "%s" formatted string to a string buffer */
struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
{
char *t;
size_t tsz;
t = flex_alloc (tsz = strlen (fmt) + strlen (s) + 1);
snprintf (t, tsz, fmt, s);
buf = buf_strappend (buf, t);
flex_free (t);
return buf;
}
/** Append a line directive to the string buffer.
* @param buf A string buffer.
* @param filename file name
* @param lineno line number
* @return buf
*/
struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
{
char *t, *fmt = "#line %d \"%s\"\n";
size_t tsz;
t = flex_alloc (tsz = strlen (fmt) + strlen (filename) + (int)(1 + log10(lineno>=0?lineno:-lineno)) + 1);
snprintf (t, tsz, fmt, lineno, filename);
buf = buf_strappend (buf, t);
flex_free (t);
return buf;
}
/** Append the contents of @a src to @a dest.
* @param @a dest the destination buffer
* @param @a dest the source buffer
* @return @a dest
*/
struct Buf *buf_concat(struct Buf* dest, const struct Buf* src)
{
buf_append(dest, src->elts, src->nelts);
return dest;
}
/* Appends n characters in str to buf. */
struct Buf *buf_strnappend (buf, str, n)
struct Buf *buf;
const char *str;
int n;
{
buf_append (buf, str, n + 1);
/* "undo" the '\0' character that buf_append() already copied. */
buf->nelts--;
return buf;
}
/* Appends characters in str to buf. */
struct Buf *buf_strappend (buf, str)
struct Buf *buf;
const char *str;
{
return buf_strnappend (buf, str, strlen (str));
}
/* appends "#define str def\n" */
struct Buf *buf_strdefine (buf, str, def)
struct Buf *buf;
const char *str;
const char *def;
{
buf_strappend (buf, "#define ");
buf_strappend (buf, " ");
buf_strappend (buf, str);
buf_strappend (buf, " ");
buf_strappend (buf, def);
buf_strappend (buf, "\n");
return buf;
}
/** Pushes "m4_define( [[def]], [[val]])m4_dnl" to end of buffer.
* @param buf A buffer as a list of strings.
* @param def The m4 symbol to define.
* @param val The definition; may be NULL.
* @return buf
*/
struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
{
const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
char * str;
size_t strsz;
val = val?val:"";
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + strlen(val) + 2);
snprintf(str, strsz, fmt, def, val);
buf_append(buf, &str, 1);
return buf;
}
/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer.
* @param buf A buffer as a list of strings.
* @param def The m4 symbol to undefine.
* @return buf
*/
struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
{
const char * fmt = "m4_undefine( [[%s]])m4_dnl\n";
char * str;
size_t strsz;
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + 2);
snprintf(str, strsz, fmt, def);
buf_append(buf, &str, 1);
return buf;
}
/* create buf with 0 elements, each of size elem_size. */
void buf_init (buf, elem_size)
struct Buf *buf;
size_t elem_size;
{
buf->elts = (void *) 0;
buf->nelts = 0;
buf->elt_size = elem_size;
buf->nmax = 0;
}
/* frees memory */
void buf_destroy (buf)
struct Buf *buf;
{
if (buf && buf->elts)
flex_free (buf->elts);
buf->elts = (void *) 0;
}
/* appends ptr[] to buf, grow if necessary.
* n_elem is number of elements in ptr[], NOT bytes.
* returns buf.
* We grow by mod(512) boundaries.
*/
struct Buf *buf_append (buf, ptr, n_elem)
struct Buf *buf;
const void *ptr;
int n_elem;
{
int n_alloc = 0;
if (!ptr || n_elem == 0)
return buf;
/* May need to alloc more. */
if (n_elem + buf->nelts > buf->nmax) {
/* exact amount needed... */
n_alloc = (n_elem + buf->nelts) * buf->elt_size;
/* ...plus some extra */
if (((n_alloc * buf->elt_size) % 512) != 0
&& buf->elt_size < 512)
n_alloc +=
(512 -
((n_alloc * buf->elt_size) % 512)) /
buf->elt_size;
if (!buf->elts)
buf->elts =
allocate_array (n_alloc, buf->elt_size);
else
buf->elts =
reallocate_array (buf->elts, n_alloc,
buf->elt_size);
buf->nmax = n_alloc;
}
memcpy ((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
n_elem * buf->elt_size);
buf->nelts += n_elem;
return buf;
}
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */

310
ccl.c Normal file
View File

@ -0,0 +1,310 @@
/* ccl - routines for character classes */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
/* return true if the chr is in the ccl. Takes negation into account. */
static bool
ccl_contains (const int cclp, const int ch)
{
int ind, len, i;
len = ccllen[cclp];
ind = cclmap[cclp];
for (i = 0; i < len; ++i)
if (ccltbl[ind + i] == ch)
return !cclng[cclp];
return cclng[cclp];
}
/* ccladd - add a single character to a ccl */
void ccladd (cclp, ch)
int cclp;
int ch;
{
int ind, len, newpos, i;
check_char (ch);
len = ccllen[cclp];
ind = cclmap[cclp];
/* check to see if the character is already in the ccl */
for (i = 0; i < len; ++i)
if (ccltbl[ind + i] == ch)
return;
/* mark newlines */
if (ch == nlch)
ccl_has_nl[cclp] = true;
newpos = ind + len;
if (newpos >= current_max_ccl_tbl_size) {
current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT;
++num_reallocs;
ccltbl = reallocate_Character_array (ccltbl,
current_max_ccl_tbl_size);
}
ccllen[cclp] = len + 1;
ccltbl[newpos] = ch;
}
/* dump_cclp - same thing as list_character_set, but for cclps. */
static void dump_cclp (FILE* file, int cclp)
{
register int i;
putc ('[', file);
for (i = 0; i < csize; ++i) {
if (ccl_contains(cclp, i)){
register int start_char = i;
putc (' ', file);
fputs (readable_form (i), file);
while (++i < csize && ccl_contains(cclp,i)) ;
if (i - 1 > start_char)
/* this was a run */
fprintf (file, "-%s",
readable_form (i - 1));
putc (' ', file);
}
}
putc (']', file);
}
/* ccl_set_diff - create a new ccl as the set difference of the two given ccls. */
int
ccl_set_diff (int a, int b)
{
int d, ch;
/* create new class */
d = cclinit();
/* In order to handle negation, we spin through all possible chars,
* addding each char in a that is not in b.
* (This could be O(n^2), but n is small and bounded.)
*/
for ( ch = 0; ch < csize; ++ch )
if (ccl_contains (a, ch) && !ccl_contains(b, ch))
ccladd (d, ch);
/* debug */
if (0){
fprintf(stderr, "ccl_set_diff (");
fprintf(stderr, "\n ");
dump_cclp (stderr, a);
fprintf(stderr, "\n ");
dump_cclp (stderr, b);
fprintf(stderr, "\n ");
dump_cclp (stderr, d);
fprintf(stderr, "\n)\n");
}
return d;
}
/* ccl_set_union - create a new ccl as the set union of the two given ccls. */
int
ccl_set_union (int a, int b)
{
int d, i;
/* create new class */
d = cclinit();
/* Add all of a */
for (i = 0; i < ccllen[a]; ++i)
ccladd (d, ccltbl[cclmap[a] + i]);
/* Add all of b */
for (i = 0; i < ccllen[b]; ++i)
ccladd (d, ccltbl[cclmap[b] + i]);
/* debug */
if (0){
fprintf(stderr, "ccl_set_union (%d + %d = %d", a, b, d);
fprintf(stderr, "\n ");
dump_cclp (stderr, a);
fprintf(stderr, "\n ");
dump_cclp (stderr, b);
fprintf(stderr, "\n ");
dump_cclp (stderr, d);
fprintf(stderr, "\n)\n");
}
return d;
}
/* cclinit - return an empty ccl */
int cclinit ()
{
if (++lastccl >= current_maxccls) {
current_maxccls += MAX_CCLS_INCREMENT;
++num_reallocs;
cclmap =
reallocate_integer_array (cclmap, current_maxccls);
ccllen =
reallocate_integer_array (ccllen, current_maxccls);
cclng = reallocate_integer_array (cclng, current_maxccls);
ccl_has_nl =
reallocate_bool_array (ccl_has_nl,
current_maxccls);
}
if (lastccl == 1)
/* we're making the first ccl */
cclmap[lastccl] = 0;
else
/* The new pointer is just past the end of the last ccl.
* Since the cclmap points to the \first/ character of a
* ccl, adding the length of the ccl to the cclmap pointer
* will produce a cursor to the first free space.
*/
cclmap[lastccl] =
cclmap[lastccl - 1] + ccllen[lastccl - 1];
ccllen[lastccl] = 0;
cclng[lastccl] = 0; /* ccl's start out life un-negated */
ccl_has_nl[lastccl] = false;
return lastccl;
}
/* cclnegate - negate the given ccl */
void cclnegate (cclp)
int cclp;
{
cclng[cclp] = 1;
ccl_has_nl[cclp] = !ccl_has_nl[cclp];
}
/* list_character_set - list the members of a set of characters in CCL form
*
* Writes to the given file a character-class representation of those
* characters present in the given CCL. A character is present if it
* has a non-zero value in the cset array.
*/
void list_character_set (file, cset)
FILE *file;
int cset[];
{
register int i;
putc ('[', file);
for (i = 0; i < csize; ++i) {
if (cset[i]) {
register int start_char = i;
putc (' ', file);
fputs (readable_form (i), file);
while (++i < csize && cset[i]) ;
if (i - 1 > start_char)
/* this was a run */
fprintf (file, "-%s",
readable_form (i - 1));
putc (' ', file);
}
}
putc (']', file);
}
/** Determines if the range [c1-c2] is unambiguous in a case-insensitive
* scanner. Specifically, if a lowercase or uppercase character, x, is in the
* range [c1-c2], then we require that UPPERCASE(x) and LOWERCASE(x) must also
* be in the range. If not, then this range is ambiguous, and the function
* returns false. For example, [@-_] spans [a-z] but not [A-Z]. Beware that
* [a-z] will be labeled ambiguous because it does not include [A-Z].
*
* @param c1 the lower end of the range
* @param c2 the upper end of the range
* @return true if [c1-c2] is not ambiguous for a caseless scanner.
*/
bool range_covers_case (int c1, int c2)
{
int i, o;
for (i = c1; i <= c2; i++) {
if (has_case (i)) {
o = reverse_case (i);
if (o < c1 || c2 < o)
return false;
}
}
return true;
}
/** Reverse the case of a character, if possible.
* @return c if case-reversal does not apply.
*/
int reverse_case (int c)
{
return isupper (c) ? tolower (c) : (islower (c) ? toupper (c) : c);
}
/** Return true if c is uppercase or lowercase. */
bool has_case (int c)
{
return (isupper (c) || islower (c)) ? true : false;
}

142
compile Executable file
View File

@ -0,0 +1,142 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
scriptversion=2005-05-14.22
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
esac
ofile=
cfile=
eat=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

197
conf.in Normal file
View File

@ -0,0 +1,197 @@
/* conf.in. Generated from configure.in by autoheader. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `isascii' function. */
#undef HAVE_ISASCII
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* pthread library */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the `pow' function. */
#undef HAVE_POW
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#undef HAVE_REALLOC
/* Define to 1 if you have the `regcomp' function. */
#undef HAVE_REGCOMP
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if stdbool.h conforms to C99. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK
/* Define to 1 if you have the <vfork.h> header file. */
#undef HAVE_VFORK_H
/* Define to 1 if `fork' works. */
#undef HAVE_WORKING_FORK
/* Define to 1 if `vfork' works. */
#undef HAVE_WORKING_VFORK
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
/* Define to the GNU M4 executable name. */
#undef M4
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to rpl_realloc if the replacement function should be used. */
#undef realloc
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Define as `fork' if `vfork' does not work. */
#undef vfork

1466
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

548
config.rpath Executable file
View File

@ -0,0 +1,548 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2003 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except M$VC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
mingw* | pw32* | os2*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux*)
case $CC in
icc|ecc)
wl='-Wl,'
;;
ccc)
wl='-Wl,'
;;
esac
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
sco3.2v5*)
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
wl='-Wl,'
;;
sysv4*MP*)
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we can use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris* | sysv5*)
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = yes; then
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
hardcode_direct=yes
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
bsdi4*)
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
hardcode_direct=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10* | hpux11*)
if test "$with_gnu_ld" = no; then
case "$host_cpu" in
hppa*64*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=no
;;
ia64*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=no
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
sco3.2v5*)
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4.2uw2*)
hardcode_direct=yes
hardcode_minus_L=no
;;
sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
;;
sysv5*)
hardcode_libdir_flag_spec=
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
libname_spec='lib$name'
case "$host_os" in
aix3*)
;;
aix4* | aix5*)
;;
amigaos*)
;;
beos*)
;;
bsdi4*)
;;
cygwin* | mingw* | pw32*)
shrext=.dll
;;
darwin* | rhapsody*)
shrext=.dylib
;;
dgux*)
;;
freebsd1*)
;;
freebsd*)
;;
gnu*)
;;
hpux9* | hpux10* | hpux11*)
case "$host_cpu" in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
;;
irix5* | irix6* | nonstopux*)
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux*)
;;
netbsd*)
;;
newsos6)
;;
nto-qnx)
;;
openbsd*)
;;
os2*)
libname_spec='$name'
shrext=.dll
;;
osf3* | osf4* | osf5*)
;;
sco3.2v5*)
;;
solaris*)
;;
sunos4*)
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
;;
sysv4*MP*)
;;
uts4*)
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF

1579
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

11131
configure vendored Executable file

File diff suppressed because it is too large Load Diff

173
configure.in Normal file
View File

@ -0,0 +1,173 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# This file is part of flex.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# autoconf requirements and initialization
AC_PREREQ(2.59)
AC_INIT([the fast lexical analyser generator], [2.5.35],
[flex-help@lists.sourceforge.net], [flex])
AC_CONFIG_SRCDIR([scan.l])
AM_INIT_AUTOMAKE([gnits dist-bzip2])
AC_CONFIG_HEADER([config.h:conf.in])
# checks for programs
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.12)
AC_PROG_YACC
AM_PROG_LEX
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LN_S
AC_PROG_RANLIB
AC_PROG_AWK
AC_PROG_INSTALL
AC_PATH_PROG(BISON, bison,bison)
AC_PATH_PROG(HELP2MAN, help2man, help2man)
# Check for a GNU m4 that supports --prefix-builtins
AC_PATH_PROGS(M4, gm4 gnum4 m4, m4)
if test x"$M4" != x; then
AC_MSG_CHECKING([for GNU m4])
case `$M4 --help < /dev/null 2>&1` in
*prefix-builtins*) AC_MSG_RESULT(yes) ;;
*) AC_MSG_RESULT(no) ;
AC_MSG_ERROR([GNU M4 1.4 is required]) ;;
esac
else
AC_MSG_ERROR([GNU M4 1.4 is required]) ;
fi
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
AC_PATH_PROG(INDENT, indent, indent)
# if INDENT is set to 'indent' then we didn't find indent
if test "$INDENT" != indent ; then
AC_MSG_CHECKING(if $INDENT is GNU indent)
if $INDENT --version 2>/dev/null | head -n 1|grep "GNU indent" > /dev/null ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_WARN($INDENT does not appear to be GNU indent.)
fi
else
AC_MSG_WARN(no indent program found: make indent target will not function)
fi
# checks for libraries
AC_FUNC_ALLOCA
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h stddef.h stdlib.h string.h strings.h unistd.h])
AC_CHECK_LIB(m, log10)
# The test test-pthread uses libpthread, so we check for it here, but
# all we need is the preprocessor symbol defined since we don't need
# LIBS to include libpthread for building flex.
AC_CHECK_LIB(pthread, pthread_mutex_lock,
AC_DEFINE([HAVE_LIBPTHREAD], 1, [pthread library] ),
AC_DEFINE([HAVE_LIBPTHREAD], 0, [pthread library] )
)
AC_CHECK_HEADERS([pthread.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([dup2 isascii memset pow regcomp setlocale strchr strtol])
AC_CONFIG_FILES(
Makefile
doc/Makefile
examples/Makefile
examples/fastwc/Makefile
examples/manual/Makefile
m4/Makefile
po/Makefile.in
tools/Makefile
tests/Makefile
tests/TEMPLATE/Makefile
tests/test-array-nr/Makefile
tests/test-array-r/Makefile
tests/test-basic-nr/Makefile
tests/test-basic-r/Makefile
tests/test-bison-yylloc/Makefile
tests/test-bison-yylval/Makefile
tests/test-c-cpp-nr/Makefile
tests/test-c-cpp-r/Makefile
tests/test-header-nr/Makefile
tests/test-header-r/Makefile
tests/test-include-by-buffer/Makefile
tests/test-include-by-push/Makefile
tests/test-include-by-reentrant/Makefile
tests/test-multiple-scanners-nr/Makefile
tests/test-multiple-scanners-r/Makefile
tests/test-noansi-nr/Makefile
tests/test-noansi-r/Makefile
tests/test-prefix-nr/Makefile
tests/test-prefix-r/Makefile
tests/test-pthread/Makefile
tests/test-string-nr/Makefile
tests/test-string-r/Makefile
tests/test-yyextra/Makefile
tests/test-alloc-extra/Makefile
tests/test-lineno-nr/Makefile
tests/test-lineno-r/Makefile
tests/test-linedir-r/Makefile
tests/test-debug-r/Makefile
tests/test-debug-nr/Makefile
tests/test-mem-nr/Makefile
tests/test-mem-r/Makefile
tests/test-posix/Makefile
tests/test-posixly-correct/Makefile
tests/test-table-opts/Makefile
tests/test-c++-basic/Makefile
tests/test-bison-nr/Makefile
tests/test-reject/Makefile
tests/test-c++-multiple-scanners/Makefile
tests/test-top/Makefile
tests/test-rescan-nr/Makefile
tests/test-rescan-r/Makefile
tests/test-quotes/Makefile
tests/test-ccl/Makefile
tests/test-extended/Makefile
tests/test-c++-yywrap/Makefile
tests/test-concatenated-options/Makefile
dnl --new-test-here-- This line is processed by tests/create-test.
)
AC_OUTPUT

530
depcomp Executable file
View File

@ -0,0 +1,530 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2005-07-09.11
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mecanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

File diff suppressed because it is too large Load Diff

16
doc/Makefile.am Normal file
View File

@ -0,0 +1,16 @@
help2man = @HELP2MAN@
info_TEXINFOS = flex.texi
dist_man_MANS = flex.1
EXTRA_DIST = flex.pdf
CLEANFILES = \
flex.hks \
flex.ops
$(dist_man_MANS): $(top_srcdir)/main.c
for i in $(dist_man_MANS) ; do \
$(help2man) --name='$(PACKAGE_NAME)' \
--section=`echo $$i | sed -e 's/.*\.\([^.]*\)$$/\1/'` \
../flex$(EXEEXT) > $$i || rm -f $$i ; \
done

560
doc/Makefile.in Normal file
View File

@ -0,0 +1,560 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = doc
DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/stamp-vti \
$(srcdir)/version.texi mdate-sh texinfo.tex
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
INFO_DEPS = $(srcdir)/flex.info
am__TEXINFO_TEX_DIR = $(srcdir)
DVIS = flex.dvi
PDFS = flex.pdf
PSS = flex.ps
HTMLS = flex.html
TEXINFOS = flex.texi
TEXI2DVI = texi2dvi
TEXI2PDF = $(TEXI2DVI) --pdf --batch
MAKEINFOHTML = $(MAKEINFO) --html
AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
DVIPS = dvips
am__installdirs = "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)"
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(dist_man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BISON = @BISON@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GMSGFMT = @GMSGFMT@
HELP2MAN = @HELP2MAN@
INDENT = @INDENT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
M4 = @M4@
MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
POSUB = @POSUB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
YACC = @YACC@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
help2man = @HELP2MAN@
info_TEXINFOS = flex.texi
dist_man_MANS = flex.1
EXTRA_DIST = flex.pdf
CLEANFILES = \
flex.hks \
flex.ops
all: all-am
.SUFFIXES:
.SUFFIXES: .dvi .html .info .pdf .ps .texi
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits doc/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnits doc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
.texi.info:
restore=: && backupdir="$(am__leading_dot)am$$$$" && \
am__cwd=`pwd` && cd $(srcdir) && \
rm -rf $$backupdir && mkdir $$backupdir && \
if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
done; \
else :; fi && \
cd "$$am__cwd"; \
if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $@ $<; \
then \
rc=0; \
cd $(srcdir); \
else \
rc=$$?; \
cd $(srcdir) && \
$$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
fi; \
rm -rf $$backupdir; exit $$rc
.texi.dvi:
TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
$(TEXI2DVI) $<
.texi.pdf:
TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
$(TEXI2PDF) $<
.texi.html:
rm -rf $(@:.html=.htp)
if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $(@:.html=.htp) $<; \
then \
rm -rf $@; \
if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \
else \
if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \
exit 1; \
fi
$(srcdir)/flex.info: flex.texi $(srcdir)/version.texi
flex.dvi: flex.texi $(srcdir)/version.texi
flex.pdf: flex.texi $(srcdir)/version.texi
flex.html: flex.texi $(srcdir)/version.texi
$(srcdir)/version.texi: $(srcdir)/stamp-vti
$(srcdir)/stamp-vti: flex.texi $(top_srcdir)/configure
@(dir=.; test -f ./flex.texi || dir=$(srcdir); \
set `$(SHELL) $(srcdir)/mdate-sh $$dir/flex.texi`; \
echo "@set UPDATED $$1 $$2 $$3"; \
echo "@set UPDATED-MONTH $$2 $$3"; \
echo "@set EDITION $(VERSION)"; \
echo "@set VERSION $(VERSION)") > vti.tmp
@cmp -s vti.tmp $(srcdir)/version.texi \
|| (echo "Updating $(srcdir)/version.texi"; \
cp vti.tmp $(srcdir)/version.texi)
-@rm -f vti.tmp
@cp $(srcdir)/version.texi $@
mostlyclean-vti:
-rm -f vti.tmp
maintainer-clean-vti:
-rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi
.dvi.ps:
TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
$(DVIPS) -o $@ $<
uninstall-info-am:
@$(PRE_UNINSTALL)
@if (install-info --version && \
install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
done; \
else :; fi
@$(NORMAL_UNINSTALL)
@list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
(if cd "$(DESTDIR)$(infodir)"; then \
echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \
rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
else :; fi); \
done
dist-info: $(INFO_DEPS)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
list='$(INFO_DEPS)'; \
for base in $$list; do \
case $$base in \
$(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
esac; \
if test -f $$base; then d=.; else d=$(srcdir); fi; \
for file in $$d/$$base*; do \
relfile=`expr "$$file" : "$$d/\(.*\)"`; \
test -f $(distdir)/$$relfile || \
cp -p $$file $(distdir)/$$relfile; \
done; \
done
mostlyclean-aminfo:
-rm -rf flex.aux flex.cp flex.cps flex.fn flex.fns flex.hk flex.hks flex.ky \
flex.kys flex.log flex.op flex.ops flex.pg flex.pgs flex.tmp \
flex.toc flex.tp flex.tps flex.vr flex.vrs flex.dvi flex.pdf \
flex.ps flex.html
maintainer-clean-aminfo:
@list='$(INFO_DEPS)'; for i in $$list; do \
i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
done
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-info
check-am: all-am
check: check-am
all-am: Makefile $(INFO_DEPS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am: $(DVIS)
html: html-am
html-am: $(HTMLS)
info: info-am
info-am: $(INFO_DEPS)
install-data-am: install-info-am install-man
install-exec-am:
install-info: install-info-am
install-info-am: $(INFO_DEPS)
@$(NORMAL_INSTALL)
test -z "$(infodir)" || $(mkdir_p) "$(DESTDIR)$(infodir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
list='$(INFO_DEPS)'; \
for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
esac; \
if test -f $$file; then d=.; else d=$(srcdir); fi; \
file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
$$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
if test -f $$ifile; then \
relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \
$(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \
else : ; fi; \
done; \
done
@$(POST_INSTALL)
@if (install-info --version && \
install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\
done; \
else : ; fi
install-man: install-man1
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-aminfo \
maintainer-clean-generic maintainer-clean-vti
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti
pdf: pdf-am
pdf-am: $(PDFS)
ps: ps-am
ps-am: $(PSS)
uninstall-am: uninstall-info-am uninstall-man
uninstall-man: uninstall-man1
.PHONY: all all-am check check-am clean clean-generic dist-info \
distclean distclean-generic distdir dvi dvi-am html html-am \
info info-am install install-am install-data install-data-am \
install-exec install-exec-am install-info install-info-am \
install-man install-man1 install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-aminfo maintainer-clean-generic \
maintainer-clean-vti mostlyclean mostlyclean-aminfo \
mostlyclean-generic mostlyclean-vti pdf pdf-am ps ps-am \
uninstall uninstall-am uninstall-info-am uninstall-man \
uninstall-man1
$(dist_man_MANS): $(top_srcdir)/main.c
for i in $(dist_man_MANS) ; do \
$(help2man) --name='$(PACKAGE_NAME)' \
--section=`echo $$i | sed -e 's/.*\.\([^.]*\)$$/\1/'` \
../flex$(EXEEXT) > $$i || rm -f $$i ; \
done
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

165
doc/flex.1 Normal file
View File

@ -0,0 +1,165 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH FLEX "1" "February 2008" "flex 2.5.35" "User Commands"
.SH NAME
flex \- the fast lexical analyser generator
.SH SYNOPSIS
.B flex
[\fIOPTIONS\fR] [\fIFILE\fR]...
.SH DESCRIPTION
Generates programs that perform pattern\-matching on text.
.SS "Table Compression:"
.TP
\fB\-Ca\fR, \fB\-\-align\fR
trade off larger tables for better memory alignment
.TP
\fB\-Ce\fR, \fB\-\-ecs\fR
construct equivalence classes
.TP
\fB\-Cf\fR
do not compress tables; use \fB\-f\fR representation
.TP
\fB\-CF\fR
do not compress tables; use \fB\-F\fR representation
.TP
\fB\-Cm\fR, \fB\-\-meta\-ecs\fR
construct meta\-equivalence classes
.TP
\fB\-Cr\fR, \fB\-\-read\fR
use read() instead of stdio for scanner input
.TP
\fB\-f\fR, \fB\-\-full\fR
generate fast, large scanner. Same as \fB\-Cfr\fR
.TP
\fB\-F\fR, \fB\-\-fast\fR
use alternate table representation. Same as \fB\-CFr\fR
.TP
\fB\-Cem\fR
default compression (same as \fB\-\-ecs\fR \fB\-\-meta\-ecs\fR)
.SS "Debugging:"
.TP
\fB\-d\fR, \fB\-\-debug\fR
enable debug mode in scanner
.TP
\fB\-b\fR, \fB\-\-backup\fR
write backing\-up information to lex.backup
.TP
\fB\-p\fR, \fB\-\-perf\-report\fR
write performance report to stderr
.TP
\fB\-s\fR, \fB\-\-nodefault\fR
suppress default rule to ECHO unmatched text
.TP
\fB\-T\fR, \fB\-\-trace\fR
flex should run in trace mode
.TP
\fB\-w\fR, \fB\-\-nowarn\fR
do not generate warnings
.TP
\fB\-v\fR, \fB\-\-verbose\fR
write summary of scanner statistics to stdout
.SS "Files:"
.TP
\fB\-o\fR, \fB\-\-outfile\fR=\fIFILE\fR
specify output filename
.TP
\fB\-S\fR, \fB\-\-skel\fR=\fIFILE\fR
specify skeleton file
.TP
\fB\-t\fR, \fB\-\-stdout\fR
write scanner on stdout instead of lex.yy.c
.TP
\fB\-\-yyclass\fR=\fINAME\fR
name of C++ class
.TP
\fB\-\-header\-file\fR=\fIFILE\fR
create a C header file in addition to the scanner
.HP
\fB\-\-tables\-file\fR[=\fIFILE\fR] write tables to FILE
.SS "Scanner behavior:"
.TP
\fB\-7\fR, \fB\-\-7bit\fR
generate 7\-bit scanner
.TP
\fB\-8\fR, \fB\-\-8bit\fR
generate 8\-bit scanner
.TP
\fB\-B\fR, \fB\-\-batch\fR
generate batch scanner (opposite of \fB\-I\fR)
.TP
\fB\-i\fR, \fB\-\-case\-insensitive\fR
ignore case in patterns
.TP
\fB\-l\fR, \fB\-\-lex\-compat\fR
maximal compatibility with original lex
.TP
\fB\-X\fR, \fB\-\-posix\-compat\fR
maximal compatibility with POSIX lex
.TP
\fB\-I\fR, \fB\-\-interactive\fR
generate interactive scanner (opposite of \fB\-B\fR)
.TP
\fB\-\-yylineno\fR
track line count in yylineno
.SS "Generated code:"
.TP
\-+, \fB\-\-c\fR++
generate C++ scanner class
.TP
\fB\-Dmacro\fR[=\fIdefn\fR]
#define macro defn (default defn is '1')
.TP
\fB\-L\fR, \fB\-\-noline\fR
suppress #line directives in scanner
.TP
\fB\-P\fR, \fB\-\-prefix\fR=\fISTRING\fR
use STRING as prefix instead of "yy"
.TP
\fB\-R\fR, \fB\-\-reentrant\fR
generate a reentrant C scanner
.TP
\fB\-\-bison\-bridge\fR
scanner for bison pure parser.
.TP
\fB\-\-bison\-locations\fR
include yylloc support.
.TP
\fB\-\-stdinit\fR
initialize yyin/yyout to stdin/stdout
.HP
\fB\-\-noansi\-definitions\fR old\-style function definitions
.TP
\fB\-\-noansi\-prototypes\fR
empty parameter list in prototypes
.TP
\fB\-\-nounistd\fR
do not include <unistd.h>
.TP
\fB\-\-noFUNCTION\fR
do not generate a particular FUNCTION
.SS "Miscellaneous:"
.TP
\fB\-c\fR
do\-nothing POSIX option
.TP
\fB\-n\fR
do\-nothing POSIX option
.HP
\-?
.TP
\fB\-h\fR, \fB\-\-help\fR
produce this help message
.TP
\fB\-V\fR, \fB\-\-version\fR
report flex version
.SH "SEE ALSO"
The full documentation for
.B flex
is maintained as a Texinfo manual. If the
.B info
and
.B flex
programs are properly installed at your site, the command
.IP
.B info flex
.PP
should give you access to the complete manual.

282
doc/flex.info Normal file
View File

@ -0,0 +1,282 @@
This is flex.info, produced by makeinfo version 4.8 from flex.texi.
INFO-DIR-SECTION Programming
START-INFO-DIR-ENTRY
* flex: (flex). Fast lexical analyzer generator (lex replacement).
END-INFO-DIR-ENTRY
The flex manual is placed under the same licensing conditions as the
rest of flex:
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Flex
Project.
Copyright (C) 1990, 1997 The Regents of the University of California.
All rights reserved.
This code is derived from software contributed to Berkeley by Vern
Paxson.
The United States Government has rights in this work pursuant to
contract no. DE-AC03-76SF00098 between the United States Department of
Energy and the University of California.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.
Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Indirect:
flex.info-1: 1620
flex.info-2: 287921

Tag Table:
(Indirect)
Node: Top1620
Node: Copyright7690
Node: Reporting Bugs9203
Node: Introduction9508
Node: Simple Examples10336
Node: Format13646
Node: Definitions Section14060
Ref: Definitions Section-Footnote-116323
Node: Rules Section16391
Node: User Code Section17549
Node: Comments in the Input17987
Node: Patterns19355
Ref: case and character ranges26186
Node: Matching30201
Node: Actions33487
Node: Generated Scanner42466
Node: Start Conditions47484
Node: Multiple Input Buffers58043
Ref: Scanning Strings64581
Node: EOF66211
Node: Misc Macros67799
Node: User Values70653
Node: Yacc72984
Node: Scanner Options73880
Node: Options for Specifying Filenames76638
Ref: option-header76864
Ref: option-outfile77576
Ref: option-stdout77901
Node: Options Affecting Scanner Behavior78883
Ref: option-case-insensitive79124
Ref: option-lex-compat79557
Ref: option-batch80089
Ref: option-interactive80613
Ref: option-7bit81967
Ref: option-8bit83271
Ref: option-default83683
Ref: option-always-interactive83747
Ref: option-posix84351
Ref: option-stack85498
Ref: option-stdinit85606
Ref: option-yylineno86084
Ref: option-yywrap86527
Node: Code-Level And API Options86795
Ref: option-ansi-definitions87022
Ref: option-ansi-prototypes87274
Ref: option-bison-bridge87521
Ref: option-bison-locations87860
Ref: option-noline88120
Ref: option-reentrant88634
Ref: option-c++89245
Ref: option-array89371
Ref: option-pointer89469
Ref: option-prefix89597
Ref: option-main91126
Ref: option-nounistd91310
Ref: option-yyclass91818
Node: Options for Scanner Speed and Size92304
Ref: option-align92853
Ref: option-ecs93354
Ref: option-meta-ecs94390
Ref: option-read94877
Ref: option-full96760
Ref: option-fast96955
Node: Debugging Options97881
Ref: option-backup98068
Ref: option-debug98613
Ref: option-perf-report99336
Ref: option-nodefault99962
Ref: option-trace100280
Ref: option-nowarn100571
Ref: option-verbose100639
Ref: option-warn101068
Node: Miscellaneous Options101287
Node: Performance101744
Node: Cxx112008
Node: Reentrant119531
Node: Reentrant Uses120208
Node: Reentrant Overview121771
Node: Reentrant Example122570
Node: Reentrant Detail123345
Node: Specify Reentrant123778
Node: Extra Reentrant Argument124425
Node: Global Replacement125677
Node: Init and Destroy Functions126906
Node: Accessor Methods129418
Node: Extra Data130762
Node: About yyscan_t133029
Node: Reentrant Functions133425
Ref: bison-functions134909
Node: Lex and Posix135650
Node: Memory Management143034
Ref: memory-management143180
Node: The Default Memory Management143408
Ref: The Default Memory Management-Footnote-1147217
Node: Overriding The Default Memory Management147370
Ref: Overriding The Default Memory Management-Footnote-1149769
Node: A Note About yytext And Memory149933
Node: Serialized Tables151166
Ref: serialization151310
Node: Creating Serialized Tables152075
Node: Loading and Unloading Serialized Tables153685
Node: Tables File Format155453
Node: Diagnostics162468
Node: Limitations165879
Node: Bibliography167828
Node: FAQ168501
Node: When was flex born?172741
Node: How do I expand backslash-escape sequences in C-style quoted strings?173118
Node: Why do flex scanners call fileno if it is not ANSI compatible?174422
Node: Does flex support recursive pattern definitions?175217
Node: How do I skip huge chunks of input (tens of megabytes) while using flex?176064
Node: Flex is not matching my patterns in the same order that I defined them.176531
Node: My actions are executing out of order or sometimes not at all.178277
Node: How can I have multiple input sources feed into the same scanner at the same time?179052
Node: Can I build nested parsers that work with the same input file?181040
Node: How can I match text only at the end of a file?182046
Node: How can I make REJECT cascade across start condition boundaries?182851
Node: Why cant I use fast or full tables with interactive mode?183866
Node: How much faster is -F or -f than -C?185124
Node: If I have a simple grammar cant I just parse it with flex?185436
Node: Why doesn't yyrestart() set the start state back to INITIAL?185917
Node: How can I match C-style comments?186544
Node: The period isn't working the way I expected.187358
Node: Can I get the flex manual in another format?188605
Node: Does there exist a "faster" NDFA->DFA algorithm?189094
Node: How does flex compile the DFA so quickly?189604
Node: How can I use more than 8192 rules?190571
Node: How do I abandon a file in the middle of a scan and switch to a new file?191983
Node: How do I execute code only during initialization (only before the first scan)?192536
Node: How do I execute code at termination?193314
Node: Where else can I find help?193640
Node: Can I include comments in the "rules" section of the file?194013
Node: I get an error about undefined yywrap().194392
Node: How can I change the matching pattern at run time?194869
Node: How can I expand macros in the input?195231
Node: How can I build a two-pass scanner?196264
Node: How do I match any string not matched in the preceding rules?197180
Node: I am trying to port code from AT&T lex that uses yysptr and yysbuf.198090
Node: Is there a way to make flex treat NULL like a regular character?198885
Node: Whenever flex can not match the input it says "flex scanner jammed".199406
Node: Why doesn't flex have non-greedy operators like perl does?200050
Node: Memory leak - 16386 bytes allocated by malloc.201403
Ref: faq-memory-leak201701
Node: How do I track the byte offset for lseek()?202669
Node: How do I use my own I/O classes in a C++ scanner?204180
Node: How do I skip as many chars as possible?205023
Node: deleteme00206100
Node: Are certain equivalent patterns faster than others?206541
Node: Is backing up a big deal?209960
Node: Can I fake multi-byte character support?211867
Node: deleteme01213309
Node: Can you discuss some flex internals?214419
Node: unput() messes up yy_at_bol216664
Node: The | operator is not doing what I want217767
Node: Why can't flex understand this variable trailing context pattern?219314
Node: The ^ operator isn't working220564
Node: Trailing context is getting confused with trailing optional patterns221800
Node: Is flex GNU or not?223044
Node: ERASEME53224718
Node: I need to scan if-then-else blocks and while loops225489
Node: ERASEME55226689
Node: ERASEME56227788
Node: ERASEME57229147
Node: Is there a repository for flex scanners?230146
Node: How can I conditionally compile or preprocess my flex input file?230461
Node: Where can I find grammars for lex and yacc?230934
Node: I get an end-of-buffer message for each character scanned.231281
Node: unnamed-faq-62231876
Node: unnamed-faq-63232895
Node: unnamed-faq-64234193
Node: unnamed-faq-65235160
Node: unnamed-faq-66235947
Node: unnamed-faq-67237063
Node: unnamed-faq-68238051
Node: unnamed-faq-69239194
Node: unnamed-faq-70239908
Node: unnamed-faq-71240670
Node: unnamed-faq-72241880
Node: unnamed-faq-73242924
Node: unnamed-faq-74243849
Node: unnamed-faq-75244795
Node: unnamed-faq-76245928
Node: unnamed-faq-77246635
Node: unnamed-faq-78247529
Node: unnamed-faq-79248528
Node: unnamed-faq-80250229
Node: unnamed-faq-81251548
Node: unnamed-faq-82254349
Node: unnamed-faq-83255307
Node: unnamed-faq-84257088
Node: unnamed-faq-85258192
Node: unnamed-faq-86259200
Node: unnamed-faq-87260139
Node: unnamed-faq-88260786
Node: unnamed-faq-90261618
Node: unnamed-faq-91262882
Node: unnamed-faq-92265311
Node: unnamed-faq-93265811
Node: unnamed-faq-94266739
Node: unnamed-faq-95268152
Node: unnamed-faq-96269671
Node: unnamed-faq-97270431
Node: unnamed-faq-98271099
Node: unnamed-faq-99271765
Node: unnamed-faq-100272695
Node: unnamed-faq-101273406
Node: What is the difference between YYLEX_PARAM and YY_DECL?274220
Node: Why do I get "conflicting types for yylex" error?274742
Node: How do I access the values set in a Flex action from within a Bison action?275272
Node: Appendices275703
Node: Makefiles and Flex275912
Ref: Makefiles and Flex-Footnote-1279112
Ref: Makefiles and Flex-Footnote-2279229
Ref: Makefiles and Flex-Footnote-3279415
Node: Bison Bridge279466
Ref: Bison Bridge-Footnote-1282135
Node: M4 Dependency282327
Ref: M4 Dependency-Footnote-1283732
Node: Common Patterns283867
Node: Numbers284158
Node: Identifiers285135
Node: Quoted Constructs285964
Node: Addresses287017
Node: Indices287683
Node: Concept Index287921
Node: Index of Functions and Macros313204
Node: Index of Variables318100
Node: Index of Data Types319766
Node: Index of Hooks320654
Node: Index of Scanner Options321222

End Tag Table

7683
doc/flex.info-1 Normal file

File diff suppressed because it is too large Load Diff

BIN
doc/flex.info-2 Normal file

Binary file not shown.

201
doc/mdate-sh Executable file
View File

@ -0,0 +1,201 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.
scriptversion=2005-06-29.22
# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software
# Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No file. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: mdate-sh [--help] [--version] FILE
Pretty-print the modification time of FILE.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "mdate-sh $scriptversion"
exit $?
;;
esac
# Prevent date giving response in another language.
LANG=C
export LANG
LC_ALL=C
export LC_ALL
LC_TIME=C
export LC_TIME
# GNU ls changes its time format in response to the TIME_STYLE
# variable. Since we cannot assume `unset' works, revert this
# variable to its documented default.
if test "${TIME_STYLE+set}" = set; then
TIME_STYLE=posix-long-iso
export TIME_STYLE
fi
save_arg1=$1
# Find out how to get the extended ls output of a file or directory.
if ls -L /dev/null 1>/dev/null 2>&1; then
ls_command='ls -L -l -d'
else
ls_command='ls -l -d'
fi
# A `ls -l' line looks as follows on OS/2.
# drwxrwx--- 0 Aug 11 2001 foo
# This differs from Unix, which adds ownership information.
# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
#
# To find the date, we split the line on spaces and iterate on words
# until we find a month. This cannot work with files whose owner is a
# user named `Jan', or `Feb', etc. However, it's unlikely that `/'
# will be owned by a user whose name is a month. So we first look at
# the extended ls output of the root directory to decide how many
# words should be skipped to get the date.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
set x`ls -l -d /`
# Find which argument is the month.
month=
command=
until test $month
do
shift
# Add another shift to the command.
command="$command shift;"
case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
done
# Get the extended ls output of the file or directory.
set dummy x`eval "$ls_command \"\$save_arg1\""`
# Remove all preceding arguments
eval $command
# Because of the dummy argument above, month is in $2.
#
# On a POSIX system, we should have
#
# $# = 5
# $1 = file size
# $2 = month
# $3 = day
# $4 = year or time
# $5 = filename
#
# On Darwin 7.7.0 and 7.6.0, we have
#
# $# = 4
# $1 = day
# $2 = month
# $3 = year or time
# $4 = filename
# Get the month.
case $2 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
case $3 in
???*) day=$1;;
*) day=$3; shift;;
esac
# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
case $3 in
*:*) set `date`; eval year=\$$#
case $2 in
Jan) nummonthtod=1;;
Feb) nummonthtod=2;;
Mar) nummonthtod=3;;
Apr) nummonthtod=4;;
May) nummonthtod=5;;
Jun) nummonthtod=6;;
Jul) nummonthtod=7;;
Aug) nummonthtod=8;;
Sep) nummonthtod=9;;
Oct) nummonthtod=10;;
Nov) nummonthtod=11;;
Dec) nummonthtod=12;;
esac
# For the first six month of the year the time notation can also
# be used for files modified in the last year.
if (expr $nummonth \> $nummonthtod) > /dev/null;
then
year=`expr $year - 1`
fi;;
*) year=$3;;
esac
# The result.
echo $day $month $year
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

4
doc/stamp-vti Normal file
View File

@ -0,0 +1,4 @@
@set UPDATED 10 September 2007
@set UPDATED-MONTH September 2007
@set EDITION 2.5.35
@set VERSION 2.5.35

View File

@ -1,43 +1,46 @@
/* ecs - equivalence class routines */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
/* $Header: /home/daffy/u0/vern/flex/RCS/ecs.c,v 2.9 93/12/07 10:18:20 vern Exp $ */
#include "flexdef.h"
/* ccl2ecl - convert character classes to set of equivalence classes */
void ccl2ecl()
{
int i, ich, newlen, cclp, ccls, cclmec;
void ccl2ecl ()
{
int i, ich, newlen, cclp, ccls, cclmec;
for ( i = 1; i <= lastccl; ++i )
{
for (i = 1; i <= lastccl; ++i) {
/* We loop through each character class, and for each character
* in the class, add the character's equivalence class to the
* new "character" class we are creating. Thus when we are all
@ -48,21 +51,19 @@ void ccl2ecl()
newlen = 0;
cclp = cclmap[i];
for ( ccls = 0; ccls < ccllen[i]; ++ccls )
{
for (ccls = 0; ccls < ccllen[i]; ++ccls) {
ich = ccltbl[cclp + ccls];
cclmec = ecgroup[ich];
if ( cclmec > 0 )
{
if (cclmec > 0) {
ccltbl[cclp + newlen] = cclmec;
++newlen;
}
}
}
ccllen[i] = newlen;
}
}
}
/* cre8ecs - associate equivalence class numbers with class members
@ -73,10 +74,10 @@ void ccl2ecl()
* Returned is the number of classes.
*/
int cre8ecs( fwd, bck, num )
int fwd[], bck[], num;
{
int i, j, numcl;
int cre8ecs (fwd, bck, num)
int fwd[], bck[], num;
{
int i, j, numcl;
numcl = 0;
@ -85,16 +86,15 @@ int fwd[], bck[], num;
* is positive, then x is the representative of its equivalence
* class.
*/
for ( i = 1; i <= num; ++i )
if ( bck[i] == NIL )
{
for (i = 1; i <= num; ++i)
if (bck[i] == NIL) {
bck[i] = ++numcl;
for ( j = fwd[i]; j != NIL; j = fwd[j] )
for (j = fwd[i]; j != NIL; j = fwd[j])
bck[j] = -numcl;
}
}
return numcl;
}
}
/* mkeccl - update equivalence classes based on character class xtions
@ -112,12 +112,12 @@ int fwd[], bck[], num;
* NUL_mapping is the value which NUL (0) should be mapped to.
*/
void mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping )
Char ccls[];
int lenccl, fwd[], bck[], llsiz, NUL_mapping;
{
int cclp, oldec, newec;
int cclm, i, j;
void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping)
Char ccls[];
int lenccl, fwd[], bck[], llsiz, NUL_mapping;
{
int cclp, oldec, newec;
int cclm, i, j;
static unsigned char cclflags[CSIZE]; /* initialized to all '\0' */
/* Note that it doesn't matter whether or not the character class is
@ -126,11 +126,10 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
cclp = 0;
while ( cclp < lenccl )
{
while (cclp < lenccl) {
cclm = ccls[cclp];
if ( NUL_mapping && cclm == 0 )
if (NUL_mapping && cclm == 0)
cclm = NUL_mapping;
oldec = bck[cclm];
@ -138,22 +137,19 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
j = cclp + 1;
for ( i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i] )
{ /* look for the symbol in the character class */
for ( ; j < lenccl; ++j )
{
for (i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i]) { /* look for the symbol in the character class */
for (; j < lenccl; ++j) {
register int ccl_char;
if ( NUL_mapping && ccls[j] == 0 )
if (NUL_mapping && ccls[j] == 0)
ccl_char = NUL_mapping;
else
ccl_char = ccls[j];
if ( ccl_char > i )
if (ccl_char > i)
break;
if ( ccl_char == i && ! cclflags[j] )
{
if (ccl_char == i && !cclflags[j]) {
/* We found an old companion of cclm
* in the ccl. Link it into the new
* equivalence class and flag it as
@ -169,8 +165,8 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
/* Get next equivalence class member. */
/* continue 2 */
goto next_pt;
}
}
}
/* Symbol isn't in character class. Put it in the old
* equivalence class.
@ -178,48 +174,46 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
bck[i] = oldec;
if ( oldec != NIL )
if (oldec != NIL)
fwd[oldec] = i;
oldec = i;
next_pt: ;
}
next_pt:;
}
if ( bck[cclm] != NIL || oldec != bck[cclm] )
{
if (bck[cclm] != NIL || oldec != bck[cclm]) {
bck[cclm] = NIL;
fwd[oldec] = NIL;
}
}
fwd[newec] = NIL;
/* Find next ccl member to process. */
for ( ++cclp; cclflags[cclp] && cclp < lenccl; ++cclp )
{
for (++cclp; cclflags[cclp] && cclp < lenccl; ++cclp) {
/* Reset "doesn't need processing" flag. */
cclflags[cclp] = 0;
}
}
}
}
/* mkechar - create equivalence class for single character */
void mkechar( tch, fwd, bck )
int tch, fwd[], bck[];
{
void mkechar (tch, fwd, bck)
int tch, fwd[], bck[];
{
/* If until now the character has been a proper subset of
* an equivalence class, break it away to create a new ec
*/
if ( fwd[tch] != NIL )
if (fwd[tch] != NIL)
bck[fwd[tch]] = bck[tch];
if ( bck[tch] != NIL )
if (bck[tch] != NIL)
fwd[bck[tch]] = fwd[tch];
fwd[tch] = NIL;
bck[tch] = NIL;
}
}

427
filter.c Normal file
View File

@ -0,0 +1,427 @@
/* filter - postprocessing of flex output through filters */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
static const char * check_4_gnu_m4 =
"m4_dnl ifdef(`__gnu__', ,"
"`errprint(Flex requires GNU M4. Set the PATH or set the M4 environment variable to its path name.)"
" m4exit(2)')\n";
/** global chain. */
struct filter *output_chain = NULL;
/* Allocate and initialize an external filter.
* @param chain the current chain or NULL for new chain
* @param cmd the command to execute.
* @param ... a NULL terminated list of (const char*) arguments to command,
* not including argv[0].
* @return newest filter in chain
*/
struct filter *filter_create_ext (struct filter *chain, const char *cmd,
...)
{
struct filter *f;
int max_args;
const char *s;
va_list ap;
/* allocate and initialize new filter */
f = (struct filter *) flex_alloc (sizeof (struct filter));
memset (f, 0, sizeof (*f));
f->filter_func = NULL;
f->extra = NULL;
f->next = NULL;
f->argc = 0;
if (chain != NULL) {
/* append f to end of chain */
while (chain->next)
chain = chain->next;
chain->next = f;
}
/* allocate argv, and populate it with the argument list. */
max_args = 8;
f->argv =
(const char **) flex_alloc (sizeof (char *) *
(max_args + 1));
f->argv[f->argc++] = cmd;
va_start (ap, cmd);
while ((s = va_arg (ap, const char *)) != NULL) {
if (f->argc >= max_args) {
max_args += 8;
f->argv =
(const char **) flex_realloc (f->argv,
sizeof (char
*) *
(max_args +
1));
}
f->argv[f->argc++] = s;
}
f->argv[f->argc] = NULL;
va_end (ap);
return f;
}
/* Allocate and initialize an internal filter.
* @param chain the current chain or NULL for new chain
* @param filter_func The function that will perform the filtering.
* filter_func should return 0 if successful, and -1
* if an error occurs -- or it can simply exit().
* @param extra optional user-defined data to pass to the filter.
* @return newest filter in chain
*/
struct filter *filter_create_int (struct filter *chain,
int (*filter_func) (struct filter *),
void *extra)
{
struct filter *f;
/* allocate and initialize new filter */
f = (struct filter *) flex_alloc (sizeof (struct filter));
memset (f, 0, sizeof (*f));
f->next = NULL;
f->argc = 0;
f->argv = NULL;
f->filter_func = filter_func;
f->extra = extra;
if (chain != NULL) {
/* append f to end of chain */
while (chain->next)
chain = chain->next;
chain->next = f;
}
return f;
}
/** Fork and exec entire filter chain.
* @param chain The head of the chain.
* @return true on success.
*/
bool filter_apply_chain (struct filter * chain)
{
int pid, pipes[2];
/* Tricky recursion, since we want to begin the chain
* at the END. Why? Because we need all the forked processes
* to be children of the main flex process.
*/
if (chain)
filter_apply_chain (chain->next);
else
return true;
/* Now we are the right-most unprocessed link in the chain.
*/
fflush (stdout);
fflush (stderr);
if (pipe (pipes) == -1)
flexerror (_("pipe failed"));
if ((pid = fork ()) == -1)
flexerror (_("fork failed"));
if (pid == 0) {
/* child */
/* We need stdin (the FILE* stdin) to connect to this new pipe.
* There is no portable way to set stdin to a new file descriptor,
* as stdin is not an lvalue on some systems (BSD).
* So we dup the new pipe onto the stdin descriptor and use a no-op fseek
* to sync the stream. This is a Hail Mary situation. It seems to work.
*/
close (pipes[1]);
if (dup2 (pipes[0], fileno (stdin)) == -1)
flexfatal (_("dup2(pipes[0],0)"));
close (pipes[0]);
fseek (stdin, 0, SEEK_CUR);
/* run as a filter, either internally or by exec */
if (chain->filter_func) {
int r;
if ((r = chain->filter_func (chain)) == -1)
flexfatal (_("filter_func failed"));
exit (0);
}
else {
execvp (chain->argv[0],
(char **const) (chain->argv));
flexfatal (_("exec failed"));
}
exit (1);
}
/* Parent */
close (pipes[0]);
if (dup2 (pipes[1], fileno (stdout)) == -1)
flexfatal (_("dup2(pipes[1],1)"));
close (pipes[1]);
fseek (stdout, 0, SEEK_CUR);
return true;
}
/** Truncate the chain to max_len number of filters.
* @param chain the current chain.
* @param max_len the maximum length of the chain.
* @return the resulting length of the chain.
*/
int filter_truncate (struct filter *chain, int max_len)
{
int len = 1;
if (!chain)
return 0;
while (chain->next && len < max_len) {
chain = chain->next;
++len;
}
chain->next = NULL;
return len;
}
/** Splits the chain in order to write to a header file.
* Similar in spirit to the 'tee' program.
* The header file name is in extra.
* @return 0 (zero) on success, and -1 on failure.
*/
int filter_tee_header (struct filter *chain)
{
/* This function reads from stdin and writes to both the C file and the
* header file at the same time.
*/
const int readsz = 512;
char *buf;
int to_cfd = -1;
FILE *to_c = NULL, *to_h = NULL;
bool write_header;
write_header = (chain->extra != NULL);
/* Store a copy of the stdout pipe, which is already piped to C file
* through the running chain. Then create a new pipe to the H file as
* stdout, and fork the rest of the chain again.
*/
if ((to_cfd = dup (1)) == -1)
flexfatal (_("dup(1) failed"));
to_c = fdopen (to_cfd, "w");
if (write_header) {
if (freopen ((char *) chain->extra, "w", stdout) == NULL)
flexfatal (_("freopen(headerfilename) failed"));
filter_apply_chain (chain->next);
to_h = stdout;
}
/* Now to_c is a pipe to the C branch, and to_h is a pipe to the H branch.
*/
if (write_header) {
fputs (check_4_gnu_m4, to_h);
fputs ("m4_changecom`'m4_dnl\n", to_h);
fputs ("m4_changequote`'m4_dnl\n", to_h);
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h);
fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h);
fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n",
to_h);
fprintf (to_h, "#ifndef %sHEADER_H\n", prefix);
fprintf (to_h, "#define %sHEADER_H 1\n", prefix);
fprintf (to_h, "#define %sIN_HEADER 1\n\n", prefix);
fprintf (to_h,
"m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
headerfilename ? headerfilename : "<stdout>");
}
fputs (check_4_gnu_m4, to_c);
fputs ("m4_changecom`'m4_dnl\n", to_c);
fputs ("m4_changequote`'m4_dnl\n", to_c);
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c);
fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_c);
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
outfilename ? outfilename : "<stdout>");
buf = (char *) flex_alloc (readsz);
while (fgets (buf, readsz, stdin)) {
fputs (buf, to_c);
if (write_header)
fputs (buf, to_h);
}
if (write_header) {
fprintf (to_h, "\n");
/* write a fake line number. It will get fixed by the linedir filter. */
fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n");
fprintf (to_h, "#undef %sIN_HEADER\n", prefix);
fprintf (to_h, "#endif /* %sHEADER_H */\n", prefix);
fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h);
fflush (to_h);
if (ferror (to_h))
lerrsf (_("error writing output file %s"),
(char *) chain->extra);
else if (fclose (to_h))
lerrsf (_("error closing output file %s"),
(char *) chain->extra);
}
fflush (to_c);
if (ferror (to_c))
lerrsf (_("error writing output file %s"),
outfilename ? outfilename : "<stdout>");
else if (fclose (to_c))
lerrsf (_("error closing output file %s"),
outfilename ? outfilename : "<stdout>");
while (wait (0) > 0) ;
exit (0);
return 0;
}
/** Adjust the line numbers in the #line directives of the generated scanner.
* After the m4 expansion, the line numbers are incorrect since the m4 macros
* can add or remove lines. This only adjusts line numbers for generated code,
* not user code. This also happens to be a good place to squeeze multiple
* blank lines into a single blank line.
*/
int filter_fix_linedirs (struct filter *chain)
{
char *buf;
const int readsz = 512;
int lineno = 1;
bool in_gen = true; /* in generated code */
bool last_was_blank = false;
if (!chain)
return 0;
buf = (char *) flex_alloc (readsz);
while (fgets (buf, readsz, stdin)) {
regmatch_t m[10];
/* Check for #line directive. */
if (buf[0] == '#'
&& regexec (&regex_linedir, buf, 3, m, 0) == 0) {
int num;
char *fname;
/* extract the line number and filename */
num = regmatch_strtol (&m[1], buf, NULL, 0);
fname = regmatch_dup (&m[2], buf);
if (strcmp (fname,
outfilename ? outfilename : "<stdout>")
== 0
|| strcmp (fname,
headerfilename ? headerfilename : "<stdout>")
== 0) {
char *s1, *s2;
char filename[MAXLINE];
s1 = fname;
s2 = filename;
while ((s2 - filename) < (MAXLINE - 1) && *s1) {
/* Escape the backslash */
if (*s1 == '\\')
*s2++ = '\\';
/* Escape the double quote */
if (*s1 == '\"')
*s2++ = '\\';
/* Copy the character as usual */
*s2++ = *s1++;
}
*s2 = '\0';
/* Adjust the line directives. */
in_gen = true;
snprintf (buf, readsz, "#line %d \"%s\"\n",
lineno + 1, filename);
}
else {
/* it's a #line directive for code we didn't write */
in_gen = false;
}
free (fname);
last_was_blank = false;
}
/* squeeze blank lines from generated code */
else if (in_gen
&& regexec (&regex_blank_line, buf, 0, NULL,
0) == 0) {
if (last_was_blank)
continue;
else
last_was_blank = true;
}
else {
/* it's a line of normal, non-empty code. */
last_was_blank = false;
}
fputs (buf, stdout);
lineno++;
}
fflush (stdout);
if (ferror (stdout))
lerrsf (_("error writing output file %s"),
outfilename ? outfilename : "<stdout>");
else if (fclose (stdout))
lerrsf (_("error closing output file %s"),
outfilename ? outfilename : "<stdout>");
return 0;
}
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */

3430
flex.skl Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

63
flexint.h Normal file
View File

@ -0,0 +1,63 @@
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! FLEXINT_H */

2169
gen.c Normal file

File diff suppressed because it is too large Load Diff

59
gettext.h Normal file
View File

@ -0,0 +1,59 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option. */
#if ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
#else
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
# define gettext(Msgid) ((const char *) (Msgid))
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define textdomain(Domainname) ((const char *) (Domainname))
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
The argument, String, should be a literal string. Concatenated strings
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
#endif /* _LIBGETTEXT_H */

323
install-sh Executable file
View File

@ -0,0 +1,323 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2005-05-14.22
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
shift
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit 1; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

33
libmain.c Normal file
View File

@ -0,0 +1,33 @@
/* libmain - flex run-time support library "main" function */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
extern int yylex ();
int main (argc, argv)
int argc;
char *argv[];
{
while (yylex () != 0) ;
return 0;
}

27
libyywrap.c Normal file
View File

@ -0,0 +1,27 @@
/* libyywrap - flex run-time support library "yywrap" function */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
int yywrap (void)
{
return 1;
}

1
m4/Makefile.am Normal file
View File

@ -0,0 +1 @@
EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes-pri.m4 inttypes.m4 inttypes_h.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 nls.m4 po.m4

316
m4/Makefile.in Normal file
View File

@ -0,0 +1,316 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = m4
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BISON = @BISON@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GMSGFMT = @GMSGFMT@
HELP2MAN = @HELP2MAN@
INDENT = @INDENT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
M4 = @M4@
MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
POSUB = @POSUB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
YACC = @YACC@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes-pri.m4 inttypes.m4 inttypes_h.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 nls.m4 po.m4
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits m4/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnits m4/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1857
main.c Normal file

File diff suppressed because it is too large Load Diff

1095
misc.c Normal file

File diff suppressed because it is too large Load Diff

360
missing Executable file
View File

@ -0,0 +1,360 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2005-06-08.21
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case "$1" in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

111
mkinstalldirs Executable file
View File

@ -0,0 +1,111 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
errstatus=0
dirmode=""
usage="\
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage" 1>&2
exit 0
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
case $dirmode in
'')
if mkdir -p -- . 2>/dev/null; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
fi
;;
*)
if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
fi
;;
esac
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=""
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# End:
# mkinstalldirs ends here

37
mkskel.sh Executable file
View File

@ -0,0 +1,37 @@
#! /bin/sh
# This file is part of flex.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
cat <<!
/* File created from flex.skl via mkskel.sh */
#include "flexdef.h"
const char *skel[] = {
!
sed 's/\\/&&/g' | sed 's/"/\\"/g' | sed 's/.*/ "&",/'
cat <<!
0
};
!

View File

@ -1,40 +1,43 @@
/* nfa - NFA construction routines */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* $Header: /home/daffy/u0/vern/flex/RCS/nfa.c,v 2.17 95/03/04 16:11:42 vern Exp $ */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
/* declare functions that have forward references */
int dupmachine PROTO((int));
void mkxtion PROTO((int, int));
int dupmachine PROTO ((int));
void mkxtion PROTO ((int, int));
/* add_accept - add an accepting state to a machine
@ -42,25 +45,25 @@ void mkxtion PROTO((int, int));
* accepting_number becomes mach's accepting number.
*/
void add_accept( mach, accepting_number )
int mach, accepting_number;
{
void add_accept (mach, accepting_number)
int mach, accepting_number;
{
/* Hang the accepting number off an epsilon state. if it is associated
* with a state that has a non-epsilon out-transition, then the state
* will accept BEFORE it makes that transition, i.e., one character
* too soon.
*/
if ( transchar[finalst[mach]] == SYM_EPSILON )
if (transchar[finalst[mach]] == SYM_EPSILON)
accptnum[finalst[mach]] = accepting_number;
else
{
int astate = mkstate( SYM_EPSILON );
else {
int astate = mkstate (SYM_EPSILON);
accptnum[astate] = accepting_number;
(void) link_machines( mach, astate );
}
(void) link_machines (mach, astate);
}
}
/* copysingl - make a given number of copies of a singleton machine
@ -74,31 +77,32 @@ int mach, accepting_number;
* num - the number of copies of singl to be present in newsng
*/
int copysingl( singl, num )
int singl, num;
{
int copy, i;
int copysingl (singl, num)
int singl, num;
{
int copy, i;
copy = mkstate( SYM_EPSILON );
copy = mkstate (SYM_EPSILON);
for ( i = 1; i <= num; ++i )
copy = link_machines( copy, dupmachine( singl ) );
for (i = 1; i <= num; ++i)
copy = link_machines (copy, dupmachine (singl));
return copy;
}
}
/* dumpnfa - debugging routine to write out an nfa */
void dumpnfa( state1 )
int state1;
void dumpnfa (state1)
int state1;
{
int sym, tsp1, tsp2, anum, ns;
{
int sym, tsp1, tsp2, anum, ns;
fprintf( stderr,
_( "\n\n********** beginning dump of nfa with start state %d\n" ),
state1 );
fprintf (stderr,
_
("\n\n********** beginning dump of nfa with start state %d\n"),
state1);
/* We probably should loop starting at firstst[state1] and going to
* lastst[state1], but they're not maintained properly when we "or"
@ -107,26 +111,25 @@ int state1;
*/
/* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
for ( ns = 1; ns <= lastnfa; ++ns )
{
fprintf( stderr, _( "state # %4d\t" ), ns );
for (ns = 1; ns <= lastnfa; ++ns) {
fprintf (stderr, _("state # %4d\t"), ns);
sym = transchar[ns];
tsp1 = trans1[ns];
tsp2 = trans2[ns];
anum = accptnum[ns];
fprintf( stderr, "%3d: %4d, %4d", sym, tsp1, tsp2 );
fprintf (stderr, "%3d: %4d, %4d", sym, tsp1, tsp2);
if ( anum != NIL )
fprintf( stderr, " [%d]", anum );
if (anum != NIL)
fprintf (stderr, " [%d]", anum);
fprintf( stderr, "\n" );
}
fprintf( stderr, _( "********** end of dump\n" ) );
fprintf (stderr, "\n");
}
fprintf (stderr, _("********** end of dump\n"));
}
/* dupmachine - make a duplicate of a given machine
*
@ -145,32 +148,30 @@ int state1;
* states accessible by the arrays firstst and lastst
*/
int dupmachine( mach )
int mach;
{
int i, init, state_offset;
int state = 0;
int last = lastst[mach];
int dupmachine (mach)
int mach;
{
int i, init, state_offset;
int state = 0;
int last = lastst[mach];
for ( i = firstst[mach]; i <= last; ++i )
{
state = mkstate( transchar[i] );
for (i = firstst[mach]; i <= last; ++i) {
state = mkstate (transchar[i]);
if ( trans1[i] != NO_TRANSITION )
{
mkxtion( finalst[state], trans1[i] + state - i );
if (trans1[i] != NO_TRANSITION) {
mkxtion (finalst[state], trans1[i] + state - i);
if ( transchar[i] == SYM_EPSILON &&
trans2[i] != NO_TRANSITION )
mkxtion( finalst[state],
trans2[i] + state - i );
}
accptnum[state] = accptnum[i];
if (transchar[i] == SYM_EPSILON &&
trans2[i] != NO_TRANSITION)
mkxtion (finalst[state],
trans2[i] + state - i);
}
if ( state == 0 )
flexfatal( _( "empty machine in dupmachine()" ) );
accptnum[state] = accptnum[i];
}
if (state == 0)
flexfatal (_("empty machine in dupmachine()"));
state_offset = state - i + 1;
@ -180,7 +181,7 @@ int mach;
lastst[init] = lastst[mach] + state_offset;
return init;
}
}
/* finish_rule - finish up the processing for a rule
@ -195,12 +196,13 @@ int mach;
* context has variable length.
*/
void finish_rule( mach, variable_trail_rule, headcnt, trailcnt )
int mach, variable_trail_rule, headcnt, trailcnt;
{
char action_text[MAXLINE];
void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
pcont_act)
int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
{
char action_text[MAXLINE];
add_accept( mach, num_rules );
add_accept (mach, num_rules);
/* We did this in new_rule(), but it often gets the wrong
* number because we do it before we start parsing the current rule.
@ -210,68 +212,77 @@ int mach, variable_trail_rule, headcnt, trailcnt;
/* If this is a continued action, then the line-number has already
* been updated, giving us the wrong number.
*/
if ( continued_action )
if (continued_action)
--rule_linenum[num_rules];
sprintf( action_text, "case %d:\n", num_rules );
add_action( action_text );
if ( variable_trail_rule )
{
/* If the previous rule was continued action, then we inherit the
* previous newline flag, possibly overriding the current one.
*/
if (pcont_act && rule_has_nl[num_rules - 1])
rule_has_nl[num_rules] = true;
snprintf (action_text, sizeof(action_text), "case %d:\n", num_rules);
add_action (action_text);
if (rule_has_nl[num_rules]) {
snprintf (action_text, sizeof(action_text), "/* rule %d can match eol */\n",
num_rules);
add_action (action_text);
}
if (variable_trail_rule) {
rule_type[num_rules] = RULE_VARIABLE;
if ( performance_report > 0 )
fprintf( stderr,
_( "Variable trailing context rule at line %d\n" ),
rule_linenum[num_rules] );
if (performance_report > 0)
fprintf (stderr,
_
("Variable trailing context rule at line %d\n"),
rule_linenum[num_rules]);
variable_trailing_context_rules = true;
}
}
else
{
else {
rule_type[num_rules] = RULE_NORMAL;
if ( headcnt > 0 || trailcnt > 0 )
{
if (headcnt > 0 || trailcnt > 0) {
/* Do trailing context magic to not match the trailing
* characters.
*/
char *scanner_cp = "yy_c_buf_p = yy_cp";
char *scanner_bp = "yy_bp";
char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp";
char *scanner_bp = "yy_bp";
add_action(
"*yy_cp = yy_hold_char; /* undo effects of setting up yytext */\n" );
add_action
("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n");
if ( headcnt > 0 )
{
sprintf( action_text, "%s = %s + %d;\n",
scanner_cp, scanner_bp, headcnt );
add_action( action_text );
}
else
{
sprintf( action_text, "%s -= %d;\n",
scanner_cp, trailcnt );
add_action( action_text );
}
add_action(
"YY_DO_BEFORE_ACTION; /* set up yytext again */\n" );
if (headcnt > 0) {
snprintf (action_text, sizeof(action_text), "%s = %s + %d;\n",
scanner_cp, scanner_bp, headcnt);
add_action (action_text);
}
else {
snprintf (action_text, sizeof(action_text), "%s -= %d;\n",
scanner_cp, trailcnt);
add_action (action_text);
}
add_action
("YY_DO_BEFORE_ACTION; /* set up yytext again */\n");
}
}
/* 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_RULE_SETUP's.
*/
if ( ! continued_action )
add_action( "YY_RULE_SETUP\n" );
if (!continued_action)
add_action ("YY_RULE_SETUP\n");
line_directive_out( (FILE *) 0, 1 );
}
line_directive_out ((FILE *) 0, 1);
}
/* link_machines - connect two machines together
@ -290,25 +301,24 @@ int mach, variable_trail_rule, headcnt, trailcnt;
* FIRST is set to new by the operation. last is unmolested.
*/
int link_machines( first, last )
int first, last;
{
if ( first == NIL )
int link_machines (first, last)
int first, last;
{
if (first == NIL)
return last;
else if ( last == NIL )
else if (last == NIL)
return first;
else
{
mkxtion( finalst[first], last );
else {
mkxtion (finalst[first], last);
finalst[first] = finalst[last];
lastst[first] = MAX( lastst[first], lastst[last] );
firstst[first] = MIN( firstst[first], firstst[last] );
lastst[first] = MAX (lastst[first], lastst[last]);
firstst[first] = MIN (firstst[first], firstst[last]);
return first;
}
}
}
/* mark_beginning_as_normal - mark each "beginning" state in a machine
@ -318,36 +328,32 @@ int first, last;
* The "beginning" states are the epsilon closure of the first state
*/
void mark_beginning_as_normal( mach )
register int mach;
{
switch ( state_type[mach] )
{
case STATE_NORMAL:
/* Oh, we've already visited here. */
return;
void mark_beginning_as_normal (mach)
register int mach;
{
switch (state_type[mach]) {
case STATE_NORMAL:
/* Oh, we've already visited here. */
return;
case STATE_TRAILING_CONTEXT:
state_type[mach] = STATE_NORMAL;
case STATE_TRAILING_CONTEXT:
state_type[mach] = STATE_NORMAL;
if ( transchar[mach] == SYM_EPSILON )
{
if ( trans1[mach] != NO_TRANSITION )
mark_beginning_as_normal(
trans1[mach] );
if (transchar[mach] == SYM_EPSILON) {
if (trans1[mach] != NO_TRANSITION)
mark_beginning_as_normal (trans1[mach]);
if ( trans2[mach] != NO_TRANSITION )
mark_beginning_as_normal(
trans2[mach] );
}
break;
default:
flexerror(
_( "bad state type in mark_beginning_as_normal()" ) );
break;
if (trans2[mach] != NO_TRANSITION)
mark_beginning_as_normal (trans2[mach]);
}
break;
default:
flexerror (_
("bad state type in mark_beginning_as_normal()"));
break;
}
}
/* mkbranch - make a machine that branches to two machines
@ -364,24 +370,24 @@ register int mach;
* more mkbranch's. Compare with mkor()
*/
int mkbranch( first, second )
int first, second;
{
int eps;
int mkbranch (first, second)
int first, second;
{
int eps;
if ( first == NO_TRANSITION )
if (first == NO_TRANSITION)
return second;
else if ( second == NO_TRANSITION )
else if (second == NO_TRANSITION)
return first;
eps = mkstate( SYM_EPSILON );
eps = mkstate (SYM_EPSILON);
mkxtion( eps, first );
mkxtion( eps, second );
mkxtion (eps, first);
mkxtion (eps, second);
return eps;
}
}
/* mkclos - convert a machine into a closure
@ -392,11 +398,11 @@ int first, second;
* new - a new state which matches the closure of "state"
*/
int mkclos( state )
int state;
{
return mkopt( mkposcl( state ) );
}
int mkclos (state)
int state;
{
return mkopt (mkposcl (state));
}
/* mkopt - make a machine optional
@ -413,28 +419,27 @@ int state;
* 2. mach is destroyed by the call
*/
int mkopt( mach )
int mach;
{
int eps;
int mkopt (mach)
int mach;
{
int eps;
if ( ! SUPER_FREE_EPSILON(finalst[mach]) )
{
eps = mkstate( SYM_EPSILON );
mach = link_machines( mach, eps );
}
if (!SUPER_FREE_EPSILON (finalst[mach])) {
eps = mkstate (SYM_EPSILON);
mach = link_machines (mach, eps);
}
/* Can't skimp on the following if FREE_EPSILON(mach) is true because
* some state interior to "mach" might point back to the beginning
* for a closure.
*/
eps = mkstate( SYM_EPSILON );
mach = link_machines( eps, mach );
eps = mkstate (SYM_EPSILON);
mach = link_machines (eps, mach);
mkxtion( mach, finalst[mach] );
mkxtion (mach, finalst[mach]);
return mach;
}
}
/* mkor - make a machine that matches either one of two machines
@ -451,56 +456,52 @@ int mach;
* the number of epsilon states needed
*/
int mkor( first, second )
int first, second;
{
int eps, orend;
int mkor (first, second)
int first, second;
{
int eps, orend;
if ( first == NIL )
if (first == NIL)
return second;
else if ( second == NIL )
else if (second == NIL)
return first;
else
{
else {
/* See comment in mkopt() about why we can't use the first
* state of "first" or "second" if they satisfy "FREE_EPSILON".
*/
eps = mkstate( SYM_EPSILON );
eps = mkstate (SYM_EPSILON);
first = link_machines( eps, first );
first = link_machines (eps, first);
mkxtion( first, second );
mkxtion (first, second);
if ( SUPER_FREE_EPSILON(finalst[first]) &&
accptnum[finalst[first]] == NIL )
{
if (SUPER_FREE_EPSILON (finalst[first]) &&
accptnum[finalst[first]] == NIL) {
orend = finalst[first];
mkxtion( finalst[second], orend );
}
else if ( SUPER_FREE_EPSILON(finalst[second]) &&
accptnum[finalst[second]] == NIL )
{
orend = finalst[second];
mkxtion( finalst[first], orend );
}
else
{
eps = mkstate( SYM_EPSILON );
first = link_machines( first, eps );
orend = finalst[first];
mkxtion( finalst[second], orend );
}
mkxtion (finalst[second], orend);
}
else if (SUPER_FREE_EPSILON (finalst[second]) &&
accptnum[finalst[second]] == NIL) {
orend = finalst[second];
mkxtion (finalst[first], orend);
}
else {
eps = mkstate (SYM_EPSILON);
first = link_machines (first, eps);
orend = finalst[first];
mkxtion (finalst[second], orend);
}
}
finalst[first] = orend;
return first;
}
}
/* mkposcl - convert a machine into a positive closure
@ -511,25 +512,23 @@ int first, second;
* new - a machine matching the positive closure of "state"
*/
int mkposcl( state )
int state;
{
int eps;
int mkposcl (state)
int state;
{
int eps;
if ( SUPER_FREE_EPSILON(finalst[state]) )
{
mkxtion( finalst[state], state );
if (SUPER_FREE_EPSILON (finalst[state])) {
mkxtion (finalst[state], state);
return state;
}
else
{
eps = mkstate( SYM_EPSILON );
mkxtion( eps, state );
return link_machines( state, eps );
}
}
else {
eps = mkstate (SYM_EPSILON);
mkxtion (eps, state);
return link_machines (state, eps);
}
}
/* mkrep - make a replicated machine
*
@ -540,38 +539,38 @@ int state;
* number of times to "ub" number of times
*
* note
* if "ub" is INFINITY then "new" matches "lb" or more occurrences of "mach"
* if "ub" is INFINITE_REPEAT then "new" matches "lb" or more occurrences of "mach"
*/
int mkrep( mach, lb, ub )
int mach, lb, ub;
{
int base_mach, tail, copy, i;
int mkrep (mach, lb, ub)
int mach, lb, ub;
{
int base_mach, tail, copy, i;
base_mach = copysingl( mach, lb - 1 );
base_mach = copysingl (mach, lb - 1);
if ( ub == INFINITY )
{
copy = dupmachine( mach );
mach = link_machines( mach,
link_machines( base_mach, mkclos( copy ) ) );
if (ub == INFINITE_REPEAT) {
copy = dupmachine (mach);
mach = link_machines (mach,
link_machines (base_mach,
mkclos (copy)));
}
else {
tail = mkstate (SYM_EPSILON);
for (i = lb; i < ub; ++i) {
copy = dupmachine (mach);
tail = mkopt (link_machines (copy, tail));
}
else
{
tail = mkstate( SYM_EPSILON );
for ( i = lb; i < ub; ++i )
{
copy = dupmachine( mach );
tail = mkopt( link_machines( copy, tail ) );
}
mach = link_machines( mach, link_machines( base_mach, tail ) );
}
mach =
link_machines (mach,
link_machines (base_mach, tail));
}
return mach;
}
}
/* mkstate - create a state with a transition on a given symbol
@ -590,30 +589,31 @@ int mach, lb, ub;
* that it admittedly is)
*/
int mkstate( sym )
int sym;
{
if ( ++lastnfa >= current_mns )
{
if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS )
lerrif(
_( "input rules are too complicated (>= %d NFA states)" ),
current_mns );
int mkstate (sym)
int sym;
{
if (++lastnfa >= current_mns) {
if ((current_mns += MNS_INCREMENT) >= maximum_mns)
lerrif (_
("input rules are too complicated (>= %d NFA states)"),
current_mns);
++num_reallocs;
firstst = reallocate_integer_array( firstst, current_mns );
lastst = reallocate_integer_array( lastst, current_mns );
finalst = reallocate_integer_array( finalst, current_mns );
transchar = reallocate_integer_array( transchar, current_mns );
trans1 = reallocate_integer_array( trans1, current_mns );
trans2 = reallocate_integer_array( trans2, current_mns );
accptnum = reallocate_integer_array( accptnum, current_mns );
firstst = reallocate_integer_array (firstst, current_mns);
lastst = reallocate_integer_array (lastst, current_mns);
finalst = reallocate_integer_array (finalst, current_mns);
transchar =
reallocate_integer_array (transchar, current_mns);
trans1 = reallocate_integer_array (trans1, current_mns);
trans2 = reallocate_integer_array (trans2, current_mns);
accptnum =
reallocate_integer_array (accptnum, current_mns);
assoc_rule =
reallocate_integer_array( assoc_rule, current_mns );
reallocate_integer_array (assoc_rule, current_mns);
state_type =
reallocate_integer_array( state_type, current_mns );
}
reallocate_integer_array (state_type, current_mns);
}
firstst[lastnfa] = lastnfa;
finalst[lastnfa] = lastnfa;
@ -634,28 +634,26 @@ int sym;
* elsewhere in the input).
*/
if ( sym < 0 )
{
if (sym < 0) {
/* We don't have to update the equivalence classes since
* that was already done when the ccl was created for the
* first time.
*/
}
}
else if ( sym == SYM_EPSILON )
else if (sym == SYM_EPSILON)
++numeps;
else
{
check_char( sym );
else {
check_char (sym);
if ( useecs )
if (useecs)
/* Map NUL's to csize. */
mkechar( sym ? sym : csize, nextecm, ecgroup );
}
mkechar (sym ? sym : csize, nextecm, ecgroup);
}
return lastnfa;
}
}
/* mkxtion - make a transition from one state to another
@ -668,42 +666,43 @@ int sym;
* stateto - the state to which the transition is to be made
*/
void mkxtion( statefrom, stateto )
int statefrom, stateto;
{
if ( trans1[statefrom] == NO_TRANSITION )
void mkxtion (statefrom, stateto)
int statefrom, stateto;
{
if (trans1[statefrom] == NO_TRANSITION)
trans1[statefrom] = stateto;
else if ( (transchar[statefrom] != SYM_EPSILON) ||
(trans2[statefrom] != NO_TRANSITION) )
flexfatal( _( "found too many transitions in mkxtion()" ) );
else if ((transchar[statefrom] != SYM_EPSILON) ||
(trans2[statefrom] != NO_TRANSITION))
flexfatal (_("found too many transitions in mkxtion()"));
else
{ /* second out-transition for an epsilon state */
else { /* second out-transition for an epsilon state */
++eps2;
trans2[statefrom] = stateto;
}
}
}
/* new_rule - initialize for a new rule */
void new_rule()
{
if ( ++num_rules >= current_max_rules )
{
void new_rule ()
{
if (++num_rules >= current_max_rules) {
++num_reallocs;
current_max_rules += MAX_RULES_INCREMENT;
rule_type = reallocate_integer_array( rule_type,
current_max_rules );
rule_linenum = reallocate_integer_array( rule_linenum,
current_max_rules );
rule_useful = reallocate_integer_array( rule_useful,
current_max_rules );
}
rule_type = reallocate_integer_array (rule_type,
current_max_rules);
rule_linenum = reallocate_integer_array (rule_linenum,
current_max_rules);
rule_useful = reallocate_integer_array (rule_useful,
current_max_rules);
rule_has_nl = reallocate_bool_array (rule_has_nl,
current_max_rules);
}
if ( num_rules > MAX_RULE )
lerrif( _( "too many rules (> %d)!" ), MAX_RULE );
if (num_rules > MAX_RULE)
lerrif (_("too many rules (> %d)!"), MAX_RULE);
rule_linenum[num_rules] = linenum;
rule_useful[num_rules] = false;
}
rule_has_nl[num_rules] = false;
}

280
options.c Normal file
View File

@ -0,0 +1,280 @@
/* flex - tool to generate fast lexical analyzers */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "options.h"
/* Be sure to synchronize these options with those defined in "options.h",
* the giant switch() statement in "main.c", and the %option processing in
* "scan.l".
*/
/* The command-line options, passed to scanopt_init() */
optspec_t flexopts[] = {
{"-7", OPT_7BIT, 0}
,
{"--7bit", OPT_7BIT, 0}
, /* Generate 7-bit scanner. */
{"-8", OPT_8BIT, 0}
,
{"--8bit", OPT_8BIT, 0}
, /* Generate 8-bit scanner. */
{"--align", OPT_ALIGN, 0}
, /* Trade off larger tables for better memory alignment. */
{"--noalign", OPT_NO_ALIGN, 0}
,
{"--always-interactive", OPT_ALWAYS_INTERACTIVE, 0}
,
{"--array", OPT_ARRAY, 0}
,
{"-b", OPT_BACKUP, 0}
,
{"--backup", OPT_BACKUP, 0}
, /* Generate backing-up information to lex.backup. */
{"-B", OPT_BATCH, 0}
,
{"--batch", OPT_BATCH, 0}
, /* Generate batch scanner (opposite of -I). */
{"--bison-bridge", OPT_BISON_BRIDGE, 0}
, /* Scanner to be called by a bison pure parser. */
{"--bison-locations", OPT_BISON_BRIDGE_LOCATIONS, 0}
, /* Scanner to be called by a bison pure parser. */
{"-i", OPT_CASE_INSENSITIVE, 0}
,
{"--case-insensitive", OPT_CASE_INSENSITIVE, 0}
, /* Generate case-insensitive scanner. */
{"-C[aefFmr]", OPT_COMPRESSION,
"Specify degree of table compression (default is -Cem)"},
{"-+", OPT_CPLUSPLUS, 0}
,
{"--c++", OPT_CPLUSPLUS, 0}
, /* Generate C++ scanner class. */
{"-d", OPT_DEBUG, 0}
,
{"--debug", OPT_DEBUG, 0}
, /* Turn on debug mode in generated scanner. */
{"--nodebug", OPT_NO_DEBUG, 0}
,
{"-s", OPT_NO_DEFAULT, 0}
,
{"--nodefault", OPT_NO_DEFAULT, 0}
, /* Suppress default rule to ECHO unmatched text. */
{"--default", OPT_DEFAULT, 0}
,
{"-c", OPT_DONOTHING, 0}
, /* For POSIX lex compatibility. */
{"-n", OPT_DONOTHING, 0}
, /* For POSIX lex compatibility. */
{"--ecs", OPT_ECS, 0}
, /* Construct equivalence classes. */
{"--noecs", OPT_NO_ECS, 0}
,
{"-F", OPT_FAST, 0}
,
{"--fast", OPT_FAST, 0}
, /* Same as -CFr. */
{"-f", OPT_FULL, 0}
,
{"--full", OPT_FULL, 0}
, /* Same as -Cfr. */
{"--header-file[=FILE]", OPT_HEADER_FILE, 0}
,
{"-?", OPT_HELP, 0}
,
{"-h", OPT_HELP, 0}
,
{"--help", OPT_HELP, 0}
, /* Produce this help message. */
{"-I", OPT_INTERACTIVE, 0}
,
{"--interactive", OPT_INTERACTIVE, 0}
, /* Generate interactive scanner (opposite of -B). */
{"-l", OPT_LEX_COMPAT, 0}
,
{"--lex-compat", OPT_LEX_COMPAT, 0}
, /* Maximal compatibility with original lex. */
{"-X", OPT_POSIX_COMPAT, 0}
,
{"--posix-compat", OPT_POSIX_COMPAT, 0}
, /* Maximal compatibility with POSIX lex. */
{"--preproc=NUM", OPT_PREPROC_LEVEL, 0}
,
{"-L", OPT_NO_LINE, 0}
, /* Suppress #line directives in scanner. */
{"--noline", OPT_NO_LINE, 0}
, /* Suppress #line directives in scanner. */
{"--main", OPT_MAIN, 0}
, /* use built-in main() function. */
{"--nomain", OPT_NO_MAIN, 0}
,
{"--meta-ecs", OPT_META_ECS, 0}
, /* Construct meta-equivalence classes. */
{"--nometa-ecs", OPT_NO_META_ECS, 0}
,
{"--never-interactive", OPT_NEVER_INTERACTIVE, 0}
,
{"-o FILE", OPT_OUTFILE, 0}
,
{"--outfile=FILE", OPT_OUTFILE, 0}
, /* Write to FILE (default is lex.yy.c) */
{"-p", OPT_PERF_REPORT, 0}
,
{"--perf-report", OPT_PERF_REPORT, 0}
, /* Generate performance report to stderr. */
{"--pointer", OPT_POINTER, 0}
,
{"-P PREFIX", OPT_PREFIX, 0}
,
{"--prefix=PREFIX", OPT_PREFIX, 0}
, /* Use PREFIX (default is yy) */
{"-Dmacro", OPT_PREPROCDEFINE, 0}
, /* Define a preprocessor symbol. */
{"--read", OPT_READ, 0}
, /* Use read(2) instead of stdio. */
{"-R", OPT_REENTRANT, 0}
,
{"--reentrant", OPT_REENTRANT, 0}
, /* Generate a reentrant C scanner. */
{"--noreentrant", OPT_NO_REENTRANT, 0}
,
{"--reject", OPT_REJECT, 0}
,
{"--noreject", OPT_NO_REJECT, 0}
,
{"-S FILE", OPT_SKEL, 0}
,
{"--skel=FILE", OPT_SKEL, 0}
, /* Use skeleton from FILE */
{"--stack", OPT_STACK, 0}
,
{"--stdinit", OPT_STDINIT, 0}
,
{"--nostdinit", OPT_NO_STDINIT, 0}
,
{"-t", OPT_STDOUT, 0}
,
{"--stdout", OPT_STDOUT, 0}
, /* Write generated scanner to stdout. */
{"-T", OPT_TRACE, 0}
,
{"--trace", OPT_TRACE, 0}
, /* Flex should run in trace mode. */
{"--tables-file[=FILE]", OPT_TABLES_FILE, 0}
, /* Save tables to FILE */
{"--tables-verify", OPT_TABLES_VERIFY, 0}
, /* Tables integrity check */
{"--nounistd", OPT_NO_UNISTD_H, 0}
, /* Do not include unistd.h */
{"-v", OPT_VERBOSE, 0}
,
{"--verbose", OPT_VERBOSE, 0}
, /* Write summary of scanner statistics to stdout. */
{"-V", OPT_VERSION, 0}
,
{"--version", OPT_VERSION, 0}
, /* Report flex version. */
{"--warn", OPT_WARN, 0}
,
{"-w", OPT_NO_WARN, 0}
,
{"--nowarn", OPT_NO_WARN, 0}
, /* Suppress warning messages. */
{"--noansi-definitions", OPT_NO_ANSI_FUNC_DEFS, 0}
,
{"--noansi-prototypes", OPT_NO_ANSI_FUNC_PROTOS, 0}
,
{"--yyclass=NAME", OPT_YYCLASS, 0}
,
{"--yylineno", OPT_YYLINENO, 0}
,
{"--noyylineno", OPT_NO_YYLINENO, 0}
,
{"--yymore", OPT_YYMORE, 0}
,
{"--noyymore", OPT_NO_YYMORE, 0}
,
{"--noyywrap", OPT_NO_YYWRAP, 0}
,
{"--yywrap", OPT_YYWRAP, 0}
,
{"--nounput", OPT_NO_UNPUT, 0}
,
{"--noyy_push_state", OPT_NO_YY_PUSH_STATE, 0}
,
{"--noyy_pop_state", OPT_NO_YY_POP_STATE, 0}
,
{"--noyy_top_state", OPT_NO_YY_TOP_STATE, 0}
,
{"--noyy_scan_buffer", OPT_NO_YY_SCAN_BUFFER, 0}
,
{"--noyy_scan_bytes", OPT_NO_YY_SCAN_BYTES, 0}
,
{"--noyy_scan_string", OPT_NO_YY_SCAN_STRING, 0}
,
{"--noyyget_extra", OPT_NO_YYGET_EXTRA, 0}
,
{"--noyyset_extra", OPT_NO_YYSET_EXTRA, 0}
,
{"--noyyget_leng", OPT_NO_YYGET_LENG, 0}
,
{"--noyyget_text", OPT_NO_YYGET_TEXT, 0}
,
{"--noyyget_lineno", OPT_NO_YYGET_LINENO, 0}
,
{"--noyyset_lineno", OPT_NO_YYSET_LINENO, 0}
,
{"--noyyget_in", OPT_NO_YYGET_IN, 0}
,
{"--noyyset_in", OPT_NO_YYSET_IN, 0}
,
{"--noyyget_out", OPT_NO_YYGET_OUT, 0}
,
{"--noyyset_out", OPT_NO_YYSET_OUT, 0}
,
{"--noyyget_lval", OPT_NO_YYGET_LVAL, 0}
,
{"--noyyset_lval", OPT_NO_YYSET_LVAL, 0}
,
{"--noyyget_lloc", OPT_NO_YYGET_LLOC, 0}
,
{"--noyyset_lloc", OPT_NO_YYSET_LLOC, 0}
,
{0, 0, 0} /* required final NULL entry. */
};
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */

134
options.h Normal file
View File

@ -0,0 +1,134 @@
/* flex - tool to generate fast lexical analyzers */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#ifndef OPTIONS_H
#define OPTIONS_H
#include "scanopt.h"
extern optspec_t flexopts[];
enum flexopt_flag_t {
/* Use positive integers only, since they are return codes for scanopt.
* Order is not important. */
OPT_7BIT = 1,
OPT_8BIT,
OPT_ALIGN,
OPT_ALWAYS_INTERACTIVE,
OPT_ARRAY,
OPT_BACKUP,
OPT_BATCH,
OPT_BISON_BRIDGE,
OPT_BISON_BRIDGE_LOCATIONS,
OPT_CASE_INSENSITIVE,
OPT_COMPRESSION,
OPT_CPLUSPLUS,
OPT_DEBUG,
OPT_DEFAULT,
OPT_DONOTHING,
OPT_ECS,
OPT_FAST,
OPT_FULL,
OPT_HEADER_FILE,
OPT_HELP,
OPT_INTERACTIVE,
OPT_LEX_COMPAT,
OPT_POSIX_COMPAT,
OPT_MAIN,
OPT_META_ECS,
OPT_NEVER_INTERACTIVE,
OPT_NO_ALIGN,
OPT_NO_ANSI_FUNC_DEFS,
OPT_NO_ANSI_FUNC_PROTOS,
OPT_NO_DEBUG,
OPT_NO_DEFAULT,
OPT_NO_ECS,
OPT_NO_LINE,
OPT_NO_MAIN,
OPT_NO_META_ECS,
OPT_NO_REENTRANT,
OPT_NO_REJECT,
OPT_NO_STDINIT,
OPT_NO_UNPUT,
OPT_NO_WARN,
OPT_NO_YYGET_EXTRA,
OPT_NO_YYGET_IN,
OPT_NO_YYGET_LENG,
OPT_NO_YYGET_LINENO,
OPT_NO_YYGET_LLOC,
OPT_NO_YYGET_LVAL,
OPT_NO_YYGET_OUT,
OPT_NO_YYGET_TEXT,
OPT_NO_YYLINENO,
OPT_NO_YYMORE,
OPT_NO_YYSET_EXTRA,
OPT_NO_YYSET_IN,
OPT_NO_YYSET_LINENO,
OPT_NO_YYSET_LLOC,
OPT_NO_YYSET_LVAL,
OPT_NO_YYSET_OUT,
OPT_NO_YYWRAP,
OPT_NO_YY_POP_STATE,
OPT_NO_YY_PUSH_STATE,
OPT_NO_YY_SCAN_BUFFER,
OPT_NO_YY_SCAN_BYTES,
OPT_NO_YY_SCAN_STRING,
OPT_NO_YY_TOP_STATE,
OPT_OUTFILE,
OPT_PERF_REPORT,
OPT_POINTER,
OPT_PREFIX,
OPT_PREPROCDEFINE,
OPT_PREPROC_LEVEL,
OPT_READ,
OPT_REENTRANT,
OPT_REJECT,
OPT_SKEL,
OPT_STACK,
OPT_STDINIT,
OPT_STDOUT,
OPT_TABLES_FILE,
OPT_TABLES_VERIFY,
OPT_TRACE,
OPT_NO_UNISTD_H,
OPT_VERBOSE,
OPT_VERSION,
OPT_WARN,
OPT_YYCLASS,
OPT_YYLINENO,
OPT_YYMORE,
OPT_YYWRAP
};
#endif
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4 textwidth=0: */

2830
parse.c Normal file

File diff suppressed because it is too large Load Diff

139
parse.h Normal file
View File

@ -0,0 +1,139 @@
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
CHAR = 258,
NUMBER = 259,
SECTEND = 260,
SCDECL = 261,
XSCDECL = 262,
NAME = 263,
PREVCCL = 264,
EOF_OP = 265,
OPTION_OP = 266,
OPT_OUTFILE = 267,
OPT_PREFIX = 268,
OPT_YYCLASS = 269,
OPT_HEADER = 270,
OPT_EXTRA_TYPE = 271,
OPT_TABLES = 272,
CCE_ALNUM = 273,
CCE_ALPHA = 274,
CCE_BLANK = 275,
CCE_CNTRL = 276,
CCE_DIGIT = 277,
CCE_GRAPH = 278,
CCE_LOWER = 279,
CCE_PRINT = 280,
CCE_PUNCT = 281,
CCE_SPACE = 282,
CCE_UPPER = 283,
CCE_XDIGIT = 284,
CCE_NEG_ALNUM = 285,
CCE_NEG_ALPHA = 286,
CCE_NEG_BLANK = 287,
CCE_NEG_CNTRL = 288,
CCE_NEG_DIGIT = 289,
CCE_NEG_GRAPH = 290,
CCE_NEG_LOWER = 291,
CCE_NEG_PRINT = 292,
CCE_NEG_PUNCT = 293,
CCE_NEG_SPACE = 294,
CCE_NEG_UPPER = 295,
CCE_NEG_XDIGIT = 296,
CCL_OP_UNION = 297,
CCL_OP_DIFF = 298,
BEGIN_REPEAT_POSIX = 299,
END_REPEAT_POSIX = 300,
BEGIN_REPEAT_FLEX = 301,
END_REPEAT_FLEX = 302
};
#endif
/* Tokens. */
#define CHAR 258
#define NUMBER 259
#define SECTEND 260
#define SCDECL 261
#define XSCDECL 262
#define NAME 263
#define PREVCCL 264
#define EOF_OP 265
#define OPTION_OP 266
#define OPT_OUTFILE 267
#define OPT_PREFIX 268
#define OPT_YYCLASS 269
#define OPT_HEADER 270
#define OPT_EXTRA_TYPE 271
#define OPT_TABLES 272
#define CCE_ALNUM 273
#define CCE_ALPHA 274
#define CCE_BLANK 275
#define CCE_CNTRL 276
#define CCE_DIGIT 277
#define CCE_GRAPH 278
#define CCE_LOWER 279
#define CCE_PRINT 280
#define CCE_PUNCT 281
#define CCE_SPACE 282
#define CCE_UPPER 283
#define CCE_XDIGIT 284
#define CCE_NEG_ALNUM 285
#define CCE_NEG_ALPHA 286
#define CCE_NEG_BLANK 287
#define CCE_NEG_CNTRL 288
#define CCE_NEG_DIGIT 289
#define CCE_NEG_GRAPH 290
#define CCE_NEG_LOWER 291
#define CCE_NEG_PRINT 292
#define CCE_NEG_PUNCT 293
#define CCE_NEG_SPACE 294
#define CCE_NEG_UPPER 295
#define CCE_NEG_XDIGIT 296
#define CCL_OP_UNION 297
#define CCL_OP_DIFF 298
#define BEGIN_REPEAT_POSIX 299
#define END_REPEAT_POSIX 300
#define BEGIN_REPEAT_FLEX 301
#define END_REPEAT_FLEX 302
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
typedef int YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;

View File

@ -1,99 +1,105 @@
/* parse.y - parser for flex input */
%token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP
%token OPTION_OP OPT_OUTFILE OPT_PREFIX OPT_YYCLASS
%token OPTION_OP OPT_OUTFILE OPT_PREFIX OPT_YYCLASS OPT_HEADER OPT_EXTRA_TYPE
%token OPT_TABLES
%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
%token CCE_NEG_ALNUM CCE_NEG_ALPHA CCE_NEG_BLANK CCE_NEG_CNTRL CCE_NEG_DIGIT CCE_NEG_GRAPH
%token CCE_NEG_LOWER CCE_NEG_PRINT CCE_NEG_PUNCT CCE_NEG_SPACE CCE_NEG_UPPER CCE_NEG_XDIGIT
%left CCL_OP_DIFF CCL_OP_UNION
/*
*POSIX and AT&T lex place the
* precedence of the repeat operator, {}, below that of concatenation.
* Thus, ab{3} is ababab. Most other POSIX utilities use an Extended
* Regular Expression (ERE) precedence that has the repeat operator
* higher than concatenation. This causes ab{3} to yield abbb.
*
* In order to support the POSIX and AT&T precedence and the flex
* precedence we define two token sets for the begin and end tokens of
* the repeat operator, '{' and '}'. The lexical scanner chooses
* which tokens to return based on whether posix_compat or lex_compat
* are specified. Specifying either posix_compat or lex_compat will
* cause flex to parse scanner files as per the AT&T and
* POSIX-mandated behavior.
*/
%token BEGIN_REPEAT_POSIX END_REPEAT_POSIX BEGIN_REPEAT_FLEX END_REPEAT_FLEX
%{
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* $Header: /home/daffy/u0/vern/flex/RCS/parse.y,v 2.28 95/04/21 11:51:51 vern Exp $ */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* Some versions of bison are broken in that they use alloca() but don't
* declare it properly. The following is the patented (just kidding!)
* #ifdef chud to fix the problem, courtesy of Francois Pinard.
*/
#ifdef YYBISON
/* AIX requires this to be the first thing in the file. What a piece. */
# ifdef _AIX
#pragma alloca
# endif
#endif
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
#include "tables.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
# endif
# endif
# endif
#endif
/* Bletch, ^^^^ that was ugly! */
int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, rulelen;
int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen;
int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
int *scon_stk;
int scon_stk_ptr;
static int madeany = false; /* whether we've made the '.' character class */
static int ccldot, cclany;
int previous_continued_action; /* whether the previous rule's action was '|' */
#define format_warn3(fmt, a1, a2) \
do{ \
char fw3_msg[MAXLINE];\
snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\
warn( fw3_msg );\
}while(0)
/* Expand a POSIX character class expression. */
#define CCL_EXPR(func) \
{ \
do{ \
int c; \
for ( c = 0; c < csize; ++c ) \
if ( isascii(c) && func(c) ) \
ccladd( currccl, c ); \
}
}while(0)
/* negated class */
#define CCL_NEG_EXPR(func) \
do{ \
int c; \
for ( c = 0; c < csize; ++c ) \
if ( !func(c) ) \
ccladd( currccl, c ); \
}while(0)
/* While POSIX defines isblank(), it's not ANSI C. */
#define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
@ -123,7 +129,7 @@ goal : initlex sect1 sect1end sect2 initforrule
*/
default_rule = num_rules;
finish_rule( def_rule, false, 0, 0 );
finish_rule( def_rule, false, 0, 0, 0);
for ( i = 1; i <= lastsc; ++i )
scset[i] = mkbranch( scset[i], def_rule );
@ -150,7 +156,7 @@ sect1 : sect1 startconddecl namelist1
| sect1 options
|
| error
{ synerr( "unknown error processing section 1" ); }
{ synerr( _("unknown error processing section 1") ); }
;
sect1end : SECTEND
@ -175,7 +181,7 @@ namelist1 : namelist1 NAME
{ scinstal( nmstr, xcluflg ); }
| error
{ synerr( "bad start condition list" ); }
{ synerr( _("bad start condition list") ); }
;
options : OPTION_OP optionlist
@ -190,10 +196,16 @@ option : OPT_OUTFILE '=' NAME
outfilename = copy_string( nmstr );
did_outfilename = 1;
}
| OPT_EXTRA_TYPE '=' NAME
{ extra_type = copy_string( nmstr ); }
| OPT_PREFIX '=' NAME
{ prefix = copy_string( nmstr ); }
| OPT_YYCLASS '=' NAME
{ yyclass = copy_string( nmstr ); }
| OPT_HEADER '=' NAME
{ headerfilename = copy_string( nmstr ); }
| OPT_TABLES '=' NAME
{ tablesext = true; tablesfilename = copy_string( nmstr ); }
;
sect2 : sect2 scon initforrule flexrule '\n'
@ -220,7 +232,7 @@ flexrule : '^' rule
{
pat = $2;
finish_rule( pat, variable_trail_rule,
headcnt, trailcnt );
headcnt, trailcnt , previous_continued_action);
if ( scon_stk_ptr > 0 )
{
@ -256,7 +268,7 @@ flexrule : '^' rule
{
pat = $1;
finish_rule( pat, variable_trail_rule,
headcnt, trailcnt );
headcnt, trailcnt , previous_continued_action);
if ( scon_stk_ptr > 0 )
{
@ -300,7 +312,7 @@ flexrule : '^' rule
}
| error
{ synerr( "unrecognized rule" ); }
{ synerr( _("unrecognized rule") ); }
;
scon_stk_ptr :
@ -336,7 +348,7 @@ namelist2 : namelist2 ',' sconname
| sconname
| error
{ synerr( "bad start condition list" ); }
{ synerr( _("bad start condition list") ); }
;
sconname : NAME
@ -392,6 +404,7 @@ rule : re2 re
/* Mark as variable. */
varlength = true;
headcnt = 0;
}
if ( lex_compat || (varlength && headcnt == 0) )
@ -418,7 +431,7 @@ rule : re2 re
}
| re2 re '$'
{ synerr( "trailing context used twice" ); }
{ synerr( _("trailing context used twice") ); }
| re '$'
{
@ -431,7 +444,7 @@ rule : re2 re
if ( trlcontxt )
{
synerr( "trailing context used twice" );
synerr( _("trailing context used twice") );
$$ = mkstate( SYM_EPSILON );
}
@ -500,7 +513,7 @@ re2 : re '/'
*/
if ( trlcontxt )
synerr( "trailing context used twice" );
synerr( _("trailing context used twice") );
else
trlcontxt = true;
@ -529,6 +542,69 @@ series : series singleton
| singleton
{ $$ = $1; }
| series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX
{
varlength = true;
if ( $3 > $5 || $3 < 0 )
{
synerr( _("bad iteration values") );
$$ = $1;
}
else
{
if ( $3 == 0 )
{
if ( $5 <= 0 )
{
synerr(
_("bad iteration values") );
$$ = $1;
}
else
$$ = mkopt(
mkrep( $1, 1, $5 ) );
}
else
$$ = mkrep( $1, $3, $5 );
}
}
| series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX
{
varlength = true;
if ( $3 <= 0 )
{
synerr( _("iteration value must be positive") );
$$ = $1;
}
else
$$ = mkrep( $1, $3, INFINITE_REPEAT );
}
| series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX
{
/* The series could be something like "(foo)",
* in which case we have no idea what its length
* is, so we punt here.
*/
varlength = true;
if ( $3 <= 0 )
{
synerr( _("iteration value must be positive")
);
$$ = $1;
}
else
$$ = link_machines( $1,
copysingl( $1, $3 - 1 ) );
}
;
singleton : singleton '*'
@ -550,13 +626,13 @@ singleton : singleton '*'
$$ = mkopt( $1 );
}
| singleton '{' NUMBER ',' NUMBER '}'
| singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX
{
varlength = true;
if ( $3 > $5 || $3 < 0 )
{
synerr( "bad iteration values" );
synerr( _("bad iteration values") );
$$ = $1;
}
else
@ -566,7 +642,7 @@ singleton : singleton '*'
if ( $5 <= 0 )
{
synerr(
"bad iteration values" );
_("bad iteration values") );
$$ = $1;
}
else
@ -578,21 +654,21 @@ singleton : singleton '*'
}
}
| singleton '{' NUMBER ',' '}'
| singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX
{
varlength = true;
if ( $3 <= 0 )
{
synerr( "iteration value must be positive" );
synerr( _("iteration value must be positive") );
$$ = $1;
}
else
$$ = mkrep( $1, $3, INFINITY );
$$ = mkrep( $1, $3, INFINITE_REPEAT );
}
| singleton '{' NUMBER '}'
| singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX
{
/* The singleton could be something like "(foo)",
* in which case we have no idea what its length
@ -602,7 +678,7 @@ singleton : singleton '*'
if ( $3 <= 0 )
{
synerr( "iteration value must be positive" );
synerr( _("iteration value must be positive") );
$$ = $1;
}
@ -616,26 +692,37 @@ singleton : singleton '*'
if ( ! madeany )
{
/* Create the '.' character class. */
anyccl = cclinit();
ccladd( anyccl, '\n' );
cclnegate( anyccl );
ccldot = cclinit();
ccladd( ccldot, '\n' );
cclnegate( ccldot );
if ( useecs )
mkeccl( ccltbl + cclmap[anyccl],
ccllen[anyccl], nextecm,
ecgroup, csize, csize );
if ( useecs )
mkeccl( ccltbl + cclmap[ccldot],
ccllen[ccldot], nextecm,
ecgroup, csize, csize );
/* Create the (?s:'.') character class. */
cclany = cclinit();
cclnegate( cclany );
if ( useecs )
mkeccl( ccltbl + cclmap[cclany],
ccllen[cclany], nextecm,
ecgroup, csize, csize );
madeany = true;
}
++rulelen;
$$ = mkstate( -anyccl );
if (sf_dot_all())
$$ = mkstate( -cclany );
else
$$ = mkstate( -ccldot );
}
| fullccl
{
if ( ! cclsorted )
/* Sort characters for fast searching. We
* use a shell sort since this list could
* be large.
@ -648,6 +735,9 @@ singleton : singleton '*'
++rulelen;
if (ccl_has_nl[$1])
rule_has_nl[num_rules] = true;
$$ = mkstate( -$1 );
}
@ -655,6 +745,9 @@ singleton : singleton '*'
{
++rulelen;
if (ccl_has_nl[$1])
rule_has_nl[num_rules] = true;
$$ = mkstate( -$1 );
}
@ -668,15 +761,25 @@ singleton : singleton '*'
{
++rulelen;
if ( caseins && $1 >= 'A' && $1 <= 'Z' )
$1 = clower( $1 );
if ($1 == nlch)
rule_has_nl[num_rules] = true;
$$ = mkstate( $1 );
if (sf_case_ins() && has_case($1))
/* create an alternation, as in (a|A) */
$$ = mkor (mkstate($1), mkstate(reverse_case($1)));
else
$$ = mkstate( $1 );
}
;
fullccl:
fullccl CCL_OP_DIFF braceccl { $$ = ccl_set_diff ($1, $3); }
| fullccl CCL_OP_UNION braceccl { $$ = ccl_set_union ($1, $3); }
| braceccl
;
fullccl : '[' ccl ']'
{ $$ = $2; }
braceccl:
'[' ccl ']' { $$ = $2; }
| '[' '^' ccl ']'
{
@ -687,16 +790,35 @@ fullccl : '[' ccl ']'
ccl : ccl CHAR '-' CHAR
{
if ( caseins )
{
if ( $2 >= 'A' && $2 <= 'Z' )
$2 = clower( $2 );
if ( $4 >= 'A' && $4 <= 'Z' )
$4 = clower( $4 );
}
if (sf_case_ins())
{
/* If one end of the range has case and the other
* does not, or the cases are different, then we're not
* sure what range the user is trying to express.
* Examples: [@-z] or [S-t]
*/
if (has_case ($2) != has_case ($4)
|| (has_case ($2) && (b_islower ($2) != b_islower ($4)))
|| (has_case ($2) && (b_isupper ($2) != b_isupper ($4))))
format_warn3 (
_("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
$2, $4);
/* If the range spans uppercase characters but not
* lowercase (or vice-versa), then should we automatically
* include lowercase characters in the range?
* Example: [@-_] spans [a-z] but not [A-Z]
*/
else if (!has_case ($2) && !has_case ($4) && !range_covers_case ($2, $4))
format_warn3 (
_("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
$2, $4);
}
if ( $2 > $4 )
synerr( "negative range in character class" );
synerr( _("negative range in character class") );
else
{
@ -708,6 +830,19 @@ ccl : ccl CHAR '-' CHAR
*/
cclsorted = cclsorted && ($2 > lastchar);
lastchar = $4;
/* Do it again for upper/lowercase */
if (sf_case_ins() && has_case($2) && has_case($4)){
$2 = reverse_case ($2);
$4 = reverse_case ($4);
for ( i = $2; i <= $4; ++i )
ccladd( $1, i );
cclsorted = cclsorted && ($2 > lastchar);
lastchar = $4;
}
}
$$ = $1;
@ -715,12 +850,19 @@ ccl : ccl CHAR '-' CHAR
| ccl CHAR
{
if ( caseins && $2 >= 'A' && $2 <= 'Z' )
$2 = clower( $2 );
ccladd( $1, $2 );
cclsorted = cclsorted && ($2 > lastchar);
lastchar = $2;
/* Do it again for upper/lowercase */
if (sf_case_ins() && has_case($2)){
$2 = reverse_case ($2);
ccladd ($1, $2);
cclsorted = cclsorted && ($2 > lastchar);
lastchar = $2;
}
$$ = $1;
}
@ -739,33 +881,65 @@ ccl : ccl CHAR '-' CHAR
}
;
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) }
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);
if (sf_case_ins())
CCL_EXPR(isupper);
}
| CCE_PRINT { CCL_EXPR(isprint); }
| CCE_PUNCT { CCL_EXPR(ispunct); }
| CCE_SPACE { CCL_EXPR(isspace); }
| CCE_XDIGIT { CCL_EXPR(isxdigit); }
| CCE_UPPER {
if ( caseins )
CCL_EXPR(islower)
else
CCL_EXPR(isupper)
CCL_EXPR(isupper);
if (sf_case_ins())
CCL_EXPR(islower);
}
| CCE_NEG_ALNUM { CCL_NEG_EXPR(isalnum); }
| CCE_NEG_ALPHA { CCL_NEG_EXPR(isalpha); }
| CCE_NEG_BLANK { CCL_NEG_EXPR(IS_BLANK); }
| CCE_NEG_CNTRL { CCL_NEG_EXPR(iscntrl); }
| CCE_NEG_DIGIT { CCL_NEG_EXPR(isdigit); }
| CCE_NEG_GRAPH { CCL_NEG_EXPR(isgraph); }
| CCE_NEG_PRINT { CCL_NEG_EXPR(isprint); }
| CCE_NEG_PUNCT { CCL_NEG_EXPR(ispunct); }
| CCE_NEG_SPACE { CCL_NEG_EXPR(isspace); }
| CCE_NEG_XDIGIT { CCL_NEG_EXPR(isxdigit); }
| CCE_NEG_LOWER {
if ( sf_case_ins() )
warn(_("[:^lower:] is ambiguous in case insensitive scanner"));
else
CCL_NEG_EXPR(islower);
}
| CCE_NEG_UPPER {
if ( sf_case_ins() )
warn(_("[:^upper:] ambiguous in case insensitive scanner"));
else
CCL_NEG_EXPR(isupper);
}
| CCE_XDIGIT { CCL_EXPR(isxdigit) }
;
string : string CHAR
{
if ( caseins && $2 >= 'A' && $2 <= 'Z' )
$2 = clower( $2 );
if ( $2 == nlch )
rule_has_nl[num_rules] = true;
++rulelen;
$$ = link_machines( $1, mkstate( $2 ) );
if (sf_case_ins() && has_case($2))
$$ = mkor (mkstate($2), mkstate(reverse_case($2)));
else
$$ = mkstate ($2);
$$ = link_machines( $1, $$);
}
|
@ -794,7 +968,7 @@ void build_eof_action()
else
{
sceof[scon_stk[i]] = true;
sprintf( action_text, "case YY_STATE_EOF(%s):\n",
snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n",
scname[scon_stk[i]] );
add_action( action_text );
}
@ -815,11 +989,11 @@ void build_eof_action()
/* format_synerr - write out formatted syntax error */
void format_synerr( msg, arg )
char msg[], arg[];
const char *msg, arg[];
{
char errmsg[MAXLINE];
(void) sprintf( errmsg, msg, arg );
(void) snprintf( errmsg, sizeof(errmsg), msg, arg );
synerr( errmsg );
}
@ -827,7 +1001,7 @@ char msg[], arg[];
/* synerr - report a syntax error */
void synerr( str )
char str[];
const char *str;
{
syntaxerror = true;
pinpoint_message( str );
@ -837,11 +1011,11 @@ char str[];
/* format_warn - write out formatted warning */
void format_warn( msg, arg )
char msg[], arg[];
const char *msg, arg[];
{
char warn_msg[MAXLINE];
(void) sprintf( warn_msg, msg, arg );
snprintf( warn_msg, sizeof(warn_msg), msg, arg );
warn( warn_msg );
}
@ -849,7 +1023,7 @@ char msg[], arg[];
/* warn - report a warning, unless -w was given */
void warn( str )
char str[];
const char *str;
{
line_warning( str, linenum );
}
@ -859,11 +1033,11 @@ char str[];
*/
void format_pinpoint_message( msg, arg )
char msg[], arg[];
const char *msg, arg[];
{
char errmsg[MAXLINE];
(void) sprintf( errmsg, msg, arg );
snprintf( errmsg, sizeof(errmsg), msg, arg );
pinpoint_message( errmsg );
}
@ -871,7 +1045,7 @@ char msg[], arg[];
/* pinpoint_message - write out a message, pinpointing its location */
void pinpoint_message( str )
char str[];
const char *str;
{
line_pinpoint( str, linenum );
}
@ -880,14 +1054,14 @@ char str[];
/* line_warning - report a warning at a given line, unless -w was given */
void line_warning( str, line )
char str[];
const char *str;
int line;
{
char warning[MAXLINE];
if ( ! nowarn )
{
sprintf( warning, "warning, %s", str );
snprintf( warning, sizeof(warning), "warning, %s", str );
line_pinpoint( warning, line );
}
}
@ -896,10 +1070,10 @@ int line;
/* line_pinpoint - write out a message, pinpointing it at the given line */
void line_pinpoint( str, line )
char str[];
const char *str;
int line;
{
fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str );
fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
}
@ -908,6 +1082,6 @@ int line;
*/
void yyerror( msg )
char msg[];
const char *msg;
{
}

164
regex.c Normal file
View File

@ -0,0 +1,164 @@
/** regex - regular expression functions related to POSIX regex lib. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
static const char* REGEXP_LINEDIR = "^#line ([[:digit:]]+) \"(.*)\"";
static const char* REGEXP_BLANK_LINE = "^[[:space:]]*$";
regex_t regex_linedir; /**< matches line directives */
regex_t regex_blank_line; /**< matches blank lines */
/** Initialize the regular expressions.
* @return true upon success.
*/
bool flex_init_regex(void)
{
flex_regcomp(&regex_linedir, REGEXP_LINEDIR, REG_EXTENDED);
flex_regcomp(&regex_blank_line, REGEXP_BLANK_LINE, REG_EXTENDED);
return true;
}
/** Compiles a regular expression or dies trying.
* @param preg Same as for regcomp().
* @param regex Same as for regcomp().
* @param cflags Same as for regcomp().
*/
void flex_regcomp(regex_t *preg, const char *regex, int cflags)
{
int err;
memset (preg, 0, sizeof (regex_t));
if ((err = regcomp (preg, regex, cflags)) != 0) {
const int errbuf_sz = 200;
char * errbuf=0;
errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
regerror (err, preg, errbuf, errbuf_sz);
snprintf (errbuf, errbuf_sz, "regcomp failed: %s\n", errbuf);
flexfatal (errbuf);
free(errbuf);
}
}
/** Extract a copy of the match, or NULL if no match.
* @param m A match as returned by regexec().
* @param src The source string that was passed to regexec().
* @return The allocated string.
*/
char *regmatch_dup (regmatch_t * m, const char *src)
{
char *str;
int len;
if (m == NULL || m->rm_so < 0)
return NULL;
len = m->rm_eo - m->rm_so;
str = (char *) flex_alloc ((len + 1) * sizeof (char));
strncpy (str, src + m->rm_so, len);
str[len] = 0;
return str;
}
/** Copy the match.
* @param m A match as returned by regexec().
* @param dest The destination buffer.
* @param src The source string that was passed to regexec().
* @return dest
*/
char *regmatch_cpy (regmatch_t * m, char *dest, const char *src)
{
if (m == NULL || m->rm_so < 0) {
if (dest)
dest[0] = '\0';
return dest;
}
snprintf (dest, regmatch_len(m), "%s", src + m->rm_so);
return dest;
}
/** Get the length in characters of the match.
* @param m A match as returned by regexec().
* @param src The source string that was passed to regexec().
* @return The length of the match.
*/
int regmatch_len (regmatch_t * m)
{
if (m == NULL || m->rm_so < 0) {
return 0;
}
return m->rm_eo - m->rm_so;
}
/** Convert a regmatch_t object to an integer using the strtol() function.
* @param m A match as returned by regexec().
* @param src The source string that was passed to regexec().
* @param endptr Same as the second argument to strtol().
* @param base Same as the third argument to strtol().
* @return The converted integer or error (Return value is the same as for strtol()).
*/
int regmatch_strtol (regmatch_t * m, const char *src, char **endptr,
int base)
{
int n = 0;
#define bufsz 20
char buf[bufsz];
char *s;
if (m == NULL || m->rm_so < 0)
return 0;
if (regmatch_len (m) < bufsz)
s = regmatch_cpy (m, buf, src);
else
s = regmatch_dup (m, src);
n = strtol (s, endptr, base);
if (s != buf)
free (s);
return n;
}
/** Check for empty or non-existent match.
* @param m A match as returned by regexec().
* @return false if match length is non-zero.
* Note that reg_empty returns true even if match did not occur at all.
*/
bool regmatch_empty (regmatch_t * m)
{
return (m == NULL || m->rm_so < 0 || m->rm_so == m->rm_eo);
}
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */

5201
scan.c Normal file

File diff suppressed because it is too large Load Diff

1029
scan.l Normal file

File diff suppressed because it is too large Load Diff

66
scanflags.c Normal file
View File

@ -0,0 +1,66 @@
/* scanflags - flags used by scanning. */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
scanflags_t* _sf_stk = NULL;
size_t _sf_top_ix=0, _sf_max=0;
void
sf_push (void)
{
if (_sf_top_ix + 1 >= _sf_max)
_sf_stk = (scanflags_t*) flex_realloc ( (void*) _sf_stk, sizeof(scanflags_t) * (_sf_max += 32));
// copy the top element
_sf_stk[_sf_top_ix + 1] = _sf_stk[_sf_top_ix];
++_sf_top_ix;
}
void
sf_pop (void)
{
assert(_sf_top_ix > 0);
--_sf_top_ix;
}
/* one-time initialization. Should be called before any sf_ functions. */
void
sf_init (void)
{
assert(_sf_stk == NULL);
_sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32));
_sf_stk[_sf_top_ix] = 0;
}
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */

874
scanopt.c Normal file
View File

@ -0,0 +1,874 @@
/* flex - tool to generate fast lexical analyzers */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
#include "scanopt.h"
/* Internal structures */
#ifdef HAVE_STRCASECMP
#define STRCASECMP(a,b) strcasecmp(a,b)
#else
static int STRCASECMP PROTO ((const char *, const char *));
static int STRCASECMP (a, b)
const char *a;
const char *b;
{
while (tolower (*a++) == tolower (*b++)) ;
return b - a;
}
#endif
#define ARG_NONE 0x01
#define ARG_REQ 0x02
#define ARG_OPT 0x04
#define IS_LONG 0x08
struct _aux {
int flags; /* The above hex flags. */
int namelen; /* Length of the actual option word, e.g., "--file[=foo]" is 4 */
int printlen; /* Length of entire string, e.g., "--file[=foo]" is 12 */
};
struct _scanopt_t {
const optspec_t *options; /* List of options. */
struct _aux *aux; /* Auxiliary data about options. */
int optc; /* Number of options. */
int argc; /* Number of args. */
char **argv; /* Array of strings. */
int index; /* Used as: argv[index][subscript]. */
int subscript;
char no_err_msg; /* If true, do not print errors. */
char has_long;
char has_short;
};
/* Accessor functions. These WOULD be one-liners, but portability calls. */
static const char *NAME PROTO ((struct _scanopt_t *, int));
static int PRINTLEN PROTO ((struct _scanopt_t *, int));
static int RVAL PROTO ((struct _scanopt_t *, int));
static int FLAGS PROTO ((struct _scanopt_t *, int));
static const char *DESC PROTO ((struct _scanopt_t *, int));
static int scanopt_err PROTO ((struct _scanopt_t *, int, int, int));
static int matchlongopt PROTO ((char *, char **, int *, char **, int *));
static int find_opt
PROTO ((struct _scanopt_t *, int, char *, int, int *, int *opt_offset));
static const char *NAME (s, i)
struct _scanopt_t *s;
int i;
{
return s->options[i].opt_fmt +
((s->aux[i].flags & IS_LONG) ? 2 : 1);
}
static int PRINTLEN (s, i)
struct _scanopt_t *s;
int i;
{
return s->aux[i].printlen;
}
static int RVAL (s, i)
struct _scanopt_t *s;
int i;
{
return s->options[i].r_val;
}
static int FLAGS (s, i)
struct _scanopt_t *s;
int i;
{
return s->aux[i].flags;
}
static const char *DESC (s, i)
struct _scanopt_t *s;
int i;
{
return s->options[i].desc ? s->options[i].desc : "";
}
#ifndef NO_SCANOPT_USAGE
static int get_cols PROTO ((void));
static int get_cols ()
{
char *env;
int cols = 80; /* default */
#ifdef HAVE_NCURSES_H
initscr ();
endwin ();
if (COLS > 0)
return COLS;
#endif
if ((env = getenv ("COLUMNS")) != NULL)
cols = atoi (env);
return cols;
}
#endif
/* Macro to check for NULL before assigning a value. */
#define SAFE_ASSIGN(ptr,val) \
do{ \
if((ptr)!=NULL) \
*(ptr) = val; \
}while(0)
/* Macro to assure we reset subscript whenever we adjust s->index.*/
#define INC_INDEX(s,n) \
do{ \
(s)->index += (n); \
(s)->subscript= 0; \
}while(0)
scanopt_t *scanopt_init (options, argc, argv, flags)
const optspec_t *options;
int argc;
char **argv;
int flags;
{
int i;
struct _scanopt_t *s;
s = (struct _scanopt_t *) malloc (sizeof (struct _scanopt_t));
s->options = options;
s->optc = 0;
s->argc = argc;
s->argv = (char **) argv;
s->index = 1;
s->subscript = 0;
s->no_err_msg = (flags & SCANOPT_NO_ERR_MSG);
s->has_long = 0;
s->has_short = 0;
/* Determine option count. (Find entry with all zeros). */
s->optc = 0;
while (options[s->optc].opt_fmt
|| options[s->optc].r_val || options[s->optc].desc)
s->optc++;
/* Build auxiliary data */
s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux));
for (i = 0; i < s->optc; i++) {
const char *p, *pname;
const struct optspec_t *opt;
struct _aux *aux;
opt = s->options + i;
aux = s->aux + i;
aux->flags = ARG_NONE;
if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
aux->flags |= IS_LONG;
pname = opt->opt_fmt + 2;
s->has_long = 1;
}
else {
pname = opt->opt_fmt + 1;
s->has_short = 1;
}
aux->printlen = strlen (opt->opt_fmt);
aux->namelen = 0;
for (p = pname + 1; *p; p++) {
/* detect required arg */
if (*p == '=' || isspace (*p)
|| !(aux->flags & IS_LONG)) {
if (aux->namelen == 0)
aux->namelen = p - pname;
aux->flags |= ARG_REQ;
aux->flags &= ~ARG_NONE;
}
/* detect optional arg. This overrides required arg. */
if (*p == '[') {
if (aux->namelen == 0)
aux->namelen = p - pname;
aux->flags &= ~(ARG_REQ | ARG_NONE);
aux->flags |= ARG_OPT;
break;
}
}
if (aux->namelen == 0)
aux->namelen = p - pname;
}
return (scanopt_t *) s;
}
#ifndef NO_SCANOPT_USAGE
/* these structs are for scanopt_usage(). */
struct usg_elem {
int idx;
struct usg_elem *next;
struct usg_elem *alias;
};
typedef struct usg_elem usg_elem;
/* Prints a usage message based on contents of optlist.
* Parameters:
* scanner - The scanner, already initialized with scanopt_init().
* fp - The file stream to write to.
* usage - Text to be prepended to option list.
* Return: Always returns 0 (zero).
* The output looks something like this:
[indent][option, alias1, alias2...][indent][description line1
description line2...]
*/
int scanopt_usage (scanner, fp, usage)
scanopt_t *scanner;
FILE *fp;
const char *usage;
{
struct _scanopt_t *s;
int i, columns, indent = 2;
usg_elem *byr_val = NULL; /* option indices sorted by r_val */
usg_elem *store; /* array of preallocated elements. */
int store_idx = 0;
usg_elem *ue;
int maxlen[2];
int desccol = 0;
int print_run = 0;
maxlen[0] = 0;
maxlen[1] = 0;
s = (struct _scanopt_t *) scanner;
if (usage) {
fprintf (fp, "%s\n", usage);
}
else {
/* Find the basename of argv[0] */
const char *p;
p = s->argv[0] + strlen (s->argv[0]);
while (p != s->argv[0] && *p != '/')
--p;
if (*p == '/')
p++;
fprintf (fp, _("Usage: %s [OPTIONS]...\n"), p);
}
fprintf (fp, "\n");
/* Sort by r_val and string. Yes, this is O(n*n), but n is small. */
store = (usg_elem *) malloc (s->optc * sizeof (usg_elem));
for (i = 0; i < s->optc; i++) {
/* grab the next preallocate node. */
ue = store + store_idx++;
ue->idx = i;
ue->next = ue->alias = NULL;
/* insert into list. */
if (!byr_val)
byr_val = ue;
else {
int found_alias = 0;
usg_elem **ue_curr, **ptr_if_no_alias = NULL;
ue_curr = &byr_val;
while (*ue_curr) {
if (RVAL (s, (*ue_curr)->idx) ==
RVAL (s, ue->idx)) {
/* push onto the alias list. */
ue_curr = &((*ue_curr)->alias);
found_alias = 1;
break;
}
if (!ptr_if_no_alias
&&
STRCASECMP (NAME (s, (*ue_curr)->idx),
NAME (s, ue->idx)) > 0) {
ptr_if_no_alias = ue_curr;
}
ue_curr = &((*ue_curr)->next);
}
if (!found_alias && ptr_if_no_alias)
ue_curr = ptr_if_no_alias;
ue->next = *ue_curr;
*ue_curr = ue;
}
}
#if 0
if (1) {
printf ("ORIGINAL:\n");
for (i = 0; i < s->optc; i++)
printf ("%2d: %s\n", i, NAME (s, i));
printf ("SORTED:\n");
ue = byr_val;
while (ue) {
usg_elem *ue2;
printf ("%2d: %s\n", ue->idx, NAME (s, ue->idx));
for (ue2 = ue->alias; ue2; ue2 = ue2->next)
printf (" +---> %2d: %s\n", ue2->idx,
NAME (s, ue2->idx));
ue = ue->next;
}
}
#endif
/* Now build each row of output. */
/* first pass calculate how much room we need. */
for (ue = byr_val; ue; ue = ue->next) {
usg_elem *ap;
int len = 0;
int nshort = 0, nlong = 0;
#define CALC_LEN(i) do {\
if(FLAGS(s,i) & IS_LONG) \
len += (nlong++||nshort) ? 2+PRINTLEN(s,i) : PRINTLEN(s,i);\
else\
len += (nshort++||nlong)? 2+PRINTLEN(s,i) : PRINTLEN(s,i);\
}while(0)
if (!(FLAGS (s, ue->idx) & IS_LONG))
CALC_LEN (ue->idx);
/* do short aliases first. */
for (ap = ue->alias; ap; ap = ap->next) {
if (FLAGS (s, ap->idx) & IS_LONG)
continue;
CALC_LEN (ap->idx);
}
if (FLAGS (s, ue->idx) & IS_LONG)
CALC_LEN (ue->idx);
/* repeat the above loop, this time for long aliases. */
for (ap = ue->alias; ap; ap = ap->next) {
if (!(FLAGS (s, ap->idx) & IS_LONG))
continue;
CALC_LEN (ap->idx);
}
if (len > maxlen[0])
maxlen[0] = len;
/* It's much easier to calculate length for description column! */
len = strlen (DESC (s, ue->idx));
if (len > maxlen[1])
maxlen[1] = len;
}
/* Determine how much room we have, and how much we will allocate to each col.
* Do not address pathological cases. Output will just be ugly. */
columns = get_cols () - 1;
if (maxlen[0] + maxlen[1] + indent * 2 > columns) {
/* col 0 gets whatever it wants. we'll wrap the desc col. */
maxlen[1] = columns - (maxlen[0] + indent * 2);
if (maxlen[1] < 14) /* 14 is arbitrary lower limit on desc width. */
maxlen[1] = INT_MAX;
}
desccol = maxlen[0] + indent * 2;
#define PRINT_SPACES(fp,n)\
do{\
int _n;\
_n=(n);\
while(_n-- > 0)\
fputc(' ',(fp));\
}while(0)
/* Second pass (same as above loop), this time we print. */
/* Sloppy hack: We iterate twice. The first time we print short and long options.
The second time we print those lines that have ONLY long options. */
while (print_run++ < 2) {
for (ue = byr_val; ue; ue = ue->next) {
usg_elem *ap;
int nwords = 0, nchars = 0, has_short = 0;
/* TODO: get has_short schtick to work */
has_short = !(FLAGS (s, ue->idx) & IS_LONG);
for (ap = ue->alias; ap; ap = ap->next) {
if (!(FLAGS (s, ap->idx) & IS_LONG)) {
has_short = 1;
break;
}
}
if ((print_run == 1 && !has_short) ||
(print_run == 2 && has_short))
continue;
PRINT_SPACES (fp, indent);
nchars += indent;
/* Print, adding a ", " between aliases. */
#define PRINT_IT(i) do{\
if(nwords++)\
nchars+=fprintf(fp,", ");\
nchars+=fprintf(fp,"%s",s->options[i].opt_fmt);\
}while(0)
if (!(FLAGS (s, ue->idx) & IS_LONG))
PRINT_IT (ue->idx);
/* print short aliases first. */
for (ap = ue->alias; ap; ap = ap->next) {
if (!(FLAGS (s, ap->idx) & IS_LONG))
PRINT_IT (ap->idx);
}
if (FLAGS (s, ue->idx) & IS_LONG)
PRINT_IT (ue->idx);
/* repeat the above loop, this time for long aliases. */
for (ap = ue->alias; ap; ap = ap->next) {
if (FLAGS (s, ap->idx) & IS_LONG)
PRINT_IT (ap->idx);
}
/* pad to desccol */
PRINT_SPACES (fp, desccol - nchars);
/* Print description, wrapped to maxlen[1] columns. */
if (1) {
const char *pstart;
pstart = DESC (s, ue->idx);
while (1) {
int n = 0;
const char *lastws = NULL, *p;
p = pstart;
while (*p && n < maxlen[1]
&& *p != '\n') {
if (isspace (*p)
|| *p == '-') lastws =
p;
n++;
p++;
}
if (!*p) { /* hit end of desc. done. */
fprintf (fp, "%s\n",
pstart);
break;
}
else if (*p == '\n') { /* print everything up to here then wrap. */
fprintf (fp, "%.*s\n", n,
pstart);
PRINT_SPACES (fp, desccol);
pstart = p + 1;
continue;
}
else { /* we hit the edge of the screen. wrap at space if possible. */
if (lastws) {
fprintf (fp,
"%.*s\n",
lastws -
pstart,
pstart);
pstart =
lastws + 1;
}
else {
fprintf (fp,
"%.*s\n",
n,
pstart);
pstart = p + 1;
}
PRINT_SPACES (fp, desccol);
continue;
}
}
}
}
} /* end while */
free (store);
return 0;
}
#endif /* no scanopt_usage */
static int scanopt_err (s, opt_offset, is_short, err)
struct _scanopt_t *s;
int opt_offset;
int is_short;
int err;
{
const char *optname = "";
char optchar[2];
const optspec_t *opt = NULL;
if (opt_offset >= 0)
opt = s->options + opt_offset;
if (!s->no_err_msg) {
if (s->index > 0 && s->index < s->argc) {
if (is_short) {
optchar[0] =
s->argv[s->index][s->subscript];
optchar[1] = '\0';
optname = optchar;
}
else {
optname = s->argv[s->index];
}
}
fprintf (stderr, "%s: ", s->argv[0]);
switch (err) {
case SCANOPT_ERR_ARG_NOT_ALLOWED:
fprintf (stderr,
_
("option `%s' doesn't allow an argument\n"),
optname);
break;
case SCANOPT_ERR_ARG_NOT_FOUND:
fprintf (stderr,
_("option `%s' requires an argument\n"),
optname);
break;
case SCANOPT_ERR_OPT_AMBIGUOUS:
fprintf (stderr, _("option `%s' is ambiguous\n"),
optname);
break;
case SCANOPT_ERR_OPT_UNRECOGNIZED:
fprintf (stderr, _("Unrecognized option `%s'\n"),
optname);
break;
default:
fprintf (stderr, _("Unknown error=(%d)\n"), err);
break;
}
}
return err;
}
/* Internal. Match str against the regex ^--([^=]+)(=(.*))?
* return 1 if *looks* like a long option.
* 'str' is the only input argument, the rest of the arguments are output only.
* optname will point to str + 2
*
*/
static int matchlongopt (str, optname, optlen, arg, arglen)
char *str;
char **optname;
int *optlen;
char **arg;
int *arglen;
{
char *p;
*optname = *arg = (char *) 0;
*optlen = *arglen = 0;
/* Match regex /--./ */
p = str;
if (p[0] != '-' || p[1] != '-' || !p[2])
return 0;
p += 2;
*optname = (char *) p;
/* find the end of optname */
while (*p && *p != '=')
++p;
*optlen = p - *optname;
if (!*p)
/* an option with no '=...' part. */
return 1;
/* We saw an '=' char. The rest of p is the arg. */
p++;
*arg = p;
while (*p)
++p;
*arglen = p - *arg;
return 1;
}
/* Internal. Look up long or short option by name.
* Long options must match a non-ambiguous prefix, or exact match.
* Short options must be exact.
* Return boolean true if found and no error.
* Error stored in err_code or zero if no error. */
static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
struct _scanopt_t *s;
int lookup_long;
char *optstart;
int len;
int *err_code;
int *opt_offset;
{
int nmatch = 0, lastr_val = 0, i;
*err_code = 0;
*opt_offset = -1;
if (!optstart)
return 0;
for (i = 0; i < s->optc; i++) {
char *optname;
optname =
(char *) (s->options[i].opt_fmt +
(lookup_long ? 2 : 1));
if (lookup_long && (s->aux[i].flags & IS_LONG)) {
if (len > s->aux[i].namelen)
continue;
if (strncmp (optname, optstart, len) == 0) {
nmatch++;
*opt_offset = i;
/* exact match overrides all. */
if (len == s->aux[i].namelen) {
nmatch = 1;
break;
}
/* ambiguity is ok between aliases. */
if (lastr_val
&& lastr_val ==
s->options[i].r_val) nmatch--;
lastr_val = s->options[i].r_val;
}
}
else if (!lookup_long && !(s->aux[i].flags & IS_LONG)) {
if (optname[0] == optstart[0]) {
nmatch++;
*opt_offset = i;
}
}
}
if (nmatch == 0) {
*err_code = SCANOPT_ERR_OPT_UNRECOGNIZED;
*opt_offset = -1;
}
else if (nmatch > 1) {
*err_code = SCANOPT_ERR_OPT_AMBIGUOUS;
*opt_offset = -1;
}
return *err_code ? 0 : 1;
}
int scanopt (svoid, arg, optindex)
scanopt_t *svoid;
char **arg;
int *optindex;
{
char *optname = NULL, *optarg = NULL, *pstart;
int namelen = 0, arglen = 0;
int errcode = 0, has_next;
const optspec_t *optp;
struct _scanopt_t *s;
struct _aux *auxp;
int is_short;
int opt_offset = -1;
s = (struct _scanopt_t *) svoid;
/* Normalize return-parameters. */
SAFE_ASSIGN (arg, NULL);
SAFE_ASSIGN (optindex, s->index);
if (s->index >= s->argc)
return 0;
/* pstart always points to the start of our current scan. */
pstart = s->argv[s->index] + s->subscript;
if (!pstart)
return 0;
if (s->subscript == 0) {
/* test for exact match of "--" */
if (pstart[0] == '-' && pstart[1] == '-' && !pstart[2]) {
SAFE_ASSIGN (optindex, s->index + 1);
INC_INDEX (s, 1);
return 0;
}
/* Match an opt. */
if (matchlongopt
(pstart, &optname, &namelen, &optarg, &arglen)) {
/* it LOOKS like an opt, but is it one?! */
if (!find_opt
(s, 1, optname, namelen, &errcode,
&opt_offset)) {
scanopt_err (s, opt_offset, 0, errcode);
return errcode;
}
/* We handle this below. */
is_short = 0;
/* Check for short opt. */
}
else if (pstart[0] == '-' && pstart[1]) {
/* Pass through to below. */
is_short = 1;
s->subscript++;
pstart++;
}
else {
/* It's not an option. We're done. */
return 0;
}
}
/* We have to re-check the subscript status because it
* may have changed above. */
if (s->subscript != 0) {
/* we are somewhere in a run of short opts,
* e.g., at the 'z' in `tar -xzf` */
optname = pstart;
namelen = 1;
is_short = 1;
if (!find_opt
(s, 0, pstart, namelen, &errcode, &opt_offset)) {
return scanopt_err (s, opt_offset, 1, errcode);
}
optarg = pstart + 1;
if (!*optarg) {
optarg = NULL;
arglen = 0;
}
else
arglen = strlen (optarg);
}
/* At this point, we have a long or short option matched at opt_offset into
* the s->options array (and corresponding aux array).
* A trailing argument is in {optarg,arglen}, if any.
*/
/* Look ahead in argv[] to see if there is something
* that we can use as an argument (if needed). */
has_next = s->index + 1 < s->argc
&& strcmp ("--", s->argv[s->index + 1]) != 0;
optp = s->options + opt_offset;
auxp = s->aux + opt_offset;
/* case: no args allowed */
if (auxp->flags & ARG_NONE) {
if (optarg && !is_short) {
scanopt_err (s, opt_offset, is_short, errcode =
SCANOPT_ERR_ARG_NOT_ALLOWED);
INC_INDEX (s, 1);
return errcode;
}
else if (!optarg)
INC_INDEX (s, 1);
else
s->subscript++;
return optp->r_val;
}
/* case: required */
if (auxp->flags & ARG_REQ) {
if (!optarg && !has_next)
return scanopt_err (s, opt_offset, is_short,
SCANOPT_ERR_ARG_NOT_FOUND);
if (!optarg) {
/* Let the next argv element become the argument. */
SAFE_ASSIGN (arg, s->argv[s->index + 1]);
INC_INDEX (s, 2);
}
else {
SAFE_ASSIGN (arg, (char *) optarg);
INC_INDEX (s, 1);
}
return optp->r_val;
}
/* case: optional */
if (auxp->flags & ARG_OPT) {
SAFE_ASSIGN (arg, optarg);
INC_INDEX (s, 1);
return optp->r_val;
}
/* Should not reach here. */
return 0;
}
int scanopt_destroy (svoid)
scanopt_t *svoid;
{
struct _scanopt_t *s;
s = (struct _scanopt_t *) svoid;
if (s) {
if (s->aux)
free (s->aux);
free (s);
}
return 0;
}
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */

132
scanopt.h Normal file
View File

@ -0,0 +1,132 @@
/* flex - tool to generate fast lexical analyzers */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#ifndef SCANOPT_H
#define SCANOPT_H
#include "flexdef.h"
#ifndef NO_SCANOPT_USAGE
/* Used by scanopt_usage for pretty-printing. */
#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef PROTO
#define PROTO(args) args
#endif
/* Error codes. */ enum scanopt_err_t {
SCANOPT_ERR_OPT_UNRECOGNIZED = -1, /* Unrecognized option. */
SCANOPT_ERR_OPT_AMBIGUOUS = -2, /* It matched more than one option name. */
SCANOPT_ERR_ARG_NOT_FOUND = -3, /* The required arg was not found. */
SCANOPT_ERR_ARG_NOT_ALLOWED = -4 /* Option does not take an argument. */
};
/* flags passed to scanopt_init */
enum scanopt_flag_t {
SCANOPT_NO_ERR_MSG = 0x01 /* Suppress printing to stderr. */
};
/* Specification for a single option. */
struct optspec_t {
const char *opt_fmt; /* e.g., "--foo=FILE", "-f FILE", "-n [NUM]" */
int r_val; /* Value to be returned by scanopt_ex(). */
const char *desc; /* Brief description of this option, or NULL. */
};
typedef struct optspec_t optspec_t;
/* Used internally by scanopt() to maintain state. */
/* Never modify these value directly. */
typedef void *scanopt_t;
/* Initializes scanner and checks option list for errors.
* Parameters:
* options - Array of options.
* argc - Same as passed to main().
* argv - Same as passed to main(). First element is skipped.
* flags - Control behavior.
* Return: A malloc'd pointer .
*/
scanopt_t *scanopt_init PROTO ((const optspec_t * options,
int argc, char **argv, int flags));
/* Frees memory used by scanner.
* Always returns 0. */
int scanopt_destroy PROTO ((scanopt_t * scanner));
#ifndef NO_SCANOPT_USAGE
/* Prints a usage message based on contents of optlist.
* Parameters:
* scanner - The scanner, already initialized with scanopt_init().
* fp - The file stream to write to.
* usage - Text to be prepended to option list. May be NULL.
* Return: Always returns 0 (zero).
*/
int scanopt_usage
PROTO (
(scanopt_t * scanner, FILE * fp,
const char *usage));
#endif
/* Scans command-line options in argv[].
* Parameters:
* scanner - The scanner, already initialized with scanopt_init().
* optarg - Return argument, may be NULL.
* On success, it points to start of an argument.
* optindex - Return argument, may be NULL.
* On success or failure, it is the index of this option.
* If return is zero, then optindex is the NEXT valid option index.
*
* Return: > 0 on success. Return value is from optspec_t->rval.
* == 0 if at end of options.
* < 0 on error (return value is an error code).
*
*/
int scanopt
PROTO (
(scanopt_t * scanner, char **optarg,
int *optindex));
#ifdef __cplusplus
}
#endif
#endif
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */

3713
skel.c Normal file

File diff suppressed because it is too large Load Diff

272
sym.c Normal file
View File

@ -0,0 +1,272 @@
/* sym - symbol table routines */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
/* Variables for symbol tables:
* sctbl - start-condition symbol table
* ndtbl - name-definition symbol table
* ccltab - character class text symbol table
*/
struct hash_entry {
struct hash_entry *prev, *next;
char *name;
char *str_val;
int int_val;
};
typedef struct hash_entry **hash_table;
#define NAME_TABLE_HASH_SIZE 101
#define START_COND_HASH_SIZE 101
#define CCL_HASH_SIZE 101
static struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
static struct hash_entry *sctbl[START_COND_HASH_SIZE];
static struct hash_entry *ccltab[CCL_HASH_SIZE];
/* declare functions that have forward references */
static int addsym PROTO ((register char[], char *, int, hash_table, int));
static struct hash_entry *findsym PROTO ((register const char *sym,
hash_table table,
int table_size));
static int hashfunct PROTO ((register const char *, int));
/* addsym - add symbol and definitions to symbol table
*
* -1 is returned if the symbol already exists, and the change not made.
*/
static int addsym (sym, str_def, int_def, table, table_size)
register char sym[];
char *str_def;
int int_def;
hash_table table;
int table_size;
{
int hash_val = hashfunct (sym, table_size);
register struct hash_entry *sym_entry = table[hash_val];
register struct hash_entry *new_entry;
register struct hash_entry *successor;
while (sym_entry) {
if (!strcmp (sym, sym_entry->name)) { /* entry already exists */
return -1;
}
sym_entry = sym_entry->next;
}
/* create new entry */
new_entry = (struct hash_entry *)
flex_alloc (sizeof (struct hash_entry));
if (new_entry == NULL)
flexfatal (_("symbol table memory allocation failed"));
if ((successor = table[hash_val]) != 0) {
new_entry->next = successor;
successor->prev = new_entry;
}
else
new_entry->next = NULL;
new_entry->prev = NULL;
new_entry->name = sym;
new_entry->str_val = str_def;
new_entry->int_val = int_def;
table[hash_val] = new_entry;
return 0;
}
/* cclinstal - save the text of a character class */
void cclinstal (ccltxt, cclnum)
Char ccltxt[];
int cclnum;
{
/* We don't bother checking the return status because we are not
* called unless the symbol is new.
*/
(void) addsym ((char *) copy_unsigned_string (ccltxt),
(char *) 0, cclnum, ccltab, CCL_HASH_SIZE);
}
/* ccllookup - lookup the number associated with character class text
*
* Returns 0 if there's no CCL associated with the text.
*/
int ccllookup (ccltxt)
Char ccltxt[];
{
return findsym ((char *) ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
}
/* findsym - find symbol in symbol table */
static struct hash_entry *findsym (sym, table, table_size)
register const char *sym;
hash_table table;
int table_size;
{
static struct hash_entry empty_entry = {
(struct hash_entry *) 0, (struct hash_entry *) 0,
(char *) 0, (char *) 0, 0,
};
register struct hash_entry *sym_entry =
table[hashfunct (sym, table_size)];
while (sym_entry) {
if (!strcmp (sym, sym_entry->name))
return sym_entry;
sym_entry = sym_entry->next;
}
return &empty_entry;
}
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
static int hashfunct (str, hash_size)
register const char *str;
int hash_size;
{
register int hashval;
register int locstr;
hashval = 0;
locstr = 0;
while (str[locstr]) {
hashval = (hashval << 1) + (unsigned char) str[locstr++];
hashval %= hash_size;
}
return hashval;
}
/* ndinstal - install a name definition */
void ndinstal (name, definition)
const char *name;
Char definition[];
{
if (addsym (copy_string (name),
(char *) copy_unsigned_string (definition), 0,
ndtbl, NAME_TABLE_HASH_SIZE))
synerr (_("name defined twice"));
}
/* ndlookup - lookup a name definition
*
* Returns a nil pointer if the name definition does not exist.
*/
Char *ndlookup (nd)
const char *nd;
{
return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
}
/* scextend - increase the maximum number of start conditions */
void scextend ()
{
current_max_scs += MAX_SCS_INCREMENT;
++num_reallocs;
scset = reallocate_integer_array (scset, current_max_scs);
scbol = reallocate_integer_array (scbol, current_max_scs);
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);
}
/* scinstal - make a start condition
*
* NOTE
* The start condition is "exclusive" if xcluflg is true.
*/
void scinstal (str, xcluflg)
const char *str;
int xcluflg;
{
if (++lastsc >= current_max_scs)
scextend ();
scname[lastsc] = copy_string (str);
if (addsym (scname[lastsc], (char *) 0, lastsc,
sctbl, START_COND_HASH_SIZE))
format_pinpoint_message (_
("start condition %s declared twice"),
str);
scset[lastsc] = mkstate (SYM_EPSILON);
scbol[lastsc] = mkstate (SYM_EPSILON);
scxclu[lastsc] = xcluflg;
sceof[lastsc] = false;
}
/* sclookup - lookup the number associated with a start condition
*
* Returns 0 if no such start condition.
*/
int sclookup (str)
const char *str;
{
return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val;
}

497
tables.c Normal file
View File

@ -0,0 +1,497 @@
/* tables.c - tables serialization code
*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* This file is part of flex.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
#include "flexdef.h"
#include "tables.h"
/** Convert size_t to t_flag.
* @param n in {1,2,4}
* @return YYTD_DATA*.
*/
#define BYTES2TFLAG(n)\
(((n) == sizeof(flex_int8_t))\
? YYTD_DATA8\
:(((n)== sizeof(flex_int16_t))\
? YYTD_DATA16\
: YYTD_DATA32))
/** Clear YYTD_DATA* bit flags
* @return the flag with the YYTD_DATA* bits cleared
*/
#define TFLAGS_CLRDATA(flg) ((flg) & ~(YYTD_DATA8 | YYTD_DATA16 | YYTD_DATA32))
int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v);
int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v);
int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v);
int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len);
static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i);
static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
int j, int k);
/** Initialize the table writer.
* @param wr an uninitialized writer
* @param the output file
* @return 0 on success
*/
int yytbl_writer_init (struct yytbl_writer *wr, FILE * out)
{
wr->out = out;
wr->total_written = 0;
return 0;
}
/** Initialize a table header.
* @param th The uninitialized structure
* @param version_str the version string
* @param name the name of this table set
*/
int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
const char *name)
{
memset (th, 0, sizeof (struct yytbl_hdr));
th->th_magic = YYTBL_MAGIC;
th->th_hsize = 14 + strlen (version_str) + 1 + strlen (name) + 1;
th->th_hsize += yypad64 (th->th_hsize);
th->th_ssize = 0; // Not known at this point.
th->th_flags = 0;
th->th_version = copy_string (version_str);
th->th_name = copy_string (name);
return 0;
}
/** Allocate and initialize a table data structure.
* @param tbl a pointer to an uninitialized table
* @param id the table identifier
* @return 0 on success
*/
int yytbl_data_init (struct yytbl_data *td, enum yytbl_id id)
{
memset (td, 0, sizeof (struct yytbl_data));
td->td_id = id;
td->td_flags = YYTD_DATA32;
return 0;
}
/** Clean up table and data array.
* @param td will be destroyed
* @return 0 on success
*/
int yytbl_data_destroy (struct yytbl_data *td)
{
if (td->td_data)
free (td->td_data);
td->td_data = 0;
free (td);
return 0;
}
/** Write enough padding to bring the file pointer to a 64-bit boundary. */
static int yytbl_write_pad64 (struct yytbl_writer *wr)
{
int pad, bwritten = 0;
pad = yypad64 (wr->total_written);
while (pad-- > 0)
if (yytbl_write8 (wr, 0) < 0)
return -1;
else
bwritten++;
return bwritten;
}
/** write the header.
* @param out the output stream
* @param th table header to be written
* @return -1 on error, or bytes written on success.
*/
int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th)
{
int sz, rv;
int bwritten = 0;
if (yytbl_write32 (wr, th->th_magic) < 0
|| yytbl_write32 (wr, th->th_hsize) < 0)
flex_die (_("th_magic|th_hsize write32 failed"));
bwritten += 8;
if (fgetpos (wr->out, &(wr->th_ssize_pos)) != 0)
flex_die (_("fgetpos failed"));
if (yytbl_write32 (wr, th->th_ssize) < 0
|| yytbl_write16 (wr, th->th_flags) < 0)
flex_die (_("th_ssize|th_flags write failed"));
bwritten += 6;
sz = strlen (th->th_version) + 1;
if ((rv = yytbl_writen (wr, th->th_version, sz)) != sz)
flex_die (_("th_version writen failed"));
bwritten += rv;
sz = strlen (th->th_name) + 1;
if ((rv = yytbl_writen (wr, th->th_name, sz)) != sz)
flex_die (_("th_name writen failed"));
bwritten += rv;
/* add padding */
if ((rv = yytbl_write_pad64 (wr)) < 0)
flex_die (_("pad64 failed"));
bwritten += rv;
/* Sanity check */
if (bwritten != (int) th->th_hsize)
flex_die (_("pad64 failed"));
return bwritten;
}
/** Write this table.
* @param out the file writer
* @param td table data to be written
* @return -1 on error, or bytes written on success.
*/
int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
{
int rv;
flex_int32_t bwritten = 0;
flex_int32_t i, total_len;
fpos_t pos;
if ((rv = yytbl_write16 (wr, td->td_id)) < 0)
return -1;
bwritten += rv;
if ((rv = yytbl_write16 (wr, td->td_flags)) < 0)
return -1;
bwritten += rv;
if ((rv = yytbl_write32 (wr, td->td_hilen)) < 0)
return -1;
bwritten += rv;
if ((rv = yytbl_write32 (wr, td->td_lolen)) < 0)
return -1;
bwritten += rv;
total_len = yytbl_calc_total_len (td);
for (i = 0; i < total_len; i++) {
switch (YYTDFLAGS2BYTES (td->td_flags)) {
case sizeof (flex_int8_t):
rv = yytbl_write8 (wr, yytbl_data_geti (td, i));
break;
case sizeof (flex_int16_t):
rv = yytbl_write16 (wr, yytbl_data_geti (td, i));
break;
case sizeof (flex_int32_t):
rv = yytbl_write32 (wr, yytbl_data_geti (td, i));
break;
default:
flex_die (_("invalid td_flags detected"));
}
if (rv < 0) {
flex_die (_("error while writing tables"));
return -1;
}
bwritten += rv;
}
/* Sanity check */
if (bwritten != (int) (12 + total_len * YYTDFLAGS2BYTES (td->td_flags))) {
flex_die (_("insanity detected"));
return -1;
}
/* add padding */
if ((rv = yytbl_write_pad64 (wr)) < 0) {
flex_die (_("pad64 failed"));
return -1;
}
bwritten += rv;
/* Now go back and update the th_hsize member */
if (fgetpos (wr->out, &pos) != 0
|| fsetpos (wr->out, &(wr->th_ssize_pos)) != 0
|| yytbl_write32 (wr, wr->total_written) < 0
|| fsetpos (wr->out, &pos)) {
flex_die (_("get|set|fwrite32 failed"));
return -1;
}
else
/* Don't count the int we just wrote. */
wr->total_written -= sizeof (flex_int32_t);
return bwritten;
}
/** Write n bytes.
* @param wr the table writer
* @param v data to be written
* @param len number of bytes
* @return -1 on error. number of bytes written on success.
*/
int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len)
{
int rv;
rv = fwrite (v, 1, len, wr->out);
if (rv != len)
return -1;
wr->total_written += len;
return len;
}
/** Write four bytes in network byte order
* @param wr the table writer
* @param v a dword in host byte order
* @return -1 on error. number of bytes written on success.
*/
int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v)
{
flex_uint32_t vnet;
size_t bytes, rv;
vnet = htonl (v);
bytes = sizeof (flex_uint32_t);
rv = fwrite (&vnet, bytes, 1, wr->out);
if (rv != 1)
return -1;
wr->total_written += bytes;
return bytes;
}
/** Write two bytes in network byte order.
* @param wr the table writer
* @param v a word in host byte order
* @return -1 on error. number of bytes written on success.
*/
int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v)
{
flex_uint16_t vnet;
size_t bytes, rv;
vnet = htons (v);
bytes = sizeof (flex_uint16_t);
rv = fwrite (&vnet, bytes, 1, wr->out);
if (rv != 1)
return -1;
wr->total_written += bytes;
return bytes;
}
/** Write a byte.
* @param wr the table writer
* @param v the value to be written
* @return -1 on error. number of bytes written on success.
*/
int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v)
{
size_t bytes, rv;
bytes = sizeof (flex_uint8_t);
rv = fwrite (&v, bytes, 1, wr->out);
if (rv != 1)
return -1;
wr->total_written += bytes;
return bytes;
}
/** Extract data element [i][j] from array data tables.
* @param tbl data table
* @param i index into higher dimension array. i should be zero for one-dimensional arrays.
* @param j index into lower dimension array.
* @param k index into struct, must be 0 or 1. Only valid for YYTD_ID_TRANSITION table
* @return data[i][j + k]
*/
static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
int j, int k)
{
flex_int32_t lo;
k %= 2;
lo = tbl->td_lolen;
switch (YYTDFLAGS2BYTES (tbl->td_flags)) {
case sizeof (flex_int8_t):
return ((flex_int8_t *) (tbl->td_data))[(i * lo + j) * (k + 1) +
k];
case sizeof (flex_int16_t):
return ((flex_int16_t *) (tbl->td_data))[(i * lo + j) * (k +
1) +
k];
case sizeof (flex_int32_t):
return ((flex_int32_t *) (tbl->td_data))[(i * lo + j) * (k +
1) +
k];
default:
flex_die (_("invalid td_flags detected"));
break;
}
return 0;
}
/** Extract data element [i] from array data tables treated as a single flat array of integers.
* Be careful for 2-dimensional arrays or for YYTD_ID_TRANSITION, which is an array
* of structs.
* @param tbl data table
* @param i index into array.
* @return data[i]
*/
static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i)
{
switch (YYTDFLAGS2BYTES (tbl->td_flags)) {
case sizeof (flex_int8_t):
return ((flex_int8_t *) (tbl->td_data))[i];
case sizeof (flex_int16_t):
return ((flex_int16_t *) (tbl->td_data))[i];
case sizeof (flex_int32_t):
return ((flex_int32_t *) (tbl->td_data))[i];
default:
flex_die (_("invalid td_flags detected"));
break;
}
return 0;
}
/** Set data element [i] in array data tables treated as a single flat array of integers.
* Be careful for 2-dimensional arrays or for YYTD_ID_TRANSITION, which is an array
* of structs.
* @param tbl data table
* @param i index into array.
* @param newval new value for data[i]
*/
static void yytbl_data_seti (const struct yytbl_data *tbl, int i,
flex_int32_t newval)
{
switch (YYTDFLAGS2BYTES (tbl->td_flags)) {
case sizeof (flex_int8_t):
((flex_int8_t *) (tbl->td_data))[i] = (flex_int8_t) newval;
break;
case sizeof (flex_int16_t):
((flex_int16_t *) (tbl->td_data))[i] = (flex_int16_t) newval;
break;
case sizeof (flex_int32_t):
((flex_int32_t *) (tbl->td_data))[i] = (flex_int32_t) newval;
break;
default:
flex_die (_("invalid td_flags detected"));
break;
}
}
/** Calculate the number of bytes needed to hold the largest
* absolute value in this data array.
* @param tbl the data table
* @return sizeof(n) where n in {flex_int8_t, flex_int16_t, flex_int32_t}
*/
static size_t min_int_size (struct yytbl_data *tbl)
{
flex_uint32_t i, total_len;
flex_int32_t max = 0;
total_len = yytbl_calc_total_len (tbl);
for (i = 0; i < total_len; i++) {
flex_int32_t n;
n = abs (yytbl_data_geti (tbl, i));
if (n > max)
max = n;
}
if (max <= INT8_MAX)
return sizeof (flex_int8_t);
else if (max <= INT16_MAX)
return sizeof (flex_int16_t);
else
return sizeof (flex_int32_t);
}
/** Transform data to smallest possible of (int32, int16, int8).
* For example, we may have generated an int32 array due to user options
* (e.g., %option align), but if the maximum value in that array
* is 80 (for example), then we can serialize it with only 1 byte per int.
* This is NOT the same as compressed DFA tables. We're just trying
* to save storage space here.
*
* @param tbl the table to be compressed
*/
void yytbl_data_compress (struct yytbl_data *tbl)
{
flex_int32_t i, newsz, total_len;
struct yytbl_data newtbl;
yytbl_data_init (&newtbl, tbl->td_id);
newtbl.td_hilen = tbl->td_hilen;
newtbl.td_lolen = tbl->td_lolen;
newtbl.td_flags = tbl->td_flags;
newsz = min_int_size (tbl);
if (newsz == (int) YYTDFLAGS2BYTES (tbl->td_flags))
/* No change in this table needed. */
return;
if (newsz > (int) YYTDFLAGS2BYTES (tbl->td_flags)) {
flex_die (_("detected negative compression"));
return;
}
total_len = yytbl_calc_total_len (tbl);
newtbl.td_data = calloc (total_len, newsz);
newtbl.td_flags =
TFLAGS_CLRDATA (newtbl.td_flags) | BYTES2TFLAG (newsz);
for (i = 0; i < total_len; i++) {
flex_int32_t g;
g = yytbl_data_geti (tbl, i);
yytbl_data_seti (&newtbl, i, g);
}
/* Now copy over the old table */
free (tbl->td_data);
*tbl = newtbl;
}
/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */

85
tables.h Normal file
View File

@ -0,0 +1,85 @@
/* tables.h - tables serialization code
*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* This file is part of flex.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
#ifndef TABLES_H
#define TABLES_H
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* Tables serialization API declarations. */
#include "tables_shared.h"
struct yytbl_writer {
FILE *out;
flex_uint32_t total_written;
/**< bytes written so far */
fpos_t th_ssize_pos;
/**< position of th_ssize */
};
/* These are used by main.c, gen.c, etc.
* tablesext - if true, create external tables
* tablesfilename - filename for external tables
* tablesname - name that goes in serialized data, e.g., "yytables"
* tableswr - writer for external tables
* tablesverify - true if tables-verify option specified
* gentables - true if we should spit out the normal C tables
*/
extern bool tablesext, tablesverify,gentables;
extern char *tablesfilename, *tablesname;
extern struct yytbl_writer tableswr;
int yytbl_writer_init (struct yytbl_writer *, FILE *);
int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
const char *name);
int yytbl_data_init (struct yytbl_data *tbl, enum yytbl_id id);
int yytbl_data_destroy (struct yytbl_data *td);
int yytbl_hdr_fwrite (struct yytbl_writer *wr,
const struct yytbl_hdr *th);
int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td);
void yytbl_data_compress (struct yytbl_data *tbl);
struct yytbl_data *mkftbl (void);
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#endif
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */

70
tables_shared.c Normal file
View File

@ -0,0 +1,70 @@
#ifdef FLEX_SCANNER
/*
dnl tables_shared.c - tables serialization code
dnl
dnl Copyright (c) 1990 The Regents of the University of California.
dnl All rights reserved.
dnl
dnl This code is derived from software contributed to Berkeley by
dnl Vern Paxson.
dnl
dnl The United States Government has rights in this work pursuant
dnl to contract no. DE-AC03-76SF00098 between the United States
dnl Department of Energy and the University of California.
dnl
dnl This file is part of flex.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl
dnl 1. Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl Neither the name of the University nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
dnl IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
dnl PURPOSE.
dnl
*/
/* This file is meant to be included in both the skeleton and the actual
* flex code (hence the name "_shared").
*/
#ifndef yyskel_static
#define yyskel_static static
#endif
#else
#include "flexdef.h"
#include "tables.h"
#ifndef yyskel_static
#define yyskel_static
#endif
#endif
/** Get the number of integers in this table. This is NOT the
* same thing as the number of elements.
* @param td the table
* @return the number of integers in the table
*/
yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl)
{
flex_int32_t n;
/* total number of ints */
n = tbl->td_lolen;
if (tbl->td_hilen > 0)
n *= tbl->td_hilen;
if (tbl->td_id == YYTD_ID_TRANSITION)
n *= 2;
return n;
}

144
tables_shared.h Normal file
View File

@ -0,0 +1,144 @@
#ifdef FLEX_SCANNER
/*
dnl tables_shared.h - tables serialization header
dnl
dnl Copyright (c) 1990 The Regents of the University of California.
dnl All rights reserved.
dnl
dnl This code is derived from software contributed to Berkeley by
dnl Vern Paxson.
dnl
dnl The United States Government has rights in this work pursuant
dnl to contract no. DE-AC03-76SF00098 between the United States
dnl Department of Energy and the University of California.
dnl
dnl This file is part of flex.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl
dnl 1. Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl Neither the name of the University nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
dnl IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
dnl PURPOSE.
dnl
dnl This file is meant to be included in both the skeleton and the actual
dnl flex code (hence the name "_shared").
*/
#ifndef yyskel_static
#define yyskel_static static
#endif
#else
#ifndef yyskel_static
#define yyskel_static
#endif
#endif
/* Structures and prototypes for serializing flex tables. The
* binary format is documented in the manual.
*
* Design considerations:
*
* - The format allows many tables per file.
* - The tables can be streamed.
* - All data is stored in network byte order.
* - We do not hinder future unicode support.
* - We can lookup tables by name.
*/
/** Magic number for serialized format. */
#ifndef YYTBL_MAGIC
#define YYTBL_MAGIC 0xF13C57B1
#endif
/** Calculate (0-7) = number bytes needed to pad n to next 64-bit boundary. */
#ifndef yypad64
#define yypad64(n) ((8-((n)%8))%8)
#endif
#ifndef YYTABLES_TYPES
#define YYTABLES_TYPES
/** Possible values for td_id field. Each one corresponds to a
* scanner table of the same name.
*/
enum yytbl_id {
YYTD_ID_ACCEPT = 0x01, /**< 1-dim ints */
YYTD_ID_BASE = 0x02, /**< 1-dim ints */
YYTD_ID_CHK = 0x03, /**< 1-dim ints */
YYTD_ID_DEF = 0x04, /**< 1-dim ints */
YYTD_ID_EC = 0x05, /**< 1-dim ints */
YYTD_ID_META = 0x06, /**< 1-dim ints */
YYTD_ID_NUL_TRANS = 0x07, /**< 1-dim ints, maybe indices */
YYTD_ID_NXT = 0x08, /**< may be 2 dimensional ints */
YYTD_ID_RULE_CAN_MATCH_EOL = 0x09, /**< 1-dim ints */
YYTD_ID_START_STATE_LIST = 0x0A, /**< 1-dim indices into trans tbl */
YYTD_ID_TRANSITION = 0x0B, /**< structs */
YYTD_ID_ACCLIST = 0x0C /**< 1-dim ints */
};
/** bit flags for t_flags field of struct yytbl_data */
enum yytbl_flags {
/* These first three are mutually exclusive */
YYTD_DATA8 = 0x01, /**< data is an array of type flex_int8_t */
YYTD_DATA16 = 0x02, /**< data is an array of type flex_int16_t */
YYTD_DATA32 = 0x04, /**< data is an array of type flex_int32_t */
/* These two are mutually exclusive. */
YYTD_PTRANS = 0x08, /**< data is a list of indexes of entries
into the expanded `yy_transition'
array. See notes in manual. */
YYTD_STRUCT = 0x10 /**< data consists of yy_trans_info structs */
};
/* The serialized tables header. */
struct yytbl_hdr {
flex_uint32_t th_magic; /**< Must be 0xF13C57B1 (comes from "Flex Table") */
flex_uint32_t th_hsize; /**< Size of this header in bytes. */
flex_uint32_t th_ssize; /**< Size of this dataset, in bytes, including header. */
flex_uint16_t th_flags; /**< Currently unused, must be 0 */
char *th_version; /**< Flex version string. NUL terminated. */
char *th_name; /**< The name of this table set. NUL terminated. */
};
/** A single serialized table */
struct yytbl_data {
flex_uint16_t td_id; /**< enum yytbl_id table identifier */
flex_uint16_t td_flags; /**< how to interpret this data */
flex_uint32_t td_hilen; /**< num elements in highest dimension array */
flex_uint32_t td_lolen; /**< num elements in lowest dimension array */
void *td_data; /**< table data */
};
#endif
/** Extract corresponding data size_t from td_flags */
#ifndef YYTDFLAGS2BYTES
#define YYTDFLAGS2BYTES(td_flags)\
(((td_flags) & YYTD_DATA8)\
? sizeof(flex_int8_t)\
:(((td_flags) & YYTD_DATA16)\
? sizeof(flex_int16_t)\
:sizeof(flex_int32_t)))
#endif
#ifdef FLEX_SCANNER
%not-for-header
#endif
yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl);
#ifdef FLEX_SCANNER
%ok-for-header
#endif
/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +0,0 @@
Flex carries the copyright used for BSD software, slightly modified
because it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
which operates under a contract with the Department of Energy:
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.
This code is derived from software contributed to Berkeley by
Vern Paxson.
The United States Government has rights in this work pursuant
to contract no. DE-AC03-76SF00098 between the United States
Department of Energy and the University of California.
Redistribution and use in source and binary forms are permitted
provided that: (1) source distributions retain this entire
copyright notice and comment, and (2) distributions including
binaries display the following acknowledgement: ``This product
includes software developed by the University of California,
Berkeley and its contributors'' in the documentation or other
materials provided with the distribution and in all advertising
materials mentioning features or use of this software. Neither the
name of the University nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
This basically says "do whatever you please with this software except
remove this notice or take advantage of the University's (or the flex
authors') name".
Note that the "flex.skl" scanner skeleton carries no copyright notice.
You are free to do whatever you please with scanners generated using flex;
for them, you are not even bound by the above copyright.

View File

@ -1,57 +0,0 @@
# $Id$
#
# By default, flex will be configured to generate 8-bit scanners only if the
# -8 flag is given. If you want it to always generate 8-bit scanners, add
# "-DDEFAULT_CSIZE=256" to CFLAGS. Note that doing so will double the size
# of all uncompressed scanners.
#
# Bootstrapping of lex is handled automatically.
# ALso note that flex.skel no longer gets installed.
#
# XXX Todo:
# Install as lex++, and install FlexLexer.h
PROG= lex
LINKS= ${BINDIR}/lex ${BINDIR}/flex
#LINKS+= ${BINDIR}/lex ${BINDIR}/lex++ ${BINDIR}/flex ${BINDIR}/flex++
SRCS= ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y \
skel.c sym.c tblcmp.c yylex.c
OBJS+= scan.o
LFLAGS+= -is
CFLAGS+= -I. -I${.CURDIR}
MAN1= flex.1 flexdoc.1
MLINKS= flex.1 lex.1 flexdoc.1 lexdoc.1
CLEANFILES+= parse.c parse.h scan.c y.tab.h
SUBDIR= lib
.depend: parse.h
parse.c parse.h: parse.y
$(YACC) -d $(.CURDIR)/parse.y
mv y.tab.c parse.c
mv y.tab.h parse.h
.if exists(/usr/bin/lex)
scan.o: parse.c
.else
# We must bootstrap
scan.o: scan.c parse.h
scan.c:
@echo "Bootstrapping flex"
@rm -f scan.c
@cp -pf ${.CURDIR}/initscan.c scan.c
.endif
test: check
check: $(PROG)
./$(PROG) $(LFLAGS) -t $(COMPRESSION) $(.CURDIR)/scan.l \
| sed s,\"$(.CURDIR)/scan.l",\"scan.l", \
| diff $(.CURDIR)/initscan.c -
@echo "Check successful"
.include <bsd.prog.mk>

View File

@ -1,60 +0,0 @@
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.
Read the file "INSTALL" for general installation directives. Peek near
the beginning of the file "Makefile.in" for special DEFS values. On most
systems, you can just run the "configure" script and type "make" to build
flex; then "make check" to test whether it built correctly; and if it did,
then "make install" to install it.
If you're feeling adventurous, you can also issue "make bigcheck" (be
prepared to wait a while).
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.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 (vern@ee.lbl.gov).
The flex distribution consists of the following files:
README This message
NEWS Differences between the various releases
INSTALL General installation information
COPYING flex's copyright
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,
misc.c, nfa.c, sym.c, tblcmp.c, yylex.c
source files
version.h version of this flex release
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
libmain.c flex library (-lfl) sources
libyywrap.c
initscan.c pre-flex'd version of scan.l
FlexLexer.h header file for C++ lexer class
flex.1 user documentation
MISC/ a directory containing miscellaneous contributions.
See MISC/README for details.

View File

@ -1,149 +0,0 @@
/* ccl - routines for character classes */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/RCS/ccl.c,v 2.9 93/09/16 20:32:14 vern Exp $ */
#include "flexdef.h"
/* ccladd - add a single character to a ccl */
void ccladd( cclp, ch )
int cclp;
int ch;
{
int ind, len, newpos, i;
check_char( ch );
len = ccllen[cclp];
ind = cclmap[cclp];
/* check to see if the character is already in the ccl */
for ( i = 0; i < len; ++i )
if ( ccltbl[ind + i] == ch )
return;
newpos = ind + len;
if ( newpos >= current_max_ccl_tbl_size )
{
current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT;
++num_reallocs;
ccltbl = reallocate_Character_array( ccltbl,
current_max_ccl_tbl_size );
}
ccllen[cclp] = len + 1;
ccltbl[newpos] = ch;
}
/* cclinit - return an empty ccl */
int cclinit()
{
if ( ++lastccl >= current_maxccls )
{
current_maxccls += MAX_CCLS_INCREMENT;
++num_reallocs;
cclmap = reallocate_integer_array( cclmap, current_maxccls );
ccllen = reallocate_integer_array( ccllen, current_maxccls );
cclng = reallocate_integer_array( cclng, current_maxccls );
}
if ( lastccl == 1 )
/* we're making the first ccl */
cclmap[lastccl] = 0;
else
/* The new pointer is just past the end of the last ccl.
* Since the cclmap points to the \first/ character of a
* ccl, adding the length of the ccl to the cclmap pointer
* will produce a cursor to the first free space.
*/
cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1];
ccllen[lastccl] = 0;
cclng[lastccl] = 0; /* ccl's start out life un-negated */
return lastccl;
}
/* cclnegate - negate the given ccl */
void cclnegate( cclp )
int cclp;
{
cclng[cclp] = 1;
}
/* list_character_set - list the members of a set of characters in CCL form
*
* Writes to the given file a character-class representation of those
* characters present in the given CCL. A character is present if it
* has a non-zero value in the cset array.
*/
void list_character_set( file, cset )
FILE *file;
int cset[];
{
register int i;
putc( '[', file );
for ( i = 0; i < csize; ++i )
{
if ( cset[i] )
{
register int start_char = i;
putc( ' ', file );
fputs( readable_form( i ), file );
while ( ++i < csize && cset[i] )
;
if ( i - 1 > start_char )
/* this was a run */
fprintf( file, "-%s", readable_form( i - 1 ) );
putc( ' ', file );
}
}
putc( ']', file );
}

View File

@ -1,26 +0,0 @@
/* 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 */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
# $Id$
LIB= ln
SRCS= libmain.c libyywrap.c
LINKS= ${LIBDIR}/libln.a ${LIBDIR}/libl.a \
.if !defined(NOPROFILE)
LINKS+= ${LIBDIR}/libln_p.a ${LIBDIR}/libl_p.a
.endif
.if !defined(NOSHARED)
LINKS+= ${LIBDIR}/libln.so.$(SHLIB_MAJOR).$(SHLIB_MINOR) \
${LIBDIR}/libl.so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
.endif
#This is where we get our SHLIB_MAJOR and SHLIB_MINOR
.include "${.CURDIR}/../../../lib/Makefile.inc"
.include <bsd.lib.mk>

View File

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

View File

@ -1,8 +0,0 @@
/* libyywrap - flex run-time support library "yywrap" function */
/* $Header: /home/daffy/u0/vern/flex/RCS/libyywrap.c,v 1.1 93/10/02 15:23:09 vern Exp $ */
int yywrap()
{
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,886 +0,0 @@
/* misc - miscellaneous flex routines */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $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];
if ( (int) strlen( defname ) > MAXLINE / 2 )
{
format_pinpoint_message( _( "name \"%s\" ridiculously long" ),
defname );
return;
}
sprintf( buf, "#define %s %d\n", defname, value );
add_action( buf );
}
void add_action( new_text )
char *new_text;
{
int len = strlen( new_text );
while ( len + action_index >= action_size - 10 /* slop */ )
{
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 );
}
strcpy( &action_array[action_index], new_text );
action_index += len;
}
/* allocate_array - allocate memory for an integer array of the given size */
void *allocate_array( size, element_size )
int size;
size_t element_size;
{
register void *mem;
size_t num_bytes = element_size * size;
mem = flex_alloc( num_bytes );
if ( ! mem )
flexfatal(
_( "memory allocation failed in allocate_array()" ) );
return mem;
}
/* all_lower - true if a string is all lower-case */
int all_lower( str )
register char *str;
{
while ( *str )
{
if ( ! isascii( (Char) *str ) || ! islower( *str ) )
return 0;
++str;
}
return 1;
}
/* all_upper - true if a string is all upper-case */
int all_upper( str )
register char *str;
{
while ( *str )
{
if ( ! isascii( (Char) *str ) || ! isupper( *str ) )
return 0;
++str;
}
return 1;
}
/* bubble - bubble sort an integer array in increasing order
*
* synopsis
* int v[n], n;
* void bubble( v, n );
*
* description
* sorts the first n elements of array v and replaces them in
* increasing order.
*
* passed
* v - the array to be sorted
* n - the number of elements of 'v' to be sorted
*/
void bubble( v, n )
int v[], n;
{
register int i, j, k;
for ( i = n; i > 1; --i )
for ( j = 1; j < i; ++j )
if ( v[j] > v[j + 1] ) /* compare */
{
k = v[j]; /* exchange */
v[j] = v[j + 1];
v[j + 1] = k;
}
}
/* check_char - checks a character to make sure it's within the range
* we're expecting. If not, generates fatal error message
* and exits.
*/
void check_char( c )
int c;
{
if ( c >= CSIZE )
lerrsf( _( "bad character '%s' detected in check_char()" ),
readable_form( c ) );
if ( c >= csize )
lerrsf(
_( "scanner requires -8 flag to use the character %s" ),
readable_form( c ) );
}
/* clower - replace upper-case letter to lower-case */
Char clower( c )
register int c;
{
return (Char) ((isascii( c ) && isupper( c )) ? tolower( c ) : c);
}
/* copy_string - returns a dynamically allocated copy of a string */
char *copy_string( str )
register const char *str;
{
register const char *c1;
register char *c2;
char *copy;
unsigned int size;
/* find length */
for ( c1 = str; *c1; ++c1 )
;
size = (c1 - str + 1) * sizeof( char );
copy = (char *) flex_alloc( size );
if ( copy == NULL )
flexfatal( _( "dynamic memory failure in copy_string()" ) );
for ( c2 = copy; (*c2++ = *str++) != 0; )
;
return copy;
}
/* copy_unsigned_string -
* returns a dynamically allocated copy of a (potentially) unsigned string
*/
Char *copy_unsigned_string( str )
register Char *str;
{
register Char *c;
Char *copy;
/* find length */
for ( c = str; *c; ++c )
;
copy = allocate_Character_array( c - str + 1 );
for ( c = copy; (*c++ = *str++) != 0; )
;
return copy;
}
/* cshell - shell sort a character array in increasing order
*
* synopsis
*
* Char v[n];
* int n, special_case_0;
* cshell( v, n, special_case_0 );
*
* description
* Does a shell sort of the first n elements of array v.
* If special_case_0 is true, then any element equal to 0
* is instead assumed to have infinite weight.
*
* passed
* v - array to be sorted
* n - number of elements of v to be sorted
*/
void cshell( v, n, special_case_0 )
Char v[];
int n, special_case_0;
{
int gap, i, j, jg;
Char k;
for ( gap = n / 2; gap > 0; gap = gap / 2 )
for ( i = gap; i < n; ++i )
for ( j = i - gap; j >= 0; j = j - gap )
{
jg = j + gap;
if ( special_case_0 )
{
if ( v[jg] == 0 )
break;
else if ( v[j] != 0 && v[j] <= v[jg] )
break;
}
else if ( v[j] <= v[jg] )
break;
k = v[j];
v[j] = v[jg];
v[jg] = k;
}
}
/* dataend - finish up a block of data declarations */
void dataend()
{
if ( datapos > 0 )
dataflush();
/* add terminator for initialization; { for vi */
outn( " } ;\n" );
dataline = 0;
datapos = 0;
}
/* dataflush - flush generated data statements */
void dataflush()
{
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.
*/
outc( '\n' );
dataline = 0;
}
/* Reset the number of characters written on the current line. */
datapos = 0;
}
/* flexerror - report an error message and terminate */
void flexerror( msg )
const char msg[];
{
fprintf( stderr, "%s: %s\n", program_name, msg );
flexend( 1 );
}
/* flexfatal - report a fatal error message and terminate */
void flexfatal( msg )
const char msg[];
{
fprintf( stderr, _( "%s: fatal internal error, %s\n" ),
program_name, msg );
exit( 1 );
}
/* htoi - convert a hexadecimal digit string to an integer value */
int htoi( str )
Char str[];
{
unsigned int result;
(void) sscanf( (char *) str, "%x", &result );
return result;
}
/* lerrif - report an error message formatted with one integer argument */
void lerrif( msg, arg )
const 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 )
const char msg[], arg[];
{
char errmsg[MAXLINE];
(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 );
}
/* mark_defs1 - mark the current position in the action array as
* representing where the user's section 1 definitions end
* and the prolog begins
*/
void mark_defs1()
{
defs1_offset = 0;
action_array[action_index++] = '\0';
action_offset = prolog_offset = action_index;
action_array[action_index] = '\0';
}
/* mark_prolog - mark the current position in the action array as
* representing the end of the action prolog
*/
void mark_prolog()
{
action_array[action_index++] = '\0';
action_offset = action_index;
action_array[action_index] = '\0';
}
/* mk2data - generate a data statement for a two-dimensional array
*
* Generates a data statement initializing the current 2-D array to "value".
*/
void mk2data( value )
int value;
{
if ( datapos >= NUMDATAITEMS )
{
outc( ',' );
dataflush();
}
if ( datapos == 0 )
/* Indent. */
out( " " );
else
outc( ',' );
++datapos;
out_dec( "%5d", value );
}
/* mkdata - generate a data statement
*
* Generates a data statement initializing the current array element to
* "value".
*/
void mkdata( value )
int value;
{
if ( datapos >= NUMDATAITEMS )
{
outc( ',' );
dataflush();
}
if ( datapos == 0 )
/* Indent. */
out( " " );
else
outc( ',' );
++datapos;
out_dec( "%5d", value );
}
/* myctoi - return the integer represented by a string of digits */
int myctoi( array )
char array[];
{
int val = 0;
(void) sscanf( array, "%d", &val );
return val;
}
/* myesc - return character corresponding to escape sequence */
Char myesc( array )
Char array[];
{
Char c, esc_char;
switch ( array[1] )
{
case 'b': return '\b';
case 'f': return '\f';
case 'n': return '\n';
case 'r': return '\r';
case 't': return '\t';
#if __STDC__
case 'a': return '\a';
case 'v': return '\v';
#else
case 'a': return '\007';
case 'v': return '\013';
#endif
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{ /* \<octal> */
int sptr = 1;
while ( isascii( array[sptr] ) &&
isdigit( array[sptr] ) )
/* Don't increment inside loop control
* because if isdigit() is a macro it might
* expand into multiple increments ...
*/
++sptr;
c = array[sptr];
array[sptr] = '\0';
esc_char = otoi( array + 1 );
array[sptr] = c;
return esc_char;
}
case 'x':
{ /* \x<hex> */
int sptr = 2;
while ( isascii( array[sptr] ) &&
isxdigit( (char) array[sptr] ) )
/* Don't increment inside loop control
* because if isdigit() is a macro it might
* expand into multiple increments ...
*/
++sptr;
c = array[sptr];
array[sptr] = '\0';
esc_char = htoi( array + 2 );
array[sptr] = c;
return esc_char;
}
default:
return array[1];
}
}
/* otoi - convert an octal digit string to an integer value */
int otoi( str )
Char str[];
{
unsigned int result;
(void) sscanf( (char *) str, "%o", &result );
return result;
}
/* 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.
*/
char *readable_form( c )
register int c;
{
static char rform[10];
if ( (c >= 0 && c < 32) || c >= 127 )
{
switch ( c )
{
case '\b': return "\\b";
case '\f': return "\\f";
case '\n': return "\\n";
case '\r': return "\\r";
case '\t': return "\\t";
#if __STDC__
case '\a': return "\\a";
case '\v': return "\\v";
#endif
default:
(void) sprintf( rform, "\\%.3o",
(unsigned int) c );
return rform;
}
}
else if ( c == ' ' )
return "' '";
else
{
rform[0] = c;
rform[1] = '\0';
return rform;
}
}
/* reallocate_array - increase the size of a dynamic array */
void *reallocate_array( array, size, element_size )
void *array;
int size;
size_t element_size;
{
register void *new_array;
size_t num_bytes = element_size * size;
new_array = flex_realloc( array, num_bytes );
if ( ! new_array )
flexfatal( _( "attempt to increase array size failed" ) );
return new_array;
}
/* skelout - write out one section of the skeleton file
*
* Description
* Copies skelfile or skel array to stdout until a line beginning with
* "%%" or EOF is found.
*/
void skelout()
{
char buf_storage[MAXLINE];
char *buf = buf_storage;
int do_copy = 1;
/* Loop pulling lines either from the skelfile, if we're using
* one, or from the skel[] array.
*/
while ( skelfile ?
(fgets( buf, MAXLINE, skelfile ) != NULL) :
((buf = (char *) skel[skel_ind++]) != 0) )
{ /* copy from skel array */
if ( buf[0] == '%' )
{ /* control line */
switch ( buf[1] )
{
case '%':
return;
case '+':
do_copy = C_plus_plus;
break;
case '-':
do_copy = ! C_plus_plus;
break;
case '*':
do_copy = 1;
break;
default:
flexfatal(
_( "bad line in skeleton file" ) );
}
}
else if ( do_copy )
{
if ( skelfile )
/* Skeleton file reads include final
* newline, skel[] array does not.
*/
out( buf );
else
outn( buf );
}
}
}
/* transition_struct_out - output a yy_trans_info structure
*
* outputs the yy_trans_info structure with the two elements, element_v and
* element_n. Formats the output with spaces and carriage returns.
*/
void transition_struct_out( element_v, element_n )
int element_v, element_n;
{
out_dec2( " {%4d,%4d },", element_v, element_n );
datapos += TRANS_STRUCT_PRINT_LENGTH;
if ( datapos >= 79 - TRANS_STRUCT_PRINT_LENGTH )
{
outc( '\n' );
if ( ++dataline % 10 == 0 )
outc( '\n' );
datapos = 0;
}
}
/* The following is only needed when building flex's parser using certain
* broken versions of bison.
*/
void *yy_flex_xmalloc( size )
int size;
{
void *result = flex_alloc( (size_t) size );
if ( ! result )
flexfatal(
_( "memory allocation failed in yy_flex_xmalloc()" ) );
return result;
}
/* zero_out - set a region of memory to 0
*
* Sets region_ptr[0] through region_ptr[size_in_bytes - 1] to zero.
*/
void zero_out( region_ptr, size_in_bytes )
char *region_ptr;
size_t size_in_bytes;
{
register char *rp, *rp_end;
rp = region_ptr;
rp_end = region_ptr + size_in_bytes;
while ( rp < rp_end )
*rp++ = 0;
}

View File

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

View File

@ -1,710 +0,0 @@
/* scan.l - scanner for flex input */
%{
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $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 \
int flexscan()
#define RETURNCHAR \
yylval = (unsigned char) yytext[0]; \
return CHAR;
#define RETURNNAME \
strcpy( nmstr, yytext ); \
return NAME;
#define PUT_BACK_STRING(str, start) \
for ( i = strlen( str ) - 1; i >= start; --i ) \
unput((str)[i])
#define CHECK_REJECT(str) \
if ( all_upper( str ) ) \
reject = true;
#define CHECK_YYMORE(str) \
if ( all_lower( str ) ) \
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 COMMENT ACTION_STRING PERCENT_BRACE_ACTION
%x OPTION LINEDIR
WS [[:blank:]]+
OPTWS [[:blank:]]*
NOT_WS [^[:blank:]\n]
NL \r?\n
NAME ([[:alpha:]_][[:alnum:]_-]*)
NOT_NAME [^[:alpha:]_*\n]+
SCNAME {NAME}
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;
static int doing_rule_action = false;
static int option_sense;
int doing_codeblock = false;
int i;
Char nmdef[MAXLINE], myesc();
<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, 1 );
indented_code = false;
BEGIN(CODEBLOCK);
}
{WS} /* discard */
^"%%".* {
sectnum = 2;
bracelevel = 0;
mark_defs1();
line_directive_out( (FILE *) 0, 1 );
BEGIN(SECT2PROLOG);
return SECTEND;
}
^"%pointer".*{NL} yytext_is_array = false; ++linenum;
^"%array".*{NL} yytext_is_array = true; ++linenum;
^"%option" BEGIN(OPTION); return OPTION_OP;
^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) );
^{NAME} {
strcpy( nmstr, yytext );
didadef = false;
BEGIN(PICKUPDEF);
}
{SCNAME} RETURNNAME;
^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
{OPTWS}{NL} ACTION_ECHO; ++linenum; /* maybe end of comment line */
}
<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 );
\"[^"\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 */
{NOT_WS}.* {
strcpy( (char *) nmdef, yytext );
/* Skip trailing whitespace. */
for ( i = strlen( (char *) nmdef ) - 1;
i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
--i )
;
nmdef[i + 1] = '\0';
ndinstal( nmstr, nmdef );
didadef = true;
}
{NL} {
if ( ! didadef )
synerr( _( "incomplete name definition" ) );
BEGIN(INITIAL);
++linenum;
}
}
<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 );
}
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;
}
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 %{ */
^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
^{WS}.* ACTION_ECHO; /* indented code in prolog */
^{NOT_WS}.* { /* non-indented code */
if ( bracelevel <= 0 )
{ /* not in %{ ... %} */
yyless( 0 ); /* put it all back */
yy_set_bol( 1 );
mark_prolog();
BEGIN(SECT2);
}
else
ACTION_ECHO;
}
.* ACTION_ECHO;
{NL} ++linenum; ACTION_ECHO;
<<EOF>> {
mark_prolog();
sectnum = 0;
yyterminate(); /* to stop the parser */
}
}
<SECT2>{
^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
^{OPTWS}"%{" {
indented_code = false;
doing_codeblock = true;
bracelevel = 1;
BEGIN(PERCENT_BRACE_ACTION);
}
^{OPTWS}"<" BEGIN(SC); return '<';
^{OPTWS}"^" return '^';
\" BEGIN(QUOTE); return '"';
"{"/[[:digit:]] BEGIN(NUM); return '{';
"$"/([[:blank:]]|{NL}) return '$';
{WS}"%{" {
bracelevel = 1;
BEGIN(PERCENT_BRACE_ACTION);
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}.
*/
bracelevel = 0;
continued_action = false;
BEGIN(ACTION);
if ( in_rule )
{
doing_rule_action = true;
in_rule = false;
return '\n';
}
}
{OPTWS}{NL} {
bracelevel = 0;
continued_action = false;
BEGIN(ACTION);
unput( '\n' ); /* so <ACTION> sees it */
if ( in_rule )
{
doing_rule_action = true;
in_rule = false;
return '\n';
}
}
^{OPTWS}"<<EOF>>" |
"<<EOF>>" return EOF_OP;
^"%%".* {
sectnum = 3;
BEGIN(SECT3);
yyterminate(); /* to stop the parser */
}
"["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
int cclval;
strcpy( nmstr, yytext );
/* Check to see if we've already encountered this
* ccl.
*/
if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
{
if ( input() != ']' )
synerr( _( "bad character class" ) );
yylval = cclval;
++cclreuse;
return PREVCCL;
}
else
{
/* We fudge a bit. We know that this ccl will
* soon be numbered as lastccl + 1 by cclinit.
*/
cclinstal( (Char *) nmstr, lastccl + 1 );
/* Push back everything but the leading bracket
* so the ccl can be rescanned.
*/
yyless( 1 );
BEGIN(FIRSTCCL);
return '[';
}
}
"{"{NAME}"}" {
register Char *nmdefptr;
Char *ndlookup();
strcpy( nmstr, yytext + 1 );
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
if ( (nmdefptr = ndlookup( nmstr )) == 0 )
format_synerr(
_( "undefined definition {%s}" ),
nmstr );
else
{ /* push back name surrounded by ()'s */
int len = strlen( (char *) nmdefptr );
if ( lex_compat || nmdefptr[0] == '^' ||
(len > 0 && nmdefptr[len - 1] == '$') )
{ /* don't use ()'s after all */
PUT_BACK_STRING((char *) nmdefptr, 0);
if ( nmdefptr[0] == '^' )
BEGIN(CARETISBOL);
}
else
{
unput(')');
PUT_BACK_STRING((char *) nmdefptr, 0);
unput('(');
}
}
}
[/|*+?.(){}] return (unsigned char) yytext[0];
. RETURNCHAR;
}
<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;
\" BEGIN(SECT2); return '"';
{NL} {
synerr( _( "missing quote" ) );
BEGIN(SECT2);
++linenum;
return '"';
}
}
<FIRSTCCL>{
"^"/[^-\]\n] BEGIN(CCL); return '^';
"^"/("-"|"]") return '^';
. BEGIN(CCL); RETURNCHAR;
}
<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>{
[[:digit:]]+ {
yylval = myctoi( yytext );
return NUMBER;
}
"," return ',';
"}" BEGIN(SECT2); return '}';
. {
synerr( _( "bad character inside {}'s" ) );
BEGIN(SECT2);
return '}';
}
{NL} {
synerr( _( "missing }" ) );
BEGIN(SECT2);
++linenum;
return '}';
}
}
<PERCENT_BRACE_ACTION>{
{OPTWS}"%}".* bracelevel = 0;
<ACTION>"/*" ACTION_ECHO; yy_push_state( COMMENT );
<CODEBLOCK,ACTION>{
"reject" {
ACTION_ECHO;
CHECK_REJECT(yytext);
}
"yymore" {
ACTION_ECHO;
CHECK_YYMORE(yytext);
}
}
{NAME}|{NOT_NAME}|. ACTION_ECHO;
{NL} {
++linenum;
ACTION_ECHO;
if ( bracelevel == 0 ||
(doing_codeblock && indented_code) )
{
if ( doing_rule_action )
add_action( "\tYY_BREAK\n" );
doing_rule_action = doing_codeblock = false;
BEGIN(SECT2);
}
}
}
/* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
<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 )
{
if ( doing_rule_action )
add_action( "\tYY_BREAK\n" );
doing_rule_action = false;
BEGIN(SECT2);
}
}
. ACTION_ECHO;
}
<ACTION_STRING>{
[^"\\\n]+ ACTION_ECHO;
\\. ACTION_ECHO;
{NL} ++linenum; ACTION_ECHO;
\" ACTION_ECHO; BEGIN(ACTION);
. ACTION_ECHO;
}
<COMMENT,ACTION,ACTION_STRING><<EOF>> {
synerr( _( "EOF encountered inside an action" ) );
yyterminate();
}
<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
yylval = myesc( (Char *) yytext );
if ( YY_START == FIRSTCCL )
BEGIN(CCL);
return CHAR;
}
<SECT3>{
.*(\n?) ECHO;
<<EOF>> sectnum = 0; yyterminate();
}
<*>.|\n format_synerr( _( "bad character: %s" ), yytext );
%%
int yywrap()
{
if ( --num_input_files > 0 )
{
set_input_file( *++input_files );
return 0;
}
else
return 1;
}
/* set_input_file - open the given file (if NULL, stdin) for scanning */
void set_input_file( file )
char *file;
{
if ( file && strcmp( file, "-" ) )
{
infilename = copy_string( file );
yyin = fopen( infilename, "r" );
if ( yyin == NULL )
lerrsf( _( "can't open %s" ), file );
}
else
{
yyin = stdin;
infilename = copy_string( "<stdin>" );
}
linenum = 1;
}
/* Wrapper routines for accessing the scanner's malloc routines. */
void *flex_alloc( size )
size_t size;
{
return (void *) malloc( size );
}
void *flex_realloc( ptr, size )
void *ptr;
size_t size;
{
return (void *) realloc( ptr, size );
}
void flex_free( ptr )
void *ptr;
{
if ( ptr )
free( ptr );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,262 +0,0 @@
/* sym - symbol table routines */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $Header: /home/daffy/u0/vern/flex/RCS/sym.c,v 2.19 95/03/04 16:11:04 vern Exp $ */
#include "flexdef.h"
/* declare functions that have forward references */
int hashfunct PROTO((register char[], int));
struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
struct hash_entry *sctbl[START_COND_HASH_SIZE];
struct hash_entry *ccltab[CCL_HASH_SIZE];
struct hash_entry *findsym();
/* addsym - add symbol and definitions to symbol table
*
* -1 is returned if the symbol already exists, and the change not made.
*/
int addsym( sym, str_def, int_def, table, table_size )
register char sym[];
char *str_def;
int int_def;
hash_table table;
int table_size;
{
int hash_val = hashfunct( sym, table_size );
register struct hash_entry *sym_entry = table[hash_val];
register struct hash_entry *new_entry;
register struct hash_entry *successor;
while ( sym_entry )
{
if ( ! strcmp( sym, sym_entry->name ) )
{ /* entry already exists */
return -1;
}
sym_entry = sym_entry->next;
}
/* create new entry */
new_entry = (struct hash_entry *)
flex_alloc( sizeof( struct hash_entry ) );
if ( new_entry == NULL )
flexfatal( _( "symbol table memory allocation failed" ) );
if ( (successor = table[hash_val]) != 0 )
{
new_entry->next = successor;
successor->prev = new_entry;
}
else
new_entry->next = NULL;
new_entry->prev = NULL;
new_entry->name = sym;
new_entry->str_val = str_def;
new_entry->int_val = int_def;
table[hash_val] = new_entry;
return 0;
}
/* cclinstal - save the text of a character class */
void cclinstal( ccltxt, cclnum )
Char ccltxt[];
int cclnum;
{
/* We don't bother checking the return status because we are not
* called unless the symbol is new.
*/
Char *copy_unsigned_string();
(void) addsym( (char *) copy_unsigned_string( ccltxt ),
(char *) 0, cclnum,
ccltab, CCL_HASH_SIZE );
}
/* ccllookup - lookup the number associated with character class text
*
* Returns 0 if there's no CCL associated with the text.
*/
int ccllookup( ccltxt )
Char ccltxt[];
{
return findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val;
}
/* findsym - find symbol in symbol table */
struct hash_entry *findsym( sym, table, table_size )
register char sym[];
hash_table table;
int table_size;
{
static struct hash_entry empty_entry =
{
(struct hash_entry *) 0, (struct hash_entry *) 0,
(char *) 0, (char *) 0, 0,
} ;
register struct hash_entry *sym_entry =
table[hashfunct( sym, table_size )];
while ( sym_entry )
{
if ( ! strcmp( sym, sym_entry->name ) )
return sym_entry;
sym_entry = sym_entry->next;
}
return &empty_entry;
}
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
int hashfunct( str, hash_size )
register char str[];
int hash_size;
{
register int hashval;
register int locstr;
hashval = 0;
locstr = 0;
while ( str[locstr] )
{
hashval = (hashval << 1) + (unsigned char) str[locstr++];
hashval %= hash_size;
}
return hashval;
}
/* ndinstal - install a name definition */
void ndinstal( name, definition )
char name[];
Char definition[];
{
char *copy_string();
Char *copy_unsigned_string();
if ( addsym( copy_string( name ),
(char *) copy_unsigned_string( definition ), 0,
ndtbl, NAME_TABLE_HASH_SIZE ) )
synerr( _( "name defined twice" ) );
}
/* ndlookup - lookup a name definition
*
* Returns a nil pointer if the name definition does not exist.
*/
Char *ndlookup( nd )
char nd[];
{
return (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val;
}
/* scextend - increase the maximum number of start conditions */
void scextend()
{
current_max_scs += MAX_SCS_INCREMENT;
++num_reallocs;
scset = reallocate_integer_array( scset, current_max_scs );
scbol = reallocate_integer_array( scbol, current_max_scs );
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 );
}
/* scinstal - make a start condition
*
* NOTE
* The start condition is "exclusive" if xcluflg is true.
*/
void scinstal( str, xcluflg )
char str[];
int xcluflg;
{
char *copy_string();
/* Generate start condition definition, for use in BEGIN et al. */
action_define( str, lastsc );
if ( ++lastsc >= current_max_scs )
scextend();
scname[lastsc] = copy_string( str );
if ( addsym( scname[lastsc], (char *) 0, lastsc,
sctbl, START_COND_HASH_SIZE ) )
format_pinpoint_message(
_( "start condition %s declared twice" ),
str );
scset[lastsc] = mkstate( SYM_EPSILON );
scbol[lastsc] = mkstate( SYM_EPSILON );
scxclu[lastsc] = xcluflg;
sceof[lastsc] = false;
}
/* sclookup - lookup the number associated with a start condition
*
* Returns 0 if no such start condition.
*/
int sclookup( str )
char str[];
{
return findsym( str, sctbl, START_COND_HASH_SIZE )->int_val;
}

View File

@ -1 +0,0 @@
#define FLEX_VERSION "2.5.4"

View File

@ -1,216 +0,0 @@
/* yylex - scanner front-end for flex */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Vern Paxson.
*
* The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California.
*
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* $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"
#include "parse.h"
/* yylex - scan for a regular expression token */
int yylex()
{
int toktype;
static int beglin = false;
extern char *yytext;
if ( eofseen )
toktype = EOF;
else
toktype = flexscan();
if ( toktype == EOF || toktype == 0 )
{
eofseen = 1;
if ( sectnum == 1 )
{
synerr( _( "premature EOF" ) );
sectnum = 2;
toktype = SECTEND;
}
else
toktype = 0;
}
if ( trace )
{
if ( beglin )
{
fprintf( stderr, "%d\t", num_rules + 1 );
beglin = 0;
}
switch ( toktype )
{
case '<':
case '>':
case '^':
case '$':
case '"':
case '[':
case ']':
case '{':
case '}':
case '|':
case '(':
case ')':
case '-':
case '/':
case '\\':
case '?':
case '.':
case '*':
case '+':
case ',':
(void) putc( toktype, stderr );
break;
case '\n':
(void) putc( '\n', stderr );
if ( sectnum == 2 )
beglin = 1;
break;
case SCDECL:
fputs( "%s", stderr );
break;
case XSCDECL:
fputs( "%x", stderr );
break;
case SECTEND:
fputs( "%%\n", stderr );
/* We set beglin to be true so we'll start
* writing out numbers as we echo rules.
* flexscan() has already assigned sectnum.
*/
if ( sectnum == 2 )
beglin = 1;
break;
case NAME:
fprintf( stderr, "'%s'", nmstr );
break;
case CHAR:
switch ( yylval )
{
case '<':
case '>':
case '^':
case '$':
case '"':
case '[':
case ']':
case '{':
case '}':
case '|':
case '(':
case ')':
case '-':
case '/':
case '\\':
case '?':
case '.':
case '*':
case '+':
case ',':
fprintf( stderr, "\\%c",
yylval );
break;
default:
if ( ! isascii( yylval ) ||
! isprint( yylval ) )
fprintf( stderr,
"\\%.3o",
(unsigned int) yylval );
else
(void) putc( yylval,
stderr );
break;
}
break;
case NUMBER:
fprintf( stderr, "%d", yylval );
break;
case PREVCCL:
fprintf( stderr, "[%d]", yylval );
break;
case EOF_OP:
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\n" ) );
break;
default:
fprintf( stderr,
_( "*Something Weird* - tok: %d val: %d\n" ),
toktype, yylval );
break;
}
}
return toktype;
}

1
version.h Normal file
View File

@ -0,0 +1 @@
#define FLEX_VERSION VERSION

211
yylex.c Normal file
View File

@ -0,0 +1,211 @@
/* yylex - scanner front-end for flex */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include <ctype.h>
#include "flexdef.h"
#include "parse.h"
/* yylex - scan for a regular expression token */
int yylex ()
{
int toktype;
static int beglin = false;
extern char *yytext;
if (eofseen)
toktype = EOF;
else
toktype = flexscan ();
if (toktype == EOF || toktype == 0) {
eofseen = 1;
if (sectnum == 1) {
synerr (_("premature EOF"));
sectnum = 2;
toktype = SECTEND;
}
else
toktype = 0;
}
if (trace) {
if (beglin) {
fprintf (stderr, "%d\t", num_rules + 1);
beglin = 0;
}
switch (toktype) {
case '<':
case '>':
case '^':
case '$':
case '"':
case '[':
case ']':
case '{':
case '}':
case '|':
case '(':
case ')':
case '-':
case '/':
case '\\':
case '?':
case '.':
case '*':
case '+':
case ',':
(void) putc (toktype, stderr);
break;
case '\n':
(void) putc ('\n', stderr);
if (sectnum == 2)
beglin = 1;
break;
case SCDECL:
fputs ("%s", stderr);
break;
case XSCDECL:
fputs ("%x", stderr);
break;
case SECTEND:
fputs ("%%\n", stderr);
/* We set beglin to be true so we'll start
* writing out numbers as we echo rules.
* flexscan() has already assigned sectnum.
*/
if (sectnum == 2)
beglin = 1;
break;
case NAME:
fprintf (stderr, "'%s'", nmstr);
break;
case CHAR:
switch (yylval) {
case '<':
case '>':
case '^':
case '$':
case '"':
case '[':
case ']':
case '{':
case '}':
case '|':
case '(':
case ')':
case '-':
case '/':
case '\\':
case '?':
case '.':
case '*':
case '+':
case ',':
fprintf (stderr, "\\%c", yylval);
break;
default:
if (!isascii (yylval) || !isprint (yylval))
fprintf (stderr,
"\\%.3o",
(unsigned int) yylval);
else
(void) putc (yylval, stderr);
break;
}
break;
case NUMBER:
fprintf (stderr, "%d", yylval);
break;
case PREVCCL:
fprintf (stderr, "[%d]", yylval);
break;
case EOF_OP:
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\n"));
break;
default:
fprintf (stderr,
_
("*Something Weird* - tok: %d val: %d\n"),
toktype, yylval);
break;
}
}
return toktype;
}