print <. Non-C99 systems may or may not. */ #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ END } # Skip over the flex output prologue: the above typedefs, forward declarations, etc. # Stop when we get to the declarations of tables. while (<>) { last if /YY_NUM_RULES/; } # Dump the generated tables. /yy_last_accepting/ matches the first declaration after the tables. print; while (<>) { last if /yy_last_accepting/; print; } # Skip down the the declaration of yytext; the body of the flex output begins after it. while (<>) { last if /yytext/; } # Dump the definitions of states (INITIAL, media query, tokenizer state support). while (<>) { last if not (/define/ || /line/) ; print; } # Skip to main scanner function. while (<>) { last if /^YY_DECL/; } # Dump main scanner declarations, substituting in our 16-bit character type. # Declarations end with the declaration matching /yy_act/. print; while (<>) { s/char/UChar/; print; last if /yy_act/; } # Skip past initialization code, down to main loop. while (<>) { last if /while \( 1 \)/; } # Dump the main loop, skipping over labels we don't use. # Stop before dumping the end-of-buffer handling, because we output our own custom end-of-buffer handling. print; while (<>) { next if /^yy_match:/; next if /^do_action:/; last if /YY_END_OF_BUFFER/; if (/^case YY_STATE_EOF\(INITIAL\):/) { print "case YY_END_OF_BUFFER:\n"; # flex outputs a ton of logic related to end-of-buffer handling; we just want to fall through to # the yyterminate() found in other EOF states. But we need to be careful to back up to behind # the terminating double-NUL so that subsequent calls to flex will have the pointers in order, # so this logic is a reduction of the normal flex-generated YY_END_OF_BUFFER code. print "\tyy_c_buf_p = yy_cp - 1;\n"; print "\tyy_cp = yy_c_buf_p;\n"; } print; } # Skip over the end-of-buffer handling; dump the rest of the function. while (<>) { last if /default:/; } print; while (<>) { print; last if /end of yylex/; } # We don't want the remainder of flex's output. # However, flex may choke with "flex: error writing output file " # if its stdout is unexpectedly closed on it. # Consume the remaining output. while (<>) { }