#!/usr/bin/perl open(IN, "flex -t tokenizer.flex|") or die "no flex?\n"; open(OUT, ">tokenizer.cpp") or die $!; print OUT <. 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 */ STOP while () { /YY_NUM_RULES/../yy_last_accepting/ and !/yy_last_accepting/ and print OUT; /^YY_DECL/ and print OUT and last; } while () { s/char/unsigned short/; print OUT; last if /yy_act/; } while () { last if /while \( 1 \)/; } print OUT; while () { next if /^yy_match:/; next if /^do_action:/; last if /YY_END_OF_BUFFER/; print OUT; print OUT "case YY_END_OF_BUFFER:\n" if /^case YY_STATE_EOF\(INITIAL\):/; } while () { last if /default:/; } print OUT; while () { print OUT; last if /end of yylex/; }