]> granicus.if.org Git - flex/commitdiff
yymore + %array tweaks
authorVern Paxson <vern@ee.lbl.gov>
Sat, 25 May 1996 20:43:38 +0000 (20:43 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Sat, 25 May 1996 20:43:38 +0000 (20:43 +0000)
gen.c

diff --git a/gen.c b/gen.c
index d0f7d7cc31c71b91c399f9f55696bdb475d89dac..7798a191b727afbdef6d8952920db0c7409e128b 100644 (file)
--- a/gen.c
+++ b/gen.c
@@ -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();