mirror of
https://github.com/westes/flex.git
synced 2026-01-26 15:39:06 +00:00
Clean up various sporadic symbol definitions that weren't going through ctrl.
Includes handling of --nounistd, --always_interactive, --never_interactive, --stack, their corresponding lexer items, and and noinput. An unavoidable side effect is that the place where "#define YY_NO_INPUT 1" is inserted, if it's inserted. has to move because it's done by a different route - m4 expansion rather than the action_define function (which is now gone - this was the last use). I have put the new insertion point just iin time for the first reference to the macro. Otherwise the only diffs in generarted test code are symbol definitions becoming visible. #56 in the retargeting patch series
This commit is contained in:
parent
7e77d8f475
commit
0fc45ce97c
@ -1219,6 +1219,8 @@ static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG);
|
||||
static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG);
|
||||
#endif
|
||||
|
||||
m4_ifdef([[M4_MODE_NO_INPUT]], [[#define YY_NO_INPUT 1]])
|
||||
|
||||
#ifndef YY_NO_INPUT
|
||||
%if-c-only Standard (non-C++) definition
|
||||
%not-for-header
|
||||
|
||||
@ -356,6 +356,7 @@ extern struct flex_backend_t cpp_backend;
|
||||
* If it;s in this structure, it has a corresponding m4 symbol.
|
||||
*/
|
||||
struct ctrl_bundle_t {
|
||||
bool always_interactive;// always use cheacter-by-character input
|
||||
FILE *backing_up_file; // file to summarize backing-up states to
|
||||
bool bison_bridge_lval; // (--bison-bridge), bison pure calling convention.
|
||||
bool bison_bridge_lloc; // (--bison-locations), bison yylloc.
|
||||
@ -371,18 +372,22 @@ struct ctrl_bundle_t {
|
||||
bool fullspd; // (-F flag) use Jacobson method of table representation
|
||||
bool fulltbl; // (-Cf flag) don't compress the DFA state table
|
||||
bool gen_line_dirs; // (no -L flag) generate #line directives
|
||||
trit interactive; // (-I) generate an interactive scanner
|
||||
trit interactive; // (-I) generate an interactive scanner
|
||||
bool never_interactive; // always use buffered input, don't check for tty/
|
||||
bool lex_compat; // (-l), maximize compatibility with AT&T lex
|
||||
bool long_align; // (-Ca flag), favor long-word alignment for speed
|
||||
bool no_input; // Suppress use of imnput()
|
||||
bool no_unistd; // suppress inclusion of unistd.h
|
||||
bool posix_compat; // (-X) maximize compatibility with POSIX lex
|
||||
char *prefix; // prefix for externally visible names, default "yy"
|
||||
bool reentrant; // if true (-R), generate a reentrant C scanner
|
||||
bool stack_used; // Enable use of start-condition stacks
|
||||
bool spprdflt; // (-s) suppress the default rule
|
||||
bool useecs; // (-Ce flag) use equivalence classes
|
||||
bool usemecs; // (-Cm flag), use meta-equivalence classes
|
||||
bool use_read; // (-f, -F, or -Cr) use read() for scanner input
|
||||
// otherwise, use fread().
|
||||
char *yyclass; // yyFlexLexer subclass to use for YY_DECL
|
||||
char *yyclass; // yyFlexLexer subclass to use for YY_DECL
|
||||
bool yytext_is_array; // if true (i.e., %array directive), then declare
|
||||
// yytext as array instead of a character pointer.
|
||||
// Nice and inefficient.
|
||||
@ -851,9 +856,6 @@ extern void usage(void);
|
||||
|
||||
/* from file misc.c */
|
||||
|
||||
/* Add a #define to the action file. */
|
||||
extern void action_define(const char *defname, int value);
|
||||
|
||||
/* Add the given text to the stored actions. */
|
||||
extern void add_action(const char *new_text);
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ static void geneoltbl (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[[");
|
||||
outn ("m4_ifdef( [[M4_MODE_YYLINENO]],[[");
|
||||
backend->comment ("Table of booleans, true if rule could match eol.\n");
|
||||
footprint += backend->geneoltbl(num_rules + 1);
|
||||
|
||||
|
||||
23
src/main.c
23
src/main.c
@ -868,7 +868,7 @@ void flexinit (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case OPT_NO_UNISTD_H:
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
|
||||
ctrl.no_unistd = true;
|
||||
break;
|
||||
|
||||
case OPT_TABLES_FILE:
|
||||
@ -917,11 +917,11 @@ void flexinit (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case OPT_ALWAYS_INTERACTIVE:
|
||||
buf_m4_define (&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0);
|
||||
ctrl.always_interactive = true;
|
||||
break;
|
||||
|
||||
case OPT_NEVER_INTERACTIVE:
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
|
||||
ctrl.never_interactive = true;
|
||||
break;
|
||||
|
||||
case OPT_ARRAY:
|
||||
@ -974,7 +974,7 @@ void flexinit (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case OPT_STACK:
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0);
|
||||
ctrl.stack_used = true;
|
||||
break;
|
||||
|
||||
case OPT_STDINIT:
|
||||
@ -1496,7 +1496,10 @@ void readin (void)
|
||||
visible_define ( "M4_MODE_TABLESEXT");
|
||||
if (ctrl.prefix != NULL)
|
||||
visible_define_str ( "M4_MODE_PREFIX", ctrl.prefix);
|
||||
|
||||
|
||||
if (ctrl.no_input)
|
||||
visible_define("M4_MODE_NO_INPUT");
|
||||
|
||||
if (ctrl.no_yy_push_state)
|
||||
visible_define("M4_YY_NO_PUSH_STATE");
|
||||
if (ctrl.no_yy_pop_state)
|
||||
@ -1554,6 +1557,16 @@ void readin (void)
|
||||
if (ctrl.no_set_debug)
|
||||
visible_define("M4_YY_NO_SET_DEBUG");
|
||||
|
||||
if (ctrl.no_unistd)
|
||||
visible_define("M4_YY_NO_UNISTD_H");
|
||||
|
||||
if (ctrl.always_interactive)
|
||||
visible_define("M4_YY_ALWAYS_INTERACTIVE");
|
||||
if (ctrl.never_interactive)
|
||||
visible_define("M4_YY_NEVER_INTERACTIVE");
|
||||
if (ctrl.stack_used)
|
||||
visible_define("M4_YY_STACK_USED");
|
||||
|
||||
backend->comment("m4 controls end\n");
|
||||
out ("\n");
|
||||
|
||||
|
||||
23
src/misc.c
23
src/misc.c
@ -88,29 +88,6 @@ static void sko_pop(bool* dc)
|
||||
flex_die("popped too many times in skeleton.");
|
||||
}
|
||||
|
||||
/* Append a constant declaration to the running buffer. */
|
||||
void action_define (const char *defname, int value)
|
||||
{
|
||||
char buf[MAXLINE];
|
||||
char *cpy;
|
||||
|
||||
if ((int) strlen (defname) > MAXLINE / 2) {
|
||||
format_pinpoint_message (_
|
||||
("name \"%s\" ridiculously long"),
|
||||
defname);
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf (buf, sizeof(buf), backend->int_define_fmt, defname, value);
|
||||
add_action (buf);
|
||||
|
||||
/* track definitions so we can naybe undef them when we're done;
|
||||
* this is only ever likely to work with the cpp back end.
|
||||
*/
|
||||
cpy = xstrdup(defname);
|
||||
buf_append (&defs_buf, &cpy, 1);
|
||||
}
|
||||
|
||||
/* Append "new_text" to the running buffer. */
|
||||
void add_action (const char *new_text)
|
||||
{
|
||||
|
||||
26
src/scan.l
26
src/scan.l
@ -50,23 +50,9 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
#define ESCAPED_QEND M4QEND "]" M4QSTART M4QEND "]" M4QSTART
|
||||
|
||||
#define ACTION_ECHO add_action( yytext )
|
||||
#define ACTION_IFDEF(def, should_define) \
|
||||
{ \
|
||||
if ( should_define ) \
|
||||
action_define( def, 1 ); \
|
||||
}
|
||||
|
||||
#define ACTION_ECHO_QSTART add_action (ESCAPED_QSTART)
|
||||
#define ACTION_ECHO_QEND add_action (ESCAPED_QEND)
|
||||
|
||||
#define ACTION_M4_IFDEF(def, should_define) \
|
||||
do{ \
|
||||
if ( should_define ) \
|
||||
buf_m4_define( &m4defs_buf, def, NULL);\
|
||||
else \
|
||||
buf_m4_undefine( &m4defs_buf, def);\
|
||||
} while(0)
|
||||
|
||||
#define MARK_END_OF_PROLOG mark_prolog();
|
||||
|
||||
#define YY_DECL \
|
||||
@ -364,7 +350,7 @@ M4QEND "]""]"
|
||||
|
||||
align ctrl.long_align = option_sense;
|
||||
always-interactive {
|
||||
ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
|
||||
ctrl.always_interactive = option_sense;
|
||||
ctrl.interactive = (trit)option_sense;
|
||||
}
|
||||
array ctrl.yytext_is_array = option_sense;
|
||||
@ -388,7 +374,7 @@ M4QEND "]""]"
|
||||
ctrl.useecs = ctrl.usemecs = false;
|
||||
ctrl.use_read = ctrl.fulltbl = true;
|
||||
}
|
||||
input ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
|
||||
input ctrl.no_input = ! option_sense;
|
||||
interactive ctrl.interactive = (trit)option_sense;
|
||||
lex-compat ctrl.posix_compat = option_sense;
|
||||
posix-compat ctrl.posix_compat = option_sense;
|
||||
@ -401,7 +387,7 @@ M4QEND "]""]"
|
||||
}
|
||||
meta-ecs ctrl.usemecs = option_sense;
|
||||
never-interactive {
|
||||
ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense );
|
||||
ctrl.never_interactive = option_sense;
|
||||
ctrl.interactive = (trit)!option_sense;
|
||||
}
|
||||
perf-report env.performance_hint += option_sense ? 1 : -1;
|
||||
@ -409,14 +395,14 @@ M4QEND "]""]"
|
||||
read ctrl.use_read = option_sense;
|
||||
reentrant ctrl.reentrant = option_sense;
|
||||
reject reject_really_used = option_sense;
|
||||
stack ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense );
|
||||
stack ctrl.stack_used = option_sense;
|
||||
stdinit ctrl.do_stdinit = option_sense;
|
||||
stdout env.use_stdout = option_sense;
|
||||
unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense);
|
||||
unistd ctrl.no_unistd = ! option_sense;
|
||||
unput ctrl.no_unput = ! option_sense;
|
||||
verbose env.printstats = option_sense;
|
||||
warn env.nowarn = ! option_sense;
|
||||
yylineno ctrl.do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense);
|
||||
yylineno ctrl.do_yylineno = option_sense;
|
||||
yymore yymore_really_used = option_sense;
|
||||
yywrap ctrl.do_yywrap = option_sense;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user