Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
581ef6d17f | ||
|
|
adddfba7ab | ||
|
|
6964073c59 | ||
|
|
935478c3fe | ||
|
|
a33e6fd5b4 | ||
|
|
8d4aa5ccaf | ||
|
|
7975c43384 | ||
|
|
6bea32e937 | ||
|
|
223f297825 | ||
|
|
44fa758931 | ||
|
|
713f5a0cb4 | ||
|
|
11c445cde9 | ||
|
|
99612781d9 | ||
|
|
5d71e9ffb9 | ||
|
|
347652c32b | ||
|
|
d374b87e68 | ||
|
|
c8ad3d682f | ||
|
|
0af671a275 | ||
|
|
14846e5e1a | ||
|
|
e1038db19a | ||
|
|
75f4305eed | ||
|
|
c503eaf061 | ||
|
|
92311a56b3 | ||
|
|
2bf2ad6d68 | ||
|
|
023cd4f754 | ||
|
|
31cc18ebd0 | ||
|
|
35d2fdfad1 | ||
|
|
2ecf674239 | ||
|
|
b02489f588 | ||
|
|
802cd0a6ed | ||
|
|
4bffa41e4e | ||
|
|
7dcb10c048 | ||
|
|
9a4ae5d619 | ||
|
|
2ad733a56e | ||
|
|
507f96a5ff | ||
|
|
17bf278ad7 | ||
|
|
9d3ddf572e | ||
|
|
735ffb6a65 | ||
|
|
ee87e5df00 | ||
|
|
749a8c80f7 | ||
|
|
fb91984b3b | ||
|
|
e50d903620 | ||
|
|
7528bc0aee | ||
|
|
b22b8fdb97 | ||
|
|
925549475e | ||
|
|
7878f90988 | ||
|
|
1b7a7165f3 | ||
|
|
98fd512f9a | ||
|
|
0cc66ab7fd | ||
|
|
0afeed389c | ||
|
|
2061043d3d | ||
|
|
84ca965d1f | ||
|
|
9f2343bf65 | ||
|
|
ad46bcf9cd | ||
|
|
e15146bbaa | ||
|
|
4db9c203f6 | ||
|
|
7cfb440c7c | ||
|
|
39cff7e239 | ||
|
|
07a1d30ba3 | ||
|
|
8d09d89c33 | ||
|
|
f57cb42c7d | ||
|
|
f1ce47684c | ||
|
|
babe9a1e8e | ||
|
|
c5d903dcda | ||
|
|
fab3f206e4 | ||
|
|
42325b8b39 | ||
|
|
e873499f32 | ||
|
|
0292299ec5 | ||
|
|
ed59d3e066 | ||
|
|
c2429b5a4a | ||
|
|
70b804fb02 | ||
|
|
676a62ec1e | ||
|
|
d112fbaf53 | ||
|
|
2da698f147 | ||
|
|
08fd44f453 | ||
|
|
f4be44b2b2 | ||
|
|
8756116ccb | ||
|
|
1da19feba7 | ||
|
|
197b523555 | ||
|
|
dc55016677 | ||
|
|
8c098febc9 | ||
|
|
cf4121fa97 | ||
|
|
3946924ed5 | ||
|
|
986bb5e294 | ||
|
|
33dd868353 | ||
|
|
3614d4c834 | ||
|
|
04c31bf09f | ||
|
|
48152721a0 | ||
|
|
bdc999cbc1 | ||
|
|
fb60d5a04e | ||
|
|
3d640d049d | ||
|
|
de3fb712c2 | ||
|
|
9160ceb67f | ||
|
|
00bc43fa04 | ||
|
|
c7b3db7957 | ||
|
|
598ba7fd4c | ||
|
|
e8e83d2dbe | ||
|
|
c2940d142b | ||
|
|
fe89a09e29 | ||
|
|
1d5b34b52a | ||
|
|
609af5775f | ||
|
|
455205b2e0 | ||
|
|
265e8e5c90 | ||
|
|
f951c3f8cc | ||
|
|
22d123c1fe | ||
|
|
d2c0374297 | ||
|
|
0f276adbb2 | ||
|
|
967819769e | ||
|
|
b7b9789469 | ||
|
|
2532a957a6 | ||
|
|
0f4684dd2a | ||
|
|
cc7d14899c | ||
|
|
860d7cfe15 | ||
|
|
ad994f507e | ||
|
|
4d6fb2187b | ||
|
|
519783bb98 | ||
|
|
318396d05a | ||
|
|
804efe8c42 | ||
|
|
80484ea267 | ||
|
|
aade6607e2 | ||
|
|
fd722d7030 | ||
|
|
bffbf1fa28 | ||
|
|
48fa65020f | ||
|
|
e66a12bbff | ||
|
|
3a132d28d9 | ||
|
|
71530afc7e | ||
|
|
9132612c2c | ||
|
|
f691a6345d | ||
|
|
458180116d | ||
|
|
aa4eac68e7 | ||
|
|
782ee061ec | ||
|
|
0e2b8c0f95 | ||
|
|
09fd5851bc | ||
|
|
a5cbe929ac | ||
|
|
7a7c3dfe1b | ||
|
|
de03dfb8fa | ||
|
|
a51bd6c301 | ||
|
|
4a8eccf830 | ||
|
|
d2a67ba6b7 | ||
|
|
dcf0226b06 | ||
|
|
647a92b9f4 | ||
|
|
64f2774378 | ||
|
|
1cc6c871f9 | ||
|
|
a7ff1b23a9 | ||
|
|
4936786fc5 | ||
|
|
24a1589f86 | ||
|
|
c351f39a2f | ||
|
|
3d1175b232 | ||
|
|
11ea8d73fc | ||
|
|
958ccda44e | ||
|
|
3efb40df0e | ||
|
|
5b856d1fa3 | ||
|
|
5d22149d43 | ||
|
|
145968f5e2 | ||
|
|
0e00f445a9 | ||
|
|
6fa7ed0446 | ||
|
|
64874cd464 | ||
|
|
5f6b7645e6 | ||
|
|
ed855892c7 | ||
|
|
aebf37aa12 | ||
|
|
c1c3b82b79 | ||
|
|
c918627e08 | ||
|
|
559d79d0f5 | ||
|
|
56f558ffef | ||
|
|
43f8adbe60 | ||
|
|
bfdef978fc | ||
|
|
4082a04921 | ||
|
|
ff622ae961 | ||
|
|
9acbb870c1 | ||
|
|
e05e093047 | ||
|
|
77e54b25ee | ||
|
|
13b5b214f5 | ||
|
|
c34590c4bf | ||
|
|
f863c9490e | ||
|
|
3a4af3424c | ||
|
|
965c9fa979 | ||
|
|
6f9cbd4af1 | ||
|
|
e5e5fb59c9 | ||
|
|
07d89829cc | ||
|
|
1e13e9656b | ||
|
|
d4e8f383e8 | ||
|
|
8205442c7c | ||
|
|
3d08a01292 | ||
|
|
0dfcb6228f | ||
|
|
d41be27501 | ||
|
|
7969134687 | ||
|
|
d95947343e | ||
|
|
1cc5d87032 | ||
|
|
c53d722b0b | ||
|
|
c03bef5411 | ||
|
|
53e3088d75 | ||
|
|
e0877888da | ||
|
|
3a1d84cfc0 | ||
|
|
a562291415 | ||
|
|
35a307f959 | ||
|
|
004399be12 | ||
|
|
4cea6bfe54 | ||
|
|
7ddfe81aa8 | ||
|
|
9e24fe5ea9 | ||
|
|
399e94f904 | ||
|
|
9ba6e5283e | ||
|
|
f1d53eb001 | ||
|
|
9e1ec519f4 | ||
|
|
a97cf48486 | ||
|
|
45db9033fe | ||
|
|
3bc38e963e | ||
|
|
0f7b9136ed | ||
|
|
09eae589d3 | ||
|
|
83d5d1695a | ||
|
|
d34b6160af | ||
|
|
5263986825 | ||
|
|
54201ab377 | ||
|
|
0be145eea8 | ||
|
|
4864c4f23a | ||
|
|
83006c65f8 | ||
|
|
b54685ff22 | ||
|
|
589bb43094 | ||
|
|
b382a56bf3 | ||
|
|
461f987f09 | ||
|
|
a6ceb756d9 | ||
|
|
cf6cb4dce7 | ||
|
|
1f4c0e67fe | ||
|
|
336a1deaa5 | ||
|
|
5acd407ed4 | ||
|
|
b4b8b7ed81 | ||
|
|
5f23fc0033 | ||
|
|
4f2ae90b28 | ||
|
|
b6fa146a0f | ||
|
|
341bfbd389 |
+3
-1
@@ -2,7 +2,7 @@
|
||||
*.rej
|
||||
*.tar.bz2
|
||||
*.tar.gz
|
||||
*.tar.xz
|
||||
*.tar.lz
|
||||
*~
|
||||
.deps
|
||||
.libs
|
||||
@@ -13,9 +13,11 @@ Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
autoscan.log
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
configure.scan
|
||||
flex-*/
|
||||
libtool
|
||||
stamp-*
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
This is a list of bugs still in the queue at lex.sf.net at the time we closed
|
||||
out the project and moved it to flex.sf.net.
|
||||
|
||||
-------------------------------------------------------------
|
||||
|
||||
Some strict compilers warn about a few internal flex variables signedness. They
|
||||
are bogus warnings and can be ignored, but people send in reports nonethless.
|
||||
|
||||
-------------------------------------------------------------
|
||||
|
||||
The initializer of the yy_transition array in the
|
||||
generated scanner
|
||||
contains fewer entries than the declared size of the array.
|
||||
|
||||
Examples include yy_transition[6504] with 6250 entries,
|
||||
yy_transition[13215] with 12961 entries. This looks
|
||||
like it
|
||||
is always 254 fewer entries than the declared size.
|
||||
|
||||
This bug is present in flex 2.5.4a as well. It appears to be harmless.
|
||||
|
||||
-------------------------------------------------------------
|
||||
The examples in the chapter "Generating C++ Scanners"
|
||||
contain suspicious code. Attached is a patch that
|
||||
corrects this, and after these
|
||||
modifications this example compiles and works.
|
||||
|
||||
-------------------------------------------------------------
|
||||
|
||||
C++ scanners derived from the yyFlexLexer base class
|
||||
will not compile with flex-2.5.31 because the
|
||||
<FlexLexer.h> automatically gets included into the
|
||||
scanner twice. Because yyFlexLexer is now defined by
|
||||
default even if no prefix is specified, including
|
||||
FlexLexer.h twice causes the class yyFlexLexer to be
|
||||
declared twice. In flex-2.5.4 because yyFlexLexer was
|
||||
not defined by flex in the scanner code, including
|
||||
FlexLexer.h more than once only declared yyFlexLexer
|
||||
once. I appreciate that this is because of the M4
|
||||
additions to flex, but I can not find a way to stop
|
||||
flex defining yyFlexLexer if it is not needed.
|
||||
|
||||
Here is an example of a class that will not compile:
|
||||
|
||||
derived_lexer.h:
|
||||
|
||||
#ifndef __derived_lexer__
|
||||
#define __derived_lexer__
|
||||
|
||||
#include <FlexLexer.h>
|
||||
|
||||
class derived_lexer : public yyFlexLexer
|
||||
{
|
||||
public:
|
||||
derived_lexer(std::istream* arg_yyin = 0) :
|
||||
yyFlexLexer(arg_yyin){}
|
||||
int yylex();
|
||||
int x;
|
||||
};
|
||||
#endif
|
||||
|
||||
derived_lexer.l:
|
||||
|
||||
%{
|
||||
#include "derived_lexer.h"
|
||||
%}
|
||||
|
||||
%option yyclass="derived_lexer"
|
||||
|
||||
%%
|
||||
[0-9]+ {
|
||||
x = atoi(yytext);
|
||||
}
|
||||
%%
|
||||
|
||||
main.cpp:
|
||||
|
||||
#include "derived_lexer.h"
|
||||
#include <fstream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ifstream input;
|
||||
input.open("input");
|
||||
derived_lexer lexer(&input);
|
||||
lexer.yylex();
|
||||
}
|
||||
|
||||
-------------------------------------------------------------
|
||||
|
||||
Hi, the anomally is that if I generate a c++ parser it will not make
|
||||
yy_scan_buffer and friends.
|
||||
this is happenning on flex version 2.5.4.
|
||||
Is this the intent, if so how do I make a c++ parser read from my buffer?
|
||||
|
||||
P.S. in c++ it will only generate:
|
||||
#ifndef YY_NO_SCAN_BUFFER
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef YY_NO_SCAN_STRING
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef YY_NO_SCAN_BYTES
|
||||
#endif
|
||||
-------------------------------------------------------------
|
||||
@@ -0,0 +1,5 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
This project adheres to No Code of Conduct. We are all adults. We accept anyone's contributions. Nothing else matters.
|
||||
|
||||
For more information please visit the [No Code of Conduct](https://github.com/domgetter/NCoC) homepage.
|
||||
+1
-6
@@ -27,11 +27,6 @@
|
||||
# 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.
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
indent = @INDENT@
|
||||
@@ -41,7 +36,7 @@ dist_doc_DATA = \
|
||||
COPYING \
|
||||
NEWS \
|
||||
ONEWS \
|
||||
README
|
||||
README.md
|
||||
|
||||
EXTRA_DIST = \
|
||||
.indent.pro \
|
||||
|
||||
@@ -3,7 +3,161 @@ changes between releases of flex.
|
||||
|
||||
See the file COPYING for copying conditions.
|
||||
|
||||
* version 2.6.0-pre
|
||||
* version 2.6.3 released 2016-12-30
|
||||
|
||||
** scanner
|
||||
|
||||
*** several bug fixes resolved problems introduced in recent flex
|
||||
versions regarding processing of comments, literals and various
|
||||
quoting scenarios.
|
||||
|
||||
*** If the path to m4 was sufficiently long, a buffer overflow could
|
||||
occur. This has been resolved. The fix also removes dependence on
|
||||
the constant PATH_MAX.
|
||||
|
||||
** build
|
||||
|
||||
*** A new configure option --disable-bootstrap changes the behavior of
|
||||
the build system when building flex. The default
|
||||
"--enable-bootstrap" behavior is to build flex, then to use that
|
||||
flex to build flex again. With --disable-bootstrap, the scanner is
|
||||
simply built by sedding the scanner source. This is friendlier to
|
||||
cross compilation.
|
||||
|
||||
*** The compatibility functions in lib/ are no longer built as a
|
||||
library. Instead, they are built as $(LIBOBJ) objects. This is
|
||||
simpler and friendlier to cross compilation.
|
||||
|
||||
*** It is now possible to build flex without building the accompanying
|
||||
libfl. This is friendlier to cross compilation. See the
|
||||
--disable-libfl option to configure. Resolves #99.
|
||||
|
||||
*** the PIC version of libfl was not correctly built. It is no longer
|
||||
included in the build/installation targets of flex since it was
|
||||
unused.
|
||||
|
||||
*** the distributed man page is only rebuilt when the relevant source
|
||||
files change or when the binary doesn't exist. In particular, this
|
||||
is friendlier to cross compilation. Resolves #108
|
||||
|
||||
** test
|
||||
|
||||
*** the shell scripts in the test suite are more portable across different shell implementations.
|
||||
|
||||
* version 2.6.2 released 2016-10-24
|
||||
|
||||
** flex internals
|
||||
|
||||
*** a segfalt involving yyrestart(NULL) has been fixed
|
||||
|
||||
*** flex should now handle quoting when mixed with m4 processing correctly
|
||||
|
||||
*** flex handles `[[' and `]]' correctly
|
||||
|
||||
*** flex no longer generates non-ANSI code
|
||||
|
||||
*** more compilation warnings were squashed in generated scanners
|
||||
|
||||
*** prevented a buffer overflow that could occur when input buffers were the exact wrong size
|
||||
|
||||
** test suite
|
||||
|
||||
*** input filenames on MSWindows are now calculated correctly
|
||||
|
||||
*** general code cleanups in a number of tests now make the test suite compile much more cleanly
|
||||
|
||||
** build system
|
||||
|
||||
*** the xz archive has been replaced with an lzip archive
|
||||
|
||||
*** a new option to configure --enable-warnings to encapsulate passing
|
||||
of warning-related flags which is useful in testing flex
|
||||
|
||||
*** make indent now works for out of source builds
|
||||
|
||||
*** Portability warnings when generating Makefile.in files are now suppressed; they were just noise and the use of GNU extensions in Makefile.{am,in,} was intentional and well known.
|
||||
|
||||
** bugs
|
||||
|
||||
*** resolved gh#67
|
||||
|
||||
** new sv translation from the translation project
|
||||
|
||||
* version 2.6.1 released 2016-03-01
|
||||
|
||||
** flex resources
|
||||
|
||||
*** The flex project is now hosted at github. Consider this a "period of transition". In particular, you should start at https://github.com/westes/flex for the flex codebase, issue tracking and pull requests.
|
||||
|
||||
*** New releases of flex are to be found at https://github.com/westes/flex/releases.
|
||||
|
||||
** flex internals
|
||||
|
||||
*** Flex now uses more modern and more standard names for variable types. There's more work to be done on that front yet, though.
|
||||
|
||||
*** A number of compiler warnings have been remedied.
|
||||
|
||||
*** Line directives should now work as expected and be absent when that is expected.
|
||||
|
||||
** test suite
|
||||
|
||||
*** When running the test suite, c++ files are compiled with the c++ header inside the flex distribution, rather than relying on the build system's flex header , which might not be installed yet or which might be out of date with respect to what flex tests expect.
|
||||
|
||||
*** Some portability fixes in the test suite such as opening files for reading in binary mode
|
||||
|
||||
** Building flex
|
||||
|
||||
*** The file src/scan.c asdistributed with flex source is now built with the current version of flex. Occasionally this had to be done manually to pick up new flex features. It's now just a part of flex's build system.
|
||||
|
||||
*** The pdf version of the manual is no longer distributed with flex, although if you have the texinfo package installed, you can still build it.
|
||||
|
||||
*** lots of general build system cleanup
|
||||
|
||||
*** the build system tries a bit harder to find libtoolize and texi2dvi.
|
||||
|
||||
*** When help2man and texi2dvi are missing, the error messages are now much more helpful.
|
||||
|
||||
** bug fixes
|
||||
|
||||
*** resolved github issues #53, #54, #55, #61.
|
||||
|
||||
*** Resolved sf bugs #128, #129, #155, #160, #184, #187, #195.
|
||||
|
||||
* version 2.6.0 released 2015-11-17
|
||||
|
||||
** User Visible Changes
|
||||
|
||||
*** C++ scanners now use references instead of pointers. See the manual for details.
|
||||
|
||||
*** A number of compiler warnings were addressed, so flex generated scanners should be quieter under compiler warning scenarios.
|
||||
|
||||
*** Allow error reporting routines to accept varying number of arguments
|
||||
|
||||
*** Removed deprecated 'register' storage class specifier
|
||||
|
||||
*** Changeed output formats from octal to hexadecimal
|
||||
|
||||
*** check limits before using array index cclp; resolves sf-166
|
||||
|
||||
*** Suppress clang warning about empty @param paragraph; resolves sf#158
|
||||
|
||||
*** Fixed malloc/realloc replacement, resolves sf bug#151.
|
||||
|
||||
*** Adjusted buffer sizes on ia64.
|
||||
|
||||
*** various documentation and code clean up fixes: resolves sf bugs #167, #168, among other patches.
|
||||
|
||||
** Flex Internals
|
||||
|
||||
*** flex is now organized into subdirectories. This keeps the tree neater at the top level and puts like things near each other and unlike things away from each other.
|
||||
|
||||
*** The test suite has been reorganized and is now run with the parallel test suite harness from automake.
|
||||
|
||||
*** Cleaned up the automake parts of the build system to better reflect what automake does on its own. Also added a call to libtoolize in autogen.sh because autoreconf gets confused without a prior run of libtoolize.
|
||||
|
||||
*** po/Makefile now includes a rule to fetch the latest translations from the translation project. "make -f po/Makefile getpo" from the top level of the flex tree will fetch the files.
|
||||
|
||||
*** New da translation from the translation project
|
||||
|
||||
* flex version 2.5.39 released 2014-03-26
|
||||
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
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 for
|
||||
flex at:
|
||||
|
||||
http://sourceforge.net/tracker/?group_id=97492&atid=618177
|
||||
|
||||
The flex codebase is kept in git at:
|
||||
|
||||
https://github.com/westes/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
|
||||
|
||||
Find information on subscribing to the mailing lists at:
|
||||
|
||||
http://sourceforge.net/mail/?group_id=97492
|
||||
|
||||
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.
|
||||
|
||||
You need the following tools to build flex from the maintainer's
|
||||
repository:
|
||||
|
||||
compiler suite - flex is built with gcc
|
||||
bash, or a good Bourne-style shell
|
||||
m4 - m4 -p needs to work; GNU m4 and a few others are suitable
|
||||
GNU bison; to generate parse.c from parse.y
|
||||
autoconf 2.69; for handling the build system
|
||||
automake 1.12.2; for Makefile generation
|
||||
gettext 0.18; fori18n support
|
||||
help2man 1.36; to generate the flex man page
|
||||
tar, gzip, etc.; for packaging of the source distribution
|
||||
GNU texinfo 498; to build and test the flex manual
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
This is flex, the fast lexical analyzer generator.
|
||||
|
||||
flex is a tool for generating scanners: programs which recognize
|
||||
lexical patterns in text.
|
||||
|
||||
The flex codebase is kept in
|
||||
[Git on GitHub.](https://github.com/westes/flex)
|
||||
|
||||
Use GitHub's [issues](https://github.com/westes/flex/issues) and
|
||||
[pull request](https://github.com/westes/flex) features to file bugs
|
||||
and submit patches.
|
||||
|
||||
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
|
||||
|
||||
Find information on subscribing to the mailing lists at:
|
||||
|
||||
http://sourceforge.net/mail/?group_id=97492
|
||||
|
||||
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.
|
||||
* tests/ - regression tests. See TESTS/README for details.
|
||||
* po/ - internationalization support files.
|
||||
|
||||
You need the following tools to build flex from the maintainer's
|
||||
repository:
|
||||
|
||||
* compiler suite - flex is built with gcc
|
||||
* bash, or a good Bourne-style shell
|
||||
* m4 - m4 -p needs to work; GNU m4 and a few others are suitable
|
||||
* GNU bison; to generate parse.c from parse.y
|
||||
* autoconf; for handling the build system
|
||||
* automake; for Makefile generation
|
||||
* gettext; for i18n support
|
||||
* help2man; to generate the flex man page
|
||||
* tar, gzip, lzip, etc.; for packaging of the source distribution
|
||||
* GNU texinfo; to build and test the flex manual. Note that if you want
|
||||
to build the dvi/ps/pdf versions of the documentation you will need
|
||||
texi2dvi and related programs, along with a sufficiently powerful
|
||||
implementation of TeX to process them. See your operating system
|
||||
documentation for how to achieve this. The printable versions of the
|
||||
manual are not built unless specifically requested, but the targets
|
||||
are included by automake.
|
||||
* GNU indent; for indenting the flex source the way we want it done
|
||||
|
||||
In cases where the versions of the above tools matter, the file
|
||||
configure.ac will specify the minimum required versions.
|
||||
|
||||
Once you have all the necessary tools installed, life becomes
|
||||
simple. To prepare the flex tree for building, run the script:
|
||||
|
||||
```bash
|
||||
./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 routine:
|
||||
|
||||
```bash
|
||||
configure && make && make install
|
||||
```
|
||||
|
||||
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.
|
||||
@@ -1,66 +0,0 @@
|
||||
* 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.
|
||||
|
||||
* 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++
|
||||
|
||||
** revisit the C++ API. We get requests to make it more complete.
|
||||
|
||||
Local Variables:
|
||||
Mode: text
|
||||
mode: outline-minor
|
||||
End:
|
||||
+2
-1
@@ -29,4 +29,5 @@
|
||||
#Makefile first.)
|
||||
|
||||
touch ChangeLog
|
||||
autoreconf --install --verbose --force
|
||||
libtoolize --install --force || glibtoolize --install --force
|
||||
autoreconf --install --force
|
||||
|
||||
+64
-11
@@ -24,15 +24,14 @@
|
||||
|
||||
# autoconf requirements and initialization
|
||||
|
||||
AC_INIT([the fast lexical analyser generator], [2.6.0-pre],
|
||||
[flex-help@lists.sourceforge.net], [flex])
|
||||
AC_INIT([the fast lexical analyser generator],[2.6.3],[flex-help@lists.sourceforge.net],[flex])
|
||||
AC_CONFIG_SRCDIR([src/scan.l])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AM_INIT_AUTOMAKE([gnu check-news std-options dist-bzip2 dist-xz parallel-tests 1.14.1])
|
||||
LT_INIT
|
||||
AM_INIT_AUTOMAKE([-Wno-portability foreign check-news std-options dist-lzip parallel-tests subdir-objects 1.14.1])
|
||||
AC_CONFIG_HEADER([src/config.h])
|
||||
AC_CONFIG_LIBOBJ_DIR([lib])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
LT_INIT
|
||||
SHARED_VERSION_INFO="2:0:0"
|
||||
AC_SUBST(SHARED_VERSION_INFO)
|
||||
|
||||
@@ -49,8 +48,48 @@ AC_PROG_LN_S
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_PATH_PROG(BISON, bison,bison)
|
||||
AC_PATH_PROG(HELP2MAN, help2man, help2man)
|
||||
# allow passing a variable `WARNINGFLAGS',
|
||||
# either when invoking `configure', or when invoking `make'
|
||||
# default to something useful if GCC was detected
|
||||
|
||||
AC_ARG_ENABLE([warnings],
|
||||
[AS_HELP_STRING([--enable-warnings],
|
||||
[enable a bunch of compiler warning flags (defaults to GCC warning flags).])],
|
||||
[AS_IF([test "x$GCC" = xyes],
|
||||
[ : ${WARNINGFLAGS="-Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wconversion -Wno-unused-but-set-variable"} ])])
|
||||
|
||||
AC_SUBST([WARNINGFLAGS])
|
||||
|
||||
AC_ARG_ENABLE([libfl],
|
||||
[AS_HELP_STRING([--disable-libfl],
|
||||
[do not build -lfl runtime support library])],
|
||||
[], [enable_libfl=yes])
|
||||
AM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes])
|
||||
|
||||
# --disable-bootstrap is intended only to workaround problems with bootstrap
|
||||
# (e.g. when cross-compiling flex or when bootstrapping has bugs).
|
||||
# Ideally we should be able to bootstrap even when cross-compiling.
|
||||
AC_ARG_ENABLE([bootstrap],
|
||||
[AS_HELP_STRING([--disable-bootstrap],
|
||||
[don't perform a bootstrap when building flex])],
|
||||
[], [enable_bootstrap=yes])
|
||||
AM_CONDITIONAL([ENABLE_BOOTSTRAP], [test "x$enable_bootstrap" = xyes])
|
||||
|
||||
AC_PATH_PROG([BISON], bison, no)
|
||||
AS_IF([test "$BISON" != no],[],
|
||||
[ AC_SUBST([BISON], [\${top_srcdir}/build-aux/missing bison])
|
||||
AC_MSG_NOTICE(no bison program found: only required for maintainers)
|
||||
])
|
||||
|
||||
AC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man])
|
||||
AS_IF([test "$HELP2MAN" = "\${top_srcdir}/build-aux/missing help2man"],
|
||||
AC_MSG_WARN(help2man: program not found: building man page will not work)
|
||||
)
|
||||
|
||||
AC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi])
|
||||
AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"],
|
||||
AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work)
|
||||
)
|
||||
|
||||
# Check for a m4 that supports -P
|
||||
|
||||
@@ -79,9 +118,7 @@ fi
|
||||
|
||||
# checks for headers
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h regex.h stddef.h stdlib.h string.h strings.h unistd.h])
|
||||
AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h regex.h unistd.h])
|
||||
|
||||
# checks for libraries
|
||||
|
||||
@@ -94,7 +131,7 @@ AC_DEFINE([HAVE_LIBPTHREAD], 1, [pthread library] ),
|
||||
AC_DEFINE([HAVE_LIBPTHREAD], 0, [pthread library] )
|
||||
)
|
||||
AC_CHECK_HEADERS([pthread.h])
|
||||
AM_CONDITIONAL([want_pthread], [test x$ac_cv_lib_pthread_pthread_mutex_lock = xyes])
|
||||
AM_CONDITIONAL([want_pthread], [test "x$ac_cv_lib_pthread_pthread_mutex_lock" = xyes])
|
||||
|
||||
AC_CHECK_LIB(m, log10)
|
||||
|
||||
@@ -108,9 +145,25 @@ AC_TYPE_SIZE_T
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_FORK
|
||||
dnl Autoconf bug: AC_FUNC_MALLOC and AC_FUNC_REALLOC might not warn of cross
|
||||
dnl compilation. Workaround this.
|
||||
AC_FUNC_MALLOC
|
||||
AS_IF([test "$cross_compiling" = yes],
|
||||
AC_MSG_WARN([result $ac_cv_func_malloc_0_nonnull guessed because of cross compilation]))
|
||||
AC_FUNC_REALLOC
|
||||
AC_CHECK_FUNCS([dup2 isascii memset pow regcomp setlocale strchr strtol])
|
||||
AS_IF([test "$cross_compiling" = yes],
|
||||
AC_MSG_WARN([result $ac_cv_func_realloc_0_nonnull guessed because of cross compilation]))
|
||||
|
||||
AC_CHECK_FUNCS(dup2 dnl
|
||||
memset dnl
|
||||
pow dnl
|
||||
regcomp dnl
|
||||
setlocale dnl
|
||||
strchr dnl
|
||||
strdup dnl
|
||||
strtol)
|
||||
|
||||
AC_REPLACE_FUNCS(reallocarray)
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
Makefile
|
||||
|
||||
+8
-7
@@ -1,8 +1,10 @@
|
||||
help2man = @HELP2MAN@
|
||||
|
||||
FLEX = $(top_builddir)/src/flex$(EXEEXT)
|
||||
|
||||
info_TEXINFOS = flex.texi
|
||||
dist_man_MANS = flex.1
|
||||
dist_doc_DATA= flex.pdf
|
||||
MAINTAINERCLEANFILES = flex.1
|
||||
|
||||
CLEANFILES = \
|
||||
flex.aux \
|
||||
@@ -23,9 +25,8 @@ CLEANFILES = \
|
||||
flex.vr \
|
||||
flex.vrs
|
||||
|
||||
$(dist_man_MANS): $(top_srcdir)/src/main.c
|
||||
for i in $(dist_man_MANS) ; do \
|
||||
$(help2man) --name='$(PACKAGE_NAME)' \
|
||||
--section=`echo $$i | sed -e 's/.*\.\([^.]*\)$$/\1/'` \
|
||||
$(top_srcdir)/src/flex$(EXEEXT) > $$i || rm -f $$i ; \
|
||||
done
|
||||
flex.1: $(top_srcdir)/configure.ac $(top_srcdir)/src/flex.skl $(top_srcdir)/src/options.c $(top_srcdir)/src/options.h | $(FLEX)
|
||||
$(help2man) --name='$(PACKAGE_NAME)' --section=1 \
|
||||
--source='The Flex Project' --manual='Programming' \
|
||||
--output=$@ $(FLEX) \
|
||||
|| rm -f $@
|
||||
|
||||
+26
-25
@@ -296,8 +296,7 @@ Indices
|
||||
@cindex reporting bugs
|
||||
|
||||
If you find a bug in @code{flex}, please report it using
|
||||
the SourceForge Bug Tracking facilities which can be found on
|
||||
@url{http://sourceforge.net/projects/flex,flex's SourceForge Page}.
|
||||
GitHub's issue tracking facility at @url{https://github.com/westes/flex/issues/}
|
||||
|
||||
@node Introduction, Simple Examples, Reporting Bugs, Top
|
||||
@chapter Introduction
|
||||
@@ -409,7 +408,7 @@ A somewhat more complicated example:
|
||||
|
||||
"+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext );
|
||||
|
||||
"{"[\^{}}\n]*"}" /* eat up one-line comments */
|
||||
"{"[^{}\n]*"}" /* eat up one-line comments */
|
||||
|
||||
[ \t\n]+ /* eat up whitespace */
|
||||
|
||||
@@ -1492,15 +1491,14 @@ the scanning routine using a K&R-style/non-prototyped function
|
||||
declaration, you must terminate the definition with a semi-colon (;).
|
||||
|
||||
@code{flex} generates @samp{C99} function definitions by
|
||||
default. However flex does have the ability to generate obsolete, er,
|
||||
@samp{traditional}, function definitions. This is to support
|
||||
default. Flex used to have the ability to generate obsolete, er,
|
||||
@samp{traditional}, function definitions. This was to support
|
||||
bootstrapping gcc on old systems. Unfortunately, traditional
|
||||
definitions prevent us from using any standard data types smaller than
|
||||
int (such as short, char, or bool) as function arguments. For this
|
||||
reason, future versions of @code{flex} may generate standard C99 code
|
||||
only, leaving K&R-style functions to the historians. Currently, if you
|
||||
do @strong{not} want @samp{C99} definitions, then you must use
|
||||
@code{%option noansi-definitions}.
|
||||
int (such as short, char, or bool) as function arguments. Furthermore,
|
||||
traditional definitions support added extra complexity in the skeleton file.
|
||||
For this reason, current versions of @code{flex} generate standard C99 code
|
||||
only, leaving K&R-style functions to the historians.
|
||||
|
||||
@cindex stdin, default for yyin
|
||||
@cindex yyin
|
||||
@@ -2861,19 +2859,13 @@ calls @code{yylex()} again).
|
||||
@opindex ---option-ansi-definitions
|
||||
@opindex ansi-definitions
|
||||
@item --ansi-definitions, @code{%option ansi-definitions}
|
||||
instruct flex to generate ANSI C99 definitions for functions.
|
||||
This option is enabled by default.
|
||||
If @code{%option noansi-definitions} is specified, then the obsolete style
|
||||
is generated.
|
||||
Deprecated, ignored
|
||||
|
||||
@anchor{option-ansi-prototypes}
|
||||
@opindex ---option-ansi-prototypes
|
||||
@opindex ansi-prototypes
|
||||
@item --ansi-prototypes, @code{%option ansi-prototypes}
|
||||
instructs flex to generate ANSI C99 prototypes for functions.
|
||||
This option is enabled by default.
|
||||
If @code{noansi-prototypes} is specified, then
|
||||
prototypes will have empty parameter lists.
|
||||
Deprecated, ignored
|
||||
|
||||
@anchor{option-bison-bridge}
|
||||
@opindex ---bison-bridge
|
||||
@@ -3764,8 +3756,7 @@ defaults to generating the scanner to the file @file{lex.yy.cc} instead
|
||||
of @file{lex.yy.c}. The generated scanner includes the header file
|
||||
@file{FlexLexer.h}, which defines the interface to two C++ classes.
|
||||
|
||||
The first class,
|
||||
@code{FlexLexer},
|
||||
The first class in @file{FlexLexer.h}, @code{FlexLexer},
|
||||
provides an abstract base class defining the general scanner class
|
||||
interface. It provides the following member functions:
|
||||
|
||||
@@ -3799,10 +3790,10 @@ returns the current setting of the debugging flag.
|
||||
|
||||
Also provided are member functions equivalent to
|
||||
@code{yy_switch_to_buffer()}, @code{yy_create_buffer()} (though the
|
||||
first argument is an @code{istream*} object pointer and not a
|
||||
first argument is an @code{istream&} object reference and not a
|
||||
@code{FILE*)}, @code{yy_flush_buffer()}, @code{yy_delete_buffer()}, and
|
||||
@code{yyrestart()} (again, the first argument is a @code{istream*}
|
||||
object pointer).
|
||||
@code{yyrestart()} (again, the first argument is a @code{istream&}
|
||||
object reference).
|
||||
|
||||
@tindex yyFlexLexer (C++ only)
|
||||
@tindex FlexLexer (C++ only)
|
||||
@@ -3813,9 +3804,12 @@ additional member functions:
|
||||
@table @code
|
||||
@findex yyFlexLexer constructor (C++ only)
|
||||
@item yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 )
|
||||
@item yyFlexLexer( istream& arg_yyin, ostream& arg_yyout )
|
||||
constructs a @code{yyFlexLexer} object using the given streams for input
|
||||
and output. If not specified, the streams default to @code{cin} and
|
||||
@code{cout}, respectively.
|
||||
@code{cout}, respectively. @code{yyFlexLexer} does not take ownership of
|
||||
its stream arguments. It's up to the user to ensure the streams pointed
|
||||
to remain alive at least as long as the @code{yyFlexLexer} instance.
|
||||
|
||||
@findex yylex (C++ version)
|
||||
@item virtual int yylex()
|
||||
@@ -3832,11 +3826,13 @@ instead of @code{yyFlexLexer}. In this case, rather than generating
|
||||
|
||||
@findex switch_streams (C++ only)
|
||||
@item virtual void switch_streams(istream* new_in = 0, ostream* new_out = 0)
|
||||
@item virtual void switch_streams(istream& new_in, ostream& new_out)
|
||||
reassigns @code{yyin} to @code{new_in} (if non-null) and @code{yyout} to
|
||||
@code{new_out} (if non-null), deleting the previous input buffer if
|
||||
@code{yyin} is reassigned.
|
||||
|
||||
@item int yylex( istream* new_in, ostream* new_out = 0 )
|
||||
@item int yylex( istream& new_in, ostream& new_out )
|
||||
first switches the input streams via @code{switch_streams( new_in,
|
||||
new_out )} and then returns the value of @code{yylex()}.
|
||||
@end table
|
||||
@@ -3893,7 +3889,7 @@ Here is an example of a simple C++ scanner:
|
||||
int mylineno = 0;
|
||||
%}
|
||||
|
||||
%option noyywrap
|
||||
%option noyywrap c++
|
||||
|
||||
string \"[^\n"]+\"
|
||||
|
||||
@@ -3938,6 +3934,9 @@ Here is an example of a simple C++ scanner:
|
||||
|
||||
%%
|
||||
|
||||
// This include is required if main() is an another source file.
|
||||
//#include <FlexLexer.h>
|
||||
|
||||
int main( int /* argc */, char** /* argv */ )
|
||||
{
|
||||
FlexLexer* lexer = new yyFlexLexer;
|
||||
@@ -4910,8 +4909,10 @@ custom allocator through @code{yyextra}.
|
||||
%option reentrant
|
||||
|
||||
/* Initialize the allocator. */
|
||||
%{
|
||||
#define YY_EXTRA_TYPE struct allocator*
|
||||
#define YY_USER_INIT yyextra = allocator_create();
|
||||
%}
|
||||
|
||||
%%
|
||||
.|\n ;
|
||||
|
||||
@@ -39,13 +39,13 @@ number {num1}|{num2}
|
||||
}
|
||||
}
|
||||
|
||||
{number} FLEX_STD cout << "number " << YYText() << '\n';
|
||||
{number} std::cout << "number " << YYText() << '\n';
|
||||
|
||||
\n mylineno++;
|
||||
|
||||
{name} FLEX_STD cout << "name " << YYText() << '\n';
|
||||
{name} std::cout << "name " << YYText() << '\n';
|
||||
|
||||
{string} FLEX_STD cout << "string " << YYText() << '\n';
|
||||
{string} std::cout << "string " << YYText() << '\n';
|
||||
|
||||
%%
|
||||
|
||||
|
||||
+3
-4
@@ -1,4 +1,3 @@
|
||||
noinst_LTLIBRARIES = libcompat.la
|
||||
libcompat_la_SOURCES = lib.c
|
||||
libcompat_la_LIBADD = $(LTLIBOBJS)
|
||||
|
||||
# Files in the lib/ subdirectory are picked up as needed by the flex
|
||||
# build system. As such, we don't need to specify anything beyond
|
||||
# having a Makefile.am for automake to generate a Makefile.in from.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Since building an empty library could cause problems, we provide a
|
||||
* function to go into the library. We could make this non-trivial by
|
||||
* moving something that flex treats as a library function into this
|
||||
* directory. */
|
||||
|
||||
void do_nothing(){ return;}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/stdlib/reallocarray.c */
|
||||
|
||||
#include <config.h>
|
||||
#ifndef HAVE_REALLOCARRAY
|
||||
#undef reallocarray
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
void *reallocarray(void *, size_t, size_t);
|
||||
|
||||
/*
|
||||
* This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
|
||||
* if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
|
||||
*/
|
||||
#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
|
||||
|
||||
void *
|
||||
reallocarray(void *optr, size_t nmemb, size_t size)
|
||||
{
|
||||
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
|
||||
nmemb > 0 && SIZE_MAX / nmemb < size) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
return realloc(optr, size * nmemb);
|
||||
}
|
||||
#endif /* HAVE_REALLOCARRAY */
|
||||
@@ -12,7 +12,6 @@ src/options.c
|
||||
src/parse.y
|
||||
src/scan.l
|
||||
src/scanopt.c
|
||||
src/skel.c
|
||||
src/sym.c
|
||||
src/tblcmp.c
|
||||
src/yylex.c
|
||||
|
||||
@@ -2,20 +2,37 @@
|
||||
# Copyright (C) 2007 The Flex Project (msgids)
|
||||
# This file is distributed under the same license as the flex package.
|
||||
# Johan Linde <jl@theophys.kth.se>, 1996.
|
||||
# Keld Simonsen <keld@keldix.com>, 2000-2011.
|
||||
# Keld Simonsen <keld@keldix.com>, 2000-2011, 2015.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: flex-2.5.35\n"
|
||||
"Project-Id-Version: flex-2.5.38\n"
|
||||
"Report-Msgid-Bugs-To: flex-devel@lists.sourceforge.net\n"
|
||||
"POT-Creation-Date: 2008-02-26 16:34-0500\n"
|
||||
"PO-Revision-Date: 2011-01-11 09:12+0100\n"
|
||||
"POT-Creation-Date: 2014-02-11 16:15-0500\n"
|
||||
"PO-Revision-Date: 2015-04-26 09:12+0200\n"
|
||||
"Last-Translator: Keld Simonsen <keld@keldix.com>\n"
|
||||
"Language-Team: Danish <dansk@dansk-gruppen.dk>\n"
|
||||
"Language: da\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=ISO-8859-1\n"
|
||||
"Content-Transfer-Encoding: 8-bit\n"
|
||||
|
||||
#: buf.c:78
|
||||
msgid "Allocation of buffer to print string failed"
|
||||
msgstr "Tildeling af buffer til udskrivningsstreng mislykkedes"
|
||||
|
||||
#: buf.c:100
|
||||
msgid "Allocation of buffer for line directive failed"
|
||||
msgstr "Tildeling af buffer til linjedirektiv mislykkedes"
|
||||
|
||||
#: buf.c:177
|
||||
msgid "Allocation of buffer for m4 def failed"
|
||||
msgstr "Tildeling af buffer til m4 def mislykkedes"
|
||||
|
||||
#: buf.c:197
|
||||
msgid "Allocation of buffer for m4 undef failed"
|
||||
msgstr "Tildeling af buffer til m4 undef mislykkedes"
|
||||
|
||||
#: dfa.c:61
|
||||
#, c-format
|
||||
msgid "State #%d is non-accepting -\n"
|
||||
@@ -75,7 +92,7 @@ msgstr "tilstand %d:\n"
|
||||
msgid "Could not write yynxt_tbl[][]"
|
||||
msgstr "Kunne ikke skrive yynxt_tbl[][]"
|
||||
|
||||
#: dfa.c:1052
|
||||
#: dfa.c:1049
|
||||
msgid "bad transition character detected in sympartition()"
|
||||
msgstr "forkert overgangstegn fundet i sympartition()"
|
||||
|
||||
@@ -159,353 +176,357 @@ msgstr "Kunne ikke skrive eoltbl"
|
||||
msgid "Could not write yynultrans_tbl"
|
||||
msgstr "Kunne ikke skrive yynultrans_tbl"
|
||||
|
||||
#: main.c:189
|
||||
#: main.c:191
|
||||
msgid "rule cannot be matched"
|
||||
msgstr "reglen kan ikke matches"
|
||||
|
||||
#: main.c:194
|
||||
#: main.c:196
|
||||
msgid "-s option given but default rule can be matched"
|
||||
msgstr "flaget -s angivet, men standardreglen kan følges"
|
||||
|
||||
#: main.c:234
|
||||
#: main.c:236
|
||||
msgid "Can't use -+ with -l option"
|
||||
msgstr "-+ kan ikke bruges sammen med flaget -l"
|
||||
|
||||
#: main.c:237
|
||||
#: main.c:239
|
||||
msgid "Can't use -f or -F with -l option"
|
||||
msgstr "-f eller -F kan ikke bruges sammen med -l"
|
||||
|
||||
#: main.c:241
|
||||
#: main.c:243
|
||||
msgid "Can't use --reentrant or --bison-bridge with -l option"
|
||||
msgstr "Kan ikke bruge --reentrant eller --bison-bridge sammen med flaget -l"
|
||||
|
||||
#: main.c:278
|
||||
#: main.c:275
|
||||
msgid "-Cf/-CF and -Cm don't make sense together"
|
||||
msgstr "-Cf/-CF og -Cm kan ikke bruges sammen"
|
||||
|
||||
#: main.c:281
|
||||
#: main.c:278
|
||||
msgid "-Cf/-CF and -I are incompatible"
|
||||
msgstr "-Cf/-CF og -I kan ikke bruges sammen"
|
||||
|
||||
#: main.c:285
|
||||
#: main.c:282
|
||||
msgid "-Cf/-CF are incompatible with lex-compatibility mode"
|
||||
msgstr "-Cf/-CF kan ikke bruges i lex-kompatibilitetstilstand"
|
||||
|
||||
#: main.c:290
|
||||
#: main.c:287
|
||||
msgid "-Cf and -CF are mutually exclusive"
|
||||
msgstr "-Cf og -CF er gensidigt udelukkende"
|
||||
|
||||
#: main.c:294
|
||||
#: main.c:291
|
||||
msgid "Can't use -+ with -CF option"
|
||||
msgstr "-+ kan ikke bruges sammen med flaget -CF"
|
||||
|
||||
#: main.c:297
|
||||
#: main.c:294
|
||||
#, c-format
|
||||
msgid "%array incompatible with -+ option"
|
||||
msgstr "-+ kan ikke bruges sammen med %array"
|
||||
|
||||
#: main.c:302
|
||||
#: main.c:299
|
||||
msgid "Options -+ and --reentrant are mutually exclusive."
|
||||
msgstr "Flagene -+ og --reentrant er gensidigt udelukkende."
|
||||
|
||||
#: main.c:305
|
||||
#: main.c:302
|
||||
msgid "bison bridge not supported for the C++ scanner."
|
||||
msgstr "bisonbro understøttes ikke for C++-skanneren."
|
||||
|
||||
#: main.c:360 main.c:406
|
||||
#: main.c:357 main.c:403
|
||||
#, c-format
|
||||
msgid "could not create %s"
|
||||
msgstr "kunne ikke oprette %s"
|
||||
|
||||
#: main.c:419
|
||||
#: main.c:416
|
||||
msgid "could not write tables header"
|
||||
msgstr "kunne ikke skrive tabellhoved"
|
||||
|
||||
#: main.c:423
|
||||
#: main.c:420
|
||||
#, c-format
|
||||
msgid "can't open skeleton file %s"
|
||||
msgstr "kan ikke åbne skabelonfilen %s"
|
||||
|
||||
#: main.c:505
|
||||
#: main.c:456
|
||||
msgid "allocation of macro definition failed"
|
||||
msgstr "tildeling af makro-definition mislykkedes"
|
||||
|
||||
#: main.c:504
|
||||
#, c-format
|
||||
msgid "input error reading skeleton file %s"
|
||||
msgstr "fejl ved læsning af skabelonsfilen %s"
|
||||
|
||||
#: main.c:509
|
||||
#: main.c:508
|
||||
#, c-format
|
||||
msgid "error closing skeleton file %s"
|
||||
msgstr "fejl ved lukning af skabelonfilen %s"
|
||||
|
||||
#: main.c:694
|
||||
#: main.c:693
|
||||
#, c-format
|
||||
msgid "error creating header file %s"
|
||||
msgstr "fejl ved oprettelsen af headerfilen %s"
|
||||
|
||||
#: main.c:702
|
||||
#: main.c:701
|
||||
#, c-format
|
||||
msgid "error writing output file %s"
|
||||
msgstr "fejl ved skrivning af udfilen %s"
|
||||
|
||||
#: main.c:706
|
||||
#: main.c:705
|
||||
#, c-format
|
||||
msgid "error closing output file %s"
|
||||
msgstr "fejl ved lukning af udfilen %s"
|
||||
|
||||
#: main.c:710
|
||||
#: main.c:709
|
||||
#, c-format
|
||||
msgid "error deleting output file %s"
|
||||
msgstr "fejl ved sletning af udfilen %s"
|
||||
|
||||
#: main.c:717
|
||||
#: main.c:716
|
||||
#, c-format
|
||||
msgid "No backing up.\n"
|
||||
msgstr "Ingen sikkerhedskopiering.\n"
|
||||
|
||||
#: main.c:721
|
||||
#: main.c:720
|
||||
#, c-format
|
||||
msgid "%d backing up (non-accepting) states.\n"
|
||||
msgstr "%d sikkerhedskopierer (ikke-accepterende) tilstande.\n"
|
||||
|
||||
#: main.c:725
|
||||
#: main.c:724
|
||||
#, c-format
|
||||
msgid "Compressed tables always back up.\n"
|
||||
msgstr "Komprimerete tabeller backer alltid tillbaka.\n"
|
||||
|
||||
#: main.c:728
|
||||
#: main.c:727
|
||||
#, c-format
|
||||
msgid "error writing backup file %s"
|
||||
msgstr "fejl ved skrivning af sikkerhedskopifilen %s"
|
||||
|
||||
#: main.c:732
|
||||
#: main.c:731
|
||||
#, c-format
|
||||
msgid "error closing backup file %s"
|
||||
msgstr "fejl ved lukning af sikerhedskopifilen %s"
|
||||
|
||||
#: main.c:737
|
||||
#: main.c:736
|
||||
#, c-format
|
||||
msgid "%s version %s usage statistics:\n"
|
||||
msgstr "Statistik over brugaf %s version %s:\n"
|
||||
|
||||
#: main.c:740
|
||||
#: main.c:739
|
||||
#, c-format
|
||||
msgid " scanner options: -"
|
||||
msgstr " fortolkningsflag: -"
|
||||
|
||||
#: main.c:819
|
||||
#: main.c:818
|
||||
#, c-format
|
||||
msgid " %d/%d NFA states\n"
|
||||
msgstr " %d/%d NFA-tilstand\n"
|
||||
|
||||
#: main.c:821
|
||||
#: main.c:820
|
||||
#, c-format
|
||||
msgid " %d/%d DFA states (%d words)\n"
|
||||
msgstr " %d/%d DFA-tilstand (%d ord)\n"
|
||||
|
||||
#: main.c:823
|
||||
#: main.c:822
|
||||
#, c-format
|
||||
msgid " %d rules\n"
|
||||
msgstr " %d regler\n"
|
||||
|
||||
#: main.c:828
|
||||
#: main.c:827
|
||||
#, c-format
|
||||
msgid " No backing up\n"
|
||||
msgstr " Ingen sikkerhedskopiering\n"
|
||||
|
||||
#: main.c:832
|
||||
#: main.c:831
|
||||
#, c-format
|
||||
msgid " %d backing-up (non-accepting) states\n"
|
||||
msgstr " %d sikkerhedskopierer (ikke-accepterende) tilstande.\n"
|
||||
|
||||
#: main.c:837
|
||||
#: main.c:836
|
||||
#, c-format
|
||||
msgid " Compressed tables always back-up\n"
|
||||
msgstr " Komprimerede tabeller bakker altid tilbake\n"
|
||||
|
||||
#: main.c:841
|
||||
#: main.c:840
|
||||
#, c-format
|
||||
msgid " Beginning-of-line patterns used\n"
|
||||
msgstr " Begyndelse-af-linje-mønster brugt\n"
|
||||
|
||||
#: main.c:843
|
||||
#: main.c:842
|
||||
#, c-format
|
||||
msgid " %d/%d start conditions\n"
|
||||
msgstr " %d/%d startbetingelse\n"
|
||||
|
||||
#: main.c:847
|
||||
#: main.c:846
|
||||
#, c-format
|
||||
msgid " %d epsilon states, %d double epsilon states\n"
|
||||
msgstr " %d epsilontilstande, %d dobbelte epsilontilstande\n"
|
||||
|
||||
#: main.c:851
|
||||
#: main.c:850
|
||||
#, c-format
|
||||
msgid " no character classes\n"
|
||||
msgstr " ingen tegnklasser\n"
|
||||
|
||||
#: main.c:855
|
||||
#: main.c:854
|
||||
#, c-format
|
||||
msgid " %d/%d character classes needed %d/%d words of storage, %d reused\n"
|
||||
msgstr " %d/%d tegnklasser behøvede %d/%d ord for gemning, %d genbrugte\n"
|
||||
|
||||
#: main.c:860
|
||||
#: main.c:859
|
||||
#, c-format
|
||||
msgid " %d state/nextstate pairs created\n"
|
||||
msgstr " %d par med tilstand/næste-tilstand oprettede\n"
|
||||
|
||||
#: main.c:863
|
||||
#: main.c:862
|
||||
#, c-format
|
||||
msgid " %d/%d unique/duplicate transitions\n"
|
||||
msgstr " %d/%d unikke/duplikerede overgange\n"
|
||||
|
||||
#: main.c:868
|
||||
#: main.c:867
|
||||
#, c-format
|
||||
msgid " %d table entries\n"
|
||||
msgstr " %d tabelposter\n"
|
||||
|
||||
#: main.c:876
|
||||
#: main.c:875
|
||||
#, c-format
|
||||
msgid " %d/%d base-def entries created\n"
|
||||
msgstr " %d/%d base/standard-poster oprettede\n"
|
||||
|
||||
#: main.c:880
|
||||
#: main.c:879
|
||||
#, c-format
|
||||
msgid " %d/%d (peak %d) nxt-chk entries created\n"
|
||||
msgstr " %d/%d (max %d) næste/test-poster oprettede\n"
|
||||
|
||||
#: main.c:884
|
||||
#: main.c:883
|
||||
#, c-format
|
||||
msgid " %d/%d (peak %d) template nxt-chk entries created\n"
|
||||
msgstr " %d/%d (max %d) skablon-næste/test-poster oprettede\n"
|
||||
|
||||
#: main.c:888
|
||||
#: main.c:887
|
||||
#, c-format
|
||||
msgid " %d empty table entries\n"
|
||||
msgstr " %d tomme tabelposter\n"
|
||||
|
||||
#: main.c:890
|
||||
#: main.c:889
|
||||
#, c-format
|
||||
msgid " %d protos created\n"
|
||||
msgstr " %d prototyper oprettede\n"
|
||||
|
||||
#: main.c:893
|
||||
#: main.c:892
|
||||
#, c-format
|
||||
msgid " %d templates created, %d uses\n"
|
||||
msgstr " %d skabloner oprettede, %d formål\n"
|
||||
|
||||
#: main.c:901
|
||||
#: main.c:900
|
||||
#, c-format
|
||||
msgid " %d/%d equivalence classes created\n"
|
||||
msgstr " %d/%d ækvivalensklasser oprettet\n"
|
||||
|
||||
#: main.c:909
|
||||
#: main.c:908
|
||||
#, c-format
|
||||
msgid " %d/%d meta-equivalence classes created\n"
|
||||
msgstr " %d/%d meta-ækvivalensklasser oprettede\n"
|
||||
|
||||
#: main.c:915
|
||||
#: main.c:914
|
||||
#, c-format
|
||||
msgid " %d (%d saved) hash collisions, %d DFAs equal\n"
|
||||
msgstr " %d (%d gemte) hash-kollisioner, %d DFA'er er ens\n"
|
||||
|
||||
#: main.c:917
|
||||
#: main.c:916
|
||||
#, c-format
|
||||
msgid " %d sets of reallocations needed\n"
|
||||
msgstr " %d opsætninger med omallokeringer krævedes\n"
|
||||
|
||||
#: main.c:919
|
||||
#: main.c:918
|
||||
#, c-format
|
||||
msgid " %d total table entries needed\n"
|
||||
msgstr " %d totale tabelposter kræves\n"
|
||||
|
||||
#: main.c:996
|
||||
#: main.c:995
|
||||
#, c-format
|
||||
msgid "Internal error. flexopts are malformed.\n"
|
||||
msgstr "Intern fejl. flexopts er fejlbehæftede.\n"
|
||||
|
||||
#: main.c:1006
|
||||
#: main.c:1005
|
||||
#, c-format
|
||||
msgid "Try `%s --help' for more information.\n"
|
||||
msgstr "Prøv '%s --help' for mere information.\n"
|
||||
|
||||
#: main.c:1063
|
||||
#: main.c:1062
|
||||
#, c-format
|
||||
msgid "unknown -C option '%c'"
|
||||
msgstr "ukendt flag til -C '%c'"
|
||||
|
||||
#: main.c:1192
|
||||
#: main.c:1191
|
||||
#, c-format
|
||||
msgid "%s %s\n"
|
||||
msgstr "%s %s\n"
|
||||
|
||||
#: main.c:1467
|
||||
#: main.c:1466
|
||||
msgid "fatal parse error"
|
||||
msgstr "uoprettelig fejl ved analysen"
|
||||
|
||||
#: main.c:1499
|
||||
#: main.c:1498
|
||||
#, c-format
|
||||
msgid "could not create backing-up info file %s"
|
||||
msgstr "kunne ikke oprette sikkerhedskopi af info-fil %s"
|
||||
|
||||
#: main.c:1520
|
||||
#: main.c:1519
|
||||
#, c-format
|
||||
msgid "-l AT&T lex compatibility option entails a large performance penalty\n"
|
||||
msgstr "flaget -l for opførsel som AT&T's lex medfører et væsentligt præstationstab\n"
|
||||
|
||||
#: main.c:1523
|
||||
#: main.c:1522
|
||||
#, c-format
|
||||
msgid " and may be the actual source of other reported performance penalties\n"
|
||||
msgstr " og kan være den egentlige årsag til andre rapporter om dette\n"
|
||||
|
||||
#: main.c:1529
|
||||
#: main.c:1528
|
||||
#, c-format
|
||||
msgid "%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n"
|
||||
msgstr "%%option yylineno medfører et præstationstab KUN på regler der kan matche nylinje-tegn\n"
|
||||
|
||||
#: main.c:1536
|
||||
#: main.c:1535
|
||||
#, c-format
|
||||
msgid "-I (interactive) entails a minor performance penalty\n"
|
||||
msgstr "-I (interaktiv) medfører et mindre præstationstab\n"
|
||||
|
||||
#: main.c:1541
|
||||
#: main.c:1540
|
||||
#, c-format
|
||||
msgid "yymore() entails a minor performance penalty\n"
|
||||
msgstr "yymore() medfører et mindre præstationstab\n"
|
||||
|
||||
#: main.c:1547
|
||||
#: main.c:1546
|
||||
#, c-format
|
||||
msgid "REJECT entails a large performance penalty\n"
|
||||
msgstr "REJECT medfører et væsentligt præstationstab\n"
|
||||
|
||||
#: main.c:1552
|
||||
#: main.c:1551
|
||||
#, c-format
|
||||
msgid "Variable trailing context rules entail a large performance penalty\n"
|
||||
msgstr "Regler for variabel efterfølgende kontekst medfører et væsentlig præstationstab\n"
|
||||
|
||||
#: main.c:1564
|
||||
#: main.c:1563
|
||||
msgid "REJECT cannot be used with -f or -F"
|
||||
msgstr "REJECT kan ikke bruges sammen med -f eller -F"
|
||||
|
||||
#: main.c:1567
|
||||
#: main.c:1566
|
||||
#, c-format
|
||||
msgid "%option yylineno cannot be used with REJECT"
|
||||
msgstr "%option yylineno kan ikke bruges sammen med REJECT"
|
||||
|
||||
#: main.c:1570
|
||||
#: main.c:1569
|
||||
msgid "variable trailing context rules cannot be used with -f or -F"
|
||||
msgstr ""
|
||||
"regler for variabel efterfølgende kontekst kan ikke bruges\n"
|
||||
"sammen med -f eller -F"
|
||||
|
||||
#: main.c:1691
|
||||
#: main.c:1692
|
||||
#, c-format
|
||||
msgid "%option yyclass only meaningful for C++ scanners"
|
||||
msgstr "%option yyclass er kun meningsfyldt for C++-fortolkere"
|
||||
|
||||
#: main.c:1798
|
||||
#: main.c:1799
|
||||
#, c-format
|
||||
msgid "Usage: %s [OPTIONS] [FILE]...\n"
|
||||
msgstr "Brug: %s [FLAG] [FIL]...\n"
|
||||
|
||||
#: main.c:1801
|
||||
#: main.c:1802
|
||||
#, c-format
|
||||
msgid ""
|
||||
"Generates programs that perform pattern-matching on text.\n"
|
||||
@@ -630,43 +651,47 @@ msgstr ""
|
||||
" -h, --help udskriv denne hjælpebesked\n"
|
||||
" -V, --version udskriv %s version\n"
|
||||
|
||||
#: misc.c:100 misc.c:126
|
||||
#: misc.c:65
|
||||
msgid "allocation of sko_stack failed"
|
||||
msgstr "tildeling af sko_stack mislykkedes"
|
||||
|
||||
#: misc.c:102 misc.c:128
|
||||
#, c-format
|
||||
msgid "name \"%s\" ridiculously long"
|
||||
msgstr "navnet '%s' er latterligt langt"
|
||||
|
||||
#: misc.c:175
|
||||
#: misc.c:177
|
||||
msgid "memory allocation failed in allocate_array()"
|
||||
msgstr "hukommelsestildelingen mislykkedes i allocate_array()"
|
||||
|
||||
#: misc.c:250
|
||||
#: misc.c:230
|
||||
#, c-format
|
||||
msgid "bad character '%s' detected in check_char()"
|
||||
msgstr "forkert tegn '%s' fundet i check_char()"
|
||||
|
||||
#: misc.c:255
|
||||
#: misc.c:235
|
||||
#, c-format
|
||||
msgid "scanner requires -8 flag to use the character %s"
|
||||
msgstr "skanneren kræver flaget -8 for at kunne bruge tegnet %s"
|
||||
|
||||
#: misc.c:288
|
||||
#: misc.c:268
|
||||
msgid "dynamic memory failure in copy_string()"
|
||||
msgstr "dynamisk hukommelsesfejl i copy_string()"
|
||||
|
||||
#: misc.c:422
|
||||
#: misc.c:367
|
||||
#, c-format
|
||||
msgid "%s: fatal internal error, %s\n"
|
||||
msgstr "%s: uoprettelig intern fejl, %s\n"
|
||||
|
||||
#: misc.c:875
|
||||
#: misc.c:803
|
||||
msgid "attempt to increase array size failed"
|
||||
msgstr "forsøg på at øge arraystørrelse mislykkedes"
|
||||
|
||||
#: misc.c:1002
|
||||
#: misc.c:930
|
||||
msgid "bad line in skeleton file"
|
||||
msgstr "forkert linje i skeletfilen"
|
||||
|
||||
#: misc.c:1051
|
||||
#: misc.c:979
|
||||
msgid "memory allocation failed in yy_flex_xmalloc()"
|
||||
msgstr "hukommelsestildelingen mislykkedes i yy_flex_xmalloc()"
|
||||
|
||||
@@ -700,20 +725,20 @@ msgstr "tom maskine i dupmachine()"
|
||||
msgid "Variable trailing context rule at line %d\n"
|
||||
msgstr "Regel for variabel efterfølgende kontekst på linje %d\n"
|
||||
|
||||
#: nfa.c:353
|
||||
#: nfa.c:364
|
||||
msgid "bad state type in mark_beginning_as_normal()"
|
||||
msgstr "forkert tilstandstype i mark_beginning_as_normal()"
|
||||
|
||||
#: nfa.c:598
|
||||
#: nfa.c:609
|
||||
#, c-format
|
||||
msgid "input rules are too complicated (>= %d NFA states)"
|
||||
msgstr "inddatareglerne er for komplicerede (>= %d NFA-tilstand)"
|
||||
|
||||
#: nfa.c:677
|
||||
#: nfa.c:688
|
||||
msgid "found too many transitions in mkxtion()"
|
||||
msgstr "fandt for mange overgange i mkxtion()"
|
||||
|
||||
#: nfa.c:703
|
||||
#: nfa.c:714
|
||||
#, c-format
|
||||
msgid "too many rules (> %d)!"
|
||||
msgstr "for mange regler (> %d)!"
|
||||
@@ -742,24 +767,24 @@ msgstr "fejlagtige iterationsv
|
||||
msgid "iteration value must be positive"
|
||||
msgstr "iterationsværdi skal være positiv"
|
||||
|
||||
#: parse.y:806 parse.y:816
|
||||
#: parse.y:804 parse.y:814
|
||||
#, c-format
|
||||
msgid "the character range [%c-%c] is ambiguous in a case-insensitive scanner"
|
||||
msgstr "tegnintervallet [%c-%c] er flertydigt i en versalufølsom skanner"
|
||||
|
||||
#: parse.y:821
|
||||
#: parse.y:819
|
||||
msgid "negative range in character class"
|
||||
msgstr "negativt interval i tegnklasse"
|
||||
|
||||
#: parse.y:918
|
||||
#: parse.y:916
|
||||
msgid "[:^lower:] is ambiguous in case insensitive scanner"
|
||||
msgstr "[:^lower:] er flertydigt i en versalufølsom skanner"
|
||||
|
||||
#: parse.y:924
|
||||
#: parse.y:922
|
||||
msgid "[:^upper:] ambiguous in case insensitive scanner"
|
||||
msgstr "[:^upper:] er flertydigt i en versalufølsom skanner"
|
||||
|
||||
#: scan.l:75 scan.l:192 scan.l:300 scan.l:443 scan.l:618 scan.l:676
|
||||
#: scan.l:75 scan.l:618 scan.l:676
|
||||
msgid "Input line too long\n"
|
||||
msgstr "For lang inddatalinje\n"
|
||||
|
||||
@@ -773,14 +798,27 @@ msgstr "fejlagtigt '%top'-direktiv"
|
||||
msgid "unrecognized '%' directive"
|
||||
msgstr "ukendt '%'-direktiv"
|
||||
|
||||
#: scan.l:192
|
||||
msgid "Definition name too long\n"
|
||||
msgstr "For langt definitionsnavn\n"
|
||||
|
||||
#: scan.l:284
|
||||
msgid "Unmatched '{'"
|
||||
msgstr "Ensomt '{'"
|
||||
|
||||
#: scan.l:300
|
||||
#, c-format
|
||||
msgid "Definition value for {%s} too long\n"
|
||||
msgstr "Definitionsværdi for (%s) for langt\n"
|
||||
|
||||
#: scan.l:317
|
||||
msgid "incomplete name definition"
|
||||
msgstr "ufuldstændig navnedefinition"
|
||||
|
||||
#: scan.l:443
|
||||
msgid "Option line too long\n"
|
||||
msgstr "For lang valgmulighedslinje\n"
|
||||
|
||||
#: scan.l:451
|
||||
#, c-format
|
||||
msgid "unrecognized %%option: %s"
|
||||
@@ -840,27 +878,27 @@ msgstr "kan ikke
|
||||
msgid "Usage: %s [OPTIONS]...\n"
|
||||
msgstr "Brug: %s [FLAG]...\n"
|
||||
|
||||
#: scanopt.c:565
|
||||
#: scanopt.c:564
|
||||
#, c-format
|
||||
msgid "option `%s' doesn't allow an argument\n"
|
||||
msgstr "flaget '%s' tager ikke noget argument\n"
|
||||
|
||||
#: scanopt.c:570
|
||||
#: scanopt.c:569
|
||||
#, c-format
|
||||
msgid "option `%s' requires an argument\n"
|
||||
msgstr "flaget '%s' kræver et argument\n"
|
||||
|
||||
#: scanopt.c:574
|
||||
#: scanopt.c:573
|
||||
#, c-format
|
||||
msgid "option `%s' is ambiguous\n"
|
||||
msgstr "flaget '%s' er flertydig\n"
|
||||
|
||||
#: scanopt.c:578
|
||||
#: scanopt.c:577
|
||||
#, c-format
|
||||
msgid "Unrecognized option `%s'\n"
|
||||
msgstr "Ukendt flag: '%s'\n"
|
||||
|
||||
#: scanopt.c:582
|
||||
#: scanopt.c:581
|
||||
#, c-format
|
||||
msgid "Unknown error=(%d)\n"
|
||||
msgstr "Ukendt fejl=(%d)\n"
|
||||
|
||||
+523
-314
File diff suppressed because it is too large
Load Diff
@@ -8,3 +8,5 @@ parse.c
|
||||
parse.h
|
||||
scan.c
|
||||
skel.c
|
||||
stage1scan.[cl]
|
||||
stage1flex
|
||||
|
||||
+116
-102
@@ -35,67 +35,74 @@
|
||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define __FLEX_LEXER_H
|
||||
|
||||
#include <iostream>
|
||||
# ifndef FLEX_STD
|
||||
# define FLEX_STD std::
|
||||
# endif
|
||||
|
||||
extern "C++" {
|
||||
|
||||
struct yy_buffer_state;
|
||||
typedef int yy_state_type;
|
||||
|
||||
class FlexLexer {
|
||||
class FlexLexer
|
||||
{
|
||||
public:
|
||||
virtual ~FlexLexer() { }
|
||||
virtual ~FlexLexer() { }
|
||||
|
||||
const char* YYText() const { return yytext; }
|
||||
int YYLeng() const { 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( FLEX_STD istream* s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
||||
virtual void yyrestart( FLEX_STD istream* s ) = 0;
|
||||
virtual void
|
||||
yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0;
|
||||
virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0;
|
||||
virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( yy_buffer_state* b ) = 0;
|
||||
virtual void yyrestart( std::istream* s ) = 0;
|
||||
virtual void yyrestart( std::istream& s ) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( std::istream& new_in, std::ostream& new_out )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( FLEX_STD istream* new_in = 0,
|
||||
FLEX_STD ostream* new_out = 0 ) = 0;
|
||||
int yylex( std::istream* new_in, std::ostream* new_out = 0)
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
int lineno() const { return yylineno; }
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( std::istream* new_in,
|
||||
std::ostream* new_out ) = 0;
|
||||
virtual void switch_streams( std::istream& new_in,
|
||||
std::ostream& new_out ) = 0;
|
||||
|
||||
int debug() const { return yy_flex_debug; }
|
||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
||||
int lineno() const { return yylineno; }
|
||||
|
||||
int debug() const { return yy_flex_debug; }
|
||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
||||
|
||||
protected:
|
||||
char* yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
char* yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
};
|
||||
|
||||
}
|
||||
@@ -105,102 +112,109 @@ protected:
|
||||
// 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 manual.
|
||||
#define yyFlexLexerOnce
|
||||
# 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( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
|
||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
||||
// only make that assignment when initializing in yylex().
|
||||
yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout );
|
||||
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
|
||||
private:
|
||||
void ctor_common();
|
||||
|
||||
virtual ~yyFlexLexer();
|
||||
public:
|
||||
|
||||
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
|
||||
struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
|
||||
void yy_delete_buffer( struct yy_buffer_state* b );
|
||||
void yyrestart( FLEX_STD istream* s );
|
||||
virtual ~yyFlexLexer();
|
||||
|
||||
void yypush_buffer_state( struct yy_buffer_state* new_buffer );
|
||||
void yypop_buffer_state();
|
||||
void yy_switch_to_buffer( yy_buffer_state* new_buffer );
|
||||
yy_buffer_state* yy_create_buffer( std::istream* s, int size );
|
||||
yy_buffer_state* yy_create_buffer( std::istream& s, int size );
|
||||
void yy_delete_buffer( yy_buffer_state* b );
|
||||
void yyrestart( std::istream* s );
|
||||
void yyrestart( std::istream& s );
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
|
||||
virtual int yywrap();
|
||||
void yypush_buffer_state( yy_buffer_state* new_buffer );
|
||||
void yypop_buffer_state();
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( std::istream& new_in, std::ostream& new_out );
|
||||
virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 );
|
||||
virtual int yywrap();
|
||||
|
||||
protected:
|
||||
virtual int LexerInput( char* buf, int max_size );
|
||||
virtual void LexerOutput( const char* buf, int size );
|
||||
virtual void LexerError( const char* msg );
|
||||
virtual int LexerInput( char* buf, int max_size );
|
||||
virtual void LexerOutput( const char* buf, int size );
|
||||
virtual void LexerError( const char* msg );
|
||||
|
||||
void yyunput( int c, char* buf_ptr );
|
||||
int yyinput();
|
||||
void yyunput( int c, char* buf_ptr );
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
|
||||
void yy_flush_buffer( struct yy_buffer_state* b );
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer( yy_buffer_state* b, std::istream& s );
|
||||
void yy_flush_buffer( yy_buffer_state* b );
|
||||
|
||||
int yy_start_stack_ptr;
|
||||
int yy_start_stack_depth;
|
||||
int* yy_start_stack;
|
||||
int yy_start_stack_ptr;
|
||||
int yy_start_stack_depth;
|
||||
int* yy_start_stack;
|
||||
|
||||
void yy_push_state( int new_state );
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
void yy_push_state( int new_state );
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_buffer();
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_buffer();
|
||||
|
||||
FLEX_STD istream* yyin; // input source for default LexerInput
|
||||
FLEX_STD ostream* yyout; // output sink for default LexerOutput
|
||||
std::istream yyin; // input source for default LexerInput
|
||||
std::ostream yyout; // output sink for default LexerOutput
|
||||
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
|
||||
// Points to current character in buffer.
|
||||
char* yy_c_buf_p;
|
||||
// Points to current character in buffer.
|
||||
char* yy_c_buf_p;
|
||||
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
||||
int yy_did_buffer_switch_on_eof;
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// 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);
|
||||
size_t yy_buffer_stack_top; /**< index of top of stack. */
|
||||
size_t yy_buffer_stack_max; /**< capacity of stack. */
|
||||
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()).
|
||||
// The following are not always needed, but may be depending
|
||||
// on use of certain flex features (like REJECT or yymore()).
|
||||
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char* yy_last_accepting_cpos;
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char* yy_last_accepting_cpos;
|
||||
|
||||
yy_state_type* yy_state_buf;
|
||||
yy_state_type* yy_state_ptr;
|
||||
yy_state_type* yy_state_buf;
|
||||
yy_state_type* yy_state_ptr;
|
||||
|
||||
char* yy_full_match;
|
||||
int* yy_full_state;
|
||||
int yy_full_lp;
|
||||
char* yy_full_match;
|
||||
int* yy_full_state;
|
||||
int yy_full_lp;
|
||||
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // yyFlexLexer || ! yyFlexLexerOnce
|
||||
|
||||
|
||||
+70
-66
@@ -1,60 +1,67 @@
|
||||
AM_YFLAGS = -d
|
||||
localedir = $(datadir)/locale
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/intl
|
||||
LIBS = @LIBINTL@ @LIBS@
|
||||
LIBS = @LIBS@
|
||||
|
||||
m4 = @M4@
|
||||
|
||||
bin_PROGRAMS = flex
|
||||
lib_LTLIBRARIES = \
|
||||
libfl.la \
|
||||
libfl_pic.la
|
||||
if ENABLE_BOOTSTRAP
|
||||
noinst_PROGRAMS = stage1flex
|
||||
endif
|
||||
|
||||
if ENABLE_LIBFL
|
||||
lib_LTLIBRARIES = libfl.la
|
||||
endif
|
||||
libfl_la_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
libfl_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
|
||||
|
||||
stage1flex_SOURCES = \
|
||||
scan.l \
|
||||
$(COMMON_SOURCES)
|
||||
|
||||
stage1flex_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
flex_SOURCES = \
|
||||
$(COMMON_SOURCES)
|
||||
|
||||
nodist_flex_SOURCES = \
|
||||
stage1scan.c
|
||||
|
||||
flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS)
|
||||
|
||||
COMMON_SOURCES = \
|
||||
buf.c \
|
||||
ccl.c \
|
||||
dfa.c \
|
||||
ecs.c \
|
||||
scanflags.c \
|
||||
filter.c \
|
||||
flexdef.h \
|
||||
flexint.h \
|
||||
gen.c \
|
||||
main.c \
|
||||
misc.c \
|
||||
nfa.c \
|
||||
options.c \
|
||||
options.h \
|
||||
parse.y \
|
||||
scan.l \
|
||||
regex.c \
|
||||
scanflags.c \
|
||||
scanopt.c \
|
||||
scanopt.h \
|
||||
skel.c \
|
||||
sym.c \
|
||||
tblcmp.c \
|
||||
yylex.c \
|
||||
options.c \
|
||||
scanopt.c \
|
||||
buf.c \
|
||||
tables.c \
|
||||
tables_shared.c \
|
||||
filter.c \
|
||||
regex.c
|
||||
|
||||
LDADD = ../lib/libcompat.la
|
||||
|
||||
libfl_la_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
|
||||
libfl_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@
|
||||
|
||||
libfl_pic_la_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
|
||||
libfl_pic_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@
|
||||
|
||||
noinst_HEADERS = \
|
||||
flexdef.h \
|
||||
flexint.h \
|
||||
version.h \
|
||||
options.h \
|
||||
scanopt.h \
|
||||
tables.h \
|
||||
tables_shared.h
|
||||
tables_shared.c \
|
||||
tables_shared.h \
|
||||
tblcmp.c \
|
||||
version.h \
|
||||
yylex.c
|
||||
|
||||
LDADD = $(LIBOBJS) @LIBINTL@
|
||||
|
||||
include_HEADERS = \
|
||||
FlexLexer.h
|
||||
@@ -64,38 +71,34 @@ EXTRA_DIST = \
|
||||
mkskel.sh \
|
||||
gettext.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
skel.c
|
||||
CLEANFILES = stage1scan.c stage1flex$(EXEEXT)
|
||||
|
||||
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
|
||||
MAINTAINERCLEANFILES = 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
|
||||
skel.c: flex.skl mkskel.sh flexint.h tables_shared.h tables_shared.c
|
||||
sed 's/4_/a4_/g; s/m4preproc_/m4_/g' $< | \
|
||||
$(m4) -P -I $(srcdir) \
|
||||
-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 .` | \
|
||||
$(SHELL) $(srcdir)/mkskel.sh > $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
if ENABLE_BOOTSTRAP
|
||||
stage1scan.c: scan.l stage1flex$(EXEEXT)
|
||||
./stage1flex$(EXEEXT) $(AM_LFLAGS) $(LFLAGS) -o $@ $<
|
||||
else
|
||||
stage1scan.c: scan.c
|
||||
sed 's|^\(#line .*\)"'`printf %s $< | sed 's|[][\\\\.*]|\\\\&|g'`'"|\1"$@"|g' $< > $@
|
||||
endif
|
||||
|
||||
# make needs to be told to make parse.h so that parallelized runs will
|
||||
# not fail.
|
||||
|
||||
main.c: parse.h
|
||||
yylex.c: parse.h
|
||||
stage1flex-scan.$(OBJEXT): parse.h
|
||||
flex-stage1scan.$(OBJEXT): parse.h
|
||||
|
||||
# Run GNU indent on sources. Don't run this unless all the sources compile cleanly.
|
||||
#
|
||||
@@ -137,6 +140,7 @@ indent:
|
||||
for f in $(indentfiles);\
|
||||
do\
|
||||
echo indenting $$f ;\
|
||||
f='$(srcdir)'/$$f; \
|
||||
$(indent) < $$f >/dev/null && indent $$f || echo $$f FAILED to indent ;\
|
||||
done \
|
||||
fi
|
||||
|
||||
@@ -73,12 +73,13 @@ 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);
|
||||
tsz = strlen(fmt) + strlen(s) + 1;
|
||||
t = malloc(tsz);
|
||||
if (!t)
|
||||
flexfatal (_("Allocation of buffer to print string failed"));
|
||||
snprintf (t, tsz, fmt, s);
|
||||
buf = buf_strappend (buf, t);
|
||||
flex_free (t);
|
||||
free(t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -92,21 +93,26 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
|
||||
{
|
||||
char *dst, *t;
|
||||
const char *src;
|
||||
size_t tsz;
|
||||
|
||||
t = flex_alloc (strlen ("#line \"\"\n") + /* constant parts */
|
||||
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
|
||||
(int) (1 + log10 (abs (lineno))) + /* line number */
|
||||
1); /* NUL */
|
||||
if (gen_line_dirs)
|
||||
return buf;
|
||||
|
||||
tsz = strlen("#line \"\"\n") + /* constant parts */
|
||||
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
|
||||
(size_t) (1 + ceil (log10 (abs (lineno)))) + /* line number */
|
||||
1; /* NUL */
|
||||
t = malloc(tsz);
|
||||
if (!t)
|
||||
flexfatal (_("Allocation of buffer for line directive failed"));
|
||||
for (dst = t + sprintf (t, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
|
||||
for (dst = t + snprintf (t, tsz, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
|
||||
if (*src == '\\') /* escape backslashes */
|
||||
*dst++ = '\\';
|
||||
*dst++ = '"';
|
||||
*dst++ = '\n';
|
||||
*dst = '\0';
|
||||
buf = buf_strappend (buf, t);
|
||||
flex_free (t);
|
||||
free(t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -124,10 +130,7 @@ struct Buf *buf_concat(struct Buf* dest, const struct Buf* src)
|
||||
|
||||
|
||||
/* Appends n characters in str to buf. */
|
||||
struct Buf *buf_strnappend (buf, str, n)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
int n;
|
||||
struct Buf *buf_strnappend (struct Buf *buf, const char *str, int n)
|
||||
{
|
||||
buf_append (buf, str, n + 1);
|
||||
|
||||
@@ -138,18 +141,13 @@ struct Buf *buf_strnappend (buf, str, n)
|
||||
}
|
||||
|
||||
/* Appends characters in str to buf. */
|
||||
struct Buf *buf_strappend (buf, str)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
struct Buf *buf_strappend (struct Buf *buf, const char *str)
|
||||
{
|
||||
return buf_strnappend (buf, str, strlen (str));
|
||||
return buf_strnappend (buf, str, (int) strlen (str));
|
||||
}
|
||||
|
||||
/* appends "#define str def\n" */
|
||||
struct Buf *buf_strdefine (buf, str, def)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
const char *def;
|
||||
struct Buf *buf_strdefine (struct Buf *buf, const char *str, const char *def)
|
||||
{
|
||||
buf_strappend (buf, "#define ");
|
||||
buf_strappend (buf, " ");
|
||||
@@ -168,12 +166,13 @@ struct Buf *buf_strdefine (buf, str, def)
|
||||
*/
|
||||
struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
|
||||
{
|
||||
const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
|
||||
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);
|
||||
strsz = strlen(fmt) + strlen(def) + strlen(val) + 2;
|
||||
str = malloc(strsz);
|
||||
if (!str)
|
||||
flexfatal (_("Allocation of buffer for m4 def failed"));
|
||||
|
||||
@@ -193,7 +192,8 @@ struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
|
||||
char * str;
|
||||
size_t strsz;
|
||||
|
||||
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + 2);
|
||||
strsz = strlen(fmt) + strlen(def) + 2;
|
||||
str = malloc(strsz);
|
||||
if (!str)
|
||||
flexfatal (_("Allocation of buffer for m4 undef failed"));
|
||||
|
||||
@@ -203,23 +203,21 @@ struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
|
||||
}
|
||||
|
||||
/* create buf with 0 elements, each of size elem_size. */
|
||||
void buf_init (buf, elem_size)
|
||||
struct Buf *buf;
|
||||
size_t elem_size;
|
||||
void buf_init (struct Buf *buf, size_t elem_size)
|
||||
{
|
||||
buf->elts = (void *) 0;
|
||||
buf->elts = NULL;
|
||||
buf->nelts = 0;
|
||||
buf->elt_size = elem_size;
|
||||
buf->nmax = 0;
|
||||
}
|
||||
|
||||
/* frees memory */
|
||||
void buf_destroy (buf)
|
||||
struct Buf *buf;
|
||||
void buf_destroy (struct Buf *buf)
|
||||
{
|
||||
if (buf && buf->elts)
|
||||
flex_free (buf->elts);
|
||||
buf->elts = (void *) 0;
|
||||
if (buf) {
|
||||
free(buf->elts);
|
||||
buf->elts = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,10 +227,7 @@ void buf_destroy (buf)
|
||||
* We grow by mod(512) boundaries.
|
||||
*/
|
||||
|
||||
struct Buf *buf_append (buf, ptr, n_elem)
|
||||
struct Buf *buf;
|
||||
const void *ptr;
|
||||
int n_elem;
|
||||
struct Buf *buf_append (struct Buf *buf, const void *ptr, int n_elem)
|
||||
{
|
||||
int n_alloc = 0;
|
||||
|
||||
@@ -242,30 +237,30 @@ struct Buf *buf_append (buf, ptr, n_elem)
|
||||
/* May need to alloc more. */
|
||||
if (n_elem + buf->nelts > buf->nmax) {
|
||||
|
||||
/* exact amount needed... */
|
||||
n_alloc = (n_elem + buf->nelts) * buf->elt_size;
|
||||
/* exact count needed... */
|
||||
n_alloc = n_elem + buf->nelts;
|
||||
|
||||
/* ...plus some extra */
|
||||
if (((n_alloc * buf->elt_size) % 512) != 0
|
||||
if ((((size_t) n_alloc * buf->elt_size) % 512) != 0
|
||||
&& buf->elt_size < 512)
|
||||
n_alloc +=
|
||||
(512 -
|
||||
((n_alloc * buf->elt_size) % 512)) /
|
||||
buf->elt_size;
|
||||
n_alloc += (int)
|
||||
((512 -
|
||||
(((size_t) n_alloc * buf->elt_size) % 512)) /
|
||||
buf->elt_size);
|
||||
|
||||
if (!buf->elts)
|
||||
buf->elts =
|
||||
allocate_array (n_alloc, buf->elt_size);
|
||||
allocate_array ((int) n_alloc, buf->elt_size);
|
||||
else
|
||||
buf->elts =
|
||||
reallocate_array (buf->elts, n_alloc,
|
||||
reallocate_array (buf->elts, (int) n_alloc,
|
||||
buf->elt_size);
|
||||
|
||||
buf->nmax = n_alloc;
|
||||
}
|
||||
|
||||
memcpy ((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
|
||||
n_elem * buf->elt_size);
|
||||
memcpy (buf->elts + (size_t) buf->nelts * buf->elt_size, ptr,
|
||||
(size_t) n_elem * buf->elt_size);
|
||||
buf->nelts += n_elem;
|
||||
|
||||
return buf;
|
||||
|
||||
@@ -52,9 +52,7 @@ ccl_contains (const int cclp, const int ch)
|
||||
|
||||
/* ccladd - add a single character to a ccl */
|
||||
|
||||
void ccladd (cclp, ch)
|
||||
int cclp;
|
||||
int ch;
|
||||
void ccladd (int cclp, int ch)
|
||||
{
|
||||
int ind, len, newpos, i;
|
||||
|
||||
@@ -85,7 +83,7 @@ void ccladd (cclp, ch)
|
||||
}
|
||||
|
||||
ccllen[cclp] = len + 1;
|
||||
ccltbl[newpos] = ch;
|
||||
ccltbl[newpos] = (unsigned char) ch;
|
||||
}
|
||||
|
||||
/* dump_cclp - same thing as list_character_set, but for cclps. */
|
||||
@@ -185,7 +183,7 @@ ccl_set_union (int a, int b)
|
||||
|
||||
/* cclinit - return an empty ccl */
|
||||
|
||||
int cclinit ()
|
||||
int cclinit (void)
|
||||
{
|
||||
if (++lastccl >= current_maxccls) {
|
||||
current_maxccls += MAX_CCLS_INCREMENT;
|
||||
@@ -225,8 +223,7 @@ int cclinit ()
|
||||
|
||||
/* cclnegate - negate the given ccl */
|
||||
|
||||
void cclnegate (cclp)
|
||||
int cclp;
|
||||
void cclnegate (int cclp)
|
||||
{
|
||||
cclng[cclp] = 1;
|
||||
ccl_has_nl[cclp] = !ccl_has_nl[cclp];
|
||||
@@ -240,9 +237,7 @@ void cclnegate (cclp)
|
||||
* has a non-zero value in the cset array.
|
||||
*/
|
||||
|
||||
void list_character_set (file, cset)
|
||||
FILE *file;
|
||||
int cset[];
|
||||
void list_character_set (FILE *file, int cset[])
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
void dump_associated_rules PROTO ((FILE *, int));
|
||||
void dump_transitions PROTO ((FILE *, int[]));
|
||||
void sympartition PROTO ((int[], int, int[], int[]));
|
||||
int symfollowset PROTO ((int[], int, int, int[]));
|
||||
void dump_associated_rules(FILE *, int);
|
||||
void dump_transitions(FILE *, int[]);
|
||||
void sympartition(int[], int, int[], int[]);
|
||||
int symfollowset(int[], int, int, int[]);
|
||||
|
||||
|
||||
/* check_for_backing_up - check a DFA state for backing up
|
||||
@@ -49,9 +49,7 @@ int symfollowset PROTO ((int[], int, int, int[]));
|
||||
* indexed by equivalence class.
|
||||
*/
|
||||
|
||||
void check_for_backing_up (ds, state)
|
||||
int ds;
|
||||
int state[];
|
||||
void check_for_backing_up (int ds, int state[])
|
||||
{
|
||||
if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */
|
||||
++num_backing_up;
|
||||
@@ -96,10 +94,7 @@ void check_for_backing_up (ds, state)
|
||||
* accset[1 .. nacc] is the list of accepting numbers for the DFA state.
|
||||
*/
|
||||
|
||||
void check_trailing_context (nfa_states, num_states, accset, nacc)
|
||||
int *nfa_states, num_states;
|
||||
int *accset;
|
||||
int nacc;
|
||||
void check_trailing_context (int *nfa_states, int num_states, int *accset, int nacc)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -137,9 +132,7 @@ void check_trailing_context (nfa_states, num_states, accset, nacc)
|
||||
* and writes a report to the given file.
|
||||
*/
|
||||
|
||||
void dump_associated_rules (file, ds)
|
||||
FILE *file;
|
||||
int ds;
|
||||
void dump_associated_rules (FILE *file, int ds)
|
||||
{
|
||||
int i, j;
|
||||
int num_associated_rules = 0;
|
||||
@@ -161,7 +154,7 @@ void dump_associated_rules (file, ds)
|
||||
}
|
||||
}
|
||||
|
||||
qsort (&rule_set [1], num_associated_rules, sizeof (rule_set [1]), intcmp);
|
||||
qsort (&rule_set [1], (size_t) num_associated_rules, sizeof (rule_set [1]), intcmp);
|
||||
|
||||
fprintf (file, _(" associated rule line numbers:"));
|
||||
|
||||
@@ -187,9 +180,7 @@ void dump_associated_rules (file, ds)
|
||||
* is done to the given file.
|
||||
*/
|
||||
|
||||
void dump_transitions (file, state)
|
||||
FILE *file;
|
||||
int state[];
|
||||
void dump_transitions (FILE *file, int state[])
|
||||
{
|
||||
int i, ec;
|
||||
int out_char_set[CSIZE];
|
||||
@@ -235,8 +226,7 @@ void dump_transitions (file, state)
|
||||
* hashval is the hash value for the dfa corresponding to the state set.
|
||||
*/
|
||||
|
||||
int *epsclosure (t, ns_addr, accset, nacc_addr, hv_addr)
|
||||
int *t, *ns_addr, accset[], *nacc_addr, *hv_addr;
|
||||
int *epsclosure (int *t, int *ns_addr, int accset[], int *nacc_addr, int *hv_addr)
|
||||
{
|
||||
int stkpos, ns, tsp;
|
||||
int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum;
|
||||
@@ -351,7 +341,7 @@ ADD_STATE(state); \
|
||||
|
||||
/* increase_max_dfas - increase the maximum number of DFAs */
|
||||
|
||||
void increase_max_dfas ()
|
||||
void increase_max_dfas (void)
|
||||
{
|
||||
current_max_dfas += MAX_DFAS_INCREMENT;
|
||||
|
||||
@@ -378,7 +368,7 @@ void increase_max_dfas ()
|
||||
* dfa starts out in state #1.
|
||||
*/
|
||||
|
||||
void ntod ()
|
||||
void ntod (void)
|
||||
{
|
||||
int *accset, ds, nacc, newds;
|
||||
int sym, hashval, numstates, dsize;
|
||||
@@ -400,7 +390,7 @@ void ntod ()
|
||||
* from 1 to CSIZE, so their size must be CSIZE + 1.
|
||||
*/
|
||||
int duplist[CSIZE + 1], state[CSIZE + 1];
|
||||
int targfreq[CSIZE + 1], targstate[CSIZE + 1];
|
||||
int targfreq[CSIZE + 1] = {0}, targstate[CSIZE + 1];
|
||||
|
||||
/* accset needs to be large enough to hold all of the rules present
|
||||
* in the input, *plus* their YY_TRAILING_HEAD_MASK variants.
|
||||
@@ -521,15 +511,13 @@ void ntod ()
|
||||
* So we'll have to realloc() on the way...
|
||||
* we'll wait until we can calculate yynxt_tbl->td_hilen.
|
||||
*/
|
||||
yynxt_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct
|
||||
yytbl_data));
|
||||
yynxt_tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
|
||||
yytbl_data_init (yynxt_tbl, YYTD_ID_NXT);
|
||||
yynxt_tbl->td_hilen = 1;
|
||||
yynxt_tbl->td_lolen = num_full_table_rows;
|
||||
yynxt_tbl->td_lolen = (flex_uint32_t) num_full_table_rows;
|
||||
yynxt_tbl->td_data = yynxt_data =
|
||||
(flex_int32_t *) calloc (yynxt_tbl->td_lolen *
|
||||
calloc(yynxt_tbl->td_lolen *
|
||||
yynxt_tbl->td_hilen,
|
||||
sizeof (flex_int32_t));
|
||||
yynxt_curr = 0;
|
||||
@@ -543,12 +531,12 @@ void ntod ()
|
||||
*/
|
||||
if (gentables)
|
||||
out_str_dec
|
||||
("static yyconst %s yy_nxt[][%d] =\n {\n",
|
||||
("static const %s yy_nxt[][%d] =\n {\n",
|
||||
long_align ? "flex_int32_t" : "flex_int16_t",
|
||||
num_full_table_rows);
|
||||
else {
|
||||
out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows);
|
||||
out_str ("static yyconst %s *yy_nxt =0;\n",
|
||||
out_str ("static const %s *yy_nxt =0;\n",
|
||||
long_align ? "flex_int32_t" : "flex_int16_t");
|
||||
}
|
||||
|
||||
@@ -713,7 +701,7 @@ void ntod ()
|
||||
/* Each time we hit here, it's another td_hilen, so we realloc. */
|
||||
yynxt_tbl->td_hilen++;
|
||||
yynxt_tbl->td_data = yynxt_data =
|
||||
(flex_int32_t *) realloc (yynxt_data,
|
||||
realloc (yynxt_data,
|
||||
yynxt_tbl->td_hilen *
|
||||
yynxt_tbl->td_lolen *
|
||||
sizeof (flex_int32_t));
|
||||
@@ -805,8 +793,8 @@ void ntod ()
|
||||
mkdeftbl ();
|
||||
}
|
||||
|
||||
flex_free ((void *) accset);
|
||||
flex_free ((void *) nset);
|
||||
free(accset);
|
||||
free(nset);
|
||||
}
|
||||
|
||||
|
||||
@@ -820,8 +808,7 @@ void ntod ()
|
||||
* On return, the dfa state number is in newds.
|
||||
*/
|
||||
|
||||
int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
int sns[], numstates, accset[], nacc, hashval, *newds_addr;
|
||||
int snstods (int sns[], int numstates, int accset[], int nacc, int hashval, int *newds_addr)
|
||||
{
|
||||
int didsort = 0;
|
||||
int i, j;
|
||||
@@ -836,7 +823,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
/* We sort the states in sns so we
|
||||
* can compare it to oldsns quickly.
|
||||
*/
|
||||
qsort (&sns [1], numstates, sizeof (sns [1]), intcmp);
|
||||
qsort (&sns [1], (size_t) numstates, sizeof (sns [1]), intcmp);
|
||||
didsort = 1;
|
||||
}
|
||||
|
||||
@@ -871,7 +858,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
*/
|
||||
|
||||
if (!didsort)
|
||||
qsort (&sns [1], numstates, sizeof (sns [1]), intcmp);
|
||||
qsort (&sns [1], (size_t) numstates, sizeof (sns [1]), intcmp);
|
||||
|
||||
for (i = 1; i <= numstates; ++i)
|
||||
dss[newds][i] = sns[i];
|
||||
@@ -881,7 +868,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
|
||||
if (nacc == 0) {
|
||||
if (reject)
|
||||
dfaacc[newds].dfaacc_set = (int *) 0;
|
||||
dfaacc[newds].dfaacc_set = NULL;
|
||||
else
|
||||
dfaacc[newds].dfaacc_state = 0;
|
||||
|
||||
@@ -894,7 +881,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
* match in the event of ties will work.
|
||||
*/
|
||||
|
||||
qsort (&accset [1], nacc, sizeof (accset [1]), intcmp);
|
||||
qsort (&accset [1], (size_t) nacc, sizeof (accset [1]), intcmp);
|
||||
|
||||
dfaacc[newds].dfaacc_set =
|
||||
allocate_integer_array (nacc + 1);
|
||||
@@ -942,8 +929,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
* int transsym, int nset[current_max_dfa_size] );
|
||||
*/
|
||||
|
||||
int symfollowset (ds, dsize, transsym, nset)
|
||||
int ds[], dsize, transsym, nset[];
|
||||
int symfollowset (int ds[], int dsize, int transsym, int nset[])
|
||||
{
|
||||
int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist;
|
||||
|
||||
@@ -1020,9 +1006,7 @@ int symfollowset (ds, dsize, transsym, nset)
|
||||
* int symlist[numecs], int duplist[numecs] );
|
||||
*/
|
||||
|
||||
void sympartition (ds, numstates, symlist, duplist)
|
||||
int ds[], numstates;
|
||||
int symlist[], duplist[];
|
||||
void sympartition (int ds[], int numstates, int symlist[], int duplist[])
|
||||
{
|
||||
int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
/* ccl2ecl - convert character classes to set of equivalence classes */
|
||||
|
||||
void ccl2ecl ()
|
||||
void ccl2ecl (void)
|
||||
{
|
||||
int i, ich, newlen, cclp, ccls, cclmec;
|
||||
|
||||
@@ -56,7 +56,8 @@ void ccl2ecl ()
|
||||
cclmec = ecgroup[ich];
|
||||
|
||||
if (cclmec > 0) {
|
||||
ccltbl[cclp + newlen] = cclmec;
|
||||
/* Note: range 1..256 is mapped to 1..255,0 */
|
||||
ccltbl[cclp + newlen] = (unsigned char) cclmec;
|
||||
++newlen;
|
||||
}
|
||||
}
|
||||
@@ -74,8 +75,7 @@ void ccl2ecl ()
|
||||
* Returned is the number of classes.
|
||||
*/
|
||||
|
||||
int cre8ecs (fwd, bck, num)
|
||||
int fwd[], bck[], num;
|
||||
int cre8ecs (int fwd[], int bck[], int num)
|
||||
{
|
||||
int i, j, numcl;
|
||||
|
||||
@@ -100,9 +100,9 @@ int cre8ecs (fwd, bck, num)
|
||||
/* mkeccl - update equivalence classes based on character class xtions
|
||||
*
|
||||
* synopsis
|
||||
* Char ccls[];
|
||||
* unsigned char ccls[];
|
||||
* int lenccl, fwd[llsiz], bck[llsiz], llsiz, NUL_mapping;
|
||||
* void mkeccl( Char ccls[], int lenccl, int fwd[llsiz], int bck[llsiz],
|
||||
* void mkeccl( unsigned char ccls[], int lenccl, int fwd[llsiz], int bck[llsiz],
|
||||
* int llsiz, int NUL_mapping );
|
||||
*
|
||||
* ccls contains the elements of the character class, lenccl is the
|
||||
@@ -112,9 +112,7 @@ int cre8ecs (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;
|
||||
void mkeccl (unsigned char ccls[], int lenccl, int fwd[], int bck[], int llsiz, int NUL_mapping)
|
||||
{
|
||||
int cclp, oldec, newec;
|
||||
int cclm, i, j;
|
||||
@@ -201,8 +199,7 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping)
|
||||
|
||||
/* mkechar - create equivalence class for single character */
|
||||
|
||||
void mkechar (tch, fwd, bck)
|
||||
int tch, fwd[], bck[];
|
||||
void mkechar (int tch, int fwd[], int bck[])
|
||||
{
|
||||
/* If until now the character has been a proper subset of
|
||||
* an equivalence class, break it away to create a new ec
|
||||
|
||||
+16
-21
@@ -47,9 +47,9 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
|
||||
va_list ap;
|
||||
|
||||
/* allocate and initialize new filter */
|
||||
f = (struct filter *) flex_alloc (sizeof (struct filter));
|
||||
f = malloc(sizeof(struct filter));
|
||||
if (!f)
|
||||
flexerror (_("flex_alloc failed (f) in filter_create_ext"));
|
||||
flexerror(_("malloc failed (f) in filter_create_ext"));
|
||||
memset (f, 0, sizeof (*f));
|
||||
f->filter_func = NULL;
|
||||
f->extra = NULL;
|
||||
@@ -66,23 +66,16 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
|
||||
|
||||
/* 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 = malloc(sizeof(char *) * (size_t) (max_args + 1));
|
||||
if (!f->argv)
|
||||
flexerror (_("flex_alloc failed (f->argv) in filter_create_ext"));
|
||||
flexerror(_("malloc failed (f->argv) in filter_create_ext"));
|
||||
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 = realloc(f->argv, sizeof(char*) * (size_t) (max_args + 1));
|
||||
}
|
||||
f->argv[f->argc++] = s;
|
||||
}
|
||||
@@ -107,9 +100,9 @@ struct filter *filter_create_int (struct filter *chain,
|
||||
struct filter *f;
|
||||
|
||||
/* allocate and initialize new filter */
|
||||
f = (struct filter *) flex_alloc (sizeof (struct filter));
|
||||
f = malloc(sizeof(struct filter));
|
||||
if (!f)
|
||||
flexerror (_("flex_alloc failed in filter_create_int"));
|
||||
flexerror(_("malloc failed in filter_create_int"));
|
||||
memset (f, 0, sizeof (*f));
|
||||
f->next = NULL;
|
||||
f->argc = 0;
|
||||
@@ -174,6 +167,8 @@ clearerr(stdin);
|
||||
flexfatal (_("dup2(pipes[0],0)"));
|
||||
close (pipes[0]);
|
||||
fseek (stdin, 0, SEEK_CUR);
|
||||
ungetc(' ', stdin); /* still an evil hack, but one that works better */
|
||||
(void)fgetc(stdin); /* on NetBSD than the fseek attempt does */
|
||||
|
||||
/* run as a filter, either internally or by exec */
|
||||
if (chain->filter_func) {
|
||||
@@ -288,9 +283,9 @@ int filter_tee_header (struct filter *chain)
|
||||
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
buf = (char *) flex_alloc (readsz);
|
||||
buf = malloc((size_t) readsz);
|
||||
if (!buf)
|
||||
flexerror (_("flex_alloc failed in filter_tee_header"));
|
||||
flexerror(_("malloc failed in filter_tee_header"));
|
||||
while (fgets (buf, readsz, stdin)) {
|
||||
fputs (buf, to_c);
|
||||
if (write_header)
|
||||
@@ -341,7 +336,7 @@ int filter_tee_header (struct filter *chain)
|
||||
int filter_fix_linedirs (struct filter *chain)
|
||||
{
|
||||
char *buf;
|
||||
const int readsz = 512;
|
||||
const size_t readsz = 512;
|
||||
int lineno = 1;
|
||||
bool in_gen = true; /* in generated code */
|
||||
bool last_was_blank = false;
|
||||
@@ -349,11 +344,11 @@ int filter_fix_linedirs (struct filter *chain)
|
||||
if (!chain)
|
||||
return 0;
|
||||
|
||||
buf = (char *) flex_alloc (readsz);
|
||||
buf = malloc(readsz);
|
||||
if (!buf)
|
||||
flexerror (_("flex_alloc failed in filter_fix_linedirs"));
|
||||
flexerror(_("malloc failed in filter_fix_linedirs"));
|
||||
|
||||
while (fgets (buf, readsz, stdin)) {
|
||||
while (fgets (buf, (int) readsz, stdin)) {
|
||||
|
||||
regmatch_t m[10];
|
||||
|
||||
@@ -395,7 +390,7 @@ int filter_fix_linedirs (struct filter *chain)
|
||||
/* Adjust the line directives. */
|
||||
in_gen = true;
|
||||
snprintf (buf, readsz, "#line %d \"%s\"\n",
|
||||
lineno + 1, filename);
|
||||
lineno, filename);
|
||||
}
|
||||
else {
|
||||
/* it's a #line directive for code we didn't write */
|
||||
|
||||
+271
-351
File diff suppressed because it is too large
Load Diff
+164
-232
@@ -39,30 +39,15 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#if !defined(__GNUC__) && !defined(__lint__)
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
#pragma alloca
|
||||
# else
|
||||
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
||||
char *alloca ();
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <setjmp.h>
|
||||
#include <ctype.h>
|
||||
#include <libgen.h> /* for XPG version of basename(3) */
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASSERT_H
|
||||
#include <assert.h>
|
||||
#else
|
||||
@@ -81,16 +66,11 @@ char *alloca ();
|
||||
#ifdef HAVE_SYS_PARAMS_H
|
||||
#include <sys/params.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#define bool int
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
#include <regex.h>
|
||||
#endif
|
||||
@@ -109,33 +89,12 @@ char *alloca ();
|
||||
|
||||
/* Always be prepared to generate an 8-bit scanner. */
|
||||
#define CSIZE 256
|
||||
#define Char unsigned char
|
||||
|
||||
/* Size of input alphabet - should be size of ASCII set. */
|
||||
#ifndef DEFAULT_CSIZE
|
||||
#define DEFAULT_CSIZE 128
|
||||
#endif
|
||||
|
||||
#ifndef PROTO
|
||||
#if defined(__STDC__)
|
||||
#define PROTO(proto) proto
|
||||
#else
|
||||
#define PROTO(proto) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
#ifndef __VMS_POSIX
|
||||
#define unlink remove
|
||||
#define SHORT_FILE_NAMES
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MS_DOS
|
||||
#define SHORT_FILE_NAMES
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum line length we'll have to deal with. */
|
||||
#define MAXLINE 2048
|
||||
|
||||
@@ -150,11 +109,6 @@ char *alloca ();
|
||||
#endif
|
||||
|
||||
|
||||
/* ANSI C does not guarantee that isascii() is defined */
|
||||
#ifndef isascii
|
||||
#define isascii(c) ((c) <= 0177)
|
||||
#endif
|
||||
|
||||
#define unspecified -1
|
||||
|
||||
/* Special chk[] values marking the slots taking by end-of-buffer and action
|
||||
@@ -404,7 +358,6 @@ extern int interactive, lex_compat, posix_compat, do_yylineno;
|
||||
extern int useecs, fulltbl, usemecs, fullspd;
|
||||
extern int gen_line_dirs, performance_report, backing_up_report;
|
||||
extern int reentrant, bison_bridge_lval, bison_bridge_lloc;
|
||||
extern bool ansi_func_defs, ansi_func_protos;
|
||||
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
|
||||
extern int csize;
|
||||
extern int yymore_used, reject, real_reject, continued_action, in_rule;
|
||||
@@ -445,7 +398,7 @@ extern int trace_hex;
|
||||
*/
|
||||
|
||||
extern int datapos, dataline, linenum;
|
||||
extern FILE *skelfile, *yyin, *backing_up_file;
|
||||
extern FILE *skelfile, *backing_up_file;
|
||||
extern const char *skel[];
|
||||
extern int skel_ind;
|
||||
extern char *infilename, *outfilename, *headerfilename;
|
||||
@@ -647,7 +600,7 @@ extern int end_of_buffer_state;
|
||||
|
||||
extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
|
||||
extern int current_maxccls, current_max_ccl_tbl_size;
|
||||
extern Char *ccltbl;
|
||||
extern unsigned char *ccltbl;
|
||||
|
||||
|
||||
/* Variables for miscellaneous information:
|
||||
@@ -675,62 +628,54 @@ extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
|
||||
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
|
||||
extern int num_backing_up, bol_needed;
|
||||
|
||||
void *allocate_array PROTO ((int, size_t));
|
||||
void *reallocate_array PROTO ((void *, int, size_t));
|
||||
#ifndef HAVE_REALLOCARRAY
|
||||
void *reallocarray(void *, size_t, size_t);
|
||||
#endif
|
||||
|
||||
void *flex_alloc PROTO ((size_t));
|
||||
void *flex_realloc PROTO ((void *, size_t));
|
||||
void flex_free PROTO ((void *));
|
||||
void *allocate_array(int, size_t);
|
||||
void *reallocate_array(void *, int, size_t);
|
||||
|
||||
#define allocate_integer_array(size) \
|
||||
(int *) allocate_array( size, sizeof( int ) )
|
||||
allocate_array(size, sizeof(int))
|
||||
|
||||
#define reallocate_integer_array(array,size) \
|
||||
(int *) reallocate_array( (void *) array, size, sizeof( int ) )
|
||||
reallocate_array((void *) array, size, sizeof(int))
|
||||
|
||||
#define allocate_bool_array(size) \
|
||||
(bool *) allocate_array( size, sizeof( bool ) )
|
||||
allocate_array(size, sizeof(bool))
|
||||
|
||||
#define reallocate_bool_array(array,size) \
|
||||
(bool *) reallocate_array( (void *) array, size, sizeof( bool ) )
|
||||
reallocate_array((void *) array, size, sizeof(bool))
|
||||
|
||||
#define allocate_int_ptr_array(size) \
|
||||
(int **) allocate_array( size, sizeof( int * ) )
|
||||
allocate_array(size, sizeof(int *))
|
||||
|
||||
#define allocate_char_ptr_array(size) \
|
||||
(char **) allocate_array( size, sizeof( char * ) )
|
||||
allocate_array(size, sizeof(char *))
|
||||
|
||||
#define allocate_dfaacc_union(size) \
|
||||
(union dfaacc_union *) \
|
||||
allocate_array( size, sizeof( union dfaacc_union ) )
|
||||
allocate_array(size, sizeof(union dfaacc_union))
|
||||
|
||||
#define reallocate_int_ptr_array(array,size) \
|
||||
(int **) reallocate_array( (void *) array, size, sizeof( int * ) )
|
||||
reallocate_array((void *) array, size, sizeof(int *))
|
||||
|
||||
#define reallocate_char_ptr_array(array,size) \
|
||||
(char **) reallocate_array( (void *) array, size, sizeof( char * ) )
|
||||
reallocate_array((void *) array, size, sizeof(char *))
|
||||
|
||||
#define reallocate_dfaacc_union(array, size) \
|
||||
(union dfaacc_union *) \
|
||||
reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
|
||||
reallocate_array((void *) array, size, sizeof(union dfaacc_union))
|
||||
|
||||
#define allocate_character_array(size) \
|
||||
(char *) allocate_array( size, sizeof( char ) )
|
||||
allocate_array( size, sizeof(char))
|
||||
|
||||
#define reallocate_character_array(array,size) \
|
||||
(char *) reallocate_array( (void *) array, size, sizeof( char ) )
|
||||
reallocate_array((void *) array, size, sizeof(char))
|
||||
|
||||
#define allocate_Character_array(size) \
|
||||
(Char *) allocate_array( size, sizeof( Char ) )
|
||||
allocate_array(size, sizeof(unsigned char))
|
||||
|
||||
#define reallocate_Character_array(array,size) \
|
||||
(Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
|
||||
|
||||
|
||||
/* Used to communicate between scanner and parser. The type should really
|
||||
* be YYSTYPE, but we can't easily get our hands on it.
|
||||
*/
|
||||
extern int yylval;
|
||||
reallocate_array((void *) array, size, sizeof(unsigned char))
|
||||
|
||||
|
||||
/* External functions that are cross-referenced among the flex source files. */
|
||||
@@ -738,146 +683,143 @@ extern int yylval;
|
||||
|
||||
/* from file ccl.c */
|
||||
|
||||
extern void ccladd PROTO ((int, int)); /* add a single character to a ccl */
|
||||
extern int cclinit PROTO ((void)); /* make an empty ccl */
|
||||
extern void cclnegate PROTO ((int)); /* negate a ccl */
|
||||
extern void ccladd(int, int); /* add a single character to a ccl */
|
||||
extern int cclinit(void); /* make an empty ccl */
|
||||
extern void cclnegate(int); /* negate a ccl */
|
||||
extern int ccl_set_diff (int a, int b); /* set difference of two ccls. */
|
||||
extern int ccl_set_union (int a, int b); /* set union of two ccls. */
|
||||
|
||||
/* List the members of a set of characters in CCL form. */
|
||||
extern void list_character_set PROTO ((FILE *, int[]));
|
||||
extern void list_character_set(FILE *, int[]);
|
||||
|
||||
|
||||
/* from file dfa.c */
|
||||
|
||||
/* Check a DFA state for backing up. */
|
||||
extern void check_for_backing_up PROTO ((int, int[]));
|
||||
extern void check_for_backing_up(int, int[]);
|
||||
|
||||
/* Check to see if NFA state set constitutes "dangerous" trailing context. */
|
||||
extern void check_trailing_context PROTO ((int *, int, int *, int));
|
||||
extern void check_trailing_context(int *, int, int *, int);
|
||||
|
||||
/* Construct the epsilon closure of a set of ndfa states. */
|
||||
extern int *epsclosure PROTO ((int *, int *, int[], int *, int *));
|
||||
extern int *epsclosure(int *, int *, int[], int *, int *);
|
||||
|
||||
/* Increase the maximum number of dfas. */
|
||||
extern void increase_max_dfas PROTO ((void));
|
||||
extern void increase_max_dfas(void);
|
||||
|
||||
extern void ntod PROTO ((void)); /* convert a ndfa to a dfa */
|
||||
extern void ntod(void); /* convert a ndfa to a dfa */
|
||||
|
||||
/* Converts a set of ndfa states into a dfa state. */
|
||||
extern int snstods PROTO ((int[], int, int[], int, int, int *));
|
||||
extern int snstods(int[], int, int[], int, int, int *);
|
||||
|
||||
|
||||
/* from file ecs.c */
|
||||
|
||||
/* Convert character classes to set of equivalence classes. */
|
||||
extern void ccl2ecl PROTO ((void));
|
||||
extern void ccl2ecl(void);
|
||||
|
||||
/* Associate equivalence class numbers with class members. */
|
||||
extern int cre8ecs PROTO ((int[], int[], int));
|
||||
extern int cre8ecs(int[], int[], int);
|
||||
|
||||
/* Update equivalence classes based on character class transitions. */
|
||||
extern void mkeccl PROTO ((Char[], int, int[], int[], int, int));
|
||||
extern void mkeccl(unsigned char[], int, int[], int[], int, int);
|
||||
|
||||
/* Create equivalence class for single character. */
|
||||
extern void mkechar PROTO ((int, int[], int[]));
|
||||
extern void mkechar(int, int[], int[]);
|
||||
|
||||
|
||||
/* from file gen.c */
|
||||
|
||||
extern void do_indent PROTO ((void)); /* indent to the current level */
|
||||
extern void do_indent(void); /* indent to the current level */
|
||||
|
||||
/* Generate the code to keep backing-up information. */
|
||||
extern void gen_backing_up PROTO ((void));
|
||||
extern void gen_backing_up(void);
|
||||
|
||||
/* Generate the code to perform the backing up. */
|
||||
extern void gen_bu_action PROTO ((void));
|
||||
extern void gen_bu_action(void);
|
||||
|
||||
/* Generate full speed compressed transition table. */
|
||||
extern void genctbl PROTO ((void));
|
||||
extern void genctbl(void);
|
||||
|
||||
/* Generate the code to find the action number. */
|
||||
extern void gen_find_action PROTO ((void));
|
||||
extern void gen_find_action(void);
|
||||
|
||||
extern void genftbl PROTO ((void)); /* generate full transition table */
|
||||
extern void genftbl(void); /* generate full transition table */
|
||||
|
||||
/* Generate the code to find the next compressed-table state. */
|
||||
extern void gen_next_compressed_state PROTO ((char *));
|
||||
extern void gen_next_compressed_state(char *);
|
||||
|
||||
/* Generate the code to find the next match. */
|
||||
extern void gen_next_match PROTO ((void));
|
||||
extern void gen_next_match(void);
|
||||
|
||||
/* Generate the code to find the next state. */
|
||||
extern void gen_next_state PROTO ((int));
|
||||
extern void gen_next_state(int);
|
||||
|
||||
/* Generate the code to make a NUL transition. */
|
||||
extern void gen_NUL_trans PROTO ((void));
|
||||
extern void gen_NUL_trans(void);
|
||||
|
||||
/* Generate the code to find the start state. */
|
||||
extern void gen_start_state PROTO ((void));
|
||||
extern void gen_start_state(void);
|
||||
|
||||
/* Generate data statements for the transition tables. */
|
||||
extern void gentabs PROTO ((void));
|
||||
extern void gentabs(void);
|
||||
|
||||
/* Write out a formatted string at the current indentation level. */
|
||||
extern void indent_put2s PROTO ((const char *, const char *));
|
||||
extern void indent_put2s(const char *, const char *);
|
||||
|
||||
/* Write out a string + newline at the current indentation level. */
|
||||
extern void indent_puts PROTO ((const char *));
|
||||
extern void indent_puts(const char *);
|
||||
|
||||
extern void make_tables PROTO ((void)); /* generate transition tables */
|
||||
extern void make_tables(void); /* generate transition tables */
|
||||
|
||||
|
||||
/* from file main.c */
|
||||
|
||||
extern void check_options PROTO ((void));
|
||||
extern void flexend PROTO ((int));
|
||||
extern void usage PROTO ((void));
|
||||
extern void check_options(void);
|
||||
extern void flexend(int);
|
||||
extern void usage(void);
|
||||
|
||||
|
||||
/* from file misc.c */
|
||||
|
||||
/* Add a #define to the action file. */
|
||||
extern void action_define PROTO ((const char *defname, int value));
|
||||
extern void action_define(const char *defname, int value);
|
||||
|
||||
/* Add the given text to the stored actions. */
|
||||
extern void add_action PROTO ((const char *new_text));
|
||||
extern void add_action(const char *new_text);
|
||||
|
||||
/* True if a string is all lower case. */
|
||||
extern int all_lower PROTO ((char *));
|
||||
extern int all_lower(char *);
|
||||
|
||||
/* True if a string is all upper case. */
|
||||
extern int all_upper PROTO ((char *));
|
||||
extern int all_upper(char *);
|
||||
|
||||
/* Compare two integers for use by qsort. */
|
||||
extern int intcmp PROTO ((const void *, const void *));
|
||||
extern int intcmp(const void *, const void *);
|
||||
|
||||
/* Check a character to make sure it's in the expected range. */
|
||||
extern void check_char PROTO ((int c));
|
||||
extern void check_char(int c);
|
||||
|
||||
/* Replace upper-case letter to lower-case. */
|
||||
extern Char clower PROTO ((int));
|
||||
extern unsigned char clower(int);
|
||||
|
||||
/* Returns a dynamically allocated copy of a string. */
|
||||
extern char *copy_string PROTO ((const char *));
|
||||
|
||||
/* Returns a dynamically allocated copy of a (potentially) unsigned string. */
|
||||
extern Char *copy_unsigned_string PROTO ((Char *));
|
||||
/* strdup() that fails fatally on allocation failures. */
|
||||
extern char *xstrdup(const char *);
|
||||
|
||||
/* Compare two characters for use by qsort with '\0' sorting last. */
|
||||
extern int cclcmp PROTO ((const void *, const void *));
|
||||
extern int cclcmp(const void *, const void *);
|
||||
|
||||
/* Finish up a block of data declarations. */
|
||||
extern void dataend PROTO ((void));
|
||||
extern void dataend(void);
|
||||
|
||||
/* Flush generated data statements. */
|
||||
extern void dataflush PROTO ((void));
|
||||
extern void dataflush(void);
|
||||
|
||||
/* Report an error message and terminate. */
|
||||
extern void flexerror PROTO ((const char *));
|
||||
extern void flexerror(const char *);
|
||||
|
||||
/* Report a fatal error message and terminate. */
|
||||
extern void flexfatal PROTO ((const char *));
|
||||
extern void flexfatal(const char *);
|
||||
|
||||
/* Report a fatal error with a pinpoint, and terminate */
|
||||
#if HAVE_DECL___FUNC__
|
||||
@@ -901,207 +843,199 @@ extern void flexfatal PROTO ((const char *));
|
||||
#endif /* ! HAVE_DECL___func__ */
|
||||
|
||||
/* Convert a hexadecimal digit string to an integer value. */
|
||||
extern int htoi PROTO ((Char[]));
|
||||
extern unsigned int htoui(unsigned char[]);
|
||||
|
||||
/* Report an error message formatted */
|
||||
extern void lerr PROTO ((const char *, ...))
|
||||
extern void lerr(const char *, ...)
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__format__(__printf__, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Like lerr, but also exit after displaying message. */
|
||||
extern void lerr_fatal PROTO ((const char *, ...))
|
||||
extern void lerr_fatal(const char *, ...)
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__format__(__printf__, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Spit out a "#line" statement. */
|
||||
extern void line_directive_out PROTO ((FILE *, int));
|
||||
extern void line_directive_out(FILE *, int);
|
||||
|
||||
/* Mark the current position in the action array as the end of the section 1
|
||||
* user defs.
|
||||
*/
|
||||
extern void mark_defs1 PROTO ((void));
|
||||
extern void mark_defs1(void);
|
||||
|
||||
/* Mark the current position in the action array as the end of the prolog. */
|
||||
extern void mark_prolog PROTO ((void));
|
||||
extern void mark_prolog(void);
|
||||
|
||||
/* Generate a data statment for a two-dimensional array. */
|
||||
extern void mk2data PROTO ((int));
|
||||
extern void mk2data(int);
|
||||
|
||||
extern void mkdata PROTO ((int)); /* generate a data statement */
|
||||
extern void mkdata(int); /* generate a data statement */
|
||||
|
||||
/* Return the integer represented by a string of digits. */
|
||||
extern int myctoi PROTO ((const char *));
|
||||
extern int myctoi(const char *);
|
||||
|
||||
/* Return character corresponding to escape sequence. */
|
||||
extern Char myesc PROTO ((Char[]));
|
||||
extern unsigned char myesc(unsigned char[]);
|
||||
|
||||
/* Convert an octal digit string to an integer value. */
|
||||
extern int otoi PROTO ((Char[]));
|
||||
extern unsigned int otoui(unsigned char[]);
|
||||
|
||||
/* Output a (possibly-formatted) string to the generated scanner. */
|
||||
extern void out PROTO ((const char *));
|
||||
extern void out_dec PROTO ((const char *, int));
|
||||
extern void out_dec2 PROTO ((const char *, int, int));
|
||||
extern void out_hex PROTO ((const char *, unsigned int));
|
||||
extern void out_str PROTO ((const char *, const char *));
|
||||
extern void out_str3
|
||||
PROTO ((const char *, const char *, const char *, const char *));
|
||||
extern void out_str_dec PROTO ((const char *, const char *, int));
|
||||
extern void outc PROTO ((int));
|
||||
extern void outn PROTO ((const char *));
|
||||
extern void out_m4_define (const char* def, const char* val);
|
||||
extern void out(const char *);
|
||||
extern void out_dec(const char *, int);
|
||||
extern void out_dec2(const char *, int, int);
|
||||
extern void out_hex(const char *, unsigned int);
|
||||
extern void out_str(const char *, const char *);
|
||||
extern void out_str3(const char *, const char *, const char *, const char *);
|
||||
extern void out_str_dec(const char *, const char *, int);
|
||||
extern void outc(int);
|
||||
extern void outn(const char *);
|
||||
extern void out_m4_define(const char* def, const char* val);
|
||||
|
||||
/* Return a printable version of the given character, which might be
|
||||
* 8-bit.
|
||||
*/
|
||||
extern char *readable_form PROTO ((int));
|
||||
extern char *readable_form(int);
|
||||
|
||||
/* Write out one section of the skeleton file. */
|
||||
extern void skelout PROTO ((void));
|
||||
extern void skelout(void);
|
||||
|
||||
/* Output a yy_trans_info structure. */
|
||||
extern void transition_struct_out PROTO ((int, int));
|
||||
extern void transition_struct_out(int, int);
|
||||
|
||||
/* Only needed when using certain broken versions of bison to build parse.c. */
|
||||
extern void *yy_flex_xmalloc PROTO ((int));
|
||||
|
||||
/* Set a region of memory to 0. */
|
||||
extern void zero_out PROTO ((char *, size_t));
|
||||
extern void *yy_flex_xmalloc(int);
|
||||
|
||||
|
||||
/* from file nfa.c */
|
||||
|
||||
/* Add an accepting state to a machine. */
|
||||
extern void add_accept PROTO ((int, int));
|
||||
extern void add_accept(int, int);
|
||||
|
||||
/* Make a given number of copies of a singleton machine. */
|
||||
extern int copysingl PROTO ((int, int));
|
||||
extern int copysingl(int, int);
|
||||
|
||||
/* Debugging routine to write out an nfa. */
|
||||
extern void dumpnfa PROTO ((int));
|
||||
extern void dumpnfa(int);
|
||||
|
||||
/* Finish up the processing for a rule. */
|
||||
extern void finish_rule PROTO ((int, int, int, int, int));
|
||||
extern void finish_rule(int, int, int, int, int);
|
||||
|
||||
/* Connect two machines together. */
|
||||
extern int link_machines PROTO ((int, int));
|
||||
extern int link_machines(int, int);
|
||||
|
||||
/* Mark each "beginning" state in a machine as being a "normal" (i.e.,
|
||||
* not trailing context associated) state.
|
||||
*/
|
||||
extern void mark_beginning_as_normal PROTO ((int));
|
||||
extern void mark_beginning_as_normal(int);
|
||||
|
||||
/* Make a machine that branches to two machines. */
|
||||
extern int mkbranch PROTO ((int, int));
|
||||
extern int mkbranch(int, int);
|
||||
|
||||
extern int mkclos PROTO ((int)); /* convert a machine into a closure */
|
||||
extern int mkopt PROTO ((int)); /* make a machine optional */
|
||||
extern int mkclos(int); /* convert a machine into a closure */
|
||||
extern int mkopt(int); /* make a machine optional */
|
||||
|
||||
/* Make a machine that matches either one of two machines. */
|
||||
extern int mkor PROTO ((int, int));
|
||||
extern int mkor(int, int);
|
||||
|
||||
/* Convert a machine into a positive closure. */
|
||||
extern int mkposcl PROTO ((int));
|
||||
extern int mkposcl(int);
|
||||
|
||||
extern int mkrep PROTO ((int, int, int)); /* make a replicated machine */
|
||||
extern int mkrep(int, int, int); /* make a replicated machine */
|
||||
|
||||
/* Create a state with a transition on a given symbol. */
|
||||
extern int mkstate PROTO ((int));
|
||||
extern int mkstate(int);
|
||||
|
||||
extern void new_rule PROTO ((void)); /* initialize for a new rule */
|
||||
extern void new_rule(void); /* initialize for a new rule */
|
||||
|
||||
|
||||
/* from file parse.y */
|
||||
|
||||
/* Build the "<<EOF>>" action for the active start conditions. */
|
||||
extern void build_eof_action PROTO ((void));
|
||||
extern void build_eof_action(void);
|
||||
|
||||
/* Write out a message formatted with one string, pinpointing its location. */
|
||||
extern void format_pinpoint_message PROTO ((const char *, const char *));
|
||||
extern void format_pinpoint_message(const char *, const char *);
|
||||
|
||||
/* Write out a message, pinpointing its location. */
|
||||
extern void pinpoint_message PROTO ((const char *));
|
||||
extern void pinpoint_message(const char *);
|
||||
|
||||
/* Write out a warning, pinpointing it at the given line. */
|
||||
extern void line_warning PROTO ((const char *, int));
|
||||
extern void line_warning(const char *, int);
|
||||
|
||||
/* Write out a message, pinpointing it at the given line. */
|
||||
extern void line_pinpoint PROTO ((const char *, int));
|
||||
extern void line_pinpoint(const char *, int);
|
||||
|
||||
/* Report a formatted syntax error. */
|
||||
extern void format_synerr PROTO ((const char *, const char *));
|
||||
extern void synerr PROTO ((const char *)); /* report a syntax error */
|
||||
extern void format_warn PROTO ((const char *, const char *));
|
||||
extern void warn PROTO ((const char *)); /* report a warning */
|
||||
extern void yyerror PROTO ((const char *)); /* report a parse error */
|
||||
extern int yyparse PROTO ((void)); /* the YACC parser */
|
||||
extern void format_synerr(const char *, const char *);
|
||||
extern void synerr(const char *); /* report a syntax error */
|
||||
extern void format_warn(const char *, const char *);
|
||||
extern void warn(const char *); /* report a warning */
|
||||
extern void yyerror(const char *); /* report a parse error */
|
||||
|
||||
|
||||
/* from file scan.l */
|
||||
|
||||
/* The Flex-generated scanner for flex. */
|
||||
extern int flexscan PROTO ((void));
|
||||
extern int flexscan(void);
|
||||
|
||||
/* Open the given file (if NULL, stdin) for scanning. */
|
||||
extern void set_input_file PROTO ((char *));
|
||||
|
||||
/* Wrapup a file in the lexical analyzer. */
|
||||
extern int yywrap PROTO ((void));
|
||||
extern void set_input_file(char *);
|
||||
|
||||
|
||||
/* from file sym.c */
|
||||
|
||||
/* Save the text of a character class. */
|
||||
extern void cclinstal PROTO ((Char[], int));
|
||||
extern void cclinstal(char[], int);
|
||||
|
||||
/* Lookup the number associated with character class. */
|
||||
extern int ccllookup PROTO ((Char[]));
|
||||
extern int ccllookup(char[]);
|
||||
|
||||
extern void ndinstal PROTO ((const char *, Char[])); /* install a name definition */
|
||||
extern Char *ndlookup PROTO ((const char *)); /* lookup a name definition */
|
||||
extern void ndinstal(const char *, char[]); /* install a name definition */
|
||||
extern char *ndlookup(const char *); /* lookup a name definition */
|
||||
|
||||
/* Increase maximum number of SC's. */
|
||||
extern void scextend PROTO ((void));
|
||||
extern void scinstal PROTO ((const char *, int)); /* make a start condition */
|
||||
extern void scextend(void);
|
||||
extern void scinstal(const char *, int); /* make a start condition */
|
||||
|
||||
/* Lookup the number associated with a start condition. */
|
||||
extern int sclookup PROTO ((const char *));
|
||||
extern int sclookup(const char *);
|
||||
|
||||
|
||||
/* from file tblcmp.c */
|
||||
|
||||
/* Build table entries for dfa state. */
|
||||
extern void bldtbl PROTO ((int[], int, int, int, int));
|
||||
extern void bldtbl(int[], int, int, int, int);
|
||||
|
||||
extern void cmptmps PROTO ((void)); /* compress template table entries */
|
||||
extern void expand_nxt_chk PROTO ((void)); /* increase nxt/chk arrays */
|
||||
extern void cmptmps(void); /* compress template table entries */
|
||||
extern void expand_nxt_chk(void); /* increase nxt/chk arrays */
|
||||
|
||||
/* Finds a space in the table for a state to be placed. */
|
||||
extern int find_table_space PROTO ((int *, int));
|
||||
extern void inittbl PROTO ((void)); /* initialize transition tables */
|
||||
extern int find_table_space(int *, int);
|
||||
extern void inittbl(void); /* initialize transition tables */
|
||||
|
||||
/* Make the default, "jam" table entries. */
|
||||
extern void mkdeftbl PROTO ((void));
|
||||
extern void mkdeftbl(void);
|
||||
|
||||
/* Create table entries for a state (or state fragment) which has
|
||||
* only one out-transition.
|
||||
*/
|
||||
extern void mk1tbl PROTO ((int, int, int, int));
|
||||
extern void mk1tbl(int, int, int, int);
|
||||
|
||||
/* Place a state into full speed transition table. */
|
||||
extern void place_state PROTO ((int *, int, int));
|
||||
extern void place_state(int *, int, int);
|
||||
|
||||
/* Save states with only one out-transition to be processed later. */
|
||||
extern void stack1 PROTO ((int, int, int, int));
|
||||
extern void stack1(int, int, int, int);
|
||||
|
||||
|
||||
/* from file yylex.c */
|
||||
|
||||
extern int yylex PROTO ((void));
|
||||
extern int yylex(void);
|
||||
|
||||
/* A growable array. See buf.c. */
|
||||
struct Buf {
|
||||
@@ -1111,30 +1045,28 @@ struct Buf {
|
||||
int nmax; /* max capacity of elements. */
|
||||
};
|
||||
|
||||
extern void buf_init PROTO ((struct Buf * buf, size_t elem_size));
|
||||
extern void buf_destroy PROTO ((struct Buf * buf));
|
||||
extern struct Buf *buf_append
|
||||
PROTO ((struct Buf * buf, const void *ptr, int n_elem));
|
||||
extern struct Buf *buf_concat PROTO((struct Buf* dest, const struct Buf* src));
|
||||
extern struct Buf *buf_strappend PROTO ((struct Buf *, const char *str));
|
||||
extern struct Buf *buf_strnappend
|
||||
PROTO ((struct Buf *, const char *str, int nchars));
|
||||
extern struct Buf *buf_strdefine
|
||||
PROTO ((struct Buf * buf, const char *str, const char *def));
|
||||
extern struct Buf *buf_prints PROTO((struct Buf *buf, const char *fmt, const char* s));
|
||||
extern struct Buf *buf_m4_define PROTO((struct Buf *buf, const char* def, const char* val));
|
||||
extern struct Buf *buf_m4_undefine PROTO((struct Buf *buf, const char* def));
|
||||
extern struct Buf *buf_print_strings PROTO((struct Buf * buf, FILE* out));
|
||||
extern struct Buf *buf_linedir PROTO((struct Buf *buf, const char* filename, int lineno));
|
||||
extern void buf_init(struct Buf * buf, size_t elem_size);
|
||||
extern void buf_destroy(struct Buf * buf);
|
||||
extern struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem);
|
||||
extern struct Buf *buf_concat(struct Buf* dest, const struct Buf* src);
|
||||
extern struct Buf *buf_strappend(struct Buf *, const char *str);
|
||||
extern struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars);
|
||||
extern struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def);
|
||||
extern struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s);
|
||||
extern struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val);
|
||||
extern struct Buf *buf_m4_undefine(struct Buf *buf, const char* def);
|
||||
extern struct Buf *buf_print_strings(struct Buf * buf, FILE* out);
|
||||
extern struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno);
|
||||
|
||||
extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */
|
||||
extern struct Buf defs_buf; /* a char* buffer to save #define'd some symbols generated by flex. */
|
||||
extern struct Buf yydmap_buf; /* a string buffer to hold yydmap elements */
|
||||
extern struct Buf m4defs_buf; /* Holds m4 definitions. */
|
||||
extern struct Buf top_buf; /* contains %top code. String buffer. */
|
||||
extern bool no_section3_escape; /* True if the undocumented option --unsafe-no-m4-sect3-escape was passed */
|
||||
|
||||
/* For blocking out code from the header file. */
|
||||
#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[")
|
||||
#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl")
|
||||
#define OUT_END_CODE() outn("]])")
|
||||
|
||||
/* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */
|
||||
@@ -1187,14 +1119,14 @@ struct filter {
|
||||
|
||||
/* output filter chain */
|
||||
extern struct filter * output_chain;
|
||||
extern struct filter *filter_create_ext PROTO((struct filter * chain, const char *cmd, ...));
|
||||
struct filter *filter_create_int PROTO((struct filter *chain,
|
||||
extern struct filter *filter_create_ext (struct filter * chain, const char *cmd, ...);
|
||||
struct filter *filter_create_int(struct filter *chain,
|
||||
int (*filter_func) (struct filter *),
|
||||
void *extra));
|
||||
extern bool filter_apply_chain PROTO((struct filter * chain));
|
||||
extern int filter_truncate (struct filter * chain, int max_len);
|
||||
extern int filter_tee_header PROTO((struct filter *chain));
|
||||
extern int filter_fix_linedirs PROTO((struct filter *chain));
|
||||
void *extra);
|
||||
extern bool filter_apply_chain(struct filter * chain);
|
||||
extern int filter_truncate(struct filter * chain, int max_len);
|
||||
extern int filter_tee_header(struct filter *chain);
|
||||
extern int filter_fix_linedirs(struct filter *chain);
|
||||
|
||||
|
||||
/*
|
||||
@@ -1214,9 +1146,9 @@ bool regmatch_empty (regmatch_t * m);
|
||||
typedef unsigned int scanflags_t;
|
||||
extern scanflags_t* _sf_stk;
|
||||
extern size_t _sf_top_ix, _sf_max; /**< stack of scanner flags. */
|
||||
#define _SF_CASE_INS 0x0001
|
||||
#define _SF_DOT_ALL 0x0002
|
||||
#define _SF_SKIP_WS 0x0004
|
||||
#define _SF_CASE_INS ((scanflags_t) 0x0001)
|
||||
#define _SF_DOT_ALL ((scanflags_t) 0x0002)
|
||||
#define _SF_SKIP_WS ((scanflags_t) 0x0004)
|
||||
#define sf_top() (_sf_stk[_sf_top_ix])
|
||||
#define sf_case_ins() (sf_top() & _SF_CASE_INS)
|
||||
#define sf_dot_all() (sf_top() & _SF_DOT_ALL)
|
||||
|
||||
@@ -37,16 +37,11 @@
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
void gen_next_state PROTO ((int));
|
||||
void genecs PROTO ((void));
|
||||
void indent_put2s PROTO ((const char *, const char *));
|
||||
void indent_puts PROTO ((const char *));
|
||||
void genecs(void);
|
||||
|
||||
|
||||
static int indent_level = 0; /* each level is 8 spaces */
|
||||
|
||||
#define indent_up() (++indent_level)
|
||||
#define indent_down() (--indent_level)
|
||||
#define set_indent(indent_val) indent_level = indent_val
|
||||
|
||||
/* Almost everything is done in terms of arrays starting at 1, so provide
|
||||
@@ -58,44 +53,30 @@ static int indent_level = 0; /* each level is 8 spaces */
|
||||
static const char *get_int16_decl (void)
|
||||
{
|
||||
return (gentables)
|
||||
? "static yyconst flex_int16_t %s[%d] =\n { 0,\n"
|
||||
: "static yyconst flex_int16_t * %s = 0;\n";
|
||||
? "static const flex_int16_t %s[%d] =\n { 0,\n"
|
||||
: "static const flex_int16_t * %s = 0;\n";
|
||||
}
|
||||
|
||||
|
||||
static const char *get_int32_decl (void)
|
||||
{
|
||||
return (gentables)
|
||||
? "static yyconst flex_int32_t %s[%d] =\n { 0,\n"
|
||||
: "static yyconst flex_int32_t * %s = 0;\n";
|
||||
? "static const flex_int32_t %s[%d] =\n { 0,\n"
|
||||
: "static const flex_int32_t * %s = 0;\n";
|
||||
}
|
||||
|
||||
static const char *get_state_decl (void)
|
||||
{
|
||||
return (gentables)
|
||||
? "static yyconst yy_state_type %s[%d] =\n { 0,\n"
|
||||
: "static yyconst yy_state_type * %s = 0;\n";
|
||||
}
|
||||
|
||||
static const char *get_uint16_decl (void)
|
||||
{
|
||||
return (gentables)
|
||||
? "static yyconst flex_uint16_t %s[%d] =\n { 0,\n"
|
||||
: "static yyconst flex_uint16_t * %s = 0;\n";
|
||||
}
|
||||
|
||||
static const char *get_uint32_decl (void)
|
||||
{
|
||||
return (gentables)
|
||||
? "static yyconst flex_uint32_t %s[%d] =\n { 0,\n"
|
||||
: "static yyconst flex_uint32_t * %s = 0;\n";
|
||||
? "static const yy_state_type %s[%d] =\n { 0,\n"
|
||||
: "static const yy_state_type * %s = 0;\n";
|
||||
}
|
||||
|
||||
static const char *get_yy_char_decl (void)
|
||||
{
|
||||
return (gentables)
|
||||
? "static yyconst YY_CHAR %s[%d] =\n { 0,\n"
|
||||
: "static yyconst YY_CHAR * %s = 0;\n";
|
||||
? "static const YY_CHAR %s[%d] =\n { 0,\n"
|
||||
: "static const YY_CHAR * %s = 0;\n";
|
||||
}
|
||||
|
||||
/* Indent to the current level. */
|
||||
@@ -125,12 +106,12 @@ static struct yytbl_data *mkeoltbl (void)
|
||||
flex_int8_t *tdata = 0;
|
||||
struct yytbl_data *tbl;
|
||||
|
||||
tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
|
||||
tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (tbl, YYTD_ID_RULE_CAN_MATCH_EOL);
|
||||
tbl->td_flags = YYTD_DATA8;
|
||||
tbl->td_lolen = num_rules + 1;
|
||||
tbl->td_lolen = (flex_uint32_t) (num_rules + 1);
|
||||
tbl->td_data = tdata =
|
||||
(flex_int8_t *) calloc (tbl->td_lolen, sizeof (flex_int8_t));
|
||||
calloc(tbl->td_lolen, sizeof (flex_int8_t));
|
||||
|
||||
for (i = 1; i <= num_rules; i++)
|
||||
tdata[i] = rule_has_nl[i] ? 1 : 0;
|
||||
@@ -176,12 +157,12 @@ void gen_backing_up (void)
|
||||
else
|
||||
indent_puts ("if ( yy_accept[yy_current_state] )");
|
||||
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("YY_G(yy_last_accepting_state) = yy_current_state;");
|
||||
indent_puts ("YY_G(yy_last_accepting_cpos) = yy_cp;");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
|
||||
@@ -232,14 +213,14 @@ static struct yytbl_data *mkctbl (void)
|
||||
((tblend + numecs + 1) >= INT16_MAX
|
||||
|| long_align) ? "flex_int32_t" : "flex_int16_t");
|
||||
|
||||
tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
|
||||
tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (tbl, YYTD_ID_TRANSITION);
|
||||
tbl->td_flags = YYTD_DATA32 | YYTD_STRUCT;
|
||||
tbl->td_hilen = 0;
|
||||
tbl->td_lolen = tblend + numecs + 1; /* number of structs */
|
||||
tbl->td_lolen = (flex_uint32_t) (tblend + numecs + 1); /* number of structs */
|
||||
|
||||
tbl->td_data = tdata =
|
||||
(flex_int32_t *) calloc (tbl->td_lolen * 2, sizeof (flex_int32_t));
|
||||
calloc(tbl->td_lolen * 2, sizeof (flex_int32_t));
|
||||
|
||||
/* We want the transition to be represented as the offset to the
|
||||
* next state, not the actual state number, which is what it currently
|
||||
@@ -328,14 +309,14 @@ static struct yytbl_data *mkssltbl (void)
|
||||
flex_int32_t *tdata = 0;
|
||||
flex_int32_t i;
|
||||
|
||||
tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
|
||||
tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (tbl, YYTD_ID_START_STATE_LIST);
|
||||
tbl->td_flags = YYTD_DATA32 | YYTD_PTRANS;
|
||||
tbl->td_hilen = 0;
|
||||
tbl->td_lolen = lastsc * 2 + 1;
|
||||
tbl->td_lolen = (flex_uint32_t) (lastsc * 2 + 1);
|
||||
|
||||
tbl->td_data = tdata =
|
||||
(flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(tbl->td_lolen, sizeof (flex_int32_t));
|
||||
|
||||
for (i = 0; i <= lastsc * 2; ++i)
|
||||
tdata[i] = base[i];
|
||||
@@ -358,9 +339,9 @@ void genctbl (void)
|
||||
|
||||
/* Table of verify for transition and offset to next state. */
|
||||
if (gentables)
|
||||
out_dec ("static yyconst struct yy_trans_info yy_transition[%d] =\n {\n", tblend + numecs + 1);
|
||||
out_dec ("static const struct yy_trans_info yy_transition[%d] =\n {\n", tblend + numecs + 1);
|
||||
else
|
||||
outn ("static yyconst struct yy_trans_info *yy_transition = 0;");
|
||||
outn ("static const struct yy_trans_info *yy_transition = 0;");
|
||||
|
||||
/* We want the transition to be represented as the offset to the
|
||||
* next state, not the actual state number, which is what it currently
|
||||
@@ -432,9 +413,9 @@ void genctbl (void)
|
||||
|
||||
/* Table of pointers to start states. */
|
||||
if (gentables)
|
||||
out_dec ("static yyconst struct yy_trans_info *yy_start_state_list[%d] =\n", lastsc * 2 + 1);
|
||||
out_dec ("static const struct yy_trans_info *yy_start_state_list[%d] =\n", lastsc * 2 + 1);
|
||||
else
|
||||
outn ("static yyconst struct yy_trans_info **yy_start_state_list =0;");
|
||||
outn ("static const struct yy_trans_info **yy_start_state_list =0;");
|
||||
|
||||
if (gentables) {
|
||||
outn (" {");
|
||||
@@ -452,20 +433,20 @@ void genctbl (void)
|
||||
|
||||
/* mkecstbl - Make equivalence-class tables. */
|
||||
|
||||
struct yytbl_data *mkecstbl (void)
|
||||
static struct yytbl_data *mkecstbl (void)
|
||||
{
|
||||
int i;
|
||||
struct yytbl_data *tbl = 0;
|
||||
flex_int32_t *tdata = 0;
|
||||
|
||||
tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
|
||||
tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (tbl, YYTD_ID_EC);
|
||||
tbl->td_flags |= YYTD_DATA32;
|
||||
tbl->td_hilen = 0;
|
||||
tbl->td_lolen = csize;
|
||||
tbl->td_lolen = (flex_uint32_t) csize;
|
||||
|
||||
tbl->td_data = tdata =
|
||||
(flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(tbl->td_lolen, sizeof (flex_int32_t));
|
||||
|
||||
for (i = 1; i < csize; ++i) {
|
||||
ecgroup[i] = ABS (ecgroup[i]);
|
||||
@@ -534,13 +515,13 @@ void gen_find_action (void)
|
||||
indent_puts
|
||||
("for ( ; ; ) /* until we find what rule we matched */");
|
||||
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
indent_puts ("{");
|
||||
|
||||
indent_puts
|
||||
("if ( YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1] )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("yy_act = yy_acclist[YY_G(yy_lp)];");
|
||||
|
||||
@@ -548,25 +529,25 @@ void gen_find_action (void)
|
||||
indent_puts
|
||||
("if ( yy_act & YY_TRAILING_HEAD_MASK ||");
|
||||
indent_puts (" YY_G(yy_looking_for_trail_begin) )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
|
||||
indent_puts
|
||||
("if ( yy_act == YY_G(yy_looking_for_trail_begin) )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("YY_G(yy_looking_for_trail_begin) = 0;");
|
||||
indent_puts ("yy_act &= ~YY_TRAILING_HEAD_MASK;");
|
||||
indent_puts ("break;");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts
|
||||
("else if ( yy_act & YY_TRAILING_MASK )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts
|
||||
("YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK;");
|
||||
@@ -585,10 +566,10 @@ void gen_find_action (void)
|
||||
}
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts ("else");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("YY_G(yy_full_match) = yy_cp;");
|
||||
indent_puts
|
||||
@@ -596,7 +577,7 @@ void gen_find_action (void)
|
||||
indent_puts ("YY_G(yy_full_lp) = YY_G(yy_lp);");
|
||||
indent_puts ("break;");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts ("++YY_G(yy_lp);");
|
||||
indent_puts ("goto find_rule;");
|
||||
@@ -606,16 +587,16 @@ void gen_find_action (void)
|
||||
/* Remember matched text in case we back up due to
|
||||
* trailing context plus REJECT.
|
||||
*/
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("YY_G(yy_full_match) = yy_cp;");
|
||||
indent_puts ("break;");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts ("--yy_cp;");
|
||||
|
||||
@@ -628,7 +609,7 @@ void gen_find_action (void)
|
||||
|
||||
indent_puts ("}");
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
else { /* compressed */
|
||||
@@ -639,7 +620,7 @@ void gen_find_action (void)
|
||||
* the match.
|
||||
*/
|
||||
indent_puts ("if ( yy_act == 0 )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{ /* have to back up */");
|
||||
indent_puts
|
||||
("yy_cp = YY_G(yy_last_accepting_cpos);");
|
||||
@@ -648,7 +629,7 @@ void gen_find_action (void)
|
||||
indent_puts
|
||||
("yy_act = yy_accept[yy_current_state];");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -664,14 +645,14 @@ struct yytbl_data *mkftbl (void)
|
||||
struct yytbl_data *tbl;
|
||||
flex_int32_t *tdata = 0;
|
||||
|
||||
tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
|
||||
tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (tbl, YYTD_ID_ACCEPT);
|
||||
tbl->td_flags |= YYTD_DATA32;
|
||||
tbl->td_hilen = 0; /* it's a one-dimensional array */
|
||||
tbl->td_lolen = lastdfa + 1;
|
||||
tbl->td_lolen = (flex_uint32_t) (lastdfa + 1);
|
||||
|
||||
tbl->td_data = tdata =
|
||||
(flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(tbl->td_lolen, sizeof (flex_int32_t));
|
||||
|
||||
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
|
||||
|
||||
@@ -727,8 +708,7 @@ void genftbl (void)
|
||||
|
||||
/* Generate the code to find the next compressed-table state. */
|
||||
|
||||
void gen_next_compressed_state (char_map)
|
||||
char *char_map;
|
||||
void gen_next_compressed_state (char *char_map)
|
||||
{
|
||||
indent_put2s ("YY_CHAR yy_c = %s;", char_map);
|
||||
|
||||
@@ -740,7 +720,7 @@ void gen_next_compressed_state (char_map)
|
||||
|
||||
indent_puts
|
||||
("while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("yy_current_state = (int) yy_def[yy_current_state];");
|
||||
|
||||
@@ -757,16 +737,16 @@ void gen_next_compressed_state (char_map)
|
||||
/* lastdfa + 2 is the beginning of the templates */
|
||||
out_dec ("if ( yy_current_state >= %d )\n", lastdfa + 2);
|
||||
|
||||
indent_up ();
|
||||
indent_puts ("yy_c = yy_meta[(unsigned int) yy_c];");
|
||||
indent_down ();
|
||||
++indent_level;
|
||||
indent_puts ("yy_c = yy_meta[yy_c];");
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts
|
||||
("yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];");
|
||||
("yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];");
|
||||
}
|
||||
|
||||
|
||||
@@ -793,7 +773,7 @@ void gen_next_match (void)
|
||||
("while ( (yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s ]) > 0 )",
|
||||
char_map);
|
||||
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
if (num_backing_up > 0) {
|
||||
indent_puts ("{");
|
||||
@@ -807,7 +787,7 @@ void gen_next_match (void)
|
||||
|
||||
indent_puts ("}");
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
outc ('\n');
|
||||
indent_puts ("yy_current_state = -yy_current_state;");
|
||||
@@ -816,15 +796,15 @@ void gen_next_match (void)
|
||||
else if (fullspd) {
|
||||
indent_puts ("{");
|
||||
indent_puts
|
||||
("yyconst struct yy_trans_info *yy_trans_info;\n");
|
||||
("const struct yy_trans_info *yy_trans_info;\n");
|
||||
indent_puts ("YY_CHAR yy_c;\n");
|
||||
indent_put2s ("for ( yy_c = %s;", char_map);
|
||||
indent_puts
|
||||
(" (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->");
|
||||
(" (yy_trans_info = &yy_current_state[yy_c])->");
|
||||
indent_puts ("yy_verify == yy_c;");
|
||||
indent_put2s (" yy_c = %s )", char_map_2);
|
||||
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
if (num_backing_up > 0)
|
||||
indent_puts ("{");
|
||||
@@ -837,14 +817,14 @@ void gen_next_match (void)
|
||||
indent_puts ("}");
|
||||
}
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
indent_puts ("}");
|
||||
}
|
||||
|
||||
else { /* compressed */
|
||||
indent_puts ("do");
|
||||
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
|
||||
gen_next_state (false);
|
||||
@@ -853,7 +833,7 @@ void gen_next_match (void)
|
||||
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
do_indent ();
|
||||
|
||||
@@ -878,8 +858,7 @@ void gen_next_match (void)
|
||||
|
||||
/* Generate the code to find the next state. */
|
||||
|
||||
void gen_next_state (worry_about_NULs)
|
||||
int worry_about_NULs;
|
||||
void gen_next_state (int worry_about_NULs)
|
||||
{ /* NOTE - changes in here should be reflected in gen_next_match() */
|
||||
char char_map[256];
|
||||
|
||||
@@ -905,7 +884,7 @@ void gen_next_state (worry_about_NULs)
|
||||
gen_backing_up ();
|
||||
|
||||
indent_puts ("if ( *yy_cp )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
}
|
||||
|
||||
@@ -931,12 +910,12 @@ void gen_next_state (worry_about_NULs)
|
||||
if (worry_about_NULs && nultrans) {
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
indent_puts ("else");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts
|
||||
("yy_current_state = yy_NUL_trans[yy_current_state];");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
if (fullspd || fulltbl)
|
||||
@@ -984,7 +963,7 @@ void gen_NUL_trans (void)
|
||||
out_dec ("int yy_c = %d;\n", NUL_ec);
|
||||
|
||||
indent_puts
|
||||
("yyconst struct yy_trans_info *yy_trans_info;\n");
|
||||
("const struct yy_trans_info *yy_trans_info;\n");
|
||||
indent_puts
|
||||
("yy_trans_info = &yy_current_state[(unsigned int) yy_c];");
|
||||
indent_puts ("yy_current_state += yy_trans_info->yy_nxt;");
|
||||
@@ -1009,10 +988,10 @@ void gen_NUL_trans (void)
|
||||
* the state stack and yy_c_buf_p get out of sync.
|
||||
*/
|
||||
indent_puts ("if ( ! yy_is_jam )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts
|
||||
("*YY_G(yy_state_ptr)++ = yy_current_state;");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1023,11 +1002,11 @@ void gen_NUL_trans (void)
|
||||
if (need_backing_up && (fullspd || fulltbl)) {
|
||||
outc ('\n');
|
||||
indent_puts ("if ( ! yy_is_jam )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
gen_backing_up ();
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,11 +1090,11 @@ void gentabs (void)
|
||||
"\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n",
|
||||
long_align ? "flex_int32_t" : "flex_int16_t");
|
||||
|
||||
yyacclist_tbl = (struct yytbl_data*)calloc(1,sizeof(struct yytbl_data));
|
||||
yyacclist_tbl = calloc(1,sizeof(struct yytbl_data));
|
||||
yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST);
|
||||
yyacclist_tbl->td_lolen = MAX(numas,1) + 1;
|
||||
yyacclist_tbl->td_lolen = (flex_uint32_t) (MAX(numas,1) + 1);
|
||||
yyacclist_tbl->td_data = yyacclist_data =
|
||||
(flex_int32_t *) calloc (yyacclist_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(yyacclist_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
yyacclist_curr = 1;
|
||||
|
||||
j = 1; /* index into "yy_acclist" array */
|
||||
@@ -1220,13 +1199,11 @@ void gentabs (void)
|
||||
"\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
|
||||
long_align ? "flex_int32_t" : "flex_int16_t");
|
||||
|
||||
yyacc_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct yytbl_data));
|
||||
yyacc_tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT);
|
||||
yyacc_tbl->td_lolen = k;
|
||||
yyacc_tbl->td_lolen = (flex_uint32_t) k;
|
||||
yyacc_tbl->td_data = yyacc_data =
|
||||
(flex_int32_t *) calloc (yyacc_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(yyacc_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
yyacc_curr=1;
|
||||
|
||||
for (i = 1; i <= lastdfa; ++i) {
|
||||
@@ -1279,14 +1256,11 @@ void gentabs (void)
|
||||
* templates with).
|
||||
*/
|
||||
flex_int32_t *yymecs_data = 0;
|
||||
yymeta_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct
|
||||
yytbl_data));
|
||||
yymeta_tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yymeta_tbl, YYTD_ID_META);
|
||||
yymeta_tbl->td_lolen = numecs + 1;
|
||||
yymeta_tbl->td_lolen = (flex_uint32_t) (numecs + 1);
|
||||
yymeta_tbl->td_data = yymecs_data =
|
||||
(flex_int32_t *) calloc (yymeta_tbl->td_lolen,
|
||||
calloc(yymeta_tbl->td_lolen,
|
||||
sizeof (flex_int32_t));
|
||||
|
||||
if (trace)
|
||||
@@ -1323,20 +1297,18 @@ void gentabs (void)
|
||||
|
||||
/* Begin generating yy_base */
|
||||
out_str_dec ((tblend >= INT16_MAX || long_align) ?
|
||||
get_uint32_decl () : get_uint16_decl (),
|
||||
get_int32_decl () : get_int16_decl (),
|
||||
"yy_base", total_states + 1);
|
||||
|
||||
buf_prints (&yydmap_buf,
|
||||
"\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n",
|
||||
(tblend >= INT16_MAX
|
||||
|| long_align) ? "flex_uint32_t" : "flex_uint16_t");
|
||||
yybase_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct yytbl_data));
|
||||
|| long_align) ? "flex_int32_t" : "flex_int16_t");
|
||||
yybase_tbl = calloc (1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yybase_tbl, YYTD_ID_BASE);
|
||||
yybase_tbl->td_lolen = total_states + 1;
|
||||
yybase_tbl->td_lolen = (flex_uint32_t) (total_states + 1);
|
||||
yybase_tbl->td_data = yybase_data =
|
||||
(flex_int32_t *) calloc (yybase_tbl->td_lolen,
|
||||
calloc(yybase_tbl->td_lolen,
|
||||
sizeof (flex_int32_t));
|
||||
yybase_curr = 1;
|
||||
|
||||
@@ -1390,13 +1362,11 @@ void gentabs (void)
|
||||
(total_states >= INT16_MAX
|
||||
|| long_align) ? "flex_int32_t" : "flex_int16_t");
|
||||
|
||||
yydef_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct yytbl_data));
|
||||
yydef_tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yydef_tbl, YYTD_ID_DEF);
|
||||
yydef_tbl->td_lolen = total_states + 1;
|
||||
yydef_tbl->td_lolen = (flex_uint32_t) (total_states + 1);
|
||||
yydef_tbl->td_data = yydef_data =
|
||||
(flex_int32_t *) calloc (yydef_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(yydef_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
|
||||
for (i = 1; i <= total_states; ++i) {
|
||||
mkdata (def[i]);
|
||||
@@ -1416,21 +1386,19 @@ void gentabs (void)
|
||||
|
||||
/* Begin generating yy_nxt */
|
||||
out_str_dec ((total_states >= INT16_MAX || long_align) ?
|
||||
get_uint32_decl () : get_uint16_decl (), "yy_nxt",
|
||||
get_int32_decl () : get_int16_decl (), "yy_nxt",
|
||||
tblend + 1);
|
||||
|
||||
buf_prints (&yydmap_buf,
|
||||
"\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n",
|
||||
(total_states >= INT16_MAX
|
||||
|| long_align) ? "flex_uint32_t" : "flex_uint16_t");
|
||||
|| long_align) ? "flex_int32_t" : "flex_int16_t");
|
||||
|
||||
yynxt_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct yytbl_data));
|
||||
yynxt_tbl = calloc (1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yynxt_tbl, YYTD_ID_NXT);
|
||||
yynxt_tbl->td_lolen = tblend + 1;
|
||||
yynxt_tbl->td_lolen = (flex_uint32_t) (tblend + 1);
|
||||
yynxt_tbl->td_data = yynxt_data =
|
||||
(flex_int32_t *) calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
|
||||
for (i = 1; i <= tblend; ++i) {
|
||||
/* Note, the order of the following test is important.
|
||||
@@ -1463,13 +1431,11 @@ void gentabs (void)
|
||||
(total_states >= INT16_MAX
|
||||
|| long_align) ? "flex_int32_t" : "flex_int16_t");
|
||||
|
||||
yychk_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct yytbl_data));
|
||||
yychk_tbl = calloc (1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yychk_tbl, YYTD_ID_CHK);
|
||||
yychk_tbl->td_lolen = tblend + 1;
|
||||
yychk_tbl->td_lolen = (flex_uint32_t) (tblend + 1);
|
||||
yychk_tbl->td_data = yychk_data =
|
||||
(flex_int32_t *) calloc (yychk_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
calloc(yychk_tbl->td_lolen, sizeof (flex_int32_t));
|
||||
|
||||
for (i = 1; i <= tblend; ++i) {
|
||||
if (chk[i] == 0)
|
||||
@@ -1489,7 +1455,7 @@ void gentabs (void)
|
||||
}
|
||||
/* End generating yy_chk */
|
||||
|
||||
flex_free ((void *) acc_array);
|
||||
free(acc_array);
|
||||
}
|
||||
|
||||
|
||||
@@ -1497,8 +1463,7 @@ void gentabs (void)
|
||||
* current indentation level, adding a final newline.
|
||||
*/
|
||||
|
||||
void indent_put2s (fmt, arg)
|
||||
const char *fmt, *arg;
|
||||
void indent_put2s (const char *fmt, const char *arg)
|
||||
{
|
||||
do_indent ();
|
||||
out_str (fmt, arg);
|
||||
@@ -1510,8 +1475,7 @@ void indent_put2s (fmt, arg)
|
||||
* newline.
|
||||
*/
|
||||
|
||||
void indent_puts (str)
|
||||
const char *str;
|
||||
void indent_puts (const char *str)
|
||||
{
|
||||
do_indent ();
|
||||
outn (str);
|
||||
@@ -1525,7 +1489,7 @@ void make_tables (void)
|
||||
{
|
||||
int i;
|
||||
int did_eof_rule = false;
|
||||
struct yytbl_data *yynultrans_tbl;
|
||||
struct yytbl_data *yynultrans_tbl = NULL;
|
||||
|
||||
|
||||
skelout (); /* %% [2.0] - break point in skel */
|
||||
@@ -1538,11 +1502,11 @@ void make_tables (void)
|
||||
if (yymore_used && !yytext_is_array) {
|
||||
indent_puts ("YY_G(yytext_ptr) -= YY_G(yy_more_len); \\");
|
||||
indent_puts
|
||||
("yyleng = (size_t) (yy_cp - YY_G(yytext_ptr)); \\");
|
||||
("yyleng = (int) (yy_cp - YY_G(yytext_ptr)); \\");
|
||||
}
|
||||
|
||||
else
|
||||
indent_puts ("yyleng = (size_t) (yy_cp - yy_bp); \\");
|
||||
indent_puts ("yyleng = (int) (yy_cp - yy_bp); \\");
|
||||
|
||||
/* Now also deal with copying yytext_ptr to yytext if needed. */
|
||||
skelout (); /* %% [3.0] - break point in skel */
|
||||
@@ -1553,10 +1517,10 @@ void make_tables (void)
|
||||
else
|
||||
indent_puts ("if ( yyleng >= YYLMAX ) \\");
|
||||
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts
|
||||
("YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
if (yymore_used) {
|
||||
indent_puts
|
||||
@@ -1593,7 +1557,7 @@ void make_tables (void)
|
||||
|
||||
set_indent (0);
|
||||
indent_puts ("struct yy_trans_info");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
|
||||
/* We require that yy_verify and yy_nxt must be of the same size int. */
|
||||
@@ -1609,7 +1573,7 @@ void make_tables (void)
|
||||
|
||||
indent_put2s ("%s yy_nxt;", trans_offset_type);
|
||||
indent_puts ("};");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
else {
|
||||
/* We generate a bogus 'struct yy_trans_info' data type
|
||||
@@ -1621,12 +1585,12 @@ void make_tables (void)
|
||||
("/* This struct is not used in this scanner,");
|
||||
indent_puts (" but its presence is necessary. */");
|
||||
indent_puts ("struct yy_trans_info");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("flex_int32_t yy_verify;");
|
||||
indent_puts ("flex_int32_t yy_nxt;");
|
||||
indent_puts ("};");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
if (fullspd) {
|
||||
@@ -1724,16 +1688,13 @@ void make_tables (void)
|
||||
(fullspd) ? "struct yy_trans_info*" :
|
||||
"flex_int32_t");
|
||||
|
||||
yynultrans_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct
|
||||
yytbl_data));
|
||||
yynultrans_tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS);
|
||||
if (fullspd)
|
||||
yynultrans_tbl->td_flags |= YYTD_PTRANS;
|
||||
yynultrans_tbl->td_lolen = lastdfa + 1;
|
||||
yynultrans_tbl->td_lolen = (flex_uint32_t) (lastdfa + 1);
|
||||
yynultrans_tbl->td_data = yynultrans_data =
|
||||
(flex_int32_t *) calloc (yynultrans_tbl->td_lolen,
|
||||
calloc(yynultrans_tbl->td_lolen,
|
||||
sizeof (flex_int32_t));
|
||||
|
||||
for (i = 1; i <= lastdfa; ++i) {
|
||||
@@ -1755,9 +1716,13 @@ void make_tables (void)
|
||||
0)
|
||||
flexerror (_
|
||||
("Could not write yynultrans_tbl"));
|
||||
}
|
||||
|
||||
if (yynultrans_tbl != NULL) {
|
||||
yytbl_data_destroy (yynultrans_tbl);
|
||||
yynultrans_tbl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* End generating yy_NUL_trans */
|
||||
}
|
||||
|
||||
@@ -1846,13 +1811,13 @@ void make_tables (void)
|
||||
indent_puts ("#define YY_MORE_ADJ 0");
|
||||
indent_puts
|
||||
("#define YY_RESTORE_YY_MORE_OFFSET \\");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{ \\");
|
||||
indent_puts
|
||||
("YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\");
|
||||
indent_puts ("yyleng -= YY_G(yy_more_offset); \\");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
else {
|
||||
indent_puts
|
||||
@@ -1896,7 +1861,7 @@ void make_tables (void)
|
||||
if (!C_plus_plus) {
|
||||
if (use_read) {
|
||||
outn ("\terrno=0; \\");
|
||||
outn ("\twhile ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\");
|
||||
outn ("\twhile ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) \\");
|
||||
outn ("\t{ \\");
|
||||
outn ("\t\tif( errno != EINTR) \\");
|
||||
outn ("\t\t{ \\");
|
||||
@@ -1912,7 +1877,7 @@ void make_tables (void)
|
||||
outn ("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\");
|
||||
outn ("\t\t{ \\");
|
||||
outn ("\t\tint c = '*'; \\");
|
||||
outn ("\t\tsize_t n; \\");
|
||||
outn ("\t\tint n; \\");
|
||||
outn ("\t\tfor ( n = 0; n < max_size && \\");
|
||||
outn ("\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\");
|
||||
outn ("\t\t\tbuf[n] = (char) c; \\");
|
||||
@@ -1925,7 +1890,7 @@ void make_tables (void)
|
||||
outn ("\telse \\");
|
||||
outn ("\t\t{ \\");
|
||||
outn ("\t\terrno=0; \\");
|
||||
outn ("\t\twhile ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \\");
|
||||
outn ("\t\twhile ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \\");
|
||||
outn ("\t\t\t{ \\");
|
||||
outn ("\t\t\tif( errno != EINTR) \\");
|
||||
outn ("\t\t\t\t{ \\");
|
||||
@@ -1942,16 +1907,16 @@ void make_tables (void)
|
||||
skelout (); /* %% [6.0] - break point in skel */
|
||||
|
||||
indent_puts ("#define YY_RULE_SETUP \\");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
if (bol_needed) {
|
||||
indent_puts ("if ( yyleng > 0 ) \\");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \\");
|
||||
indent_puts ("\t\t(yytext[yyleng - 1] == '\\n'); \\");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
indent_puts ("YY_USER_ACTION");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
skelout (); /* %% [7.0] - break point in skel */
|
||||
|
||||
@@ -1967,13 +1932,13 @@ void make_tables (void)
|
||||
if (yymore_used && !yytext_is_array) {
|
||||
indent_puts ("YY_G(yy_more_len) = 0;");
|
||||
indent_puts ("if ( YY_G(yy_more_flag) )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts
|
||||
("YY_G(yy_more_len) = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);");
|
||||
("YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr));");
|
||||
indent_puts ("YY_G(yy_more_flag) = 0;");
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
skelout (); /* %% [9.0] - break point in skel */
|
||||
@@ -1992,39 +1957,39 @@ void make_tables (void)
|
||||
outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[[");
|
||||
indent_puts
|
||||
("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("{");
|
||||
indent_puts ("yy_size_t yyl;");
|
||||
indent_puts ("int yyl;");
|
||||
do_indent ();
|
||||
out_str ("for ( yyl = %s; yyl < yyleng; ++yyl )\n",
|
||||
yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" :
|
||||
"YY_G(yy_more_len)") : "0");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("if ( yytext[yyl] == '\\n' )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("M4_YY_INCR_LINENO();");
|
||||
indent_down ();
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
--indent_level;
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
outn ("]])");
|
||||
|
||||
skelout (); /* %% [12.0] - break point in skel */
|
||||
if (ddebug) {
|
||||
indent_puts ("if ( yy_flex_debug )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
indent_puts ("{");
|
||||
indent_puts ("if ( yy_act == 0 )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts (C_plus_plus ?
|
||||
"std::cerr << \"--scanner backing up\\n\";" :
|
||||
"fprintf( stderr, \"--scanner backing up\\n\" );");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
do_indent ();
|
||||
out_dec ("else if ( yy_act < %d )\n", num_rules);
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
if (C_plus_plus) {
|
||||
indent_puts
|
||||
@@ -2040,11 +2005,11 @@ void make_tables (void)
|
||||
(" (long)yy_rule_linenum[yy_act], yytext );");
|
||||
}
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
do_indent ();
|
||||
out_dec ("else if ( yy_act == %d )\n", num_rules);
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
if (C_plus_plus) {
|
||||
indent_puts
|
||||
@@ -2056,21 +2021,21 @@ void make_tables (void)
|
||||
indent_puts (" yytext );");
|
||||
}
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
do_indent ();
|
||||
out_dec ("else if ( yy_act == %d )\n", num_rules + 1);
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
indent_puts (C_plus_plus ?
|
||||
"std::cerr << \"--(end of buffer or a NUL)\\n\";" :
|
||||
"fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );");
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
do_indent ();
|
||||
outn ("else");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
|
||||
if (C_plus_plus) {
|
||||
indent_puts
|
||||
@@ -2081,15 +2046,15 @@ void make_tables (void)
|
||||
("fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );");
|
||||
}
|
||||
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
|
||||
indent_puts ("}");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
/* Copy actions to output file. */
|
||||
skelout (); /* %% [13.0] - break point in skel */
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
gen_bu_action ();
|
||||
out (&action_array[action_offset]);
|
||||
|
||||
@@ -2104,9 +2069,9 @@ void make_tables (void)
|
||||
}
|
||||
|
||||
if (did_eof_rule) {
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("yyterminate();");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
|
||||
@@ -2164,17 +2129,17 @@ void make_tables (void)
|
||||
if (do_yylineno) {
|
||||
indent_puts
|
||||
("if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("M4_YY_INCR_LINENO();");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
}
|
||||
|
||||
else if (do_yylineno) {
|
||||
indent_puts ("if ( c == '\\n' )");
|
||||
indent_up ();
|
||||
++indent_level;
|
||||
indent_puts ("M4_YY_INCR_LINENO();");
|
||||
indent_down ();
|
||||
--indent_level;
|
||||
}
|
||||
|
||||
skelout ();
|
||||
@@ -2185,7 +2150,11 @@ void make_tables (void)
|
||||
|
||||
if (sectnum == 3) {
|
||||
OUT_BEGIN_CODE ();
|
||||
if (!no_section3_escape)
|
||||
fputs("[[", stdout);
|
||||
(void) flexscan (); /* copy remainder of input to output */
|
||||
if (!no_section3_escape)
|
||||
fputs("]]", stdout);
|
||||
OUT_END_CODE ();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -21,6 +21,8 @@
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int yylex (void);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
@@ -30,5 +32,5 @@ int main (int argc, char *argv[])
|
||||
|
||||
while (yylex () != 0) ;
|
||||
|
||||
return 0;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
+78
-96
@@ -36,15 +36,15 @@
|
||||
#include "version.h"
|
||||
#include "options.h"
|
||||
#include "tables.h"
|
||||
#include "parse.h"
|
||||
|
||||
static char flex_version[] = FLEX_VERSION;
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
void flexinit PROTO ((int, char **));
|
||||
void readin PROTO ((void));
|
||||
void set_up_initial_allocations PROTO ((void));
|
||||
static char *basename2 PROTO ((char *path, int should_strip_ext));
|
||||
void flexinit(int, char **);
|
||||
void readin(void);
|
||||
void set_up_initial_allocations(void);
|
||||
|
||||
|
||||
/* these globals are all defined and commented in flexdef.h */
|
||||
@@ -94,7 +94,7 @@ int *accsiz, *dhash, numas;
|
||||
int numsnpairs, jambase, jamstate;
|
||||
int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
|
||||
int current_maxccls, current_max_ccl_tbl_size;
|
||||
Char *ccltbl;
|
||||
unsigned char *ccltbl;
|
||||
char nmstr[MAXLINE];
|
||||
int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
|
||||
int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
|
||||
@@ -106,7 +106,6 @@ int num_input_files;
|
||||
jmp_buf flex_main_jmp_buf;
|
||||
bool *rule_has_nl, *ccl_has_nl;
|
||||
int nlch = '\n';
|
||||
bool ansi_func_defs, ansi_func_protos;
|
||||
|
||||
bool tablesext, tablesverify, gentables;
|
||||
char *tablesfilename=0,*tablesname=0;
|
||||
@@ -117,19 +116,9 @@ struct yytbl_writer tableswr;
|
||||
*/
|
||||
char *program_name = "flex";
|
||||
|
||||
#ifndef SHORT_FILE_NAMES
|
||||
static const char outfile_template[] = "lex.%s.%s";
|
||||
static const char backing_name[] = "lex.backup";
|
||||
static const char tablesfile_template[] = "lex.%s.tables";
|
||||
#else
|
||||
static const char outfile_template[] = "lex%s.%s";
|
||||
static const char backing_name[] = "lex.bck";
|
||||
static const char tablesfile_template[] = "lex%s.tbl";
|
||||
#endif
|
||||
|
||||
#ifdef MS_DOS
|
||||
extern unsigned _stklen = 16384;
|
||||
#endif
|
||||
|
||||
/* From scan.l */
|
||||
extern FILE* yyout;
|
||||
@@ -138,18 +127,15 @@ static char outfile_path[MAXLINE];
|
||||
static int outfile_created = 0;
|
||||
static char *skelname = NULL;
|
||||
static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */
|
||||
const char *escaped_qstart = "[[]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[]]";
|
||||
const char *escaped_qend = "[[]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[]]";
|
||||
const char *escaped_qstart = "]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[";
|
||||
const char *escaped_qend = "]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[";
|
||||
|
||||
/* For debugging. The max number of filters to apply to skeleton. */
|
||||
static int preproc_level = 1000;
|
||||
|
||||
int flex_main PROTO ((int argc, char *argv[]));
|
||||
int main PROTO ((int argc, char *argv[]));
|
||||
int flex_main (int argc, char *argv[]);
|
||||
|
||||
int flex_main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int flex_main (int argc, char *argv[])
|
||||
{
|
||||
int i, exit_status, child_status;
|
||||
|
||||
@@ -209,9 +195,7 @@ int flex_main (argc, argv)
|
||||
}
|
||||
|
||||
/* Wrapper around flex_main, so flex_main can be built as a library. */
|
||||
int main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
#if ENABLE_NLS
|
||||
#if HAVE_LOCALE_H
|
||||
@@ -227,7 +211,7 @@ int main (argc, argv)
|
||||
|
||||
/* check_options - check user-specified options */
|
||||
|
||||
void check_options ()
|
||||
void check_options (void)
|
||||
{
|
||||
int i;
|
||||
const char * m4 = NULL;
|
||||
@@ -326,12 +310,6 @@ void check_options ()
|
||||
}
|
||||
}
|
||||
|
||||
if (!ansi_func_defs)
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_DEFS", NULL);
|
||||
|
||||
if (!ansi_func_protos)
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_PROTOS", NULL);
|
||||
|
||||
if (extra_type)
|
||||
buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type);
|
||||
|
||||
@@ -363,8 +341,44 @@ void check_options ()
|
||||
|
||||
/* Setup the filter chain. */
|
||||
output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
|
||||
if ( !(m4 = getenv("M4")))
|
||||
m4 = M4;
|
||||
if ( !(m4 = getenv("M4"))) {
|
||||
char *slash;
|
||||
m4 = M4;
|
||||
if ((slash = strrchr(M4, '/')) != NULL) {
|
||||
m4 = slash+1;
|
||||
/* break up $PATH */
|
||||
const char *path = getenv("PATH");
|
||||
if (!path) {
|
||||
m4 = M4;
|
||||
} else {
|
||||
int m4_length = strlen(m4);
|
||||
do {
|
||||
size_t length = strlen(path);
|
||||
struct stat sbuf;
|
||||
|
||||
const char *endOfDir = strchr(path, ':');
|
||||
if (!endOfDir)
|
||||
endOfDir = path+length;
|
||||
|
||||
{
|
||||
char m4_path[endOfDir-path + 1 + m4_length + 1];
|
||||
|
||||
memcpy(m4_path, path, endOfDir-path);
|
||||
m4_path[endOfDir-path] = '/';
|
||||
memcpy(m4_path + (endOfDir-path) + 1, m4, m4_length + 1);
|
||||
if (stat(m4_path, &sbuf) == 0 &&
|
||||
(S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) {
|
||||
m4 = strdup(m4_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
path = endOfDir+1;
|
||||
} while (path[0]);
|
||||
if (!path[0])
|
||||
m4 = M4;
|
||||
}
|
||||
}
|
||||
}
|
||||
filter_create_ext(output_chain, m4, "-P", 0);
|
||||
filter_create_int(output_chain, filter_fix_linedirs, NULL);
|
||||
|
||||
@@ -390,26 +404,25 @@ void check_options ()
|
||||
FILE *tablesout;
|
||||
struct yytbl_hdr hdr;
|
||||
char *pname = 0;
|
||||
int nbytes = 0;
|
||||
size_t nbytes = 0;
|
||||
|
||||
buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL);
|
||||
|
||||
if (!tablesfilename) {
|
||||
nbytes = strlen (prefix) + strlen (tablesfile_template) + 2;
|
||||
tablesfilename = pname = (char *) calloc (nbytes, 1);
|
||||
tablesfilename = pname = calloc(nbytes, 1);
|
||||
snprintf (pname, nbytes, tablesfile_template, prefix);
|
||||
}
|
||||
|
||||
if ((tablesout = fopen (tablesfilename, "w")) == NULL)
|
||||
lerr (_("could not create %s"), tablesfilename);
|
||||
if (pname)
|
||||
free (pname);
|
||||
free(pname);
|
||||
tablesfilename = 0;
|
||||
|
||||
yytbl_writer_init (&tableswr, tablesout);
|
||||
|
||||
nbytes = strlen (prefix) + strlen ("tables") + 2;
|
||||
tablesname = (char *) calloc (nbytes, 1);
|
||||
tablesname = calloc(nbytes, 1);
|
||||
snprintf (tablesname, nbytes, "%stables", prefix);
|
||||
yytbl_hdr_init (&hdr, flex_version, tablesname);
|
||||
|
||||
@@ -432,6 +445,8 @@ void check_options ()
|
||||
if ( bison_bridge_lloc)
|
||||
buf_m4_define (&m4defs_buf, "<M4_YY_BISON_LLOC>", NULL);
|
||||
|
||||
if (strchr(prefix, '[') || strchr(prefix, ']'))
|
||||
flexerror(_("Prefix cannot include '[' or ']'"));
|
||||
buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
|
||||
|
||||
if (did_outfilename)
|
||||
@@ -452,7 +467,8 @@ void check_options ()
|
||||
char *str, *fmt = "#define %s %d\n";
|
||||
size_t strsz;
|
||||
|
||||
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + (int)(1 + log10(i)) + 2);
|
||||
strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2;
|
||||
str = malloc(strsz);
|
||||
if (!str)
|
||||
flexfatal(_("allocation of macro definition failed"));
|
||||
snprintf(str, strsz, fmt, scname[i], i - 1);
|
||||
@@ -474,7 +490,8 @@ void check_options ()
|
||||
m4defs_buf.nelts = 0; /* memory leak here. */
|
||||
|
||||
/* Place a bogus line directive, it will be fixed in the filter. */
|
||||
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
|
||||
if (gen_line_dirs)
|
||||
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
|
||||
|
||||
/* Dump the user defined preproc directives. */
|
||||
if (userdef_buf.elts)
|
||||
@@ -490,9 +507,7 @@ void check_options ()
|
||||
* This routine does not return.
|
||||
*/
|
||||
|
||||
void flexend (exit_status)
|
||||
int exit_status;
|
||||
|
||||
void flexend (int exit_status)
|
||||
{
|
||||
static int called_before = -1; /* prevent infinite recursion. */
|
||||
int tblsiz;
|
||||
@@ -539,7 +554,6 @@ void flexend (exit_status)
|
||||
"EOB_ACT_END_OF_FILE",
|
||||
"EOB_ACT_LAST_MATCH",
|
||||
"FLEX_SCANNER",
|
||||
"FLEX_STD",
|
||||
"REJECT",
|
||||
"YYFARGS0",
|
||||
"YYFARGS1",
|
||||
@@ -626,7 +640,7 @@ void flexend (exit_status)
|
||||
"yypop_buffer_state",
|
||||
"yyensure_buffer_stack",
|
||||
"yyalloc",
|
||||
"yyconst",
|
||||
"const",
|
||||
"yyextra",
|
||||
"yyfree",
|
||||
"yyget_debug",
|
||||
@@ -926,9 +940,7 @@ void flexend (exit_status)
|
||||
|
||||
/* flexinit - initialize flex */
|
||||
|
||||
void flexinit (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
void flexinit (int argc, char **argv)
|
||||
{
|
||||
int i, sawcmpflag, rv, optind;
|
||||
char *arg;
|
||||
@@ -953,7 +965,6 @@ void flexinit (argc, argv)
|
||||
tablesext = tablesverify = false;
|
||||
gentables = true;
|
||||
tablesfilename = tablesname = NULL;
|
||||
ansi_func_defs = ansi_func_protos = true;
|
||||
|
||||
sawcmpflag = false;
|
||||
|
||||
@@ -982,9 +993,9 @@ void flexinit (argc, argv)
|
||||
flex_init_regex();
|
||||
|
||||
/* Enable C++ if program name ends with '+'. */
|
||||
program_name = basename2 (argv[0], 0);
|
||||
program_name = basename (argv[0]);
|
||||
|
||||
if (program_name[0] != '\0' &&
|
||||
if (program_name != NULL &&
|
||||
program_name[strlen (program_name) - 1] == '+')
|
||||
C_plus_plus = true;
|
||||
|
||||
@@ -1105,7 +1116,7 @@ void flexinit (argc, argv)
|
||||
break;
|
||||
|
||||
case OPT_PREPROC_LEVEL:
|
||||
preproc_level = strtol(arg,NULL,0);
|
||||
preproc_level = (int) strtol(arg,NULL,0);
|
||||
break;
|
||||
|
||||
case OPT_MAIN:
|
||||
@@ -1268,7 +1279,7 @@ void flexinit (argc, argv)
|
||||
}
|
||||
else {
|
||||
buf_strnappend (&userdef_buf, arg,
|
||||
def - arg);
|
||||
(int) (def - arg));
|
||||
buf_strappend (&userdef_buf, " ");
|
||||
buf_strappend (&userdef_buf,
|
||||
def + 1);
|
||||
@@ -1330,14 +1341,6 @@ void flexinit (argc, argv)
|
||||
reject_really_used = false;
|
||||
break;
|
||||
|
||||
case OPT_NO_ANSI_FUNC_DEFS:
|
||||
ansi_func_defs = false;
|
||||
break;
|
||||
|
||||
case OPT_NO_ANSI_FUNC_PROTOS:
|
||||
ansi_func_protos = false;
|
||||
break;
|
||||
|
||||
case OPT_NO_YY_PUSH_STATE:
|
||||
//buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE", "1");
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0);
|
||||
@@ -1424,6 +1427,10 @@ void flexinit (argc, argv)
|
||||
break;
|
||||
case OPT_HEX:
|
||||
trace_hex = 1;
|
||||
break;
|
||||
case OPT_NO_SECT3_ESCAPE:
|
||||
no_section3_escape = true;
|
||||
break;
|
||||
} /* switch */
|
||||
} /* while scanopt() */
|
||||
|
||||
@@ -1456,13 +1463,13 @@ void flexinit (argc, argv)
|
||||
|
||||
/* readin - read in the rules section of the input file(s) */
|
||||
|
||||
void readin ()
|
||||
void readin (void)
|
||||
{
|
||||
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
|
||||
static char yy_nostdinit[] =
|
||||
"FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;";
|
||||
"FILE *yyin = NULL, *yyout = NULL;";
|
||||
|
||||
line_directive_out ((FILE *) 0, 1);
|
||||
line_directive_out(NULL, 1);
|
||||
|
||||
if (yyparse ()) {
|
||||
pinpoint_message (_("fatal parse error"));
|
||||
@@ -1590,10 +1597,7 @@ void readin ()
|
||||
outn ("\n#define FLEX_DEBUG");
|
||||
|
||||
OUT_BEGIN_CODE ();
|
||||
if (csize == 256)
|
||||
outn ("typedef unsigned char YY_CHAR;");
|
||||
else
|
||||
outn ("typedef char YY_CHAR;");
|
||||
outn ("typedef flex_uint8_t YY_CHAR;");
|
||||
OUT_END_CODE ();
|
||||
|
||||
if (C_plus_plus) {
|
||||
@@ -1637,7 +1641,7 @@ void readin ()
|
||||
|
||||
OUT_BEGIN_CODE ();
|
||||
if (fullspd)
|
||||
outn ("typedef yyconst struct yy_trans_info *yy_state_type;");
|
||||
outn ("typedef const struct yy_trans_info *yy_state_type;");
|
||||
else if (!C_plus_plus)
|
||||
outn ("typedef int yy_state_type;");
|
||||
OUT_END_CODE ();
|
||||
@@ -1715,7 +1719,7 @@ void readin ()
|
||||
|
||||
/* set_up_initial_allocations - allocate memory for internal tables */
|
||||
|
||||
void set_up_initial_allocations ()
|
||||
void set_up_initial_allocations (void)
|
||||
{
|
||||
maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS);
|
||||
current_mns = INITIAL_MNS;
|
||||
@@ -1769,31 +1773,11 @@ void set_up_initial_allocations ()
|
||||
dss = allocate_int_ptr_array (current_max_dfas);
|
||||
dfaacc = allocate_dfaacc_union (current_max_dfas);
|
||||
|
||||
nultrans = (int *) 0;
|
||||
nultrans = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* extracts basename from path, optionally stripping the extension "\.*"
|
||||
* (same concept as /bin/sh `basename`, but different handling of extension). */
|
||||
static char *basename2 (path, strip_ext)
|
||||
char *path;
|
||||
int strip_ext; /* boolean */
|
||||
{
|
||||
char *b, *e = 0;
|
||||
|
||||
b = path;
|
||||
for (b = path; *path; path++)
|
||||
if (*path == '/')
|
||||
b = path + 1;
|
||||
else if (*path == '.')
|
||||
e = path;
|
||||
|
||||
if (strip_ext && e && e > b)
|
||||
*e = '\0';
|
||||
return b;
|
||||
}
|
||||
|
||||
void usage ()
|
||||
void usage (void)
|
||||
{
|
||||
FILE *f = stdout;
|
||||
|
||||
@@ -1851,8 +1835,6 @@ void usage ()
|
||||
" --bison-bridge scanner for bison pure parser.\n"
|
||||
" --bison-locations include yylloc support.\n"
|
||||
" --stdinit initialize yyin/yyout to stdin/stdout\n"
|
||||
" --noansi-definitions old-style function definitions\n"
|
||||
" --noansi-prototypes empty parameter list in prototypes\n"
|
||||
" --nounistd do not include <unistd.h>\n"
|
||||
" --noFUNCTION do not generate a particular FUNCTION\n"
|
||||
"\n" "Miscellaneous:\n"
|
||||
|
||||
+71
-195
@@ -60,14 +60,15 @@ static void sko_push(bool dc)
|
||||
{
|
||||
if(!sko_stack){
|
||||
sko_sz = 1;
|
||||
sko_stack = (struct sko_state*)flex_alloc(sizeof(struct sko_state)*sko_sz);
|
||||
sko_stack = malloc(sizeof(struct sko_state) * (size_t) sko_sz);
|
||||
if (!sko_stack)
|
||||
flexfatal(_("allocation of sko_stack failed"));
|
||||
sko_len = 0;
|
||||
}
|
||||
if(sko_len >= sko_sz){
|
||||
sko_sz *= 2;
|
||||
sko_stack = (struct sko_state*)flex_realloc(sko_stack,sizeof(struct sko_state)*sko_sz);
|
||||
sko_stack = realloc(sko_stack,
|
||||
sizeof(struct sko_state) * (size_t) sko_sz);
|
||||
}
|
||||
|
||||
/* initialize to zero and push */
|
||||
@@ -90,9 +91,7 @@ static void sko_pop(bool* dc)
|
||||
}
|
||||
|
||||
/* Append "#define defname value\n" to the running buffer. */
|
||||
void action_define (defname, value)
|
||||
const char *defname;
|
||||
int value;
|
||||
void action_define (const char *defname, int value)
|
||||
{
|
||||
char buf[MAXLINE];
|
||||
char *cpy;
|
||||
@@ -108,39 +107,14 @@ void action_define (defname, value)
|
||||
add_action (buf);
|
||||
|
||||
/* track #defines so we can undef them when we're done. */
|
||||
cpy = copy_string (defname);
|
||||
cpy = xstrdup(defname);
|
||||
buf_append (&defs_buf, &cpy, 1);
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/** Append "m4_define([[defname]],[[value]])m4_dnl\n" to the running buffer.
|
||||
* @param defname The macro name.
|
||||
* @param value The macro value, can be NULL, which is the same as the empty string.
|
||||
*/
|
||||
static void action_m4_define (const char *defname, const char * value)
|
||||
{
|
||||
char buf[MAXLINE];
|
||||
|
||||
flexfatal ("DO NOT USE THIS FUNCTION!");
|
||||
|
||||
if ((int) strlen (defname) > MAXLINE / 2) {
|
||||
format_pinpoint_message (_
|
||||
("name \"%s\" ridiculously long"),
|
||||
defname);
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf (buf, sizeof(buf), "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value?value:"");
|
||||
add_action (buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Append "new_text" to the running buffer. */
|
||||
void add_action (new_text)
|
||||
const char *new_text;
|
||||
void add_action (const char *new_text)
|
||||
{
|
||||
int len = strlen (new_text);
|
||||
int len = (int) strlen (new_text);
|
||||
|
||||
while (len + action_index >= action_size - 10 /* slop */ ) {
|
||||
int new_size = action_size * 2;
|
||||
@@ -166,14 +140,12 @@ void add_action (new_text)
|
||||
|
||||
/* allocate_array - allocate memory for an integer array of the given size */
|
||||
|
||||
void *allocate_array (size, element_size)
|
||||
int size;
|
||||
size_t element_size;
|
||||
void *allocate_array (int size, size_t element_size)
|
||||
{
|
||||
void *mem;
|
||||
size_t num_bytes = element_size * size;
|
||||
size_t num_bytes = element_size * (size_t) size;
|
||||
|
||||
mem = flex_alloc (num_bytes);
|
||||
mem = malloc(num_bytes);
|
||||
if (!mem)
|
||||
flexfatal (_
|
||||
("memory allocation failed in allocate_array()"));
|
||||
@@ -184,11 +156,10 @@ void *allocate_array (size, element_size)
|
||||
|
||||
/* all_lower - true if a string is all lower-case */
|
||||
|
||||
int all_lower (str)
|
||||
char *str;
|
||||
int all_lower (char *str)
|
||||
{
|
||||
while (*str) {
|
||||
if (!isascii ((Char) * str) || !islower ((Char) * str))
|
||||
if (!isascii ((unsigned char) * str) || !islower ((unsigned char) * str))
|
||||
return 0;
|
||||
++str;
|
||||
}
|
||||
@@ -199,11 +170,10 @@ int all_lower (str)
|
||||
|
||||
/* all_upper - true if a string is all upper-case */
|
||||
|
||||
int all_upper (str)
|
||||
char *str;
|
||||
int all_upper (char *str)
|
||||
{
|
||||
while (*str) {
|
||||
if (!isascii ((Char) * str) || !isupper ((Char) * str))
|
||||
if (!isascii ((unsigned char) * str) || !isupper ((unsigned char) * str))
|
||||
return 0;
|
||||
++str;
|
||||
}
|
||||
@@ -225,8 +195,7 @@ int intcmp (const void *a, const void *b)
|
||||
* and exits.
|
||||
*/
|
||||
|
||||
void check_char (c)
|
||||
int c;
|
||||
void check_char (int c)
|
||||
{
|
||||
if (c >= CSIZE)
|
||||
lerr (_("bad character '%s' detected in check_char()"),
|
||||
@@ -242,57 +211,20 @@ void check_char (c)
|
||||
|
||||
/* clower - replace upper-case letter to lower-case */
|
||||
|
||||
Char clower (c)
|
||||
int c;
|
||||
unsigned char clower (int c)
|
||||
{
|
||||
return (Char) ((isascii (c) && isupper (c)) ? tolower (c) : c);
|
||||
return (unsigned char) ((isascii (c) && isupper (c)) ? tolower (c) : c);
|
||||
}
|
||||
|
||||
|
||||
/* copy_string - returns a dynamically allocated copy of a string */
|
||||
|
||||
char *copy_string (str)
|
||||
const char *str;
|
||||
char *xstrdup(const char *s)
|
||||
{
|
||||
const char *c1;
|
||||
char *c2;
|
||||
char *copy;
|
||||
unsigned int size;
|
||||
char *s2;
|
||||
|
||||
/* find length */
|
||||
for (c1 = str; *c1; ++c1) ;
|
||||
if ((s2 = strdup(s)) == NULL)
|
||||
flexfatal (_("memory allocation failure in xstrdup()"));
|
||||
|
||||
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)
|
||||
Char *str;
|
||||
{
|
||||
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;
|
||||
return s2;
|
||||
}
|
||||
|
||||
|
||||
@@ -300,19 +232,19 @@ Char *copy_unsigned_string (str)
|
||||
|
||||
int cclcmp (const void *a, const void *b)
|
||||
{
|
||||
if (!*(const Char *) a)
|
||||
if (!*(const unsigned char *) a)
|
||||
return 1;
|
||||
else
|
||||
if (!*(const Char *) b)
|
||||
if (!*(const unsigned char *) b)
|
||||
return - 1;
|
||||
else
|
||||
return *(const Char *) a - *(const Char *) b;
|
||||
return *(const unsigned char *) a - *(const unsigned char *) b;
|
||||
}
|
||||
|
||||
|
||||
/* dataend - finish up a block of data declarations */
|
||||
|
||||
void dataend ()
|
||||
void dataend (void)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (gentables) {
|
||||
@@ -330,7 +262,7 @@ void dataend ()
|
||||
|
||||
/* dataflush - flush generated data statements */
|
||||
|
||||
void dataflush ()
|
||||
void dataflush (void)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (!gentables)
|
||||
@@ -353,8 +285,7 @@ void dataflush ()
|
||||
|
||||
/* flexerror - report an error message and terminate */
|
||||
|
||||
void flexerror (msg)
|
||||
const char *msg;
|
||||
void flexerror (const char *msg)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", program_name, msg);
|
||||
flexend (1);
|
||||
@@ -363,8 +294,7 @@ void flexerror (msg)
|
||||
|
||||
/* flexfatal - report a fatal error message and terminate */
|
||||
|
||||
void flexfatal (msg)
|
||||
const char *msg;
|
||||
void flexfatal (const char *msg)
|
||||
{
|
||||
fprintf (stderr, _("%s: fatal internal error, %s\n"),
|
||||
program_name, msg);
|
||||
@@ -372,10 +302,9 @@ void flexfatal (msg)
|
||||
}
|
||||
|
||||
|
||||
/* htoi - convert a hexadecimal digit string to an integer value */
|
||||
/* htoui - convert a hexadecimal digit string to an unsigned integer value */
|
||||
|
||||
int htoi (str)
|
||||
Char str[];
|
||||
unsigned int htoui (unsigned char str[])
|
||||
{
|
||||
unsigned int result;
|
||||
|
||||
@@ -387,7 +316,8 @@ int htoi (str)
|
||||
|
||||
/* lerr - report an error message */
|
||||
|
||||
void lerr (const char *msg, ...) {
|
||||
void lerr (const char *msg, ...)
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
va_list args;
|
||||
|
||||
@@ -414,9 +344,7 @@ void lerr_fatal (const char *msg, ...)
|
||||
|
||||
/* line_directive_out - spit out a "#line" statement */
|
||||
|
||||
void line_directive_out (output_file, do_infile)
|
||||
FILE *output_file;
|
||||
int do_infile;
|
||||
void line_directive_out (FILE *output_file, int do_infile)
|
||||
{
|
||||
char directive[MAXLINE], filename[MAXLINE];
|
||||
char *s1, *s2, *s3;
|
||||
@@ -434,8 +362,8 @@ void line_directive_out (output_file, do_infile)
|
||||
s3 = &filename[sizeof (filename) - 2];
|
||||
|
||||
while (s2 < s3 && *s1) {
|
||||
if (*s1 == '\\')
|
||||
/* Escape the '\' */
|
||||
if (*s1 == '\\' || *s1 == '"')
|
||||
/* Escape the '\' or '"' */
|
||||
*s2++ = '\\';
|
||||
|
||||
*s2++ = *s1++;
|
||||
@@ -464,7 +392,7 @@ void line_directive_out (output_file, do_infile)
|
||||
* representing where the user's section 1 definitions end
|
||||
* and the prolog begins
|
||||
*/
|
||||
void mark_defs1 ()
|
||||
void mark_defs1 (void)
|
||||
{
|
||||
defs1_offset = 0;
|
||||
action_array[action_index++] = '\0';
|
||||
@@ -476,7 +404,7 @@ void mark_defs1 ()
|
||||
/* mark_prolog - mark the current position in the action array as
|
||||
* representing the end of the action prolog
|
||||
*/
|
||||
void mark_prolog ()
|
||||
void mark_prolog (void)
|
||||
{
|
||||
action_array[action_index++] = '\0';
|
||||
action_offset = action_index;
|
||||
@@ -488,8 +416,7 @@ void mark_prolog ()
|
||||
*
|
||||
* Generates a data statement initializing the current 2-D array to "value".
|
||||
*/
|
||||
void mk2data (value)
|
||||
int value;
|
||||
void mk2data (int value)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (!gentables)
|
||||
@@ -518,8 +445,7 @@ void mk2data (value)
|
||||
* Generates a data statement initializing the current array element to
|
||||
* "value".
|
||||
*/
|
||||
void mkdata (value)
|
||||
int value;
|
||||
void mkdata (int value)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (!gentables)
|
||||
@@ -544,8 +470,7 @@ void mkdata (value)
|
||||
|
||||
/* myctoi - return the integer represented by a string of digits */
|
||||
|
||||
int myctoi (array)
|
||||
const char *array;
|
||||
int myctoi (const char *array)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
@@ -557,10 +482,9 @@ int myctoi (array)
|
||||
|
||||
/* myesc - return character corresponding to escape sequence */
|
||||
|
||||
Char myesc (array)
|
||||
Char array[];
|
||||
unsigned char myesc (unsigned char array[])
|
||||
{
|
||||
Char c, esc_char;
|
||||
unsigned char c, esc_char;
|
||||
|
||||
switch (array[1]) {
|
||||
case 'b':
|
||||
@@ -573,19 +497,10 @@ Char myesc (array)
|
||||
return '\r';
|
||||
case 't':
|
||||
return '\t';
|
||||
|
||||
#if defined (__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':
|
||||
@@ -597,7 +512,8 @@ Char myesc (array)
|
||||
{ /* \<octal> */
|
||||
int sptr = 1;
|
||||
|
||||
while (isascii (array[sptr]) &&
|
||||
while (sptr <= 3 &&
|
||||
isascii (array[sptr]) &&
|
||||
isdigit (array[sptr]))
|
||||
/* Don't increment inside loop control
|
||||
* because if isdigit() is a macro it might
|
||||
@@ -608,7 +524,7 @@ Char myesc (array)
|
||||
c = array[sptr];
|
||||
array[sptr] = '\0';
|
||||
|
||||
esc_char = otoi (array + 1);
|
||||
esc_char = (unsigned char) otoui (array + 1);
|
||||
|
||||
array[sptr] = c;
|
||||
|
||||
@@ -630,7 +546,7 @@ Char myesc (array)
|
||||
c = array[sptr];
|
||||
array[sptr] = '\0';
|
||||
|
||||
esc_char = htoi (array + 2);
|
||||
esc_char = (unsigned char) htoui (array + 2);
|
||||
|
||||
array[sptr] = c;
|
||||
|
||||
@@ -643,10 +559,9 @@ Char myesc (array)
|
||||
}
|
||||
|
||||
|
||||
/* otoi - convert an octal digit string to an integer value */
|
||||
/* otoui - convert an octal digit string to an unsigned integer value */
|
||||
|
||||
int otoi (str)
|
||||
Char str[];
|
||||
unsigned int otoui (unsigned char str[])
|
||||
{
|
||||
unsigned int result;
|
||||
|
||||
@@ -659,60 +574,47 @@ int otoi (str)
|
||||
* generated scanner, keeping track of the line count.
|
||||
*/
|
||||
|
||||
void out (str)
|
||||
const char *str;
|
||||
void out (const char *str)
|
||||
{
|
||||
fputs (str, stdout);
|
||||
}
|
||||
|
||||
void out_dec (fmt, n)
|
||||
const char *fmt;
|
||||
int n;
|
||||
void out_dec (const char *fmt, int n)
|
||||
{
|
||||
fprintf (stdout, fmt, n);
|
||||
}
|
||||
|
||||
void out_dec2 (fmt, n1, n2)
|
||||
const char *fmt;
|
||||
int n1, n2;
|
||||
void out_dec2 (const char *fmt, int n1, int n2)
|
||||
{
|
||||
fprintf (stdout, fmt, n1, n2);
|
||||
}
|
||||
|
||||
void out_hex (fmt, x)
|
||||
const char *fmt;
|
||||
unsigned int x;
|
||||
void out_hex (const char *fmt, unsigned int x)
|
||||
{
|
||||
fprintf (stdout, fmt, x);
|
||||
}
|
||||
|
||||
void out_str (fmt, str)
|
||||
const char *fmt, str[];
|
||||
void out_str (const char *fmt, const char str[])
|
||||
{
|
||||
fprintf (stdout,fmt, str);
|
||||
}
|
||||
|
||||
void out_str3 (fmt, s1, s2, s3)
|
||||
const char *fmt, s1[], s2[], s3[];
|
||||
void out_str3 (const char *fmt, const char s1[], const char s2[], const char s3[])
|
||||
{
|
||||
fprintf (stdout,fmt, s1, s2, s3);
|
||||
}
|
||||
|
||||
void out_str_dec (fmt, str, n)
|
||||
const char *fmt, str[];
|
||||
int n;
|
||||
void out_str_dec (const char *fmt, const char str[], int n)
|
||||
{
|
||||
fprintf (stdout,fmt, str, n);
|
||||
}
|
||||
|
||||
void outc (c)
|
||||
int c;
|
||||
void outc (int c)
|
||||
{
|
||||
fputc (c, stdout);
|
||||
}
|
||||
|
||||
void outn (str)
|
||||
const char *str;
|
||||
void outn (const char *str)
|
||||
{
|
||||
fputs (str,stdout);
|
||||
fputc('\n',stdout);
|
||||
@@ -734,8 +636,7 @@ void out_m4_define (const char* def, const char* val)
|
||||
* The returned string is in static storage.
|
||||
*/
|
||||
|
||||
char *readable_form (c)
|
||||
int c;
|
||||
char *readable_form (int c)
|
||||
{
|
||||
static char rform[20];
|
||||
|
||||
@@ -751,14 +652,10 @@ char *readable_form (c)
|
||||
return "\\r";
|
||||
case '\t':
|
||||
return "\\t";
|
||||
|
||||
#if defined (__STDC__)
|
||||
case '\a':
|
||||
return "\\a";
|
||||
case '\v':
|
||||
return "\\v";
|
||||
#endif
|
||||
|
||||
default:
|
||||
if(trace_hex)
|
||||
snprintf (rform, sizeof(rform), "\\x%.2x", (unsigned int) c);
|
||||
@@ -772,7 +669,7 @@ char *readable_form (c)
|
||||
return "' '";
|
||||
|
||||
else {
|
||||
rform[0] = c;
|
||||
rform[0] = (char) c;
|
||||
rform[1] = '\0';
|
||||
|
||||
return rform;
|
||||
@@ -782,15 +679,12 @@ char *readable_form (c)
|
||||
|
||||
/* reallocate_array - increase the size of a dynamic array */
|
||||
|
||||
void *reallocate_array (array, size, element_size)
|
||||
void *array;
|
||||
int size;
|
||||
size_t element_size;
|
||||
void *reallocate_array (void *array, int size, size_t element_size)
|
||||
{
|
||||
void *new_array;
|
||||
size_t num_bytes = element_size * size;
|
||||
size_t num_bytes = element_size * (size_t) size;
|
||||
|
||||
new_array = flex_realloc (array, num_bytes);
|
||||
new_array = realloc(array, num_bytes);
|
||||
if (!new_array)
|
||||
flexfatal (_("attempt to increase array size failed"));
|
||||
|
||||
@@ -804,7 +698,7 @@ void *reallocate_array (array, size, element_size)
|
||||
* Copies skelfile or skel array to stdout until a line beginning with
|
||||
* "%%" or EOF is found.
|
||||
*/
|
||||
void skelout ()
|
||||
void skelout (void)
|
||||
{
|
||||
char buf_storage[MAXLINE];
|
||||
char *buf = buf_storage;
|
||||
@@ -935,8 +829,7 @@ void skelout ()
|
||||
* element_n. Formats the output with spaces and carriage returns.
|
||||
*/
|
||||
|
||||
void transition_struct_out (element_v, element_n)
|
||||
int element_v, element_n;
|
||||
void transition_struct_out (int element_v, int element_n)
|
||||
{
|
||||
|
||||
/* short circuit any output */
|
||||
@@ -960,12 +853,14 @@ void transition_struct_out (element_v, element_n)
|
||||
|
||||
/* The following is only needed when building flex's parser using certain
|
||||
* broken versions of bison.
|
||||
*
|
||||
* XXX: this is should go soon
|
||||
*/
|
||||
void *yy_flex_xmalloc (size)
|
||||
int size;
|
||||
void *yy_flex_xmalloc (int size)
|
||||
{
|
||||
void *result = flex_alloc ((size_t) size);
|
||||
void *result;
|
||||
|
||||
result = malloc((size_t) size);
|
||||
if (!result)
|
||||
flexfatal (_
|
||||
("memory allocation failed in yy_flex_xmalloc()"));
|
||||
@@ -974,29 +869,10 @@ void *yy_flex_xmalloc (size)
|
||||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
{
|
||||
char *rp, *rp_end;
|
||||
|
||||
rp = region_ptr;
|
||||
rp_end = region_ptr + size_in_bytes;
|
||||
|
||||
while (rp < rp_end)
|
||||
*rp++ = 0;
|
||||
}
|
||||
|
||||
/* Remove all '\n' and '\r' characters, if any, from the end of str.
|
||||
* str can be any null-terminated string, or NULL.
|
||||
* returns str. */
|
||||
char *chomp (str)
|
||||
char *str;
|
||||
char *chomp (char *str)
|
||||
{
|
||||
char *p = str;
|
||||
|
||||
|
||||
+8
-9
@@ -21,17 +21,16 @@
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
|
||||
cat <<!
|
||||
/* File created from flex.skl via mkskel.sh */
|
||||
echo '/* File created from flex.skl via mkskel.sh */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
const char *skel[] = {
|
||||
!
|
||||
const char *skel[] = {'
|
||||
|
||||
sed 's/\\/&&/g' | sed 's/"/\\"/g' | sed 's/.*/ "&",/'
|
||||
sed 's/m4_/m4preproc_/g
|
||||
s/a4_/4_/g
|
||||
s/[\\"]/\\&/g
|
||||
s/.*/ "&",/'
|
||||
|
||||
cat <<!
|
||||
0
|
||||
};
|
||||
!
|
||||
echo ' 0
|
||||
};'
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
int dupmachine PROTO ((int));
|
||||
void mkxtion PROTO ((int, int));
|
||||
int dupmachine(int);
|
||||
void mkxtion(int, int);
|
||||
|
||||
|
||||
/* add_accept - add an accepting state to a machine
|
||||
@@ -45,8 +45,7 @@ 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 (int mach, int 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
|
||||
@@ -77,8 +76,7 @@ void add_accept (mach, accepting_number)
|
||||
* num - the number of copies of singl to be present in newsng
|
||||
*/
|
||||
|
||||
int copysingl (singl, num)
|
||||
int singl, num;
|
||||
int copysingl (int singl, int num)
|
||||
{
|
||||
int copy, i;
|
||||
|
||||
@@ -93,9 +91,7 @@ int copysingl (singl, num)
|
||||
|
||||
/* dumpnfa - debugging routine to write out an nfa */
|
||||
|
||||
void dumpnfa (state1)
|
||||
int state1;
|
||||
|
||||
void dumpnfa (int state1)
|
||||
{
|
||||
int sym, tsp1, tsp2, anum, ns;
|
||||
|
||||
@@ -148,8 +144,7 @@ void dumpnfa (state1)
|
||||
* states accessible by the arrays firstst and lastst
|
||||
*/
|
||||
|
||||
int dupmachine (mach)
|
||||
int mach;
|
||||
int dupmachine (int mach)
|
||||
{
|
||||
int i, init, state_offset;
|
||||
int state = 0;
|
||||
@@ -196,9 +191,8 @@ int dupmachine (mach)
|
||||
* context has variable length.
|
||||
*/
|
||||
|
||||
void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
|
||||
pcont_act)
|
||||
int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
|
||||
void finish_rule (int mach, int variable_trail_rule, int headcnt, int trailcnt,
|
||||
int pcont_act)
|
||||
{
|
||||
char action_text[MAXLINE];
|
||||
|
||||
@@ -292,7 +286,8 @@ void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
|
||||
if (!continued_action)
|
||||
add_action ("YY_RULE_SETUP\n");
|
||||
|
||||
line_directive_out ((FILE *) 0, 1);
|
||||
line_directive_out(NULL, 1);
|
||||
add_action("[[");
|
||||
}
|
||||
|
||||
|
||||
@@ -312,8 +307,7 @@ void finish_rule (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;
|
||||
int link_machines (int first, int last)
|
||||
{
|
||||
if (first == NIL)
|
||||
return last;
|
||||
@@ -339,8 +333,7 @@ int link_machines (first, last)
|
||||
* The "beginning" states are the epsilon closure of the first state
|
||||
*/
|
||||
|
||||
void mark_beginning_as_normal (mach)
|
||||
int mach;
|
||||
void mark_beginning_as_normal (int mach)
|
||||
{
|
||||
switch (state_type[mach]) {
|
||||
case STATE_NORMAL:
|
||||
@@ -381,8 +374,7 @@ void mark_beginning_as_normal (mach)
|
||||
* more mkbranch's. Compare with mkor()
|
||||
*/
|
||||
|
||||
int mkbranch (first, second)
|
||||
int first, second;
|
||||
int mkbranch (int first, int second)
|
||||
{
|
||||
int eps;
|
||||
|
||||
@@ -409,8 +401,7 @@ int mkbranch (first, second)
|
||||
* new - a new state which matches the closure of "state"
|
||||
*/
|
||||
|
||||
int mkclos (state)
|
||||
int state;
|
||||
int mkclos (int state)
|
||||
{
|
||||
return mkopt (mkposcl (state));
|
||||
}
|
||||
@@ -430,8 +421,7 @@ int mkclos (state)
|
||||
* 2. mach is destroyed by the call
|
||||
*/
|
||||
|
||||
int mkopt (mach)
|
||||
int mach;
|
||||
int mkopt (int mach)
|
||||
{
|
||||
int eps;
|
||||
|
||||
@@ -467,8 +457,7 @@ int mkopt (mach)
|
||||
* the number of epsilon states needed
|
||||
*/
|
||||
|
||||
int mkor (first, second)
|
||||
int first, second;
|
||||
int mkor (int first, int second)
|
||||
{
|
||||
int eps, orend;
|
||||
|
||||
@@ -523,8 +512,7 @@ int mkor (first, second)
|
||||
* new - a machine matching the positive closure of "state"
|
||||
*/
|
||||
|
||||
int mkposcl (state)
|
||||
int state;
|
||||
int mkposcl (int state)
|
||||
{
|
||||
int eps;
|
||||
|
||||
@@ -553,8 +541,7 @@ int mkposcl (state)
|
||||
* if "ub" is INFINITE_REPEAT then "new" matches "lb" or more occurrences of "mach"
|
||||
*/
|
||||
|
||||
int mkrep (mach, lb, ub)
|
||||
int mach, lb, ub;
|
||||
int mkrep (int mach, int lb, int ub)
|
||||
{
|
||||
int base_mach, tail, copy, i;
|
||||
|
||||
@@ -600,8 +587,7 @@ int mkrep (mach, lb, ub)
|
||||
* that it admittedly is)
|
||||
*/
|
||||
|
||||
int mkstate (sym)
|
||||
int sym;
|
||||
int mkstate (int sym)
|
||||
{
|
||||
if (++lastnfa >= current_mns) {
|
||||
if ((current_mns += MNS_INCREMENT) >= maximum_mns)
|
||||
@@ -677,8 +663,7 @@ current_mns);
|
||||
* stateto - the state to which the transition is to be made
|
||||
*/
|
||||
|
||||
void mkxtion (statefrom, stateto)
|
||||
int statefrom, stateto;
|
||||
void mkxtion (int statefrom, int stateto)
|
||||
{
|
||||
if (trans1[statefrom] == NO_TRANSITION)
|
||||
trans1[statefrom] = stateto;
|
||||
@@ -695,7 +680,7 @@ void mkxtion (statefrom, stateto)
|
||||
|
||||
/* new_rule - initialize for a new rule */
|
||||
|
||||
void new_rule ()
|
||||
void new_rule (void)
|
||||
{
|
||||
if (++num_rules >= current_max_rules) {
|
||||
++num_reallocs;
|
||||
|
||||
+2
-5
@@ -213,10 +213,6 @@ optspec_t flexopts[] = {
|
||||
,
|
||||
{"--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}
|
||||
@@ -275,7 +271,8 @@ optspec_t flexopts[] = {
|
||||
,
|
||||
{"--noyyset_lloc", OPT_NO_YYSET_LLOC, 0}
|
||||
,
|
||||
|
||||
{"--unsafe-no-m4-sect3-escape", OPT_NO_SECT3_ESCAPE, 0}
|
||||
,
|
||||
{0, 0, 0} /* required final NULL entry. */
|
||||
};
|
||||
|
||||
|
||||
+2
-3
@@ -68,8 +68,6 @@ enum flexopt_flag_t {
|
||||
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,
|
||||
@@ -127,7 +125,8 @@ enum flexopt_flag_t {
|
||||
OPT_YYCLASS,
|
||||
OPT_YYLINENO,
|
||||
OPT_YYMORE,
|
||||
OPT_YYWRAP
|
||||
OPT_YYWRAP,
|
||||
OPT_NO_SECT3_ESCAPE,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+31
-39
@@ -1,8 +1,8 @@
|
||||
/* 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 OPT_HEADER OPT_EXTRA_TYPE
|
||||
%token OPT_TABLES
|
||||
%token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE
|
||||
%token TOK_TABLES_FILE
|
||||
|
||||
%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
|
||||
@@ -140,7 +140,7 @@ goal : initlex sect1 sect1end sect2 initforrule
|
||||
else
|
||||
add_action( "ECHO" );
|
||||
|
||||
add_action( ";\n\tYY_BREAK\n" );
|
||||
add_action( ";\n\tYY_BREAK]]\n" );
|
||||
}
|
||||
;
|
||||
|
||||
@@ -184,28 +184,30 @@ namelist1 : namelist1 NAME
|
||||
{ synerr( _("bad start condition list") ); }
|
||||
;
|
||||
|
||||
options : OPTION_OP optionlist
|
||||
options : TOK_OPTION optionlist
|
||||
;
|
||||
|
||||
optionlist : optionlist option
|
||||
|
|
||||
;
|
||||
|
||||
option : OPT_OUTFILE '=' NAME
|
||||
option : TOK_OUTFILE '=' NAME
|
||||
{
|
||||
outfilename = copy_string( nmstr );
|
||||
outfilename = xstrdup(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 ); }
|
||||
| TOK_EXTRA_TYPE '=' NAME
|
||||
{ extra_type = xstrdup(nmstr); }
|
||||
| TOK_PREFIX '=' NAME
|
||||
{ prefix = xstrdup(nmstr);
|
||||
if (strchr(prefix, '[') || strchr(prefix, ']'))
|
||||
flexerror(_("Prefix must not contain [ or ]")); }
|
||||
| TOK_YYCLASS '=' NAME
|
||||
{ yyclass = xstrdup(nmstr); }
|
||||
| TOK_HEADER_FILE '=' NAME
|
||||
{ headerfilename = xstrdup(nmstr); }
|
||||
| TOK_TABLES_FILE '=' NAME
|
||||
{ tablesext = true; tablesfilename = xstrdup(nmstr); }
|
||||
;
|
||||
|
||||
sect2 : sect2 scon initforrule flexrule '\n'
|
||||
@@ -725,7 +727,7 @@ singleton : singleton '*'
|
||||
{
|
||||
/* Sort characters for fast searching.
|
||||
*/
|
||||
qsort( ccltbl + cclmap[$1], ccllen[$1], sizeof (*ccltbl), cclcmp );
|
||||
qsort( ccltbl + cclmap[$1], (size_t) ccllen[$1], sizeof (*ccltbl), cclcmp );
|
||||
|
||||
if ( useecs )
|
||||
mkeccl( ccltbl + cclmap[$1], ccllen[$1],
|
||||
@@ -951,7 +953,7 @@ string : string CHAR
|
||||
* conditions
|
||||
*/
|
||||
|
||||
void build_eof_action()
|
||||
void build_eof_action(void)
|
||||
{
|
||||
int i;
|
||||
char action_text[MAXLINE];
|
||||
@@ -976,7 +978,8 @@ void build_eof_action()
|
||||
}
|
||||
}
|
||||
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
line_directive_out(NULL, 1);
|
||||
add_action("[[");
|
||||
|
||||
/* This isn't a normal rule after all - don't count it as
|
||||
* such, so we don't have any holes in the rule numbering
|
||||
@@ -990,8 +993,7 @@ void build_eof_action()
|
||||
|
||||
/* format_synerr - write out formatted syntax error */
|
||||
|
||||
void format_synerr( msg, arg )
|
||||
const char *msg, arg[];
|
||||
void format_synerr( const char *msg, const char arg[] )
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
@@ -1002,8 +1004,7 @@ const char *msg, arg[];
|
||||
|
||||
/* synerr - report a syntax error */
|
||||
|
||||
void synerr( str )
|
||||
const char *str;
|
||||
void synerr( const char *str )
|
||||
{
|
||||
syntaxerror = true;
|
||||
pinpoint_message( str );
|
||||
@@ -1012,8 +1013,7 @@ const char *str;
|
||||
|
||||
/* format_warn - write out formatted warning */
|
||||
|
||||
void format_warn( msg, arg )
|
||||
const char *msg, arg[];
|
||||
void format_warn( const char *msg, const char arg[] )
|
||||
{
|
||||
char warn_msg[MAXLINE];
|
||||
|
||||
@@ -1024,8 +1024,7 @@ const char *msg, arg[];
|
||||
|
||||
/* warn - report a warning, unless -w was given */
|
||||
|
||||
void warn( str )
|
||||
const char *str;
|
||||
void warn( const char *str )
|
||||
{
|
||||
line_warning( str, linenum );
|
||||
}
|
||||
@@ -1034,8 +1033,7 @@ const char *str;
|
||||
* pinpointing its location
|
||||
*/
|
||||
|
||||
void format_pinpoint_message( msg, arg )
|
||||
const char *msg, arg[];
|
||||
void format_pinpoint_message( const char *msg, const char arg[] )
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
@@ -1046,8 +1044,7 @@ const char *msg, arg[];
|
||||
|
||||
/* pinpoint_message - write out a message, pinpointing its location */
|
||||
|
||||
void pinpoint_message( str )
|
||||
const char *str;
|
||||
void pinpoint_message( const char *str )
|
||||
{
|
||||
line_pinpoint( str, linenum );
|
||||
}
|
||||
@@ -1055,9 +1052,7 @@ const char *str;
|
||||
|
||||
/* line_warning - report a warning at a given line, unless -w was given */
|
||||
|
||||
void line_warning( str, line )
|
||||
const char *str;
|
||||
int line;
|
||||
void line_warning( const char *str, int line )
|
||||
{
|
||||
char warning[MAXLINE];
|
||||
|
||||
@@ -1071,9 +1066,7 @@ int line;
|
||||
|
||||
/* line_pinpoint - write out a message, pinpointing it at the given line */
|
||||
|
||||
void line_pinpoint( str, line )
|
||||
const char *str;
|
||||
int line;
|
||||
void line_pinpoint( const char *str, int line )
|
||||
{
|
||||
fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
|
||||
}
|
||||
@@ -1083,8 +1076,7 @@ int line;
|
||||
* currently, messages are ignore
|
||||
*/
|
||||
|
||||
void yyerror( msg )
|
||||
const char *msg;
|
||||
void yyerror( const char *msg )
|
||||
{
|
||||
(void)msg;
|
||||
}
|
||||
|
||||
+9
-9
@@ -54,13 +54,13 @@ void flex_regcomp(regex_t *preg, const char *regex, int cflags)
|
||||
memset (preg, 0, sizeof (regex_t));
|
||||
|
||||
if ((err = regcomp (preg, regex, cflags)) != 0) {
|
||||
const int errbuf_sz = 200;
|
||||
const size_t errbuf_sz = 200;
|
||||
char *errbuf, *rxerr;
|
||||
|
||||
errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
|
||||
errbuf = malloc(errbuf_sz * sizeof(char));
|
||||
if (!errbuf)
|
||||
flexfatal(_("Unable to allocate buffer to report regcomp"));
|
||||
rxerr = (char*)flex_alloc(errbuf_sz *sizeof(char));
|
||||
rxerr = malloc(errbuf_sz * sizeof(char));
|
||||
if (!rxerr)
|
||||
flexfatal(_("Unable to allocate buffer for regerror"));
|
||||
regerror (err, preg, rxerr, errbuf_sz);
|
||||
@@ -80,12 +80,12 @@ void flex_regcomp(regex_t *preg, const char *regex, int cflags)
|
||||
char *regmatch_dup (regmatch_t * m, const char *src)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (m == NULL || m->rm_so < 0)
|
||||
if (m == NULL || m->rm_so < 0 || m->rm_eo < m->rm_so)
|
||||
return NULL;
|
||||
len = m->rm_eo - m->rm_so;
|
||||
str = (char *) flex_alloc ((len + 1) * sizeof (char));
|
||||
len = (size_t) (m->rm_eo - m->rm_so);
|
||||
str = malloc((len + 1) * sizeof(char));
|
||||
if (!str)
|
||||
flexfatal(_("Unable to allocate a copy of the match"));
|
||||
strncpy (str, src + m->rm_so, len);
|
||||
@@ -107,7 +107,7 @@ char *regmatch_cpy (regmatch_t * m, char *dest, const char *src)
|
||||
return dest;
|
||||
}
|
||||
|
||||
snprintf (dest, regmatch_len(m), "%s", src + m->rm_so);
|
||||
snprintf (dest, (size_t) regmatch_len(m), "%s", src + m->rm_so);
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ int regmatch_strtol (regmatch_t * m, const char *src, char **endptr,
|
||||
else
|
||||
s = regmatch_dup (m, src);
|
||||
|
||||
n = strtol (s, endptr, base);
|
||||
n = (int) strtol (s, endptr, base);
|
||||
|
||||
if (s != buf)
|
||||
free (s);
|
||||
|
||||
+183
-163
@@ -38,6 +38,12 @@ extern bool tablesverify, tablesext;
|
||||
extern int trlcontxt; /* Set in parse.y for each rule. */
|
||||
extern const char *escaped_qstart, *escaped_qend;
|
||||
|
||||
#define M4QSTART "[""["
|
||||
#define M4QEND "]""]"
|
||||
|
||||
#define ESCAPED_QSTART "[" M4QEND M4QSTART "[" M4QEND M4QSTART
|
||||
#define ESCAPED_QEND M4QEND "]" M4QSTART M4QEND "]" M4QSTART
|
||||
|
||||
#define ACTION_ECHO add_action( yytext )
|
||||
#define ACTION_IFDEF(def, should_define) \
|
||||
{ \
|
||||
@@ -45,8 +51,8 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
action_define( def, 1 ); \
|
||||
}
|
||||
|
||||
#define ACTION_ECHO_QSTART add_action (escaped_qstart)
|
||||
#define ACTION_ECHO_QEND add_action (escaped_qend)
|
||||
#define ACTION_ECHO_QSTART add_action (ESCAPED_QSTART)
|
||||
#define ACTION_ECHO_QEND add_action (ESCAPED_QEND)
|
||||
|
||||
#define ACTION_M4_IFDEF(def, should_define) \
|
||||
do{ \
|
||||
@@ -59,7 +65,7 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
#define MARK_END_OF_PROLOG mark_prolog();
|
||||
|
||||
#define YY_DECL \
|
||||
int flexscan()
|
||||
int flexscan(void)
|
||||
|
||||
#define RETURNCHAR \
|
||||
yylval = (unsigned char) yytext[0]; \
|
||||
@@ -69,17 +75,19 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
if(yyleng < MAXLINE) \
|
||||
{ \
|
||||
strcpy( nmstr, yytext ); \
|
||||
return NAME; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
do { \
|
||||
synerr(_("Input line too long\n")); \
|
||||
FLEX_EXIT(EXIT_FAILURE); \
|
||||
} \
|
||||
return NAME;
|
||||
} while (0)
|
||||
|
||||
#define PUT_BACK_STRING(str, start) \
|
||||
for ( i = strlen( str ) - 1; i >= start; --i ) \
|
||||
unput((str)[i])
|
||||
{ size_t i = strlen( str ); \
|
||||
while ( i > start ) \
|
||||
unput((str)[--i]); \
|
||||
}
|
||||
|
||||
#define CHECK_REJECT(str) \
|
||||
if ( all_upper( str ) ) \
|
||||
@@ -93,6 +101,23 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
if ( getenv("POSIXLY_CORRECT") ) \
|
||||
posix_compat = true;
|
||||
|
||||
#define START_CODEBLOCK(x) do { \
|
||||
/* Emit the needed line directive... */\
|
||||
if (indented_code == false) { \
|
||||
linenum++; \
|
||||
line_directive_out(NULL, 1); \
|
||||
} \
|
||||
add_action(M4QSTART); \
|
||||
yy_push_state(CODEBLOCK); \
|
||||
if ((indented_code = x)) ACTION_ECHO; \
|
||||
} while(0)
|
||||
|
||||
#define END_CODEBLOCK do { \
|
||||
yy_pop_state();\
|
||||
add_action(M4QEND); \
|
||||
if (!indented_code) line_directive_out(NULL, 0);\
|
||||
} while (0)
|
||||
|
||||
%}
|
||||
|
||||
%option caseless nodefault noreject stack noyy_top_state
|
||||
@@ -104,7 +129,9 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
%x GROUP_WITH_PARAMS
|
||||
%x GROUP_MINUS_PARAMS
|
||||
%x EXTENDED_COMMENT
|
||||
%x COMMENT_DISCARD
|
||||
%x COMMENT_DISCARD CODE_COMMENT
|
||||
%x SECT3_NOESCAPE
|
||||
%x CHARACTER_CONSTANT
|
||||
|
||||
WS [[:blank:]]+
|
||||
OPTWS [[:blank:]]*
|
||||
@@ -125,8 +152,8 @@ CCL_EXPR ("[:"^?[[:alpha:]]+":]")
|
||||
|
||||
LEXOPT [aceknopr]
|
||||
|
||||
M4QSTART "[["
|
||||
M4QEND "]]"
|
||||
M4QSTART "[""["
|
||||
M4QEND "]""]"
|
||||
|
||||
%%
|
||||
static int bracelevel, didadef, indented_code;
|
||||
@@ -134,22 +161,17 @@ M4QEND "]]"
|
||||
static int option_sense;
|
||||
|
||||
int doing_codeblock = false;
|
||||
int i, brace_depth=0, brace_start_line=0;
|
||||
Char nmdef[MAXLINE];
|
||||
int brace_depth=0, brace_start_line=0;
|
||||
char nmdef[MAXLINE];
|
||||
|
||||
|
||||
<INITIAL>{
|
||||
^{WS} indented_code = true; BEGIN(CODEBLOCK);
|
||||
^"/*" ACTION_ECHO; yy_push_state( COMMENT );
|
||||
^{WS} START_CODEBLOCK(true);
|
||||
^"/*" add_action("/*[""["); 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);
|
||||
}
|
||||
^"%{".*{NL} START_CODEBLOCK(false);
|
||||
^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
|
||||
brace_start_line = linenum;
|
||||
++linenum;
|
||||
@@ -166,7 +188,7 @@ M4QEND "]]"
|
||||
sectnum = 2;
|
||||
bracelevel = 0;
|
||||
mark_defs1();
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
line_directive_out(NULL, 1);
|
||||
BEGIN(SECT2PROLOG);
|
||||
return SECTEND;
|
||||
}
|
||||
@@ -174,7 +196,7 @@ M4QEND "]]"
|
||||
^"%pointer".*{NL} yytext_is_array = false; ++linenum;
|
||||
^"%array".*{NL} yytext_is_array = true; ++linenum;
|
||||
|
||||
^"%option" BEGIN(OPTION); return OPTION_OP;
|
||||
^"%option" BEGIN(OPTION); return TOK_OPTION;
|
||||
|
||||
^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
|
||||
^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
|
||||
@@ -203,14 +225,18 @@ M4QEND "]]"
|
||||
}
|
||||
|
||||
|
||||
<COMMENT>{
|
||||
"*/" ACTION_ECHO; yy_pop_state();
|
||||
"*" ACTION_ECHO;
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
[^*\n] ACTION_ECHO;
|
||||
<COMMENT,CODE_COMMENT>{ /* */
|
||||
[^\[\]\*\n]* ACTION_ECHO;
|
||||
. ACTION_ECHO;
|
||||
|
||||
{NL} ++linenum; ACTION_ECHO;
|
||||
}
|
||||
<COMMENT>{
|
||||
"*/" add_action("*/]""]"); yy_pop_state();
|
||||
}
|
||||
<CODE_COMMENT>{
|
||||
"*/" ACTION_ECHO; yy_pop_state();
|
||||
}
|
||||
|
||||
<COMMENT_DISCARD>{
|
||||
/* This is the same as COMMENT, but is discarded rather than output. */
|
||||
@@ -223,7 +249,7 @@ M4QEND "]]"
|
||||
<EXTENDED_COMMENT>{
|
||||
")" yy_pop_state();
|
||||
[^\n\)]+ ;
|
||||
{NL} ++linenum;
|
||||
{NL} ++linenum;
|
||||
}
|
||||
|
||||
<LINEDIR>{
|
||||
@@ -231,25 +257,26 @@ M4QEND "]]"
|
||||
[[:digit:]]+ linenum = myctoi( yytext );
|
||||
|
||||
\"[^"\n]*\" {
|
||||
flex_free( (void *) infilename );
|
||||
infilename = copy_string( yytext + 1 );
|
||||
free(infilename);
|
||||
infilename = xstrdup(yytext + 1);
|
||||
infilename[strlen( infilename ) - 1] = '\0';
|
||||
}
|
||||
. /* ignore spurious characters */
|
||||
}
|
||||
<ACTION,CODEBLOCK,ACTION_STRING,PERCENT_BRACE_ACTION,CHARACTER_CONSTANT,
|
||||
COMMENT,CODE_COMMENT>{
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
}
|
||||
|
||||
<CODEBLOCK>{
|
||||
^"%}".*{NL} ++linenum; BEGIN(INITIAL);
|
||||
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
. ACTION_ECHO;
|
||||
|
||||
^"%}".*{NL} ++linenum; END_CODEBLOCK;
|
||||
[^\n%\[\]]* ACTION_ECHO;
|
||||
. ACTION_ECHO;
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if ( indented_code )
|
||||
BEGIN(INITIAL);
|
||||
if ( indented_code ) END_CODEBLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,12 +299,11 @@ M4QEND "]]"
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
{M4QSTART} buf_strnappend(&top_buf, escaped_qstart, strlen(escaped_qstart));
|
||||
{M4QEND} buf_strnappend(&top_buf, escaped_qend, strlen(escaped_qend));
|
||||
|
||||
[^{}\r\n] {
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
{M4QSTART} buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart));
|
||||
{M4QEND} buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend));
|
||||
([^{}\r\n\[\]]+)|[^{}\r\n] {
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
linenum = brace_start_line;
|
||||
@@ -293,7 +319,7 @@ M4QEND "]]"
|
||||
{NOT_WS}[^\r\n]* {
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( (char *) nmdef, yytext );
|
||||
strcpy( nmdef, yytext );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -301,12 +327,12 @@ M4QEND "]]"
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
/* Skip trailing whitespace. */
|
||||
for ( i = strlen( (char *) nmdef ) - 1;
|
||||
i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
|
||||
--i )
|
||||
;
|
||||
|
||||
nmdef[i + 1] = '\0';
|
||||
{
|
||||
size_t i = strlen( nmdef );
|
||||
while (i > 0 && (nmdef[i-1] == ' ' || nmdef[i-1] == '\t'))
|
||||
--i;
|
||||
nmdef[i] = '\0';
|
||||
}
|
||||
|
||||
ndinstal( nmstr, nmdef );
|
||||
didadef = true;
|
||||
@@ -338,8 +364,6 @@ M4QEND "]]"
|
||||
interactive = option_sense;
|
||||
}
|
||||
array yytext_is_array = option_sense;
|
||||
ansi-definitions ansi_func_defs = option_sense;
|
||||
ansi-prototypes ansi_func_protos = option_sense;
|
||||
backup backing_up_report = option_sense;
|
||||
batch interactive = ! option_sense;
|
||||
bison-bridge bison_bridge_lval = option_sense;
|
||||
@@ -364,6 +388,7 @@ M4QEND "]]"
|
||||
interactive interactive = option_sense;
|
||||
lex-compat lex_compat = option_sense;
|
||||
posix-compat posix_compat = option_sense;
|
||||
line gen_line_dirs = option_sense;
|
||||
main {
|
||||
ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
|
||||
/* Override yywrap */
|
||||
@@ -420,12 +445,12 @@ M4QEND "]]"
|
||||
yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense);
|
||||
yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense);
|
||||
|
||||
extra-type return OPT_EXTRA_TYPE;
|
||||
outfile return OPT_OUTFILE;
|
||||
prefix return OPT_PREFIX;
|
||||
yyclass return OPT_YYCLASS;
|
||||
header(-file)? return OPT_HEADER;
|
||||
tables-file return OPT_TABLES;
|
||||
extra-type return TOK_EXTRA_TYPE;
|
||||
outfile return TOK_OUTFILE;
|
||||
prefix return TOK_PREFIX;
|
||||
yyclass return TOK_YYCLASS;
|
||||
header(-file)? return TOK_HEADER_FILE;
|
||||
tables-file return TOK_TABLES_FILE;
|
||||
tables-verify {
|
||||
tablesverify = option_sense;
|
||||
if(!tablesext && option_sense)
|
||||
@@ -461,19 +486,20 @@ M4QEND "]]"
|
||||
^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
|
||||
^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
|
||||
|
||||
^{WS}.* ACTION_ECHO; /* indented code in prolog */
|
||||
^{WS} START_CODEBLOCK(true); /* 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;
|
||||
}
|
||||
^{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 {
|
||||
START_CODEBLOCK(true);
|
||||
}
|
||||
}
|
||||
|
||||
. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO;
|
||||
@@ -527,11 +553,11 @@ M4QEND "]]"
|
||||
if (sf_skip_ws()){
|
||||
/* We're in the middle of a (?x: ) pattern. */
|
||||
/* Push back everything starting at the "|" */
|
||||
size_t amt;
|
||||
amt = strchr (yytext, '|') - yytext;
|
||||
int amt = (int) (strchr (yytext, '|') - yytext);
|
||||
yyless(amt);
|
||||
}
|
||||
else {
|
||||
add_action("]""]");
|
||||
continued_action = true;
|
||||
++linenum;
|
||||
return '\n';
|
||||
@@ -601,9 +627,10 @@ M4QEND "]]"
|
||||
|
||||
^"%%".* {
|
||||
sectnum = 3;
|
||||
BEGIN(SECT3);
|
||||
BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3);
|
||||
outn("/* Begin user sect3 */");
|
||||
yyterminate(); /* to stop the parser */
|
||||
|
||||
}
|
||||
|
||||
"["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
|
||||
@@ -627,7 +654,7 @@ M4QEND "]]"
|
||||
* The reason it was disabled is so yacc/bison can parse
|
||||
* ccl operations, such as ccl difference and union.
|
||||
*/
|
||||
&& (cclval = ccllookup( (Char *) nmstr )) != 0 )
|
||||
&& (cclval = ccllookup( nmstr )) != 0 )
|
||||
{
|
||||
if ( input() != ']' )
|
||||
synerr( _( "bad character class" ) );
|
||||
@@ -641,7 +668,7 @@ M4QEND "]]"
|
||||
/* We fudge a bit. We know that this ccl will
|
||||
* soon be numbered as lastccl + 1 by cclinit.
|
||||
*/
|
||||
cclinstal( (Char *) nmstr, lastccl + 1 );
|
||||
cclinstal( nmstr, lastccl + 1 );
|
||||
|
||||
/* Push back everything but the leading bracket
|
||||
* so the ccl can be rescanned.
|
||||
@@ -661,7 +688,7 @@ M4QEND "]]"
|
||||
* context.
|
||||
*/
|
||||
"{"{NAME}"}"[[:space:]]? {
|
||||
Char *nmdefptr;
|
||||
char *nmdefptr;
|
||||
int end_is_ws, end_ch;
|
||||
|
||||
end_ch = yytext[yyleng-1];
|
||||
@@ -685,7 +712,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
|
||||
else
|
||||
{ /* push back name surrounded by ()'s */
|
||||
int len = strlen( (char *) nmdefptr );
|
||||
size_t len = strlen( nmdefptr );
|
||||
if (end_is_ws)
|
||||
unput(end_ch);
|
||||
|
||||
@@ -693,7 +720,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
(len > 0 && nmdefptr[len - 1] == '$')
|
||||
|| (end_is_ws && trlcontxt && !sf_skip_ws()))
|
||||
{ /* don't use ()'s after all */
|
||||
PUT_BACK_STRING((char *) nmdefptr, 0);
|
||||
PUT_BACK_STRING(nmdefptr, 0);
|
||||
|
||||
if ( nmdefptr[0] == '^' )
|
||||
BEGIN(CARETISBOL);
|
||||
@@ -702,7 +729,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
else
|
||||
{
|
||||
unput(')');
|
||||
PUT_BACK_STRING((char *) nmdefptr, 0);
|
||||
PUT_BACK_STRING(nmdefptr, 0);
|
||||
unput('(');
|
||||
}
|
||||
}
|
||||
@@ -738,7 +765,13 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
return '(';
|
||||
}
|
||||
"(" sf_push(); return '(';
|
||||
")" sf_pop(); return ')';
|
||||
")" {
|
||||
if (_sf_top_ix > 0) {
|
||||
sf_pop();
|
||||
return ')';
|
||||
} else
|
||||
synerr(_("unbalanced parenthesis"));
|
||||
}
|
||||
|
||||
[/|*+?.(){}] return (unsigned char) yytext[0];
|
||||
. RETURNCHAR;
|
||||
@@ -870,35 +903,31 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
<PERCENT_BRACE_ACTION>{
|
||||
{OPTWS}"%}".* bracelevel = 0;
|
||||
|
||||
<ACTION>"/*" ACTION_ECHO; yy_push_state( COMMENT );
|
||||
<ACTION>"/*" ACTION_ECHO; yy_push_state( CODE_COMMENT );
|
||||
|
||||
<CODEBLOCK,ACTION>{
|
||||
"reject" {
|
||||
ACTION_ECHO;
|
||||
CHECK_REJECT(yytext);
|
||||
}
|
||||
"yymore" {
|
||||
ACTION_ECHO;
|
||||
CHECK_YYMORE(yytext);
|
||||
}
|
||||
"reject" {
|
||||
ACTION_ECHO;
|
||||
CHECK_REJECT(yytext);
|
||||
}
|
||||
"yymore" {
|
||||
ACTION_ECHO;
|
||||
CHECK_YYMORE(yytext);
|
||||
}
|
||||
}
|
||||
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
. ACTION_ECHO;
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if ( bracelevel == 0 ||
|
||||
(doing_codeblock && indented_code) )
|
||||
{
|
||||
if ( doing_rule_action )
|
||||
add_action( "\tYY_BREAK\n" );
|
||||
. 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);
|
||||
}
|
||||
}
|
||||
doing_rule_action = doing_codeblock = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -906,37 +935,41 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
<ACTION>{
|
||||
"{" ACTION_ECHO; ++bracelevel;
|
||||
"}" ACTION_ECHO; --bracelevel;
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
[^[:alpha:]_{}"'/\n\[\]]+ ACTION_ECHO;
|
||||
[\[\]] ACTION_ECHO;
|
||||
{NAME} ACTION_ECHO;
|
||||
"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
|
||||
[^[:alpha:]_{}\"'/\n\[\]]+ ACTION_ECHO;
|
||||
{NAME} ACTION_ECHO;
|
||||
"'"([^\'\\\n]|\\.)"'" ACTION_ECHO; /* character constant */
|
||||
"'" ACTION_ECHO; BEGIN(CHARACTER_CONSTANT);
|
||||
\" ACTION_ECHO; BEGIN(ACTION_STRING);
|
||||
{NL} {
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if ( bracelevel == 0 )
|
||||
{
|
||||
if (bracelevel == 0) {
|
||||
if ( doing_rule_action )
|
||||
add_action( "\tYY_BREAK\n" );
|
||||
add_action( "\tYY_BREAK]""]\n" );
|
||||
|
||||
doing_rule_action = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
. ACTION_ECHO;
|
||||
doing_rule_action = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
|
||||
<ACTION_STRING>{
|
||||
[^"\\\n]+ ACTION_ECHO;
|
||||
\\. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO; BEGIN(ACTION);
|
||||
[^\[\]\"\\\n]+ ACTION_ECHO;
|
||||
\" ACTION_ECHO; BEGIN(ACTION);
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
<CHARACTER_CONSTANT>{
|
||||
[^\[\]\'\\\n]+ ACTION_ECHO;
|
||||
\' ACTION_ECHO; BEGIN(ACTION);
|
||||
}
|
||||
<ACTION_STRING,CHARACTER_CONSTANT>{
|
||||
(\\\n)* ACTION_ECHO;
|
||||
\\(\\\n)*. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO; BEGIN(ACTION);
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
|
||||
<COMMENT,COMMENT_DISCARD,ACTION,ACTION_STRING><<EOF>> {
|
||||
<COMMENT,CODE_COMMENT,COMMENT_DISCARD,ACTION,ACTION_STRING,CHARACTER_CONSTANT><<EOF>> {
|
||||
synerr( _( "EOF encountered inside an action" ) );
|
||||
yyterminate();
|
||||
}
|
||||
@@ -947,7 +980,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
}
|
||||
|
||||
<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
|
||||
yylval = myesc( (Char *) yytext );
|
||||
yylval = myesc( (unsigned char *) yytext );
|
||||
|
||||
if ( YY_START == FIRSTCCL )
|
||||
BEGIN(CCL);
|
||||
@@ -955,21 +988,32 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
return CHAR;
|
||||
}
|
||||
|
||||
|
||||
<SECT3>{
|
||||
{M4QSTART} fwrite (escaped_qstart, 1, strlen(escaped_qstart), yyout);
|
||||
{M4QEND} fwrite (escaped_qend, 1, strlen(escaped_qend), yyout);
|
||||
[^\[\]\n]*(\n?) ECHO;
|
||||
(.|\n) ECHO;
|
||||
<<EOF>> sectnum = 0; yyterminate();
|
||||
{M4QSTART} fputs(escaped_qstart, yyout);
|
||||
{M4QEND} fputs(escaped_qend, yyout);
|
||||
[^\[\]]* ECHO;
|
||||
[][] ECHO;
|
||||
<<EOF>> {
|
||||
sectnum = 0;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
<SECT3_NOESCAPE>{
|
||||
{M4QSTART} fprintf(yyout, "[""[%s]""]", escaped_qstart);
|
||||
{M4QEND} fprintf(yyout, "[""[%s]""]", escaped_qend);
|
||||
[^][]* ECHO;
|
||||
[][] ECHO;
|
||||
<<EOF>> {
|
||||
sectnum = 0;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
|
||||
<*>.|\n format_synerr( _( "bad character: %s" ), yytext );
|
||||
|
||||
%%
|
||||
|
||||
|
||||
int yywrap()
|
||||
int yywrap(void)
|
||||
{
|
||||
if ( --num_input_files > 0 )
|
||||
{
|
||||
@@ -984,12 +1028,11 @@ int yywrap()
|
||||
|
||||
/* set_input_file - open the given file (if NULL, stdin) for scanning */
|
||||
|
||||
void set_input_file( file )
|
||||
char *file;
|
||||
void set_input_file( char *file )
|
||||
{
|
||||
if ( file && strcmp( file, "-" ) )
|
||||
{
|
||||
infilename = copy_string( file );
|
||||
infilename = xstrdup(file);
|
||||
yyin = fopen( infilename, "r" );
|
||||
|
||||
if ( yyin == NULL )
|
||||
@@ -999,31 +1042,8 @@ char *file;
|
||||
else
|
||||
{
|
||||
yyin = stdin;
|
||||
infilename = copy_string( "<stdin>" );
|
||||
infilename = xstrdup("<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 );
|
||||
}
|
||||
|
||||
+6
-3
@@ -39,8 +39,10 @@ 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));
|
||||
if (_sf_top_ix + 1 >= _sf_max) {
|
||||
_sf_max += 32;
|
||||
_sf_stk = realloc(_sf_stk, sizeof(scanflags_t) * _sf_max);
|
||||
}
|
||||
|
||||
// copy the top element
|
||||
_sf_stk[_sf_top_ix + 1] = _sf_stk[_sf_top_ix];
|
||||
@@ -59,7 +61,8 @@ void
|
||||
sf_init (void)
|
||||
{
|
||||
assert(_sf_stk == NULL);
|
||||
_sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32));
|
||||
_sf_max = 32;
|
||||
_sf_stk = malloc(sizeof(scanflags_t) * _sf_max);
|
||||
if (!_sf_stk)
|
||||
lerr_fatal(_("Unable to allocate %zu of stack"), sizeof(scanflags_t));
|
||||
_sf_stk[_sf_top_ix] = 0;
|
||||
|
||||
+46
-98
@@ -37,20 +37,6 @@
|
||||
|
||||
/* 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 ((unsigned char)*a++) == tolower ((unsigned char)*b++)) ;
|
||||
return b - a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ARG_NONE 0x01
|
||||
#define ARG_REQ 0x02
|
||||
#define ARG_OPT 0x04
|
||||
@@ -77,56 +63,45 @@ struct _scanopt_t {
|
||||
};
|
||||
|
||||
/* 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));
|
||||
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(struct _scanopt_t *, int);
|
||||
static int PRINTLEN(struct _scanopt_t *, int);
|
||||
static int RVAL(struct _scanopt_t *, int);
|
||||
static int FLAGS(struct _scanopt_t *, int);
|
||||
static const char *DESC(struct _scanopt_t *, int);
|
||||
static int scanopt_err(struct _scanopt_t *, int, int);
|
||||
static int matchlongopt(char *, char **, int *, char **, int *);
|
||||
static int find_opt(struct _scanopt_t *, int, char *, int, int *, int *opt_offset);
|
||||
|
||||
static const char *NAME (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static const char *NAME (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;
|
||||
static int PRINTLEN (struct _scanopt_t *s, int i)
|
||||
{
|
||||
return s->aux[i].printlen;
|
||||
}
|
||||
|
||||
static int RVAL (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static int RVAL (struct _scanopt_t *s, int i)
|
||||
{
|
||||
return s->options[i].r_val;
|
||||
}
|
||||
|
||||
static int FLAGS (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static int FLAGS (struct _scanopt_t *s, int i)
|
||||
{
|
||||
return s->aux[i].flags;
|
||||
}
|
||||
|
||||
static const char *DESC (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static const char *DESC (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 (void);
|
||||
|
||||
static int get_cols ()
|
||||
static int get_cols (void)
|
||||
{
|
||||
char *env;
|
||||
int cols = 80; /* default */
|
||||
@@ -159,15 +134,11 @@ static int get_cols ()
|
||||
(s)->subscript= 0; \
|
||||
}while(0)
|
||||
|
||||
scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
const optspec_t *options;
|
||||
int argc;
|
||||
char **argv;
|
||||
int flags;
|
||||
scanopt_t *scanopt_init (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 = malloc(sizeof (struct _scanopt_t));
|
||||
|
||||
s->options = options;
|
||||
s->optc = 0;
|
||||
@@ -186,10 +157,10 @@ scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
s->optc++;
|
||||
|
||||
/* Build auxiliary data */
|
||||
s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux));
|
||||
s->aux = malloc((size_t) s->optc * sizeof (struct _aux));
|
||||
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
const Char *p, *pname;
|
||||
const unsigned char *p, *pname;
|
||||
const struct optspec_t *opt;
|
||||
struct _aux *aux;
|
||||
|
||||
@@ -200,14 +171,14 @@ scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
|
||||
if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
|
||||
aux->flags |= IS_LONG;
|
||||
pname = (const Char *)(opt->opt_fmt + 2);
|
||||
pname = (const unsigned char *)(opt->opt_fmt + 2);
|
||||
s->has_long = 1;
|
||||
}
|
||||
else {
|
||||
pname = (const Char *)(opt->opt_fmt + 1);
|
||||
pname = (const unsigned char *)(opt->opt_fmt + 1);
|
||||
s->has_short = 1;
|
||||
}
|
||||
aux->printlen = strlen (opt->opt_fmt);
|
||||
aux->printlen = (int) strlen (opt->opt_fmt);
|
||||
|
||||
aux->namelen = 0;
|
||||
for (p = pname + 1; *p; p++) {
|
||||
@@ -215,21 +186,21 @@ scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
if (*p == '=' || isspace ((unsigned char)*p)
|
||||
|| !(aux->flags & IS_LONG)) {
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
aux->namelen = (int) (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->namelen = (int) (p - pname);
|
||||
aux->flags &= ~(ARG_REQ | ARG_NONE);
|
||||
aux->flags |= ARG_OPT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
aux->namelen = (int) (p - pname);
|
||||
}
|
||||
return (scanopt_t *) s;
|
||||
}
|
||||
@@ -255,10 +226,7 @@ typedef struct usg_elem usg_elem;
|
||||
[indent][option, alias1, alias2...][indent][description line1
|
||||
description line2...]
|
||||
*/
|
||||
int scanopt_usage (scanner, fp, usage)
|
||||
scanopt_t *scanner;
|
||||
FILE *fp;
|
||||
const char *usage;
|
||||
int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage)
|
||||
{
|
||||
struct _scanopt_t *s;
|
||||
int i, columns, indent = 2;
|
||||
@@ -293,7 +261,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
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));
|
||||
store = malloc((size_t) s->optc * sizeof (usg_elem));
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
|
||||
/* grab the next preallocate node. */
|
||||
@@ -319,7 +287,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
}
|
||||
if (!ptr_if_no_alias
|
||||
&&
|
||||
STRCASECMP (NAME (s, (*ue_curr)->idx),
|
||||
strcasecmp (NAME (s, (*ue_curr)->idx),
|
||||
NAME (s, ue->idx)) > 0) {
|
||||
ptr_if_no_alias = ue_curr;
|
||||
}
|
||||
@@ -391,7 +359,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
maxlen[0] = len;
|
||||
|
||||
/* It's much easier to calculate length for description column! */
|
||||
len = strlen (DESC (s, ue->idx));
|
||||
len = (int) strlen (DESC (s, ue->idx));
|
||||
if (len > maxlen[1])
|
||||
maxlen[1] = len;
|
||||
}
|
||||
@@ -529,10 +497,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
#endif /* no scanopt_usage */
|
||||
|
||||
|
||||
static int scanopt_err (s, is_short, err)
|
||||
struct _scanopt_t *s;
|
||||
int is_short;
|
||||
int err;
|
||||
static int scanopt_err (struct _scanopt_t *s, int is_short, int err)
|
||||
{
|
||||
const char *optname = "";
|
||||
char optchar[2];
|
||||
@@ -587,16 +552,11 @@ static int scanopt_err (s, is_short, err)
|
||||
* optname will point to str + 2
|
||||
*
|
||||
*/
|
||||
static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
char *str;
|
||||
char **optname;
|
||||
int *optlen;
|
||||
char **arg;
|
||||
int *arglen;
|
||||
static int matchlongopt (char *str, char **optname, int *optlen, char **arg, int *arglen)
|
||||
{
|
||||
char *p;
|
||||
|
||||
*optname = *arg = (char *) 0;
|
||||
*optname = *arg = NULL;
|
||||
*optlen = *arglen = 0;
|
||||
|
||||
/* Match regex /--./ */
|
||||
@@ -605,13 +565,13 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
return 0;
|
||||
|
||||
p += 2;
|
||||
*optname = (char *) p;
|
||||
*optname = p;
|
||||
|
||||
/* find the end of optname */
|
||||
while (*p && *p != '=')
|
||||
++p;
|
||||
|
||||
*optlen = p - *optname;
|
||||
*optlen = (int) (p - *optname);
|
||||
|
||||
if (!*p)
|
||||
/* an option with no '=...' part. */
|
||||
@@ -623,7 +583,7 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
*arg = p;
|
||||
while (*p)
|
||||
++p;
|
||||
*arglen = p - *arg;
|
||||
*arglen = (int) (p - *arg);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -634,13 +594,8 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
* 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;
|
||||
static int find_opt (struct _scanopt_t *s, int lookup_long, char *optstart, int
|
||||
len, int *err_code, int *opt_offset)
|
||||
{
|
||||
int nmatch = 0, lastr_val = 0, i;
|
||||
|
||||
@@ -651,17 +606,15 @@ static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
char *optname;
|
||||
const char *optname;
|
||||
|
||||
optname =
|
||||
(char *) (s->options[i].opt_fmt +
|
||||
(lookup_long ? 2 : 1));
|
||||
optname = 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) {
|
||||
if (strncmp (optname, optstart, (size_t) len) == 0) {
|
||||
nmatch++;
|
||||
*opt_offset = i;
|
||||
|
||||
@@ -699,10 +652,7 @@ static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
|
||||
}
|
||||
|
||||
|
||||
int scanopt (svoid, arg, optindex)
|
||||
scanopt_t *svoid;
|
||||
char **arg;
|
||||
int *optindex;
|
||||
int scanopt (scanopt_t *svoid, char **arg, int *optindex)
|
||||
{
|
||||
char *optname = NULL, *optarg = NULL, *pstart;
|
||||
int namelen = 0, arglen = 0;
|
||||
@@ -788,7 +738,7 @@ int scanopt (svoid, arg, optindex)
|
||||
arglen = 0;
|
||||
}
|
||||
else
|
||||
arglen = strlen (optarg);
|
||||
arglen = (int) strlen (optarg);
|
||||
}
|
||||
|
||||
/* At this point, we have a long or short option matched at opt_offset into
|
||||
@@ -848,16 +798,14 @@ int scanopt (svoid, arg, optindex)
|
||||
}
|
||||
|
||||
|
||||
int scanopt_destroy (svoid)
|
||||
scanopt_t *svoid;
|
||||
int scanopt_destroy (scanopt_t *svoid)
|
||||
{
|
||||
struct _scanopt_t *s;
|
||||
|
||||
s = (struct _scanopt_t *) svoid;
|
||||
if (s) {
|
||||
if (s->aux)
|
||||
free (s->aux);
|
||||
free (s);
|
||||
if (s != NULL) {
|
||||
free(s->aux);
|
||||
free(s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+5
-14
@@ -47,9 +47,6 @@
|
||||
#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. */
|
||||
@@ -85,12 +82,12 @@ extern "C" {
|
||||
* flags - Control behavior.
|
||||
* Return: A malloc'd pointer .
|
||||
*/
|
||||
scanopt_t *scanopt_init PROTO ((const optspec_t * options,
|
||||
int argc, char **argv, int flags));
|
||||
scanopt_t *scanopt_init (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));
|
||||
int scanopt_destroy (scanopt_t * scanner);
|
||||
|
||||
#ifndef NO_SCANOPT_USAGE
|
||||
/* Prints a usage message based on contents of optlist.
|
||||
@@ -100,10 +97,7 @@ extern "C" {
|
||||
* 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));
|
||||
int scanopt_usage (scanopt_t * scanner, FILE * fp, const char *usage);
|
||||
#endif
|
||||
|
||||
/* Scans command-line options in argv[].
|
||||
@@ -120,10 +114,7 @@ extern "C" {
|
||||
* < 0 on error (return value is an error code).
|
||||
*
|
||||
*/
|
||||
int scanopt
|
||||
PROTO (
|
||||
(scanopt_t * scanner, char **optarg,
|
||||
int *optindex));
|
||||
int scanopt (scanopt_t * scanner, char **optarg, int *optindex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -59,12 +59,10 @@ static struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
static int addsym PROTO ((char[], char *, int, hash_table, int));
|
||||
static struct hash_entry *findsym PROTO ((const char *sym,
|
||||
hash_table table,
|
||||
|
||||
int table_size));
|
||||
static int hashfunct PROTO ((const char *, int));
|
||||
static int addsym(char[], char *, int, hash_table, int);
|
||||
static struct hash_entry *findsym (const char *sym, hash_table table,
|
||||
int table_size);
|
||||
static int hashfunct(const char *, int);
|
||||
|
||||
|
||||
/* addsym - add symbol and definitions to symbol table
|
||||
@@ -72,12 +70,7 @@ static int hashfunct PROTO ((const char *, int));
|
||||
* -1 is returned if the symbol already exists, and the change not made.
|
||||
*/
|
||||
|
||||
static int addsym (sym, str_def, int_def, table, table_size)
|
||||
char sym[];
|
||||
char *str_def;
|
||||
int int_def;
|
||||
hash_table table;
|
||||
int table_size;
|
||||
static int addsym (char sym[], char *str_def, int int_def, hash_table table, int table_size)
|
||||
{
|
||||
int hash_val = hashfunct (sym, table_size);
|
||||
struct hash_entry *sym_entry = table[hash_val];
|
||||
@@ -93,8 +86,7 @@ static int addsym (sym, str_def, int_def, table, table_size)
|
||||
}
|
||||
|
||||
/* create new entry */
|
||||
new_entry = (struct hash_entry *)
|
||||
flex_alloc (sizeof (struct hash_entry));
|
||||
new_entry = malloc(sizeof(struct hash_entry));
|
||||
|
||||
if (new_entry == NULL)
|
||||
flexfatal (_("symbol table memory allocation failed"));
|
||||
@@ -119,15 +111,13 @@ static int addsym (sym, str_def, int_def, table, table_size)
|
||||
|
||||
/* cclinstal - save the text of a character class */
|
||||
|
||||
void cclinstal (ccltxt, cclnum)
|
||||
Char ccltxt[];
|
||||
int cclnum;
|
||||
void cclinstal (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),
|
||||
(void) addsym (xstrdup(ccltxt),
|
||||
(char *) 0, cclnum, ccltab, CCL_HASH_SIZE);
|
||||
}
|
||||
|
||||
@@ -137,23 +127,18 @@ void cclinstal (ccltxt, cclnum)
|
||||
* Returns 0 if there's no CCL associated with the text.
|
||||
*/
|
||||
|
||||
int ccllookup (ccltxt)
|
||||
Char ccltxt[];
|
||||
int ccllookup (char ccltxt[])
|
||||
{
|
||||
return findsym ((char *) ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
|
||||
return findsym (ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
|
||||
}
|
||||
|
||||
|
||||
/* findsym - find symbol in symbol table */
|
||||
|
||||
static struct hash_entry *findsym (sym, table, table_size)
|
||||
const char *sym;
|
||||
hash_table table;
|
||||
int table_size;
|
||||
static struct hash_entry *findsym (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,
|
||||
NULL, NULL, NULL, NULL, 0,
|
||||
};
|
||||
struct hash_entry *sym_entry =
|
||||
|
||||
@@ -170,9 +155,7 @@ static struct hash_entry *findsym (sym, table, table_size)
|
||||
|
||||
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
|
||||
|
||||
static int hashfunct (str, hash_size)
|
||||
const char *str;
|
||||
int hash_size;
|
||||
static int hashfunct (const char *str, int hash_size)
|
||||
{
|
||||
int hashval;
|
||||
int locstr;
|
||||
@@ -191,13 +174,11 @@ static int hashfunct (str, hash_size)
|
||||
|
||||
/* ndinstal - install a name definition */
|
||||
|
||||
void ndinstal (name, definition)
|
||||
const char *name;
|
||||
Char definition[];
|
||||
void ndinstal (const char *name, char definition[])
|
||||
{
|
||||
|
||||
if (addsym (copy_string (name),
|
||||
(char *) copy_unsigned_string (definition), 0,
|
||||
if (addsym (xstrdup(name),
|
||||
xstrdup(definition), 0,
|
||||
ndtbl, NAME_TABLE_HASH_SIZE))
|
||||
synerr (_("name defined twice"));
|
||||
}
|
||||
@@ -208,16 +189,15 @@ void ndinstal (name, definition)
|
||||
* Returns a nil pointer if the name definition does not exist.
|
||||
*/
|
||||
|
||||
Char *ndlookup (nd)
|
||||
const char *nd;
|
||||
char *ndlookup (const char *nd)
|
||||
{
|
||||
return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
|
||||
return findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
|
||||
}
|
||||
|
||||
|
||||
/* scextend - increase the maximum number of start conditions */
|
||||
|
||||
void scextend ()
|
||||
void scextend (void)
|
||||
{
|
||||
current_max_scs += MAX_SCS_INCREMENT;
|
||||
|
||||
@@ -237,17 +217,15 @@ void scextend ()
|
||||
* The start condition is "exclusive" if xcluflg is true.
|
||||
*/
|
||||
|
||||
void scinstal (str, xcluflg)
|
||||
const char *str;
|
||||
int xcluflg;
|
||||
void scinstal (const char *str, int xcluflg)
|
||||
{
|
||||
|
||||
if (++lastsc >= current_max_scs)
|
||||
scextend ();
|
||||
|
||||
scname[lastsc] = copy_string (str);
|
||||
scname[lastsc] = xstrdup(str);
|
||||
|
||||
if (addsym (scname[lastsc], (char *) 0, lastsc,
|
||||
if (addsym(scname[lastsc], NULL, lastsc,
|
||||
sctbl, START_COND_HASH_SIZE))
|
||||
format_pinpoint_message (_
|
||||
("start condition %s declared twice"),
|
||||
@@ -265,8 +243,7 @@ str);
|
||||
* Returns 0 if no such start condition.
|
||||
*/
|
||||
|
||||
int sclookup (str)
|
||||
const char *str;
|
||||
int sclookup (const char *str)
|
||||
{
|
||||
return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val;
|
||||
}
|
||||
|
||||
+33
-33
@@ -55,7 +55,7 @@
|
||||
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);
|
||||
int yytbl_writen (struct yytbl_writer *wr, void *v, int len);
|
||||
static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i);
|
||||
/* XXX Not used
|
||||
static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
|
||||
@@ -86,12 +86,12 @@ int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
|
||||
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 = (flex_uint32_t) (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);
|
||||
th->th_version = xstrdup(version_str);
|
||||
th->th_name = xstrdup(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -115,8 +115,7 @@ int yytbl_data_init (struct yytbl_data *td, enum yytbl_id id)
|
||||
*/
|
||||
int yytbl_data_destroy (struct yytbl_data *td)
|
||||
{
|
||||
if (td->td_data)
|
||||
free (td->td_data);
|
||||
free(td->td_data);
|
||||
td->td_data = 0;
|
||||
free (td);
|
||||
return 0;
|
||||
@@ -159,12 +158,12 @@ int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th)
|
||||
flex_die (_("th_ssize|th_flags write failed"));
|
||||
bwritten += 6;
|
||||
|
||||
sz = strlen (th->th_version) + 1;
|
||||
sz = (int) 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;
|
||||
sz = (int) strlen (th->th_name) + 1;
|
||||
if ((rv = yytbl_writen (wr, th->th_name, sz)) != sz)
|
||||
flex_die (_("th_name writen failed"));
|
||||
bwritten += rv;
|
||||
@@ -214,13 +213,13 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *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));
|
||||
rv = yytbl_write8 (wr, (flex_uint8_t) yytbl_data_geti (td, i));
|
||||
break;
|
||||
case sizeof (flex_int16_t):
|
||||
rv = yytbl_write16 (wr, yytbl_data_geti (td, i));
|
||||
rv = yytbl_write16 (wr, (flex_uint16_t) yytbl_data_geti (td, i));
|
||||
break;
|
||||
case sizeof (flex_int32_t):
|
||||
rv = yytbl_write32 (wr, yytbl_data_geti (td, i));
|
||||
rv = yytbl_write32 (wr, (flex_uint32_t) yytbl_data_geti (td, i));
|
||||
break;
|
||||
default:
|
||||
flex_die (_("invalid td_flags detected"));
|
||||
@@ -233,7 +232,7 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
}
|
||||
|
||||
/* Sanity check */
|
||||
if (bwritten != (int) (12 + total_len * YYTDFLAGS2BYTES (td->td_flags))) {
|
||||
if (bwritten != (12 + total_len * (int) YYTDFLAGS2BYTES (td->td_flags))) {
|
||||
flex_die (_("insanity detected"));
|
||||
return -1;
|
||||
}
|
||||
@@ -248,14 +247,14 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
/* 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
|
||||
|| yytbl_write32 (wr, (flex_uint32_t) 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);
|
||||
wr->total_written -= (int) sizeof (flex_int32_t);
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
@@ -265,11 +264,11 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
* @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 yytbl_writen (struct yytbl_writer *wr, void *v, int len)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fwrite (v, 1, len, wr->out);
|
||||
rv = (int) fwrite (v, 1, (size_t) len, wr->out);
|
||||
if (rv != len)
|
||||
return -1;
|
||||
wr->total_written += len;
|
||||
@@ -284,11 +283,11 @@ int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len)
|
||||
int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v)
|
||||
{
|
||||
flex_uint32_t vnet;
|
||||
size_t bytes, rv;
|
||||
int bytes, rv;
|
||||
|
||||
vnet = htonl (v);
|
||||
bytes = sizeof (flex_uint32_t);
|
||||
rv = fwrite (&vnet, bytes, 1, wr->out);
|
||||
bytes = (int) sizeof (flex_uint32_t);
|
||||
rv = (int) fwrite (&vnet, (size_t) bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
@@ -303,11 +302,11 @@ int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v)
|
||||
int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v)
|
||||
{
|
||||
flex_uint16_t vnet;
|
||||
size_t bytes, rv;
|
||||
int bytes, rv;
|
||||
|
||||
vnet = htons (v);
|
||||
bytes = sizeof (flex_uint16_t);
|
||||
rv = fwrite (&vnet, bytes, 1, wr->out);
|
||||
bytes = (int) sizeof (flex_uint16_t);
|
||||
rv = (int) fwrite (&vnet, (size_t) bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
@@ -321,10 +320,10 @@ int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v)
|
||||
*/
|
||||
int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v)
|
||||
{
|
||||
size_t bytes, rv;
|
||||
int bytes, rv;
|
||||
|
||||
bytes = sizeof (flex_uint8_t);
|
||||
rv = fwrite (&v, bytes, 1, wr->out);
|
||||
bytes = (int) sizeof (flex_uint8_t);
|
||||
rv = (int) fwrite (&v, (size_t) bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
@@ -428,7 +427,7 @@ static void yytbl_data_seti (const struct yytbl_data *tbl, int i,
|
||||
*/
|
||||
static size_t min_int_size (struct yytbl_data *tbl)
|
||||
{
|
||||
flex_uint32_t i, total_len;
|
||||
flex_int32_t i, total_len;
|
||||
flex_int32_t max = 0;
|
||||
|
||||
total_len = yytbl_calc_total_len (tbl);
|
||||
@@ -438,7 +437,7 @@ static size_t min_int_size (struct yytbl_data *tbl)
|
||||
|
||||
n = abs (yytbl_data_geti (tbl, i));
|
||||
|
||||
if (n > max)
|
||||
if (max < n)
|
||||
max = n;
|
||||
}
|
||||
|
||||
@@ -461,7 +460,8 @@ static size_t min_int_size (struct yytbl_data *tbl)
|
||||
*/
|
||||
void yytbl_data_compress (struct yytbl_data *tbl)
|
||||
{
|
||||
flex_int32_t i, newsz, total_len;
|
||||
flex_int32_t i, total_len;
|
||||
size_t newsz;
|
||||
struct yytbl_data newtbl;
|
||||
|
||||
yytbl_data_init (&newtbl, tbl->td_id);
|
||||
@@ -472,19 +472,19 @@ void yytbl_data_compress (struct yytbl_data *tbl)
|
||||
newsz = min_int_size (tbl);
|
||||
|
||||
|
||||
if (newsz == (int) YYTDFLAGS2BYTES (tbl->td_flags))
|
||||
if (newsz == YYTDFLAGS2BYTES (tbl->td_flags))
|
||||
/* No change in this table needed. */
|
||||
return;
|
||||
|
||||
if (newsz > (int) YYTDFLAGS2BYTES (tbl->td_flags)) {
|
||||
if (newsz > 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);
|
||||
newtbl.td_data = calloc ((size_t) total_len, newsz);
|
||||
newtbl.td_flags = (flex_uint16_t)
|
||||
(TFLAGS_CLRDATA (newtbl.td_flags) | BYTES2TFLAG (newsz));
|
||||
|
||||
for (i = 0; i < total_len; i++) {
|
||||
flex_int32_t g;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ extern "C" {
|
||||
#include "tables_shared.h"
|
||||
struct yytbl_writer {
|
||||
FILE *out;
|
||||
flex_uint32_t total_written;
|
||||
int total_written;
|
||||
/**< bytes written so far */
|
||||
fpos_t th_ssize_pos;
|
||||
/**< position of th_ssize */
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ dnl
|
||||
*/
|
||||
yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl)
|
||||
{
|
||||
flex_int32_t n;
|
||||
flex_uint32_t n;
|
||||
|
||||
/* total number of ints */
|
||||
n = tbl->td_lolen;
|
||||
@@ -66,5 +66,5 @@ yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl)
|
||||
|
||||
if (tbl->td_id == YYTD_ID_TRANSITION)
|
||||
n *= 2;
|
||||
return n;
|
||||
return (flex_int32_t) n;
|
||||
}
|
||||
|
||||
+25
-37
@@ -36,11 +36,11 @@
|
||||
|
||||
/* declarations for functions that have forward references */
|
||||
|
||||
void mkentry PROTO ((int *, int, int, int, int));
|
||||
void mkprot PROTO ((int[], int, int));
|
||||
void mktemplate PROTO ((int[], int, int));
|
||||
void mv2front PROTO ((int));
|
||||
int tbldiff PROTO ((int[], int, int[]));
|
||||
void mkentry(int *, int, int, int, int);
|
||||
void mkprot(int[], int, int);
|
||||
void mktemplate(int[], int, int);
|
||||
void mv2front(int);
|
||||
int tbldiff(int[], int, int[]);
|
||||
|
||||
|
||||
/* bldtbl - build table entries for dfa state
|
||||
@@ -78,8 +78,7 @@ int tbldiff PROTO ((int[], int, int[]));
|
||||
* cost only one difference.
|
||||
*/
|
||||
|
||||
void bldtbl (state, statenum, totaltrans, comstate, comfreq)
|
||||
int state[], statenum, totaltrans, comstate, comfreq;
|
||||
void bldtbl (int state[], int statenum, int totaltrans, int comstate, int comfreq)
|
||||
{
|
||||
int extptr, extrct[2][CSIZE + 1];
|
||||
int mindiff, minprot, i, d;
|
||||
@@ -221,7 +220,7 @@ void bldtbl (state, statenum, totaltrans, comstate, comfreq)
|
||||
* classes.
|
||||
*/
|
||||
|
||||
void cmptmps ()
|
||||
void cmptmps (void)
|
||||
{
|
||||
int tmpstorage[CSIZE + 1];
|
||||
int *tmp = tmpstorage, i, j;
|
||||
@@ -289,7 +288,7 @@ void cmptmps ()
|
||||
|
||||
/* expand_nxt_chk - expand the next check arrays */
|
||||
|
||||
void expand_nxt_chk ()
|
||||
void expand_nxt_chk (void)
|
||||
{
|
||||
int old_max = current_max_xpairs;
|
||||
|
||||
@@ -300,8 +299,7 @@ void expand_nxt_chk ()
|
||||
nxt = reallocate_integer_array (nxt, current_max_xpairs);
|
||||
chk = reallocate_integer_array (chk, current_max_xpairs);
|
||||
|
||||
zero_out ((char *) (chk + old_max),
|
||||
(size_t) (MAX_XPAIRS_INCREMENT * sizeof (int)));
|
||||
memset(chk + old_max, 0, MAX_XPAIRS_INCREMENT * sizeof(int));
|
||||
}
|
||||
|
||||
|
||||
@@ -324,8 +322,7 @@ void expand_nxt_chk ()
|
||||
* and an action number will be added in [-1].
|
||||
*/
|
||||
|
||||
int find_table_space (state, numtrans)
|
||||
int *state, numtrans;
|
||||
int find_table_space (int *state, int numtrans)
|
||||
{
|
||||
/* Firstfree is the position of the first possible occurrence of two
|
||||
* consecutive unused records in the chk and nxt arrays.
|
||||
@@ -419,13 +416,11 @@ int find_table_space (state, numtrans)
|
||||
* Initializes "firstfree" to be one beyond the end of the table. Initializes
|
||||
* all "chk" entries to be zero.
|
||||
*/
|
||||
void inittbl ()
|
||||
void inittbl (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
zero_out ((char *) chk,
|
||||
|
||||
(size_t) (current_max_xpairs * sizeof (int)));
|
||||
memset(chk, 0, (size_t) current_max_xpairs * sizeof(int));
|
||||
|
||||
tblend = 0;
|
||||
firstfree = tblend + 1;
|
||||
@@ -451,7 +446,7 @@ void inittbl ()
|
||||
|
||||
/* mkdeftbl - make the default, "jam" table entries */
|
||||
|
||||
void mkdeftbl ()
|
||||
void mkdeftbl (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -500,9 +495,8 @@ void mkdeftbl ()
|
||||
* state array.
|
||||
*/
|
||||
|
||||
void mkentry (state, numchars, statenum, deflink, totaltrans)
|
||||
int *state;
|
||||
int numchars, statenum, deflink, totaltrans;
|
||||
void mkentry (int *state, int numchars, int statenum, int deflink,
|
||||
int totaltrans)
|
||||
{
|
||||
int minec, maxec, i, baseaddr;
|
||||
int tblbase, tbllast;
|
||||
@@ -616,8 +610,7 @@ void mkentry (state, numchars, statenum, deflink, totaltrans)
|
||||
* has only one out-transition
|
||||
*/
|
||||
|
||||
void mk1tbl (state, sym, onenxt, onedef)
|
||||
int state, sym, onenxt, onedef;
|
||||
void mk1tbl (int state, int sym, int onenxt, int onedef)
|
||||
{
|
||||
if (firstfree < sym)
|
||||
firstfree = sym;
|
||||
@@ -642,8 +635,7 @@ void mk1tbl (state, sym, onenxt, onedef)
|
||||
|
||||
/* mkprot - create new proto entry */
|
||||
|
||||
void mkprot (state, statenum, comstate)
|
||||
int state[], statenum, comstate;
|
||||
void mkprot (int state[], int statenum, int comstate)
|
||||
{
|
||||
int i, slot, tblbase;
|
||||
|
||||
@@ -680,11 +672,10 @@ void mkprot (state, statenum, comstate)
|
||||
* to it
|
||||
*/
|
||||
|
||||
void mktemplate (state, statenum, comstate)
|
||||
int state[], statenum, comstate;
|
||||
void mktemplate (int state[], int statenum, int comstate)
|
||||
{
|
||||
int i, numdiff, tmpbase, tmp[CSIZE + 1];
|
||||
Char transset[CSIZE + 1];
|
||||
unsigned char transset[CSIZE + 1];
|
||||
int tsptr;
|
||||
|
||||
++numtemps;
|
||||
@@ -712,7 +703,8 @@ void mktemplate (state, statenum, comstate)
|
||||
if (state[i] == 0)
|
||||
tnxt[tmpbase + i] = 0;
|
||||
else {
|
||||
transset[tsptr++] = i;
|
||||
/* Note: range 1..256 is mapped to 1..255,0 */
|
||||
transset[tsptr++] = (unsigned char) i;
|
||||
tnxt[tmpbase + i] = comstate;
|
||||
}
|
||||
|
||||
@@ -732,8 +724,7 @@ void mktemplate (state, statenum, comstate)
|
||||
|
||||
/* mv2front - move proto queue element to front of queue */
|
||||
|
||||
void mv2front (qelm)
|
||||
int qelm;
|
||||
void mv2front (int qelm)
|
||||
{
|
||||
if (firstprot != qelm) {
|
||||
if (qelm == lastprot)
|
||||
@@ -759,8 +750,7 @@ void mv2front (qelm)
|
||||
* Transnum is the number of out-transitions for the state.
|
||||
*/
|
||||
|
||||
void place_state (state, statenum, transnum)
|
||||
int *state, statenum, transnum;
|
||||
void place_state (int *state, int statenum, int transnum)
|
||||
{
|
||||
int i;
|
||||
int *state_ptr;
|
||||
@@ -802,8 +792,7 @@ void place_state (state, statenum, transnum)
|
||||
* no room, we process the sucker right now.
|
||||
*/
|
||||
|
||||
void stack1 (statenum, sym, nextstate, deflink)
|
||||
int statenum, sym, nextstate, deflink;
|
||||
void stack1 (int statenum, int sym, int nextstate, int deflink)
|
||||
{
|
||||
if (onesp >= ONE_STACK_SIZE - 1)
|
||||
mk1tbl (statenum, sym, nextstate, deflink);
|
||||
@@ -832,8 +821,7 @@ void stack1 (statenum, sym, nextstate, deflink)
|
||||
* number is "numecs" minus the number of "SAME_TRANS" entries in "ext".
|
||||
*/
|
||||
|
||||
int tbldiff (state, pr, ext)
|
||||
int state[], pr, ext[];
|
||||
int tbldiff (int state[], int pr, int ext[])
|
||||
{
|
||||
int i, *sp = state, *ep = ext, *protp;
|
||||
int numdiff = 0;
|
||||
|
||||
+8
-7
@@ -37,18 +37,19 @@
|
||||
|
||||
|
||||
/* yylex - scan for a regular expression token */
|
||||
|
||||
extern char *yytext;
|
||||
extern FILE *yyout;
|
||||
bool no_section3_escape = false;
|
||||
int yylex (void)
|
||||
{
|
||||
int toktype;
|
||||
static int beglin = false;
|
||||
|
||||
if (eofseen)
|
||||
if (eofseen) {
|
||||
toktype = EOF;
|
||||
else
|
||||
} else {
|
||||
toktype = flexscan ();
|
||||
|
||||
}
|
||||
if (toktype == EOF || toktype == 0) {
|
||||
eofseen = 1;
|
||||
|
||||
@@ -174,12 +175,12 @@ int yylex (void)
|
||||
fprintf (stderr, "<<EOF>>");
|
||||
break;
|
||||
|
||||
case OPTION_OP:
|
||||
case TOK_OPTION:
|
||||
fprintf (stderr, "%s ", yytext);
|
||||
break;
|
||||
|
||||
case OPT_OUTFILE:
|
||||
case OPT_PREFIX:
|
||||
case TOK_OUTFILE:
|
||||
case TOK_PREFIX:
|
||||
case CCE_ALNUM:
|
||||
case CCE_ALPHA:
|
||||
case CCE_BLANK:
|
||||
|
||||
+4
-4
@@ -31,6 +31,8 @@ cxx_basic
|
||||
cxx_basic.cc
|
||||
cxx_multiple_scanners
|
||||
cxx_multiple_scanners_[12].cc
|
||||
cxx_restart
|
||||
cxx_restart.cc
|
||||
cxx_yywrap.i3
|
||||
cxx_yywrap.cc
|
||||
debug_nr
|
||||
@@ -63,10 +65,6 @@ multiple_scanners_nr
|
||||
multiple_scanners_nr_[12].[ch]
|
||||
multiple_scanners_r
|
||||
multiple_scanners_r_[12].[ch]
|
||||
noansi_nr
|
||||
noansi_nr.c
|
||||
noansi_r
|
||||
noansi_r.c
|
||||
posix
|
||||
posix.c
|
||||
posixly_correct
|
||||
@@ -89,6 +87,8 @@ rescan_nr.direct
|
||||
rescan_nr.direct.c
|
||||
rescan_r.direct
|
||||
rescan_r.direct.c
|
||||
quote_in_comment
|
||||
quote_in_comment.c
|
||||
quotes
|
||||
quotes.c
|
||||
string_nr
|
||||
|
||||
+138
-76
@@ -19,6 +19,8 @@
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
|
||||
AM_CFLAGS = $(WARNINGFLAGS)
|
||||
|
||||
TESTS = $(check_PROGRAMS) options.cn
|
||||
|
||||
# The script testwrapper.sh will run most tests as is. A couple tests
|
||||
@@ -33,13 +35,13 @@ LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_LOG_FLAGS = -d $(srcdir) -r
|
||||
|
||||
REJECT_LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_REJECT_LOG_FLAGS = -d $(srcdir) -i reject.txt -r
|
||||
AM_REJECT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/reject.txt -r
|
||||
|
||||
TABLE_LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_TABLE_LOG_FLAGS = -d $(srcdir) -i reject.txt -t
|
||||
AM_TABLE_LOG_FLAGS = -d $(builddir) -i $(srcdir)/reject.txt -t
|
||||
|
||||
DIRECT_LOG_COMPILER=$(srcdir)/testwrapper.sh
|
||||
AM_DIRECT_LOG_FLAGS = -d $(srcdir)
|
||||
DIRECT_LOG_COMPILER=$(srcdir)/testwrapper-direct.sh
|
||||
AM_DIRECT_LOG_FLAGS = -b $(abs_builddir) -s $(srcdir)
|
||||
|
||||
CN_LOG_COMPILER=$(srcdir)/options.cn
|
||||
AM_CN_LOG_FLAGS=$(FLEX)
|
||||
@@ -54,6 +56,7 @@ ONE_LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_ONE_LOG_FLAGS = -1 -d $(srcdir)
|
||||
|
||||
AM_YFLAGS = -d -p test
|
||||
AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src
|
||||
|
||||
check_PROGRAMS = $(simple_tests) $(reject_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS)
|
||||
|
||||
@@ -71,6 +74,7 @@ simple_tests = \
|
||||
ccl \
|
||||
cxx_basic \
|
||||
cxx_multiple_scanners \
|
||||
cxx_restart \
|
||||
debug_nr \
|
||||
debug_r \
|
||||
extended \
|
||||
@@ -80,15 +84,14 @@ simple_tests = \
|
||||
mem_r \
|
||||
multiple_scanners_nr \
|
||||
multiple_scanners_r \
|
||||
noansi_nr \
|
||||
noansi_r \
|
||||
posix \
|
||||
posixly_correct \
|
||||
prefix_nr \
|
||||
prefix_r \
|
||||
quote_in_comment \
|
||||
quotes \
|
||||
string_nr \
|
||||
string_r \
|
||||
string_r \
|
||||
top \
|
||||
yyextra
|
||||
|
||||
@@ -107,7 +110,7 @@ DIRECT_TESTS = \
|
||||
rescan_nr.direct \
|
||||
rescan_r.direct
|
||||
|
||||
I3_TESTS = \
|
||||
I3_TESTS = \
|
||||
cxx_yywrap.i3
|
||||
|
||||
if want_pthread
|
||||
@@ -120,6 +123,7 @@ ONE_TESTS = \
|
||||
lineno_r.one \
|
||||
lineno_trailing.one
|
||||
|
||||
quote_in_comment_SOURCES = quote_in_comment.l
|
||||
alloc_extra_SOURCES = alloc_extra.l
|
||||
array_nr_SOURCES = array_nr.l
|
||||
array_r_SOURCES = array_r.l
|
||||
@@ -132,6 +136,7 @@ c_cxx_nr_SOURCES = c_cxx_nr.lll
|
||||
c_cxx_r_SOURCES = c_cxx_r.lll
|
||||
ccl_SOURCES = ccl.l
|
||||
cxx_basic_SOURCES = cxx_basic.ll
|
||||
cxx_restart_SOURCES = cxx_restart.ll
|
||||
cxx_multiple_scanners_SOURCES = cxx_multiple_scanners_main.cc cxx_multiple_scanners_1.ll cxx_multiple_scanners_2.ll
|
||||
cxx_yywrap_i3_SOURCES = cxx_yywrap.ll
|
||||
debug_nr_SOURCES = debug_nr.l
|
||||
@@ -149,8 +154,6 @@ mem_nr_SOURCES = mem_nr.l
|
||||
mem_r_SOURCES = mem_r.l
|
||||
multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_1.l multiple_scanners_nr_2.l
|
||||
multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l
|
||||
noansi_nr_SOURCES = noansi_nr.l
|
||||
noansi_r_SOURCES = noansi_r.l
|
||||
posix_SOURCES = posix.l
|
||||
posixly_correct_SOURCES = posixly_correct.l
|
||||
prefix_nr_SOURCES = prefix_nr.l
|
||||
@@ -169,55 +172,127 @@ top_SOURCES = top.l top_main.c
|
||||
yyextra_SOURCES = yyextra.l
|
||||
|
||||
BUILT_SOURCES = \
|
||||
bison_nr_scanner.h \
|
||||
bison_nr_parser.h \
|
||||
bison_nr_scanner.h \
|
||||
bison_yylloc_parser.h \
|
||||
bison_yylloc_scanner.h \
|
||||
bison_yylval_parser.h \
|
||||
bison_yylval_scanner.h \
|
||||
c_cxx_nr.cc \
|
||||
c_cxx_r.cc \
|
||||
header_nr_scanner.h \
|
||||
header_r_scanner.h \
|
||||
multiple_scanners_nr_1.h \
|
||||
multiple_scanners_nr_2.h \
|
||||
multiple_scanners_r_1.h \
|
||||
multiple_scanners_r_2.h \
|
||||
top.h
|
||||
|
||||
# Normally, automake would distribute files built by flex. Since the
|
||||
# point of the test suite is to test the files that flex builds, and
|
||||
# since anyone who has the flex distribution can build a flex binary
|
||||
# without having a flex binary, we want to not distribute the files
|
||||
# built by flex in the test suite. The dist-hook target accomplishes
|
||||
# this goal. It's also handy to have the list of files to clean since
|
||||
# automake doesn't know about the whacky ways in which we're abusing
|
||||
# it.
|
||||
|
||||
CLEANFILES = \
|
||||
array_nr.c \
|
||||
array_r.c \
|
||||
basic_nr.c \
|
||||
basic_r.c \
|
||||
bison_nr_parser.c \
|
||||
bison_nr_parser.h \
|
||||
bison_nr_scanner.c \
|
||||
bison_nr_scanner.h \
|
||||
bison_yylloc_parser.c \
|
||||
bison_yylloc_parser.h \
|
||||
bison_yylloc_scanner.c \
|
||||
bison_yylloc_scanner.h \
|
||||
bison_yylval_parser.c \
|
||||
bison_yylval_parser.h \
|
||||
bison_yylval_scanner.c \
|
||||
bison_yylval_scanner.h \
|
||||
c_cxx_nr.cc \
|
||||
c_cxx_r.cc \
|
||||
ccl.c \
|
||||
cxx_basic.cc \
|
||||
cxx_multiple_scanners_1.cc \
|
||||
cxx_multiple_scanners_2.cc \
|
||||
cxx_restart.cc \
|
||||
cxx_yywrap.cc \
|
||||
debug_nr.c \
|
||||
debug_r.c \
|
||||
extended.c \
|
||||
header_nr_scanner.c \
|
||||
header_nr_scanner.h \
|
||||
header_r_scanner.c \
|
||||
header_r_scanner.h \
|
||||
include_by_buffer.direct.c \
|
||||
include_by_push.direct.c \
|
||||
include_by_reentrant.direct.c \
|
||||
lineno_nr.c \
|
||||
lineno_r.c \
|
||||
lineno_trailing.c \
|
||||
mem_nr.c \
|
||||
mem_r.c \
|
||||
multiple_scanners_nr_1.c \
|
||||
multiple_scanners_nr_1.h \
|
||||
multiple_scanners_nr_2.c \
|
||||
multiple_scanners_nr_2.h \
|
||||
multiple_scanners_r_1.c \
|
||||
multiple_scanners_r_1.h \
|
||||
multiple_scanners_r_2.c \
|
||||
multiple_scanners_r_2.h \
|
||||
posix.c \
|
||||
posixly_correct.c \
|
||||
prefix_nr.c \
|
||||
prefix_r.c \
|
||||
pthread.c \
|
||||
quote_in_comment.c \
|
||||
quotes.c \
|
||||
reject_nr.reject.c \
|
||||
reject_r.reject.c \
|
||||
reject_ver.table.c \
|
||||
reject_ser.table.c \
|
||||
top.h \
|
||||
$(tableopts_c)
|
||||
reject_ser.table.tables \
|
||||
reject_ver.table.c \
|
||||
reject_ver.table.tables \
|
||||
rescan_nr.direct.c \
|
||||
rescan_r.direct.c \
|
||||
string_nr.c \
|
||||
string_r.c \
|
||||
top.c \
|
||||
top.h \
|
||||
yyextra.c \
|
||||
alloc_extra.c \
|
||||
$(tableopts_c) \
|
||||
$(tableopts_tables)
|
||||
|
||||
dist-hook:
|
||||
for file in $(CLEANFILES) ; do \
|
||||
rm -f $(distdir)/$$file \
|
||||
; done
|
||||
|
||||
EXTRA_DIST = \
|
||||
README \
|
||||
testwrapper.sh \
|
||||
alloc_extra.txt \
|
||||
array_nr.txt \
|
||||
array_r.txt \
|
||||
basic_nr.txt \
|
||||
basic_nr.txt \
|
||||
basic_r.txt \
|
||||
bison_nr_scanner.h \
|
||||
bison_nr.txt \
|
||||
bison_yylloc_scanner.h \
|
||||
bison_yylloc.txt \
|
||||
bison_yylval_scanner.h \
|
||||
bison_yylval.txt \
|
||||
c_cxx_nr.cc \
|
||||
c_cxx_nr.txt \
|
||||
c_cxx_r.cc \
|
||||
c_cxx_r.txt \
|
||||
ccl.txt \
|
||||
cxx_basic.txt \
|
||||
cxx_multiple_scanners.txt \
|
||||
cxx_restart.txt \
|
||||
cxx_yywrap.txt \
|
||||
debug_nr.txt \
|
||||
debug_r.txt \
|
||||
extended.txt \
|
||||
header_nr_scanner.h \
|
||||
header_nr.txt \
|
||||
header_r_scanner.h \
|
||||
header_r.txt \
|
||||
include_by_buffer.direct.txt \
|
||||
include_by_buffer.direct_2.txt \
|
||||
@@ -233,12 +308,6 @@ basic_nr.txt \
|
||||
lineno_trailing.one.txt \
|
||||
mem_nr.txt \
|
||||
mem_r.txt \
|
||||
noansi_nr.txt \
|
||||
multiple_scanners_nr_1.h \
|
||||
multiple_scanners_nr_2.h \
|
||||
multiple_scanners_r_1.h \
|
||||
multiple_scanners_r_2.h \
|
||||
noansi_r.txt \
|
||||
prefix_nr.txt \
|
||||
prefix_r.txt \
|
||||
pthread_1.txt \
|
||||
@@ -247,22 +316,21 @@ basic_nr.txt \
|
||||
pthread_4.txt \
|
||||
pthread_5.txt \
|
||||
reject.txt \
|
||||
reject_nr.reject.c \
|
||||
reject_r.reject.c \
|
||||
reject_ver.table.c \
|
||||
reject_ver.table.tables \
|
||||
reject_ser.table.c \
|
||||
reject_ser.table.tables \
|
||||
rescan_nr.direct.txt \
|
||||
rescan_r.direct.txt \
|
||||
quote_in_comment.txt \
|
||||
quotes.txt \
|
||||
top.h \
|
||||
top.txt \
|
||||
yyextra.txt \
|
||||
$(tableopts_c) \
|
||||
$(tableopts_tables) \
|
||||
tableopts.txt \
|
||||
options.cn
|
||||
tableopts.txt
|
||||
|
||||
dist_noinst_SCRIPTS = \
|
||||
tableopts.sh
|
||||
|
||||
dist_check_SCRIPTS = \
|
||||
options.cn \
|
||||
testwrapper-direct.sh \
|
||||
testwrapper.sh
|
||||
|
||||
pthread_pthread_LDADD = -lpthread
|
||||
|
||||
@@ -270,10 +338,10 @@ pthread_pthread_LDADD = -lpthread
|
||||
|
||||
FLEX = $(top_builddir)/src/flex
|
||||
|
||||
.l.c:
|
||||
.l.c: $(FLEX)
|
||||
$(FLEX) -o $@ $<
|
||||
|
||||
.ll.cc:
|
||||
.ll.cc: $(FLEX)
|
||||
$(FLEX) -+ -o $@ $<
|
||||
|
||||
bison_nr_main.($OBJEXT): bison_nr_parser.h bison_nr_scanner.h
|
||||
@@ -288,7 +356,7 @@ bison_yylval_scanner.h: bison_yylval_scanner.c
|
||||
# automake does not support compiling flex scanners output in C as C++
|
||||
# so we explicitly sayhow, using the .lll suffix for the lex input file
|
||||
|
||||
.lll.cc:
|
||||
.lll.cc: $(FLEX)
|
||||
$(FLEX) -o $@ $<
|
||||
|
||||
header_nr_main.$(OBJEXT): header_nr_scanner.h
|
||||
@@ -297,12 +365,6 @@ header_nr_scanner.h: header_nr_scanner.c
|
||||
header_r_main.$(OBJEXT): header_r_scanner.h
|
||||
header_r_scanner.h: header_r_scanner.c
|
||||
|
||||
include_by_buffer.direct$(EXE): include_by_buffer.direct.txt include_by_buffer.direct_2.txt include_by_buffer.direct_3.txt
|
||||
|
||||
include_by_push.direct$(EXE): include_by_push.direct.txt include_by_push.direct_2.txt include_by_push.direct_3.txt
|
||||
|
||||
include_by_reentrant.direct$(EXE): include_by_reentrant.direct.txt include_by_reentrant.direct_2.txt include_by_reentrant.direct_3.txt
|
||||
|
||||
multiple_scanners_nr_main.$(OBJEXT): multiple_scanners_nr_1.h multiple_scanners_nr_2.h
|
||||
multiple_scanners_nr_1.h: multiple_scanners_nr_1.c
|
||||
multiple_scanners_nr_2.h: multiple_scanners_nr_2.c
|
||||
@@ -311,17 +373,17 @@ multiple_scanners_r_main.$(OBJEXT): multiple_scanners_r_1.h multiple_scanners_r_
|
||||
multiple_scanners_r_1.h: multiple_scanners_r_1.c
|
||||
multiple_scanners_r_2.h: multiple_scanners_r_2.c
|
||||
|
||||
posixly_correct.c: posixly_correct.l
|
||||
posixly_correct.c: posixly_correct.l $(FLEX)
|
||||
POSIXLY_CORRECT=1 $(FLEX) -o $@ $<
|
||||
|
||||
reject_nr.reject.c: reject.l4
|
||||
$(FLEX) -o $@ $<
|
||||
reject_nr.reject.c: reject.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -o $@ $<
|
||||
|
||||
reject_nr.reject$(EXEEXT): reject_nr.reject.$(OBJEXT)
|
||||
$(LINK) $^
|
||||
|
||||
reject_r.reject.c: reject.l4
|
||||
$(FLEX) --reentrant -o $@ $<
|
||||
reject_r.reject.c: reject.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape --reentrant -o $@ $<
|
||||
|
||||
reject_r.reject.$(OBJEXT): reject_r.reject.c
|
||||
$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $<
|
||||
@@ -329,8 +391,8 @@ reject_r.reject.$(OBJEXT): reject_r.reject.c
|
||||
reject_r.reject$(EXEEXT): reject_r.reject.$(OBJEXT)
|
||||
$(LINK) $^
|
||||
|
||||
reject_ver.table.c: reject.l4
|
||||
$(FLEX) -o $@ --tables-verify --tables-file=$(basename $@).tables $<
|
||||
reject_ver.table.c: reject.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $<
|
||||
|
||||
reject_ver.table.$(OBJEXT): reject_ver.table.c
|
||||
$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
|
||||
@@ -338,8 +400,8 @@ reject_ver.table.$(OBJEXT): reject_ver.table.c
|
||||
reject_ver.table$(EXEEXT): reject_ver.table.$(OBJEXT)
|
||||
$(LINK) $^
|
||||
|
||||
reject_ser.table.c: reject.l4
|
||||
$(FLEX) -o $@ --tables-file=$(basename $@).tables $<
|
||||
reject_ser.table.c: reject.l4 $(FLEX)
|
||||
$(FLEX) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $<
|
||||
|
||||
reject_ser.table.$(OBJEXT): reject_ser.table.c
|
||||
$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
|
||||
@@ -359,7 +421,7 @@ top.h: top.c
|
||||
tableopts.am: tableopts.sh
|
||||
$(srcdir)/tableopts.sh > $(srcdir)/tableopts.am
|
||||
|
||||
include tableopts.am
|
||||
include $(srcdir)/tableopts.am
|
||||
|
||||
tableopts := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem
|
||||
tableopts_opt_tests := $(foreach opt,$(tableopts), tableopts_opt_nr$(opt) tableopts_opt_r$(opt))
|
||||
@@ -370,40 +432,40 @@ tableopts_tests := $(tableopts_opttests) $(tableopts_vertests) $(tableopts_sert
|
||||
tableopts_c := $(addsuffix .c,$(tableopts_tests))
|
||||
|
||||
OPT_LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_OPT_LOG_FLAGS = -d $(srcdir) -i tableopts.txt -r
|
||||
AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r
|
||||
|
||||
tableopts_opt_nr%.c: tableopts.l4
|
||||
$(FLEX) -P $(subst -,_,$(basename $(*F))) $* -o $@ $<
|
||||
tableopts_opt_nr%.c: tableopts.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $* -o $@ $<
|
||||
|
||||
tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c
|
||||
$(COMPILE) -c -o $@ $<
|
||||
|
||||
tableopts_opt_r%.c: tableopts.l4
|
||||
$(FLEX) -P $(subst -,_,$(basename $(*F))) --reentrant $* -o $@ $<
|
||||
tableopts_opt_r%.c: tableopts.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $* -o $@ $<
|
||||
|
||||
tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c
|
||||
$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $<
|
||||
|
||||
SER_LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_SER_LOG_FLAGS = -d $(srcdir) -i tableopts.txt -r -t
|
||||
AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t
|
||||
|
||||
tableopts_ser_nr%.c: tableopts.l4
|
||||
$(FLEX) -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $* -o $@ $<
|
||||
tableopts_ser_nr%.c: tableopts.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $* -o $@ $<
|
||||
|
||||
tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c
|
||||
$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
|
||||
|
||||
tableopts_ser_r%.c: tableopts.l4
|
||||
$(FLEX) -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $* -o $@ $<
|
||||
tableopts_ser_r%.c: tableopts.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $* -o $@ $<
|
||||
|
||||
tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c
|
||||
$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $<
|
||||
|
||||
VER_LOG_COMPILER = $(srcdir)/testwrapper.sh
|
||||
AM_VER_LOG_FLAGS = -d $(srcdir) -i tableopts.txt -r -t
|
||||
AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t
|
||||
|
||||
tableopts_ver_nr%.c: tableopts.l4
|
||||
$(FLEX) -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $* -o $@ $<
|
||||
tableopts_ver_nr%.c: tableopts.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $* -o $@ $<
|
||||
|
||||
tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c
|
||||
$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
|
||||
@@ -411,8 +473,8 @@ tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c
|
||||
tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT)
|
||||
$(LINK) -o $@ $^
|
||||
|
||||
tableopts_ver_r%.c: tableopts.l4
|
||||
$(FLEX) -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $* -o $@ $<
|
||||
tableopts_ver_r%.c: tableopts.l4 $(FLEX)
|
||||
$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $* -o $@ $<
|
||||
|
||||
tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c
|
||||
$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $<
|
||||
|
||||
+4
-7
@@ -43,9 +43,6 @@ struct Check {
|
||||
/* Save char into junk array at next position. */
|
||||
static void check_extra ( yyscan_t scanner );
|
||||
|
||||
/* Special yyalloc */
|
||||
void *yyalloc ( size_t size, yyscan_t scanner );
|
||||
|
||||
%}
|
||||
|
||||
%option 8bit prefix="test"
|
||||
@@ -65,7 +62,7 @@ void *yyalloc ( size_t size, yyscan_t scanner );
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyscan_t scanner;
|
||||
struct Check check;
|
||||
@@ -78,8 +75,8 @@ main ()
|
||||
testset_in(stdin, scanner);
|
||||
testset_out(stdout, scanner);
|
||||
|
||||
/* Test to confirm that yyalloc was called from
|
||||
* yylex_init_extra with the yyextra argument.
|
||||
/* Test to confirm that testalloc was called from
|
||||
* testlex_init_extra with the testextra argument.
|
||||
*/
|
||||
check_extra(scanner);
|
||||
|
||||
@@ -89,7 +86,7 @@ main ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *yyalloc(size_t size, yyscan_t scanner)
|
||||
void *testalloc(size_t size, yyscan_t scanner)
|
||||
{
|
||||
struct Check *check;
|
||||
check = testget_extra(scanner);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@
|
||||
int main (void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyscan_t lexer;
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ WS [[:blank:]]
|
||||
|
||||
int main(void);
|
||||
|
||||
int main ()
|
||||
int main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
|
||||
+6
-6
@@ -52,16 +52,16 @@ WS [[:blank:]]
|
||||
|
||||
int main(void);
|
||||
|
||||
int main ()
|
||||
int main (void)
|
||||
{
|
||||
yyscan_t lexer;
|
||||
yylex_init( &lexer );
|
||||
yyset_out ( stdout,lexer);
|
||||
yyset_in ( stdin, lexer);
|
||||
while( yylex(lexer) )
|
||||
testlex_init( &lexer );
|
||||
testset_out ( stdout,lexer);
|
||||
testset_in ( stdin, lexer);
|
||||
while( testlex(lexer) )
|
||||
{
|
||||
}
|
||||
yylex_destroy( lexer );
|
||||
testlex_destroy( lexer );
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "bison_nr_parser.h"
|
||||
#include "bison_nr_scanner.h"
|
||||
|
||||
extern int testparse(void);
|
||||
|
||||
int main ( int argc, char** argv )
|
||||
{
|
||||
|
||||
@@ -38,11 +38,10 @@
|
||||
/* #define YYLEX_PARAM scanner */
|
||||
|
||||
int yyerror(const char* msg);
|
||||
extern int testget_lineno(void);
|
||||
|
||||
|
||||
/* A dummy function. A check against seg-faults in yylval->str. */
|
||||
int process_text(char* s) {
|
||||
static int process_text(char* s) {
|
||||
int total =0;
|
||||
while(*s) {
|
||||
total += (int) *s;
|
||||
@@ -54,7 +53,7 @@ int process_text(char* s) {
|
||||
|
||||
%}
|
||||
|
||||
%pure_parser
|
||||
%pure-parser
|
||||
|
||||
%union {
|
||||
int lineno;
|
||||
|
||||
@@ -56,7 +56,7 @@ static char* STRDUP(char* s1);
|
||||
|
||||
static char* STRDUP(char* s1)
|
||||
{
|
||||
char* s2 = (char*)malloc(strlen(s1)+1);
|
||||
char* s2 = malloc(strlen(s1)+1);
|
||||
sprintf(s2,"%s",s1);
|
||||
return s2;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,9 @@ int yyerror(YYLTYPE *location, void* scanner, const char* msg);
|
||||
|
||||
#define YYERROR_VERBOSE 1
|
||||
|
||||
extern int testget_lineno(void*);
|
||||
|
||||
|
||||
/* A dummy function. A check against seg-faults in yylval->str. */
|
||||
int process_text(char* s) {
|
||||
static int process_text(char* s) {
|
||||
int total =0;
|
||||
while(*s) {
|
||||
total += (int) *s;
|
||||
|
||||
@@ -59,7 +59,7 @@ static char* STRDUP(char* s1);
|
||||
|
||||
static char* STRDUP(char* s1)
|
||||
{
|
||||
char* s2 = (char*)malloc(strlen(s1)+1);
|
||||
char* s2 = malloc(strlen(s1)+1);
|
||||
sprintf(s2,"%s",s1);
|
||||
return s2;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
int yyerror(void* scanner, const char* msg);
|
||||
|
||||
/* A dummy function. A check against seg-faults in yylval->str. */
|
||||
int process_text(char* s) {
|
||||
static int process_text(char* s) {
|
||||
int total =0;
|
||||
while(*s) {
|
||||
total += (int) *s;
|
||||
|
||||
@@ -52,7 +52,7 @@ enum yesno_t { no=0, yes=1 };
|
||||
"</" { NEED_TAG_NAME= yes; yy_push_state( IN_TAG, yyscanner); return LTSLASH;}
|
||||
"<"[^[:alpha:]] { yy_push_state(DISCARD_THRU_GT,yyscanner); }
|
||||
"<" { NEED_TAG_NAME= yes; yy_push_state( IN_TAG, yyscanner); return LT; }
|
||||
[^<]{1,512} { yyget_lval(yyscanner)->str = STRDUP(yytext); return TEXT;}
|
||||
[^<]{1,512} { testget_lval(yyscanner)->str = STRDUP(yytext); return TEXT;}
|
||||
}
|
||||
<IN_TAG>{
|
||||
">" { yy_pop_state( yyscanner ); return GT; }
|
||||
@@ -75,7 +75,7 @@ enum yesno_t { no=0, yes=1 };
|
||||
|
||||
static char* STRDUP(char* s1)
|
||||
{
|
||||
char* s2 = (char*)malloc(strlen(s1)+1);
|
||||
char* s2 = malloc(strlen(s1)+1);
|
||||
sprintf(s2,"%s",s1);
|
||||
return s2;
|
||||
}
|
||||
|
||||
+4
-4
@@ -48,10 +48,10 @@ int main(void);
|
||||
int
|
||||
main ()
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
yylex();
|
||||
yylex_destroy();
|
||||
testin = stdin;
|
||||
testout = stdout;
|
||||
testlex();
|
||||
testlex_destroy();
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+5
-5
@@ -49,13 +49,13 @@ int
|
||||
main ()
|
||||
{
|
||||
yyscan_t lexer;
|
||||
yylex_init( &lexer );
|
||||
yyset_out ( stdout,lexer);
|
||||
yyset_in ( stdin, lexer);
|
||||
while( yylex(lexer) )
|
||||
testlex_init( &lexer );
|
||||
testset_out ( stdout,lexer);
|
||||
testset_in ( stdin, lexer);
|
||||
while( testlex(lexer) )
|
||||
{
|
||||
}
|
||||
yylex_destroy( lexer );
|
||||
testlex_destroy( lexer );
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
|
||||
@@ -21,47 +21,31 @@
|
||||
* PURPOSE.
|
||||
*/
|
||||
|
||||
/* TEST scanner.
|
||||
Basic non-reentrant scanner, but with non-ansi function defs.
|
||||
Compile with: flex scanner.l
|
||||
|
||||
Sample Input:
|
||||
# this is a comment
|
||||
foo = true
|
||||
bar = "string value"
|
||||
integer = 43
|
||||
*/
|
||||
%{
|
||||
|
||||
#include "config.h"
|
||||
|
||||
%}
|
||||
|
||||
%option prefix="test"
|
||||
%option nounput noyywrap noyylineno warn nodefault noinput
|
||||
%option noansi-prototypes noansi-definitions
|
||||
%option 8bit prefix="test"
|
||||
%option warn c++
|
||||
%option nounput nomain noinput noyywrap
|
||||
|
||||
IDENT [[:alnum:]_-]
|
||||
WS [[:blank:]]
|
||||
%%
|
||||
|
||||
^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;}
|
||||
^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;}
|
||||
^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;}
|
||||
^{WS}*#.*\r?\n { }
|
||||
^{WS}*\r?\n { }
|
||||
.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);}
|
||||
. { }
|
||||
|
||||
%%
|
||||
|
||||
int main(void);
|
||||
|
||||
int main ()
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
while( yylex() )
|
||||
{
|
||||
}
|
||||
printf("TEST RETURNING OK.\n");
|
||||
yyFlexLexer f;
|
||||
f.switch_streams(&std::cin, &std::cout);
|
||||
f.yylex();
|
||||
f.yyrestart(NULL);
|
||||
std::cout << "TEST RETURNING OK." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
0000 foo 1111 foo 0000 bar
|
||||
0000 foo 1111 foo 0000 bar
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
|
||||
+6
-6
@@ -40,20 +40,20 @@
|
||||
|
||||
int main(void);
|
||||
|
||||
int main ()
|
||||
int main (void)
|
||||
{
|
||||
yyscan_t lexer;
|
||||
yylex_init( &lexer );
|
||||
yyset_out ( stdout,lexer);
|
||||
yyset_in ( stdin, lexer);
|
||||
testlex_init( &lexer );
|
||||
testset_out ( stdout,lexer);
|
||||
testset_in ( stdin, lexer);
|
||||
|
||||
/* Just see if the next line compiles. */
|
||||
testset_debug (testget_debug(lexer), lexer);
|
||||
|
||||
while( yylex(lexer) )
|
||||
while( testlex(lexer) )
|
||||
{
|
||||
}
|
||||
yylex_destroy( lexer );
|
||||
testlex_destroy( lexer );
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ A(?x: B
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
|
||||
@@ -29,6 +29,8 @@ f * are met:
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "config.h"
|
||||
|
||||
int error = 0;
|
||||
%}
|
||||
|
||||
%option 8bit prefix="test"
|
||||
@@ -56,6 +58,7 @@ int include_stack_ptr = 0;
|
||||
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
|
||||
if((yyin=fopen(yytext,"r"))==NULL) {
|
||||
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext);
|
||||
error = 1;
|
||||
yyterminate();
|
||||
}
|
||||
yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE ));
|
||||
@@ -63,6 +66,7 @@ int include_stack_ptr = 0;
|
||||
}
|
||||
.|\n {
|
||||
fprintf(stderr,"Invalid input \"%s\".\n", yytext);
|
||||
error = 1;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
@@ -97,6 +101,9 @@ main ( int argc, char** argv )
|
||||
yyin = fp;
|
||||
yyout = stdout;
|
||||
yylex();
|
||||
printf("TEST RETURNING OK.\n");
|
||||
if (!error)
|
||||
printf("TEST RETURNING OK.\n");
|
||||
else
|
||||
exit(-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "config.h"
|
||||
|
||||
int error = 0;
|
||||
%}
|
||||
|
||||
%option 8bit prefix="test"
|
||||
@@ -50,20 +52,22 @@
|
||||
yytext[yyleng-1]='\0';
|
||||
if((yyin=fopen(yytext,"r"))==NULL) {
|
||||
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext);
|
||||
error = 1;
|
||||
yyterminate();
|
||||
}
|
||||
yypush_buffer_state( yy_create_buffer( yyin, YY_BUF_SIZE ));
|
||||
testpush_buffer_state( yy_create_buffer( yyin, YY_BUF_SIZE ));
|
||||
BEGIN(0);
|
||||
}
|
||||
.|\n {
|
||||
fprintf(stderr,"Invalid input \"%s\".\n", yytext);
|
||||
error = 1;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
fclose(yyin);
|
||||
yypop_buffer_state();
|
||||
testpop_buffer_state();
|
||||
if(!YY_CURRENT_BUFFER)
|
||||
yyterminate();
|
||||
}
|
||||
@@ -87,6 +91,9 @@ main ( int argc, char** argv )
|
||||
yyin = fp;
|
||||
yyout = stdout;
|
||||
yylex();
|
||||
printf("TEST RETURNING OK.\n");
|
||||
if (!error)
|
||||
printf("TEST RETURNING OK.\n");
|
||||
else
|
||||
exit(-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "config.h"
|
||||
|
||||
int error = 0;
|
||||
%}
|
||||
|
||||
%option 8bit prefix="test"
|
||||
@@ -54,18 +56,20 @@
|
||||
if((fp=fopen(yytext,"r"))==NULL) {
|
||||
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",
|
||||
yytext);
|
||||
error = 1;
|
||||
yyterminate();
|
||||
}
|
||||
yylex_init(&scanner);
|
||||
yyset_in( fp, scanner);
|
||||
yyset_out( stdout, scanner);
|
||||
yylex(scanner);
|
||||
yylex_destroy(scanner);
|
||||
testlex_init(&scanner);
|
||||
testset_in( fp, scanner);
|
||||
testset_out( stdout, scanner);
|
||||
testlex(scanner);
|
||||
testlex_destroy(scanner);
|
||||
|
||||
BEGIN(0);
|
||||
}
|
||||
.|\n {
|
||||
fprintf(stderr,"Invalid input \"%s\".\n", yytext);
|
||||
error = 1;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
@@ -77,9 +81,7 @@
|
||||
int main (int argc, char** argv);
|
||||
|
||||
int
|
||||
main ( argc, argv )
|
||||
int argc;
|
||||
char ** argv;
|
||||
main ( int argc, char **argv )
|
||||
{
|
||||
FILE * fp;
|
||||
yyscan_t scanner;
|
||||
@@ -91,11 +93,14 @@ main ( argc, argv )
|
||||
fprintf(stderr,"*** Error: fopen(%s) failed.\n",argv[1]);
|
||||
exit(-1);
|
||||
}
|
||||
yylex_init(&scanner);
|
||||
yyset_in( fp, scanner);
|
||||
yyset_out( stdout, scanner);
|
||||
yylex(scanner);
|
||||
yylex_destroy(scanner);
|
||||
printf("TEST RETURNING OK.\n");
|
||||
testlex_init(&scanner);
|
||||
testset_in( fp, scanner);
|
||||
testset_out( stdout, scanner);
|
||||
testlex(scanner);
|
||||
testlex_destroy(scanner);
|
||||
if (!error)
|
||||
printf("TEST RETURNING OK.\n");
|
||||
else
|
||||
exit(-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-3
@@ -78,9 +78,7 @@ count_newlines (FILE* in)
|
||||
int main ( int, char**);
|
||||
|
||||
int
|
||||
main ( argc, argv )
|
||||
int argc;
|
||||
char** argv;
|
||||
main ( int argc, char **argv )
|
||||
{
|
||||
(void)argv;
|
||||
|
||||
|
||||
+6
-8
@@ -78,9 +78,7 @@ count_newlines (FILE* in)
|
||||
int main ( int argc, char** argv );
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char ** argv;
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
(void)argv;
|
||||
|
||||
@@ -89,11 +87,11 @@ main (argc, argv)
|
||||
|
||||
else{
|
||||
yyscan_t s;
|
||||
yylex_init(&s);
|
||||
yyset_in(stdin,s);
|
||||
yyset_out(stdout,s);
|
||||
yylex(s);
|
||||
yylex_destroy(s);
|
||||
testlex_init(&s);
|
||||
testset_in(stdin,s);
|
||||
testset_out(stdout,s);
|
||||
testlex(s);
|
||||
testlex_destroy(s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,9 +71,7 @@ count_newlines (FILE* in)
|
||||
int main ( int, char**);
|
||||
|
||||
int
|
||||
main ( argc, argv )
|
||||
int argc;
|
||||
char** argv;
|
||||
main ( int argc, char **argv )
|
||||
{
|
||||
(void)argv;
|
||||
|
||||
|
||||
+7
-7
@@ -91,12 +91,12 @@ void * yyalloc(yy_size_t n)
|
||||
int i;
|
||||
|
||||
total_mem += n;
|
||||
p = (void*)malloc(n);
|
||||
p = malloc(n);
|
||||
|
||||
if( nptrs >= arrsz){
|
||||
/* increase array size by 1 */
|
||||
arrsz++;
|
||||
ptrs = (struct memsz*)realloc( ptrs, arrsz * sizeof(struct memsz));
|
||||
ptrs = realloc(ptrs, (size_t) arrsz * sizeof(struct memsz));
|
||||
ptrs[nptrs].p = 0;
|
||||
ptrs[nptrs].sz = 0;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ void * yyrealloc(void* p, yy_size_t n)
|
||||
if ( ptrs[i].p == p){
|
||||
total_mem -= ptrs[i].sz;
|
||||
total_mem += n;
|
||||
ptrs[i].p = (void*)realloc(p,n);
|
||||
ptrs[i].p = realloc(p,n);
|
||||
ptrs[i].sz = n;
|
||||
|
||||
printf("yyflex_realloc(%#10lx,%8ld) total=%8ld return=%8lx\n",
|
||||
@@ -158,16 +158,16 @@ void yyfree(void* p)
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
arrsz = 1;
|
||||
ptrs = (struct memsz*)calloc(1,sizeof(struct memsz));
|
||||
ptrs = calloc(1, sizeof(struct memsz));
|
||||
nptrs = 0;
|
||||
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
yylex();
|
||||
yylex_destroy();
|
||||
testlex();
|
||||
testlex_destroy();
|
||||
free(ptrs);
|
||||
|
||||
if ( nptrs > 0 || total_mem > 0){
|
||||
|
||||
+13
-13
@@ -85,7 +85,7 @@ static void dump_mem(FILE* fp){
|
||||
fprintf(fp,"}\n");
|
||||
}
|
||||
|
||||
void * yyalloc(yy_size_t n , void* yyscanner)
|
||||
void * testalloc(yy_size_t n , void* yyscanner)
|
||||
{
|
||||
(void)yyscanner;
|
||||
|
||||
@@ -93,12 +93,12 @@ void * yyalloc(yy_size_t n , void* yyscanner)
|
||||
int i;
|
||||
|
||||
total_mem += n;
|
||||
p = (void*)malloc(n);
|
||||
p = malloc(n);
|
||||
|
||||
if( nptrs >= arrsz){
|
||||
/* increase array size by 1 */
|
||||
arrsz++;
|
||||
ptrs = (struct memsz*)realloc( ptrs, arrsz * sizeof(struct memsz));
|
||||
ptrs = realloc(ptrs, (size_t) arrsz * sizeof(struct memsz));
|
||||
ptrs[nptrs].p = 0;
|
||||
ptrs[nptrs].sz = 0;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ void * yyalloc(yy_size_t n , void* yyscanner)
|
||||
return p;
|
||||
}
|
||||
|
||||
void * yyrealloc(void* p, yy_size_t n , void* yyscanner)
|
||||
void * testrealloc(void* p, yy_size_t n , void* yyscanner)
|
||||
{
|
||||
(void)yyscanner;
|
||||
|
||||
@@ -125,7 +125,7 @@ void * yyrealloc(void* p, yy_size_t n , void* yyscanner)
|
||||
if ( ptrs[i].p == p){
|
||||
total_mem -= ptrs[i].sz;
|
||||
total_mem += n;
|
||||
ptrs[i].p = (void*)realloc(p,n);
|
||||
ptrs[i].p = realloc(p, n);
|
||||
ptrs[i].sz = n;
|
||||
|
||||
printf("yyflex_realloc(%#10lx,%8ld) total=%8ld return=%8lx\n",
|
||||
@@ -139,7 +139,7 @@ void * yyrealloc(void* p, yy_size_t n , void* yyscanner)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void yyfree(void* p , void* yyscanner)
|
||||
void testfree(void* p , void* yyscanner)
|
||||
{
|
||||
(void)yyscanner;
|
||||
|
||||
@@ -164,18 +164,18 @@ void yyfree(void* p , void* yyscanner)
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyscan_t scanner;
|
||||
arrsz = 1;
|
||||
ptrs = (struct memsz*)calloc(1,sizeof(struct memsz));
|
||||
ptrs = calloc(1, sizeof(struct memsz));
|
||||
nptrs = 0;
|
||||
|
||||
yylex_init(&scanner);
|
||||
yyset_in(stdin,scanner);
|
||||
yyset_out(stdout,scanner);
|
||||
yylex(scanner);
|
||||
yylex_destroy(scanner);
|
||||
testlex_init(&scanner);
|
||||
testset_in(stdin,scanner);
|
||||
testset_out(stdout,scanner);
|
||||
testlex(scanner);
|
||||
testlex_destroy(scanner);
|
||||
free(ptrs);
|
||||
|
||||
if ( nptrs > 0 || total_mem > 0){
|
||||
|
||||
@@ -31,7 +31,6 @@ main ( int argc, char** argv )
|
||||
(void)argv;
|
||||
|
||||
int S1_ok=1, S2_ok=1;
|
||||
FILE * fp;
|
||||
YY_BUFFER_STATE buff1, buff2;
|
||||
yyscan_t scan1, scan2;
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# this is a comment
|
||||
foo = "bar"
|
||||
num = 43
|
||||
setting = false
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* A reentrant scanner.
|
||||
This file will not compile under flex version <= 2.5.4.
|
||||
Sample Input:
|
||||
# this is a comment
|
||||
foo = true
|
||||
bar = "string value"
|
||||
integer = 43
|
||||
*/
|
||||
%{
|
||||
#include "config.h"
|
||||
%}
|
||||
|
||||
%option prefix="test"
|
||||
%option nounput noyywrap noyylineno warn nodefault noinput
|
||||
%option reentrant
|
||||
%option noansi-definitions noansi-prototypes
|
||||
|
||||
IDENT [[:alnum:]_-]
|
||||
WS [[:blank:]]
|
||||
%%
|
||||
|
||||
^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;}
|
||||
^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;}
|
||||
^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;}
|
||||
^{WS}*#.*\r?\n { }
|
||||
^{WS}*\r?\n { }
|
||||
.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);}
|
||||
|
||||
%%
|
||||
|
||||
int main(void);
|
||||
|
||||
int main ()
|
||||
{
|
||||
yyscan_t lexer;
|
||||
yylex_init( &lexer );
|
||||
yyset_out ( stdout,lexer);
|
||||
yyset_in ( stdin, lexer);
|
||||
while( yylex(lexer) )
|
||||
{
|
||||
}
|
||||
yylex_destroy( lexer );
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# this is a comment
|
||||
foo = "bar"
|
||||
num = 43
|
||||
setting = false
|
||||
+4
-4
@@ -53,7 +53,7 @@ ab{3} tests_ok[0] = 1; return 0;
|
||||
%%
|
||||
|
||||
|
||||
int main ()
|
||||
int main (void)
|
||||
{
|
||||
YY_BUFFER_STATE state;
|
||||
int i;
|
||||
@@ -63,9 +63,9 @@ int main ()
|
||||
|
||||
/* Run the tests */
|
||||
for (i=0; i < NUM_TESTS; i++){
|
||||
printf("Testing: yy_scan_string(%s): ", tests[i]);
|
||||
state = yy_scan_string(tests[i]);
|
||||
yylex();
|
||||
printf("Testing: test_scan_string(%s): ", tests[i]);
|
||||
state = test_scan_string(tests[i]);
|
||||
testlex();
|
||||
yy_delete_buffer(state);
|
||||
printf("... %s\n", tests_ok[i] ? "OK" : "FAILED");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ ab{3} tests_ok[0] = 1; return 0;
|
||||
%%
|
||||
|
||||
|
||||
int main ()
|
||||
int main (void)
|
||||
{
|
||||
YY_BUFFER_STATE state;
|
||||
int i;
|
||||
@@ -63,9 +63,9 @@ int main ()
|
||||
|
||||
/* Run the tests */
|
||||
for (i=0; i < NUM_TESTS; i++){
|
||||
printf("Testing: yy_scan_string(%s): ", tests[i]);
|
||||
state = yy_scan_string(tests[i]);
|
||||
yylex();
|
||||
printf("Testing: test_scan_string(%s): ", tests[i]);
|
||||
state = test_scan_string(tests[i]);
|
||||
testlex();
|
||||
yy_delete_buffer(state);
|
||||
printf("... %s\n", tests_ok[i] ? "OK" : "FAILED");
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyscan_t scanner;
|
||||
FOOlex_init( &scanner);
|
||||
|
||||
+8
-10
@@ -78,14 +78,14 @@ static int process_text(char* s, yyscan_t scanner);
|
||||
<INITIAL,STATE_1,STATE_2>[[:space:]\r\n]+ { }
|
||||
%%
|
||||
|
||||
int yywrap( yyscan_t scanner) {
|
||||
int testwrap( yyscan_t scanner) {
|
||||
(void)scanner;
|
||||
return 1;
|
||||
}
|
||||
static int process_text(char* s, yyscan_t scanner)
|
||||
{
|
||||
(void)scanner;
|
||||
return (int)(*s) + (int) *(s + yyget_leng(scanner)-1);
|
||||
return (int)(*s) + (int) *(s + testget_leng(scanner)-1);
|
||||
}
|
||||
|
||||
int main(int ARGC, char *ARGV[]);
|
||||
@@ -114,7 +114,7 @@ static pthread_mutex_t *file_locks;
|
||||
static char **filenames;
|
||||
|
||||
|
||||
void * thread_func ( void* arg )
|
||||
static void * thread_func ( void* arg )
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -126,8 +126,6 @@ void * thread_func ( void* arg )
|
||||
|
||||
for( i =0 ; i < N_SCANS ; i++ )
|
||||
{
|
||||
int main(int ARGC, char *ARGV[]);
|
||||
|
||||
int next;
|
||||
yyscan_t scanner;
|
||||
FILE * fp;
|
||||
@@ -138,19 +136,19 @@ void * thread_func ( void* arg )
|
||||
|
||||
pthread_mutex_lock ( &file_locks[ next ] );
|
||||
|
||||
yylex_init( &scanner );
|
||||
testlex_init( &scanner );
|
||||
/*printf("Scanning file %s #%d\n",filenames[next],i); fflush(stdout); */
|
||||
if((fp = fopen(filenames[next],"r"))==NULL) {
|
||||
perror("fopen");
|
||||
return NULL;
|
||||
}
|
||||
yyset_in(fp,scanner);
|
||||
testset_in(fp,scanner);
|
||||
|
||||
while( yylex( scanner) != 0)
|
||||
while( testlex( scanner) != 0)
|
||||
{
|
||||
}
|
||||
fclose(fp);
|
||||
yylex_destroy(scanner);
|
||||
testlex_destroy(scanner);
|
||||
pthread_mutex_unlock ( &file_locks[ next ] );
|
||||
}
|
||||
return NULL;
|
||||
@@ -167,7 +165,7 @@ int main (int ARGC, char *ARGV[])
|
||||
}
|
||||
|
||||
/* Allocate and initialize the locks. One for each filename in ARGV. */
|
||||
file_locks = (pthread_mutex_t*)malloc( (ARGC-1) * sizeof(pthread_mutex_t));
|
||||
file_locks = malloc((size_t) (ARGC-1) * sizeof(pthread_mutex_t));
|
||||
for( i = 0; i < ARGC-1; i++)
|
||||
pthread_mutex_init( &file_locks[i], NULL );
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
%option 8bit noyywrap
|
||||
%%
|
||||
.|\n { ECHO;
|
||||
//' "
|
||||
}
|
||||
%%
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
yyout = stdout;
|
||||
while (yylex())
|
||||
;
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
test
|
||||
+34
-4
@@ -38,6 +38,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
/*#include "parser.h" */
|
||||
|
||||
/* sect 1 block [ 1 ] TEST_XXX */
|
||||
@@ -61,6 +62,17 @@ static int foo (int i){
|
||||
|
||||
|
||||
%%
|
||||
/* indented code [ 1 ] */
|
||||
/* indented code [[ 2 ]] */
|
||||
/* indented code [[[ 3 ]]] */
|
||||
/* indented code [[[[ 4 ]]]] */
|
||||
/* indented code ]] unmatched [[ */
|
||||
%{
|
||||
// non-indented code [ 1 ]
|
||||
// non-indented code [[ 2 ]]
|
||||
// non-indented code [[[ 3 ]]]
|
||||
// non-indented code [[[[ 4 ]]]]
|
||||
%}
|
||||
|
||||
a /* action comment [ 1 ] */ ;
|
||||
b /* action comment [[ 2 ]] */ ;
|
||||
@@ -68,13 +80,27 @@ c /* action comment [[[ 3 ]]] */ ;
|
||||
d /* action comment [[[[ 4 ]]]] */ ;
|
||||
e /* action comment ]] unmatched [[ */ ;
|
||||
f return 1+foo(a[b[c[0]]]);
|
||||
.|\n {
|
||||
.|\n {
|
||||
|
||||
#if 0
|
||||
action code [ 1 ] TEST_XXX
|
||||
action code [[ 2 ]] TEST_XXX
|
||||
action code [[[ 3 ]]] TEST_XXX
|
||||
action code [[[[ 4 ]]]] TEST_XXX
|
||||
action code ]] unmatched [[ TEST_XXX
|
||||
#endif
|
||||
/* action block [ 1 ] TEST_XXX */
|
||||
/* action block [[ 2 ]] TEST_XXX */
|
||||
/* action block [[[ 3 ]]] TEST_XXX */
|
||||
/* action block [[[[ 4 ]]]] TEST_XXX */
|
||||
/* action block ]] unmatched [[ TEST_XXX */
|
||||
return 1+foo(a[b[c[0]]]); // TEST_XXX
|
||||
assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]"));
|
||||
assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]"));
|
||||
assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]"));
|
||||
assert(!strcmp("]] unmatched [[", "]""] unmatched [""["));
|
||||
assert(!strcmp("]]m4_define(alpha, beta)[[",
|
||||
"]""]m4_""define(alpha, beta)[""["));
|
||||
return 1+foo(a[b[c[0]]]); /* TEST_XXX */
|
||||
}
|
||||
%%
|
||||
|
||||
@@ -88,13 +114,17 @@ static int bar (int i){
|
||||
}
|
||||
int main(void);
|
||||
|
||||
#define CONCAT_IDENTS(a, b) a##b
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
yyin = stdin;
|
||||
/* m4_m4exit(100) */
|
||||
FILE *M4_YY_NOT_IN_HEADER = stdin;
|
||||
yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER);
|
||||
yyout = stdout;
|
||||
while (yylex())
|
||||
;
|
||||
assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)"));
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return bar(0);
|
||||
}
|
||||
|
||||
+5
-5
@@ -47,13 +47,13 @@ int main ( int argc, char** argv )
|
||||
M4_YY_DECL_GUTS_VAR();
|
||||
|
||||
#ifdef TEST_IS_REENTRANT
|
||||
yylex_init(&yyscanner);
|
||||
testlex_init(&yyscanner);
|
||||
#else
|
||||
(void)yyscanner;
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HAS_TABLES_EXTERNAL
|
||||
if((fp = fopen(argv[1],"r"))== NULL)
|
||||
if((fp = fopen(argv[1],"rb"))== NULL)
|
||||
YY_FATAL_ERROR("could not open tables file for reading");
|
||||
|
||||
if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0)
|
||||
@@ -67,13 +67,13 @@ int main ( int argc, char** argv )
|
||||
YY_FATAL_ERROR("could not open input file for reading");
|
||||
yyin = fp;
|
||||
}
|
||||
while(yylex(M4_YY_CALL_ONLY_ARG) != 0)
|
||||
while(testlex(M4_YY_CALL_ONLY_ARG) != 0)
|
||||
;
|
||||
|
||||
#ifdef TEST_HAS_TABLES_EXTERNAL
|
||||
yytables_destroy(M4_YY_CALL_ONLY_ARG);
|
||||
testtables_destroy(M4_YY_CALL_ONLY_ARG);
|
||||
#endif
|
||||
yylex_destroy(M4_YY_CALL_ONLY_ARG);
|
||||
testlex_destroy(M4_YY_CALL_ONLY_ARG);
|
||||
|
||||
if(argc < 0) /* silence the compiler */
|
||||
yyscanner = (void*)fp;
|
||||
|
||||
@@ -58,14 +58,14 @@ main (int argc, char* const argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
yyset_out ( stdout);
|
||||
testset_out ( stdout);
|
||||
|
||||
for (i=0; i < 4; ++i){
|
||||
rewind(fp);
|
||||
yyset_in ( fp);
|
||||
while( yylex() )
|
||||
testset_in ( fp);
|
||||
while( testlex() )
|
||||
;
|
||||
yylex_destroy();
|
||||
testlex_destroy();
|
||||
}
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
|
||||
+10
-10
@@ -60,18 +60,18 @@ main (int argc, char* const argv[])
|
||||
}
|
||||
|
||||
printf("Test 1: Reusing same scanner.\n");
|
||||
yylex_init( &yyscanner );
|
||||
yyset_out ( stdout, yyscanner);
|
||||
testlex_init( &yyscanner );
|
||||
testset_out ( stdout, yyscanner);
|
||||
|
||||
for (i=0; i < 4; ++i){
|
||||
|
||||
rewind(fp);
|
||||
yyset_in ( fp, yyscanner);
|
||||
testset_in ( fp, yyscanner);
|
||||
|
||||
while( yylex(yyscanner) )
|
||||
while( testlex(yyscanner) )
|
||||
;
|
||||
}
|
||||
yylex_destroy( yyscanner );
|
||||
testlex_destroy( yyscanner );
|
||||
printf("Test 1 OK\n\n");
|
||||
|
||||
printf("Test 2: Rescanning with new scanner each time.\n");
|
||||
@@ -80,14 +80,14 @@ main (int argc, char* const argv[])
|
||||
|
||||
for (i=0; i < 4; ++i){
|
||||
yyscan_t s;
|
||||
yylex_init( &s );
|
||||
yyset_out ( stdout, s);
|
||||
testlex_init( &s );
|
||||
testset_out ( stdout, s);
|
||||
rewind(fp);
|
||||
yyset_in ( fp, s);
|
||||
testset_in ( fp, s);
|
||||
|
||||
while( yylex(s) )
|
||||
while( testlex(s) )
|
||||
;
|
||||
yylex_destroy( s );
|
||||
testlex_destroy( s );
|
||||
}
|
||||
printf("Test 2 OK\n\n");
|
||||
|
||||
|
||||
+14
-14
@@ -59,37 +59,37 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
char * buf;
|
||||
int len;
|
||||
size_t len;
|
||||
YY_BUFFER_STATE state;
|
||||
|
||||
|
||||
/* Scan a good string. */
|
||||
printf("Testing: yy_scan_string(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
state = yy_scan_string ( INPUT_STRING_1 );
|
||||
yylex();
|
||||
printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
state = test_scan_string ( INPUT_STRING_1 );
|
||||
testlex();
|
||||
yy_delete_buffer(state);
|
||||
|
||||
/* Scan only the first 12 chars of a string. */
|
||||
printf("Testing: yy_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout);
|
||||
state = yy_scan_bytes ( INPUT_STRING_2, 12 );
|
||||
yylex();
|
||||
yy_delete_buffer(state);
|
||||
printf("Testing: test_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout);
|
||||
state = test_scan_bytes ( INPUT_STRING_2, 12 );
|
||||
testlex();
|
||||
test_delete_buffer(state);
|
||||
|
||||
/* Scan directly from a buffer.
|
||||
We make a copy, since the buffer will be modified by flex.*/
|
||||
printf("Testing: yy_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
printf("Testing: test_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
len = strlen(INPUT_STRING_1) + 2;
|
||||
buf = (char*)malloc( len );
|
||||
buf = malloc(len);
|
||||
strcpy( buf, INPUT_STRING_1);
|
||||
buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */
|
||||
buf[ len -1 ] =0;
|
||||
|
||||
state = yy_scan_buffer( buf, len );
|
||||
yylex();
|
||||
yy_delete_buffer(state);
|
||||
state = test_scan_buffer( buf, len );
|
||||
testlex();
|
||||
test_delete_buffer(state);
|
||||
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
|
||||
+21
-21
@@ -59,44 +59,44 @@
|
||||
int main(void);
|
||||
|
||||
int
|
||||
main ()
|
||||
main (void)
|
||||
{
|
||||
char * buf;
|
||||
int len;
|
||||
size_t len;
|
||||
YY_BUFFER_STATE state;
|
||||
yyscan_t scanner=NULL;
|
||||
|
||||
|
||||
/* Scan a good string. */
|
||||
printf("Testing: yy_scan_string(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
yylex_init(&scanner);
|
||||
state = yy_scan_string ( INPUT_STRING_1 ,scanner);
|
||||
yylex(scanner);
|
||||
yy_delete_buffer(state, scanner);
|
||||
yylex_destroy(scanner);
|
||||
printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
testlex_init(&scanner);
|
||||
state = test_scan_string ( INPUT_STRING_1 ,scanner);
|
||||
testlex(scanner);
|
||||
test_delete_buffer(state, scanner);
|
||||
testlex_destroy(scanner);
|
||||
|
||||
/* Scan only the first 12 chars of a string. */
|
||||
printf("Testing: yy_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout);
|
||||
yylex_init(&scanner);
|
||||
state = yy_scan_bytes ( INPUT_STRING_2, 12 ,scanner);
|
||||
yylex(scanner);
|
||||
yy_delete_buffer(state,scanner);
|
||||
yylex_destroy(scanner);
|
||||
printf("Testing: test_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout);
|
||||
testlex_init(&scanner);
|
||||
state = test_scan_bytes ( INPUT_STRING_2, 12 ,scanner);
|
||||
testlex(scanner);
|
||||
test_delete_buffer(state,scanner);
|
||||
testlex_destroy(scanner);
|
||||
|
||||
/* Scan directly from a buffer.
|
||||
We make a copy, since the buffer will be modified by flex.*/
|
||||
printf("Testing: yy_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
printf("Testing: test_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
|
||||
len = strlen(INPUT_STRING_1) + 2;
|
||||
buf = (char*)malloc( len );
|
||||
buf = malloc(len);
|
||||
strcpy( buf, INPUT_STRING_1);
|
||||
buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */
|
||||
buf[ len -1 ] =0;
|
||||
|
||||
yylex_init(&scanner);
|
||||
state = yy_scan_buffer( buf, len ,scanner);
|
||||
yylex(scanner);
|
||||
yy_delete_buffer(state,scanner);
|
||||
yylex_destroy(scanner);
|
||||
testlex_init(&scanner);
|
||||
state = test_scan_buffer( buf, len ,scanner);
|
||||
testlex(scanner);
|
||||
test_delete_buffer(state,scanner);
|
||||
testlex_destroy(scanner);
|
||||
|
||||
printf("TEST RETURNING OK.\n");
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ int main ( int argc, char** argv )
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HAS_TABLES_EXTERNAL
|
||||
if((fp = fopen(argv[1],"r"))== NULL)
|
||||
if((fp = fopen(argv[1],"rb"))== NULL)
|
||||
YY_FATAL_ERROR("could not open tables file for reading");
|
||||
|
||||
if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0)
|
||||
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash -vx
|
||||
set -euo pipefail
|
||||
|
||||
# testwrapper-direct.sh: run some specialized flex tests that care where they're run from.
|
||||
|
||||
while getopts :b:s: OPTION ; do
|
||||
case $OPTION in
|
||||
b) BINARY_DIR=$OPTARG ;;
|
||||
s) SOURCE_DIR=$OPTARG ;;
|
||||
esac
|
||||
done
|
||||
|
||||
TESTNAME="${!OPTIND}"
|
||||
|
||||
INPUT_NAME=`basename ${TESTNAME%.exe}`.txt
|
||||
|
||||
cd ${SOURCE_DIR} && ${BINARY_DIR}/${TESTNAME} ${INPUT_NAME}
|
||||
@@ -30,23 +30,23 @@ while getopts :d:i:rt1 OPTION ; do
|
||||
|
||||
TESTNAME="${!OPTIND}"
|
||||
|
||||
INPUT_NAME=${INPUT_NAME:-`basename $TESTNAME`.txt}
|
||||
INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename ${TESTNAME%.exe}`.txt}
|
||||
|
||||
if [ "$DO_COMPARISON" -eq "1" ] ; then
|
||||
test `$TESTNAME 1 < $INPUT_DIRECTORY/$INPUT_NAME` -eq `$TESTNAME < $INPUT_DIRECTORY/$INPUT_NAME`
|
||||
test `$TESTNAME 1 < $INPUT_NAME` -eq `$TESTNAME < $INPUT_NAME`
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ $INPUT_COUNT -gt 1 ] ; then
|
||||
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} ${INPUT_NAME}
|
||||
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} ${INPUT_NAME}
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ -f ${INPUT_DIRECTORY}/${INPUT_NAME} ] ; then
|
||||
if [ -f ${INPUT_NAME} ] ; then
|
||||
if [ $USE_REDIRECT == 1 ] ; then
|
||||
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} < $INPUT_DIRECTORY/$INPUT_NAME
|
||||
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < $INPUT_NAME
|
||||
else
|
||||
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} $INPUT_DIRECTORY/$INPUT_NAME
|
||||
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} $INPUT_NAME
|
||||
fi
|
||||
else
|
||||
$TESTNAME
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user