*/
num_full_table_rows = numecs + 1;
- /* Declare it "short" because it's a real long-shot that that
- * won't be large enough.
+ /* Unless -a, declare it "short" because it's a real
+ * long-shot that that won't be large enough.
*/
- printf( "static const short yy_nxt[][%d] =\n {\n",
+ printf( "static const %s yy_nxt[][%d] =\n {\n",
/* '}' so vi doesn't get too confused */
- num_full_table_rows );
+ long_align ? "long" : "short", num_full_table_rows );
/* Generate 0 entries for state #0. */
for ( i = 0; i < num_full_table_rows; ++i )
* listing backing-up states
* C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
* otherwise, a standard C scanner
+ * long_align - if true (-a flag), favor long-word alignment.
* yytext_is_array - if true (i.e., %array directive), then declare
* yytext as a array instead of a character pointer. Nice and inefficient.
* csize - size of character set for the scanner we're generating;
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
extern int interactive, caseins, useecs, fulltbl, usemecs;
extern int fullspd, gen_line_dirs, performance_report, backing_up_report;
-extern int C_plus_plus, yytext_is_array, csize;
+extern int C_plus_plus, long_align, yytext_is_array, csize;
extern int yymore_used, reject, real_reject, continued_action;
#define REALLY_NOT_DETERMINED 0
register int i;
int end_of_buffer_action = num_rules + 1;
- printf( C_short_decl, "yy_accept", lastdfa + 1 );
+ printf( long_align ? C_long_decl : C_short_decl,
+ "yy_accept", lastdfa + 1 );
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
"while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )" );
indent_up();
indent_puts( "{" );
- indent_puts( "yy_current_state = yy_def[yy_current_state];" );
+ indent_puts( "yy_current_state = (int) yy_def[yy_current_state];" );
if ( usemecs )
{
accsiz[end_of_buffer_state] = 1;
dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list;
- printf( C_short_decl, "yy_acclist", max( numas, 1 ) + 1 );
+ printf( long_align ? C_long_decl : C_short_decl,
+ "yy_acclist", max( numas, 1 ) + 1 );
j = 1; /* index into "yy_acclist" array */
*/
++k;
- printf( C_short_decl, "yy_accept", k );
+ printf( long_align ? C_long_decl : C_short_decl, "yy_accept", k );
for ( i = 1; i <= lastdfa; ++i )
{
total_states = lastdfa + numtemps;
- printf( total_states >= MAX_SHORT ? C_long_decl : C_short_decl,
+ printf( (total_states >= MAX_SHORT || long_align) ?
+ C_long_decl : C_short_decl,
"yy_base", total_states + 1 );
for ( i = 1; i <= lastdfa; ++i )
dataend();
- printf( total_states >= MAX_SHORT ? C_long_decl : C_short_decl,
+ printf( (total_states >= MAX_SHORT || long_align) ?
+ C_long_decl : C_short_decl,
"yy_def", total_states + 1 );
for ( i = 1; i <= total_states; ++i )
dataend();
- printf( tblend >= MAX_SHORT ? C_long_decl : C_short_decl,
+ printf( (tblend >= MAX_SHORT || long_align) ?
+ C_long_decl : C_short_decl,
"yy_nxt", tblend + 1 );
for ( i = 1; i <= tblend; ++i )
dataend();
- printf( tblend >= MAX_SHORT ? C_long_decl : C_short_decl,
+ printf( (tblend >= MAX_SHORT || long_align) ?
+ C_long_decl : C_short_decl,
"yy_chk", tblend + 1 );
for ( i = 1; i <= tblend; ++i )
/* First, take care of YY_DO_BEFORE_ACTION depending on yymore
* being used.
*/
- set_indent( 2 );
+ set_indent( 1 );
if ( yymore_used )
{
*/
int total_table_size = tblend + numecs + 1;
char *trans_offset_type =
- total_table_size >= MAX_SHORT ? "long" : "short";
+ (total_table_size >= MAX_SHORT || long_align) ?
+ "long" : "short";
set_indent( 0 );
indent_puts( "struct yy_trans_info" );
indent_up();
indent_puts( "{" ); /* } for vi */
- indent_puts( "short yy_verify;" );
+
+ if ( long_align )
+ indent_puts( "long yy_verify;" );
+ else
+ indent_puts( "short yy_verify;" );
/* In cases where its sister yy_verify *is* a "yes, there is
* a transition", yy_nxt is the offset (in records) to the
indent_puts( "extern int yy_flex_debug;" );
indent_puts( "int yy_flex_debug = 1;\n" );
- printf( C_short_decl, "yy_rule_linenum", num_rules );
+ printf( long_align ? C_long_decl : C_short_decl,
+ "yy_rule_linenum", num_rules );
for ( i = 1; i < num_rules; ++i )
mkdata( rule_linenum[i] );
dataend();
int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
int interactive, caseins, useecs, fulltbl, usemecs;
int fullspd, gen_line_dirs, performance_report, backing_up_report;
-int C_plus_plus, yytext_is_array, csize;
+int C_plus_plus, long_align, yytext_is_array, csize;
int yymore_used, reject, real_reject, continued_action;
int yymore_really_used, reject_really_used;
int datapos, dataline, linenum;
if ( C_plus_plus )
putc( '+', stderr );
+ if ( long_align )
+ putc( 'a', stderr );
if ( backing_up_report )
putc( 'b', stderr );
if ( ddebug )
printstats = syntaxerror = trace = spprdflt = caseins = false;
C_plus_plus = backing_up_report = ddebug = fulltbl = fullspd = false;
- nowarn = yymore_used = continued_action = reject = false;
+ long_align = nowarn = yymore_used = continued_action = reject = false;
yytext_is_array = yymore_really_used = reject_really_used = false;
gen_line_dirs = usemecs = useecs = true;
performance_report = 0;
C_plus_plus = true;
break;
+ case 'a':
+ long_align = true;
+ break;
+
case 'B':
interactive = false;
interactive_given = true;
{
if ( yytext_is_array )
{
+ puts( "\n#include <string.h>\n" );
puts( "extern char yytext[];\n" );
puts( "#ifndef YYLMAX" );
puts( "#define YYLMAX YY_READ_BUF_SIZE" );
void usage()
{
fprintf( stderr,
- "%s [-bcdfhinpstvwBFILTV78+ -C[efmF] -Pprefix -Sskeleton] [file ...]\n",
+"%s [-abcdfhinpstvwBFILTV78+ -C[efmF] -Pprefix -Sskeleton] [file ...]\n",
program_name );
+ fprintf( stderr,
+ "\t-a trade off larger tables for better memory alignment\n" );
fprintf( stderr,
"\t-b generate backing-up information to lex.backup\n" );
fprintf( stderr, "\t-c do-nothing POSIX option\n" );