mirror of
https://github.com/westes/flex.git
synced 2026-01-26 15:39:06 +00:00
yytext_is_array moves to the ctrl structure.
This is separate from the big reorganization in commit #52 because there's a comment about this variable in flexdef.h that makes me nervous. According to the comment this variable is a trit, but it looks to me like flexinit sets it to false and I can't find anywhere in the code that sets it to a non-boolean value. This commit asumes that the comment is stale and the member can be typed boolean. Should be audited.
This commit is contained in:
parent
99e6b1c89a
commit
9dbc704ad4
@ -383,6 +383,9 @@ struct ctrl_bundle_t {
|
||||
bool use_read; // (-f, -F, or -Cr) use read() for scanner input
|
||||
// otherwise, use fread().
|
||||
char *yyclass; // yyFlexLexer subclass to use for YY_DECL
|
||||
bool yytext_is_array; // if true (i.e., %array directive), then declare
|
||||
// yytext as a array instead of a character pointer.
|
||||
// Nice and inefficient.
|
||||
};
|
||||
|
||||
/* Environment variables. These control the lexer operation, but do
|
||||
@ -416,10 +419,7 @@ extern struct env_bundle_t env;
|
||||
/* Variables for flags:
|
||||
* syntaxerror - true if a syntax error has been found
|
||||
* eofseen - true if we've seen an eof in the input file
|
||||
* yytext_is_array - if true (i.e., %array directive), then declare
|
||||
* yytext as a array instead of a character pointer. Nice and inefficient.
|
||||
* Note that 0 is unset, 1 corresponds to --no-main, and 2 to --main.
|
||||
ya * yymore_used - if true, yymore() is used in input rules
|
||||
* yymore_used - if true, yymore() is used in input rules
|
||||
* reject - if true, generate back-up tables for REJECT macro
|
||||
* real_reject - if true, scanner really uses REJECT (as opposed to just
|
||||
* having "reject" set for variable trailing context)
|
||||
@ -432,7 +432,6 @@ ya * yymore_used - if true, yymore() is used in input rules
|
||||
*/
|
||||
|
||||
extern int syntaxerror, eofseen;
|
||||
extern int yytext_is_array;
|
||||
extern int yymore_used, reject, real_reject, continued_action, in_rule;
|
||||
extern int yymore_really_used, reject_really_used;
|
||||
|
||||
|
||||
18
src/main.c
18
src/main.c
@ -47,7 +47,7 @@ void readin(void);
|
||||
void set_up_initial_allocations(void);
|
||||
|
||||
/* these globals are all defined and commented in flexdef.h */
|
||||
int syntaxerror, eofseen, yytext_is_array;
|
||||
int syntaxerror, eofseen;
|
||||
int yymore_used, reject, real_reject, continued_action, in_rule;
|
||||
int yymore_really_used, reject_really_used;
|
||||
int datapos, dataline, linenum;
|
||||
@ -221,7 +221,7 @@ void check_options (void)
|
||||
flexerror (_
|
||||
("Can't use --ctrl.reentrant or --bison-bridge with -l option"));
|
||||
|
||||
yytext_is_array = true;
|
||||
ctrl.yytext_is_array = true;
|
||||
ctrl.do_yylineno = true;
|
||||
ctrl.use_read = false;
|
||||
}
|
||||
@ -269,9 +269,9 @@ void check_options (void)
|
||||
if (ctrl.C_plus_plus && ctrl.fullspd)
|
||||
flexerror (_("Can't use -+ with -CF option"));
|
||||
|
||||
if (ctrl.C_plus_plus && yytext_is_array) {
|
||||
if (ctrl.C_plus_plus && ctrl.yytext_is_array) {
|
||||
lwarn (_("%array incompatible with -+ option"));
|
||||
yytext_is_array = false;
|
||||
ctrl.yytext_is_array = false;
|
||||
}
|
||||
|
||||
if (ctrl.C_plus_plus && (ctrl.reentrant))
|
||||
@ -639,7 +639,7 @@ void flexinit (int argc, char **argv)
|
||||
memset(&ctrl, '\0', sizeof(ctrl));
|
||||
syntaxerror = false;
|
||||
yymore_used = continued_action = false;
|
||||
yytext_is_array = in_rule = reject = false;
|
||||
in_rule = reject = false;
|
||||
yymore_really_used = reject_really_used = trit_unspecified;
|
||||
ctrl.do_main = trit_unspecified;
|
||||
ctrl.interactive = ctrl.csize = trit_unspecified;
|
||||
@ -925,11 +925,11 @@ void flexinit (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case OPT_ARRAY:
|
||||
yytext_is_array = true;
|
||||
ctrl.yytext_is_array = true;
|
||||
break;
|
||||
|
||||
case OPT_POINTER:
|
||||
yytext_is_array = false;
|
||||
ctrl.yytext_is_array = false;
|
||||
break;
|
||||
|
||||
case OPT_ECS:
|
||||
@ -1369,7 +1369,7 @@ void readin (void)
|
||||
|
||||
if (ctrl.reentrant) {
|
||||
visible_define ("M4_YY_REENTRANT");
|
||||
if (yytext_is_array)
|
||||
if (ctrl.yytext_is_array)
|
||||
visible_define ("M4_YY_TEXT_IS_ARRAY");
|
||||
} else
|
||||
visible_define ("M4_YY_NOT_REENTRANT");
|
||||
@ -1385,7 +1385,7 @@ void readin (void)
|
||||
visible_define ( "M4_MODE_NO_DO_STDINIT");
|
||||
|
||||
// mode switches for YY_DO_BEFORE_ACTION code generation
|
||||
if (yytext_is_array)
|
||||
if (ctrl.yytext_is_array)
|
||||
visible_define ( "M4_MODE_YYTEXT_IS_ARRAY");
|
||||
else
|
||||
visible_define ( "M4_MODE_NO_YYTEXT_IS_ARRAY");
|
||||
|
||||
@ -198,8 +198,8 @@ M4QEND "]""]"
|
||||
return SECTEND;
|
||||
}
|
||||
|
||||
^"%pointer".*{NL} yytext_is_array = false; ++linenum;
|
||||
^"%array".*{NL} yytext_is_array = true; ++linenum;
|
||||
^"%pointer".*{NL} ctrl.yytext_is_array = false; ++linenum;
|
||||
^"%array".*{NL} ctrl.yytext_is_array = true; ++linenum;
|
||||
|
||||
^"%option" BEGIN(OPTION); return TOK_OPTION;
|
||||
|
||||
@ -367,7 +367,7 @@ M4QEND "]""]"
|
||||
ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
|
||||
ctrl.interactive = (trit)option_sense;
|
||||
}
|
||||
array yytext_is_array = option_sense;
|
||||
array ctrl.yytext_is_array = option_sense;
|
||||
backup env.backing_up_report = option_sense;
|
||||
batch ctrl.interactive = (trit)!option_sense;
|
||||
bison-bridge ctrl.bison_bridge_lval = option_sense;
|
||||
@ -405,7 +405,7 @@ M4QEND "]""]"
|
||||
ctrl.interactive = (trit)!option_sense;
|
||||
}
|
||||
perf-report env.performance_hint += option_sense ? 1 : -1;
|
||||
pointer yytext_is_array = ! option_sense;
|
||||
pointer ctrl.yytext_is_array = ! option_sense;
|
||||
read ctrl.use_read = option_sense;
|
||||
reentrant ctrl.reentrant = option_sense;
|
||||
reject reject_really_used = option_sense;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user