diff options
-rw-r--r-- | main.c | 139 | ||||
-rw-r--r-- | options.c | 101 | ||||
-rw-r--r-- | options.h | 80 |
3 files changed, 248 insertions, 72 deletions
@@ -801,6 +801,10 @@ char **argv; ddebug = true; break; + case OPT_NO_DEBUG: + ddebug = false; + break; + case OPT_FULL: useecs = usemecs = false; use_read = fulltbl = true; @@ -829,6 +833,11 @@ char **argv; case OPT_MAIN: buf_strdefine(&userdef_buf, "YY_MAIN", "1"); + do_yywrap = false; + break; + + case OPT_NO_MAIN: + buf_strdefine(&userdef_buf, "YY_MAIN", "0"); break; case OPT_NO_LINE: @@ -865,6 +874,10 @@ char **argv; } break; + case OPT_NO_REENTRANT: + reentrant = reentrant_bison_pure = false; + break; + case OPT_SKEL: skelname = arg; break; @@ -894,6 +907,10 @@ char **argv; program_name, flex_version ); exit( 0 ); + case OPT_WARN: + nowarn = false; + break; + case OPT_NO_WARN: nowarn = true; break; @@ -910,6 +927,10 @@ char **argv; long_align = true; break; + case OPT_NO_ALIGN: + long_align = false; + break; + case OPT_ALWAYS_INTERACTIVE: buf_strdefine(&userdef_buf,"YY_ALWAYS_INTERACTIVE", "1"); break; @@ -930,13 +951,21 @@ char **argv; useecs = true; break; + case OPT_NO_ECS: + useecs = false; + break; + case OPT_HEADER: headerfilename = arg; break; case OPT_META_ECS: usemecs = true; + break; + case OPT_NO_META_ECS: + usemecs = false; + break; case OPT_PREPROCDEFINE: { @@ -971,6 +1000,10 @@ char **argv; do_stdinit = true; break; + case OPT_NO_STDINIT: + do_stdinit = false; + break; + case OPT_YYCLASS: yyclass = arg; break; @@ -979,10 +1012,98 @@ char **argv; do_yylineno = true; break; + case OPT_NO_YYLINENO: + do_yylineno = false; + break; + case OPT_YYWRAP: do_yywrap = true; break; + case OPT_NO_YYWRAP: + do_yywrap = false; + break; + + case OPT_YYMORE: + yymore_really_used = true; + break; + + case OPT_NO_YYMORE: + yymore_really_used = false; + break; + + case OPT_REJECT: + reject_really_used = true; + break; + + case OPT_NO_REJECT: + reject_really_used = false; + break; + + case OPT_NO_YY_PUSH_STATE: + buf_strdefine(&userdef_buf, "YY_NO_PUSH_STATE", "1"); + break; + case OPT_NO_YY_POP_STATE: + buf_strdefine(&userdef_buf, "YY_NO_POP_STATE", "1"); + break; + case OPT_NO_YY_TOP_STATE: + buf_strdefine(&userdef_buf, "YY_NO_TOP_STATE", "1"); + break; + case OPT_NO_UNPUT: + buf_strdefine(&userdef_buf, "YY_NO_UNPUT", "1"); + break; + case OPT_NO_YY_SCAN_BUFFER: + buf_strdefine(&userdef_buf, "YY_NO_SCAN_BUFFER", "1"); + break; + case OPT_NO_YY_SCAN_BYTES: + buf_strdefine(&userdef_buf, "YY_NO_SCAN_BYTES", "1"); + break; + case OPT_NO_YY_SCAN_STRING: + buf_strdefine(&userdef_buf, "YY_NO_SCAN_STRING", "1"); + break; + case OPT_NO_YYGET_EXTRA: + buf_strdefine(&userdef_buf, "YY_NO_GET_EXTRA", "1"); + break; + case OPT_NO_YYSET_EXTRA: + buf_strdefine(&userdef_buf, "YY_NO_SET_EXTRA", "1"); + break; + case OPT_NO_YYGET_LENG: + buf_strdefine(&userdef_buf, "YY_NO_GET_LENG", "1"); + break; + case OPT_NO_YYGET_TEXT: + buf_strdefine(&userdef_buf, "YY_NO_GET_TEXT", "1"); + break; + case OPT_NO_YYGET_LINENO: + buf_strdefine(&userdef_buf, "YY_NO_GET_LINENO", "1"); + break; + case OPT_NO_YYSET_LINENO: + buf_strdefine(&userdef_buf, "YY_NO_SET_LINENO", "1"); + break; + case OPT_NO_YYGET_IN: + buf_strdefine(&userdef_buf, "YY_NO_GET_IN", "1"); + break; + case OPT_NO_YYSET_IN: + buf_strdefine(&userdef_buf, "YY_NO_SET_IN", "1"); + break; + case OPT_NO_YYGET_OUT: + buf_strdefine(&userdef_buf, "YY_NO_GET_OUT", "1"); + break; + case OPT_NO_YYSET_OUT: + buf_strdefine(&userdef_buf, "YY_NO_SET_OUT", "1"); + break; + case OPT_NO_YYGET_LVAL: + buf_strdefine(&userdef_buf, "YY_NO_GET_LVAL", "1"); + break; + case OPT_NO_YYSET_LVAL: + buf_strdefine(&userdef_buf, "YY_NO_SET_LVAL", "1"); + break; + case OPT_NO_YYGET_LLOC: + buf_strdefine(&userdef_buf, "YY_NO_GET_LLOC", "1"); + break; + case OPT_NO_YYSET_LLOC: + buf_strdefine(&userdef_buf, "YY_NO_SET_LLOC", "1"); + break; + } /* switch */ } /* while scanopt() */ @@ -1369,16 +1490,14 @@ _( "\n" "Generated code:\n" -" -+, --c++ generate C++ scanner class\n" -" -Dmacro[=defn] #define macro defn (default defn is '1')\n" -" -L, --noline suppress #line directives in scanner\n" -" -P, --prefix=STRING use STRING as prefix instead of \"yy\"\n" -" -R, --reentrant generate a reentrant C scanner\n" -" -Rb, --reentrant-bison reentrant scanner for bison pure parser.\n" - -"\n" -"Functions:\n" -" --yywrap call yywrap on EOF\n" +" -+, --c++ generate C++ scanner class\n" +" -Dmacro[=defn] #define macro defn (default defn is '1')\n" +" -L, --noline suppress #line directives in scanner\n" +" -P, --prefix=STRING use STRING as prefix instead of \"yy\"\n" +" -R, --reentrant generate a reentrant C scanner\n" +" -Rb, --reentrant-bison reentrant scanner for bison pure parser.\n" +" --stdinit initialize yyin/yyout to stdin/stdout\n" +" --noFUNCTION do not generate a particular FUNCTION\n" "\n" "Miscellaneous:\n" @@ -1,77 +1,122 @@ #include "options.h" +/* Be sure to synchronize these options with those defined in "options.h", + * the giant switch() statement in "main.c", and the %option processing in + * "scan.l". + */ + + +/* The command-line options, passed to scanopt_init() */ optspec_t flexopts[] = { -{"--7bit", OPT_7BIT,0},/* Generate 7-bit scanner. */ {"-7", OPT_7BIT,0}, -{"--8bit", OPT_8BIT,0},/* Generate 8-bit scanner. */ +{"--7bit", OPT_7BIT,0},/* Generate 7-bit scanner. */ {"-8", OPT_8BIT,0}, +{"--8bit", OPT_8BIT,0},/* Generate 8-bit scanner. */ {"--align", OPT_ALIGN,0},/* Trade off larger tables for better memory alignment. */ -{"--always-interactive",OPT_ALWAYS_INTERACTIVE,0}, +{"--noalign", OPT_NO_ALIGN,0}, +{"--always-interactive", OPT_ALWAYS_INTERACTIVE,0}, {"--array", OPT_ARRAY,0}, -{"--backup", OPT_BACKUP,0},/* Generate backing-up information to lex.backup. */ {"-b", OPT_BACKUP,0}, -{"--batch", OPT_BATCH,0},/* Generate batch scanner (opposite of -I). */ +{"--backup", OPT_BACKUP,0},/* Generate backing-up information to lex.backup. */ {"-B", OPT_BATCH,0}, -{"--case-insensitive", OPT_CASE_INSENSITIVE,0},/* Generate case-insensitive scanner. */ +{"--batch", OPT_BATCH,0},/* Generate batch scanner (opposite of -I). */ {"-i", OPT_CASE_INSENSITIVE,0}, +{"--case-insensitive", OPT_CASE_INSENSITIVE,0},/* Generate case-insensitive scanner. */ {"-C[aefFmr]", OPT_COMPRESSION,"Specify degree of table compression (default is -Cem)"}, -{"--c++", OPT_CPLUSPLUS,0},/* Generate C++ scanner class. */ {"-+", OPT_CPLUSPLUS,0}, -{"--debug", OPT_DEBUG,0},/* Turn on debug mode in generated scanner. */ +{"--c++", OPT_CPLUSPLUS,0},/* Generate C++ scanner class. */ {"-d", OPT_DEBUG,0}, +{"--debug", OPT_DEBUG,0},/* Turn on debug mode in generated scanner. */ +{"--nodebug", OPT_NO_DEBUG,0}, +{"-s", OPT_NO_DEFAULT,0}, +{"--nodefault", OPT_NO_DEFAULT,0},/* Suppress default rule to ECHO unmatched text. */ {"--default", OPT_DEFAULT,0}, {"-c", OPT_DONOTHING,0},/* For POSIX lex compatibility. */ {"-n", OPT_DONOTHING,0},/* For POSIX lex compatibility. */ {"--ecs", OPT_ECS,0},/* Construct equivalence classes. */ -{"--fast", OPT_FAST,0},/* Same as -CFr. */ +{"--noecs", OPT_NO_ECS,0}, {"-F", OPT_FAST,0}, -{"--full", OPT_FULL,0},/* Same as -Cfr. */ +{"--fast", OPT_FAST,0},/* Same as -CFr. */ {"-f", OPT_FULL,0}, +{"--full", OPT_FULL,0},/* Same as -Cfr. */ {"--header[=FILE]", OPT_HEADER,0}, -{"--help", OPT_HELP,0},/* Produce this help message. */ {"-?", OPT_HELP,0}, {"-h", OPT_HELP,0}, -{"--interactive", OPT_INTERACTIVE,0},/* Generate interactive scanner (opposite of -B). */ +{"--help", OPT_HELP,0},/* Produce this help message. */ {"-I", OPT_INTERACTIVE,0}, -{"--lex-compat", OPT_LEX_COMPAT,0},/* Maximal compatibility with original lex. */ +{"--interactive", OPT_INTERACTIVE,0},/* Generate interactive scanner (opposite of -B). */ {"-l", OPT_LEX_COMPAT,0}, +{"--lex-compat", OPT_LEX_COMPAT,0},/* Maximal compatibility with original lex. */ +{"-L", OPT_NO_LINE,0},/* Suppress #line directives in scanner. */ +{"--noline", OPT_NO_LINE,0},/* Suppress #line directives in scanner. */ {"--main", OPT_MAIN,0}, /* use built-in main() function. */ +{"--nomain", OPT_NO_MAIN,0}, {"--meta-ecs", OPT_META_ECS,0},/* Construct meta-equivalence classes. */ +{"--nometa-ecs", OPT_NO_META_ECS,0}, {"--never-interactive", OPT_NEVER_INTERACTIVE,0}, -{"--nodefault", OPT_NO_DEFAULT,0},/* Suppress default rule to ECHO unmatched text. */ -{"-s", OPT_NO_DEFAULT,0}, -{"--noline", OPT_NO_LINE,0},/* Suppress #line directives in scanner. */ -{"-L", OPT_NO_LINE,0},/* Suppress #line directives in scanner. */ -{"--nowarn", OPT_NO_WARN,0},/* Suppress warning messages. */ -{"-w", OPT_NO_WARN,0}, -{"--outfile=FILE", OPT_OUTFILE,0},/* Write to FILE (default is lex.yy.c) */ {"-o FILE", OPT_OUTFILE,0}, -{"--perf-report", OPT_PERF_REPORT,0},/* Generate performance report to stderr. */ +{"--outfile=FILE", OPT_OUTFILE,0},/* Write to FILE (default is lex.yy.c) */ {"-p", OPT_PERF_REPORT,0}, +{"--perf-report", OPT_PERF_REPORT,0},/* Generate performance report to stderr. */ {"--pointer", OPT_POINTER,0}, -{"--prefix=PREFIX", OPT_PREFIX,0},/* Use PREFIX (default is yy) */ {"-P PREFIX", OPT_PREFIX,0}, +{"--prefix=PREFIX", OPT_PREFIX,0},/* Use PREFIX (default is yy) */ {"-Dmacro", OPT_PREPROCDEFINE,0},/* Define a preprocessor symbol. */ {"--read", OPT_READ,0},/* Use read(2) instead of stdio. */ -{"--reentrant", OPT_REENTRANT,0},/* Generate a reentrant C scanner. */ {"-R[b]", OPT_REENTRANT,0}, +{"--reentrant", OPT_REENTRANT,0},/* Generate a reentrant C scanner. */ +{"--noreentrant", OPT_NO_REENTRANT,0}, {"--reentrant-bison", OPT_REENTRANT_BISON,0},/* Reentrant scanner to be called by a bison pure parser. */ -{"--skel=FILE", OPT_SKEL,0},/* Use skeleton from FILE */ +{"--reject", OPT_REJECT,0}, +{"--noreject", OPT_NO_REJECT,0}, {"-S FILE", OPT_SKEL,0}, +{"--skel=FILE", OPT_SKEL,0},/* Use skeleton from FILE */ {"--stack", OPT_STACK,0}, {"--stdinit", OPT_STDINIT,0}, -{"--stdout", OPT_STDOUT,0},/* Write generated scanner to stdout. */ +{"--nostdinit", OPT_NO_STDINIT,0}, {"-t", OPT_STDOUT,0}, -{"--trace", OPT_TRACE,0},/* Flex should run in trace mode. */ +{"--stdout", OPT_STDOUT,0},/* Write generated scanner to stdout. */ {"-T", OPT_TRACE,0}, -{"--verbose", OPT_VERBOSE,0},/* Write summary of scanner statistics to stdout. */ +{"--trace", OPT_TRACE,0},/* Flex should run in trace mode. */ {"-v", OPT_VERBOSE,0}, -{"--version", OPT_VERSION,0},/* Report flex version. */ +{"--verbose", OPT_VERBOSE,0},/* Write summary of scanner statistics to stdout. */ {"-V", OPT_VERSION,0}, +{"--version", OPT_VERSION,0},/* Report flex version. */ +{"--warn", OPT_WARN,0}, +{"-w", OPT_NO_WARN,0}, +{"--nowarn", OPT_NO_WARN,0},/* Suppress warning messages. */ {"--yyclass=NAME", OPT_YYCLASS,0}, {"--yylineno", OPT_YYLINENO,0}, +{"--noyylineno", OPT_NO_YYLINENO,0}, + +{"--yymore", OPT_YYMORE,0}, +{"--noyymore", OPT_NO_YYMORE,0}, +{"--noyywrap", OPT_NO_YYWRAP,0}, {"--yywrap" , OPT_YYWRAP,0}, + +{"--nounput", OPT_NO_UNPUT,0}, +{"--noyy_push_state", OPT_NO_YY_PUSH_STATE,0}, +{"--noyy_pop_state", OPT_NO_YY_POP_STATE,0}, +{"--noyy_top_state", OPT_NO_YY_TOP_STATE,0}, +{"--noyy_scan_buffer", OPT_NO_YY_SCAN_BUFFER,0}, +{"--noyy_scan_bytes", OPT_NO_YY_SCAN_BYTES,0}, +{"--noyy_scan_string", OPT_NO_YY_SCAN_STRING,0}, +{"--noyyget_extra", OPT_NO_YYGET_EXTRA,0}, +{"--noyyset_extra", OPT_NO_YYSET_EXTRA,0}, +{"--noyyget_leng", OPT_NO_YYGET_LENG,0}, +{"--noyyget_text", OPT_NO_YYGET_TEXT,0}, +{"--noyyget_lineno", OPT_NO_YYGET_LINENO,0}, +{"--noyyset_lineno", OPT_NO_YYSET_LINENO,0}, +{"--noyyget_in", OPT_NO_YYGET_IN,0}, +{"--noyyset_in", OPT_NO_YYSET_IN,0}, +{"--noyyget_out", OPT_NO_YYGET_OUT,0}, +{"--noyyset_out", OPT_NO_YYSET_OUT,0}, +{"--noyyget_lval", OPT_NO_YYGET_LVAL,0}, +{"--noyyset_lval", OPT_NO_YYSET_LVAL,0}, +{"--noyyget_lloc", OPT_NO_YYGET_LLOC,0}, +{"--noyyset_lloc", OPT_NO_YYSET_LLOC,0}, + {0,0,0} /* required final NULL entry.*/ }; @@ -9,7 +9,7 @@ enum flexopt_flag_t { * Order is not important. */ OPT_7BIT=1, OPT_8BIT, - OPT_ALIGN, OPT_NO_ALIGN, + OPT_ALIGN, OPT_ALWAYS_INTERACTIVE, OPT_ARRAY, OPT_BACKUP, @@ -17,63 +17,75 @@ enum flexopt_flag_t { OPT_CASE_INSENSITIVE, OPT_COMPRESSION, OPT_CPLUSPLUS, - OPT_DEBUG, OPT_NO_DEBUG, - OPT_DEFAULT, OPT_NO_DEFAULT, + OPT_DEBUG, + OPT_DEFAULT, OPT_DONOTHING, - OPT_ECS, OPT_NO_ECS, + OPT_ECS, OPT_FAST, OPT_FULL, OPT_HEADER, OPT_HELP, OPT_INTERACTIVE, OPT_LEX_COMPAT, - OPT_MAIN, OPT_NO_MAIN, - OPT_META_ECS, OPT_NO_META_ECS, + OPT_MAIN, + OPT_META_ECS, OPT_NEVER_INTERACTIVE, + OPT_NO_ALIGN, + OPT_NO_DEBUG, + OPT_NO_DEFAULT, + OPT_NO_ECS, OPT_NO_LINE, + OPT_NO_MAIN, + OPT_NO_META_ECS, + OPT_NO_REENTRANT, + OPT_NO_REJECT, + OPT_NO_STDINIT, + OPT_NO_UNPUT, + OPT_NO_WARN, + OPT_NO_YYGET_EXTRA, + OPT_NO_YYGET_IN, + OPT_NO_YYGET_LENG, + OPT_NO_YYGET_LINENO, + OPT_NO_YYGET_LLOC, + OPT_NO_YYGET_LVAL, + OPT_NO_YYGET_OUT, + OPT_NO_YYGET_TEXT, + OPT_NO_YYLINENO, + OPT_NO_YYMORE, + OPT_NO_YYSET_EXTRA, + OPT_NO_YYSET_IN, + OPT_NO_YYSET_LINENO, + OPT_NO_YYSET_LLOC, + OPT_NO_YYSET_LVAL, + OPT_NO_YYSET_OUT, + OPT_NO_YYWRAP, + OPT_NO_YY_POP_STATE, + OPT_NO_YY_PUSH_STATE, + OPT_NO_YY_SCAN_BUFFER, + OPT_NO_YY_SCAN_BYTES, + OPT_NO_YY_SCAN_STRING, + OPT_NO_YY_TOP_STATE, OPT_OUTFILE, OPT_PERF_REPORT, OPT_POINTER, OPT_PREFIX, OPT_PREPROCDEFINE, OPT_READ, - OPT_REENTRANT, OPT_NO_REENTRANT, + OPT_REENTRANT, OPT_REENTRANT_BISON, - OPT_REJECT, OPT_NO_REJECT, + OPT_REJECT, OPT_SKEL, OPT_STACK, OPT_STDINIT, OPT_STDOUT, OPT_TRACE, - OPT_UNPUT, OPT_NOUNPUT, OPT_VERBOSE, OPT_VERSION, - OPT_WARN, OPT_NO_WARN, + OPT_WARN, OPT_YYCLASS, - OPT_YYLINENO, OPT_NO_YYLINEO, - OPT_YYMORE, OPT_NO_YYMORE, - OPT_YYWRAP, OPT_NO_YYWRAP, - - OPT_YY_PUSH_STATE, OPT_NO_YY_PUSH_STATE, - OPT_YY_POP_STATE, OPT_NO_YY_POP_STATE, - OPT_YY_TOP_STATE, OPT_NO_YY_TOP_STATE, - OPT_YY_SCAN_BUFFER,OPT_NO_YY_SCAN_BUFFER, - OPT_YY_SCAN_BYTES, OPT_NO_YY_SCAN_BYTES, - OPT_YY_SCAN_STRING,OPT_NO_YY_SCAN_STRING, - OPT_YYGET_EXTRA, OPT_NO_YYGET_EXTRA, - OPT_YYSET_EXTRA, OPT_NO_YYSET_EXTRA, - OPT_YYGET_LENG, OPT_NO_YYGET_LENG, - OPT_YYGET_TEXT, OPT_NO_YYGET_TEXT, - OPT_YYGET_LINENO, OPT_NO_YYGET_LINENO, - OPT_YYSET_LINENO, OPT_NO_YYSET_LINENO, - OPT_YYGET_IN, OPT_NO_YYGET_IN, - OPT_YYSET_IN, OPT_NO_YYSET_IN, - OPT_YYGET_OUT, OPT_NO_YYGET_OUT, - OPT_YYSET_OUT, OPT_NO_YYSET_OUT, - OPT_YYGET_LVAL, OPT_NO_YYGET_LVAL, - OPT_YYSET_LVAL, OPT_NO_YYSET_LVAL, - OPT_YYGET_LLOC, OPT_NO_YYGET_LLOC, - OPT_YYSET_LLOC, OPT_NO_YYSET_LLOC + OPT_YYLINENO, + OPT_YYMORE, + OPT_YYWRAP }; #endif |