summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c876
1 files changed, 256 insertions, 620 deletions
diff --git a/main.c b/main.c
index 31833c4..4acd381 100644
--- a/main.c
+++ b/main.c
@@ -41,10 +41,10 @@ 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);
+static char *basename2 (char *path, int should_strip_ext);
/* these globals are all defined and commented in flexdef.h */
@@ -57,14 +57,17 @@ int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap,
int reentrant, bison_bridge_lval, bison_bridge_lloc;
int yymore_used, reject, real_reject, continued_action, in_rule;
int yymore_really_used, reject_really_used;
-int datapos, dataline, linenum;
+int datapos, dataline, linenum, out_linenum;
FILE *skelfile = NULL;
-int skel_ind = 0;
+/* TODO: May want C skel and C++ skel, and maybe reentrant C skel */
+static char skelname_default[] = "flex_skel.m4";
+char *skelname = skelname_default;
+char *flex_include_path = DATAROOTDIR;
char *action_array;
int action_size, defs1_offset, prolog_offset, action_offset,
action_index;
char *infilename = NULL, *outfilename = NULL, *headerfilename = NULL;
-int did_outfilename;
+char *m4outfilename = NULL;
char *prefix, *yyclass, *extra_type = NULL;
int do_stdinit, use_stdout;
int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
@@ -105,12 +108,16 @@ 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;
+char *tablesfilename=0, *tablesname=0;
struct yytbl_writer tableswr;
+/* This is a flag to tell the internal lexer that it is parsing
+ * options in the --option=LIST string.
+ */
+bool parsing_option_string = false;
+
/* Make sure program_name is initialized so we don't crash if writing
* out an error message before getting the program name from argv[0].
*/
@@ -132,25 +139,25 @@ extern unsigned _stklen = 16384;
/* From scan.l */
extern FILE* yyout;
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+extern YY_BUFFER_STATE yy_scan_buffer(char *base, unsigned int size);
+extern int yylex_destroy(void);
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 = "]]" "[[[]]" "[[[]]" "[[";
+const char *escaped_qend = "]]" "[[]]]" "[[]]]" "[[";
/* 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 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;
+ int exit_status, child_status;
/* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The
* return value of setjmp, if non-zero, is the desired exit code PLUS ONE.
@@ -177,25 +184,11 @@ int flex_main (argc, argv)
}
return exit_status - 1;
}
-
flexinit (argc, argv);
readin ();
- ntod ();
-
- for (i = 1; i <= num_rules; ++i)
- if (!rule_useful[i] && i != default_rule)
- line_warning (_("rule cannot be matched"),
- rule_linenum[i]);
-
- if (spprdflt && !reject && rule_useful[default_rule])
- line_warning (_
- ("-s option given but default rule can be matched"),
- rule_linenum[default_rule]);
-
- /* Generate the C state transition tables from the DFA. */
- make_tables ();
+ generate_code();
/* Note, flexend does not return. It exits with its argument
* as status.
@@ -206,9 +199,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
@@ -222,9 +213,13 @@ int main (argc, argv)
return flex_main (argc, argv);
}
-/* check_options - check user-specified options */
+/* check_options - check user-specified options
+ * Sets some defaults where not options were given.
+ * Also sets M4 macro definitions for all options not already
+ * defined as an m4 macro.
+ */
-void check_options ()
+void check_options (void)
{
int i;
const char * m4 = NULL;
@@ -237,8 +232,7 @@ void check_options ()
flexerror (_("Can't use -f or -F with -l option"));
if (reentrant || bison_bridge_lval)
- flexerror (_
- ("Can't use --reentrant or --bison-bridge with -l option"));
+ flexerror (_("Can't use --reentrant or --bison-bridge with -l option"));
/* Don't rely on detecting use of yymore() and REJECT,
* just assume they'll be used.
@@ -250,60 +244,50 @@ void check_options ()
use_read = false;
}
+ if (interactive == unspecified)
+ interactive = !(fulltbl || fullspd);
-#if 0
- /* This makes no sense whatsoever. I'm removing it. */
- if (do_yylineno)
- /* This should really be "maintain_backup_tables = true" */
- reject_really_used = true;
-#endif
+ if (useecs == unspecified)
+ useecs = !(fulltbl || fullspd);
- if (csize == unspecified) {
- if ((fulltbl || fullspd) && !useecs)
- csize = DEFAULT_CSIZE;
- else
- csize = CSIZE;
- }
+ if (usemecs == unspecified)
+ usemecs = !(fulltbl || fullspd);
- if (interactive == unspecified) {
- if (fulltbl || fullspd)
- interactive = false;
- else
- interactive = true;
- }
+ if (use_read == unspecified)
+ use_read = (fulltbl || fullspd);
+
+ if (csize == unspecified)
+ csize = ((fulltbl || fullspd) && !useecs) ? DEFAULT_CSIZE : CSIZE;
if (fulltbl || fullspd) {
if (usemecs)
- flexerror (_
- ("-Cf/-CF and -Cm don't make sense together"));
+ flexerror (_("-Cf/-CF and -Cm don't make sense together"));
if (interactive)
flexerror (_("-Cf/-CF and -I are incompatible"));
if (lex_compat)
- flexerror (_
- ("-Cf/-CF are incompatible with lex-compatibility mode"));
+ flexerror (_("-Cf/-CF are incompatible with lex-compatibility mode"));
if (fulltbl && fullspd)
- flexerror (_
- ("-Cf and -CF are mutually exclusive"));
+ flexerror (_("-Cf and -CF are mutually exclusive"));
}
- if (C_plus_plus && fullspd)
- flexerror (_("Can't use -+ with -CF option"));
+ if (C_plus_plus) {
+ if (yytext_is_array) {
+ warn (_("%array incompatible with -+ option"));
+ yytext_is_array = false;
+ }
- if (C_plus_plus && yytext_is_array) {
- warn (_("%array incompatible with -+ option"));
- yytext_is_array = false;
+ if (reentrant)
+ flexerror (_("Options -+ and --reentrant are mutually exclusive."));
}
- if (C_plus_plus && (reentrant))
- flexerror (_("Options -+ and --reentrant are mutually exclusive."));
-
- if (C_plus_plus && bison_bridge_lval)
- flexerror (_("bison bridge not supported for the C++ scanner."));
-
+ else {
+ if (yyclass)
+ flexerror (_("%option yyclass only meaningful for C++ scanners"));
+ }
if (useecs) { /* Set up doubly-linked equivalence classes. */
@@ -328,19 +312,13 @@ 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);
+ if (extra_type)
+ buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEF", extra_type);
if (!use_stdout) {
FILE *prev_stdout;
- if (!did_outfilename) {
+ if (!outfilename) {
char *suffix;
if (C_plus_plus)
@@ -363,20 +341,26 @@ void check_options ()
}
- /* Setup the filter chain. */
- output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
- if ( !(m4 = getenv("M4")))
- m4 = M4;
- filter_create_ext(output_chain, m4, "-P", 0);
- filter_create_int(output_chain, filter_fix_linedirs, NULL);
+ /* Setup the filter chain. */
+ if (m4outfilename) {
+ output_chain = filter_create_ext(NULL, "/usr/bin/tee", m4outfilename, 0);
+ filter_create_int(output_chain, filter_tee_header, headerfilename);
+ } else {
+ output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
+ }
- /* For debugging, only run the requested number of filters. */
- if (preproc_level > 0) {
- filter_truncate(output_chain, preproc_level);
- filter_apply_chain(output_chain);
- }
- yyout = stdout;
+ if ( !(m4 = getenv("M4")))
+ m4 = M4;
+ filter_create_ext(output_chain, m4, "-P", 0);
+ filter_create_int(output_chain, filter_fix_linedirs, NULL);
+ filter_create_int(output_chain, filter_check_errors, NULL);
+ /* For debugging, only run the requested number of filters. */
+ if (preproc_level > 0) {
+ filter_truncate(output_chain, preproc_level);
+ filter_apply_chain(output_chain);
+ }
+ yyout = stdout;
/* always generate the tablesverify flag. */
buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0");
@@ -402,7 +386,9 @@ void check_options ()
snprintf (pname, nbytes, tablesfile_template, prefix);
}
- if ((tablesout = fopen (tablesfilename, "w")) == NULL)
+ buf_m4_define (&m4defs_buf, "M4_YY_TABLES_FILENAME", tablesfilename);
+
+ if ((tablesout = fopen (tablesfilename, "wb")) == NULL)
lerrsf (_("could not create %s"), tablesfilename);
if (pname)
free (pname);
@@ -414,37 +400,53 @@ void check_options ()
tablesname = (char *) calloc (nbytes, 1);
snprintf (tablesname, nbytes, "%stables", prefix);
yytbl_hdr_init (&hdr, flex_version, tablesname);
+ buf_m4_define (&m4defs_buf, "M4_YY_TABLES_NAME", tablesname);
if (yytbl_hdr_fwrite (&tableswr, &hdr) <= 0)
flexerror (_("could not write tables header"));
}
- if (skelname && (skelfile = fopen (skelname, "r")) == NULL)
- lerrsf (_("can't open skeleton file %s"), skelname);
-
- if (reentrant) {
- buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
- if (yytext_is_array)
- buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL);
+ if ( (skelfile = fopen (skelname, "r")) == NULL)
+ {
+ char skelpath[1024];
+ snprintf(skelpath,sizeof(skelpath),"%s/%s",flex_include_path,skelname);
+ if ( (skelfile = fopen (skelpath, "r")) == NULL)
+ {
+ /* No formatted flexerror(), so use snprintf() */
+ snprintf(skelpath,sizeof(skelpath),_("can't open skeleton file %s"), skelname);
+ flexerror ( skelpath );
+ }
}
- if ( bison_bridge_lval)
- buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL);
+ buf_m4_define(&m4defs_buf, "M4_FLEX_VERSION", flex_version);
+
+ if (C_plus_plus)
+ buf_m4_define (&m4defs_buf, "M4_YY_CPLUSPLUS", NULL);
- if ( bison_bridge_lloc)
- buf_m4_define (&m4defs_buf, "<M4_YY_BISON_LLOC>", NULL);
+ if (yyclass)
+ buf_m4_define( &m4defs_buf, "M4_YY_CLASS",yyclass);
- buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
+/* Was BUG here? M4_YY_TEXT_IS_ARRAY was set ONLY if reentrant. */
+ if (reentrant)
+ buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
- if (did_outfilename)
- line_directive_out (stdout, 0);
+ if (yytext_is_array)
+ buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL);
+
+ if (bison_bridge_lval)
+ buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL);
+
+ if (bison_bridge_lloc)
+ buf_m4_define (&m4defs_buf, "M4_YY_BISON_LLOC", NULL);
+
+ buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
if (do_yylineno)
buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL);
/* Create the alignment type. */
- buf_strdefine (&userdef_buf, "YY_INT_ALIGNED",
- long_align ? "long int" : "short int");
+ buf_m4_define (&m4defs_buf, "M4_YY_INT_ALIGNED",
+ long_align ? "flex_int32_t" : "flex_int16_t");
/* Define the start condition macros. */
{
@@ -461,29 +463,10 @@ void check_options ()
buf_strappend(&tmpbuf, str);
free(str);
}
- buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts);
+ buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", (char*)tmpbuf.elts);
buf_destroy(&tmpbuf);
}
- /* This is where we begin writing to the file. */
-
- /* Dump the %top code. */
- if( top_buf.elts)
- outn((char*) top_buf.elts);
-
- /* Dump the m4 definitions. */
- buf_print_strings(&m4defs_buf, stdout);
- 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");
-
- /* Dump the user defined preproc directives. */
- if (userdef_buf.elts)
- outn ((char *) (userdef_buf.elts));
-
- skelout ();
- /* %% [1.0] */
}
/* flexend - terminate flex
@@ -492,9 +475,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;
@@ -512,193 +493,6 @@ void flexend (exit_status)
skelname);
}
-#if 0
- fprintf (header_out,
- "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
- fprintf (header_out,
- "/* Beware! Start conditions are not prefixed. */\n");
-
- /* Special case for "INITIAL" */
- fprintf (header_out,
- "#undef INITIAL\n#define INITIAL 0\n");
- for (i = 2; i <= lastsc; i++)
- fprintf (header_out, "#define %s %d\n", scname[i], i - 1);
- fprintf (header_out,
- "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n");
-
- /* Kill ALL flex-related macros. This is so the user
- * can #include more than one generated header file. */
- fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n");
- fprintf (header_out,
- "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n");
-
- {
- const char * undef_list[] = {
-
- "BEGIN",
- "ECHO",
- "EOB_ACT_CONTINUE_SCAN",
- "EOB_ACT_END_OF_FILE",
- "EOB_ACT_LAST_MATCH",
- "FLEX_SCANNER",
- "FLEX_STD",
- "REJECT",
- "YYFARGS0",
- "YYFARGS1",
- "YYFARGS2",
- "YYFARGS3",
- "YYLMAX",
- "YYSTATE",
- "YY_AT_BOL",
- "YY_BREAK",
- "YY_BUFFER_EOF_PENDING",
- "YY_BUFFER_NEW",
- "YY_BUFFER_NORMAL",
- "YY_BUF_SIZE",
- "M4_YY_CALL_LAST_ARG",
- "M4_YY_CALL_ONLY_ARG",
- "YY_CURRENT_BUFFER",
- "YY_DECL",
- "M4_YY_DECL_LAST_ARG",
- "M4_YY_DEF_LAST_ARG",
- "M4_YY_DEF_ONLY_ARG",
- "YY_DO_BEFORE_ACTION",
- "YY_END_OF_BUFFER",
- "YY_END_OF_BUFFER_CHAR",
- "YY_EXIT_FAILURE",
- "YY_EXTRA_TYPE",
- "YY_FATAL_ERROR",
- "YY_FLEX_DEFINED_ECHO",
- "YY_FLEX_LEX_COMPAT",
- "YY_FLEX_MAJOR_VERSION",
- "YY_FLEX_MINOR_VERSION",
- "YY_FLEX_SUBMINOR_VERSION",
- "YY_FLUSH_BUFFER",
- "YY_G",
- "YY_INPUT",
- "YY_INTERACTIVE",
- "YY_INT_ALIGNED",
- "YY_LAST_ARG",
- "YY_LESS_LINENO",
- "YY_LEX_ARGS",
- "YY_LEX_DECLARATION",
- "YY_LEX_PROTO",
- "YY_MAIN",
- "YY_MORE_ADJ",
- "YY_NEED_STRLEN",
- "YY_NEW_FILE",
- "YY_NULL",
- "YY_NUM_RULES",
- "YY_ONLY_ARG",
- "YY_PARAMS",
- "YY_PROTO",
- "M4_YY_PROTO_LAST_ARG",
- "M4_YY_PROTO_ONLY_ARG void",
- "YY_READ_BUF_SIZE",
- "YY_REENTRANT",
- "YY_RESTORE_YY_MORE_OFFSET",
- "YY_RULE_SETUP",
- "YY_SC_TO_UI",
- "YY_SKIP_YYWRAP",
- "YY_START",
- "YY_START_STACK_INCR",
- "YY_STATE_EOF",
- "YY_STDINIT",
- "YY_TRAILING_HEAD_MASK",
- "YY_TRAILING_MASK",
- "YY_USER_ACTION",
- "YY_USE_CONST",
- "YY_USE_PROTOS",
- "unput",
- "yyTABLES_NAME",
- "yy_create_buffer",
- "yy_delete_buffer",
- "yy_flex_debug",
- "yy_flush_buffer",
- "yy_init_buffer",
- "yy_load_buffer_state",
- "yy_new_buffer",
- "yy_scan_buffer",
- "yy_scan_bytes",
- "yy_scan_string",
- "yy_set_bol",
- "yy_set_interactive",
- "yy_switch_to_buffer",
- "yypush_buffer_state",
- "yypop_buffer_state",
- "yyensure_buffer_stack",
- "yyalloc",
- "yyconst",
- "yyextra",
- "yyfree",
- "yyget_debug",
- "yyget_extra",
- "yyget_in",
- "yyget_leng",
- "yyget_lineno",
- "yyget_lloc",
- "yyget_lval",
- "yyget_out",
- "yyget_text",
- "yyin",
- "yyleng",
- "yyless",
- "yylex",
- "yylex_destroy",
- "yylex_init",
- "yylex_init_extra",
- "yylineno",
- "yylloc",
- "yylval",
- "yymore",
- "yyout",
- "yyrealloc",
- "yyrestart",
- "yyset_debug",
- "yyset_extra",
- "yyset_in",
- "yyset_lineno",
- "yyset_lloc",
- "yyset_lval",
- "yyset_out",
- "yytables_destroy",
- "yytables_fload",
- "yyterminate",
- "yytext",
- "yytext_ptr",
- "yywrap",
-
- /* must be null-terminated */
- NULL};
-
-
- for (i=0; undef_list[i] != NULL; i++)
- fprintf (header_out, "#undef %s\n", undef_list[i]);
- }
-
- /* undef any of the auto-generated symbols. */
- for (i = 0; i < defs_buf.nelts; i++) {
-
- /* don't undef start conditions */
- if (sclookup (((char **) defs_buf.elts)[i]) > 0)
- continue;
- fprintf (header_out, "#undef %s\n",
- ((char **) defs_buf.elts)[i]);
- }
-
- fprintf (header_out,
- "#endif /* !YY_HEADER_NO_UNDEFS */\n");
- fprintf (header_out, "\n");
- fprintf (header_out, "#undef %sIN_HEADER\n", prefix);
- fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix);
-
- if (ferror (header_out))
- lerrsf (_("error creating header file %s"),
- headerfilename);
- fflush (header_out);
- fclose (header_out);
-#endif
-
if (exit_status != 0 && outfile_created) {
if (ferror (stdout))
lerrsf (_("error writing output file %s"),
@@ -719,8 +513,7 @@ void flexend (exit_status)
fprintf (backing_up_file, _("No backing up.\n"));
else if (fullspd || fulltbl)
fprintf (backing_up_file,
- _
- ("%d backing up (non-accepting) states.\n"),
+ _("%d backing up (non-accepting) states.\n"),
num_backing_up);
else
fprintf (backing_up_file,
@@ -807,10 +600,10 @@ void flexend (exit_status)
if (use_read)
putc ('r', stderr);
- if (did_outfilename)
+ if (outfilename)
fprintf (stderr, " -o%s", outfilename);
- if (skelname)
+ if (skelname != skelname_default)
fprintf (stderr, " -S%s", skelname);
if (strcmp (prefix, "yy"))
@@ -830,13 +623,11 @@ void flexend (exit_status)
fprintf (stderr, _(" No backing up\n"));
else if (fullspd || fulltbl)
fprintf (stderr,
- _
- (" %d backing-up (non-accepting) states\n"),
+ _(" %d backing-up (non-accepting) states\n"),
num_backing_up);
else
fprintf (stderr,
- _
- (" Compressed tables always back-up\n"));
+ _(" Compressed tables always back-up\n"));
if (bol_needed)
fprintf (stderr,
@@ -845,16 +636,14 @@ void flexend (exit_status)
fprintf (stderr, _(" %d/%d start conditions\n"), lastsc,
current_max_scs);
fprintf (stderr,
- _
- (" %d epsilon states, %d double epsilon states\n"),
+ _(" %d epsilon states, %d double epsilon states\n"),
numeps, eps2);
if (lastccl == 0)
fprintf (stderr, _(" no character classes\n"));
else
fprintf (stderr,
- _
- (" %d/%d character classes needed %d/%d words of storage, %d reused\n"),
+ _(" %d/%d character classes needed %d/%d words of storage, %d reused\n"),
lastccl, current_maxccls,
cclmap[lastccl] + ccllen[lastccl],
current_max_ccl_tbl_size, cclreuse);
@@ -878,12 +667,10 @@ void flexend (exit_status)
_(" %d/%d base-def entries created\n"),
lastdfa + numtemps, current_max_dfas);
fprintf (stderr,
- _
- (" %d/%d (peak %d) nxt-chk entries created\n"),
+ _(" %d/%d (peak %d) nxt-chk entries created\n"),
tblend, current_max_xpairs, peakpairs);
fprintf (stderr,
- _
- (" %d/%d (peak %d) template nxt-chk entries created\n"),
+ _(" %d/%d (peak %d) template nxt-chk entries created\n"),
numtemps * nummecs,
current_max_template_xpairs,
numtemps * numecs);
@@ -899,22 +686,19 @@ void flexend (exit_status)
if (useecs) {
tblsiz = tblsiz + csize;
fprintf (stderr,
- _
- (" %d/%d equivalence classes created\n"),
+ _(" %d/%d equivalence classes created\n"),
numecs, csize);
}
if (usemecs) {
tblsiz = tblsiz + numecs;
fprintf (stderr,
- _
- (" %d/%d meta-equivalence classes created\n"),
+ _(" %d/%d meta-equivalence classes created\n"),
nummecs, csize);
}
fprintf (stderr,
- _
- (" %d (%d saved) hash collisions, %d DFAs equal\n"),
+ _(" %d (%d saved) hash collisions, %d DFAs equal\n"),
hshcol, hshsave, dfaeql);
fprintf (stderr, _(" %d sets of reallocations needed\n"),
num_reallocs);
@@ -928,13 +712,11 @@ 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;
+ int i, rv, optind;
char *arg;
- scanopt_t sopt;
+ scanopt_t *sopt;
printstats = syntaxerror = trace = spprdflt = false;
lex_compat = posix_compat = C_plus_plus = backing_up_report =
@@ -944,20 +726,17 @@ void flexinit (argc, argv)
do_yylineno = yytext_is_array = in_rule = reject = do_stdinit =
false;
yymore_really_used = reject_really_used = unspecified;
- interactive = csize = unspecified;
- do_yywrap = gen_line_dirs = usemecs = useecs = true;
+ interactive = csize = usemecs = useecs = use_read = unspecified;
+ do_yywrap = gen_line_dirs = true;
reentrant = bison_bridge_lval = bison_bridge_lloc = false;
performance_report = 0;
- did_outfilename = 0;
prefix = "yy";
yyclass = 0;
- use_read = use_stdout = false;
+ use_read = unspecified;
+ use_stdout = false;
tablesext = tablesverify = false;
gentables = true;
tablesfilename = tablesname = NULL;
- ansi_func_defs = ansi_func_protos = true;
-
- sawcmpflag = false;
/* Initialize dynamic array for holding the rule actions. */
action_size = 2048; /* default size of action array in bytes */
@@ -969,21 +748,16 @@ void flexinit (argc, argv)
buf_init (&userdef_buf, sizeof (char)); /* one long string */
buf_init (&defs_buf, sizeof (char *)); /* list of strings */
buf_init (&yydmap_buf, sizeof (char)); /* one long string */
- buf_init (&top_buf, sizeof (char)); /* one long string */
-
- {
- const char * m4defs_init_str[] = {"m4_changequote\n",
- "m4_changequote([[, ]])\n"};
- buf_init (&m4defs_buf, sizeof (char *));
- buf_append (&m4defs_buf, &m4defs_init_str, 2);
- }
+ buf_init (&top_buf, sizeof (char)); /* one long string */
+ buf_init (&m4defs_buf, sizeof (char *));/* list of strings */
sf_init ();
+ if ((arg = getenv("FLEX_INCLUDE_PATH")) != NULL) flex_include_path = arg; /* FIXME? */
+
/* initialize regex lib */
flex_init_regex();
- /* Enable C++ if program name ends with '+'. */
program_name = basename2 (argv[0], 0);
if (program_name[0] != '\0' &&
@@ -1004,8 +778,7 @@ void flexinit (argc, argv)
if (rv < 0) {
/* Scanopt has already printed an option-specific error message. */
fprintf (stderr,
- _
- ("Try `%s --help' for more information.\n"),
+ _("Try `%s --help' for more information.\n"),
program_name);
FLEX_EXIT (1);
}
@@ -1015,6 +788,10 @@ void flexinit (argc, argv)
C_plus_plus = true;
break;
+ case OPT_C_SCANNER:
+ C_plus_plus = false;
+ break;
+
case OPT_BATCH:
interactive = false;
break;
@@ -1027,13 +804,6 @@ void flexinit (argc, argv)
break;
case OPT_COMPRESSION:
- if (!sawcmpflag) {
- useecs = false;
- usemecs = false;
- fulltbl = false;
- sawcmpflag = true;
- }
-
for (i = 0; arg && arg[i] != '\0'; i++)
switch (arg[i]) {
case 'a':
@@ -1061,8 +831,7 @@ void flexinit (argc, argv)
break;
default:
- lerrif (_
- ("unknown -C option '%c'"),
+ lerrif (_("unknown -C option '%c'"),
(int) arg[i]);
break;
}
@@ -1077,19 +846,21 @@ void flexinit (argc, argv)
break;
case OPT_FULL:
- useecs = usemecs = false;
- use_read = fulltbl = true;
+ fulltbl = true;
break;
case OPT_FAST:
- useecs = usemecs = false;
- use_read = fullspd = true;
+ fullspd = true;
break;
case OPT_HELP:
usage ();
FLEX_EXIT (0);
+ case OPT_INCLUDE_PATH:
+ flex_include_path = arg;
+ break;
+
case OPT_INTERACTIVE:
interactive = true;
break;
@@ -1106,17 +877,21 @@ void flexinit (argc, argv)
posix_compat = true;
break;
- case OPT_PREPROC_LEVEL:
- preproc_level = strtol(arg,NULL,0);
- break;
+ case OPT_PREPROC_LEVEL:
+ preproc_level = strtol(arg,NULL,0);
+ break;
+
+ case OPT_M4OUTFILE:
+ m4outfilename = arg;
+ break;
case OPT_MAIN:
- buf_strdefine (&userdef_buf, "YY_MAIN", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_MAIN",0);
do_yywrap = false;
break;
case OPT_NO_MAIN:
- buf_strdefine (&userdef_buf, "YY_MAIN", "0");
+ buf_m4_undefine( &m4defs_buf, "M4_YY_MAIN");
break;
case OPT_NO_LINE:
@@ -1125,7 +900,6 @@ void flexinit (argc, argv)
case OPT_OUTFILE:
outfilename = arg;
- did_outfilename = 1;
break;
case OPT_PREFIX:
@@ -1169,8 +943,7 @@ void flexinit (argc, argv)
break;
case OPT_NO_UNISTD_H:
- //buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
break;
case OPT_TABLES_FILE:
@@ -1198,6 +971,10 @@ void flexinit (argc, argv)
nowarn = false;
break;
+ case OPT_NO_VERBOSE:
+ printstats = false;
+ break;
+
case OPT_NO_WARN:
nowarn = true;
break;
@@ -1223,7 +1000,7 @@ void flexinit (argc, argv)
break;
case OPT_NEVER_INTERACTIVE:
- buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
break;
case OPT_ARRAY:
@@ -1284,8 +1061,7 @@ void flexinit (argc, argv)
break;
case OPT_STACK:
- //buf_strdefine (&userdef_buf, "YY_STACK_USED", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0);
break;
case OPT_STDINIT:
@@ -1332,99 +1108,92 @@ 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_DEFS:
+ warn (_("%option noansi-definitions is obsolete"));
+ break;
- case OPT_NO_ANSI_FUNC_PROTOS:
- ansi_func_protos = false;
- break;
+ case OPT_NO_ANSI_FUNC_PROTOS:
+ warn (_("%option noansi-prototypes is obsolete"));
+ 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);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0);
break;
case OPT_NO_YY_POP_STATE:
- //buf_strdefine (&userdef_buf, "YY_NO_POP_STATE", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0);
break;
case OPT_NO_YY_TOP_STATE:
- //buf_strdefine (&userdef_buf, "YY_NO_TOP_STATE", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0);
break;
case OPT_NO_UNPUT:
- //buf_strdefine (&userdef_buf, "YY_NO_UNPUT", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0);
break;
case OPT_NO_YY_SCAN_BUFFER:
- //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BUFFER", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0);
break;
case OPT_NO_YY_SCAN_BYTES:
- //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BYTES", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0);
break;
case OPT_NO_YY_SCAN_STRING:
- //buf_strdefine (&userdef_buf, "YY_NO_SCAN_STRING", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0);
break;
case OPT_NO_YYGET_EXTRA:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_EXTRA", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0);
break;
case OPT_NO_YYSET_EXTRA:
- //buf_strdefine (&userdef_buf, "YY_NO_SET_EXTRA", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0);
break;
case OPT_NO_YYGET_LENG:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_LENG", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0);
break;
case OPT_NO_YYGET_TEXT:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_TEXT", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0);
break;
case OPT_NO_YYGET_LINENO:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_LINENO", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0);
break;
case OPT_NO_YYSET_LINENO:
- //buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0);
break;
case OPT_NO_YYGET_IN:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0);
break;
case OPT_NO_YYSET_IN:
- //buf_strdefine (&userdef_buf, "YY_NO_SET_IN", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0);
break;
case OPT_NO_YYGET_OUT:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_OUT", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0);
break;
case OPT_NO_YYSET_OUT:
- //buf_strdefine (&userdef_buf, "YY_NO_SET_OUT", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0);
break;
case OPT_NO_YYGET_LVAL:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_LVAL", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0);
break;
case OPT_NO_YYSET_LVAL:
- //buf_strdefine (&userdef_buf, "YY_NO_SET_LVAL", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0);
break;
case OPT_NO_YYGET_LLOC:
- //buf_strdefine (&userdef_buf, "YY_NO_GET_LLOC", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0);
break;
case OPT_NO_YYSET_LLOC:
- //buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
break;
-
+ case OPT_OPTION_LIST:
+ {
+ struct yy_buffer_state *buf;
+ size_t len = strlen(arg)+12;
+ char *options = (char*)malloc(len);
+ parsing_option_string = true;
+ snprintf(options,len,"%%option %s\n%c%c",arg,0,0);
+ buf = yy_scan_buffer(options,len);
+ yyparse ();
+ if (syntaxerror) flexend(1);
+ free(options);
+ yylex_destroy();
+ parsing_option_string = false;
+ break;
+ }
} /* switch */
} /* while scanopt() */
@@ -1456,14 +1225,10 @@ void flexinit (argc, argv)
/* readin - read in the rules section of the input file(s) */
+/* Also set most M4 flags not done in check_options(). */
-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;";
-
- line_directive_out ((FILE *) 0, 1);
if (yyparse ()) {
pinpoint_message (_("fatal parse error"));
@@ -1497,61 +1262,49 @@ void readin ()
if (backing_up_report) {
backing_up_file = fopen (backing_name, "w");
if (backing_up_file == NULL)
- lerrsf (_
- ("could not create backing-up info file %s"),
+ lerrsf (_("could not create backing-up info file %s"),
backing_name);
}
else
backing_up_file = NULL;
- if (yymore_really_used == true)
- yymore_used = true;
- else if (yymore_really_used == false)
- yymore_used = false;
+ if (reject_really_used != unspecified)
+ reject = reject_really_used;
- if (reject_really_used == true)
- reject = true;
- else if (reject_really_used == false)
- reject = false;
+ if (yymore_really_used != unspecified)
+ yymore_used = yymore_really_used;
if (performance_report > 0) {
if (lex_compat) {
fprintf (stderr,
- _
- ("-l AT&T lex compatibility option entails a large performance penalty\n"));
+ _("-l AT&T lex compatibility option entails a large performance penalty\n"));
fprintf (stderr,
- _
- (" and may be the actual source of other reported performance penalties\n"));
+ _(" and may be the actual source of other reported performance penalties\n"));
}
else if (do_yylineno) {
fprintf (stderr,
- _
- ("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n"));
+ _("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n"));
}
if (performance_report > 1) {
if (interactive)
fprintf (stderr,
- _
- ("-I (interactive) entails a minor performance penalty\n"));
+ _("-I (interactive) entails a minor performance penalty\n"));
if (yymore_used)
fprintf (stderr,
- _
- ("yymore() entails a minor performance penalty\n"));
+ _("yymore() entails a minor performance penalty\n"));
}
if (reject)
fprintf (stderr,
- _
- ("REJECT entails a large performance penalty\n"));
+ _("REJECT entails a large performance penalty\n"));
if (variable_trailing_context_rules)
fprintf (stderr,
- _
- ("Variable trailing context rules entail a large performance penalty\n"));
+ _("Variable trailing context rules entail a large performance penalty\n"));
}
if (reject)
@@ -1562,137 +1315,12 @@ void readin ()
if ((fulltbl || fullspd) && reject) {
if (real_reject)
- flexerror (_
- ("REJECT cannot be used with -f or -F"));
+ flexerror (_("REJECT cannot be used with -f or -F"));
else if (do_yylineno)
- flexerror (_
- ("%option yylineno cannot be used with REJECT"));
+ flexerror (_("%option yylineno cannot be used with REJECT"));
else
- flexerror (_
- ("variable trailing context rules cannot be used with -f or -F"));
- }
-
- if (reject){
- out_m4_define( "M4_YY_USES_REJECT", NULL);
- //outn ("\n#define YY_USES_REJECT");
- }
- if (!do_yywrap) {
- if (!C_plus_plus)
- if (reentrant)
- outn ("\n#define yywrap(yyscanner) 1");
- else
- outn ("\n#define yywrap() 1");
- outn ("#define YY_SKIP_YYWRAP");
- }
-
- if (ddebug)
- outn ("\n#define FLEX_DEBUG");
-
- OUT_BEGIN_CODE ();
- if (csize == 256)
- outn ("typedef unsigned char YY_CHAR;");
- else
- outn ("typedef char YY_CHAR;");
- OUT_END_CODE ();
-
- if (C_plus_plus) {
- outn ("#define yytext_ptr yytext");
-
- if (interactive)
- outn ("#define YY_INTERACTIVE");
- }
-
- else {
- OUT_BEGIN_CODE ();
- /* In reentrant scanner, stdinit is handled in flex.skl. */
- if (do_stdinit) {
- if (reentrant){
- outn ("#ifdef VMS");
- outn ("#ifdef __VMS_POSIX");
- outn ("#define YY_STDINIT");
- outn ("#endif");
- outn ("#else");
- outn ("#define YY_STDINIT");
- outn ("#endif");
- }
-
- outn ("#ifdef VMS");
- outn ("#ifndef __VMS_POSIX");
- outn (yy_nostdinit);
- outn ("#else");
- outn (yy_stdinit);
- outn ("#endif");
- outn ("#else");
- outn (yy_stdinit);
- outn ("#endif");
- }
-
- else {
- if(!reentrant)
- outn (yy_nostdinit);
- }
- OUT_END_CODE ();
- }
-
- OUT_BEGIN_CODE ();
- if (fullspd)
- outn ("typedef yyconst struct yy_trans_info *yy_state_type;");
- else if (!C_plus_plus)
- outn ("typedef int yy_state_type;");
- OUT_END_CODE ();
-
- if (lex_compat)
- outn ("#define YY_FLEX_LEX_COMPAT");
-
- if (!C_plus_plus && !reentrant) {
- outn ("extern int yylineno;");
- OUT_BEGIN_CODE ();
- outn ("int yylineno = 1;");
- OUT_END_CODE ();
- }
-
- if (C_plus_plus) {
- outn ("\n#include <FlexLexer.h>");
-
- if (!do_yywrap) {
- outn("\nint yyFlexLexer::yywrap() { return 1; }");
- }
-
- if (yyclass) {
- outn ("int yyFlexLexer::yylex()");
- outn ("\t{");
- outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );");
- outn ("\treturn 0;");
- outn ("\t}");
-
- out_str ("\n#define YY_DECL int %s::yylex()\n",
- yyclass);
- }
- }
-
- else {
-
- /* Watch out: yytext_ptr is a variable when yytext is an array,
- * but it's a macro when yytext is a pointer.
- */
- if (yytext_is_array) {
- if (!reentrant)
- outn ("extern char yytext[];\n");
- }
- else {
- if (reentrant) {
- outn ("#define yytext_ptr yytext_r");
- }
- else {
- outn ("extern char *yytext;");
- outn ("#define yytext_ptr yytext");
- }
- }
-
- if (yyclass)
- flexerror (_
- ("%option yyclass only meaningful for C++ scanners"));
+ flexerror (_("variable trailing context rules cannot be used with -f or -F"));
}
if (useecs)
@@ -1711,7 +1339,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;
@@ -1771,9 +1399,7 @@ void set_up_initial_allocations ()
/* 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 */
+static char *basename2 (char *path, int strip_ext /* boolean */)
{
char *b, *e = 0;
@@ -1789,21 +1415,22 @@ static char *basename2 (path, strip_ext)
return b;
}
-void usage ()
+void usage (void)
{
FILE *f = stdout;
- if (!did_outfilename) {
+ if (!outfilename) {
snprintf (outfile_path, sizeof(outfile_path), outfile_template,
prefix, C_plus_plus ? "cc" : "c");
outfilename = outfile_path;
}
- fprintf (f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name);
- fprintf (f,
- _
- ("Generates programs that perform pattern-matching on text.\n"
- "\n" "Table Compression:\n"
+ fprintf (f,_("Usage: %s [OPTIONS] [FILE]...\n"), program_name);
+ fprintf (f,_(
+ "Generates programs that perform pattern-matching on text.\n"
+ "\n"));
+ fprintf (f,_(
+ "Table Compression:\n"
" -Ca, --align trade off larger tables for better memory alignment\n"
" -Ce, --ecs construct equivalence classes\n"
" -Cf do not compress tables; use -f representation\n"
@@ -1813,7 +1440,9 @@ void usage ()
" -f, --full generate fast, large scanner. Same as -Cfr\n"
" -F, --fast use alternate table representation. Same as -CFr\n"
" -Cem default compression (same as --ecs --meta-ecs)\n"
- "\n" "Debugging:\n"
+ "\n"));
+ fprintf (f,_(
+ "Debugging:\n"
" -d, --debug enable debug mode in scanner\n"
" -b, --backup write backing-up information to %s\n"
" -p, --perf-report write performance report to stderr\n"
@@ -1821,13 +1450,20 @@ void usage ()
" -T, --trace %s should run in trace mode\n"
" -w, --nowarn do not generate warnings\n"
" -v, --verbose write summary of scanner statistics to stdout\n"
- "\n" "Files:\n"
+ " -n not verbose (default; opposite of --verbose)\n"
+ "\n"),
+ backing_name, program_name);
+ fprintf (f,_(
+ "Files:\n"
" -o, --outfile=FILE specify output filename\n"
" -S, --skel=FILE specify skeleton file\n"
" -t, --stdout write scanner on stdout instead of %s\n"
" --yyclass=NAME name of C++ class\n"
" --header-file=FILE create a C header file in addition to the scanner\n"
- " --tables-file[=FILE] write tables to FILE\n" "\n"
+ " --tables-file[=FILE] write tables to FILE\n"
+ "\n"),
+ outfile_path);
+ fprintf (f,_(
"Scanner behavior:\n"
" -7, --7bit generate 7-bit scanner\n"
" -8, --8bit generate 8-bit scanner\n"
@@ -1837,8 +1473,11 @@ void usage ()
" -X, --posix-compat maximal compatibility with POSIX lex\n"
" -I, --interactive generate interactive scanner (opposite of -B)\n"
" --yylineno track line count in yylineno\n"
- "\n" "Generated code:\n"
+ "\n"));
+ fprintf (f,_(
+ "Generated code:\n"
" -+, --c++ generate C++ scanner class\n"
+ " -c generate output in C (the default)\n"
" -Dmacro[=defn] #define macro defn (default defn is '1')\n"
" -L, --noline suppress #line directives in scanner\n"
" -P, --prefix=STRING use STRING as prefix instead of \"yy\"\n"
@@ -1846,16 +1485,13 @@ 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"
- " -c do-nothing POSIX option\n"
- " -n do-nothing POSIX option\n"
+ "\n"));
+ fprintf (f,_("Miscellaneous:\n"
" -?\n"
" -h, --help produce this help message\n"
" -V, --version report %s version\n"),
- backing_name, program_name, outfile_path, program_name);
+ program_name);
}