diff options
author | Vern Paxson <vern@ee.lbl.gov> | 1996-05-25 20:43:38 +0000 |
---|---|---|
committer | Vern Paxson <vern@ee.lbl.gov> | 1996-05-25 20:43:38 +0000 |
commit | b1869ee4ffbd8006d7fd7aacb7df4f10c316f9bb (patch) | |
tree | c8d6e079783ee3e123f0a7aeb263d776ecc956c9 /gen.c | |
parent | a1b81d95566431d65d5a9afa024bf8fc87646d9f (diff) |
yymore + %array tweaks
Diffstat (limited to 'gen.c')
-rw-r--r-- | gen.c | 64 |
1 files changed, 55 insertions, 9 deletions
@@ -1066,7 +1066,7 @@ void make_tables() */ set_indent( 1 ); - if ( yymore_used ) + if ( yymore_used && ! yytext_is_array ) { indent_puts( "yytext_ptr -= yy_more_len; \\" ); indent_puts( "yyleng = (int) (yy_cp - yytext_ptr); \\" ); @@ -1079,13 +1079,31 @@ void make_tables() skelout(); if ( yytext_is_array ) { - indent_puts( "if ( yyleng >= YYLMAX ) \\" ); + 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(); - indent_puts( + + 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 ); @@ -1244,18 +1262,46 @@ void make_tables() { if ( ! C_plus_plus ) { - indent_puts( "static int yy_more_flag = 0;" ); - indent_puts( "static int yy_more_len = 0;" ); + 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;" ); + } } - indent_puts( "#define yymore() (yy_more_flag = 1)" ); - indent_puts( "#define YY_MORE_ADJ yy_more_len" ); + 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 ) @@ -1339,13 +1385,13 @@ void make_tables() set_indent( 2 ); - if ( yymore_used ) + 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 = yyleng;" ); + indent_puts( "yy_more_len = yy_c_buf_p - yytext_ptr;" ); indent_puts( "yy_more_flag = 0;" ); indent_puts( "}" ); indent_down(); |