diff options
author | millaway <millaway> | 2002-03-18 07:50:28 +0000 |
---|---|---|
committer | millaway <millaway> | 2002-03-18 07:50:28 +0000 |
commit | ec664b3f1b616e63336a976b8322d6edf41f687a (patch) | |
tree | cf5cd71c72282f4f46781920511a241f0a22c7e9 | |
parent | b33a4821348885f06e55d0493ec83a3ee88b1b51 (diff) | |
download | flex-ec664b3f1b616e63336a976b8322d6edf41f687a.tar.gz |
Removed CFront 1.2 -specific code from skeleton, because CFront now defines __cplusplus properly.
Removed TurboC-specific code from skeleton.
Skeleton now includes proper C++ standard headers.
Relocated "unistd.h" code after user section 1 to allow user to overrid it.
New option "nounistd" to suppress unistd.h from being included.
-rw-r--r-- | flex.skl | 56 | ||||
-rw-r--r-- | flex.texi | 12 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | options.c | 1 | ||||
-rw-r--r-- | options.h | 1 | ||||
-rw-r--r-- | scan.l | 1 |
6 files changed, 42 insertions, 37 deletions
@@ -23,29 +23,24 @@ #define YY_FLEX_MINOR_VERSION 5 %- +/* begin standard C headers. */ #include <stdio.h> #include <errno.h> +#include <stdlib.h> +/* end standard C headers. */ %+ +/* begin standard C++ headers. */ +#include <iostream> #include <cerrno> +#include <cstdlib> +/* end standard C++ headers. */ %* - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - #ifdef __cplusplus -#include <stdlib.h> %+ #define FLEX_STD std:: -#include <iostream> %* -#include <unistd.h> /* Use prototypes in function declarations. */ #define YY_USE_PROTOS @@ -63,15 +58,6 @@ #endif /* __STDC__ */ #endif /* ! __cplusplus */ -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - #ifdef YY_USE_CONST #define yyconst const #else @@ -402,6 +388,19 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); %% [4.0] data tables for the DFA and the user's section 1 definitions go here %e +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#ifndef YY_NO_UNISTD_H +%- +#include <unistd.h> +%+ +#include <cunistd> +%* +#endif /* !YY_NO_UNISTD_H */ + + #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif @@ -591,21 +590,6 @@ static int yy_top_state YY_PROTO(( YY_ONLY_ARG )); #define YY_NO_TOP_STATE 1 #endif -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 @@ -2276,6 +2276,7 @@ classes are often a big win when using compressed tables, but they have a moderate performance impact (one or two @code{if} tests and one array look-up per character scanned). +@anchor{option-read} @item -Cr, --read causes the generated scanner to @emph{bypass} use of the standard I/O library (@code{stdio}) for input. Instead of calling @code{fread()} or @@ -2387,6 +2388,7 @@ constructs its scanners. You'll never need this option unless you are doing @code{flex} maintenance or development. +@anchor{option-always-interactive} @item --always-interactive instructs flex to generate a scanner which always considers its input @emph{interactive}. Normally, on each new input file the scanner calls @@ -2403,6 +2405,15 @@ scanner, which simply calls @code{yylex()}. This option implies instructs flex to generate a scanner which never considers its input interactive. This is the opposite of @code{always-interactive}. +@item --nounistd +suppresses inclusion of the non-ANSI header file @file{unistd.h}. This option +is meant to target environments in which @file{unistd.h} does not exist. Be aware +that certain options may cause flex to generate code that relies on functions +normally found in @file{unistd.h}, (e.g. @code{isatty()}, @code{read()}.) +If you wish to use these functions, you will have to inform your compiler where +to find them. +@xref{option-always-interactive}. @xref{option-read}. + @item --stack enables the use of start condition stacks (@pxref{start conditions}). @@ -2471,6 +2482,7 @@ leading @samp{--} ). interactive -I --interactive lex-compat -l --lex-compat meta-ecs -Cm --meta-ecs + nounistd --nounistd perf-report -p --perf-report pointer --pointer equivalent to "%pointer" (default) prefix="PREFIX" -P --prefix @@ -573,6 +573,7 @@ int exit_status; fprintf(header_out,"#undef YY_NO_SET_LVAL\n"); fprintf(header_out,"#undef YY_NO_SET_OUT\n"); fprintf(header_out,"#undef YY_NO_TOP_STATE\n"); + fprintf(header_out,"#undef YY_NO_UNISTD_H\n"); fprintf(header_out,"#undef YY_NO_UNPUT\n"); fprintf(header_out,"#undef YY_NULL\n"); fprintf(header_out,"#undef YY_NUM_RULES\n"); @@ -1100,7 +1101,11 @@ char **argv; case OPT_STDOUT: use_stdout = true; break; - + + case OPT_NO_UNISTD_H: + buf_strdefine(&userdef_buf,"YY_NO_UNISTD_H", "1"); + break; + case OPT_TRACE: trace = true; break; @@ -1718,6 +1723,7 @@ _( " -R, --reentrant generate a reentrant C scanner\n" " -Rb, --reentrant-bison reentrant scanner for bison pure parser.\n" " --stdinit initialize yyin/yyout to stdin/stdout\n" +" --nounistd do not include <unistd.h>\n" " --noFUNCTION do not generate a particular FUNCTION\n" "\n" @@ -79,6 +79,7 @@ optspec_t flexopts[] = { {"--stdout", OPT_STDOUT,0},/* Write generated scanner to stdout. */ {"-T", OPT_TRACE,0}, {"--trace", OPT_TRACE,0},/* Flex should run in trace mode. */ +{"--nounistd", OPT_NO_UNISTD_H,0}, /* Do not include unistd.h */ {"-v", OPT_VERBOSE,0}, {"--verbose", OPT_VERBOSE,0},/* Write summary of scanner statistics to stdout. */ {"-V", OPT_VERSION,0}, @@ -79,6 +79,7 @@ enum flexopt_flag_t { OPT_STDINIT, OPT_STDOUT, OPT_TRACE, + OPT_NO_UNISTD_H, OPT_VERBOSE, OPT_VERSION, OPT_WARN, @@ -269,6 +269,7 @@ LEXOPT [aceknopr] stack action_define( "YY_STACK_USED", option_sense ); stdinit do_stdinit = option_sense; stdout use_stdout = option_sense; + unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense); verbose printstats = option_sense; warn nowarn = ! option_sense; |