#include "flexdef.h"
void gen_next_state PROTO((int));
void genecs PROTO((void));
void indent_put2s PROTO((char [], char []));
void indent_puts PROTO((char []));
static int indent_level = 0;
#define indent_up() (++indent_level)
#define indent_down() (--indent_level)
#define set_indent(indent_val) indent_level = indent_val
static char C_int_decl[] = "static yyconst int %s[%d] =\n { 0,\n";
static char C_short_decl[] = "static yyconst short int %s[%d] =\n { 0,\n";
static char C_long_decl[] = "static yyconst long int %s[%d] =\n { 0,\n";
static char C_state_decl[] =
"static yyconst yy_state_type %s[%d] =\n { 0,\n";
void do_indent()
{
register int i = indent_level * 8;
while ( i >= 8 )
{
outc( '\t' );
i -= 8;
}
while ( i > 0 )
{
outc( ' ' );
--i;
}
}
void gen_backing_up()
{
if ( reject || num_backing_up == 0 )
return;
if ( fullspd )
indent_puts( "if ( yy_current_state[-1].yy_nxt )" );
else
indent_puts( "if ( yy_accept[yy_current_state] )" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_last_accepting_state = yy_current_state;" );
indent_puts( "yy_last_accepting_cpos = yy_cp;" );
indent_puts( "}" );
indent_down();
}
void gen_bu_action()
{
if ( reject || num_backing_up == 0 )
return;
set_indent( 3 );
indent_puts( "case 0: /* must back up */" );
indent_puts( "/* undo the effects of YY_DO_BEFORE_ACTION */" );
indent_puts( "*yy_cp = yy_hold_char;" );
if ( fullspd || fulltbl )
indent_puts( "yy_cp = yy_last_accepting_cpos + 1;" );
else
indent_puts( "yy_cp = yy_last_accepting_cpos;" );
indent_puts( "yy_current_state = yy_last_accepting_state;" );
indent_puts( "goto yy_find_action;" );
outc( '\n' );
set_indent( 0 );
}
void genctbl()
{
register int i;
int end_of_buffer_action = num_rules + 1;
out_dec( "static yyconst struct yy_trans_info yy_transition[%d] =\n",
tblend + numecs + 1 );
outn( " {" );
while ( tblend + 2 >= current_max_xpairs )
expand_nxt_chk();
while ( lastdfa + 1 >= current_max_dfas )
increase_max_dfas();
base[lastdfa + 1] = tblend + 2;
nxt[tblend + 1] = end_of_buffer_action;
chk[tblend + 1] = numecs + 1;
chk[tblend + 2] = 1;
nxt[tblend + 2] = 0;
for ( i = 0; i <= lastdfa; ++i )
{
int anum = dfaacc[i].dfaacc_state;
int offset = base[i];
chk[offset] = EOB_POSITION;
chk[offset - 1] = ACTION_POSITION;
nxt[offset - 1] = anum;
}
for ( i = 0; i <= tblend; ++i )
{
if ( chk[i] == EOB_POSITION )
transition_struct_out( 0, base[lastdfa + 1] - i );
else if ( chk[i] == ACTION_POSITION )
transition_struct_out( 0, nxt[i] );
else if ( chk[i] > numecs || chk[i] == 0 )
transition_struct_out( 0, 0 );
else
transition_struct_out( chk[i],
base[nxt[i]] - (i - chk[i]) );
}
transition_struct_out( chk[tblend + 1], nxt[tblend + 1] );
transition_struct_out( chk[tblend + 2], nxt[tblend + 2] );
outn( " };\n" );
out_dec(
"static yyconst struct yy_trans_info *yy_start_state_list[%d] =\n",
lastsc * 2 + 1 );
outn( " {" );
for ( i = 0; i <= lastsc * 2; ++i )
out_dec( " &yy_transition[%d],\n", base[i] );
dataend();
if ( useecs )
genecs();
}
void genecs()
{
register int i, j;
int numrows;
out_str_dec( C_int_decl, "yy_ec", csize );
for ( i = 1; i < csize; ++i )
{
if ( caseins && (i >= 'A') && (i <= 'Z') )
ecgroup[i] = ecgroup[clower( i )];
ecgroup[i] = ABS( ecgroup[i] );
mkdata( ecgroup[i] );
}
dataend();
if ( trace )
{
fputs( _( "\n\nEquivalence Classes:\n\n" ), stderr );
numrows = csize / 8;
for ( j = 0; j < numrows; ++j )
{
for ( i = j; i < csize; i = i + numrows )
{
fprintf( stderr, "%4s = %-2d",
readable_form( i ), ecgroup[i] );
putc( ' ', stderr );
}
putc( '\n', stderr );
}
}
}
void gen_find_action()
{
if ( fullspd )
indent_puts( "yy_act = yy_current_state[-1].yy_nxt;" );
else if ( fulltbl )
indent_puts( "yy_act = yy_accept[yy_current_state];" );
else if ( reject )
{
indent_puts( "yy_current_state = *--yy_state_ptr;" );
indent_puts( "yy_lp = yy_accept[yy_current_state];" );
outn(
"find_rule: /* we branch to this label when backing up */" );
indent_puts(
"for ( ; ; ) /* until we find what rule we matched */" );
indent_up();
indent_puts( "{" );
indent_puts(
"if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_act = yy_acclist[yy_lp];" );
if ( variable_trailing_context_rules )
{
indent_puts( "if ( yy_act & YY_TRAILING_HEAD_MASK ||" );
indent_puts( " yy_looking_for_trail_begin )" );
indent_up();
indent_puts( "{" );
indent_puts(
"if ( yy_act == yy_looking_for_trail_begin )" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_looking_for_trail_begin = 0;" );
indent_puts( "yy_act &= ~YY_TRAILING_HEAD_MASK;" );
indent_puts( "break;" );
indent_puts( "}" );
indent_down();
indent_puts( "}" );
indent_down();
indent_puts( "else if ( yy_act & YY_TRAILING_MASK )" );
indent_up();
indent_puts( "{" );
indent_puts(
"yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK;" );
indent_puts(
"yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK;" );
if ( real_reject )
{
indent_puts( "yy_full_match = yy_cp;" );
indent_puts( "yy_full_state = yy_state_ptr;" );
indent_puts( "yy_full_lp = yy_lp;" );
}
indent_puts( "}" );
indent_down();
indent_puts( "else" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_full_match = yy_cp;" );
indent_puts( "yy_full_state = yy_state_ptr;" );
indent_puts( "yy_full_lp = yy_lp;" );
indent_puts( "break;" );
indent_puts( "}" );
indent_down();
indent_puts( "++yy_lp;" );
indent_puts( "goto find_rule;" );
}
else
{
indent_up();
indent_puts( "{" );
indent_puts( "yy_full_match = yy_cp;" );
indent_puts( "break;" );
indent_puts( "}" );
indent_down();
}
indent_puts( "}" );
indent_down();
indent_puts( "--yy_cp;" );
indent_puts( "yy_current_state = *--yy_state_ptr;" );
indent_puts( "yy_lp = yy_accept[yy_current_state];" );
indent_puts( "}" );
indent_down();
}
else
{
indent_puts( "yy_act = yy_accept[yy_current_state];" );
if ( interactive && ! reject )
{
indent_puts( "if ( yy_act == 0 )" );
indent_up();
indent_puts( "{ /* have to back up */" );
indent_puts( "yy_cp = yy_last_accepting_cpos;" );
indent_puts(
"yy_current_state = yy_last_accepting_state;" );
indent_puts( "yy_act = yy_accept[yy_current_state];" );
indent_puts( "}" );
indent_down();
}
}
}
void genftbl()
{
register int i;
int end_of_buffer_action = num_rules + 1;
out_str_dec( long_align ? C_long_decl : C_short_decl,
"yy_accept", lastdfa + 1 );
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
for ( i = 1; i <= lastdfa; ++i )
{
register int anum = dfaacc[i].dfaacc_state;
mkdata( anum );
if ( trace && anum )
fprintf( stderr, _( "state # %d accepts: [%d]\n" ),
i, anum );
}
dataend();
if ( useecs )
genecs();
}
void gen_next_compressed_state( char_map )
char *char_map;
{
indent_put2s( "register YY_CHAR yy_c = %s;", char_map );
gen_backing_up();
indent_puts(
"while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_current_state = (int) yy_def[yy_current_state];" );
if ( usemecs )
{
do_indent();
out_dec( "if ( yy_current_state >= %d )\n", lastdfa + 2 );
indent_up();
indent_puts( "yy_c = yy_meta[(unsigned int) yy_c];" );
indent_down();
}
indent_puts( "}" );
indent_down();
indent_puts(
"yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];" );
}
void gen_next_match()
{
char *char_map = useecs ?
"yy_ec[YY_SC_TO_UI(*yy_cp)]" :
"YY_SC_TO_UI(*yy_cp)";
char *char_map_2 = useecs ?
"yy_ec[YY_SC_TO_UI(*++yy_cp)]" :
"YY_SC_TO_UI(*++yy_cp)";
if ( fulltbl )
{
indent_put2s(
"while ( (yy_current_state = yy_nxt[yy_current_state][%s]) > 0 )",
char_map );
indent_up();
if ( num_backing_up > 0 )
{
indent_puts( "{" );
gen_backing_up();
outc( '\n' );
}
indent_puts( "++yy_cp;" );
if ( num_backing_up > 0 )
indent_puts( "}" );
indent_down();
outc( '\n' );
indent_puts( "yy_current_state = -yy_current_state;" );
}
else if ( fullspd )
{
indent_puts( "{" );
indent_puts(
"register yyconst struct yy_trans_info *yy_trans_info;\n" );
indent_puts( "register YY_CHAR yy_c;\n" );
indent_put2s( "for ( yy_c = %s;", char_map );
indent_puts(
" (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->" );
indent_puts( "yy_verify == yy_c;" );
indent_put2s( " yy_c = %s )", char_map_2 );
indent_up();
if ( num_backing_up > 0 )
indent_puts( "{" );
indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" );
if ( num_backing_up > 0 )
{
outc( '\n' );
gen_backing_up();
indent_puts( "}" );
}
indent_down();
indent_puts( "}" );
}
else
{
indent_puts( "do" );
indent_up();
indent_puts( "{" );
gen_next_state( false );
indent_puts( "++yy_cp;" );
indent_puts( "}" );
indent_down();
do_indent();
if ( interactive )
out_dec( "while ( yy_base[yy_current_state] != %d );\n",
jambase );
else
out_dec( "while ( yy_current_state != %d );\n",
jamstate );
if ( ! reject && ! interactive )
{
indent_puts( "yy_cp = yy_last_accepting_cpos;" );
indent_puts(
"yy_current_state = yy_last_accepting_state;" );
}
}
}
void gen_next_state( worry_about_NULs )
int worry_about_NULs;
{
char char_map[256];
if ( worry_about_NULs && ! nultrans )
{
if ( useecs )
(void) sprintf( char_map,
"(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)",
NUL_ec );
else
(void) sprintf( char_map,
"(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)", NUL_ec );
}
else
strcpy( char_map, useecs ?
"yy_ec[YY_SC_TO_UI(*yy_cp)]" : "YY_SC_TO_UI(*yy_cp)" );
if ( worry_about_NULs && nultrans )
{
if ( ! fulltbl && ! fullspd )
gen_backing_up();
indent_puts( "if ( *yy_cp )" );
indent_up();
indent_puts( "{" );
}
if ( fulltbl )
indent_put2s(
"yy_current_state = yy_nxt[yy_current_state][%s];",
char_map );
else if ( fullspd )
indent_put2s(
"yy_current_state += yy_current_state[%s].yy_nxt;",
char_map );
else
gen_next_compressed_state( char_map );
if ( worry_about_NULs && nultrans )
{
indent_puts( "}" );
indent_down();
indent_puts( "else" );
indent_up();
indent_puts(
"yy_current_state = yy_NUL_trans[yy_current_state];" );
indent_down();
}
if ( fullspd || fulltbl )
gen_backing_up();
if ( reject )
indent_puts( "*yy_state_ptr++ = yy_current_state;" );
}
void gen_NUL_trans()
{
int need_backing_up = (num_backing_up > 0 && ! reject);
if ( need_backing_up && (! nultrans || fullspd || fulltbl) )
indent_puts( "register char *yy_cp = yy_c_buf_p;" );
outc( '\n' );
if ( nultrans )
{
indent_puts(
"yy_current_state = yy_NUL_trans[yy_current_state];" );
indent_puts( "yy_is_jam = (yy_current_state == 0);" );
}
else if ( fulltbl )
{
do_indent();
out_dec( "yy_current_state = yy_nxt[yy_current_state][%d];\n",
NUL_ec );
indent_puts( "yy_is_jam = (yy_current_state <= 0);" );
}
else if ( fullspd )
{
do_indent();
out_dec( "register int yy_c = %d;\n", NUL_ec );
indent_puts(
"register yyconst struct yy_trans_info *yy_trans_info;\n" );
indent_puts(
"yy_trans_info = &yy_current_state[(unsigned int) yy_c];" );
indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" );
indent_puts(
"yy_is_jam = (yy_trans_info->yy_verify != yy_c);" );
}
else
{
char NUL_ec_str[20];
(void) sprintf( NUL_ec_str, "%d", NUL_ec );
gen_next_compressed_state( NUL_ec_str );
do_indent();
out_dec( "yy_is_jam = (yy_current_state == %d);\n", jamstate );
if ( reject )
{
indent_puts( "if ( ! yy_is_jam )" );
indent_up();
indent_puts( "*yy_state_ptr++ = yy_current_state;" );
indent_down();
}
}
if ( need_backing_up && (fullspd || fulltbl) )
{
outc( '\n' );
indent_puts( "if ( ! yy_is_jam )" );
indent_up();
indent_puts( "{" );
gen_backing_up();
indent_puts( "}" );
indent_down();
}
}
void gen_start_state()
{
if ( fullspd )
{
if ( bol_needed )
{
indent_puts(
"yy_current_state = yy_start_state_list[yy_start + YY_AT_BOL()];" );
}
else
indent_puts(
"yy_current_state = yy_start_state_list[yy_start];" );
}
else
{
indent_puts( "yy_current_state = yy_start;" );
if ( bol_needed )
indent_puts( "yy_current_state += YY_AT_BOL();" );
if ( reject )
{
indent_puts( "yy_state_ptr = yy_state_buf;" );
indent_puts( "*yy_state_ptr++ = yy_current_state;" );
}
}
}
void gentabs()
{
int i, j, k, *accset, nacc, *acc_array, total_states;
int end_of_buffer_action = num_rules + 1;
acc_array = allocate_integer_array( current_max_dfas );
nummt = 0;
++num_backing_up;
if ( reject )
{
int EOB_accepting_list[2];
EOB_accepting_list[0] = 0;
EOB_accepting_list[1] = end_of_buffer_action;
accsiz[end_of_buffer_state] = 1;
dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list;
out_str_dec( long_align ? C_long_decl : C_short_decl,
"yy_acclist", MAX( numas, 1 ) + 1 );
j = 1;
for ( i = 1; i <= lastdfa; ++i )
{
acc_array[i] = j;
if ( accsiz[i] != 0 )
{
accset = dfaacc[i].dfaacc_set;
nacc = accsiz[i];
if ( trace )
fprintf( stderr,
_( "state # %d accepts: " ),
i );
for ( k = 1; k <= nacc; ++k )
{
int accnum = accset[k];
++j;
if ( variable_trailing_context_rules &&
! (accnum & YY_TRAILING_HEAD_MASK) &&
accnum > 0 && accnum <= num_rules &&
rule_type[accnum] == RULE_VARIABLE )
{
accnum |= YY_TRAILING_MASK;
}
mkdata( accnum );
if ( trace )
{
fprintf( stderr, "[%d]",
accset[k] );
if ( k < nacc )
fputs( ", ", stderr );
else
putc( '\n', stderr );
}
}
}
}
acc_array[i] = j;
dataend();
}
else
{
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
for ( i = 1; i <= lastdfa; ++i )
acc_array[i] = dfaacc[i].dfaacc_state;
acc_array[i] = 0;
}
k = lastdfa + 2;
if ( reject )
++k;
out_str_dec( long_align ? C_long_decl : C_short_decl, "yy_accept", k );
for ( i = 1; i <= lastdfa; ++i )
{
mkdata( acc_array[i] );
if ( ! reject && trace && acc_array[i] )
fprintf( stderr, _( "state # %d accepts: [%d]\n" ),
i, acc_array[i] );
}
mkdata( acc_array[i] );
if ( reject )
mkdata( acc_array[i] );
dataend();
if ( useecs )
genecs();
if ( usemecs )
{
if ( trace )
fputs( _( "\n\nMeta-Equivalence Classes:\n" ),
stderr );
out_str_dec( C_int_decl, "yy_meta", numecs + 1 );
for ( i = 1; i <= numecs; ++i )
{
if ( trace )
fprintf( stderr, "%d = %d\n",
i, ABS( tecbck[i] ) );
mkdata( ABS( tecbck[i] ) );
}
dataend();
}
total_states = lastdfa + numtemps;
out_str_dec( (tblend >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_base", total_states + 1 );
for ( i = 1; i <= lastdfa; ++i )
{
register int d = def[i];
if ( base[i] == JAMSTATE )
base[i] = jambase;
if ( d == JAMSTATE )
def[i] = jamstate;
else if ( d < 0 )
{
++tmpuses;
def[i] = lastdfa - d + 1;
}
mkdata( base[i] );
}
mkdata( base[i] );
for ( ++i ; i <= total_states; ++i )
{
mkdata( base[i] );
def[i] = jamstate;
}
dataend();
out_str_dec( (total_states >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_def", total_states + 1 );
for ( i = 1; i <= total_states; ++i )
mkdata( def[i] );
dataend();
out_str_dec( (total_states >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_nxt", tblend + 1 );
for ( i = 1; i <= tblend; ++i )
{
if ( chk[i] == 0 || nxt[i] == 0 )
nxt[i] = jamstate;
mkdata( nxt[i] );
}
dataend();
out_str_dec( (total_states >= MAX_SHORT || long_align) ?
C_long_decl : C_short_decl,
"yy_chk", tblend + 1 );
for ( i = 1; i <= tblend; ++i )
{
if ( chk[i] == 0 )
++nummt;
mkdata( chk[i] );
}
dataend();
}
void indent_put2s( fmt, arg )
char fmt[], arg[];
{
do_indent();
out_str( fmt, arg );
outn( "" );
}
void indent_puts( str )
char str[];
{
do_indent();
outn( str );
}
void make_tables()
{
register int i;
int did_eof_rule = false;
skelout();
set_indent( 1 );
if ( yymore_used && ! yytext_is_array )
{
indent_puts( "yytext_ptr -= yy_more_len; \\" );
indent_puts( "yyleng = (int) (yy_cp - yytext_ptr); \\" );
}
else
indent_puts( "yyleng = (int) (yy_cp - yy_bp); \\" );
skelout();
if ( yytext_is_array )
{
if ( yymore_used )
indent_puts(
"if ( yyleng + yy_more_offset >= YYLMAX ) \\" );
else
indent_puts( "if ( yyleng >= YYLMAX ) \\" );
indent_up();
indent_puts(
"YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\" );
indent_down();
if ( yymore_used )
{
indent_puts(
"yy_flex_strncpy( &yytext[yy_more_offset], yytext_ptr, yyleng + 1 ); \\" );
indent_puts( "yyleng += yy_more_offset; \\" );
indent_puts(
"yy_prev_more_offset = yy_more_offset; \\" );
indent_puts( "yy_more_offset = 0; \\" );
}
else
{
indent_puts(
"yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \\" );
}
}
set_indent( 0 );
skelout();
out_dec( "#define YY_NUM_RULES %d\n", num_rules );
out_dec( "#define YY_END_OF_BUFFER %d\n", num_rules + 1 );
if ( fullspd )
{
int total_table_size = tblend + numecs + 1;
char *trans_offset_type =
(total_table_size >= MAX_SHORT || long_align) ?
"long" : "short";
set_indent( 0 );
indent_puts( "struct yy_trans_info" );
indent_up();
indent_puts( "{" );
if ( long_align )
indent_puts( "long yy_verify;" );
else
indent_puts( "short yy_verify;" );
indent_put2s( "%s yy_nxt;", trans_offset_type );
indent_puts( "};" );
indent_down();
}
if ( fullspd )
genctbl();
else if ( fulltbl )
genftbl();
else
gentabs();
if ( num_backing_up > 0 && ! reject )
{
if ( ! C_plus_plus )
{
indent_puts(
"static yy_state_type yy_last_accepting_state;" );
indent_puts(
"static char *yy_last_accepting_cpos;\n" );
}
}
if ( nultrans )
{
out_str_dec( C_state_decl, "yy_NUL_trans", lastdfa + 1 );
for ( i = 1; i <= lastdfa; ++i )
{
if ( fullspd )
out_dec( " &yy_transition[%d],\n", base[i] );
else
mkdata( nultrans[i] );
}
dataend();
}
if ( ddebug )
{
if ( ! C_plus_plus )
{
indent_puts( "extern int yy_flex_debug;" );
indent_puts( "int yy_flex_debug = 1;\n" );
}
out_str_dec( 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();
}
if ( reject )
{
if ( ! C_plus_plus )
{
outn(
"static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;" );
outn( "static char *yy_full_match;" );
outn( "static int yy_lp;" );
}
if ( variable_trailing_context_rules )
{
if ( ! C_plus_plus )
{
outn(
"static int yy_looking_for_trail_begin = 0;" );
outn( "static int yy_full_lp;" );
outn( "static int *yy_full_state;" );
}
out_hex( "#define YY_TRAILING_MASK 0x%x\n",
(unsigned int) YY_TRAILING_MASK );
out_hex( "#define YY_TRAILING_HEAD_MASK 0x%x\n",
(unsigned int) YY_TRAILING_HEAD_MASK );
}
outn( "#define REJECT \\" );
outn( "{ \\" );
outn(
"*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \\" );
outn(
"yy_cp = yy_full_match; /* restore poss. backed-over text */ \\" );
if ( variable_trailing_context_rules )
{
outn(
"yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \\" );
outn(
"yy_state_ptr = yy_full_state; /* restore orig. state */ \\" );
outn(
"yy_current_state = *yy_state_ptr; /* restore curr. state */ \\" );
}
outn( "++yy_lp; \\" );
outn( "goto find_rule; \\" );
outn( "}" );
}
else
{
outn(
"/* The intent behind this definition is that it'll catch" );
outn( " * any uses of REJECT which flex missed." );
outn( " */" );
outn( "#define REJECT reject_used_but_not_detected" );
}
if ( yymore_used )
{
if ( ! C_plus_plus )
{
if ( yytext_is_array )
{
indent_puts( "static int yy_more_offset = 0;" );
indent_puts(
"static int yy_prev_more_offset = 0;" );
}
else
{
indent_puts( "static int yy_more_flag = 0;" );
indent_puts( "static int yy_more_len = 0;" );
}
}
if ( yytext_is_array )
{
indent_puts(
"#define yymore() (yy_more_offset = yy_flex_strlen( yytext ))" );
indent_puts( "#define YY_NEED_STRLEN" );
indent_puts( "#define YY_MORE_ADJ 0" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET \\" );
indent_up();
indent_puts( "{ \\" );
indent_puts( "yy_more_offset = yy_prev_more_offset; \\" );
indent_puts( "yyleng -= yy_more_offset; \\" );
indent_puts( "}" );
indent_down();
}
else
{
indent_puts( "#define yymore() (yy_more_flag = 1)" );
indent_puts( "#define YY_MORE_ADJ yy_more_len" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET" );
}
}
else
{
indent_puts( "#define yymore() yymore_used_but_not_detected" );
indent_puts( "#define YY_MORE_ADJ 0" );
indent_puts( "#define YY_RESTORE_YY_MORE_OFFSET" );
}
if ( ! C_plus_plus )
{
if ( yytext_is_array )
{
outn( "#ifndef YYLMAX" );
outn( "#define YYLMAX 8192" );
outn( "#endif\n" );
outn( "char yytext[YYLMAX];" );
outn( "char *yytext_ptr;" );
}
else
outn( "char *yytext;" );
}
out( &action_array[defs1_offset] );
line_directive_out( stdout, 0 );
skelout();
if ( ! C_plus_plus )
{
if ( use_read )
{
outn(
"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
else
{
outn(
"\tif ( yy_current_buffer->yy_is_interactive ) \\" );
outn( "\t\t{ \\" );
outn( "\t\tint c = '*', n; \\" );
outn( "\t\tfor ( n = 0; n < max_size && \\" );
outn( "\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\" );
outn( "\t\t\tbuf[n] = (char) c; \\" );
outn( "\t\tif ( c == '\\n' ) \\" );
outn( "\t\t\tbuf[n++] = (char) c; \\" );
outn( "\t\tif ( c == EOF && ferror( yyin ) ) \\" );
outn(
"\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
outn( "\t\tresult = n; \\" );
outn( "\t\t} \\" );
outn(
"\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\" );
outn( "\t\t && ferror( yyin ) ) \\" );
outn(
"\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
}
}
skelout();
indent_puts( "#define YY_RULE_SETUP \\" );
indent_up();
if ( bol_needed )
{
indent_puts( "if ( yyleng > 0 ) \\" );
indent_up();
indent_puts( "yy_current_buffer->yy_at_bol = \\" );
indent_puts( "\t\t(yytext[yyleng - 1] == '\\n'); \\" );
indent_down();
}
indent_puts( "YY_USER_ACTION" );
indent_down();
skelout();
out( &action_array[prolog_offset] );
line_directive_out( stdout, 0 );
skelout();
set_indent( 2 );
if ( yymore_used && ! yytext_is_array )
{
indent_puts( "yy_more_len = 0;" );
indent_puts( "if ( yy_more_flag )" );
indent_up();
indent_puts( "{" );
indent_puts( "yy_more_len = yy_c_buf_p - yytext_ptr;" );
indent_puts( "yy_more_flag = 0;" );
indent_puts( "}" );
indent_down();
}
skelout();
gen_start_state();
outn( "yy_match:" );
gen_next_match();
skelout();
set_indent( 2 );
gen_find_action();
skelout();
if ( do_yylineno )
{
indent_puts( "if ( yy_act != YY_END_OF_BUFFER )" );
indent_up();
indent_puts( "{" );
indent_puts( "int yyl;" );
indent_puts( "for ( yyl = 0; yyl < yyleng; ++yyl )" );
indent_up();
indent_puts( "if ( yytext[yyl] == '\\n' )" );
indent_up();
indent_puts( "++yylineno;" );
indent_down();
indent_down();
indent_puts( "}" );
indent_down();
}
skelout();
if ( ddebug )
{
indent_puts( "if ( yy_flex_debug )" );
indent_up();
indent_puts( "{" );
indent_puts( "if ( yy_act == 0 )" );
indent_up();
indent_puts( C_plus_plus ?
"cerr << \"--scanner backing up\\n\";" :
"fprintf( stderr, \"--scanner backing up\\n\" );" );
indent_down();
do_indent();
out_dec( "else if ( yy_act < %d )\n", num_rules );
indent_up();
if ( C_plus_plus )
{
indent_puts(
"cerr << \"--accepting rule at line \" << yy_rule_linenum[yy_act] <<" );
indent_puts(
" \"(\\\"\" << yytext << \"\\\")\\n\";" );
}
else
{
indent_puts(
"fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
indent_puts(
" yy_rule_linenum[yy_act], yytext );" );
}
indent_down();
do_indent();
out_dec( "else if ( yy_act == %d )\n", num_rules );
indent_up();
if ( C_plus_plus )
{
indent_puts(
"cerr << \"--accepting default rule (\\\"\" << yytext << \"\\\")\\n\";" );
}
else
{
indent_puts(
"fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," );
indent_puts( " yytext );" );
}
indent_down();
do_indent();
out_dec( "else if ( yy_act == %d )\n", num_rules + 1 );
indent_up();
indent_puts( C_plus_plus ?
"cerr << \"--(end of buffer or a NUL)\\n\";" :
"fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );" );
indent_down();
do_indent();
outn( "else" );
indent_up();
if ( C_plus_plus )
{
indent_puts(
"cerr << \"--EOF (start condition \" << YY_START << \")\\n\";" );
}
else
{
indent_puts(
"fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );" );
}
indent_down();
indent_puts( "}" );
indent_down();
}
skelout();
indent_up();
gen_bu_action();
out( &action_array[action_offset] );
line_directive_out( stdout, 0 );
for ( i = 1; i <= lastsc; ++i )
if ( ! sceof[i] )
{
do_indent();
out_str( "case YY_STATE_EOF(%s):\n", scname[i] );
did_eof_rule = true;
}
if ( did_eof_rule )
{
indent_up();
indent_puts( "yyterminate();" );
indent_down();
}
skelout();
set_indent( 4 );
if ( fullspd || fulltbl )
indent_puts( "yy_cp = yy_c_buf_p;" );
else
{
if ( ! reject && ! interactive )
{
indent_puts( "yy_cp = yy_last_accepting_cpos;" );
indent_puts(
"yy_current_state = yy_last_accepting_state;" );
}
else
indent_puts( "yy_cp = yy_c_buf_p;" );
}
set_indent( 1 );
skelout();
gen_start_state();
set_indent( 2 );
skelout();
gen_next_state( true );
set_indent( 1 );
skelout();
gen_NUL_trans();
skelout();
if ( do_yylineno )
{
indent_puts( "if ( c == '\\n' )" );
indent_up();
indent_puts( "--yylineno;" );
indent_down();
}
skelout();
if ( bol_needed )
{
indent_puts( "yy_current_buffer->yy_at_bol = (c == '\\n');" );
if ( do_yylineno )
{
indent_puts( "if ( yy_current_buffer->yy_at_bol )" );
indent_up();
indent_puts( "++yylineno;" );
indent_down();
}
}
else if ( do_yylineno )
{
indent_puts( "if ( c == '\\n' )" );
indent_up();
indent_puts( "++yylineno;" );
indent_down();
}
skelout();
line_directive_out( stdout, 1 );
if ( sectnum == 3 )
(void) flexscan();
}