From f0161f217e34ca77df2b1e687aa3c3f2d266c00c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 4 Sep 2020 20:19:05 -0400 Subject: Refactoring step - separate output generation from option processing. #1 in the retargeting patch series. --- src/main.c | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/src/main.c b/src/main.c index a4047d7..897caa2 100644 --- a/src/main.c +++ b/src/main.c @@ -44,6 +44,7 @@ static char flex_version[] = FLEX_VERSION; void flexinit(int, char **); void readin(void); +void cpp_prolog(void); void set_up_initial_allocations(void); @@ -169,6 +170,8 @@ int flex_main (int argc, char *argv[]) readin (); + cpp_prolog (); + skelout (); /* %% [1.5] DFA */ ntod (); @@ -1481,10 +1484,6 @@ void flexinit (int argc, char **argv) void readin (void) { - static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; - static char yy_nostdinit[] = - "FILE *yyin = NULL, *yyout = NULL;"; - line_directive_out(NULL, 1); if (yyparse ()) { @@ -1594,10 +1593,45 @@ void readin (void) ("variable trailing context rules cannot be used with -f or -F")); } + if (useecs) + numecs = cre8ecs (nextecm, ecgroup, csize); + else + numecs = csize; + + /* Now map the equivalence class for NUL to its expected place. */ + ecgroup[0] = ecgroup[csize]; + NUL_ec = ABS (ecgroup[0]); + + if (useecs) + ccl2ecl (); +} + +/* cpp_prolog - make rules prolog pecific to cpp-using languages. + * + * If you don't ship this, you will effectively be assuming that your + * parsers are always reentrant, always allow reject, always have a + * yywrap() method, have a debug member in the wrapper class, and are + * interactive. This eliminates most of the boilerplate in the C/C++ + * scanner prolog. It means such parsers will be a bit larger and + * slower than C/C++ ones, but since we're not runing on 1987's + * hardware we officially do not care. + * + * A detail to beware of: If you're not issuing this prologue, you + * may want to issue your own definition of YY_CHAR. It's a typedef + * to an unsigned octet in C/C++, but if your target language has a + * Unicode code-point type like Go's 'rune' is may be appropriate. + */ + +void cpp_prolog (void) +{ + static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; + static char yy_nostdinit[] = + "FILE *yyin = NULL, *yyout = NULL;"; + if (reject){ out_m4_define( "M4_YY_USES_REJECT", NULL); //outn ("\n#define YY_USES_REJECT"); - } + } if (!do_yywrap) { if (!C_plus_plus) { @@ -1718,18 +1752,6 @@ void readin (void) flexerror (_ ("%option yyclass only meaningful for C++ scanners")); } - - if (useecs) - numecs = cre8ecs (nextecm, ecgroup, csize); - else - numecs = csize; - - /* Now map the equivalence class for NUL to its expected place. */ - ecgroup[0] = ecgroup[csize]; - NUL_ec = ABS (ecgroup[0]); - - if (useecs) - ccl2ecl (); } -- cgit v1.2.1 From a05e39ae47294aa2103e2f897f1979f6c7ccbdea Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 5 Sep 2020 07:13:34 -0400 Subject: Factor out the wrap function for C/C++ parser generation. #2 in the retargeting patch series. --- src/main.c | 753 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 380 insertions(+), 373 deletions(-) diff --git a/src/main.c b/src/main.c index 897caa2..2c62c0c 100644 --- a/src/main.c +++ b/src/main.c @@ -45,6 +45,7 @@ static char flex_version[] = FLEX_VERSION; void flexinit(int, char **); void readin(void); void cpp_prolog(void); +void cpp_wrap(void); void set_up_initial_allocations(void); @@ -529,193 +530,7 @@ void flexend (int exit_status) skelname); } -#if 0 - fprintf (header_out, - "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n"); - fprintf (header_out, - "/* Beware! Start conditions are not prefixed. */\n"); - - /* Special case for "INITIAL" */ - fprintf (header_out, - "#undef INITIAL\n#define INITIAL 0\n"); - for (i = 2; i <= lastsc; i++) - fprintf (header_out, "#define %s %d\n", scname[i], i - 1); - fprintf (header_out, - "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); - - /* Kill ALL flex-related macros. This is so the user - * can #include more than one generated header file. */ - fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n"); - fprintf (header_out, - "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n"); - - { - const char * undef_list[] = { - - "BEGIN", - "ECHO", - "EOB_ACT_CONTINUE_SCAN", - "EOB_ACT_END_OF_FILE", - "EOB_ACT_LAST_MATCH", - "FLEX_SCANNER", - "REJECT", - "YYFARGS0", - "YYFARGS1", - "YYFARGS2", - "YYFARGS3", - "YYLMAX", - "YYSTATE", - "YY_AT_BOL", - "YY_BREAK", - "YY_BUFFER_EOF_PENDING", - "YY_BUFFER_NEW", - "YY_BUFFER_NORMAL", - "YY_BUF_SIZE", - "M4_YY_CALL_LAST_ARG", - "M4_YY_CALL_ONLY_ARG", - "YY_CURRENT_BUFFER", - "YY_DECL", - "M4_YY_DECL_LAST_ARG", - "M4_YY_DEF_LAST_ARG", - "M4_YY_DEF_ONLY_ARG", - "YY_DO_BEFORE_ACTION", - "YY_END_OF_BUFFER", - "YY_END_OF_BUFFER_CHAR", - "YY_EXIT_FAILURE", - "YY_EXTRA_TYPE", - "YY_FATAL_ERROR", - "YY_FLEX_DEFINED_ECHO", - "YY_FLEX_LEX_COMPAT", - "YY_FLEX_MAJOR_VERSION", - "YY_FLEX_MINOR_VERSION", - "YY_FLEX_SUBMINOR_VERSION", - "YY_FLUSH_BUFFER", - "YY_G", - "YY_INPUT", - "YY_INTERACTIVE", - "YY_INT_ALIGNED", - "YY_LAST_ARG", - "YY_LESS_LINENO", - "YY_LEX_ARGS", - "YY_LEX_DECLARATION", - "YY_LEX_PROTO", - "YY_MAIN", - "YY_MORE_ADJ", - "YY_NEED_STRLEN", - "YY_NEW_FILE", - "YY_NULL", - "YY_NUM_RULES", - "YY_ONLY_ARG", - "YY_PARAMS", - "YY_PROTO", - "M4_YY_PROTO_LAST_ARG", - "M4_YY_PROTO_ONLY_ARG void", - "YY_READ_BUF_SIZE", - "YY_REENTRANT", - "YY_RESTORE_YY_MORE_OFFSET", - "YY_RULE_SETUP", - "YY_SC_TO_UI", - "YY_SKIP_YYWRAP", - "YY_START", - "YY_START_STACK_INCR", - "YY_STATE_EOF", - "YY_STDINIT", - "YY_TRAILING_HEAD_MASK", - "YY_TRAILING_MASK", - "YY_USER_ACTION", - "YY_USE_CONST", - "YY_USE_PROTOS", - "unput", - "yyTABLES_NAME", - "yy_create_buffer", - "yy_delete_buffer", - "yy_flex_debug", - "yy_flush_buffer", - "yy_init_buffer", - "yy_load_buffer_state", - "yy_new_buffer", - "yy_scan_buffer", - "yy_scan_bytes", - "yy_scan_string", - "yy_set_bol", - "yy_set_interactive", - "yy_switch_to_buffer", - "yypush_buffer_state", - "yypop_buffer_state", - "yyensure_buffer_stack", - "yyalloc", - "const", - "yyextra", - "yyfree", - "yyget_debug", - "yyget_extra", - "yyget_in", - "yyget_leng", - "yyget_column", - "yyget_lineno", - "yyget_lloc", - "yyget_lval", - "yyget_out", - "yyget_text", - "yyin", - "yyleng", - "yyless", - "yylex", - "yylex_destroy", - "yylex_init", - "yylex_init_extra", - "yylineno", - "yylloc", - "yylval", - "yymore", - "yyout", - "yyrealloc", - "yyrestart", - "yyset_debug", - "yyset_extra", - "yyset_in", - "yyset_column", - "yyset_lineno", - "yyset_lloc", - "yyset_lval", - "yyset_out", - "yytables_destroy", - "yytables_fload", - "yyterminate", - "yytext", - "yytext_ptr", - "yywrap", - - /* must be null-terminated */ - NULL}; - - - for (i=0; undef_list[i] != NULL; i++) - fprintf (header_out, "#undef %s\n", undef_list[i]); - } - - /* undef any of the auto-generated symbols. */ - for (i = 0; i < defs_buf.nelts; i++) { - - /* don't undef start conditions */ - if (sclookup (((char **) defs_buf.elts)[i]) > 0) - continue; - fprintf (header_out, "#undef %s\n", - ((char **) defs_buf.elts)[i]); - } - - fprintf (header_out, - "#endif /* !YY_HEADER_NO_UNDEFS */\n"); - fprintf (header_out, "\n"); - fprintf (header_out, "#undef %sIN_HEADER\n", prefix); - fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix); - - if (ferror (header_out)) - lerr (_("error creating header file %s"), - headerfilename); - fflush (header_out); - fclose (header_out); -#endif + cpp_wrap(); if (exit_status != 0 && outfile_created) { if (ferror (stdout)) @@ -1606,201 +1421,52 @@ void readin (void) ccl2ecl (); } -/* cpp_prolog - make rules prolog pecific to cpp-using languages. - * - * If you don't ship this, you will effectively be assuming that your - * parsers are always reentrant, always allow reject, always have a - * yywrap() method, have a debug member in the wrapper class, and are - * interactive. This eliminates most of the boilerplate in the C/C++ - * scanner prolog. It means such parsers will be a bit larger and - * slower than C/C++ ones, but since we're not runing on 1987's - * hardware we officially do not care. - * - * A detail to beware of: If you're not issuing this prologue, you - * may want to issue your own definition of YY_CHAR. It's a typedef - * to an unsigned octet in C/C++, but if your target language has a - * Unicode code-point type like Go's 'rune' is may be appropriate. - */ +/* set_up_initial_allocations - allocate memory for internal tables */ -void cpp_prolog (void) +void set_up_initial_allocations (void) { - static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; - static char yy_nostdinit[] = - "FILE *yyin = NULL, *yyout = NULL;"; - - if (reject){ - out_m4_define( "M4_YY_USES_REJECT", NULL); - //outn ("\n#define YY_USES_REJECT"); - } + maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS); + current_mns = INITIAL_MNS; + firstst = allocate_integer_array (current_mns); + lastst = allocate_integer_array (current_mns); + finalst = allocate_integer_array (current_mns); + transchar = allocate_integer_array (current_mns); + trans1 = allocate_integer_array (current_mns); + trans2 = allocate_integer_array (current_mns); + accptnum = allocate_integer_array (current_mns); + assoc_rule = allocate_integer_array (current_mns); + state_type = allocate_integer_array (current_mns); - if (!do_yywrap) { - if (!C_plus_plus) { - if (reentrant) - out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix); - else - out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix); - } - outn ("#define YY_SKIP_YYWRAP"); - } + current_max_rules = INITIAL_MAX_RULES; + rule_type = allocate_integer_array (current_max_rules); + rule_linenum = allocate_integer_array (current_max_rules); + rule_useful = allocate_integer_array (current_max_rules); + rule_has_nl = allocate_bool_array (current_max_rules); - if (ddebug) - outn ("\n#define FLEX_DEBUG"); + current_max_scs = INITIAL_MAX_SCS; + scset = allocate_integer_array (current_max_scs); + scbol = allocate_integer_array (current_max_scs); + scxclu = allocate_integer_array (current_max_scs); + sceof = allocate_integer_array (current_max_scs); + scname = allocate_char_ptr_array (current_max_scs); - OUT_BEGIN_CODE (); - outn ("typedef flex_uint8_t YY_CHAR;"); - OUT_END_CODE (); + current_maxccls = INITIAL_MAX_CCLS; + cclmap = allocate_integer_array (current_maxccls); + ccllen = allocate_integer_array (current_maxccls); + cclng = allocate_integer_array (current_maxccls); + ccl_has_nl = allocate_bool_array (current_maxccls); - if (C_plus_plus) { - outn ("#define yytext_ptr yytext"); + current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE; + ccltbl = allocate_Character_array (current_max_ccl_tbl_size); - if (interactive) - outn ("#define YY_INTERACTIVE"); - } + current_max_dfa_size = INITIAL_MAX_DFA_SIZE; - else { - OUT_BEGIN_CODE (); - /* In reentrant scanner, stdinit is handled in flex.skl. */ - if (do_stdinit) { - if (reentrant){ - outn ("#ifdef VMS"); - outn ("#ifdef __VMS_POSIX"); - outn ("#define YY_STDINIT"); - outn ("#endif"); - outn ("#else"); - outn ("#define YY_STDINIT"); - outn ("#endif"); - } + current_max_xpairs = INITIAL_MAX_XPAIRS; + nxt = allocate_integer_array (current_max_xpairs); + chk = allocate_integer_array (current_max_xpairs); - outn ("#ifdef VMS"); - outn ("#ifndef __VMS_POSIX"); - outn (yy_nostdinit); - outn ("#else"); - outn (yy_stdinit); - outn ("#endif"); - outn ("#else"); - outn (yy_stdinit); - outn ("#endif"); - } - - else { - if(!reentrant) - outn (yy_nostdinit); - } - OUT_END_CODE (); - } - - OUT_BEGIN_CODE (); - if (fullspd) - outn ("typedef const struct yy_trans_info *yy_state_type;"); - else if (!C_plus_plus) - outn ("typedef int yy_state_type;"); - OUT_END_CODE (); - - if (lex_compat) - outn ("#define YY_FLEX_LEX_COMPAT"); - - if (!C_plus_plus && !reentrant) { - outn ("extern int yylineno;"); - OUT_BEGIN_CODE (); - outn ("int yylineno = 1;"); - OUT_END_CODE (); - } - - if (C_plus_plus) { - outn ("\n#include "); - - if (!do_yywrap) { - outn("\nint yyFlexLexer::yywrap() { return 1; }"); - } - - if (yyclass) { - outn ("int yyFlexLexer::yylex()"); - outn ("\t{"); - outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );"); - outn ("\treturn 0;"); - outn ("\t}"); - - out_str ("\n#define YY_DECL int %s::yylex()\n", - yyclass); - } - } - - else { - - /* Watch out: yytext_ptr is a variable when yytext is an array, - * but it's a macro when yytext is a pointer. - */ - if (yytext_is_array) { - if (!reentrant) - outn ("extern char yytext[];\n"); - } - else { - if (reentrant) { - outn ("#define yytext_ptr yytext_r"); - } - else { - outn ("extern char *yytext;"); - - outn("#ifdef yytext_ptr"); - outn("#undef yytext_ptr"); - outn("#endif"); - outn ("#define yytext_ptr yytext"); - } - } - - if (yyclass) - flexerror (_ - ("%option yyclass only meaningful for C++ scanners")); - } -} - - -/* set_up_initial_allocations - allocate memory for internal tables */ - -void set_up_initial_allocations (void) -{ - maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS); - current_mns = INITIAL_MNS; - firstst = allocate_integer_array (current_mns); - lastst = allocate_integer_array (current_mns); - finalst = allocate_integer_array (current_mns); - transchar = allocate_integer_array (current_mns); - trans1 = allocate_integer_array (current_mns); - trans2 = allocate_integer_array (current_mns); - accptnum = allocate_integer_array (current_mns); - assoc_rule = allocate_integer_array (current_mns); - state_type = allocate_integer_array (current_mns); - - current_max_rules = INITIAL_MAX_RULES; - rule_type = allocate_integer_array (current_max_rules); - rule_linenum = allocate_integer_array (current_max_rules); - rule_useful = allocate_integer_array (current_max_rules); - rule_has_nl = allocate_bool_array (current_max_rules); - - current_max_scs = INITIAL_MAX_SCS; - scset = allocate_integer_array (current_max_scs); - scbol = allocate_integer_array (current_max_scs); - scxclu = allocate_integer_array (current_max_scs); - sceof = allocate_integer_array (current_max_scs); - scname = allocate_char_ptr_array (current_max_scs); - - current_maxccls = INITIAL_MAX_CCLS; - cclmap = allocate_integer_array (current_maxccls); - ccllen = allocate_integer_array (current_maxccls); - cclng = allocate_integer_array (current_maxccls); - ccl_has_nl = allocate_bool_array (current_maxccls); - - current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE; - ccltbl = allocate_Character_array (current_max_ccl_tbl_size); - - current_max_dfa_size = INITIAL_MAX_DFA_SIZE; - - current_max_xpairs = INITIAL_MAX_XPAIRS; - nxt = allocate_integer_array (current_max_xpairs); - chk = allocate_integer_array (current_max_xpairs); - - current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS; - tnxt = allocate_integer_array (current_max_template_xpairs); + current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS; + tnxt = allocate_integer_array (current_max_template_xpairs); current_max_dfas = INITIAL_MAX_DFAS; base = allocate_integer_array (current_max_dfas); @@ -1885,3 +1551,344 @@ void usage (void) backing_name, "flex", outfile_path, "flex"); } + +/* Code specific to the C/C++ back end starts here */ + +/* cpp_prolog - make rules prolog pecific to cpp-using languages. + * + * If you don't ship this, you will effectively be assuming that your + * parsers are always reentrant, always allow reject, always have a + * yywrap() method, have a debug member in the wrapper class, and are + * interactive. This eliminates most of the boilerplate in the C/C++ + * scanner prolog. It means such parsers will be a bit larger and + * slower than C/C++ ones, but since we're not runing on 1987's + * hardware we officially do not care. + * + * A detail to beware of: If you're not issuing this prologue, you + * may want to issue your own definition of YY_CHAR. It's a typedef + * to an unsigned octet in C/C++, but if your target language has a + * Unicode code-point type like Go's 'rune' is may be appropriate. + */ + +void cpp_prolog (void) +{ + static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; + static char yy_nostdinit[] = + "FILE *yyin = NULL, *yyout = NULL;"; + + if (reject){ + out_m4_define( "M4_YY_USES_REJECT", NULL); + //outn ("\n#define YY_USES_REJECT"); + } + + if (!do_yywrap) { + if (!C_plus_plus) { + if (reentrant) + out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix); + else + out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix); + } + outn ("#define YY_SKIP_YYWRAP"); + } + + if (ddebug) + outn ("\n#define FLEX_DEBUG"); + + OUT_BEGIN_CODE (); + outn ("typedef flex_uint8_t YY_CHAR;"); + OUT_END_CODE (); + + if (C_plus_plus) { + outn ("#define yytext_ptr yytext"); + + if (interactive) + outn ("#define YY_INTERACTIVE"); + } + + else { + OUT_BEGIN_CODE (); + /* In reentrant scanner, stdinit is handled in flex.skl. */ + if (do_stdinit) { + if (reentrant){ + outn ("#ifdef VMS"); + outn ("#ifdef __VMS_POSIX"); + outn ("#define YY_STDINIT"); + outn ("#endif"); + outn ("#else"); + outn ("#define YY_STDINIT"); + outn ("#endif"); + } + + outn ("#ifdef VMS"); + outn ("#ifndef __VMS_POSIX"); + outn (yy_nostdinit); + outn ("#else"); + outn (yy_stdinit); + outn ("#endif"); + outn ("#else"); + outn (yy_stdinit); + outn ("#endif"); + } + + else { + if(!reentrant) + outn (yy_nostdinit); + } + OUT_END_CODE (); + } + + OUT_BEGIN_CODE (); + if (fullspd) + outn ("typedef const struct yy_trans_info *yy_state_type;"); + else if (!C_plus_plus) + outn ("typedef int yy_state_type;"); + OUT_END_CODE (); + + if (lex_compat) + outn ("#define YY_FLEX_LEX_COMPAT"); + + if (!C_plus_plus && !reentrant) { + outn ("extern int yylineno;"); + OUT_BEGIN_CODE (); + outn ("int yylineno = 1;"); + OUT_END_CODE (); + } + + if (C_plus_plus) { + outn ("\n#include "); + + if (!do_yywrap) { + outn("\nint yyFlexLexer::yywrap() { return 1; }"); + } + + if (yyclass) { + outn ("int yyFlexLexer::yylex()"); + outn ("\t{"); + outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );"); + outn ("\treturn 0;"); + outn ("\t}"); + + out_str ("\n#define YY_DECL int %s::yylex()\n", + yyclass); + } + } + + else { + + /* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ + if (yytext_is_array) { + if (!reentrant) + outn ("extern char yytext[];\n"); + } + else { + if (reentrant) { + outn ("#define yytext_ptr yytext_r"); + } + else { + outn ("extern char *yytext;"); + + outn("#ifdef yytext_ptr"); + outn("#undef yytext_ptr"); + outn("#endif"); + outn ("#define yytext_ptr yytext"); + } + } + + if (yyclass) + flexerror (_ + ("%option yyclass only meaningful for C++ scanners")); + } +} + +void cpp_wrap (void) +{ +#if 0 + fprintf (header_out, + "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n"); + fprintf (header_out, + "/* Beware! Start conditions are not prefixed. */\n"); + + /* Special case for "INITIAL" */ + fprintf (header_out, + "#undef INITIAL\n#define INITIAL 0\n"); + for (i = 2; i <= lastsc; i++) + fprintf (header_out, "#define %s %d\n", scname[i], i - 1); + fprintf (header_out, + "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); + + /* Kill ALL flex-related macros. This is so the user + * can #include more than one generated header file. */ + fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n"); + fprintf (header_out, + "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n"); + + { + const char * undef_list[] = { + + "BEGIN", + "ECHO", + "EOB_ACT_CONTINUE_SCAN", + "EOB_ACT_END_OF_FILE", + "EOB_ACT_LAST_MATCH", + "FLEX_SCANNER", + "REJECT", + "YYFARGS0", + "YYFARGS1", + "YYFARGS2", + "YYFARGS3", + "YYLMAX", + "YYSTATE", + "YY_AT_BOL", + "YY_BREAK", + "YY_BUFFER_EOF_PENDING", + "YY_BUFFER_NEW", + "YY_BUFFER_NORMAL", + "YY_BUF_SIZE", + "M4_YY_CALL_LAST_ARG", + "M4_YY_CALL_ONLY_ARG", + "YY_CURRENT_BUFFER", + "YY_DECL", + "M4_YY_DECL_LAST_ARG", + "M4_YY_DEF_LAST_ARG", + "M4_YY_DEF_ONLY_ARG", + "YY_DO_BEFORE_ACTION", + "YY_END_OF_BUFFER", + "YY_END_OF_BUFFER_CHAR", + "YY_EXIT_FAILURE", + "YY_EXTRA_TYPE", + "YY_FATAL_ERROR", + "YY_FLEX_DEFINED_ECHO", + "YY_FLEX_LEX_COMPAT", + "YY_FLEX_MAJOR_VERSION", + "YY_FLEX_MINOR_VERSION", + "YY_FLEX_SUBMINOR_VERSION", + "YY_FLUSH_BUFFER", + "YY_G", + "YY_INPUT", + "YY_INTERACTIVE", + "YY_INT_ALIGNED", + "YY_LAST_ARG", + "YY_LESS_LINENO", + "YY_LEX_ARGS", + "YY_LEX_DECLARATION", + "YY_LEX_PROTO", + "YY_MAIN", + "YY_MORE_ADJ", + "YY_NEED_STRLEN", + "YY_NEW_FILE", + "YY_NULL", + "YY_NUM_RULES", + "YY_ONLY_ARG", + "YY_PARAMS", + "YY_PROTO", + "M4_YY_PROTO_LAST_ARG", + "M4_YY_PROTO_ONLY_ARG void", + "YY_READ_BUF_SIZE", + "YY_REENTRANT", + "YY_RESTORE_YY_MORE_OFFSET", + "YY_RULE_SETUP", + "YY_SC_TO_UI", + "YY_SKIP_YYWRAP", + "YY_START", + "YY_START_STACK_INCR", + "YY_STATE_EOF", + "YY_STDINIT", + "YY_TRAILING_HEAD_MASK", + "YY_TRAILING_MASK", + "YY_USER_ACTION", + "YY_USE_CONST", + "YY_USE_PROTOS", + "unput", + "yyTABLES_NAME", + "yy_create_buffer", + "yy_delete_buffer", + "yy_flex_debug", + "yy_flush_buffer", + "yy_init_buffer", + "yy_load_buffer_state", + "yy_new_buffer", + "yy_scan_buffer", + "yy_scan_bytes", + "yy_scan_string", + "yy_set_bol", + "yy_set_interactive", + "yy_switch_to_buffer", + "yypush_buffer_state", + "yypop_buffer_state", + "yyensure_buffer_stack", + "yyalloc", + "const", + "yyextra", + "yyfree", + "yyget_debug", + "yyget_extra", + "yyget_in", + "yyget_leng", + "yyget_column", + "yyget_lineno", + "yyget_lloc", + "yyget_lval", + "yyget_out", + "yyget_text", + "yyin", + "yyleng", + "yyless", + "yylex", + "yylex_destroy", + "yylex_init", + "yylex_init_extra", + "yylineno", + "yylloc", + "yylval", + "yymore", + "yyout", + "yyrealloc", + "yyrestart", + "yyset_debug", + "yyset_extra", + "yyset_in", + "yyset_column", + "yyset_lineno", + "yyset_lloc", + "yyset_lval", + "yyset_out", + "yytables_destroy", + "yytables_fload", + "yyterminate", + "yytext", + "yytext_ptr", + "yywrap", + + /* must be null-terminated */ + NULL}; + + + for (i=0; undef_list[i] != NULL; i++) + fprintf (header_out, "#undef %s\n", undef_list[i]); + } + + /* undef any of the auto-generated symbols. */ + for (i = 0; i < defs_buf.nelts; i++) { + + /* don't undef start conditions */ + if (sclookup (((char **) defs_buf.elts)[i]) > 0) + continue; + fprintf (header_out, "#undef %s\n", + ((char **) defs_buf.elts)[i]); + } + + fprintf (header_out, + "#endif /* !YY_HEADER_NO_UNDEFS */\n"); + fprintf (header_out, "\n"); + fprintf (header_out, "#undef %sIN_HEADER\n", prefix); + fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix); + + if (ferror (header_out)) + lerr (_("error creating header file %s"), + headerfilename); + fflush (header_out); + fclose (header_out); +#endif +} -- cgit v1.2.1 From f1bfe65b3dc2813bdc86e27ce3d03910d949ce93 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 5 Sep 2020 07:15:05 -0400 Subject: Create a method table for the C back end, #3 in the retargeting patch series. --- src/flexdef.h | 8 ++++++++ src/main.c | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/flexdef.h b/src/flexdef.h index a48c64d..cedf56e 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -303,6 +303,12 @@ */ #define MAX_SHORT 32700 +/* Method table describing a language-specific back end */ + +struct flex_backend_t { + void (*prolog)(void); + void (*wrap)(void); +}; /* Declarations for global variables. */ @@ -369,6 +375,8 @@ extern int yymore_used, reject, real_reject, continued_action, in_rule; extern int yymore_really_used, reject_really_used; extern int trace_hex; +extern struct flex_backend_t *backend; + /* Variables used in the flex input routines: * datapos - characters on current output line * dataline - number of contiguous lines of data in current data diff --git a/src/main.c b/src/main.c index 2c62c0c..d6e99b2 100644 --- a/src/main.c +++ b/src/main.c @@ -44,10 +44,9 @@ static char flex_version[] = FLEX_VERSION; void flexinit(int, char **); void readin(void); -void cpp_prolog(void); -void cpp_wrap(void); void set_up_initial_allocations(void); +extern struct flex_backend_t cpp_backend; /* these globals are all defined and commented in flexdef.h */ int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; @@ -109,6 +108,8 @@ jmp_buf flex_main_jmp_buf; bool *rule_has_nl, *ccl_has_nl; int nlch = '\n'; +struct flex_backend_t *backend; + bool tablesext, tablesverify, gentables; char *tablesfilename=0,*tablesname=0; struct yytbl_writer tableswr; @@ -171,7 +172,7 @@ int flex_main (int argc, char *argv[]) readin (); - cpp_prolog (); + backend->prolog (); skelout (); /* %% [1.5] DFA */ @@ -530,7 +531,7 @@ void flexend (int exit_status) skelname); } - cpp_wrap(); + backend->wrap(); if (exit_status != 0 && outfile_created) { if (ferror (stdout)) @@ -1292,6 +1293,8 @@ void flexinit (int argc, char **argv) lastprot = 1; set_up_initial_allocations (); + + backend = &cpp_backend; } @@ -1570,7 +1573,7 @@ void usage (void) * Unicode code-point type like Go's 'rune' is may be appropriate. */ -void cpp_prolog (void) +static void cpp_prolog (void) { static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; static char yy_nostdinit[] = @@ -1702,7 +1705,7 @@ void cpp_prolog (void) } } -void cpp_wrap (void) +static void cpp_wrap (void) { #if 0 fprintf (header_out, @@ -1892,3 +1895,8 @@ void cpp_wrap (void) fclose (header_out); #endif } + +struct flex_backend_t cpp_backend = { + .prolog = cpp_prolog, + .wrap = cpp_wrap, +}; -- cgit v1.2.1 From f754c608ff6e5ffdb8b1fc3893bb7573c8b6f734 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 5 Sep 2020 08:04:46 -0400 Subject: Pull the format for error-tracking lines into the method table. #4 in the retargeting patch series. --- src/flexdef.h | 1 + src/main.c | 1 + src/misc.c | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/flexdef.h b/src/flexdef.h index cedf56e..a0fb522 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -308,6 +308,7 @@ struct flex_backend_t { void (*prolog)(void); void (*wrap)(void); + char *line_fmt; }; /* Declarations for global variables. */ diff --git a/src/main.c b/src/main.c index d6e99b2..85df365 100644 --- a/src/main.c +++ b/src/main.c @@ -1899,4 +1899,5 @@ static void cpp_wrap (void) struct flex_backend_t cpp_backend = { .prolog = cpp_prolog, .wrap = cpp_wrap, + .line_fmt = "#line %d \"%s\"\n", }; diff --git a/src/misc.c b/src/misc.c index 5e63291..f6dae41 100644 --- a/src/misc.c +++ b/src/misc.c @@ -343,7 +343,6 @@ void line_directive_out (FILE *output_file, int do_infile) { char directive[MAXLINE], filename[MAXLINE]; char *s1, *s2, *s3; - static const char line_fmt[] = "#line %d \"%s\"\n"; if (!gen_line_dirs) return; @@ -367,9 +366,9 @@ void line_directive_out (FILE *output_file, int do_infile) *s2 = '\0'; if (do_infile) - snprintf (directive, sizeof(directive), line_fmt, linenum, filename); + snprintf (directive, sizeof(directive), backend->line_fmt, linenum, filename); else { - snprintf (directive, sizeof(directive), line_fmt, 0, filename); + snprintf (directive, sizeof(directive), backend->line_fmt, 0, filename); } /* If output_file is nil then we should put the directive in -- cgit v1.2.1 From bb9f458eb18e32921b754c35415e09f08aaf8272 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 5 Sep 2020 10:16:25 -0400 Subject: Generated skel data is now stuffed in an array in the C/C++ back end. This means it's possible to have multiple language-specific skel files. All go through the same double m4 macroexpansion. #5 in the retargeting patch series --- doc/Makefile.am | 2 +- doc/flex.texi | 1 + src/.gitignore | 2 +- src/Makefile.am | 10 +- src/cpp-flex.skl | 3444 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/flex.skl | 3443 ----------------------------------------------------- src/flexdef.h | 1 + src/main.c | 6 + src/misc.c | 4 +- src/mkskel.sh | 21 +- 10 files changed, 3468 insertions(+), 3466 deletions(-) create mode 100644 src/cpp-flex.skl delete mode 100644 src/flex.skl diff --git a/doc/Makefile.am b/doc/Makefile.am index 523aa97..4d15da7 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -7,7 +7,7 @@ MAINTAINERCLEANFILES = flex.1 CLEANFILES = *.aux *.cp *.cps *.fn *.fns *.hk *.hks *.ky *.log \ *.op *.ops *.pg *.toc *.tp *.tps *.vr *.vrs -flex.1: $(top_srcdir)/configure.ac $(top_srcdir)/src/flex.skl $(top_srcdir)/src/options.c $(top_srcdir)/src/options.h | $(FLEX) +flex.1: $(top_srcdir)/configure.ac $(top_srcdir)/src/cpp-flex.skl $(top_srcdir)/src/options.c $(top_srcdir)/src/options.h | $(FLEX) $(HELP2MAN) --name='$(PACKAGE_NAME)' --section=1 \ --source='The Flex Project' --manual='Programming' \ --output=$@ $(FLEX) \ diff --git a/doc/flex.texi b/doc/flex.texi index 9087622..e814acd 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -7697,6 +7697,7 @@ to declare local variables. @end example @c TODO: Evaluate this faq. +@c Note that the file is now named cpp-flex.skl @node unnamed-faq-87 @unnumberedsec unnamed-faq-87 @example diff --git a/src/.gitignore b/src/.gitignore index 7f35139..5e792d7 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -8,6 +8,6 @@ libfl.pc parse.c parse.h scan.c -skel.c +cpp-skel.h stage1scan.[cl] stage1flex diff --git a/src/Makefile.am b/src/Makefile.am index e033cc8..7d70538 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,6 +53,7 @@ flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS) COMMON_SOURCES = \ buf.c \ ccl.c \ + cpp_skel.h \ dfa.c \ ecs.c \ filter.c \ @@ -70,7 +71,6 @@ COMMON_SOURCES = \ scanflags.c \ scanopt.c \ scanopt.h \ - skel.c \ sym.c \ tables.c \ tables.h \ @@ -88,16 +88,16 @@ include_HEADERS = \ FlexLexer.h EXTRA_DIST = \ - flex.skl \ + cpp-flex.skl \ mkskel.sh \ gettext.h CLEANFILES = stage1scan.c stage1flex$(EXEEXT) -MAINTAINERCLEANFILES = skel.c +MAINTAINERCLEANFILES = c9pp-skel.h -skel.c: flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c - $(SHELL) $(srcdir)/mkskel.sh $(srcdir) $(m4) $(VERSION) > $@.tmp +cpp-skel.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c + $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp mv -f $@.tmp $@ if ENABLE_BOOTSTRAP diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl new file mode 100644 index 0000000..4106985 --- /dev/null +++ b/src/cpp-flex.skl @@ -0,0 +1,3444 @@ +%# -*-C-*- vi: set ft=c: +%# This file is processed in several stages. +%# Here are the stages, as best as I can describe: +%# +%# 1. This is processed through GNU m4 during the +%# pre-compilation stage of flex. Only macros starting +%# with `m4preproc_' are processed, and quoting is normal. +%# +%# 2. The preprocessed skeleton is translated into a comma-separated +%# list of doublequoted strings which is stuffed into a language- +%# specific method block compiled into the flex binary. The %# comment +%# lines are removed. +%# +%# 3. At runtime, the skeleton is generated and filtered (again) +%# through m4. Macros beginning with `m4_' will be processed. +%# The quoting is "[[" and "]]" so we don't interfere with +%# user code. +%# +%# All generated macros for the m4 stage contain the text "m4" or "M4" +%# in them. This is to distinguish them from CPP macros. +%# The exception to this rule is YY_G, which is an m4 macro, +%# but it needs to be remain short because it is used everywhere. +%# +/* A lexical scanner generated by flex */ + +%# Macros for preproc stage. +m4preproc_changecom + +%# Macros for runtime processing stage. +m4_changecom +m4_changequote +m4_changequote([[, ]]) + +%# +%# Lines in this skeleton starting with a "%" character are "control lines" +%# and affect the generation of the scanner. The possible control codes are +%# listed and processed in misc.c. +%# +%# %# - A comment. The current line is omitted from the generated scanner. +%# %if-c++-only - The following lines are printed for C++ scanners ONLY. +%# %if-c-only - The following lines are NOT printed for C++ scanners. +%# %if-c-or-c++ - The following lines are printed in BOTH C and C++ scanners. +%# %if-reentrant - Print for reentrant scanners.(push) +%# %if-not-reentrant - Print for non-reentrant scanners. (push) +%# %if-bison-bridge - Print for bison-bridge. (push) +%# %if-not-bison-bridge - Print for non-bison-bridge. (push) +%# %endif - pop from the previous if code. +%# %% - A stop-point, where code is inserted by flex. +%# Each stop-point is numbered here and also in the code generator. +%# (See gen.c, etc. for details.) +%# %not-for-header - Begin code that should NOT appear in a ".h" file. +%# %ok-for-header - %c and %e are used for building a header file. +%# %if-tables-serialization +%# +%# All control-lines EXCEPT comment lines ("%#") will be inserted into +%# the generated scanner as a C-style comment. This is to aid those who +%# edit the skeleton. +%# + +%not-for-header +%if-c-only +%if-not-reentrant +m4_ifelse(M4_YY_PREFIX,yy,, +#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]] +#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]] +#define yy_scan_buffer M4_YY_PREFIX[[_scan_buffer]] +#define yy_scan_string M4_YY_PREFIX[[_scan_string]] +#define yy_scan_bytes M4_YY_PREFIX[[_scan_bytes]] +#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]] +#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]] +#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]] +#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]] +#define yypush_buffer_state M4_YY_PREFIX[[push_buffer_state]] +#define yypop_buffer_state M4_YY_PREFIX[[pop_buffer_state]] +#define yyensure_buffer_stack M4_YY_PREFIX[[ensure_buffer_stack]] +#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]] +#define yyin M4_YY_PREFIX[[in]] +#define yyleng M4_YY_PREFIX[[leng]] +#define yylex M4_YY_PREFIX[[lex]] +#define yylineno M4_YY_PREFIX[[lineno]] +#define yyout M4_YY_PREFIX[[out]] +#define yyrestart M4_YY_PREFIX[[restart]] +#define yytext M4_YY_PREFIX[[text]] +#define yywrap M4_YY_PREFIX[[wrap]] +#define yyalloc M4_YY_PREFIX[[alloc]] +#define yyrealloc M4_YY_PREFIX[[realloc]] +#define yyfree M4_YY_PREFIX[[free]] +) +%endif +%endif +%ok-for-header + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION +#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION +#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +%# Some negated symbols +m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) +m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) + +%# This is the m4 way to say "(stack_used || is_reentrant) +m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) +m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) + +%# Prefixes. +%# The complexity here is necessary so that m4 preserves +%# the argument lists to each C function. + + +m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]]) + +m4preproc_define(`M4_GEN_PREFIX',`` +[[#ifdef yy$1 +#define ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED +#else +#define yy$1 ]]M4_YY_PREFIX[[$1 +#endif]] +'m4preproc_divert(1)` +[[#ifndef ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED +#undef yy$1 +#endif]]'m4preproc_divert(0)') + +%if-c++-only + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]] +%endif + +%if-c-only +m4_ifelse(M4_YY_PREFIX,yy,, + M4_GEN_PREFIX(`_create_buffer') + M4_GEN_PREFIX(`_delete_buffer') + M4_GEN_PREFIX(`_scan_buffer') + M4_GEN_PREFIX(`_scan_string') + M4_GEN_PREFIX(`_scan_bytes') + M4_GEN_PREFIX(`_init_buffer') + M4_GEN_PREFIX(`_flush_buffer') + M4_GEN_PREFIX(`_load_buffer_state') + M4_GEN_PREFIX(`_switch_to_buffer') + M4_GEN_PREFIX(`push_buffer_state') + M4_GEN_PREFIX(`pop_buffer_state') + M4_GEN_PREFIX(`ensure_buffer_stack') + M4_GEN_PREFIX(`lex') + M4_GEN_PREFIX(`restart') + M4_GEN_PREFIX(`lex_init') + M4_GEN_PREFIX(`lex_init_extra') + M4_GEN_PREFIX(`lex_destroy') + M4_GEN_PREFIX(`get_debug') + M4_GEN_PREFIX(`set_debug') + M4_GEN_PREFIX(`get_extra') + M4_GEN_PREFIX(`set_extra') + M4_GEN_PREFIX(`get_in') + M4_GEN_PREFIX(`set_in') + M4_GEN_PREFIX(`get_out') + M4_GEN_PREFIX(`set_out') + M4_GEN_PREFIX(`get_leng') + M4_GEN_PREFIX(`get_text') + M4_GEN_PREFIX(`get_lineno') + M4_GEN_PREFIX(`set_lineno') + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + M4_GEN_PREFIX(`get_column') + M4_GEN_PREFIX(`set_column') + ]]) + M4_GEN_PREFIX(`wrap') +) +%endif + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + M4_GEN_PREFIX(`get_lval') + M4_GEN_PREFIX(`set_lval') +]]) + +m4_ifdef( [[]], +[[ + M4_GEN_PREFIX(`get_lloc') + M4_GEN_PREFIX(`set_lloc') +]]) + + +m4_ifelse(M4_YY_PREFIX,yy,, + M4_GEN_PREFIX(`alloc') + M4_GEN_PREFIX(`realloc') + M4_GEN_PREFIX(`free') +) + +%if-c-only +m4_ifelse(M4_YY_PREFIX,yy,, +m4_ifdef( [[M4_YY_NOT_REENTRANT]], +[[ + M4_GEN_PREFIX(`text') + M4_GEN_PREFIX(`leng') + M4_GEN_PREFIX(`in') + M4_GEN_PREFIX(`out') + M4_GEN_PREFIX(`_flex_debug') + M4_GEN_PREFIX(`lineno') +]]) +) +%endif + + +m4_ifdef( [[M4_YY_TABLES_EXTERNAL]], +[[ + M4_GEN_PREFIX(`tables_fload') + M4_GEN_PREFIX(`tables_destroy') + M4_GEN_PREFIX(`TABLES_NAME') +]]) + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +%if-c-only +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , +[[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , +[[/* Feature test macros. Flex uses functions that require a minimum set of + * macros defined. As defining some macros may hide function declarations that + * user code might use, be conservative and respect user's definitions as much + * as possible. In glibc, feature test macros may not be all set up until one + * of the libc header (that includes ) is included. This creates + * a circular dependency when we check the macros. is the safest + * header we can include and does not declare too many functions we don't need. + */ +#if !defined(__GNU_LIBRARY__) && defined(__STDC__) +#include +#endif +#if !(defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_POSIX_SOURCE)) +# define _POSIX_C_SOURCE 1 /* Required for fileno() */ +# define _POSIX_SOURCE 1 +#endif]])]]) +#include +#include +#include +#include +%endif + +%if-tables-serialization +#include +#include +%endif +/* end standard C headers. */ + +/* begin standard C++ headers. */ +%if-c++-only +#include +#include +#include +#include +#include +/* end standard C++ headers. */ +%endif + +%if-c-or-c++ +m4preproc_include(`flexint_shared.h') +%endif + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +%not-for-header +/* Returned upon end-of-file. */ +#define YY_NULL 0 +%ok-for-header + +%not-for-header +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) +%ok-for-header + + + +%if-reentrant + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +%# Declare yyguts variable +m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]]) +%# Perform a noop access on yyguts to prevent unused variable complains +m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[(void)yyg]]) +%# For use wherever a Global is accessed or assigned. +m4_define( [[YY_G]], [[yyg->$1]]) + +%# For use in function prototypes to append the additional argument. +m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]]) +m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]]) + +m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]]) +m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]]) +m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]]) + +%# For use in function calls to pass the additional argument. +m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]]) +m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]]) + +%# For use in function documentation to adjust for additional argument. +m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin YY_G(yyin_r) +#define yyout YY_G(yyout_r) +#define yyextra YY_G(yyextra_r) +#define yyleng YY_G(yyleng_r) +#define yytext YY_G(yytext_r) +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug YY_G(yy_flex_debug_r) + +m4_define( [[M4_YY_INCR_LINENO]], +[[ + do{ yylineno++; + yycolumn=0; + }while(0) +]]) + +%endif + + + +%if-not-reentrant + +m4_define( [[M4_YY_INCR_LINENO]], +[[ + yylineno++; +]]) + +%# Define these macros to be no-ops. +m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]]) +m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[m4_dnl]]) +m4_define( [[YY_G]], [[($1)]]) +m4_define( [[M4_YY_PROTO_LAST_ARG]]) +m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]]) +m4_define( [[M4_YY_DEF_LAST_ARG]]) + +m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]]) +m4_define([[M4_YY_DECL_LAST_ARG]]) +m4_define([[M4_YY_CALL_LAST_ARG]]) +m4_define([[M4_YY_CALL_ONLY_ARG]]) +m4_define( [[M4_YY_DOC_PARAM]], ) + +%endif + + +%# Generate C99 function defs. +m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]]) +m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]]) +m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN YY_G(yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((YY_G(yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG ) +#define YY_END_OF_BUFFER_CHAR 0 +]]) + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) +]]) + + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +%if-not-reentrant +extern int yyleng; +%endif + +%if-c-only +%if-not-reentrant +extern FILE *yyin, *yyout; +%endif +%endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + m4_ifdef( [[M4_YY_USE_LINENO]], + [[ + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + #define YY_LINENO_REWIND_TO(dst) \ + do {\ + const char *p;\ + for ( p = yy_cp-1; p >= (dst); --p)\ + if ( *p == '\n' )\ + --yylineno;\ + }while(0) + ]], + [[ + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + ]]) +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = YY_G(yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) +]]) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { +%if-c-only + FILE *yy_input_file; +%endif + +%if-c++-only + std::streambuf* yy_input_file; +%endif + + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 +]]) + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +%if-c-only Standard (non-C++) definition +%not-for-header +%if-not-reentrant + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ +%endif +%ok-for-header +%endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \ + ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] +]]) + +%if-c-only Standard (non-C++) definition + +%if-not-reentrant +%not-for-header +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; +%ok-for-header +%endif + +void yyrestart ( FILE *input_file M4_YY_PROTO_LAST_ARG ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size M4_YY_PROTO_LAST_ARG ); +void yy_delete_buffer ( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); +void yy_flush_buffer ( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); +void yypop_buffer_state ( M4_YY_PROTO_ONLY_ARG ); + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +static void yyensure_buffer_stack ( M4_YY_PROTO_ONLY_ARG ); +static void yy_load_buffer_state ( M4_YY_PROTO_ONLY_ARG ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG) +]]) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); + +%endif + +void *yyalloc ( yy_size_t M4_YY_PROTO_LAST_ARG ); +void *yyrealloc ( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); +void yyfree ( void * M4_YY_PROTO_LAST_ARG ); + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +]]) + +%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +%% [1.5] DFA +]]) + +%if-c-only Standard (non-C++) definition + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG); +static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); +static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); +]]) + +%endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + YY_G(yytext_ptr) = yy_bp; \ +%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ + YY_G(yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ +%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ + YY_G(yy_c_buf_p) = yy_cp; +%% [4.0] data tables for the DFA and the user's section 1 definitions go here +]]) + +m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) +M4_YY_SC_DEFS +m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) + +m4_ifdef( [[M4_YY_NO_UNISTD_H]],, +[[ +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +%if-c-only +#include +%endif +%if-c++-only +#include +%endif +#endif +]]) + +m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], +[[ +#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS +]], +[[ +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif +]] +) + +%if-c-only Reentrant structure and macros (non-C++). +%if-reentrant + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + +m4_ifdef( [[M4_YY_USES_REJECT]], +[[ + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; + + /* These are only needed for trailing context rules, + * but there's no conditional variable for that yet. */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; +]]) + +m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], +[[ + char yytext_r[YYLMAX]; + char *yytext_ptr; + int yy_more_offset; + int yy_prev_more_offset; +]], +[[ + char *yytext_r; + int yy_more_flag; + int yy_more_len; +]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + YYSTYPE * yylval_r; +]]) + +m4_ifdef( [[]], +[[ + YYLTYPE * yylloc_r; +]]) + + }; /* end struct yyguts_t */ +]]) + + +%if-c-only +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +static int yy_init_globals ( M4_YY_PROTO_ONLY_ARG ); +]]) +%endif + +%if-reentrant + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ + m4_ifdef( [[M4_YY_BISON_LVAL]], + [[ + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval YY_G(yylval_r) + ]]) + + m4_ifdef( [[]], + [[ + # define yylloc YY_G(yylloc_r) + ]]) +]]) + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +%endif + +%endif End reentrant structures and macros. + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +m4_ifdef( [[M4_YY_NO_DESTROY]],, +[[ +int yylex_destroy ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +[[ +int yyget_debug ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +[[ +void yyset_debug ( int debug_flag M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, +[[ +YY_EXTRA_TYPE yyget_extra ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +[[ +void yyset_extra ( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_IN]],, +[[ +FILE *yyget_in ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_IN]],, +[[ +void yyset_in ( FILE * _in_str M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_OUT]],, +[[ +FILE *yyget_out ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_OUT]],, +[[ +void yyset_out ( FILE * _out_str M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_LENG]],, +[[ + int yyget_leng ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +[[ +char *yyget_text ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_LINENO]],, +[[ +int yyget_lineno ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +[[ +void yyset_lineno ( int _line_number M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +[[ +int yyget_column ( M4_YY_PROTO_ONLY_ARG ); +]]) +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +[[ +void yyset_column ( int _column_no M4_YY_PROTO_LAST_ARG ); +]]) +]]) + +%if-bison-bridge +m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +[[ +YYSTYPE * yyget_lval ( M4_YY_PROTO_ONLY_ARG ); +]]) + +void yyset_lval ( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG ); + +m4_ifdef( [[]], +[[ + m4_ifdef( [[M4_YY_NO_GET_LLOC]],, + [[ + YYLTYPE *yyget_lloc ( M4_YY_PROTO_ONLY_ARG ); + ]]) + + m4_ifdef( [[M4_YY_NO_SET_LLOC]],, + [[ + void yyset_lloc ( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); + ]]) +]]) +%endif + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( M4_YY_PROTO_ONLY_ARG ); +#else +extern int yywrap ( M4_YY_PROTO_ONLY_ARG ); +#endif +#endif + +%not-for-header +#ifndef YY_NO_UNPUT + m4_ifdef( [[M4_YY_NO_UNPUT]],, + [[ + static void yyunput ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); + ]]) +#endif +%ok-for-header +%endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); +#endif + +#ifndef YY_NO_INPUT +%if-c-only Standard (non-C++) definition +%not-for-header +#ifdef __cplusplus +static int yyinput ( M4_YY_PROTO_ONLY_ARG ); +#else +static int input ( M4_YY_PROTO_ONLY_ARG ); +#endif +%ok-for-header +%endif +#endif + + +%if-c-only +%# TODO: This is messy. +m4_ifdef( [[M4_YY_STACK_USED]], +[[ + +m4_ifdef( [[M4_YY_NOT_REENTRANT]], +[[ + m4_ifdef( [[M4_YY_NOT_IN_HEADER]], + [[ + static int yy_start_stack_ptr = 0; + static int yy_start_stack_depth = 0; + static int *yy_start_stack = NULL; + ]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ + m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, + [[ + static void yy_push_state ( int _new_state M4_YY_PROTO_LAST_ARG); + ]]) + m4_ifdef( [[M4_YY_NO_POP_STATE]],, + [[ + static void yy_pop_state ( M4_YY_PROTO_ONLY_ARG ); + ]]) + m4_ifdef( [[M4_YY_NO_TOP_STATE]],, + [[ + static int yy_top_state ( M4_YY_PROTO_ONLY_ARG ); + ]]) +]]) + +]], +[[ +m4_define( [[M4_YY_NO_PUSH_STATE]]) +m4_define( [[M4_YY_NO_POP_STATE]]) +m4_define( [[M4_YY_NO_TOP_STATE]]) +]]) +%endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +%if-c-only Standard (non-C++) definition +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +%endif +%if-c++-only C++ definition +#define ECHO LexerOutput( yytext, yyleng ) +%endif +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ +\ +%if-c++-only C++ definition \ + if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +%endif + +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif +]]) + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +%if-c-only +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) +%endif +%if-c++-only +#define YY_FATAL_ERROR(msg) LexerError( msg ) +%endif +#endif +]]) + +%if-tables-serialization structures and prototypes +m4preproc_include(`tables_shared.h') + +/* Load the DFA tables from the given stream. */ +int yytables_fload (FILE * fp M4_YY_PROTO_LAST_ARG); + +/* Unload the tables from memory. */ +int yytables_destroy (M4_YY_PROTO_ONLY_ARG); +%not-for-header + +/** Describes a mapping from a serialized table id to its deserialized state in + * this scanner. This is the bridge between our "generic" deserialization code + * and the specifics of this scanner. + */ +struct yytbl_dmap { + enum yytbl_id dm_id;/**< table identifier */ + void **dm_arr; /**< address of pointer to store the deserialized table. */ + size_t dm_sz; /**< local sizeof() each element in table. */ +}; + +/** A {0,0,0}-terminated list of structs, forming the map */ +static struct yytbl_dmap yydmap[] = +{ +%tables-yydmap generated elements + {0,0,0} +}; + +/** A tables-reader object to maintain some state in the read. */ +struct yytbl_reader { + FILE * fp; /**< input stream */ + flex_uint32_t bread; /**< bytes read since beginning of current tableset */ +}; + +%endif +/* end tables serialization structures and prototypes */ + +%ok-for-header + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +%if-c-only Standard (non-C++) definition + + +m4_define( [[M4_YY_LEX_PROTO]], [[(M4_YY_PROTO_ONLY_ARG)]]) +m4_define( [[M4_YY_LEX_DECLARATION]], [[(M4_YY_DEF_ONLY_ARG)]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + m4_dnl The bison pure parser is used. Redefine yylex to + m4_dnl accept the lval parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[YYFARGS1(YYSTYPE *,yylval_param)]]) +]]) + +m4_ifdef( [[]], +[[ + m4_dnl Locations are used. yylex should also accept the ylloc parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]]) +]]) + +extern int yylex M4_YY_LEX_PROTO; + +#define YY_DECL int yylex M4_YY_LEX_DECLARATION +%endif +%if-c++-only C++ definition +#define YY_DECL int yyFlexLexer::yylex() +%endif +#endif /* !YY_DECL */ + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +%% [6.0] YY_RULE_SETUP definition goes here +]]) + +%not-for-header +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + M4_YY_DECL_GUTS_VAR(); + +m4_ifdef( [[M4_YY_NOT_REENTRANT]], +[[ + m4_ifdef( [[M4_YY_BISON_LVAL]], + [[ + YYSTYPE * yylval; + ]]) + m4_ifdef( [[]], + [[ + YYLTYPE * yylloc; + ]]) +]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + yylval = yylval_param; +]]) + +m4_ifdef( [[]], +[[ + yylloc = yylloc_param; +]]) + + if ( !YY_G(yy_init) ) + { + YY_G(yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + +m4_ifdef( [[M4_YY_USES_REJECT]], +[[ + /* Create the reject buffer large enough to save one state per allowed character. */ + if ( ! YY_G(yy_state_buf) ) + YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); + if ( ! YY_G(yy_state_buf) ) + YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); +]]) + + if ( ! YY_G(yy_start) ) + YY_G(yy_start) = 1; /* first start state */ + + if ( ! yyin ) +%if-c-only + yyin = stdin; +%endif +%if-c++-only + yyin.rdbuf(std::cin.rdbuf()); +%endif + + if ( ! yyout ) +%if-c-only + yyout = stdout; +%endif +%if-c++-only + yyout.rdbuf(std::cout.rdbuf()); +%endif + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + } + + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + } + + { +%% [7.0] user's declarations go here + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { +%% [8.0] yymore()-related code goes here + yy_cp = YY_G(yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = YY_G(yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + +%% [9.0] code to set up and find next match goes here + +yy_find_action: +%% [10.0] code to find the action number goes here + + YY_DO_BEFORE_ACTION; + +%% [11.0] code for yylineno update goes here + +do_action: /* This label is used only to access EOF actions. */ + +%% [12.0] debug code goes here + + switch ( yy_act ) + { /* beginning of action switch */ +%% [13.0] actions go here + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = YY_G(yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; +%if-c-only + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; +%endif +%if-c++-only + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); +%endif + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); + + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++YY_G(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { +%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) + { + case EOB_ACT_END_OF_FILE: + { + YY_G(yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! YY_G(yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + YY_G(yy_c_buf_p) = + YY_G(yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + yy_cp = YY_G(yy_c_buf_p); + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + YY_G(yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + yy_cp = YY_G(yy_c_buf_p); + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ +%ok-for-header + +%if-c++-only +%not-for-header +/* The contents of this function are C++ specific, so the YY_G macro is not used. + * This constructor simply maintains backward compatibility. + * DEPRECATED + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): + yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), + yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) +{ + ctor_common(); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): + yyin(arg_yyin.rdbuf()), + yyout(arg_yyout.rdbuf()) +{ + ctor_common(); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +void yyFlexLexer::ctor_common() +{ + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = NULL; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + +m4_ifdef( [[M4_YY_USES_REJECT]], +[[ + yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; +]], +[[ + yy_state_buf = 0; +]]) +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); + yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); + yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) +{ + // was if( new_in ) + yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); + + // was if( new_out ) + yyout.rdbuf(new_out.rdbuf()); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if( ! new_in ) { + new_in = &yyin; + } + + if ( ! new_out ) { + new_out = &yyout; + } + + switch_streams(*new_in, *new_out); +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin.eof() || yyin.fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin.get( buf[0] ); + + if ( yyin.eof() ) + return 0; + + if ( yyin.bad() ) + return -1; + + return 1; + +#else + (void) yyin.read( buf, max_size ); + + if ( yyin.bad() ) + return -1; + else + return yyin.gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) +{ + (void) yyout.write( buf, size ); +} +%ok-for-header +%endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +%if-c-only +static int yy_get_next_buffer (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only +int yyFlexLexer::yy_get_next_buffer() +%endif +{ + M4_YY_DECL_GUTS_VAR(); + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = YY_G(yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +m4_ifdef( [[M4_YY_USES_REJECT]], +[[ + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +]], +[[ + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; +]]) + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + YY_G(yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + } + + if ( YY_G(yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin M4_YY_CALL_LAST_ARG); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + YY_G(yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} +]]) + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +%if-c-only +%not-for-header + static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only + yy_state_type yyFlexLexer::yy_get_previous_state() +%endif +{ + yy_state_type yy_current_state; + char *yy_cp; + M4_YY_DECL_GUTS_VAR(); + +%% [15.0] code to get the start state into yy_current_state goes here + + for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) + { +%% [16.0] code to find the next state goes here + } + + return yy_current_state; +} + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ +%if-c-only + static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) +%endif +%if-c++-only + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +%endif +{ + int yy_is_jam; + M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ +%% [17.0] code to find the next state, and perhaps do backing up, goes here + + M4_YY_NOOP_GUTS_VAR(); +return yy_is_jam ? 0 : yy_current_state; +} + + +#ifndef YY_NO_UNPUT +%if-c-only +m4_ifdef( [[M4_YY_NO_UNPUT]],, +[[ + static void yyunput YYFARGS2( int,c, char *,yy_bp) +%endif +%if-c++-only + void yyFlexLexer::yyunput( int c, char* yy_bp) +%endif +{ + char *yy_cp; + M4_YY_DECL_GUTS_VAR(); + + yy_cp = YY_G(yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = YY_G(yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = YY_G(yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + YY_G(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + +%% [18.0] update yylineno here +m4_ifdef( [[M4_YY_USE_LINENO]], +[[ + if ( c == '\n' ){ + --yylineno; + } +]]) + + YY_G(yytext_ptr) = yy_bp; + YY_G(yy_hold_char) = *yy_cp; + YY_G(yy_c_buf_p) = yy_cp; +} +%if-c-only +]]) +%endif +#endif + +%if-c-only +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (M4_YY_DEF_ONLY_ARG) +#else + static int input (M4_YY_DEF_ONLY_ARG) +#endif + +%endif +%if-c++-only + int yyFlexLexer::yyinput() +%endif +{ + int c; + M4_YY_DECL_GUTS_VAR(); + + *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + + if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) + /* This was really a NUL. */ + *YY_G(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); + ++YY_G(yy_c_buf_p); + + switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin M4_YY_CALL_LAST_ARG); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) + return 0; + + if ( ! YY_G(yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(M4_YY_CALL_ONLY_ARG); +#else + return input(M4_YY_CALL_ONLY_ARG); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ + *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ + YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); + +%% [19.0] update BOL and yylineno + + return c; +} +%if-c-only +#endif /* ifndef YY_NO_INPUT */ +%endif + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * M4_YY_DOC_PARAM + * @note This function does not reset the start condition to @c INITIAL . + */ +%if-c-only + void yyrestart YYFARGS1( FILE *,input_file) +%endif +%if-c++-only + void yyFlexLexer::yyrestart( std::istream& input_file ) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); +} + +%if-c++-only +/** Delegate to the new version that takes an istream reference. + * @param input_file A readable stream. + * M4_YY_DOC_PARAM + * @note This function does not reset the start condition to @c INITIAL . + */ +void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + if( ! input_file ) { + input_file = &yyin; + } + yyrestart( *input_file ); +} +%endif + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * M4_YY_DOC_PARAM + */ +%if-c-only + void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) +%endif +%if-c++-only + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + YY_G(yy_did_buffer_switch_on_eof) = 1; +} + + +%if-c-only +static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only + void yyFlexLexer::yy_load_buffer_state() +%endif +{ + M4_YY_DECL_GUTS_VAR(); + YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; +%if-c-only + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +%endif +%if-c++-only + yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); +%endif + YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * M4_YY_DOC_PARAM + * @return the allocated buffer state. + */ +%if-c-only + YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) +%endif +%if-c++-only + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) +%endif +{ + YY_BUFFER_STATE b; + m4_dnl M4_YY_DECL_GUTS_VAR(); + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); + + return b; +} + +%if-c++-only +/** Delegate creation of buffers to the new version that takes an istream reference. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * M4_YY_DOC_PARAM + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + return yy_create_buffer( *file, size ); +} +%endif + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * M4_YY_DOC_PARAM + */ +%if-c-only + void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) +%endif +%if-c++-only + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); + + yyfree( (void *) b M4_YY_CALL_LAST_ARG ); +} + + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ +%if-c-only + static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) +%endif +%if-c++-only + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) +%endif + +{ + int oerrno = errno; + M4_YY_DECL_GUTS_VAR(); + + yy_flush_buffer( b M4_YY_CALL_LAST_ARG); + +%if-c-only + b->yy_input_file = file; +%endif +%if-c++-only + b->yy_input_file = file.rdbuf(); +%endif + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + +%if-c-only +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], +[[ + b->yy_is_interactive = 1; +]], +[[ + m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], + [[ + b->yy_is_interactive = 0; + ]], + [[ + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + ]]) +]]) +%endif +%if-c++-only + b->yy_is_interactive = 0; +%endif + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * M4_YY_DOC_PARAM + */ +%if-c-only + void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) +%endif +%if-c++-only + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); +} + +%if-c-or-c++ +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * M4_YY_DOC_PARAM + */ +%if-c-only +void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) +%endif +%if-c++-only +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + YY_G(yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + YY_G(yy_did_buffer_switch_on_eof) = 1; +} +%endif + + +%if-c-or-c++ +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * M4_YY_DOC_PARAM + */ +%if-c-only +void yypop_buffer_state (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only +void yyFlexLexer::yypop_buffer_state (void) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (YY_G(yy_buffer_stack_top) > 0) + --YY_G(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + YY_G(yy_did_buffer_switch_on_eof) = 1; + } +} +%endif + + +%if-c-or-c++ +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +%if-c-only +static void yyensure_buffer_stack (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only +void yyFlexLexer::yyensure_buffer_stack(void) +%endif +{ + yy_size_t num_to_alloc; + M4_YY_DECL_GUTS_VAR(); + + if (!YY_G(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + M4_YY_CALL_LAST_ARG); + if ( ! YY_G(yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + + memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + YY_G(yy_buffer_stack_max) = num_to_alloc; + YY_G(yy_buffer_stack_top) = 0; + return; + } + + if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; + YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + (YY_G(yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + M4_YY_CALL_LAST_ARG); + if ( ! YY_G(yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + YY_G(yy_buffer_stack_max) = num_to_alloc; + } +} +%endif + + + + +m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, +[[ +%if-c-only +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * M4_YY_DOC_PARAM + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) +{ + YY_BUFFER_STATE b; + m4_dnl M4_YY_DECL_GUTS_VAR(); + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); + + return b; +} +%endif +]]) + + +m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, +[[ +%if-c-only +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * M4_YY_DOC_PARAM + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string YYFARGS1( const char *, yystr) +{ + m4_dnl M4_YY_DECL_GUTS_VAR(); + + return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); +} +%endif +]]) + + +m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, +[[ +%if-c-only +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * M4_YY_DOC_PARAM + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + m4_dnl M4_YY_DECL_GUTS_VAR(); + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} +%endif +]]) + + +m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, +[[ +%if-c-only + static void yy_push_state YYFARGS1( int ,_new_state) +%endif +%if-c++-only + void yyFlexLexer::yy_push_state( int _new_state ) +%endif +{ + M4_YY_DECL_GUTS_VAR(); + if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) + { + yy_size_t new_size; + + YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_size_t) YY_G(yy_start_stack_depth) * sizeof( int ); + + if ( ! YY_G(yy_start_stack) ) + YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); + + else + YY_G(yy_start_stack) = (int *) yyrealloc( + (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); + + if ( ! YY_G(yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; + + BEGIN(_new_state); +} +]]) + + +m4_ifdef( [[M4_YY_NO_POP_STATE]],, +[[ +%if-c-only + static void yy_pop_state (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only + void yyFlexLexer::yy_pop_state() +%endif +{ + M4_YY_DECL_GUTS_VAR(); + if ( --YY_G(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); +} +]]) + + +m4_ifdef( [[M4_YY_NO_TOP_STATE]],, +[[ +%if-c-only + static int yy_top_state (M4_YY_DEF_ONLY_ARG) +%endif +%if-c++-only + int yyFlexLexer::yy_top_state() +%endif +{ + M4_YY_DECL_GUTS_VAR(); + return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; +} +]]) + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +%if-c-only +static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) +{ + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} +%endif +%if-c++-only +void yyFlexLexer::LexerError( const char* msg ) +{ + M4_YY_DECL_GUTS_VAR(); + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} +%endif + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = YY_G(yy_hold_char); \ + YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ + YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ + *YY_G(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + + + +/* Accessor methods (get/set functions) to struct members. */ + +%if-c-only +%if-reentrant +m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, +[[ +/** Get the user-defined data for this scanner. + * M4_YY_DOC_PARAM + */ +YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yyextra; +} +]]) +%endif + +m4_ifdef( [[M4_YY_NO_GET_LINENO]],, +[[ +/** Get the current line number. + * M4_YY_DOC_PARAM + */ +int yyget_lineno (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + if (! YY_CURRENT_BUFFER) + return 0; + ]]) + return yylineno; +} +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +[[ +/** Get the current column number. + * M4_YY_DOC_PARAM + */ +int yyget_column (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + if (! YY_CURRENT_BUFFER) + return 0; + ]]) + return yycolumn; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_GET_IN]],, +[[ +/** Get the input stream. + * M4_YY_DOC_PARAM + */ +FILE *yyget_in (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yyin; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_OUT]],, +[[ +/** Get the output stream. + * M4_YY_DOC_PARAM + */ +FILE *yyget_out (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yyout; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_LENG]],, +[[ +/** Get the length of the current token. + * M4_YY_DOC_PARAM + */ +int yyget_leng (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yyleng; +} +]]) + +/** Get the current token. + * M4_YY_DOC_PARAM + */ +m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +[[ +char *yyget_text (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yytext; +} +]]) + +%if-reentrant +m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +[[ +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * M4_YY_DOC_PARAM + */ +void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) +{ + M4_YY_DECL_GUTS_VAR(); + yyextra = user_defined ; +} +]]) +%endif + +m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +[[ +/** Set the current line number. + * @param _line_number line number + * M4_YY_DOC_PARAM + */ +void yyset_lineno YYFARGS1( int ,_line_number) +{ + M4_YY_DECL_GUTS_VAR(); + + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + ]]) + yylineno = _line_number; +} +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +[[ +/** Set the current column. + * @param _column_no column number + * M4_YY_DOC_PARAM + */ +void yyset_column YYFARGS1( int , _column_no) +{ + M4_YY_DECL_GUTS_VAR(); + + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + ]]) + yycolumn = _column_no; +} +]]) +]]) + + +m4_ifdef( [[M4_YY_NO_SET_IN]],, +[[ +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * M4_YY_DOC_PARAM + * @see yy_switch_to_buffer + */ +void yyset_in YYFARGS1( FILE * ,_in_str) +{ + M4_YY_DECL_GUTS_VAR(); + yyin = _in_str ; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_OUT]],, +[[ +void yyset_out YYFARGS1( FILE * ,_out_str) +{ + M4_YY_DECL_GUTS_VAR(); + yyout = _out_str ; +} +]]) + + +m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +[[ +int yyget_debug (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yy_flex_debug; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +[[ +void yyset_debug YYFARGS1( int ,_bdebug) +{ + M4_YY_DECL_GUTS_VAR(); + yy_flex_debug = _bdebug ; +} +]]) +%endif + +%if-reentrant +/* Accessor methods for yylval and yylloc */ + +%if-bison-bridge +m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +[[ +YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yylval; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LVAL]],, +[[ +void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) +{ + M4_YY_DECL_GUTS_VAR(); + yylval = yylval_param; +} +]]) + +m4_ifdef( [[]], +[[ + m4_ifdef( [[M4_YY_NO_GET_LLOC]],, + [[ +YYLTYPE *yyget_lloc (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + return yylloc; +} + ]]) + + m4_ifdef( [[M4_YY_NO_SET_LLOC]],, + [[ +void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) +{ + M4_YY_DECL_GUTS_VAR(); + yylloc = yylloc_param; +} + ]]) +]]) + +%endif + + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +%endif if-c-only +%# Actually, that ended an if-rentrant section + +%if-c-only +static int yy_init_globals (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + +m4_ifdef( [[M4_YY_USE_LINENO]], +[[ + m4_ifdef( [[M4_YY_NOT_REENTRANT]], + [[ + /* We do not touch yylineno unless the option is enabled. */ + yylineno = 1; + ]]) +]]) + YY_G(yy_buffer_stack) = NULL; + YY_G(yy_buffer_stack_top) = 0; + YY_G(yy_buffer_stack_max) = 0; + YY_G(yy_c_buf_p) = NULL; + YY_G(yy_init) = 0; + YY_G(yy_start) = 0; + +m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], +[[ + YY_G(yy_start_stack_ptr) = 0; + YY_G(yy_start_stack_depth) = 0; + YY_G(yy_start_stack) = NULL; +]]) + +m4_ifdef( [[M4_YY_USES_REJECT]], +[[ + YY_G(yy_state_buf) = 0; + YY_G(yy_state_ptr) = 0; + YY_G(yy_full_match) = 0; + YY_G(yy_lp) = 0; +]]) + +m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], +[[ + YY_G(yytext_ptr) = 0; + YY_G(yy_more_offset) = 0; + YY_G(yy_prev_more_offset) = 0; +]]) + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} +%endif + + +%if-c-only SNIP! this currently causes conflicts with the c++ scanner +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (M4_YY_DEF_ONLY_ARG) +{ + M4_YY_DECL_GUTS_VAR(); + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(M4_YY_CALL_ONLY_ARG); + } + + /* Destroy the stack itself. */ + yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); + YY_G(yy_buffer_stack) = NULL; + +m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], +[[ + /* Destroy the start condition stack. */ + yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); + YY_G(yy_start_stack) = NULL; +]]) + +m4_ifdef( [[M4_YY_USES_REJECT]], +[[ + yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); + YY_G(yy_state_buf) = NULL; +]]) + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( M4_YY_CALL_ONLY_ARG); + +%if-reentrant + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); + yyscanner = NULL; +%endif + return 0; +} +%endif + + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* + * Internal utility routines. + */ +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#ifndef yytext_ptr +static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) +{ + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YYFARGS1( const char *,s) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc YYFARGS1( yy_size_t ,size) +{ + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + return malloc(size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) +{ + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree YYFARGS1( void *,ptr) +{ + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} +]]) + +%if-tables-serialization definitions +m4preproc_include(`tables_shared.c') + +static int yytbl_read8 (void *v, struct yytbl_reader * rd) +{ + errno = 0; + if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ + errno = EIO; + return -1; + } + rd->bread += (flex_uint32_t) sizeof(flex_uint8_t); + return 0; +} + +static int yytbl_read16 (void *v, struct yytbl_reader * rd) +{ + errno = 0; + if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ + errno = EIO; + return -1; + } + *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); + rd->bread += (flex_uint32_t) sizeof(flex_uint16_t); + return 0; +} + +static int yytbl_read32 (void *v, struct yytbl_reader * rd) +{ + errno = 0; + if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ + errno = EIO; + return -1; + } + *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); + rd->bread += (flex_uint32_t) sizeof(flex_uint32_t); + return 0; +} + +/** Read the header */ +static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) +{ + size_t bytes; + memset (th, 0, sizeof (struct yytbl_hdr)); + + if (yytbl_read32 (&(th->th_magic), rd) != 0) + return -1; + + if (th->th_magic != YYTBL_MAGIC){ + YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ + return -1; + } + + if (yytbl_read32 (&(th->th_hsize), rd) != 0 + || yytbl_read32 (&(th->th_ssize), rd) != 0 + || yytbl_read16 (&(th->th_flags), rd) != 0) + return -1; + + /* Sanity check on header size. Greater than 1k suggests some funny business. */ + if (th->th_hsize < 16 || th->th_hsize > 1024){ + YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ + return -1; + } + + /* Allocate enough space for the version and name fields */ + bytes = th->th_hsize - 14; + th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); + if ( ! th->th_version ) + YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); + + /* we read it all into th_version, and point th_name into that data */ + if (fread (th->th_version, 1, bytes, rd->fp) != bytes){ + errno = EIO; + yyfree(th->th_version M4_YY_CALL_LAST_ARG); + th->th_version = NULL; + return -1; + } + else + rd->bread += (flex_uint32_t) bytes; + + th->th_name = th->th_version + strlen (th->th_version) + 1; + return 0; +} + +/** lookup id in the dmap list. + * @param dmap pointer to first element in list + * @return NULL if not found. + */ +static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, + int, id) +{ + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + + while (dmap->dm_id) + if ((int)(dmap->dm_id) == id) + return dmap; + else + dmap++; + return NULL; +} + +/** Read a table while mapping its contents to the local array. + * @param dmap used to performing mapping + * @return 0 on success + */ +static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) +{ + struct yytbl_data td; + struct yytbl_dmap *transdmap=0; + int len, i, rv, inner_loop_count; + void *p=0; + + memset (&td, 0, sizeof (struct yytbl_data)); + + if (yytbl_read16 (&td.td_id, rd) != 0 + || yytbl_read16 (&td.td_flags, rd) != 0 + || yytbl_read32 (&td.td_hilen, rd) != 0 + || yytbl_read32 (&td.td_lolen, rd) != 0) + return -1; + + /* Lookup the map for the transition table so we have it in case we need it + * inside the loop below. This scanner might not even have a transition + * table, which is ok. + */ + transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); + + if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){ + YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ + return -1; + } + + /* Allocate space for table. + * The --full yy_transition table is a special case, since we + * need the dmap.dm_sz entry to tell us the sizeof the individual + * struct members. + */ + { + size_t bytes; + + if ((td.td_flags & YYTD_STRUCT)) + bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); + else + bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; + + if(M4_YY_TABLES_VERIFY) + /* We point to the array itself */ + p = dmap->dm_arr; + else + /* We point to the address of a pointer. */ + *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); + if ( ! p ) + YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); + } + + /* If it's a struct, we read 2 integers to get one element */ + if ((td.td_flags & YYTD_STRUCT) != 0) + inner_loop_count = 2; + else + inner_loop_count = 1; + + /* read and map each element. + * This loop iterates once for each element of the td_data array. + * Notice that we increment 'i' in the inner loop. + */ + len = yytbl_calc_total_len (&td); + for (i = 0; i < len; ){ + int j; + + + /* This loop really executes exactly 1 or 2 times. + * The second time is to handle the second member of the + * YYTD_STRUCT for the yy_transition array. + */ + for (j = 0; j < inner_loop_count; j++, i++) { + flex_int32_t t32; + + /* read into t32 no matter what the real size is. */ + { + flex_int16_t t16; + flex_int8_t t8; + + switch (YYTDFLAGS2BYTES (td.td_flags)) { + case sizeof (flex_int32_t): + rv = yytbl_read32 (&t32, rd); + break; + case sizeof (flex_int16_t): + rv = yytbl_read16 (&t16, rd); + t32 = t16; + break; + case sizeof (flex_int8_t): + rv = yytbl_read8 (&t8, rd); + t32 = t8; + break; + default: + YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ + return -1; + } + } + if (rv != 0) + return -1; + + /* copy into the deserialized array... */ + + if ((td.td_flags & YYTD_STRUCT)) { + /* t32 is the j'th member of a two-element struct. */ + void *v; + + v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) + : &(((struct yy_trans_info *) p)->yy_nxt); + + switch (dmap->dm_sz) { + case sizeof (flex_int32_t): + if (M4_YY_TABLES_VERIFY){ + if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); + }else + ((flex_int32_t *) v)[0] = (flex_int32_t) t32; + break; + case sizeof (flex_int16_t): + if (M4_YY_TABLES_VERIFY ){ + if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); + }else + ((flex_int16_t *) v)[0] = (flex_int16_t) t32; + break; + case sizeof(flex_int8_t): + if (M4_YY_TABLES_VERIFY ){ + if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); + }else + ((flex_int8_t *) v)[0] = (flex_int8_t) t32; + break; + default: + YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ + return -1; + } + + /* if we're done with j, increment p */ + if (j == 1) + p = (struct yy_trans_info *) p + 1; + } + else if ((td.td_flags & YYTD_PTRANS)) { + /* t32 is an index into the transition array. */ + struct yy_trans_info *v; + + + if (!transdmap){ + YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ + return -1; + } + + if( M4_YY_TABLES_VERIFY) + v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); + else + v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); + + if(M4_YY_TABLES_VERIFY ){ + if( ((struct yy_trans_info **) p)[0] != v) + YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); + }else + ((struct yy_trans_info **) p)[0] = v; + + /* increment p */ + p = (struct yy_trans_info **) p + 1; + } + else { + /* t32 is a plain int. copy data, then incrememnt p. */ + switch (dmap->dm_sz) { + case sizeof (flex_int32_t): + if(M4_YY_TABLES_VERIFY ){ + if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) + YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); + }else + ((flex_int32_t *) p)[0] = (flex_int32_t) t32; + p = ((flex_int32_t *) p) + 1; + break; + case sizeof (flex_int16_t): + if(M4_YY_TABLES_VERIFY ){ + if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) + YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); + }else + ((flex_int16_t *) p)[0] = (flex_int16_t) t32; + p = ((flex_int16_t *) p) + 1; + break; + case sizeof (flex_int8_t): + if(M4_YY_TABLES_VERIFY ){ + if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) + YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); + }else + ((flex_int8_t *) p)[0] = (flex_int8_t) t32; + p = ((flex_int8_t *) p) + 1; + break; + default: + YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ + return -1; + } + } + } + + } + + /* Now eat padding. */ + { + while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) { + flex_int8_t t8; + if(yytbl_read8(&t8,rd) != 0) + return -1; + } + } + + return 0; +} + +%define-yytables The name for this specific scanner's tables. + +/* Find the key and load the DFA tables from the given stream. */ +static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) +{ + int rv=0; + struct yytbl_hdr th; + struct yytbl_reader rd; + + rd.fp = fp; + th.th_version = NULL; + + /* Keep trying until we find the right set of tables or end of file. */ + while (!feof(rd.fp)) { + rd.bread = 0; + if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ + rv = -1; + goto return_rv; + } + + /* A NULL key means choose the first set of tables. */ + if (key == NULL) + break; + + if (strcmp(th.th_name,key) != 0){ + /* Skip ahead to next set */ + fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); + yyfree(th.th_version M4_YY_CALL_LAST_ARG); + th.th_version = NULL; + } + else + break; + } + + while (rd.bread < th.th_ssize){ + /* Load the data tables */ + if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ + rv = -1; + goto return_rv; + } + } + +return_rv: + if(th.th_version){ + yyfree(th.th_version M4_YY_CALL_LAST_ARG); + th.th_version = NULL; + } + + return rv; +} + +/** Load the DFA tables for this scanner from the given stream. */ +int yytables_fload YYFARGS1(FILE *, fp) +{ + + if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) + return -1; + return 0; +} + +/** Destroy the loaded tables, freeing memory, etc.. */ +int yytables_destroy (M4_YY_DEF_ONLY_ARG) +{ + struct yytbl_dmap *dmap=0; + + if(!M4_YY_TABLES_VERIFY){ + /* Walk the dmap, freeing the pointers */ + for(dmap=yydmap; dmap->dm_id; dmap++) { + void * v; + v = dmap->dm_arr; + if(v && *(char**)v){ + yyfree(*(char**)v M4_YY_CALL_LAST_ARG); + *(char**)v = NULL; + } + } + } + + return 0; +} + +/* end table serialization code definitions */ +%endif + + +m4_ifdef([[M4_YY_MAIN]], [[ +int main (void); + +int main () +{ + +%if-reentrant + yyscan_t lexer; + yylex_init(&lexer); + yylex( lexer ); + yylex_destroy( lexer); + +%endif +%if-not-reentrant + yylex(); +%endif + + return 0; +} +]]) + +%ok-for-header +m4_ifdef( [[M4_YY_IN_HEADER]], +[[ +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif +m4preproc_undivert(1) +]]) diff --git a/src/flex.skl b/src/flex.skl deleted file mode 100644 index 9a69520..0000000 --- a/src/flex.skl +++ /dev/null @@ -1,3443 +0,0 @@ -%# -*-C-*- vi: set ft=c: -%# This file is processed in several stages. -%# Here are the stages, as best as I can describe: -%# -%# 1. flex.skl is processed through GNU m4 during the -%# pre-compilation stage of flex. Only macros starting -%# with `m4preproc_' are processed, and quoting is normal. -%# -%# 2. The preprocessed skeleton is translated into a C array, saved -%# as "skel.c" and compiled into the flex binary. The %# comment -%# lines are removed. -%# -%# 3. At runtime, the skeleton is generated and filtered (again) -%# through m4. Macros beginning with `m4_' will be processed. -%# The quoting is "[[" and "]]" so we don't interfere with -%# user code. -%# -%# All generated macros for the m4 stage contain the text "m4" or "M4" -%# in them. This is to distinguish them from CPP macros. -%# The exception to this rule is YY_G, which is an m4 macro, -%# but it needs to be remain short because it is used everywhere. -%# -/* A lexical scanner generated by flex */ - -%# Macros for preproc stage. -m4preproc_changecom - -%# Macros for runtime processing stage. -m4_changecom -m4_changequote -m4_changequote([[, ]]) - -%# -%# Lines in this skeleton starting with a "%" character are "control lines" -%# and affect the generation of the scanner. The possible control codes are -%# listed and processed in misc.c. -%# -%# %# - A comment. The current line is omitted from the generated scanner. -%# %if-c++-only - The following lines are printed for C++ scanners ONLY. -%# %if-c-only - The following lines are NOT printed for C++ scanners. -%# %if-c-or-c++ - The following lines are printed in BOTH C and C++ scanners. -%# %if-reentrant - Print for reentrant scanners.(push) -%# %if-not-reentrant - Print for non-reentrant scanners. (push) -%# %if-bison-bridge - Print for bison-bridge. (push) -%# %if-not-bison-bridge - Print for non-bison-bridge. (push) -%# %endif - pop from the previous if code. -%# %% - A stop-point, where code is inserted by flex. -%# Each stop-point is numbered here and also in the code generator. -%# (See gen.c, etc. for details.) -%# %not-for-header - Begin code that should NOT appear in a ".h" file. -%# %ok-for-header - %c and %e are used for building a header file. -%# %if-tables-serialization -%# -%# All control-lines EXCEPT comment lines ("%#") will be inserted into -%# the generated scanner as a C-style comment. This is to aid those who -%# edit the skeleton. -%# - -%not-for-header -%if-c-only -%if-not-reentrant -m4_ifelse(M4_YY_PREFIX,yy,, -#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]] -#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]] -#define yy_scan_buffer M4_YY_PREFIX[[_scan_buffer]] -#define yy_scan_string M4_YY_PREFIX[[_scan_string]] -#define yy_scan_bytes M4_YY_PREFIX[[_scan_bytes]] -#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]] -#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]] -#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]] -#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]] -#define yypush_buffer_state M4_YY_PREFIX[[push_buffer_state]] -#define yypop_buffer_state M4_YY_PREFIX[[pop_buffer_state]] -#define yyensure_buffer_stack M4_YY_PREFIX[[ensure_buffer_stack]] -#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]] -#define yyin M4_YY_PREFIX[[in]] -#define yyleng M4_YY_PREFIX[[leng]] -#define yylex M4_YY_PREFIX[[lex]] -#define yylineno M4_YY_PREFIX[[lineno]] -#define yyout M4_YY_PREFIX[[out]] -#define yyrestart M4_YY_PREFIX[[restart]] -#define yytext M4_YY_PREFIX[[text]] -#define yywrap M4_YY_PREFIX[[wrap]] -#define yyalloc M4_YY_PREFIX[[alloc]] -#define yyrealloc M4_YY_PREFIX[[realloc]] -#define yyfree M4_YY_PREFIX[[free]] -) -%endif -%endif -%ok-for-header - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION -#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION -#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -%# Some negated symbols -m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) -m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) - -%# This is the m4 way to say "(stack_used || is_reentrant) -m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) -m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) - -%# Prefixes. -%# The complexity here is necessary so that m4 preserves -%# the argument lists to each C function. - - -m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]]) - -m4preproc_define(`M4_GEN_PREFIX',`` -[[#ifdef yy$1 -#define ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED -#else -#define yy$1 ]]M4_YY_PREFIX[[$1 -#endif]] -'m4preproc_divert(1)` -[[#ifndef ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED -#undef yy$1 -#endif]]'m4preproc_divert(0)') - -%if-c++-only - /* The c++ scanner is a mess. The FlexLexer.h header file relies on the - * following macro. This is required in order to pass the c++-multiple-scanners - * test in the regression suite. We get reports that it breaks inheritance. - * We will address this in a future release of flex, or omit the C++ scanner - * altogether. - */ - #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]] -%endif - -%if-c-only -m4_ifelse(M4_YY_PREFIX,yy,, - M4_GEN_PREFIX(`_create_buffer') - M4_GEN_PREFIX(`_delete_buffer') - M4_GEN_PREFIX(`_scan_buffer') - M4_GEN_PREFIX(`_scan_string') - M4_GEN_PREFIX(`_scan_bytes') - M4_GEN_PREFIX(`_init_buffer') - M4_GEN_PREFIX(`_flush_buffer') - M4_GEN_PREFIX(`_load_buffer_state') - M4_GEN_PREFIX(`_switch_to_buffer') - M4_GEN_PREFIX(`push_buffer_state') - M4_GEN_PREFIX(`pop_buffer_state') - M4_GEN_PREFIX(`ensure_buffer_stack') - M4_GEN_PREFIX(`lex') - M4_GEN_PREFIX(`restart') - M4_GEN_PREFIX(`lex_init') - M4_GEN_PREFIX(`lex_init_extra') - M4_GEN_PREFIX(`lex_destroy') - M4_GEN_PREFIX(`get_debug') - M4_GEN_PREFIX(`set_debug') - M4_GEN_PREFIX(`get_extra') - M4_GEN_PREFIX(`set_extra') - M4_GEN_PREFIX(`get_in') - M4_GEN_PREFIX(`set_in') - M4_GEN_PREFIX(`get_out') - M4_GEN_PREFIX(`set_out') - M4_GEN_PREFIX(`get_leng') - M4_GEN_PREFIX(`get_text') - M4_GEN_PREFIX(`get_lineno') - M4_GEN_PREFIX(`set_lineno') - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - M4_GEN_PREFIX(`get_column') - M4_GEN_PREFIX(`set_column') - ]]) - M4_GEN_PREFIX(`wrap') -) -%endif - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - M4_GEN_PREFIX(`get_lval') - M4_GEN_PREFIX(`set_lval') -]]) - -m4_ifdef( [[]], -[[ - M4_GEN_PREFIX(`get_lloc') - M4_GEN_PREFIX(`set_lloc') -]]) - - -m4_ifelse(M4_YY_PREFIX,yy,, - M4_GEN_PREFIX(`alloc') - M4_GEN_PREFIX(`realloc') - M4_GEN_PREFIX(`free') -) - -%if-c-only -m4_ifelse(M4_YY_PREFIX,yy,, -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - M4_GEN_PREFIX(`text') - M4_GEN_PREFIX(`leng') - M4_GEN_PREFIX(`in') - M4_GEN_PREFIX(`out') - M4_GEN_PREFIX(`_flex_debug') - M4_GEN_PREFIX(`lineno') -]]) -) -%endif - - -m4_ifdef( [[M4_YY_TABLES_EXTERNAL]], -[[ - M4_GEN_PREFIX(`tables_fload') - M4_GEN_PREFIX(`tables_destroy') - M4_GEN_PREFIX(`TABLES_NAME') -]]) - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -%if-c-only -m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , -[[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , -[[/* Feature test macros. Flex uses functions that require a minimum set of - * macros defined. As defining some macros may hide function declarations that - * user code might use, be conservative and respect user's definitions as much - * as possible. In glibc, feature test macros may not be all set up until one - * of the libc header (that includes ) is included. This creates - * a circular dependency when we check the macros. is the safest - * header we can include and does not declare too many functions we don't need. - */ -#if !defined(__GNU_LIBRARY__) && defined(__STDC__) -#include -#endif -#if !(defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ - defined(_POSIX_SOURCE)) -# define _POSIX_C_SOURCE 1 /* Required for fileno() */ -# define _POSIX_SOURCE 1 -#endif]])]]) -#include -#include -#include -#include -%endif - -%if-tables-serialization -#include -#include -%endif -/* end standard C headers. */ - -/* begin standard C++ headers. */ -%if-c++-only -#include -#include -#include -#include -#include -/* end standard C++ headers. */ -%endif - -%if-c-or-c++ -m4preproc_include(`flexint_shared.h') -%endif - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -%not-for-header -/* Returned upon end-of-file. */ -#define YY_NULL 0 -%ok-for-header - -%not-for-header -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) -%ok-for-header - - - -%if-reentrant - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -%# Declare yyguts variable -m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]]) -%# Perform a noop access on yyguts to prevent unused variable complains -m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[(void)yyg]]) -%# For use wherever a Global is accessed or assigned. -m4_define( [[YY_G]], [[yyg->$1]]) - -%# For use in function prototypes to append the additional argument. -m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]]) -m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]]) - -m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]]) -m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]]) -m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]]) - -%# For use in function calls to pass the additional argument. -m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]]) -m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]]) - -%# For use in function documentation to adjust for additional argument. -m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin YY_G(yyin_r) -#define yyout YY_G(yyout_r) -#define yyextra YY_G(yyextra_r) -#define yyleng YY_G(yyleng_r) -#define yytext YY_G(yytext_r) -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug YY_G(yy_flex_debug_r) - -m4_define( [[M4_YY_INCR_LINENO]], -[[ - do{ yylineno++; - yycolumn=0; - }while(0) -]]) - -%endif - - - -%if-not-reentrant - -m4_define( [[M4_YY_INCR_LINENO]], -[[ - yylineno++; -]]) - -%# Define these macros to be no-ops. -m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]]) -m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[m4_dnl]]) -m4_define( [[YY_G]], [[($1)]]) -m4_define( [[M4_YY_PROTO_LAST_ARG]]) -m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]]) -m4_define( [[M4_YY_DEF_LAST_ARG]]) - -m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]]) -m4_define([[M4_YY_DECL_LAST_ARG]]) -m4_define([[M4_YY_CALL_LAST_ARG]]) -m4_define([[M4_YY_CALL_ONLY_ARG]]) -m4_define( [[M4_YY_DOC_PARAM]], ) - -%endif - - -%# Generate C99 function defs. -m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]]) -m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]]) -m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN YY_G(yy_start) = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((YY_G(yy_start) - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG ) -#define YY_END_OF_BUFFER_CHAR 0 -]]) - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) -]]) - - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -%if-not-reentrant -extern int yyleng; -%endif - -%if-c-only -%if-not-reentrant -extern FILE *yyin, *yyout; -%endif -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - m4_ifdef( [[M4_YY_USE_LINENO]], - [[ - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl )\ - if ( yytext[yyl] == '\n' )\ - --yylineno;\ - }while(0) - #define YY_LINENO_REWIND_TO(dst) \ - do {\ - const char *p;\ - for ( p = yy_cp-1; p >= (dst); --p)\ - if ( *p == '\n' )\ - --yylineno;\ - }while(0) - ]], - [[ - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - ]]) -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = YY_G(yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) -]]) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { -%if-c-only - FILE *yy_input_file; -%endif - -%if-c++-only - std::streambuf* yy_input_file; -%endif - - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 -]]) - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -%if-c-only Standard (non-C++) definition -%not-for-header -%if-not-reentrant - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ -%endif -%ok-for-header -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \ - ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] -]]) - -%if-c-only Standard (non-C++) definition - -%if-not-reentrant -%not-for-header -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; -%ok-for-header -%endif - -void yyrestart ( FILE *input_file M4_YY_PROTO_LAST_ARG ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size M4_YY_PROTO_LAST_ARG ); -void yy_delete_buffer ( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); -void yy_flush_buffer ( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); -void yypop_buffer_state ( M4_YY_PROTO_ONLY_ARG ); - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static void yyensure_buffer_stack ( M4_YY_PROTO_ONLY_ARG ); -static void yy_load_buffer_state ( M4_YY_PROTO_ONLY_ARG ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG) -]]) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); - -%endif - -void *yyalloc ( yy_size_t M4_YY_PROTO_LAST_ARG ); -void *yyrealloc ( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); -void yyfree ( void * M4_YY_PROTO_LAST_ARG ); - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -]]) - -%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -%% [1.5] DFA -]]) - -%if-c-only Standard (non-C++) definition - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG); -static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); -static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); -]]) - -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - YY_G(yytext_ptr) = yy_bp; \ -%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ - YY_G(yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ -%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ - YY_G(yy_c_buf_p) = yy_cp; -%% [4.0] data tables for the DFA and the user's section 1 definitions go here -]]) - -m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) -M4_YY_SC_DEFS -m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) - -m4_ifdef( [[M4_YY_NO_UNISTD_H]],, -[[ -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -%if-c-only -#include -%endif -%if-c++-only -#include -%endif -#endif -]]) - -m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], -[[ -#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS -]], -[[ -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif -]] -) - -%if-c-only Reentrant structure and macros (non-C++). -%if-reentrant - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; - int yy_lp; - - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ - int yy_looking_for_trail_begin; - int yy_full_lp; - int *yy_full_state; -]]) - -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], -[[ - char yytext_r[YYLMAX]; - char *yytext_ptr; - int yy_more_offset; - int yy_prev_more_offset; -]], -[[ - char *yytext_r; - int yy_more_flag; - int yy_more_len; -]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - YYSTYPE * yylval_r; -]]) - -m4_ifdef( [[]], -[[ - YYLTYPE * yylloc_r; -]]) - - }; /* end struct yyguts_t */ -]]) - - -%if-c-only -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static int yy_init_globals ( M4_YY_PROTO_ONLY_ARG ); -]]) -%endif - -%if-reentrant - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ - m4_ifdef( [[M4_YY_BISON_LVAL]], - [[ - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval YY_G(yylval_r) - ]]) - - m4_ifdef( [[]], - [[ - # define yylloc YY_G(yylloc_r) - ]]) -]]) - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -%endif - -%endif End reentrant structures and macros. - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -m4_ifdef( [[M4_YY_NO_DESTROY]],, -[[ -int yylex_destroy ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, -[[ -int yyget_debug ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, -[[ -void yyset_debug ( int debug_flag M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, -[[ -YY_EXTRA_TYPE yyget_extra ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, -[[ -void yyset_extra ( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_IN]],, -[[ -FILE *yyget_in ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_IN]],, -[[ -void yyset_in ( FILE * _in_str M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_OUT]],, -[[ -FILE *yyget_out ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_OUT]],, -[[ -void yyset_out ( FILE * _out_str M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_LENG]],, -[[ - int yyget_leng ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, -[[ -char *yyget_text ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, -[[ -int yyget_lineno ( M4_YY_PROTO_ONLY_ARG ); -]]) - -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, -[[ -void yyset_lineno ( int _line_number M4_YY_PROTO_LAST_ARG ); -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, -[[ -int yyget_column ( M4_YY_PROTO_ONLY_ARG ); -]]) -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, -[[ -void yyset_column ( int _column_no M4_YY_PROTO_LAST_ARG ); -]]) -]]) - -%if-bison-bridge -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE * yyget_lval ( M4_YY_PROTO_ONLY_ARG ); -]]) - -void yyset_lval ( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG ); - -m4_ifdef( [[]], -[[ - m4_ifdef( [[M4_YY_NO_GET_LLOC]],, - [[ - YYLTYPE *yyget_lloc ( M4_YY_PROTO_ONLY_ARG ); - ]]) - - m4_ifdef( [[M4_YY_NO_SET_LLOC]],, - [[ - void yyset_lloc ( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); - ]]) -]]) -%endif - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( M4_YY_PROTO_ONLY_ARG ); -#else -extern int yywrap ( M4_YY_PROTO_ONLY_ARG ); -#endif -#endif - -%not-for-header -#ifndef YY_NO_UNPUT - m4_ifdef( [[M4_YY_NO_UNPUT]],, - [[ - static void yyunput ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); - ]]) -#endif -%ok-for-header -%endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); -#endif - -#ifndef YY_NO_INPUT -%if-c-only Standard (non-C++) definition -%not-for-header -#ifdef __cplusplus -static int yyinput ( M4_YY_PROTO_ONLY_ARG ); -#else -static int input ( M4_YY_PROTO_ONLY_ARG ); -#endif -%ok-for-header -%endif -#endif - - -%if-c-only -%# TODO: This is messy. -m4_ifdef( [[M4_YY_STACK_USED]], -[[ - -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - m4_ifdef( [[M4_YY_NOT_IN_HEADER]], - [[ - static int yy_start_stack_ptr = 0; - static int yy_start_stack_depth = 0; - static int *yy_start_stack = NULL; - ]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ - m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, - [[ - static void yy_push_state ( int _new_state M4_YY_PROTO_LAST_ARG); - ]]) - m4_ifdef( [[M4_YY_NO_POP_STATE]],, - [[ - static void yy_pop_state ( M4_YY_PROTO_ONLY_ARG ); - ]]) - m4_ifdef( [[M4_YY_NO_TOP_STATE]],, - [[ - static int yy_top_state ( M4_YY_PROTO_ONLY_ARG ); - ]]) -]]) - -]], -[[ -m4_define( [[M4_YY_NO_PUSH_STATE]]) -m4_define( [[M4_YY_NO_POP_STATE]]) -m4_define( [[M4_YY_NO_TOP_STATE]]) -]]) -%endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -%if-c-only Standard (non-C++) definition -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -%endif -%if-c++-only C++ definition -#define ECHO LexerOutput( yytext, yyleng ) -%endif -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ -\ -%if-c++-only C++ definition \ - if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -%endif - -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif -]]) - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -%if-c-only -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) -%endif -%if-c++-only -#define YY_FATAL_ERROR(msg) LexerError( msg ) -%endif -#endif -]]) - -%if-tables-serialization structures and prototypes -m4preproc_include(`tables_shared.h') - -/* Load the DFA tables from the given stream. */ -int yytables_fload (FILE * fp M4_YY_PROTO_LAST_ARG); - -/* Unload the tables from memory. */ -int yytables_destroy (M4_YY_PROTO_ONLY_ARG); -%not-for-header - -/** Describes a mapping from a serialized table id to its deserialized state in - * this scanner. This is the bridge between our "generic" deserialization code - * and the specifics of this scanner. - */ -struct yytbl_dmap { - enum yytbl_id dm_id;/**< table identifier */ - void **dm_arr; /**< address of pointer to store the deserialized table. */ - size_t dm_sz; /**< local sizeof() each element in table. */ -}; - -/** A {0,0,0}-terminated list of structs, forming the map */ -static struct yytbl_dmap yydmap[] = -{ -%tables-yydmap generated elements - {0,0,0} -}; - -/** A tables-reader object to maintain some state in the read. */ -struct yytbl_reader { - FILE * fp; /**< input stream */ - flex_uint32_t bread; /**< bytes read since beginning of current tableset */ -}; - -%endif -/* end tables serialization structures and prototypes */ - -%ok-for-header - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 -%if-c-only Standard (non-C++) definition - - -m4_define( [[M4_YY_LEX_PROTO]], [[(M4_YY_PROTO_ONLY_ARG)]]) -m4_define( [[M4_YY_LEX_DECLARATION]], [[(M4_YY_DEF_ONLY_ARG)]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - m4_dnl The bison pure parser is used. Redefine yylex to - m4_dnl accept the lval parameter. - - m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[YYFARGS1(YYSTYPE *,yylval_param)]]) -]]) - -m4_ifdef( [[]], -[[ - m4_dnl Locations are used. yylex should also accept the ylloc parameter. - - m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]]) -]]) - -extern int yylex M4_YY_LEX_PROTO; - -#define YY_DECL int yylex M4_YY_LEX_DECLARATION -%endif -%if-c++-only C++ definition -#define YY_DECL int yyFlexLexer::yylex() -%endif -#endif /* !YY_DECL */ - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -%% [6.0] YY_RULE_SETUP definition goes here -]]) - -%not-for-header -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - M4_YY_DECL_GUTS_VAR(); - -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - m4_ifdef( [[M4_YY_BISON_LVAL]], - [[ - YYSTYPE * yylval; - ]]) - m4_ifdef( [[]], - [[ - YYLTYPE * yylloc; - ]]) -]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - yylval = yylval_param; -]]) - -m4_ifdef( [[]], -[[ - yylloc = yylloc_param; -]]) - - if ( !YY_G(yy_init) ) - { - YY_G(yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! YY_G(yy_state_buf) ) - YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_state_buf) ) - YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); -]]) - - if ( ! YY_G(yy_start) ) - YY_G(yy_start) = 1; /* first start state */ - - if ( ! yyin ) -%if-c-only - yyin = stdin; -%endif -%if-c++-only - yyin.rdbuf(std::cin.rdbuf()); -%endif - - if ( ! yyout ) -%if-c-only - yyout = stdout; -%endif -%if-c++-only - yyout.rdbuf(std::cout.rdbuf()); -%endif - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); - } - - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - } - - { -%% [7.0] user's declarations go here - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { -%% [8.0] yymore()-related code goes here - yy_cp = YY_G(yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = YY_G(yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - -%% [9.0] code to set up and find next match goes here - -yy_find_action: -%% [10.0] code to find the action number goes here - - YY_DO_BEFORE_ACTION; - -%% [11.0] code for yylineno update goes here - -do_action: /* This label is used only to access EOF actions. */ - -%% [12.0] debug code goes here - - switch ( yy_act ) - { /* beginning of action switch */ -%% [13.0] actions go here - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = YY_G(yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; -%if-c-only - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; -%endif -%if-c++-only - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); -%endif - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); - - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++YY_G(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { -%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) - { - case EOB_ACT_END_OF_FILE: - { - YY_G(yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = - YY_G(yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - YY_G(yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ -%ok-for-header - -%if-c++-only -%not-for-header -/* The contents of this function are C++ specific, so the YY_G macro is not used. - * This constructor simply maintains backward compatibility. - * DEPRECATED - */ -yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): - yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), - yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) -{ - ctor_common(); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): - yyin(arg_yyin.rdbuf()), - yyout(arg_yyout.rdbuf()) -{ - ctor_common(); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::ctor_common() -{ - yy_c_buf_p = 0; - yy_init = 0; - yy_start = 0; - yy_flex_debug = 0; - yylineno = 1; // this will only get updated if %option yylineno - - yy_did_buffer_switch_on_eof = 0; - - yy_looking_for_trail_begin = 0; - yy_more_flag = 0; - yy_more_len = 0; - yy_more_offset = yy_prev_more_offset = 0; - - yy_start_stack_ptr = yy_start_stack_depth = 0; - yy_start_stack = NULL; - - yy_buffer_stack = NULL; - yy_buffer_stack_top = 0; - yy_buffer_stack_max = 0; - - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; -]], -[[ - yy_state_buf = 0; -]]) -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -yyFlexLexer::~yyFlexLexer() -{ - delete [] yy_state_buf; - yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) -{ - // was if( new_in ) - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); - - // was if( new_out ) - yyout.rdbuf(new_out.rdbuf()); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) -{ - if( ! new_in ) { - new_in = &yyin; - } - - if ( ! new_out ) { - new_out = &yyout; - } - - switch_streams(*new_in, *new_out); -} - -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif -{ - if ( yyin.eof() || yyin.fail() ) - return 0; - -#ifdef YY_INTERACTIVE - yyin.get( buf[0] ); - - if ( yyin.eof() ) - return 0; - - if ( yyin.bad() ) - return -1; - - return 1; - -#else - (void) yyin.read( buf, max_size ); - - if ( yyin.bad() ) - return -1; - else - return yyin.gcount(); -#endif -} - -void yyFlexLexer::LexerOutput( const char* buf, int size ) -{ - (void) yyout.write( buf, size ); -} -%ok-for-header -%endif - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -%if-c-only -static int yy_get_next_buffer (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only -int yyFlexLexer::yy_get_next_buffer() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = YY_G(yytext_ptr); - int number_to_move, i; - int ret_val; - - if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -]], -[[ - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; -]]) - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - YY_G(yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } - - if ( YY_G(yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin M4_YY_CALL_LAST_ARG); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - YY_G(yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} -]]) - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -%if-c-only -%not-for-header - static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only - yy_state_type yyFlexLexer::yy_get_previous_state() -%endif -{ - yy_state_type yy_current_state; - char *yy_cp; - M4_YY_DECL_GUTS_VAR(); - -%% [15.0] code to get the start state into yy_current_state goes here - - for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) - { -%% [16.0] code to find the next state goes here - } - - return yy_current_state; -} - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ -%if-c-only - static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) -%endif -%if-c++-only - yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -%endif -{ - int yy_is_jam; - M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ -%% [17.0] code to find the next state, and perhaps do backing up, goes here - - M4_YY_NOOP_GUTS_VAR(); -return yy_is_jam ? 0 : yy_current_state; -} - - -#ifndef YY_NO_UNPUT -%if-c-only -m4_ifdef( [[M4_YY_NO_UNPUT]],, -[[ - static void yyunput YYFARGS2( int,c, char *,yy_bp) -%endif -%if-c++-only - void yyFlexLexer::yyunput( int c, char* yy_bp) -%endif -{ - char *yy_cp; - M4_YY_DECL_GUTS_VAR(); - - yy_cp = YY_G(yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = YY_G(yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = YY_G(yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - YY_G(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - -%% [18.0] update yylineno here -m4_ifdef( [[M4_YY_USE_LINENO]], -[[ - if ( c == '\n' ){ - --yylineno; - } -]]) - - YY_G(yytext_ptr) = yy_bp; - YY_G(yy_hold_char) = *yy_cp; - YY_G(yy_c_buf_p) = yy_cp; -} -%if-c-only -]]) -%endif -#endif - -%if-c-only -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (M4_YY_DEF_ONLY_ARG) -#else - static int input (M4_YY_DEF_ONLY_ARG) -#endif - -%endif -%if-c++-only - int yyFlexLexer::yyinput() -%endif -{ - int c; - M4_YY_DECL_GUTS_VAR(); - - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - - if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) - /* This was really a NUL. */ - *YY_G(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); - ++YY_G(yy_c_buf_p); - - switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin M4_YY_CALL_LAST_ARG); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - return 0; - - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(M4_YY_CALL_ONLY_ARG); -#else - return input(M4_YY_CALL_ONLY_ARG); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ - *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ - YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); - -%% [19.0] update BOL and yylineno - - return c; -} -%if-c-only -#endif /* ifndef YY_NO_INPUT */ -%endif - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * M4_YY_DOC_PARAM - * @note This function does not reset the start condition to @c INITIAL . - */ -%if-c-only - void yyrestart YYFARGS1( FILE *,input_file) -%endif -%if-c++-only - void yyFlexLexer::yyrestart( std::istream& input_file ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); -} - -%if-c++-only -/** Delegate to the new version that takes an istream reference. - * @param input_file A readable stream. - * M4_YY_DOC_PARAM - * @note This function does not reset the start condition to @c INITIAL . - */ -void yyFlexLexer::yyrestart( std::istream* input_file ) -{ - if( ! input_file ) { - input_file = &yyin; - } - yyrestart( *input_file ); -} -%endif - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * M4_YY_DOC_PARAM - */ -%if-c-only - void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) -%endif -%if-c++-only - void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - YY_G(yy_did_buffer_switch_on_eof) = 1; -} - - -%if-c-only -static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only - void yyFlexLexer::yy_load_buffer_state() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; -%if-c-only - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; -%endif -%if-c++-only - yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); -%endif - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * M4_YY_DOC_PARAM - * @return the allocated buffer state. - */ -%if-c-only - YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) -%endif -%if-c++-only - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) -%endif -{ - YY_BUFFER_STATE b; - m4_dnl M4_YY_DECL_GUTS_VAR(); - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); - - return b; -} - -%if-c++-only -/** Delegate creation of buffers to the new version that takes an istream reference. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * M4_YY_DOC_PARAM - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) -{ - return yy_create_buffer( *file, size ); -} -%endif - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * M4_YY_DOC_PARAM - */ -%if-c-only - void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) -%endif -%if-c++-only - void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); - - yyfree( (void *) b M4_YY_CALL_LAST_ARG ); -} - - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -%if-c-only - static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) -%endif -%if-c++-only - void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) -%endif - -{ - int oerrno = errno; - M4_YY_DECL_GUTS_VAR(); - - yy_flush_buffer( b M4_YY_CALL_LAST_ARG); - -%if-c-only - b->yy_input_file = file; -%endif -%if-c++-only - b->yy_input_file = file.rdbuf(); -%endif - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - -%if-c-only -m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], -[[ - b->yy_is_interactive = 1; -]], -[[ - m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], - [[ - b->yy_is_interactive = 0; - ]], - [[ - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - ]]) -]]) -%endif -%if-c++-only - b->yy_is_interactive = 0; -%endif - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * M4_YY_DOC_PARAM - */ -%if-c-only - void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) -%endif -%if-c++-only - void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); -} - -%if-c-or-c++ -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * M4_YY_DOC_PARAM - */ -%if-c-only -void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) -%endif -%if-c++-only -void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - YY_G(yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - YY_G(yy_did_buffer_switch_on_eof) = 1; -} -%endif - - -%if-c-or-c++ -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * M4_YY_DOC_PARAM - */ -%if-c-only -void yypop_buffer_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only -void yyFlexLexer::yypop_buffer_state (void) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (YY_G(yy_buffer_stack_top) > 0) - --YY_G(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - YY_G(yy_did_buffer_switch_on_eof) = 1; - } -} -%endif - - -%if-c-or-c++ -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -%if-c-only -static void yyensure_buffer_stack (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only -void yyFlexLexer::yyensure_buffer_stack(void) -%endif -{ - yy_size_t num_to_alloc; - M4_YY_DECL_GUTS_VAR(); - - if (!YY_G(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - - memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - YY_G(yy_buffer_stack_max) = num_to_alloc; - YY_G(yy_buffer_stack_top) = 0; - return; - } - - if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; - YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - (YY_G(yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - YY_G(yy_buffer_stack_max) = num_to_alloc; - } -} -%endif - - - - -m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, -[[ -%if-c-only -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) -{ - YY_BUFFER_STATE b; - m4_dnl M4_YY_DECL_GUTS_VAR(); - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); - - return b; -} -%endif -]]) - - -m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, -[[ -%if-c-only -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string YYFARGS1( const char *, yystr) -{ - m4_dnl M4_YY_DECL_GUTS_VAR(); - - return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); -} -%endif -]]) - - -m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, -[[ -%if-c-only -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * M4_YY_DOC_PARAM - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - m4_dnl M4_YY_DECL_GUTS_VAR(); - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} -%endif -]]) - - -m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, -[[ -%if-c-only - static void yy_push_state YYFARGS1( int ,_new_state) -%endif -%if-c++-only - void yyFlexLexer::yy_push_state( int _new_state ) -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) - { - yy_size_t new_size; - - YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; - new_size = (yy_size_t) YY_G(yy_start_stack_depth) * sizeof( int ); - - if ( ! YY_G(yy_start_stack) ) - YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); - - else - YY_G(yy_start_stack) = (int *) yyrealloc( - (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); - - if ( ! YY_G(yy_start_stack) ) - YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); - } - - YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; - - BEGIN(_new_state); -} -]]) - - -m4_ifdef( [[M4_YY_NO_POP_STATE]],, -[[ -%if-c-only - static void yy_pop_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only - void yyFlexLexer::yy_pop_state() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - if ( --YY_G(yy_start_stack_ptr) < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); -} -]]) - - -m4_ifdef( [[M4_YY_NO_TOP_STATE]],, -[[ -%if-c-only - static int yy_top_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only - int yyFlexLexer::yy_top_state() -%endif -{ - M4_YY_DECL_GUTS_VAR(); - return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; -} -]]) - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -%if-c-only -static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} -%endif -%if-c++-only -void yyFlexLexer::LexerError( const char* msg ) -{ - M4_YY_DECL_GUTS_VAR(); - std::cerr << msg << std::endl; - exit( YY_EXIT_FAILURE ); -} -%endif - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = YY_G(yy_hold_char); \ - YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ - *YY_G(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - - - -/* Accessor methods (get/set functions) to struct members. */ - -%if-c-only -%if-reentrant -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, -[[ -/** Get the user-defined data for this scanner. - * M4_YY_DOC_PARAM - */ -YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyextra; -} -]]) -%endif - -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, -[[ -/** Get the current line number. - * M4_YY_DOC_PARAM - */ -int yyget_lineno (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (! YY_CURRENT_BUFFER) - return 0; - ]]) - return yylineno; -} -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, -[[ -/** Get the current column number. - * M4_YY_DOC_PARAM - */ -int yyget_column (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (! YY_CURRENT_BUFFER) - return 0; - ]]) - return yycolumn; -} -]]) -]]) - -m4_ifdef( [[M4_YY_NO_GET_IN]],, -[[ -/** Get the input stream. - * M4_YY_DOC_PARAM - */ -FILE *yyget_in (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyin; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_OUT]],, -[[ -/** Get the output stream. - * M4_YY_DOC_PARAM - */ -FILE *yyget_out (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyout; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_LENG]],, -[[ -/** Get the length of the current token. - * M4_YY_DOC_PARAM - */ -int yyget_leng (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyleng; -} -]]) - -/** Get the current token. - * M4_YY_DOC_PARAM - */ -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, -[[ -char *yyget_text (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yytext; -} -]]) - -%if-reentrant -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, -[[ -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * M4_YY_DOC_PARAM - */ -void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) -{ - M4_YY_DECL_GUTS_VAR(); - yyextra = user_defined ; -} -]]) -%endif - -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, -[[ -/** Set the current line number. - * @param _line_number line number - * M4_YY_DOC_PARAM - */ -void yyset_lineno YYFARGS1( int ,_line_number) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - ]]) - yylineno = _line_number; -} -]]) - -m4_ifdef( [[M4_YY_REENTRANT]], -[[ -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, -[[ -/** Set the current column. - * @param _column_no column number - * M4_YY_DOC_PARAM - */ -void yyset_column YYFARGS1( int , _column_no) -{ - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - ]]) - yycolumn = _column_no; -} -]]) -]]) - - -m4_ifdef( [[M4_YY_NO_SET_IN]],, -[[ -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * M4_YY_DOC_PARAM - * @see yy_switch_to_buffer - */ -void yyset_in YYFARGS1( FILE * ,_in_str) -{ - M4_YY_DECL_GUTS_VAR(); - yyin = _in_str ; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_OUT]],, -[[ -void yyset_out YYFARGS1( FILE * ,_out_str) -{ - M4_YY_DECL_GUTS_VAR(); - yyout = _out_str ; -} -]]) - - -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, -[[ -int yyget_debug (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yy_flex_debug; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, -[[ -void yyset_debug YYFARGS1( int ,_bdebug) -{ - M4_YY_DECL_GUTS_VAR(); - yy_flex_debug = _bdebug ; -} -]]) -%endif - -%if-reentrant -/* Accessor methods for yylval and yylloc */ - -%if-bison-bridge -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yylval; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_LVAL]],, -[[ -void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) -{ - M4_YY_DECL_GUTS_VAR(); - yylval = yylval_param; -} -]]) - -m4_ifdef( [[]], -[[ - m4_ifdef( [[M4_YY_NO_GET_LLOC]],, - [[ -YYLTYPE *yyget_lloc (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yylloc; -} - ]]) - - m4_ifdef( [[M4_YY_NO_SET_LLOC]],, - [[ -void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) -{ - M4_YY_DECL_GUTS_VAR(); - yylloc = yylloc_param; -} - ]]) -]]) - -%endif - - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - - -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -%endif if-c-only -%# Actually, that ended an if-rentrant section - -%if-c-only -static int yy_init_globals (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - -m4_ifdef( [[M4_YY_USE_LINENO]], -[[ - m4_ifdef( [[M4_YY_NOT_REENTRANT]], - [[ - /* We do not touch yylineno unless the option is enabled. */ - yylineno = 1; - ]]) -]]) - YY_G(yy_buffer_stack) = NULL; - YY_G(yy_buffer_stack_top) = 0; - YY_G(yy_buffer_stack_max) = 0; - YY_G(yy_c_buf_p) = NULL; - YY_G(yy_init) = 0; - YY_G(yy_start) = 0; - -m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], -[[ - YY_G(yy_start_stack_ptr) = 0; - YY_G(yy_start_stack_depth) = 0; - YY_G(yy_start_stack) = NULL; -]]) - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - YY_G(yy_state_buf) = 0; - YY_G(yy_state_ptr) = 0; - YY_G(yy_full_match) = 0; - YY_G(yy_lp) = 0; -]]) - -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], -[[ - YY_G(yytext_ptr) = 0; - YY_G(yy_more_offset) = 0; - YY_G(yy_prev_more_offset) = 0; -]]) - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} -%endif - - -%if-c-only SNIP! this currently causes conflicts with the c++ scanner -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(M4_YY_CALL_ONLY_ARG); - } - - /* Destroy the stack itself. */ - yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); - YY_G(yy_buffer_stack) = NULL; - -m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], -[[ - /* Destroy the start condition stack. */ - yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); - YY_G(yy_start_stack) = NULL; -]]) - -m4_ifdef( [[M4_YY_USES_REJECT]], -[[ - yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); - YY_G(yy_state_buf) = NULL; -]]) - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( M4_YY_CALL_ONLY_ARG); - -%if-reentrant - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); - yyscanner = NULL; -%endif - return 0; -} -%endif - - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* - * Internal utility routines. - */ -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#ifndef yytext_ptr -static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YYFARGS1( const char *,s) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc YYFARGS1( yy_size_t ,size) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - return malloc(size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree YYFARGS1( void *,ptr) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} -]]) - -%if-tables-serialization definitions -m4preproc_include(`tables_shared.c') - -static int yytbl_read8 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - rd->bread += (flex_uint32_t) sizeof(flex_uint8_t); - return 0; -} - -static int yytbl_read16 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); - rd->bread += (flex_uint32_t) sizeof(flex_uint16_t); - return 0; -} - -static int yytbl_read32 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); - rd->bread += (flex_uint32_t) sizeof(flex_uint32_t); - return 0; -} - -/** Read the header */ -static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) -{ - size_t bytes; - memset (th, 0, sizeof (struct yytbl_hdr)); - - if (yytbl_read32 (&(th->th_magic), rd) != 0) - return -1; - - if (th->th_magic != YYTBL_MAGIC){ - YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ - return -1; - } - - if (yytbl_read32 (&(th->th_hsize), rd) != 0 - || yytbl_read32 (&(th->th_ssize), rd) != 0 - || yytbl_read16 (&(th->th_flags), rd) != 0) - return -1; - - /* Sanity check on header size. Greater than 1k suggests some funny business. */ - if (th->th_hsize < 16 || th->th_hsize > 1024){ - YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate enough space for the version and name fields */ - bytes = th->th_hsize - 14; - th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! th->th_version ) - YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); - - /* we read it all into th_version, and point th_name into that data */ - if (fread (th->th_version, 1, bytes, rd->fp) != bytes){ - errno = EIO; - yyfree(th->th_version M4_YY_CALL_LAST_ARG); - th->th_version = NULL; - return -1; - } - else - rd->bread += (flex_uint32_t) bytes; - - th->th_name = th->th_version + strlen (th->th_version) + 1; - return 0; -} - -/** lookup id in the dmap list. - * @param dmap pointer to first element in list - * @return NULL if not found. - */ -static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, - int, id) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - - while (dmap->dm_id) - if ((int)(dmap->dm_id) == id) - return dmap; - else - dmap++; - return NULL; -} - -/** Read a table while mapping its contents to the local array. - * @param dmap used to performing mapping - * @return 0 on success - */ -static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) -{ - struct yytbl_data td; - struct yytbl_dmap *transdmap=0; - int len, i, rv, inner_loop_count; - void *p=0; - - memset (&td, 0, sizeof (struct yytbl_data)); - - if (yytbl_read16 (&td.td_id, rd) != 0 - || yytbl_read16 (&td.td_flags, rd) != 0 - || yytbl_read32 (&td.td_hilen, rd) != 0 - || yytbl_read32 (&td.td_lolen, rd) != 0) - return -1; - - /* Lookup the map for the transition table so we have it in case we need it - * inside the loop below. This scanner might not even have a transition - * table, which is ok. - */ - transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); - - if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){ - YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate space for table. - * The --full yy_transition table is a special case, since we - * need the dmap.dm_sz entry to tell us the sizeof the individual - * struct members. - */ - { - size_t bytes; - - if ((td.td_flags & YYTD_STRUCT)) - bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); - else - bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; - - if(M4_YY_TABLES_VERIFY) - /* We point to the array itself */ - p = dmap->dm_arr; - else - /* We point to the address of a pointer. */ - *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! p ) - YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); - } - - /* If it's a struct, we read 2 integers to get one element */ - if ((td.td_flags & YYTD_STRUCT) != 0) - inner_loop_count = 2; - else - inner_loop_count = 1; - - /* read and map each element. - * This loop iterates once for each element of the td_data array. - * Notice that we increment 'i' in the inner loop. - */ - len = yytbl_calc_total_len (&td); - for (i = 0; i < len; ){ - int j; - - - /* This loop really executes exactly 1 or 2 times. - * The second time is to handle the second member of the - * YYTD_STRUCT for the yy_transition array. - */ - for (j = 0; j < inner_loop_count; j++, i++) { - flex_int32_t t32; - - /* read into t32 no matter what the real size is. */ - { - flex_int16_t t16; - flex_int8_t t8; - - switch (YYTDFLAGS2BYTES (td.td_flags)) { - case sizeof (flex_int32_t): - rv = yytbl_read32 (&t32, rd); - break; - case sizeof (flex_int16_t): - rv = yytbl_read16 (&t16, rd); - t32 = t16; - break; - case sizeof (flex_int8_t): - rv = yytbl_read8 (&t8, rd); - t32 = t8; - break; - default: - YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ - return -1; - } - } - if (rv != 0) - return -1; - - /* copy into the deserialized array... */ - - if ((td.td_flags & YYTD_STRUCT)) { - /* t32 is the j'th member of a two-element struct. */ - void *v; - - v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) - : &(((struct yy_trans_info *) p)->yy_nxt); - - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if (M4_YY_TABLES_VERIFY){ - if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); - }else - ((flex_int32_t *) v)[0] = (flex_int32_t) t32; - break; - case sizeof (flex_int16_t): - if (M4_YY_TABLES_VERIFY ){ - if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); - }else - ((flex_int16_t *) v)[0] = (flex_int16_t) t32; - break; - case sizeof(flex_int8_t): - if (M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); - }else - ((flex_int8_t *) v)[0] = (flex_int8_t) t32; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ - return -1; - } - - /* if we're done with j, increment p */ - if (j == 1) - p = (struct yy_trans_info *) p + 1; - } - else if ((td.td_flags & YYTD_PTRANS)) { - /* t32 is an index into the transition array. */ - struct yy_trans_info *v; - - - if (!transdmap){ - YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ - return -1; - } - - if( M4_YY_TABLES_VERIFY) - v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); - else - v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); - - if(M4_YY_TABLES_VERIFY ){ - if( ((struct yy_trans_info **) p)[0] != v) - YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); - }else - ((struct yy_trans_info **) p)[0] = v; - - /* increment p */ - p = (struct yy_trans_info **) p + 1; - } - else { - /* t32 is a plain int. copy data, then incrememnt p. */ - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); - }else - ((flex_int32_t *) p)[0] = (flex_int32_t) t32; - p = ((flex_int32_t *) p) + 1; - break; - case sizeof (flex_int16_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); - }else - ((flex_int16_t *) p)[0] = (flex_int16_t) t32; - p = ((flex_int16_t *) p) + 1; - break; - case sizeof (flex_int8_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); - }else - ((flex_int8_t *) p)[0] = (flex_int8_t) t32; - p = ((flex_int8_t *) p) + 1; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ - return -1; - } - } - } - - } - - /* Now eat padding. */ - { - while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) { - flex_int8_t t8; - if(yytbl_read8(&t8,rd) != 0) - return -1; - } - } - - return 0; -} - -%define-yytables The name for this specific scanner's tables. - -/* Find the key and load the DFA tables from the given stream. */ -static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) -{ - int rv=0; - struct yytbl_hdr th; - struct yytbl_reader rd; - - rd.fp = fp; - th.th_version = NULL; - - /* Keep trying until we find the right set of tables or end of file. */ - while (!feof(rd.fp)) { - rd.bread = 0; - if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - - /* A NULL key means choose the first set of tables. */ - if (key == NULL) - break; - - if (strcmp(th.th_name,key) != 0){ - /* Skip ahead to next set */ - fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - else - break; - } - - while (rd.bread < th.th_ssize){ - /* Load the data tables */ - if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - } - -return_rv: - if(th.th_version){ - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - - return rv; -} - -/** Load the DFA tables for this scanner from the given stream. */ -int yytables_fload YYFARGS1(FILE *, fp) -{ - - if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) - return -1; - return 0; -} - -/** Destroy the loaded tables, freeing memory, etc.. */ -int yytables_destroy (M4_YY_DEF_ONLY_ARG) -{ - struct yytbl_dmap *dmap=0; - - if(!M4_YY_TABLES_VERIFY){ - /* Walk the dmap, freeing the pointers */ - for(dmap=yydmap; dmap->dm_id; dmap++) { - void * v; - v = dmap->dm_arr; - if(v && *(char**)v){ - yyfree(*(char**)v M4_YY_CALL_LAST_ARG); - *(char**)v = NULL; - } - } - } - - return 0; -} - -/* end table serialization code definitions */ -%endif - - -m4_ifdef([[M4_YY_MAIN]], [[ -int main (void); - -int main () -{ - -%if-reentrant - yyscan_t lexer; - yylex_init(&lexer); - yylex( lexer ); - yylex_destroy( lexer); - -%endif -%if-not-reentrant - yylex(); -%endif - - return 0; -} -]]) - -%ok-for-header -m4_ifdef( [[M4_YY_IN_HEADER]], -[[ -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif -m4preproc_undivert(1) -]]) diff --git a/src/flexdef.h b/src/flexdef.h index a0fb522..8c3ea2f 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,6 +306,7 @@ /* Method table describing a language-specific back end */ struct flex_backend_t { + const char **skel; void (*prolog)(void); void (*wrap)(void); char *line_fmt; diff --git a/src/main.c b/src/main.c index 85df365..a2b60cb 100644 --- a/src/main.c +++ b/src/main.c @@ -1896,7 +1896,13 @@ static void cpp_wrap (void) #endif } +const char *cpp_skel[] = { +#include "cpp-skel.h" + 0, +}; + struct flex_backend_t cpp_backend = { + .skel = cpp_skel, .prolog = cpp_prolog, .wrap = cpp_wrap, .line_fmt = "#line %d \"%s\"\n", diff --git a/src/misc.c b/src/misc.c index f6dae41..975729e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -701,11 +701,11 @@ void skelout (void) /* Loop pulling lines either from the skelfile, if we're using - * one, or from the skel[] array. + * one, or from the selected back end's skel[] array. */ while (skelfile ? (fgets (buf, MAXLINE, skelfile) != NULL) : - ((buf = (char *) skel[skel_ind++]) != 0)) { + ((buf = (char *) backend->skel[skel_ind++]) != 0)) { if (skelfile) chomp (buf); diff --git a/src/mkskel.sh b/src/mkskel.sh index 2d6ae9f..6eb5b60 100755 --- a/src/mkskel.sh +++ b/src/mkskel.sh @@ -21,18 +21,14 @@ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE. -if test ! $# = 3; then - echo 'Usage: mkskel.sh srcdir m4 version' >&2 +if test ! $# = 4; then + echo 'Usage: mkskel.sh lang srcdir m4 version' >&2 exit 1 fi -echo '/* File created from flex.skl via mkskel.sh */ - -#include "flexdef.h" - -const char *skel[] = {' -srcdir=$1 -m4=$2 -VERSION=$3 +lang=$1 +srcdir=$2 +m4=$3 +VERSION=$4 case $VERSION in *[!0-9.]*) echo 'Invalid version number' >&2; exit 1;; esac @@ -40,7 +36,7 @@ IFS=. set $VERSION sed 's/4_/a4_/g s/m4preproc_/m4_/g -' "$srcdir/flex.skl" | +' "$srcdir/${lang}-flex.skl" | "$m4" -P -I "$srcdir" "-DFLEX_MAJOR_VERSION=$1" \ "-DFLEX_MINOR_VERSION=$2" \ "-DFLEX_SUBMINOR_VERSION=$3" | @@ -49,6 +45,3 @@ s/m4_/m4preproc_/g s/a4_/4_/g s/[\\"]/\\&/g s/[^\r]*/ "&",/' - -echo ' 0 -};' -- cgit v1.2.1 From 2cce209b584bf87a01038c33a09b361d82a18b0b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 5 Sep 2020 10:31:54 -0400 Subject: The C/C++ back end moves to its own source file. Someday, there might be go-backend.c etc. #6 in the retargeting patch series --- src/Makefile.am | 1 + src/cpp_backend.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 352 ------------------------------------------------ 3 files changed, 391 insertions(+), 352 deletions(-) create mode 100644 src/cpp_backend.c diff --git a/src/Makefile.am b/src/Makefile.am index 7d70538..40ca850 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,6 +53,7 @@ flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS) COMMON_SOURCES = \ buf.c \ ccl.c \ + cpp_backend.c \ cpp_skel.h \ dfa.c \ ecs.c \ diff --git a/src/cpp_backend.c b/src/cpp_backend.c new file mode 100644 index 0000000..d0a57c8 --- /dev/null +++ b/src/cpp_backend.c @@ -0,0 +1,390 @@ +/* flex - tool to generate fast lexical analyzers */ + +/* Copyright (c) 1990 The Regents of the University of California. */ +/* All rights reserved. */ + +/* This code is derived from software contributed to Berkeley by */ +/* Vern Paxson. */ + +/* The United States Government has rights in this work pursuant */ +/* to contract no. DE-AC03-76SF00098 between the United States */ +/* Department of Energy and the University of California. */ + +/* This file is part of flex. */ + +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions */ +/* are met: */ + +/* 1. Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in the */ +/* documentation and/or other materials provided with the distribution. */ + +/* Neither the name of the University nor the names of its contributors */ +/* may be used to endorse or promote products derived from this software */ +/* without specific prior written permission. */ + +/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */ +/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ +/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ +/* PURPOSE. */ + + +#include "flexdef.h" +#include "version.h" + +/* Code specific to the C/C++ back end starts here */ + +/* cpp_prolog - make rules prolog pecific to cpp-using languages. + * + * If you don't ship this, you will effectively be assuming that your + * parsers are always reentrant, always allow reject, always have a + * yywrap() method, have a debug member in the wrapper class, and are + * interactive. This eliminates most of the boilerplate in the C/C++ + * scanner prolog. It means such parsers will be a bit larger and + * slower than C/C++ ones, but since we're not runing on 1987's + * hardware we officially do not care. + * + * A detail to beware of: If you're not issuing this prologue, you + * may want to issue your own definition of YY_CHAR. It's a typedef + * to an unsigned octet in C/C++, but if your target language has a + * Unicode code-point type like Go's 'rune' is may be appropriate. + */ + +static void cpp_prolog (void) +{ + static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; + static char yy_nostdinit[] = + "FILE *yyin = NULL, *yyout = NULL;"; + + if (reject){ + out_m4_define( "M4_YY_USES_REJECT", NULL); + //outn ("\n#define YY_USES_REJECT"); + } + + if (!do_yywrap) { + if (!C_plus_plus) { + if (reentrant) + out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix); + else + out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix); + } + outn ("#define YY_SKIP_YYWRAP"); + } + + if (ddebug) + outn ("\n#define FLEX_DEBUG"); + + OUT_BEGIN_CODE (); + outn ("typedef flex_uint8_t YY_CHAR;"); + OUT_END_CODE (); + + if (C_plus_plus) { + outn ("#define yytext_ptr yytext"); + + if (interactive) + outn ("#define YY_INTERACTIVE"); + } + + else { + OUT_BEGIN_CODE (); + /* In reentrant scanner, stdinit is handled in flex.skl. */ + if (do_stdinit) { + if (reentrant){ + outn ("#ifdef VMS"); + outn ("#ifdef __VMS_POSIX"); + outn ("#define YY_STDINIT"); + outn ("#endif"); + outn ("#else"); + outn ("#define YY_STDINIT"); + outn ("#endif"); + } + + outn ("#ifdef VMS"); + outn ("#ifndef __VMS_POSIX"); + outn (yy_nostdinit); + outn ("#else"); + outn (yy_stdinit); + outn ("#endif"); + outn ("#else"); + outn (yy_stdinit); + outn ("#endif"); + } + + else { + if(!reentrant) + outn (yy_nostdinit); + } + OUT_END_CODE (); + } + + OUT_BEGIN_CODE (); + if (fullspd) + outn ("typedef const struct yy_trans_info *yy_state_type;"); + else if (!C_plus_plus) + outn ("typedef int yy_state_type;"); + OUT_END_CODE (); + + if (lex_compat) + outn ("#define YY_FLEX_LEX_COMPAT"); + + if (!C_plus_plus && !reentrant) { + outn ("extern int yylineno;"); + OUT_BEGIN_CODE (); + outn ("int yylineno = 1;"); + OUT_END_CODE (); + } + + if (C_plus_plus) { + outn ("\n#include "); + + if (!do_yywrap) { + outn("\nint yyFlexLexer::yywrap() { return 1; }"); + } + + if (yyclass) { + outn ("int yyFlexLexer::yylex()"); + outn ("\t{"); + outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );"); + outn ("\treturn 0;"); + outn ("\t}"); + + out_str ("\n#define YY_DECL int %s::yylex()\n", + yyclass); + } + } + + else { + + /* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ + if (yytext_is_array) { + if (!reentrant) + outn ("extern char yytext[];\n"); + } + else { + if (reentrant) { + outn ("#define yytext_ptr yytext_r"); + } + else { + outn ("extern char *yytext;"); + + outn("#ifdef yytext_ptr"); + outn("#undef yytext_ptr"); + outn("#endif"); + outn ("#define yytext_ptr yytext"); + } + } + + if (yyclass) + flexerror (_ + ("%option yyclass only meaningful for C++ scanners")); + } +} + +static void cpp_wrap (void) +{ +#if 0 + fprintf (header_out, + "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n"); + fprintf (header_out, + "/* Beware! Start conditions are not prefixed. */\n"); + + /* Special case for "INITIAL" */ + fprintf (header_out, + "#undef INITIAL\n#define INITIAL 0\n"); + for (i = 2; i <= lastsc; i++) + fprintf (header_out, "#define %s %d\n", scname[i], i - 1); + fprintf (header_out, + "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); + + /* Kill ALL flex-related macros. This is so the user + * can #include more than one generated header file. */ + fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n"); + fprintf (header_out, + "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n"); + + { + const char * undef_list[] = { + + "BEGIN", + "ECHO", + "EOB_ACT_CONTINUE_SCAN", + "EOB_ACT_END_OF_FILE", + "EOB_ACT_LAST_MATCH", + "FLEX_SCANNER", + "REJECT", + "YYFARGS0", + "YYFARGS1", + "YYFARGS2", + "YYFARGS3", + "YYLMAX", + "YYSTATE", + "YY_AT_BOL", + "YY_BREAK", + "YY_BUFFER_EOF_PENDING", + "YY_BUFFER_NEW", + "YY_BUFFER_NORMAL", + "YY_BUF_SIZE", + "M4_YY_CALL_LAST_ARG", + "M4_YY_CALL_ONLY_ARG", + "YY_CURRENT_BUFFER", + "YY_DECL", + "M4_YY_DECL_LAST_ARG", + "M4_YY_DEF_LAST_ARG", + "M4_YY_DEF_ONLY_ARG", + "YY_DO_BEFORE_ACTION", + "YY_END_OF_BUFFER", + "YY_END_OF_BUFFER_CHAR", + "YY_EXIT_FAILURE", + "YY_EXTRA_TYPE", + "YY_FATAL_ERROR", + "YY_FLEX_DEFINED_ECHO", + "YY_FLEX_LEX_COMPAT", + "YY_FLEX_MAJOR_VERSION", + "YY_FLEX_MINOR_VERSION", + "YY_FLEX_SUBMINOR_VERSION", + "YY_FLUSH_BUFFER", + "YY_G", + "YY_INPUT", + "YY_INTERACTIVE", + "YY_INT_ALIGNED", + "YY_LAST_ARG", + "YY_LESS_LINENO", + "YY_LEX_ARGS", + "YY_LEX_DECLARATION", + "YY_LEX_PROTO", + "YY_MAIN", + "YY_MORE_ADJ", + "YY_NEED_STRLEN", + "YY_NEW_FILE", + "YY_NULL", + "YY_NUM_RULES", + "YY_ONLY_ARG", + "YY_PARAMS", + "YY_PROTO", + "M4_YY_PROTO_LAST_ARG", + "M4_YY_PROTO_ONLY_ARG void", + "YY_READ_BUF_SIZE", + "YY_REENTRANT", + "YY_RESTORE_YY_MORE_OFFSET", + "YY_RULE_SETUP", + "YY_SC_TO_UI", + "YY_SKIP_YYWRAP", + "YY_START", + "YY_START_STACK_INCR", + "YY_STATE_EOF", + "YY_STDINIT", + "YY_TRAILING_HEAD_MASK", + "YY_TRAILING_MASK", + "YY_USER_ACTION", + "YY_USE_CONST", + "YY_USE_PROTOS", + "unput", + "yyTABLES_NAME", + "yy_create_buffer", + "yy_delete_buffer", + "yy_flex_debug", + "yy_flush_buffer", + "yy_init_buffer", + "yy_load_buffer_state", + "yy_new_buffer", + "yy_scan_buffer", + "yy_scan_bytes", + "yy_scan_string", + "yy_set_bol", + "yy_set_interactive", + "yy_switch_to_buffer", + "yypush_buffer_state", + "yypop_buffer_state", + "yyensure_buffer_stack", + "yyalloc", + "const", + "yyextra", + "yyfree", + "yyget_debug", + "yyget_extra", + "yyget_in", + "yyget_leng", + "yyget_column", + "yyget_lineno", + "yyget_lloc", + "yyget_lval", + "yyget_out", + "yyget_text", + "yyin", + "yyleng", + "yyless", + "yylex", + "yylex_destroy", + "yylex_init", + "yylex_init_extra", + "yylineno", + "yylloc", + "yylval", + "yymore", + "yyout", + "yyrealloc", + "yyrestart", + "yyset_debug", + "yyset_extra", + "yyset_in", + "yyset_column", + "yyset_lineno", + "yyset_lloc", + "yyset_lval", + "yyset_out", + "yytables_destroy", + "yytables_fload", + "yyterminate", + "yytext", + "yytext_ptr", + "yywrap", + + /* must be null-terminated */ + NULL}; + + + for (i=0; undef_list[i] != NULL; i++) + fprintf (header_out, "#undef %s\n", undef_list[i]); + } + + /* undef any of the auto-generated symbols. */ + for (i = 0; i < defs_buf.nelts; i++) { + + /* don't undef start conditions */ + if (sclookup (((char **) defs_buf.elts)[i]) > 0) + continue; + fprintf (header_out, "#undef %s\n", + ((char **) defs_buf.elts)[i]); + } + + fprintf (header_out, + "#endif /* !YY_HEADER_NO_UNDEFS */\n"); + fprintf (header_out, "\n"); + fprintf (header_out, "#undef %sIN_HEADER\n", prefix); + fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix); + + if (ferror (header_out)) + lerr (_("error creating header file %s"), + headerfilename); + fflush (header_out); + fclose (header_out); +#endif +} + +const char *cpp_skel[] = { +#include "cpp-skel.h" + 0, +}; + +/* This backend is only accessed through this method table */ +struct flex_backend_t cpp_backend = { + .skel = cpp_skel, + .prolog = cpp_prolog, + .wrap = cpp_wrap, + .line_fmt = "#line %d \"%s\"\n", +}; diff --git a/src/main.c b/src/main.c index a2b60cb..3900e08 100644 --- a/src/main.c +++ b/src/main.c @@ -1555,355 +1555,3 @@ void usage (void) } -/* Code specific to the C/C++ back end starts here */ - -/* cpp_prolog - make rules prolog pecific to cpp-using languages. - * - * If you don't ship this, you will effectively be assuming that your - * parsers are always reentrant, always allow reject, always have a - * yywrap() method, have a debug member in the wrapper class, and are - * interactive. This eliminates most of the boilerplate in the C/C++ - * scanner prolog. It means such parsers will be a bit larger and - * slower than C/C++ ones, but since we're not runing on 1987's - * hardware we officially do not care. - * - * A detail to beware of: If you're not issuing this prologue, you - * may want to issue your own definition of YY_CHAR. It's a typedef - * to an unsigned octet in C/C++, but if your target language has a - * Unicode code-point type like Go's 'rune' is may be appropriate. - */ - -static void cpp_prolog (void) -{ - static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; - static char yy_nostdinit[] = - "FILE *yyin = NULL, *yyout = NULL;"; - - if (reject){ - out_m4_define( "M4_YY_USES_REJECT", NULL); - //outn ("\n#define YY_USES_REJECT"); - } - - if (!do_yywrap) { - if (!C_plus_plus) { - if (reentrant) - out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix); - else - out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix); - } - outn ("#define YY_SKIP_YYWRAP"); - } - - if (ddebug) - outn ("\n#define FLEX_DEBUG"); - - OUT_BEGIN_CODE (); - outn ("typedef flex_uint8_t YY_CHAR;"); - OUT_END_CODE (); - - if (C_plus_plus) { - outn ("#define yytext_ptr yytext"); - - if (interactive) - outn ("#define YY_INTERACTIVE"); - } - - else { - OUT_BEGIN_CODE (); - /* In reentrant scanner, stdinit is handled in flex.skl. */ - if (do_stdinit) { - if (reentrant){ - outn ("#ifdef VMS"); - outn ("#ifdef __VMS_POSIX"); - outn ("#define YY_STDINIT"); - outn ("#endif"); - outn ("#else"); - outn ("#define YY_STDINIT"); - outn ("#endif"); - } - - outn ("#ifdef VMS"); - outn ("#ifndef __VMS_POSIX"); - outn (yy_nostdinit); - outn ("#else"); - outn (yy_stdinit); - outn ("#endif"); - outn ("#else"); - outn (yy_stdinit); - outn ("#endif"); - } - - else { - if(!reentrant) - outn (yy_nostdinit); - } - OUT_END_CODE (); - } - - OUT_BEGIN_CODE (); - if (fullspd) - outn ("typedef const struct yy_trans_info *yy_state_type;"); - else if (!C_plus_plus) - outn ("typedef int yy_state_type;"); - OUT_END_CODE (); - - if (lex_compat) - outn ("#define YY_FLEX_LEX_COMPAT"); - - if (!C_plus_plus && !reentrant) { - outn ("extern int yylineno;"); - OUT_BEGIN_CODE (); - outn ("int yylineno = 1;"); - OUT_END_CODE (); - } - - if (C_plus_plus) { - outn ("\n#include "); - - if (!do_yywrap) { - outn("\nint yyFlexLexer::yywrap() { return 1; }"); - } - - if (yyclass) { - outn ("int yyFlexLexer::yylex()"); - outn ("\t{"); - outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );"); - outn ("\treturn 0;"); - outn ("\t}"); - - out_str ("\n#define YY_DECL int %s::yylex()\n", - yyclass); - } - } - - else { - - /* Watch out: yytext_ptr is a variable when yytext is an array, - * but it's a macro when yytext is a pointer. - */ - if (yytext_is_array) { - if (!reentrant) - outn ("extern char yytext[];\n"); - } - else { - if (reentrant) { - outn ("#define yytext_ptr yytext_r"); - } - else { - outn ("extern char *yytext;"); - - outn("#ifdef yytext_ptr"); - outn("#undef yytext_ptr"); - outn("#endif"); - outn ("#define yytext_ptr yytext"); - } - } - - if (yyclass) - flexerror (_ - ("%option yyclass only meaningful for C++ scanners")); - } -} - -static void cpp_wrap (void) -{ -#if 0 - fprintf (header_out, - "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n"); - fprintf (header_out, - "/* Beware! Start conditions are not prefixed. */\n"); - - /* Special case for "INITIAL" */ - fprintf (header_out, - "#undef INITIAL\n#define INITIAL 0\n"); - for (i = 2; i <= lastsc; i++) - fprintf (header_out, "#define %s %d\n", scname[i], i - 1); - fprintf (header_out, - "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); - - /* Kill ALL flex-related macros. This is so the user - * can #include more than one generated header file. */ - fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n"); - fprintf (header_out, - "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n"); - - { - const char * undef_list[] = { - - "BEGIN", - "ECHO", - "EOB_ACT_CONTINUE_SCAN", - "EOB_ACT_END_OF_FILE", - "EOB_ACT_LAST_MATCH", - "FLEX_SCANNER", - "REJECT", - "YYFARGS0", - "YYFARGS1", - "YYFARGS2", - "YYFARGS3", - "YYLMAX", - "YYSTATE", - "YY_AT_BOL", - "YY_BREAK", - "YY_BUFFER_EOF_PENDING", - "YY_BUFFER_NEW", - "YY_BUFFER_NORMAL", - "YY_BUF_SIZE", - "M4_YY_CALL_LAST_ARG", - "M4_YY_CALL_ONLY_ARG", - "YY_CURRENT_BUFFER", - "YY_DECL", - "M4_YY_DECL_LAST_ARG", - "M4_YY_DEF_LAST_ARG", - "M4_YY_DEF_ONLY_ARG", - "YY_DO_BEFORE_ACTION", - "YY_END_OF_BUFFER", - "YY_END_OF_BUFFER_CHAR", - "YY_EXIT_FAILURE", - "YY_EXTRA_TYPE", - "YY_FATAL_ERROR", - "YY_FLEX_DEFINED_ECHO", - "YY_FLEX_LEX_COMPAT", - "YY_FLEX_MAJOR_VERSION", - "YY_FLEX_MINOR_VERSION", - "YY_FLEX_SUBMINOR_VERSION", - "YY_FLUSH_BUFFER", - "YY_G", - "YY_INPUT", - "YY_INTERACTIVE", - "YY_INT_ALIGNED", - "YY_LAST_ARG", - "YY_LESS_LINENO", - "YY_LEX_ARGS", - "YY_LEX_DECLARATION", - "YY_LEX_PROTO", - "YY_MAIN", - "YY_MORE_ADJ", - "YY_NEED_STRLEN", - "YY_NEW_FILE", - "YY_NULL", - "YY_NUM_RULES", - "YY_ONLY_ARG", - "YY_PARAMS", - "YY_PROTO", - "M4_YY_PROTO_LAST_ARG", - "M4_YY_PROTO_ONLY_ARG void", - "YY_READ_BUF_SIZE", - "YY_REENTRANT", - "YY_RESTORE_YY_MORE_OFFSET", - "YY_RULE_SETUP", - "YY_SC_TO_UI", - "YY_SKIP_YYWRAP", - "YY_START", - "YY_START_STACK_INCR", - "YY_STATE_EOF", - "YY_STDINIT", - "YY_TRAILING_HEAD_MASK", - "YY_TRAILING_MASK", - "YY_USER_ACTION", - "YY_USE_CONST", - "YY_USE_PROTOS", - "unput", - "yyTABLES_NAME", - "yy_create_buffer", - "yy_delete_buffer", - "yy_flex_debug", - "yy_flush_buffer", - "yy_init_buffer", - "yy_load_buffer_state", - "yy_new_buffer", - "yy_scan_buffer", - "yy_scan_bytes", - "yy_scan_string", - "yy_set_bol", - "yy_set_interactive", - "yy_switch_to_buffer", - "yypush_buffer_state", - "yypop_buffer_state", - "yyensure_buffer_stack", - "yyalloc", - "const", - "yyextra", - "yyfree", - "yyget_debug", - "yyget_extra", - "yyget_in", - "yyget_leng", - "yyget_column", - "yyget_lineno", - "yyget_lloc", - "yyget_lval", - "yyget_out", - "yyget_text", - "yyin", - "yyleng", - "yyless", - "yylex", - "yylex_destroy", - "yylex_init", - "yylex_init_extra", - "yylineno", - "yylloc", - "yylval", - "yymore", - "yyout", - "yyrealloc", - "yyrestart", - "yyset_debug", - "yyset_extra", - "yyset_in", - "yyset_column", - "yyset_lineno", - "yyset_lloc", - "yyset_lval", - "yyset_out", - "yytables_destroy", - "yytables_fload", - "yyterminate", - "yytext", - "yytext_ptr", - "yywrap", - - /* must be null-terminated */ - NULL}; - - - for (i=0; undef_list[i] != NULL; i++) - fprintf (header_out, "#undef %s\n", undef_list[i]); - } - - /* undef any of the auto-generated symbols. */ - for (i = 0; i < defs_buf.nelts; i++) { - - /* don't undef start conditions */ - if (sclookup (((char **) defs_buf.elts)[i]) > 0) - continue; - fprintf (header_out, "#undef %s\n", - ((char **) defs_buf.elts)[i]); - } - - fprintf (header_out, - "#endif /* !YY_HEADER_NO_UNDEFS */\n"); - fprintf (header_out, "\n"); - fprintf (header_out, "#undef %sIN_HEADER\n", prefix); - fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix); - - if (ferror (header_out)) - lerr (_("error creating header file %s"), - headerfilename); - fflush (header_out); - fclose (header_out); -#endif -} - -const char *cpp_skel[] = { -#include "cpp-skel.h" - 0, -}; - -struct flex_backend_t cpp_backend = { - .skel = cpp_skel, - .prolog = cpp_prolog, - .wrap = cpp_wrap, - .line_fmt = "#line %d \"%s\"\n", -}; -- cgit v1.2.1 From 673f2caf34fcbab9b6b2d2e3adeb1867b36b84a9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 20 Sep 2020 20:13:23 -0400 Subject: Methodize generation of C initializers for automaton tables. A large patch, but conceptually simple. Takes a bunch of functions and callsites that knew details of C initializer and declaration syntax and moves them into methods in the C backend table. This is a pure refactoring step. At this point in the patch series, not only do all tests pass but nothing in the lex-generated C code from the tests has changed. #7 in the retargeting patch series --- src/cpp_backend.c | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/dfa.c | 23 +----- src/flexdef.h | 28 +++++++ src/gen.c | 203 ++++++++++++++++--------------------------------- src/main.c | 3 +- 5 files changed, 318 insertions(+), 159 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index d0a57c8..6e7a134 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -381,10 +381,230 @@ const char *cpp_skel[] = { 0, }; +static const char *cpp_yy_int_aligned(void) +{ + return long_align ? "long int" : "short int"; +} + +static const char *cpp_get_int16_decl (void) +{ + return (gentables) + ? "static const flex_int16_t %s[%d] =\n { 0,\n" + : "static const flex_int16_t * %s = 0;\n"; +} + + +static const char *cpp_get_int32_decl (void) +{ + return (gentables) + ? "static const flex_int32_t %s[%d] =\n { 0,\n" + : "static const flex_int32_t * %s = 0;\n"; +} + +static const char *cpp_get_state_decl (void) +{ + return (gentables) + ? "static const yy_state_type %s[%d] =\n { 0,\n" + : "static const yy_state_type * %s = 0;\n"; +} + +static const char *cpp_get_yy_char_decl (void) +{ + return (gentables) + ? "static const YY_CHAR %s[%d] =\n { 0,\n" + : "static const YY_CHAR * %s = 0;\n"; +} + +static void cpp_ntod(size_t num_full_table_rows) +// Generate nxt table for ntod +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); + + /* Unless -Ca, declare it "short" because it's a real + * long-shot that that won't be large enough. + */ + if (gentables) + out_str_dec + ("static const %s yy_nxt[][%d] =\n {\n", + long_align ? "flex_int32_t" : "flex_int16_t", + num_full_table_rows); + else { + out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); + out_str ("static const %s *yy_nxt =0;\n", + long_align ? "flex_int32_t" : "flex_int16_t"); + } +} + +static void cpp_mkeoltbl() +// Make end-of-line-table - only used when yylinemo tracking is on +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", + "flex_int32_t"); +} + +static void cpp_geneoltbl(size_t sz) +// Generate end-of-line-transitions - only used when yylineno tracking is on +{ + outn ("/* Table of booleans, true if rule could match eol. */"); + out_str_dec (cpp_get_int32_decl (), "yy_rule_can_match_eol", sz); +} + +static void cpp_mkctbl (size_t sz) +// Make full-speed compressed transition table +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n", + (sz >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_mkssltbl (void) +// Make start_state_list table +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n", + "struct yy_trans_info*"); +} + +static void cpp_gen_yy_trans(size_t sz) +// Table of verify for transition and offset to next state. (sic) +{ + if (gentables) + out_dec ("static const struct yy_trans_info yy_transition[%d] =\n {\n", sz); + else + outn ("static const struct yy_trans_info *yy_transition = 0;"); +} + +static void cpp_start_state_list(size_t sz) +// Start initializer for table of pointers to start state +{ + /* Table of pointers to start states. */ + if (gentables) + out_dec ("static const struct yy_trans_info *yy_start_state_list[%d] =\n", sz); + else + outn ("static const struct yy_trans_info **yy_start_state_list =0;"); +} + +static void cpp_mkecstbl(void) +// Make equivalence-class tables +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", + "YY_CHAR"); +} + +static void cpp_mkftbl(void) +// Make full table +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_gentabs_acclist(void) +// Generate accept list initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_gentabs_accept(void) +// Generate accept table initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_gentabs_yy_meta(void) +// Generate yy_meta table initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", + "YY_CHAR"); +} + +static void cpp_gentabs_yy_base(void) +// Generate yy_meta base initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", + (tblend >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_gentabs_yy_def(size_t total_states) +// Generate yy_def initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", + (total_states >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_gentabs_yy_nxt(size_t total_states) +// Generate yy_nxt initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", + (total_states >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_gentabs_yy_chk(size_t total_states) +// Generate yy_chk initializer +{ + buf_prints (&yydmap_buf, + "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", + (total_states >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); +} + +static void cpp_nultrans(int fullspd) +// Generate nulltrans initializer +{ + // Making this a backend method may be overzealous. + // How many other languages have to sprcial-case NUL + // because it's a string terminator? + buf_prints (&yydmap_buf, + "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", + (fullspd) ? "struct yy_trans_info*" : + "flex_int32_t"); +} + /* This backend is only accessed through this method table */ struct flex_backend_t cpp_backend = { .skel = cpp_skel, .prolog = cpp_prolog, .wrap = cpp_wrap, + .yy_int_aligned = cpp_yy_int_aligned, .line_fmt = "#line %d \"%s\"\n", + .table_opener = " {", + .table_closer = " };\n", + .get_int16_decl = cpp_get_int16_decl, + .get_int32_decl = cpp_get_int32_decl, + .get_state_decl = cpp_get_state_decl, + .get_yy_char_decl = cpp_get_yy_char_decl, + .ntod = cpp_ntod, + .mkeoltbl = cpp_mkeoltbl, + .geneoltbl = cpp_geneoltbl, + .mkctbl = cpp_mkctbl, + .mkssltbl = cpp_mkssltbl, + .gen_yy_trans = cpp_gen_yy_trans, + .start_state_list = cpp_start_state_list, + .state_entry_fmt = " &yy_transition[%d],\n", + .mkecstbl = cpp_mkecstbl, + .mkftbl = cpp_mkftbl, + .gentabs_acclist = cpp_gentabs_acclist, + .gentabs_accept = cpp_gentabs_accept, + .gentabs_yy_meta = cpp_gentabs_yy_meta, + .gentabs_yy_base = cpp_gentabs_yy_base, + .gentabs_yy_def = cpp_gentabs_yy_def, + .gentabs_yy_nxt = cpp_gentabs_yy_nxt, + .gentabs_yy_chk = cpp_gentabs_yy_chk, + .nultrans = cpp_nultrans, }; diff --git a/src/dfa.c b/src/dfa.c index ab10314..7611812 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -517,27 +517,10 @@ void ntod (void) sizeof (flex_int32_t)); yynxt_curr = 0; - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - - /* Unless -Ca, declare it "short" because it's a real - * long-shot that that won't be large enough. - */ - if (gentables) - out_str_dec - ("static const %s yy_nxt[][%d] =\n {\n", - long_align ? "flex_int32_t" : "flex_int16_t", - num_full_table_rows); - else { - out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); - out_str ("static const %s *yy_nxt =0;\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - } - + backend->ntod(num_full_table_rows); if (gentables) - outn (" {"); + outn (backend->table_opener); /* Generate 0 entries for state #0. */ for (i = 0; i < num_full_table_rows; ++i) { @@ -547,7 +530,7 @@ void ntod (void) dataflush (); if (gentables) - outn (" },\n"); + out (" },\n\n"); } /* Create the first states. */ diff --git a/src/flexdef.h b/src/flexdef.h index 8c3ea2f..ada7b27 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -309,9 +309,37 @@ struct flex_backend_t { const char **skel; void (*prolog)(void); void (*wrap)(void); + const char *(*yy_int_aligned)(void); // Generate aligned type for this back end char *line_fmt; + char *table_opener; // Open an array initializer with this + char *table_closer; // Close an array initializer with this + const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s + const char *(*get_int32_decl)(void); // Format for declaring array initializer of int32s + const char *(*get_state_decl)(void); // Format for declaring array initializer of state values + const char *(*get_yy_char_decl)(void); // Format for declaring array initializer of input chars + // Flex table generation + void (*ntod)(size_t); // Generate nxt table for ntod + void (*mkeoltbl)(void); // Make end-of-line table + void (*geneoltbl)(size_t); // Generate end-of-line transitions + void (*mkctbl)(size_t); // Make full-speed compressed table + void (*mkssltbl)(void); // Make start_state_list table + void (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic) + void (*start_state_list)(size_t); // Start initializer for table of pointers to start states + void (*mkftbl)(); // Make full table + const char *state_entry_fmt; // Format of state table entry + void (*mkecstbl)(void); // Make equivalence-class tables + void (*gentabs_acclist)(void); // Generate accept list initializer + void (*gentabs_accept)(void); // Generate accept table initializer + void (*gentabs_yy_meta)(void); // Generate yy_meta table initializer + void (*gentabs_yy_base)(void); // Generate yy_base table initializer + void (*gentabs_yy_def)(size_t); // Generate yy_def initializer + void (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer + void (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer + void (*nultrans)(int); // Generate nulltrans initializer }; +extern bool gentables; + /* Declarations for global variables. */ diff --git a/src/gen.c b/src/gen.c index c959f75..31ba15c 100644 --- a/src/gen.c +++ b/src/gen.c @@ -50,35 +50,6 @@ static int indent_level = 0; /* each level is 8 spaces */ * 0 elements of its arrays, too.) */ -static const char *get_int16_decl (void) -{ - return (gentables) - ? "static const flex_int16_t %s[%d] =\n { 0,\n" - : "static const flex_int16_t * %s = 0;\n"; -} - - -static const char *get_int32_decl (void) -{ - return (gentables) - ? "static const flex_int32_t %s[%d] =\n { 0,\n" - : "static const flex_int32_t * %s = 0;\n"; -} - -static const char *get_state_decl (void) -{ - return (gentables) - ? "static const yy_state_type %s[%d] =\n { 0,\n" - : "static const yy_state_type * %s = 0;\n"; -} - -static const char *get_yy_char_decl (void) -{ - return (gentables) - ? "static const YY_CHAR %s[%d] =\n { 0,\n" - : "static const YY_CHAR * %s = 0;\n"; -} - /* Indent to the current level. */ void do_indent (void) @@ -116,9 +87,7 @@ static struct yytbl_data *mkeoltbl (void) for (i = 1; i <= num_rules; i++) tdata[i] = rule_has_nl[i] ? 1 : 0; - buf_prints (&yydmap_buf, - "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", - "flex_int32_t"); + backend->mkeoltbl(); return tbl; } @@ -128,9 +97,7 @@ static void geneoltbl (void) int i; outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); - outn ("/* Table of booleans, true if rule could match eol. */"); - out_str_dec (get_int32_decl (), "yy_rule_can_match_eol", - num_rules + 1); + backend->geneoltbl(num_rules + 1); if (gentables) { for (i = 1; i <= num_rules; i++) { @@ -208,10 +175,7 @@ static struct yytbl_data *mkctbl (void) flex_int32_t *tdata = 0, curr = 0; int end_of_buffer_action = num_rules + 1; - buf_prints (&yydmap_buf, - "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n", - ((tblend + numecs + 1) >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + backend->mkctbl(tblend + numecs + 1); tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (tbl, YYTD_ID_TRANSITION); @@ -321,9 +285,7 @@ static struct yytbl_data *mkssltbl (void) for (i = 0; i <= lastsc * 2; ++i) tdata[i] = base[i]; - buf_prints (&yydmap_buf, - "\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n", - "struct yy_trans_info*"); + backend->mkssltbl(); return tbl; } @@ -338,10 +300,7 @@ void genctbl (void) int end_of_buffer_action = num_rules + 1; /* Table of verify for transition and offset to next state. */ - if (gentables) - out_dec ("static const struct yy_trans_info yy_transition[%d] =\n {\n", tblend + numecs + 1); - else - outn ("static const struct yy_trans_info *yy_transition = 0;"); + backend->gen_yy_trans(tblend + numecs + 1); /* We want the transition to be represented as the offset to the * next state, not the actual state number, which is what it currently @@ -409,19 +368,15 @@ void genctbl (void) transition_struct_out (chk[tblend + 2], nxt[tblend + 2]); if (gentables) - outn (" };\n"); + outn (backend->table_closer); - /* Table of pointers to start states. */ - if (gentables) - out_dec ("static const struct yy_trans_info *yy_start_state_list[%d] =\n", lastsc * 2 + 1); - else - outn ("static const struct yy_trans_info **yy_start_state_list =0;"); + backend->start_state_list(lastsc * 2 + 1); if (gentables) { - outn (" {"); + outn (backend->table_opener); for (i = 0; i <= lastsc * 2; ++i) - out_dec (" &yy_transition[%d],\n", base[i]); + out_dec (backend->state_entry_fmt, base[i]); dataend (); } @@ -453,9 +408,7 @@ static struct yytbl_data *mkecstbl (void) tdata[i] = ecgroup[i]; } - buf_prints (&yydmap_buf, - "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", - "YY_CHAR"); + backend->mkecstbl(); return tbl; } @@ -467,7 +420,7 @@ void genecs (void) int ch, row; int numrows; - out_str_dec (get_yy_char_decl (), "yy_ec", csize); + out_str_dec (backend->get_yy_char_decl (), "yy_ec", csize); for (ch = 1; ch < csize; ++ch) { ecgroup[ch] = ABS (ecgroup[ch]); @@ -671,9 +624,7 @@ struct yytbl_data *mkftbl (void) i, anum); } - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + backend->mkftbl(); return tbl; } @@ -685,7 +636,7 @@ void genftbl (void) int i; int end_of_buffer_action = num_rules + 1; - out_str_dec (long_align ? get_int32_decl () : get_int16_decl (), + out_str_dec (long_align ? backend->get_int32_decl () : backend->get_int16_decl (), "yy_accept", lastdfa + 1); dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; @@ -1056,9 +1007,9 @@ void gentabs (void) int i, j, k, *accset, nacc, *acc_array, total_states; int end_of_buffer_action = num_rules + 1; struct yytbl_data *yyacc_tbl = 0, *yymeta_tbl = 0, *yybase_tbl = 0, - *yydef_tbl = 0, *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl=0; + *yydef_tbl = 0, *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl=0; flex_int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0, - *yynxt_data = 0, *yychk_data = 0, *yyacclist_data=0; + *yynxt_data = 0, *yychk_data = 0, *yyacclist_data=0; flex_int32_t yybase_curr = 0, yyacclist_curr=0,yyacc_curr=0; acc_array = allocate_integer_array (current_max_dfas); @@ -1085,22 +1036,20 @@ void gentabs (void) EOB_accepting_list[1] = end_of_buffer_action; accsiz[end_of_buffer_state] = 1; dfaacc[end_of_buffer_state].dfaacc_set = - EOB_accepting_list; - - out_str_dec (long_align ? get_int32_decl () : - get_int16_decl (), "yy_acclist", MAX (numas, - 1) + 1); - - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - - yyacclist_tbl = calloc(1,sizeof(struct yytbl_data)); - yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST); - yyacclist_tbl->td_lolen = (flex_uint32_t) (MAX(numas,1) + 1); - yyacclist_tbl->td_data = yyacclist_data = - calloc(yyacclist_tbl->td_lolen, sizeof (flex_int32_t)); - yyacclist_curr = 1; + EOB_accepting_list; + + out_str_dec (long_align ? backend->get_int32_decl () : + backend->get_int16_decl (), "yy_acclist", MAX (numas, + 1) + 1); + + backend->gentabs_acclist(); + + yyacclist_tbl = calloc(1,sizeof(struct yytbl_data)); + yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST); + yyacclist_tbl->td_lolen = (flex_uint32_t) (MAX(numas,1) + 1); + yyacclist_tbl->td_data = yyacclist_data = + calloc(yyacclist_tbl->td_lolen, sizeof (flex_int32_t)); + yyacclist_curr = 1; j = 1; /* index into "yy_acclist" array */ @@ -1136,7 +1085,7 @@ void gentabs (void) } mkdata (accnum); - yyacclist_data[yyacclist_curr++] = accnum; + yyacclist_data[yyacclist_curr++] = accnum; if (trace) { fprintf (stderr, "[%d]", @@ -1157,18 +1106,18 @@ void gentabs (void) acc_array[i] = j; dataend (); - if (tablesext) { - yytbl_data_compress (yyacclist_tbl); - if (yytbl_data_fwrite (&tableswr, yyacclist_tbl) < 0) - flexerror (_("Could not write yyacclist_tbl")); - yytbl_data_destroy (yyacclist_tbl); - yyacclist_tbl = NULL; - } + if (tablesext) { + yytbl_data_compress (yyacclist_tbl); + if (yytbl_data_fwrite (&tableswr, yyacclist_tbl) < 0) + flexerror (_("Could not write yyacclist_tbl")); + yytbl_data_destroy (yyacclist_tbl); + yyacclist_tbl = NULL; + } } else { dfaacc[end_of_buffer_state].dfaacc_state = - end_of_buffer_action; + end_of_buffer_action; for (i = 1; i <= lastdfa; ++i) acc_array[i] = dfaacc[i].dfaacc_state; @@ -1197,19 +1146,17 @@ void gentabs (void) */ ++k; - out_str_dec (long_align ? get_int32_decl () : get_int16_decl (), + out_str_dec (long_align ? backend->get_int32_decl () : backend->get_int16_decl (), "yy_accept", k); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - + backend->gentabs_accept(); + yyacc_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT); yyacc_tbl->td_lolen = (flex_uint32_t) k; yyacc_tbl->td_data = yyacc_data = - calloc(yyacc_tbl->td_lolen, sizeof (flex_int32_t)); - yyacc_curr=1; + calloc(yyacc_tbl->td_lolen, sizeof (flex_int32_t)); + yyacc_curr=1; for (i = 1; i <= lastdfa; ++i) { mkdata (acc_array[i]); @@ -1265,18 +1212,16 @@ void gentabs (void) yytbl_data_init (yymeta_tbl, YYTD_ID_META); yymeta_tbl->td_lolen = (flex_uint32_t) (numecs + 1); yymeta_tbl->td_data = yymecs_data = - calloc(yymeta_tbl->td_lolen, - sizeof (flex_int32_t)); + calloc(yymeta_tbl->td_lolen, + sizeof (flex_int32_t)); if (trace) fputs (_("\n\nMeta-Equivalence Classes:\n"), stderr); - out_str_dec (get_yy_char_decl (), "yy_meta", numecs + 1); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", - "YY_CHAR"); - + out_str_dec (backend->get_yy_char_decl (), "yy_meta", numecs + 1); + backend->gentabs_yy_meta(); + for (i = 1; i <= numecs; ++i) { if (trace) fprintf (stderr, "%d = %d\n", @@ -1301,19 +1246,16 @@ void gentabs (void) /* Begin generating yy_base */ out_str_dec ((tblend >= INT16_MAX || long_align) ? - get_int32_decl () : get_int16_decl (), + backend->get_int32_decl () : backend->get_int16_decl (), "yy_base", total_states + 1); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", - (tblend >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + backend->gentabs_yy_base(); yybase_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yybase_tbl, YYTD_ID_BASE); yybase_tbl->td_lolen = (flex_uint32_t) (total_states + 1); yybase_tbl->td_data = yybase_data = - calloc(yybase_tbl->td_lolen, - sizeof (flex_int32_t)); + calloc(yybase_tbl->td_lolen, + sizeof (flex_int32_t)); yybase_curr = 1; for (i = 1; i <= lastdfa; ++i) { @@ -1358,19 +1300,16 @@ void gentabs (void) /* Begin generating yy_def */ out_str_dec ((total_states >= INT16_MAX || long_align) ? - get_int32_decl () : get_int16_decl (), + backend->get_int32_decl () : backend->get_int16_decl (), "yy_def", total_states + 1); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + backend->gentabs_yy_def(total_states); yydef_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yydef_tbl, YYTD_ID_DEF); yydef_tbl->td_lolen = (flex_uint32_t) (total_states + 1); yydef_tbl->td_data = yydef_data = - calloc(yydef_tbl->td_lolen, sizeof (flex_int32_t)); + calloc(yydef_tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i <= total_states; ++i) { mkdata (def[i]); @@ -1390,19 +1329,16 @@ void gentabs (void) /* Begin generating yy_nxt */ out_str_dec ((total_states >= INT16_MAX || long_align) ? - get_int32_decl () : get_int16_decl (), "yy_nxt", + backend->get_int32_decl () : backend->get_int16_decl (), "yy_nxt", tblend + 1); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + backend->gentabs_yy_nxt(total_states); yynxt_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); yynxt_tbl->td_lolen = (flex_uint32_t) (tblend + 1); yynxt_tbl->td_data = yynxt_data = - calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t)); + calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i <= tblend; ++i) { /* Note, the order of the following test is important. @@ -1427,19 +1363,16 @@ void gentabs (void) /* Begin generating yy_chk */ out_str_dec ((total_states >= INT16_MAX || long_align) ? - get_int32_decl () : get_int16_decl (), "yy_chk", + backend->get_int32_decl () : backend->get_int16_decl (), "yy_chk", tblend + 1); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - + backend->gentabs_yy_chk(total_states); + yychk_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yychk_tbl, YYTD_ID_CHK); yychk_tbl->td_lolen = (flex_uint32_t) (tblend + 1); yychk_tbl->td_data = yychk_data = - calloc(yychk_tbl->td_lolen, sizeof (flex_int32_t)); + calloc(yychk_tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i <= tblend; ++i) { if (chk[i] == 0) @@ -1685,13 +1618,9 @@ void make_tables (void) flex_int32_t *yynultrans_data = 0; /* Begin generating yy_NUL_trans */ - out_str_dec (get_state_decl (), "yy_NUL_trans", + out_str_dec (backend->get_state_decl (), "yy_NUL_trans", lastdfa + 1); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", - (fullspd) ? "struct yy_trans_info*" : - "flex_int32_t"); - + backend->nultrans(fullspd); yynultrans_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); if (fullspd) @@ -1737,8 +1666,8 @@ void make_tables (void) } if (ddebug) { /* Spit out table mapping rules to line numbers. */ - out_str_dec (long_align ? get_int32_decl () : - get_int16_decl (), "yy_rule_linenum", + out_str_dec (long_align ? backend->get_int32_decl () : + backend->get_int16_decl (), "yy_rule_linenum", num_rules); for (i = 1; i < num_rules; ++i) mkdata (rule_linenum[i]); diff --git a/src/main.c b/src/main.c index 3900e08..fbb2182 100644 --- a/src/main.c +++ b/src/main.c @@ -462,8 +462,7 @@ void check_options (void) buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL); /* Create the alignment type. */ - buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", - long_align ? "long int" : "short int"); + buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", backend->yy_int_aligned()); /* Define the start condition macros. */ { -- cgit v1.2.1 From e58cdd1de0be09ac7258044ff13743538ee97c2b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 20 Sep 2020 22:10:47 -0400 Subject: Start a HOWTO on writing target-language back ends. #8 in the retargeting patch series --- src/Makefile.am | 3 ++- src/backend.adoc | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/backend.adoc diff --git a/src/Makefile.am b/src/Makefile.am index 40ca850..171549a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,7 +91,8 @@ include_HEADERS = \ EXTRA_DIST = \ cpp-flex.skl \ mkskel.sh \ - gettext.h + gettext.h \ + backend.adoc CLEANFILES = stage1scan.c stage1flex$(EXEEXT) diff --git a/src/backend.adoc b/src/backend.adoc new file mode 100644 index 0000000..f098516 --- /dev/null +++ b/src/backend.adoc @@ -0,0 +1,75 @@ += How to add a support for a new language to flex + += Theory + +The flex code was historically written to generate parsers in C, but +it has factored to isolate knowledge of the specifics of each target +languageas from the logic for byukilding the lexer state tables much +as possible. + +The only assumption that is absolutely baked into all of flex is that +the bodies of initializers for arrays of integers consist of decimal +numeric kiterals sepaerated by commas (and optional whitespace). + +Otherwise, knowledge of each target langage's syntax lives in two +places: (1) a table of langyuge-specific syntax-generator methods, +and (2) A language-specific skeleton file. + +For example: The methods for the C and C++ back end live in a source +file named cpp_backend.c (so named because both languages use the C +preprocessor), and in a skeleton file names cpp-flex.skl. + +Syntactically C-like languages such as Go, Rust, and Java should be easy +target. Alnost anything generally descended from Algol shouldn't be +much more difficult; this certainly includes the whole +Pascal/Modula/Oberon family. + += Writing a new backend + +All the code that accesses language-specific code generators goes +through a global pointer named "backend" to a method table. The +results of these generators are used to fill in some parts of the +language-specifoc skeleton file amd conditionalize other. + +Read the definition of struct backend_t in src/flexdefs.h, and +attached comments, to get a feel for the methods. Don't worry +about understandng table generator names at first. + +To write support for a langusge, you'll want to do the following +steps: + +1. Clone one of the existing back-end/skeleton pairs. If the language + you are supporting is names "foo", you should create files named + foo_backend.c and foo-flex.skl. + +2. Add foo_backend.c to COMMON_SOURCES in src.Makefile.am. Add the + name of your skeleton file to EXTRA_DIST. + +3. Add a production to src/Makefile.am parallel to the one that + priduces cpp-skel.h. Your objecting is to make s string list + initializer from your skeleton file that can be linked with flex + and is opointed at by the skel nember of your language back end. + +4. Add some logic to main.c that enables the new back end with a + new command-line option. Following this step you should be + able to run flex on a specification and fet code out in the + language of whatever back end you cloned. + +5. The interesting part: mutate your new back end and skeleton so they + produce code in your desired target langage. + +6. Write a test suite for your back end. You should be able to clone + one of the existing sets of test loads to get good coverage. Note + that is highly unliely your back end will be accepted into the + flex distribution without a test suite. + +A hint about step 5: + +* Don't bother supporting non-reentrant parser generation. + The interface of original lex with all those globals hanging out + needs to be supported in C for backwards compatibility, but + there + + + + -- cgit v1.2.1 From c0ca7faab9dce962e257c4da79133b67d5c0c6ee Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 20 Sep 2020 23:17:00 -0400 Subject: Two member name changes in the method table. Cosmetic change, #9 in the retargeting patch series --- src/cpp_backend.c | 6 +++--- src/flexdef.h | 4 ++-- src/main.c | 6 ++++-- src/misc.c | 11 ++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 6e7a134..6d6a530 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -185,7 +185,7 @@ static void cpp_prolog (void) } } -static void cpp_wrap (void) +static void cpp_epilog (void) { #if 0 fprintf (header_out, @@ -580,9 +580,9 @@ static void cpp_nultrans(int fullspd) struct flex_backend_t cpp_backend = { .skel = cpp_skel, .prolog = cpp_prolog, - .wrap = cpp_wrap, + .epilog = cpp_epilog, .yy_int_aligned = cpp_yy_int_aligned, - .line_fmt = "#line %d \"%s\"\n", + .trace_fmt = "#line %d \"%s\"\n", .table_opener = " {", .table_closer = " };\n", .get_int16_decl = cpp_get_int16_decl, diff --git a/src/flexdef.h b/src/flexdef.h index ada7b27..4250c5f 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -308,9 +308,9 @@ struct flex_backend_t { const char **skel; void (*prolog)(void); - void (*wrap)(void); + void (*epilog)(void); const char *(*yy_int_aligned)(void); // Generate aligned type for this back end - char *line_fmt; + char *trace_fmt; char *table_opener; // Open an array initializer with this char *table_closer; // Close an array initializer with this const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s diff --git a/src/main.c b/src/main.c index fbb2182..6a52a07 100644 --- a/src/main.c +++ b/src/main.c @@ -172,7 +172,8 @@ int flex_main (int argc, char *argv[]) readin (); - backend->prolog (); + if (backend->prolog) + backend->prolog (); skelout (); /* %% [1.5] DFA */ @@ -530,7 +531,8 @@ void flexend (int exit_status) skelname); } - backend->wrap(); + if (backend->epilog) + backend->epilog(); if (exit_status != 0 && outfile_created) { if (ferror (stdout)) diff --git a/src/misc.c b/src/misc.c index 975729e..3705b65 100644 --- a/src/misc.c +++ b/src/misc.c @@ -365,11 +365,12 @@ void line_directive_out (FILE *output_file, int do_infile) *s2 = '\0'; - if (do_infile) - snprintf (directive, sizeof(directive), backend->line_fmt, linenum, filename); - else { - snprintf (directive, sizeof(directive), backend->line_fmt, 0, filename); - } + if (backend->trace_fmt) + if (do_infile) + snprintf (directive, sizeof(directive), backend->trace_fmt, linenum, filename); + else { + snprintf (directive, sizeof(directive), backend->trace_fmt, 0, filename); + } /* If output_file is nil then we should put the directive in * the accumulated actions. -- cgit v1.2.1 From ef4f78f43b3b0b75de0e615d70949e0a460b90d2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 00:05:05 -0400 Subject: Continue methodization, with some target-language-specific formats... ...and one additional method. This almost finushes off all language-specfic detauks outside of gen.c. The one exception is just below the comment "add terminator for initialization" in dfa.c; we'll get to this eventually. #10 in the retargeting patch series --- src/cpp_backend.c | 18 +++++++++++++++++- src/flexdef.h | 9 +++++++-- src/gen.c | 2 +- src/main.c | 33 +++++++++------------------------ 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 6d6a530..e74cabd 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -37,6 +37,18 @@ /* Code specific to the C/C++ back end starts here */ +static const char *cpp_suffix (void) +{ + char *suffix; + + if (C_plus_plus) + suffix = "cc"; + else + suffix = "c"; + + return suffix; +} + /* cpp_prolog - make rules prolog pecific to cpp-using languages. * * If you don't ship this, you will effectively be assuming that your @@ -578,11 +590,14 @@ static void cpp_nultrans(int fullspd) /* This backend is only accessed through this method table */ struct flex_backend_t cpp_backend = { - .skel = cpp_skel, + .suffix = cpp_suffix, .prolog = cpp_prolog, + .skel = cpp_skel, .epilog = cpp_epilog, .yy_int_aligned = cpp_yy_int_aligned, .trace_fmt = "#line %d \"%s\"\n", + .int_define_fmt = "#define %s %d\n", + .string_define_fmt = "#define %s %s\n", .table_opener = " {", .table_closer = " };\n", .get_int16_decl = cpp_get_int16_decl, @@ -607,4 +622,5 @@ struct flex_backend_t cpp_backend = { .gentabs_yy_nxt = cpp_gentabs_yy_nxt, .gentabs_yy_chk = cpp_gentabs_yy_chk, .nultrans = cpp_nultrans, + .caseprefix = "case ", }; diff --git a/src/flexdef.h b/src/flexdef.h index 4250c5f..781fe25 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,11 +306,15 @@ /* Method table describing a language-specific back end */ struct flex_backend_t { - const char **skel; + const char *(*suffix)(void); // Generate suffix for lexer source code void (*prolog)(void); + const char **skel; void (*epilog)(void); const char *(*yy_int_aligned)(void); // Generate aligned type for this back end - char *trace_fmt; + char *trace_fmt; // Trace message format + // Language syntax generation + char *int_define_fmt; // Format for integer constant definitions + char *string_define_fmt; // Format for string constant definitions char *table_opener; // Open an array initializer with this char *table_closer; // Close an array initializer with this const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s @@ -336,6 +340,7 @@ struct flex_backend_t { void (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer void (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer void (*nultrans)(int); // Generate nulltrans initializer + char *caseprefix; // Prefix of an arm in the language's case construct }; extern bool gentables; diff --git a/src/gen.c b/src/gen.c index 31ba15c..b05869a 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1997,7 +1997,7 @@ void make_tables (void) for (i = 1; i <= lastsc; ++i) if (!sceof[i]) { do_indent (); - out_str ("case YY_STATE_EOF(%s):\n", scname[i]); + out_str3 ("%sYY_STATE_EOF(%s):\n", backend->caseprefix, scname[i], ""); did_eof_rule = true; } diff --git a/src/main.c b/src/main.c index 6a52a07..22b3279 100644 --- a/src/main.c +++ b/src/main.c @@ -323,15 +323,8 @@ void check_options (void) FILE *prev_stdout; if (!did_outfilename) { - char *suffix; - - if (C_plus_plus) - suffix = "cc"; - else - suffix = "c"; - snprintf (outfile_path, sizeof(outfile_path), outfile_template, - prefix, suffix); + prefix, backend->suffix()); outfilename = outfile_path; } @@ -470,7 +463,7 @@ void check_options (void) struct Buf tmpbuf; buf_init(&tmpbuf, sizeof(char)); for (i = 1; i <= lastsc; i++) { - char *str, *fmt = "#define %s %d\n"; + char *str, *fmt = backend->int_define_fmt; size_t strsz; strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; @@ -1095,24 +1088,16 @@ void flexinit (int argc, char **argv) { /* arg is "symbol" or "symbol=definition". */ char *def; + char buf2[4096]; for (def = arg; - *def != '\0' && *def != '='; ++def) ; + *def != '\0' && *def != '='; ++def) + continue; + if (*def == '\0') + def = "1"; - buf_strappend (&userdef_buf, "#define "); - if (*def == '\0') { - buf_strappend (&userdef_buf, arg); - buf_strappend (&userdef_buf, - " 1\n"); - } - else { - buf_strnappend (&userdef_buf, arg, - (int) (def - arg)); - buf_strappend (&userdef_buf, " "); - buf_strappend (&userdef_buf, - def + 1); - buf_strappend (&userdef_buf, "\n"); - } + snprintf(buf2, sizeof(buf2), backend->string_define_fmt, arg, def); + buf_strappend (&userdef_buf, buf2); } break; -- cgit v1.2.1 From cdb639cd7bbe1e4e2d8a0817c783ba48ceef8ba2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 00:21:42 -0400 Subject: Add code to initialize the macro conditional symbols we'll need. These aren't used yet. They will be as we push code feneration out of gen.c into the epansion of the m4 skeleton. This is the first revision to touch the C skeleton file, changing M4_YY_USES_REJECT to M4_MODE_USES_REJECT for uniformity with the other mode switches. C code generated from the tests is still unchanged at this revision. #11 in the retargeting patch series --- src/cpp-flex.skl | 14 ++++----- src/cpp_backend.c | 2 +- src/gen.c | 6 ++-- src/main.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 11 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4106985..6f7db7d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -102,7 +102,7 @@ m4_ifelse(M4_YY_PREFIX,yy,, m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) -%# This is the m4 way to say "(stack_used || is_reentrant) +%# This is the m4 way to say "(stack_used || is_reentrant)" m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) @@ -749,7 +749,7 @@ struct yyguts_t int yylineno_r; int yy_flex_debug_r; -m4_ifdef( [[M4_YY_USES_REJECT]], +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yy_state_type *yy_state_buf; yy_state_type *yy_state_ptr; @@ -1224,7 +1224,7 @@ m4_ifdef( [[]], YY_USER_INIT; #endif -m4_ifdef( [[M4_YY_USES_REJECT]], +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ if ( ! YY_G(yy_state_buf) ) @@ -1477,7 +1477,7 @@ void yyFlexLexer::ctor_common() yy_buffer_stack_max = 0; -m4_ifdef( [[M4_YY_USES_REJECT]], +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; ]], @@ -1626,7 +1626,7 @@ int yyFlexLexer::yy_get_next_buffer() while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ -m4_ifdef( [[M4_YY_USES_REJECT]], +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); @@ -2858,7 +2858,7 @@ m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], YY_G(yy_start_stack) = NULL; ]]) -m4_ifdef( [[M4_YY_USES_REJECT]], +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ YY_G(yy_state_buf) = 0; YY_G(yy_state_ptr) = 0; @@ -2914,7 +2914,7 @@ m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], YY_G(yy_start_stack) = NULL; ]]) -m4_ifdef( [[M4_YY_USES_REJECT]], +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); YY_G(yy_state_buf) = NULL; diff --git a/src/cpp_backend.c b/src/cpp_backend.c index e74cabd..af59fce 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -72,7 +72,7 @@ static void cpp_prolog (void) "FILE *yyin = NULL, *yyout = NULL;"; if (reject){ - out_m4_define( "M4_YY_USES_REJECT", NULL); + out_m4_define( "M4_MODE_USES_REJECT", NULL); //outn ("\n#define YY_USES_REJECT"); } diff --git a/src/gen.c b/src/gen.c index b05869a..b523513 100644 --- a/src/gen.c +++ b/src/gen.c @@ -464,7 +464,7 @@ void gen_find_action (void) indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];"); if (!variable_trailing_context_rules) - outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[["); + outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); if(reject_really_used) outn ("find_rule: /* we branch to this label when backing up */"); if (!variable_trailing_context_rules) @@ -989,7 +989,7 @@ void gen_start_state (void) if (reject) { /* Set up for storing up states. */ - outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[["); + outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); indent_puts ("YY_G(yy_state_ptr) = YY_G(yy_state_buf);"); indent_puts @@ -1675,7 +1675,7 @@ void make_tables (void) } if (reject) { - outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[["); + outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); /* Declare state buffer variables. */ if (!C_plus_plus && !reentrant) { outn ("static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;"); diff --git a/src/main.c b/src/main.c index 22b3279..15f1a4a 100644 --- a/src/main.c +++ b/src/main.c @@ -1408,6 +1408,91 @@ void readin (void) if (useecs) ccl2ecl (); + + // Set up macro conditionalization after all + // dependent flags have been computed. These + // are used to conditionalize code in the lex + // skeleton that historically used to be generated + // by C code in flex itself; by shoving all this + // stuff out to the skeleton file we make it easier + // to retarget the code generation. + + // mode switches for next-action code + if (variable_trailing_context_rules) { + out_m4_define( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES", NULL); + } else { + out_m4_define( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES", NULL); + } + if (real_reject) + out_m4_define( "M4_MODE_REAL_REJECT", NULL); + if (reject_really_used) + out_m4_define( "M4_MODE_REJECT_REALLY_USED", NULL); + if (reject) + out_m4_define( "M4_MODE_USES_REJECT", NULL); + else + out_m4_define( "M4_MODE_NO_USES_REJECT", NULL); + + // mode switches for computing next compressed state + if (usemecs) + out_m4_define( "M4_MODE_USEMECS", NULL); + + // mode switches for find-action code + if (fullspd) + out_m4_define( "M4_MODE_FULLSPD", NULL); + else if (fulltbl) + out_m4_define( "M4_MODE_FULLTBL", NULL); + else if (reject) + out_m4_define( "M4_MODE_REJECT", NULL); + else + out_m4_define( "M4_MODE_COMPRESSED", NULL); + + // mode switches for backup generation and gen_start_state + if (!fullspd) + out_m4_define( "M4_MODE_NO_FULLSPD", NULL); + if (bol_needed) + out_m4_define( "M4_MODE_BOL_NEEDED", NULL); + else + out_m4_define( "M4_MODE_NO_BOL_NEEDED", NULL); + + // yylineno + if (do_yylineno) + out_m4_define( "M4_MODE_YYLINENO", NULL); + + // Equivalance classes + if (useecs) + out_m4_define( "M4_MODE_USEECS", NULL); + else + out_m4_define( "M4_NOT_MODE_USEECS", NULL); + + // mode switches for getting next action + if (gentables) + out_m4_define( "M4_MODE_GENTABLES", NULL); + else + out_m4_define( "M4_MODE_NO_GENTABLES", NULL); + if (interactive) + out_m4_define( "M4_MODE_INTERACTIVE", NULL); + else + out_m4_define( "M4_MODE_NO_INTERACTIVE", NULL); + if (!(fullspd || fulltbl)) + out_m4_define( "M4_MODE_NO_FULLSPD_OR_FULLTBL", NULL); + if (reject || interactive) + out_m4_define( "M4_MODE_REJECT_OR_INTERACTIVE", NULL); + + // nultrans + if (nultrans) + out_m4_define( "M4_MODE_NULTRANS", NULL); + else + out_m4_define( "M4_MODE_NO_NULTRANS", NULL); + + if (ddebug) + out_m4_define( "M4_MODE_DEBUG", NULL); + + // This weird conditional pacifies lint + if (!reject && (!nultrans || fullspd || fulltbl)) + out_m4_define( "M4_MODE_NEED_YY_CP", NULL); + + if (!reject && (fullspd || fulltbl)) + out_m4_define( "M4_MODE_NULTRANS_WRAP", NULL); } /* set_up_initial_allocations - allocate memory for internal tables */ -- cgit v1.2.1 From cd01f7ff4e4aa5e9223df56d4ee04e0c039b7aff Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 00:45:47 -0400 Subject: Remove a redundant macro guard setting.... ...and clean up some comments. Removal should have happened in #11 when the guard symbol was renamed. #12 in the retargeting patch series --- src/cpp_backend.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index af59fce..a784b22 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -33,7 +33,6 @@ #include "flexdef.h" -#include "version.h" /* Code specific to the C/C++ back end starts here */ @@ -49,20 +48,21 @@ static const char *cpp_suffix (void) return suffix; } -/* cpp_prolog - make rules prolog pecific to cpp-using languages. +/* cpp_prolog - make rules prolog specific to cpp-using languages. * * If you don't ship this, you will effectively be assuming that your * parsers are always reentrant, always allow reject, always have a * yywrap() method, have a debug member in the wrapper class, and are * interactive. This eliminates most of the boilerplate in the C/C++ * scanner prolog. It means such parsers will be a bit larger and - * slower than C/C++ ones, but since we're not runing on 1987's + * slower than C/C++ ones, but since we're not running on 1987's * hardware we officially do not care. * - * A detail to beware of: If you're not issuing this prologue, you - * may want to issue your own definition of YY_CHAR. It's a typedef - * to an unsigned octet in C/C++, but if your target language has a - * Unicode code-point type like Go's 'rune' is may be appropriate. + * A detail to beware of: If you're not issuing this prologue, you may + * want to write your own definition of YY_CHAR in your skel + * file. It's a typedef to an unsigned octet in C/C++, but if your + * target language has a Unicode code-point type like Go's 'rune' is + * may be appropriate. */ static void cpp_prolog (void) @@ -71,11 +71,6 @@ static void cpp_prolog (void) static char yy_nostdinit[] = "FILE *yyin = NULL, *yyout = NULL;"; - if (reject){ - out_m4_define( "M4_MODE_USES_REJECT", NULL); - //outn ("\n#define YY_USES_REJECT"); - } - if (!do_yywrap) { if (!C_plus_plus) { if (reentrant) @@ -127,7 +122,7 @@ static void cpp_prolog (void) else { if(!reentrant) - outn (yy_nostdinit); + outn (yy_nostdinit); } OUT_END_CODE (); } @@ -388,11 +383,6 @@ static void cpp_epilog (void) #endif } -const char *cpp_skel[] = { -#include "cpp-skel.h" - 0, -}; - static const char *cpp_yy_int_aligned(void) { return long_align ? "long int" : "short int"; @@ -588,6 +578,11 @@ static void cpp_nultrans(int fullspd) "flex_int32_t"); } +const char *cpp_skel[] = { +#include "cpp-skel.h" + 0, +}; + /* This backend is only accessed through this method table */ struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, -- cgit v1.2.1 From 5f41ac5a99f49cb2780115adf167f95b3d43690d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 10:35:18 -0400 Subject: Create a TESTOPTS variable that can be used to pass options to flex in testing. Presently this is used to pass -L, making it easier to compare changes in generared C code cross revisions. To perform such comparisons, do this at a base (before) revision: # Make generated code make clean; (cd tests; make clean); make check # Save a smashot of it rm -fr snapshot && mkdir snapshot && cp tests/*.c snapshot Then rebuild at the later revision and do this: # Compare gemerated code to snapshot do diff -b -B -u $x tests/`basename $x`; done #13 in the retargeting patch series --- src/cpp-flex.skl | 66 +++++++++++++++++++++++++ src/gen.c | 145 ------------------------------------------------------ tests/Makefile.am | 30 +++++------ 3 files changed, 82 insertions(+), 159 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 6f7db7d..b4fd247 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1281,6 +1281,72 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yy_find_action: %% [10.0] code to find the action number goes here + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) + m4_ifdef([[M4_MODE_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) +m4_ifdef([[M4_MODE_REJECT]], [[ + yy_current_state = *--YY_G(yy_state_ptr); + YY_G(yy_lp) = yy_accept[yy_current_state]; +m4_ifdef([[M4_MODE_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) + for ( ; ; ) { /* loop until we find out what rule we matched */ + if (YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1]) { + yy_act = yy_acclist[YY_G(yy_lp)]; +m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || YY_G(yy_looking_for_trail_begin)) { + if (yy_act == YY_G(yy_looking_for_trail_begin)) { + YY_G(yy_looking_for_trail_begin) = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } + else if (( yy_act & YY_TRAILING_MASK) != 0) { + YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; + YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; +m4_ifdef([[M4_MODE_REAL_REJECT]], [[ + /* Remember matched text in case we back up + * due to REJECT. + */ + YY_G(yy_full_match) = yy_cp; + YY_G(yy_full_state) = YY_G(yy_state_ptr); + YY_G(yy_full_lp) = YY_G(yy_lp); +]]) + } + else + { + YY_G(yy_full_match) = yy_cp; + YY_G(yy_full_state) = YY_G(yy_state_ptr); + YY_G(yy_full_lp) = YY_G(yy_lp); + break; + } + ++YY_G(yy_lp); + goto find_rule; +]]) +m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + /* Remember matched text in case we back up due to + * trailing context plus REJECT. + */ + YY_G(yy_full_match) = yy_cp; + break; +]]) + } + + --yy_cp; + + /* We could consolidate the following two lines with those at + * the beginning, but at the cost of complaints that we're + * branching inside a loop. + */ + yy_current_state = *--YY_G(yy_state_ptr); + YY_G(yy_lp) = yy_accept[yy_current_state]; + } +]]) +m4_ifdef([[M4_MODE_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } +]]) YY_DO_BEFORE_ACTION; diff --git a/src/gen.c b/src/gen.c index b523513..682b43e 100644 --- a/src/gen.c +++ b/src/gen.c @@ -448,150 +448,6 @@ void genecs (void) } } - -/* Generate the code to find the action number. */ - -void gen_find_action (void) -{ - if (fullspd) - indent_puts ("yy_act = yy_current_state[-1].yy_nxt;"); - - else if (fulltbl) - indent_puts ("yy_act = yy_accept[yy_current_state];"); - - else if (reject) { - indent_puts ("yy_current_state = *--YY_G(yy_state_ptr);"); - indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];"); - - if (!variable_trailing_context_rules) - outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); - if(reject_really_used) - outn ("find_rule: /* we branch to this label when backing up */"); - if (!variable_trailing_context_rules) - outn ("]])\n"); - - indent_puts - ("for ( ; ; ) /* until we find what rule we matched */"); - - ++indent_level; - - indent_puts ("{"); - - indent_puts - ("if ( YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1] )"); - ++indent_level; - indent_puts ("{"); - indent_puts ("yy_act = yy_acclist[YY_G(yy_lp)];"); - - if (variable_trailing_context_rules) { - indent_puts - ("if ( yy_act & YY_TRAILING_HEAD_MASK ||"); - indent_puts (" YY_G(yy_looking_for_trail_begin) )"); - ++indent_level; - indent_puts ("{"); - - indent_puts - ("if ( yy_act == YY_G(yy_looking_for_trail_begin) )"); - ++indent_level; - indent_puts ("{"); - indent_puts ("YY_G(yy_looking_for_trail_begin) = 0;"); - indent_puts ("yy_act &= ~YY_TRAILING_HEAD_MASK;"); - indent_puts ("break;"); - indent_puts ("}"); - --indent_level; - - indent_puts ("}"); - --indent_level; - - indent_puts - ("else if ( yy_act & YY_TRAILING_MASK )"); - ++indent_level; - indent_puts ("{"); - indent_puts - ("YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK;"); - indent_puts - ("YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK;"); - - if (real_reject) { - /* Remember matched text in case we back up - * due to REJECT. - */ - indent_puts - ("YY_G(yy_full_match) = yy_cp;"); - indent_puts - ("YY_G(yy_full_state) = YY_G(yy_state_ptr);"); - indent_puts ("YY_G(yy_full_lp) = YY_G(yy_lp);"); - } - - indent_puts ("}"); - --indent_level; - - indent_puts ("else"); - ++indent_level; - indent_puts ("{"); - indent_puts ("YY_G(yy_full_match) = yy_cp;"); - indent_puts - ("YY_G(yy_full_state) = YY_G(yy_state_ptr);"); - indent_puts ("YY_G(yy_full_lp) = YY_G(yy_lp);"); - indent_puts ("break;"); - indent_puts ("}"); - --indent_level; - - indent_puts ("++YY_G(yy_lp);"); - indent_puts ("goto find_rule;"); - } - - else { - /* Remember matched text in case we back up due to - * trailing context plus REJECT. - */ - ++indent_level; - indent_puts ("{"); - indent_puts ("YY_G(yy_full_match) = yy_cp;"); - indent_puts ("break;"); - indent_puts ("}"); - --indent_level; - } - - indent_puts ("}"); - --indent_level; - - indent_puts ("--yy_cp;"); - - /* We could consolidate the following two lines with those at - * the beginning, but at the cost of complaints that we're - * branching inside a loop. - */ - indent_puts ("yy_current_state = *--YY_G(yy_state_ptr);"); - indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];"); - - indent_puts ("}"); - - --indent_level; - } - - else { /* compressed */ - indent_puts ("yy_act = yy_accept[yy_current_state];"); - - if (interactive && !reject) { - /* Do the guaranteed-needed backing up to figure out - * the match. - */ - indent_puts ("if ( yy_act == 0 )"); - ++indent_level; - indent_puts ("{ /* have to back up */"); - indent_puts - ("yy_cp = YY_G(yy_last_accepting_cpos);"); - indent_puts - ("yy_current_state = YY_G(yy_last_accepting_state);"); - indent_puts - ("yy_act = yy_accept[yy_current_state];"); - indent_puts ("}"); - --indent_level; - } - } -} - /* mkftbl - make the full table and return the struct . * you should call mkecstbl() after this. */ @@ -1884,7 +1740,6 @@ void make_tables (void) skelout (); /* %% [10.0] - break point in skel */ set_indent (2); - gen_find_action (); skelout (); /* %% [11.0] - break point in skel */ outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); diff --git a/tests/Makefile.am b/tests/Makefile.am index 65f9d65..9093f5e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -334,13 +334,15 @@ pthread_pthread_LDADD = @LIBPTHREAD@ # specify how to process .l files in order to test the flex built by make all +TESTOPTS = -L + FLEX = $(top_builddir)/src/flex .l.c: $(FLEX) - $(AM_V_LEX)$(FLEX) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $< .ll.cc: $(FLEX) - $(AM_V_LEX)$(FLEX) -+ -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) -+ -o $@ $< bison_nr_main.$(OBJEXT): bison_nr_parser.h bison_nr_scanner.h bison_nr_scanner.$(OBJEXT): bison_nr_parser.h @@ -367,7 +369,7 @@ bison_yylval_scanner.h: bison_yylval_scanner.c # so we explicitly sayhow, using the .lll suffix for the lex input file .lll.cc: $(FLEX) - $(AM_V_LEX)$(FLEX) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $< header_nr_main.$(OBJEXT): header_nr_scanner.h @@ -402,16 +404,16 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi posixly_correct.c: posixly_correct.l $(FLEX) - $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) -o $@ $< + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< reject_nr.reject.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ $< reject_nr.reject$(EXEEXT): reject_nr.reject.$(OBJEXT) $(AM_V_CCLD)$(LINK) $^ reject_r.reject.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape --reentrant -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape --reentrant -o $@ $< reject_r.reject.$(OBJEXT): reject_r.reject.c $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< @@ -420,7 +422,7 @@ reject_r.reject$(EXEEXT): reject_r.reject.$(OBJEXT) $(AM_V_CCLD)$(LINK) $^ reject_ver.table.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $< reject_ver.table.$(OBJEXT): reject_ver.table.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< @@ -429,7 +431,7 @@ reject_ver.table$(EXEEXT): reject_ver.table.$(OBJEXT) $(AM_V_CCLD)$(LINK) $^ reject_ser.table.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $< reject_ser.table.$(OBJEXT): reject_ser.table.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< @@ -463,13 +465,13 @@ OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r tableopts_opt_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:_F=F) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:_F=F) -o $@ $< tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c $(AM_V_CC)$(COMPILE) -c -o $@ $< tableopts_opt_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst _F,F,$*) -o $@ $< tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< @@ -478,13 +480,13 @@ SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t tableopts_ser_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst _F,F,$*) -o $@ $< tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< tableopts_ser_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst _F,F,$*) -o $@ $< tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< @@ -493,7 +495,7 @@ VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t tableopts_ver_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< @@ -502,7 +504,7 @@ tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT) $(AM_V_CCLD)$(LINK) -o $@ $^ tableopts_ver_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< -- cgit v1.2.1 From f858b63e23ce8e4d45926d1baa28d0fd1c67b339 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 17:03:17 -0400 Subject: Turn gen_start_state() into an M4 macro. This is the first patch in the retargeting series to substantively modify the skeleton file. (The only previous one to touch it just renamed a mode switch.) Adds some comments and whitespace to the generated code in the tests, but produces no logic changes. #14 in the retargeting patch series --- src/cpp-flex.skl | 19 +++++++++++++++++++ src/flexdef.h | 3 --- src/gen.c | 37 ++----------------------------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index b4fd247..dc9b711 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1184,6 +1184,25 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], %% [6.0] YY_RULE_SETUP definition goes here ]]) +%# Code snippets used in various cases of code generation in the main scanner. + +m4_define([[M4_GEN_START_STATE]], [[ + /* Generate the code to find the start state. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[YY_G(yy_start)];]]) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + yy_current_state = YY_G(yy_start); +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += YY_AT_BOL();]]) + /* Set up for storing up states. */ + m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + YY_G(yy_state_ptr) = YY_G(yy_state_buf); + *YY_G(yy_state_ptr)++ = yy_current_state; +]]) +]]) +]]) + %not-for-header /** The main scanner function which does all the work. */ diff --git a/src/flexdef.h b/src/flexdef.h index 781fe25..a5ee509 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -801,9 +801,6 @@ extern void gen_next_state(int); /* Generate the code to make a NUL transition. */ extern void gen_NUL_trans(void); -/* Generate the code to find the start state. */ -extern void gen_start_state(void); - /* Generate data statements for the transition tables. */ extern void gentabs(void); diff --git a/src/gen.c b/src/gen.c index 682b43e..c983d56 100644 --- a/src/gen.c +++ b/src/gen.c @@ -823,39 +823,6 @@ void gen_NUL_trans (void) } -/* Generate the code to find the start state. */ - -void gen_start_state (void) -{ - if (fullspd) { - if (bol_needed) { - indent_puts - ("yy_current_state = yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];"); - } - else - indent_puts - ("yy_current_state = yy_start_state_list[YY_G(yy_start)];"); - } - - else { - indent_puts ("yy_current_state = YY_G(yy_start);"); - - if (bol_needed) - indent_puts ("yy_current_state += YY_AT_BOL();"); - - if (reject) { - /* Set up for storing up states. */ - outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); - indent_puts - ("YY_G(yy_state_ptr) = YY_G(yy_state_buf);"); - indent_puts - ("*YY_G(yy_state_ptr)++ = yy_current_state;"); - outn ("]])"); - } - } -} - - /* gentabs - generate data statements for the transition tables */ void gentabs (void) @@ -1732,7 +1699,7 @@ void make_tables (void) skelout (); /* %% [9.0] - break point in skel */ - gen_start_state (); + outn ("M4_GEN_START_STATE"); /* Note, don't use any indentation. */ outn ("yy_match:"); @@ -1898,7 +1865,7 @@ void make_tables (void) set_indent (1); skelout (); /* %% [15.0] - break point in skel */ - gen_start_state (); + outn ("M4_GEN_START_STATE"); set_indent (2); skelout (); /* %% [16.0] - break point in skel */ -- cgit v1.2.1 From 90bf7c7bcb621d0c2483a0383fa1e5c8db6d5521 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 22:01:41 -0400 Subject: Create m4 symbols for things that used to be generated as int literals. Changes the generated C sources from the tests, but only by making them easier to read. In future patches this is going to make them easier to compare by eyeball as well. #15 in the retargeting patch series --- src/gen.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/gen.c b/src/gen.c index c983d56..1e78b96 100644 --- a/src/gen.c +++ b/src/gen.c @@ -647,13 +647,10 @@ void gen_next_match (void) indent_puts ("}"); --indent_level; - do_indent (); - if (interactive) - out_dec ("while ( yy_base[yy_current_state] != %d );\n", jambase); + indent_puts ("while ( yy_base[yy_current_state] != YY_JAMBASE );"); else - out_dec ("while ( yy_current_state != %d );\n", - jamstate); + indent_puts ("while ( yy_current_state != YY_JAMSTATE );"); if (!reject && !interactive) { /* Do the guaranteed-needed backing up to figure out @@ -672,23 +669,19 @@ void gen_next_match (void) void gen_next_state (int worry_about_NULs) { /* NOTE - changes in here should be reflected in gen_next_match() */ - char char_map[256]; + char *char_map; if (worry_about_NULs && !nultrans) { if (useecs) - snprintf (char_map, sizeof(char_map), - "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)", - NUL_ec); + char_map = "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : YY_NUL_EC)"; else - snprintf (char_map, sizeof(char_map), - "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)", - NUL_ec); + char_map = "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : YY_NUL_EC)"; } else - strcpy (char_map, useecs ? + char_map = useecs ? "yy_ec[YY_SC_TO_UI(*yy_cp)] " : - "YY_SC_TO_UI(*yy_cp)"); + "YY_SC_TO_UI(*yy_cp)"; if (worry_about_NULs && nultrans) { if (!fulltbl && !fullspd) @@ -764,15 +757,15 @@ void gen_NUL_trans (void) else if (fulltbl) { do_indent (); if (gentables) - out_dec ("yy_current_state = yy_nxt[yy_current_state][%d];\n", NUL_ec); + outn ("yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];"); else - out_dec ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %d];\n", NUL_ec); + outn ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];"); indent_puts ("yy_is_jam = (yy_current_state <= 0);"); } else if (fullspd) { do_indent (); - out_dec ("int yy_c = %d;\n", NUL_ec); + outn ("int yy_c = YY_NUL_EC;"); indent_puts ("const struct yy_trans_info *yy_trans_info;\n"); @@ -790,9 +783,7 @@ void gen_NUL_trans (void) snprintf (NUL_ec_str, sizeof(NUL_ec_str), "%d", NUL_ec); gen_next_compressed_state (NUL_ec_str); - do_indent (); - out_dec ("yy_is_jam = (yy_current_state == %d);\n", - jamstate); + indent_puts ("yy_is_jam = (yy_current_state == YY_JAMSTATE);"); if (reject) { /* Only stack this state if it's a transition we @@ -1306,6 +1297,11 @@ void make_tables (void) out_dec ("#define YY_NUM_RULES %d\n", num_rules); out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); + fprintf (stdout, backend->int_define_fmt, "YY_JAMBASE", jambase); + fprintf (stdout, backend->int_define_fmt, "YY_JAMSTATE", jamstate); + + fprintf (stdout, backend->int_define_fmt, "YY_NUL_EC", NUL_ec); + if (fullspd) { /* Need to define the transet type as a size large * enough to hold the biggest offset. @@ -1742,8 +1738,7 @@ void make_tables (void) "fprintf( stderr, \"--scanner backing up\\n\" );"); --indent_level; - do_indent (); - out_dec ("else if ( yy_act < %d )\n", num_rules); + indent_puts ("else if ( yy_act < YY_NUM_RULES )"); ++indent_level; if (C_plus_plus) { -- cgit v1.2.1 From 2ab6a3baf77f5284b035260d89c200c93157a9cb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 21 Sep 2020 23:04:50 -0400 Subject: Move debug code generation from C to m4. Differences in generated code are trivial. Some integer literals turn into symbol expressions as a side effect of the previous patch. #16 in the retargeting patch series --- src/cpp-flex.skl | 45 ++++++++++++++++++++++++++++++++++ src/gen.c | 75 -------------------------------------------------------- 2 files changed, 45 insertions(+), 75 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index dc9b711..81aee27 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1375,6 +1375,51 @@ do_action: /* This label is used only to access EOF actions. */ %% [12.0] debug code goes here +m4_ifdef([[M4_MODE_DEBUG]], [[ + if ( yy_flex_debug ) { + if ( yy_act == 0 ) { +%if-c++-only + std::cerr << "--scanner backing up\n"; +%endif +%if-c-only + fprintf( stderr, "--scanner backing up\n" ); +%endif + } else if ( yy_act < YY_NUM_RULES ) { +%if-c++-only + std::cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << + "(\"" << yytext << "\")\n"; +%endif +%if-c-only + fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", + (long)yy_rule_linenum[yy_act], yytext ); +%endif + } else if ( yy_act == YY_NUM_RULES ) { +%if-c++-only + std::cerr << "--accepting default rule (\"" << yytext << "\")\n"; +%endif +%if-c-only + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yytext ); +%endif + } else if ( yy_act == YY_NUM_RULES + 1 ) { + +%if-c++-only + std::cerr << "--(end of buffer or a NUL)\n"; +%endif +%if-c-only + fprintf( stderr, "--(end of buffer or a NUL)\n" ); +%endif + } else { +%if-c++-only + std::cerr << "--EOF (start condition " << YY_START << ")\n"; +%endif +%if-c-only + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); +%endif + } + } +]]) + switch ( yy_act ) { /* beginning of action switch */ %% [13.0] actions go here diff --git a/src/gen.c b/src/gen.c index 1e78b96..dc903c3 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1726,81 +1726,6 @@ void make_tables (void) outn ("]])"); skelout (); /* %% [12.0] - break point in skel */ - if (ddebug) { - indent_puts ("if ( yy_flex_debug )"); - ++indent_level; - - indent_puts ("{"); - indent_puts ("if ( yy_act == 0 )"); - ++indent_level; - indent_puts (C_plus_plus ? - "std::cerr << \"--scanner backing up\\n\";" : - "fprintf( stderr, \"--scanner backing up\\n\" );"); - --indent_level; - - indent_puts ("else if ( yy_act < YY_NUM_RULES )"); - ++indent_level; - - if (C_plus_plus) { - indent_puts - ("std::cerr << \"--accepting rule at line \" << yy_rule_linenum[yy_act] <<"); - indent_puts - (" \"(\\\"\" << yytext << \"\\\")\\n\";"); - } - else { - indent_puts - ("fprintf( stderr, \"--accepting rule at line %ld (\\\"%s\\\")\\n\","); - - indent_puts - (" (long)yy_rule_linenum[yy_act], yytext );"); - } - - --indent_level; - - do_indent (); - out_dec ("else if ( yy_act == %d )\n", num_rules); - ++indent_level; - - if (C_plus_plus) { - indent_puts - ("std::cerr << \"--accepting default rule (\\\"\" << yytext << \"\\\")\\n\";"); - } - else { - indent_puts - ("fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\","); - indent_puts (" yytext );"); - } - - --indent_level; - - do_indent (); - out_dec ("else if ( yy_act == %d )\n", num_rules + 1); - ++indent_level; - - indent_puts (C_plus_plus ? - "std::cerr << \"--(end of buffer or a NUL)\\n\";" : - "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );"); - - --indent_level; - - do_indent (); - outn ("else"); - ++indent_level; - - if (C_plus_plus) { - indent_puts - ("std::cerr << \"--EOF (start condition \" << YY_START << \")\\n\";"); - } - else { - indent_puts - ("fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );"); - } - - --indent_level; - - indent_puts ("}"); - --indent_level; - } /* Copy actions to output file. */ skelout (); /* %% [13.0] - break point in skel */ -- cgit v1.2.1 From feac8a6abf317090df62363f771e6487827629b0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 00:03:22 -0400 Subject: Clean up a couple of methodization loose ends. Generated-code differences are trivial whitespace. #17 in the retargeting patch series --- src/main.c | 61 ++++++++++++++++++++++++++++++++----------------------------- src/misc.c | 2 +- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/main.c b/src/main.c index 15f1a4a..5bb8260 100644 --- a/src/main.c +++ b/src/main.c @@ -458,39 +458,42 @@ void check_options (void) /* Create the alignment type. */ buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", backend->yy_int_aligned()); - /* Define the start condition macros. */ - { - struct Buf tmpbuf; - buf_init(&tmpbuf, sizeof(char)); - for (i = 1; i <= lastsc; i++) { - char *str, *fmt = backend->int_define_fmt; - size_t strsz; - - strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; - str = malloc(strsz); - if (!str) - flexfatal(_("allocation of macro definition failed")); - snprintf(str, strsz, fmt, scname[i], i - 1); - buf_strappend(&tmpbuf, str); - free(str); - } - buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); - buf_destroy(&tmpbuf); - } + /* Define the start condition macros. */ + { + struct Buf tmpbuf; + buf_init(&tmpbuf, sizeof(char)); + for (i = 1; i <= lastsc; i++) { + char *str, *fmt = backend->int_define_fmt; + size_t strsz; + + strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; + str = malloc(strsz); + if (!str) + flexfatal(_("allocation of macro definition failed")); + snprintf(str, strsz, fmt, scname[i], i - 1); + buf_strappend(&tmpbuf, str); + free(str); + } + buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); + buf_destroy(&tmpbuf); + } - /* This is where we begin writing to the file. */ + /* This is where we begin writing to the file. */ - /* Dump the %top code. */ - if( top_buf.elts) - outn((char*) top_buf.elts); + /* Dump the %top code. */ + if( top_buf.elts) + outn((char*) top_buf.elts); - /* Dump the m4 definitions. */ - buf_print_strings(&m4defs_buf, stdout); - m4defs_buf.nelts = 0; /* memory leak here. */ + /* Dump the m4 definitions. */ + buf_print_strings(&m4defs_buf, stdout); + m4defs_buf.nelts = 0; /* memory leak here. */ - /* Place a bogus line directive, it will be fixed in the filter. */ - if (gen_line_dirs) - outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n"); + /* Place a bogus line directive, it will be fixed in the filter. */ + if (gen_line_dirs && backend->trace_fmt) { + char buf2[4096]; + snprintf(buf2, sizeof(buf2), backend->trace_fmt, 0, "M4_YY_OUTFILE_NAME"); + outn(buf2); + } /* Dump the user defined preproc directives. */ if (userdef_buf.elts) diff --git a/src/misc.c b/src/misc.c index 3705b65..426b1c7 100644 --- a/src/misc.c +++ b/src/misc.c @@ -260,7 +260,7 @@ void dataend (void) dataflush (); /* add terminator for initialization; { for vi */ - outn (" } ;\n"); + outn (backend->table_closer); } dataline = 0; datapos = 0; -- cgit v1.2.1 From abe63d33d1c48a136510441346c175d8801f11c4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 00:39:21 -0400 Subject: Push code generation for some housekeeping from gen.c to m4. The pieces are BOL checking, yylineno updating, and YY_RULE_SETUP generation. No generated code changes at all from this. #18 in the retargeting patch series --- src/cpp-flex.skl | 19 +++++++++++++++++++ src/gen.c | 33 --------------------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 81aee27..4edb364 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1182,6 +1182,11 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ %% [6.0] YY_RULE_SETUP definition goes here +#define YY_RULE_SETUP \ +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ +]]) YY_USER_ACTION ]]) %# Code snippets used in various cases of code generation in the main scanner. @@ -2029,6 +2034,20 @@ m4_ifdef( [[M4_YY_USE_LINENO]], %% [19.0] update BOL and yylineno +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) + M4_YY_INCR_LINENO(); +]]) +]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( c == '\n' ) + M4_YY_INCR_LINENO(); +]]) +]]) + return c; } %if-c-only diff --git a/src/gen.c b/src/gen.c index dc903c3..4e388d0 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1657,19 +1657,6 @@ void make_tables (void) } skelout (); /* %% [6.0] - break point in skel */ - - indent_puts ("#define YY_RULE_SETUP \\"); - ++indent_level; - if (bol_needed) { - indent_puts ("if ( yyleng > 0 ) \\"); - ++indent_level; - indent_puts ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \\"); - indent_puts ("\t\t(yytext[yyleng - 1] == '\\n'); \\"); - --indent_level; - } - indent_puts ("YY_USER_ACTION"); - --indent_level; - skelout (); /* %% [7.0] - break point in skel */ /* Copy prolog to output file. */ @@ -1797,26 +1784,6 @@ void make_tables (void) skelout (); /* %% [18.0] - break point in skel */ skelout (); /* %% [19.0] - break point in skel */ - /* Update BOL and yylineno inside of input(). */ - if (bol_needed) { - indent_puts - ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\\n');"); - if (do_yylineno) { - indent_puts - ("if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )"); - ++indent_level; - indent_puts ("M4_YY_INCR_LINENO();"); - --indent_level; - } - } - - else if (do_yylineno) { - indent_puts ("if ( c == '\\n' )"); - ++indent_level; - indent_puts ("M4_YY_INCR_LINENO();"); - --indent_level; - } - skelout (); /* Copy remainder of input to output. */ -- cgit v1.2.1 From 6711981a2d7e2fc3e3965156e0cb0887387f202a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 03:16:04 -0400 Subject: gen_backing_up() becomes an m4 macro. Generated-code changes consist of whitespace and a comment. Thus patch also fixes the computation of two guard symbols that weren't actually used yet, prospectively introduced in patch #15 of this series. At the time I wrote that I didn't understand what num_backing_up was doing and failed to translate it properly. #19 in the retargeting patch series --- src/cpp-flex.skl | 18 ++++++++++++++++++ src/flexdef.h | 3 --- src/gen.c | 47 +++++++++++++++++++---------------------------- src/main.c | 8 ++------ 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4edb364..90f7c78 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1191,6 +1191,24 @@ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) \ %# Code snippets used in various cases of code generation in the main scanner. +m4_define([[M4_GEN_BACKING_UP]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + /* Generate code to keep backing-up information. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ + if ( yy_current_state[-1].yy_nxt ) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + if ( yy_accept[yy_current_state] ) +]]) + { + YY_G(yy_last_accepting_state) = yy_current_state; + YY_G(yy_last_accepting_cpos) = yy_cp; + } +]]) +]]) +]]) + m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ diff --git a/src/flexdef.h b/src/flexdef.h index a5ee509..e84de08 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -775,9 +775,6 @@ extern void mkechar(int, int[], int[]); extern void do_indent(void); /* indent to the current level */ -/* Generate the code to keep backing-up information. */ -extern void gen_backing_up(void); - /* Generate the code to perform the backing up. */ extern void gen_bu_action(void); diff --git a/src/gen.c b/src/gen.c index 4e388d0..07341ba 100644 --- a/src/gen.c +++ b/src/gen.c @@ -112,27 +112,6 @@ static void geneoltbl (void) } -/* Generate the code to keep backing-up information. */ - -void gen_backing_up (void) -{ - if (reject || num_backing_up == 0) - return; - - if (fullspd) - indent_puts ("if ( yy_current_state[-1].yy_nxt )"); - else - indent_puts ("if ( yy_accept[yy_current_state] )"); - - ++indent_level; - indent_puts ("{"); - indent_puts ("YY_G(yy_last_accepting_state) = yy_current_state;"); - indent_puts ("YY_G(yy_last_accepting_cpos) = yy_cp;"); - indent_puts ("}"); - --indent_level; -} - - /* Generate the code to perform the backing up. */ void gen_bu_action (void) @@ -528,7 +507,7 @@ void gen_next_compressed_state (char *char_map) * because we always compute one more state than needed - we * always proceed until we reach a jam state */ - gen_backing_up (); + outn ("M4_GEN_BACKING_UP"); indent_puts ("while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )"); @@ -589,14 +568,14 @@ void gen_next_match (void) if (num_backing_up > 0) { indent_puts ("{"); - gen_backing_up (); + outn ("M4_GEN_BACKING_UP"); outc ('\n'); } indent_puts ("++yy_cp;"); if (num_backing_up > 0) - + outn ("M4_GEN_BACKING_UP"); indent_puts ("}"); --indent_level; @@ -625,7 +604,7 @@ void gen_next_match (void) if (num_backing_up > 0) { outc ('\n'); - gen_backing_up (); + outn ("M4_GEN_BACKING_UP"); indent_puts ("}"); } @@ -686,7 +665,7 @@ void gen_next_state (int worry_about_NULs) if (worry_about_NULs && nultrans) { if (!fulltbl && !fullspd) /* Compressed tables back up *before* they match. */ - gen_backing_up (); + outn ("M4_GEN_BACKING_UP"); indent_puts ("if ( *yy_cp )"); ++indent_level; @@ -724,7 +703,7 @@ void gen_next_state (int worry_about_NULs) } if (fullspd || fulltbl) - gen_backing_up (); + outn ("M4_GEN_BACKING_UP"); if (reject) indent_puts ("*YY_G(yy_state_ptr)++ = yy_current_state;"); @@ -807,7 +786,7 @@ void gen_NUL_trans (void) indent_puts ("if ( ! yy_is_jam )"); ++indent_level; indent_puts ("{"); - gen_backing_up (); + outn ("M4_GEN_BACKING_UP"); indent_puts ("}"); --indent_level; } @@ -1404,6 +1383,18 @@ void make_tables (void) else gentabs (); + // Only at this point do we know if the automaton has backups. + // Some m4 conditionals require this information. + + if (num_backing_up > 0) + out_m4_define( "M4_MODE_HAS_BACKING_UP", NULL); + + // These are used for NUL transitions + if ((num_backing_up > 0 && !reject) && (!nultrans || fullspd || fulltbl)) + out_m4_define( "M4_MODE_NEED_YY_CP", NULL); + if ((num_backing_up > 0 && !reject) && (fullspd || fulltbl)) + out_m4_define( "M4_MODE_NULTRANS_WRAP", NULL); + if (do_yylineno) { geneoltbl (); diff --git a/src/main.c b/src/main.c index 5bb8260..e4fc498 100644 --- a/src/main.c +++ b/src/main.c @@ -1490,12 +1490,8 @@ void readin (void) if (ddebug) out_m4_define( "M4_MODE_DEBUG", NULL); - // This weird conditional pacifies lint - if (!reject && (!nultrans || fullspd || fulltbl)) - out_m4_define( "M4_MODE_NEED_YY_CP", NULL); - - if (!reject && (fullspd || fulltbl)) - out_m4_define( "M4_MODE_NULTRANS_WRAP", NULL); + // A few additional mode switches cannot be computed + // until we know whether the automaton has backing-up actions. } /* set_up_initial_allocations - allocate memory for internal tables */ -- cgit v1.2.1 From 30788806b98ae23151c921ad34c3a6f7ab1d0d76 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 04:35:57 -0400 Subject: gen_next_match() becomes m4 code. To verify this patch, notice that the non-whitespace changes in the generated C from the tests are of only three kinds: 1. Addition of comments. I elected to copy the comments from the generator functions into their corresponding m4 macros in hopes of making the generated code less nasty to read. 2. Lines like "if ( yy_current_state >= 12 )" changing so the numeric literal is replaced by YY_JAMSTATE + 1. This was a consequence of the change in #15 to simplify the C code generators so they could be translated into static nacros. 3. "YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]" being replaced by "YY_CHAR yy_c = *(yy_ec+YY_SC_TO_UI(*yy_cp));". The strange way of indexing yy_ec avoids a syntactic collision with the use of [] as m4 quotes. #20 in the retargeting patch series --- src/cpp-flex.skl | 89 +++++++++++++++++++++++++++++++++++++++++++++++ src/flexdef.h | 3 -- src/gen.c | 104 ------------------------------------------------------- 3 files changed, 89 insertions(+), 107 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 90f7c78..25ee2df 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1209,6 +1209,35 @@ m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ ]]) ]]) +m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ + YY_CHAR yy_c = $1; + /* Save the backing-up info \before/ computing the next state + * because we always compute one more state than needed - we + * always proceed until we reach a jam state + */ + M4_GEN_BACKING_UP + + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + +m4_ifdef([[M4_MODE_USEMECS]], [[ + /* We've arranged it so that templates are never chained + * to one another. This means we can afford to make a + * very simple test to see if we need to convert to + * yy_c's meta-equivalence class without worrying + * about erroneously looking up the meta-equivalence + * class twice + */ + + /* lastdfa + 2 == YY_JAMSTATE + 1 is the beginning of the templates */ + if (yy_current_state >= YY_JAMSTATE + 1) + yy_c = yy_meta[yy_c]; +]]) + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; +]]) + m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ @@ -1226,6 +1255,26 @@ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += YY_AT_BOL();]]) ]]) ]]) +m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ + { + const struct yy_trans_info *yy_trans_info; + YY_CHAR yy_c; + + for ( yy_c = $1; + (yy_trans_info = &yy_current_state[yy_c])->yy_verify == yy_c; + yy_c = $2 ) + { + yy_current_state += yy_trans_info->yy_nxt; + + M4_GEN_BACKING_UP + } + } +]]) + +%# Conditional indirection through an equivalence map +m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) +m4_ifdef([[M4_NOT_MODE_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) + %not-for-header /** The main scanner function which does all the work. */ @@ -1321,6 +1370,46 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], %% [9.0] code to set up and find next match goes here + /* Generate the code to find the next match. */ +m4_ifdef([[M4_MODE_FULLTBL]], [[ +m4_ifdef([[M4_MODE_GENTABLES]], [[ + while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { +]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ + while ((yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) + { +]]) +M4_GEN_BACKING_UP + yy_cp++; + } + yy_current_state = -yy_current_state; +]]) +m4_ifdef([[M4_MODE_FULLSPD]], [[ + M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yy_cp)), M4_EC(YY_SC_TO_UI(*++yy_cp))) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ + do + { + M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) + + m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) + ++yy_cp; + + } + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yy_current_state] != YY_JAMBASE );]]) + m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yy_current_state != YY_JAMSTATE );]]) + +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ + /* Do the guaranteed-needed backing up to figure out + * the match. + */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); +]]) +]]) +]]) + yy_find_action: %% [10.0] code to find the action number goes here m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) diff --git a/src/flexdef.h b/src/flexdef.h index e84de08..b1de1b6 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -789,9 +789,6 @@ extern void genftbl(void); /* generate full transition table */ /* Generate the code to find the next compressed-table state. */ extern void gen_next_compressed_state(char *); -/* Generate the code to find the next match. */ -extern void gen_next_match(void); - /* Generate the code to find the next state. */ extern void gen_next_state(int); diff --git a/src/gen.c b/src/gen.c index 07341ba..2b726a4 100644 --- a/src/gen.c +++ b/src/gen.c @@ -541,109 +541,6 @@ void gen_next_compressed_state (char *char_map) } -/* Generate the code to find the next match. */ - -void gen_next_match (void) -{ - /* NOTE - changes in here should be reflected in gen_next_state() and - * gen_NUL_trans(). - */ - char *char_map = useecs ? - "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)"; - - char *char_map_2 = useecs ? - "yy_ec[YY_SC_TO_UI(*++yy_cp)] " : "YY_SC_TO_UI(*++yy_cp)"; - - if (fulltbl) { - if (gentables) - indent_put2s - ("while ( (yy_current_state = yy_nxt[yy_current_state][ %s ]) > 0 )", - char_map); - else - indent_put2s - ("while ( (yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s ]) > 0 )", - char_map); - - ++indent_level; - - if (num_backing_up > 0) { - indent_puts ("{"); - outn ("M4_GEN_BACKING_UP"); - outc ('\n'); - } - - indent_puts ("++yy_cp;"); - - if (num_backing_up > 0) - outn ("M4_GEN_BACKING_UP"); - indent_puts ("}"); - - --indent_level; - - outc ('\n'); - indent_puts ("yy_current_state = -yy_current_state;"); - } - - else if (fullspd) { - indent_puts ("{"); - indent_puts - ("const struct yy_trans_info *yy_trans_info;\n"); - indent_puts ("YY_CHAR yy_c;\n"); - indent_put2s ("for ( yy_c = %s;", char_map); - indent_puts - (" (yy_trans_info = &yy_current_state[yy_c])->"); - indent_puts ("yy_verify == yy_c;"); - indent_put2s (" yy_c = %s )", char_map_2); - - ++indent_level; - - if (num_backing_up > 0) - indent_puts ("{"); - - indent_puts ("yy_current_state += yy_trans_info->yy_nxt;"); - - if (num_backing_up > 0) { - outc ('\n'); - outn ("M4_GEN_BACKING_UP"); - indent_puts ("}"); - } - - --indent_level; - indent_puts ("}"); - } - - else { /* compressed */ - indent_puts ("do"); - - ++indent_level; - indent_puts ("{"); - - gen_next_state (false); - - indent_puts ("++yy_cp;"); - - - indent_puts ("}"); - --indent_level; - - if (interactive) - indent_puts ("while ( yy_base[yy_current_state] != YY_JAMBASE );"); - else - indent_puts ("while ( yy_current_state != YY_JAMSTATE );"); - - if (!reject && !interactive) { - /* Do the guaranteed-needed backing up to figure out - * the match. - */ - indent_puts - ("yy_cp = YY_G(yy_last_accepting_cpos);"); - indent_puts - ("yy_current_state = YY_G(yy_last_accepting_state);"); - } - } -} - - /* Generate the code to find the next state. */ void gen_next_state (int worry_about_NULs) @@ -1677,7 +1574,6 @@ void make_tables (void) /* Note, don't use any indentation. */ outn ("yy_match:"); - gen_next_match (); skelout (); /* %% [10.0] - break point in skel */ set_indent (2); -- cgit v1.2.1 From e6fa974cd7523f2e093ed70dca591dc89d19c061 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 06:08:10 -0400 Subject: gen_bu_action() becomes m4 code. Also, two GEN_START_STATE calls get inlined in the skeleton file. Changes in generated C from the tests are all comments and whitespace. #21 in the retargeting patch series --- src/cpp-flex.skl | 19 +++++++++++++++++++ src/flexdef.h | 3 --- src/gen.c | 36 +----------------------------------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 25ee2df..25b7612 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1368,6 +1368,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], */ yy_bp = yy_cp; +M4_GEN_START_STATE %% [9.0] code to set up and find next match goes here /* Generate the code to find the next match. */ @@ -1534,6 +1535,23 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ switch ( yy_act ) { /* beginning of action switch */ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = YY_G(yy_hold_char); + + /* /\* Backing-up info for compressed tables is taken \after/ */ + /* * yy_cp has been incremented for the next state. */ + /* *\/ */ + yy_cp = YY_G(yy_last_accepting_cpos); + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) + m4_ifdef([[M4_MODE_FULLTBL]], [[yy_cp++;]]) + + yy_current_state = YY_G(yy_last_accepting_state); + goto yy_find_action; +]]) +]]) %% [13.0] actions go here case YY_END_OF_BUFFER: @@ -1973,6 +1991,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], char *yy_cp; M4_YY_DECL_GUTS_VAR(); +M4_GEN_START_STATE %% [15.0] code to get the start state into yy_current_state goes here for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) diff --git a/src/flexdef.h b/src/flexdef.h index b1de1b6..7ee87eb 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -775,9 +775,6 @@ extern void mkechar(int, int[], int[]); extern void do_indent(void); /* indent to the current level */ -/* Generate the code to perform the backing up. */ -extern void gen_bu_action(void); - /* Generate full speed compressed transition table. */ extern void genctbl(void); diff --git a/src/gen.c b/src/gen.c index 2b726a4..c0740bc 100644 --- a/src/gen.c +++ b/src/gen.c @@ -112,34 +112,6 @@ static void geneoltbl (void) } -/* Generate the code to perform the backing up. */ - -void gen_bu_action (void) -{ - if (reject || num_backing_up == 0) - return; - - set_indent (3); - - indent_puts ("case 0: /* must back up */"); - indent_puts ("/* undo the effects of YY_DO_BEFORE_ACTION */"); - indent_puts ("*yy_cp = YY_G(yy_hold_char);"); - - if (fullspd || fulltbl) - indent_puts ("yy_cp = YY_G(yy_last_accepting_cpos) + 1;"); - else - /* Backing-up info for compressed tables is taken \after/ - * yy_cp has been incremented for the next state. - */ - indent_puts ("yy_cp = YY_G(yy_last_accepting_cpos);"); - - indent_puts ("yy_current_state = YY_G(yy_last_accepting_state);"); - indent_puts ("goto yy_find_action;"); - outc ('\n'); - - set_indent (0); -} - /** mkctbl - make full speed compressed transition table * This is an array of structs; each struct a pair of integers. * You should call mkssltbl() immediately after this. @@ -1570,8 +1542,6 @@ void make_tables (void) skelout (); /* %% [9.0] - break point in skel */ - outn ("M4_GEN_START_STATE"); - /* Note, don't use any indentation. */ outn ("yy_match:"); @@ -1603,13 +1573,12 @@ void make_tables (void) /* Copy actions to output file. */ skelout (); /* %% [13.0] - break point in skel */ - ++indent_level; - gen_bu_action (); out (&action_array[action_offset]); line_directive_out (stdout, 0); /* generate cases for any missing EOF rules */ + set_indent(0); for (i = 1; i <= lastsc; ++i) if (!sceof[i]) { do_indent (); @@ -1623,7 +1592,6 @@ void make_tables (void) --indent_level; } - /* Generate code for handling NUL's, if needed. */ /* First, deal with backing up and setting up yy_cp if the scanner @@ -1659,8 +1627,6 @@ void make_tables (void) set_indent (1); skelout (); /* %% [15.0] - break point in skel */ - outn ("M4_GEN_START_STATE"); - set_indent (2); skelout (); /* %% [16.0] - break point in skel */ gen_next_state (true); -- cgit v1.2.1 From 01f4aaddd993c77ed4e7cd9213c082f95909f380 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 06:41:54 -0400 Subject: gen_next_state(true) becomes m4 code. As with patch #20 in this series, the changes in generated code fall in the classes: 1. Addition of comments. I elected to copy the comments from the generator functions into their corresponding m4 macros in hopes of making the generated code less nasty to read. 2. Lines like "if ( yy_current_state >= 12 )" changing so the numeric literal is replaced by YY_JAMSTATE + 1. This was a consequence of the change in #15 to simplify the C code generators so they could be translated into static nacros. 3. "YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : YY_NUL_EC);: being replaced by "YY_CHAR yy_c = (*yy_cp ? *(yy_ec+YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC);" The strange way of indexing yy_ec avoids a syntactic collision with the use of [] as m4 quotes. The gen_next_state(false) case was translated to m4 at patch #20 #22 in the retargeting patch series --- src/cpp-flex.skl | 27 ++++++++++++++++++++++ src/flexdef.h | 3 --- src/gen.c | 70 -------------------------------------------------------- 3 files changed, 27 insertions(+), 73 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 25b7612..83339ac 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1997,6 +1997,33 @@ M4_GEN_START_STATE for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) { %% [16.0] code to find the next state goes here + /* Generate the code to find the next state. */ + m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) + m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) + + m4_ifdef([[M4_MODE_NULTRANS]], [[ + /* Compressed tables back up *before* they match. */ + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) + if ( *yy_cp ) { + ]]) + + m4_ifdef([[M4_MODE_FULLTBL]], [[ + m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) + ]]) + + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) + + m4_ifdef([[M4_MODE_NULTRANS]], [[ + } else { + yy_current_state = yy_NUL_trans[yy_current_state]; + } + ]]) + + m4_ifdef([[M4_MODE_FULLTBL]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) } return yy_current_state; diff --git a/src/flexdef.h b/src/flexdef.h index 7ee87eb..c68cbb8 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -786,9 +786,6 @@ extern void genftbl(void); /* generate full transition table */ /* Generate the code to find the next compressed-table state. */ extern void gen_next_compressed_state(char *); -/* Generate the code to find the next state. */ -extern void gen_next_state(int); - /* Generate the code to make a NUL transition. */ extern void gen_NUL_trans(void); diff --git a/src/gen.c b/src/gen.c index c0740bc..60d9a7c 100644 --- a/src/gen.c +++ b/src/gen.c @@ -513,72 +513,6 @@ void gen_next_compressed_state (char *char_map) } -/* Generate the code to find the next state. */ - -void gen_next_state (int worry_about_NULs) -{ /* NOTE - changes in here should be reflected in gen_next_match() */ - char *char_map; - - if (worry_about_NULs && !nultrans) { - if (useecs) - char_map = "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : YY_NUL_EC)"; - else - char_map = "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : YY_NUL_EC)"; - } - - else - char_map = useecs ? - "yy_ec[YY_SC_TO_UI(*yy_cp)] " : - "YY_SC_TO_UI(*yy_cp)"; - - if (worry_about_NULs && nultrans) { - if (!fulltbl && !fullspd) - /* Compressed tables back up *before* they match. */ - outn ("M4_GEN_BACKING_UP"); - - indent_puts ("if ( *yy_cp )"); - ++indent_level; - indent_puts ("{"); - } - - if (fulltbl) { - if (gentables) - indent_put2s - ("yy_current_state = yy_nxt[yy_current_state][%s];", - char_map); - else - indent_put2s - ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s];", - char_map); - } - - else if (fullspd) - indent_put2s - ("yy_current_state += yy_current_state[%s].yy_nxt;", - char_map); - - else - gen_next_compressed_state (char_map); - - if (worry_about_NULs && nultrans) { - - indent_puts ("}"); - --indent_level; - indent_puts ("else"); - ++indent_level; - indent_puts - ("yy_current_state = yy_NUL_trans[yy_current_state];"); - --indent_level; - } - - if (fullspd || fulltbl) - outn ("M4_GEN_BACKING_UP"); - - if (reject) - indent_puts ("*YY_G(yy_state_ptr)++ = yy_current_state;"); -} - - /* Generate the code to make a NUL transition. */ void gen_NUL_trans (void) @@ -1624,12 +1558,8 @@ void make_tables (void) /* Generate code for yy_get_previous_state(). */ - set_indent (1); skelout (); /* %% [15.0] - break point in skel */ - - set_indent (2); skelout (); /* %% [16.0] - break point in skel */ - gen_next_state (true); set_indent (1); skelout (); /* %% [17.0] - break point in skel */ -- cgit v1.2.1 From e7b3a67adff063fd4be4594f3b930899720b4279 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 08:13:29 -0400 Subject: Code to do back-up for compressed tables and set up yy_cp goes to m4. Also, move the yymatch label to the skeleton. Remove an unused prototype. And fix a typo. In generated C, comment and whitespace changes only. #23 in the retargeting patch series --- src/cpp-flex.skl | 24 +++++++++++++++++++++++- src/flexdef.h | 6 ++---- src/gen.c | 36 +++--------------------------------- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 83339ac..55dcd8b 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1369,8 +1369,10 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yy_bp = yy_cp; M4_GEN_START_STATE -%% [9.0] code to set up and find next match goes here +yy_match: + +%% [9.0] code to set up and find next match goes here /* Generate the code to find the next match. */ m4_ifdef([[M4_MODE_FULLTBL]], [[ m4_ifdef([[M4_MODE_GENTABLES]], [[ @@ -1623,6 +1625,26 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ else { %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) +m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ + /* Do the guaranteed-needed backing up to figure + * out the match. + */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); +]]) +]]) +m4_ifdef([[M4_MODE_REJECT_OR_INTERACTIVE]], [[ + /* Still need to initialize yy_cp, though + * yy_current_state was set up by + * yy_get_previous_state(). + */ + yy_cp = YY_G(yy_c_buf_p); +]]) +]]) goto yy_find_action; } } diff --git a/src/flexdef.h b/src/flexdef.h index c68cbb8..8e8ea1d 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -778,10 +778,8 @@ extern void do_indent(void); /* indent to the current level */ /* Generate full speed compressed transition table. */ extern void genctbl(void); -/* Generate the code to find the action number. */ -extern void gen_find_action(void); - -extern void genftbl(void); /* generate full transition table */ +/* generate full transition table */ +extern void genftbl(void); /* Generate the code to find the next compressed-table state. */ extern void gen_next_compressed_state(char *); diff --git a/src/gen.c b/src/gen.c index 60d9a7c..cc6c251 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1215,7 +1215,7 @@ void make_tables (void) } /* Definitions for backing up. We don't need them if REJECT - * is being used because then we use an alternative backin-up + * is being used because then we use an alternative backing-up * technique instead. */ if (num_backing_up > 0 && !reject) { @@ -1475,14 +1475,10 @@ void make_tables (void) } skelout (); /* %% [9.0] - break point in skel */ - - /* Note, don't use any indentation. */ - outn ("yy_match:"); - skelout (); /* %% [10.0] - break point in skel */ - set_indent (2); - skelout (); /* %% [11.0] - break point in skel */ + + set_indent (2); outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); indent_puts ("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )"); @@ -1532,32 +1528,6 @@ void make_tables (void) * finds that it should JAM on the NUL. */ skelout (); /* %% [14.0] - break point in skel */ - set_indent (4); - - if (fullspd || fulltbl) - indent_puts ("yy_cp = YY_G(yy_c_buf_p);"); - - else { /* compressed table */ - if (!reject && !interactive) { - /* Do the guaranteed-needed backing up to figure - * out the match. - */ - indent_puts - ("yy_cp = YY_G(yy_last_accepting_cpos);"); - indent_puts - ("yy_current_state = YY_G(yy_last_accepting_state);"); - } - - else - /* Still need to initialize yy_cp, though - * yy_current_state was set up by - * yy_get_previous_state(). - */ - indent_puts ("yy_cp = YY_G(yy_c_buf_p);"); - } - - - /* Generate code for yy_get_previous_state(). */ skelout (); /* %% [15.0] - break point in skel */ skelout (); /* %% [16.0] - break point in skel */ -- cgit v1.2.1 From 9a501a4238af4b5728d32d2dbfb01d3a50023a6b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 11:52:50 -0400 Subject: Replace last use of gen_next_compressed_state*( with equivalent m4... ...and then inline the code of gen_NUL_trans() at its callsite. This contains all remaining procedural code generation in make_tables(), on the way to moving it to m4. Generated code diffs are like those of #20 and #22, for the same reasons. They add comments, whitespace changes, and uses of the YY_NUL_EC and YY+JAMSTATE macros equivalent to the old numeric literals. #24 in the retargeting patch series --- src/flexdef.h | 6 -- src/gen.c | 207 ++++++++++++++++++++++------------------------------------ 2 files changed, 78 insertions(+), 135 deletions(-) diff --git a/src/flexdef.h b/src/flexdef.h index 8e8ea1d..63cc030 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -781,12 +781,6 @@ extern void genctbl(void); /* generate full transition table */ extern void genftbl(void); -/* Generate the code to find the next compressed-table state. */ -extern void gen_next_compressed_state(char *); - -/* Generate the code to make a NUL transition. */ -extern void gen_NUL_trans(void); - /* Generate data statements for the transition tables. */ extern void gentabs(void); diff --git a/src/gen.c b/src/gen.c index cc6c251..8d551c1 100644 --- a/src/gen.c +++ b/src/gen.c @@ -468,134 +468,6 @@ void genftbl (void) */ } - -/* Generate the code to find the next compressed-table state. */ - -void gen_next_compressed_state (char *char_map) -{ - indent_put2s ("YY_CHAR yy_c = %s;", char_map); - - /* Save the backing-up info \before/ computing the next state - * because we always compute one more state than needed - we - * always proceed until we reach a jam state - */ - outn ("M4_GEN_BACKING_UP"); - - indent_puts - ("while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )"); - ++indent_level; - indent_puts ("{"); - indent_puts ("yy_current_state = (int) yy_def[yy_current_state];"); - - if (usemecs) { - /* We've arrange it so that templates are never chained - * to one another. This means we can afford to make a - * very simple test to see if we need to convert to - * yy_c's meta-equivalence class without worrying - * about erroneously looking up the meta-equivalence - * class twice - */ - do_indent (); - - /* lastdfa + 2 is the beginning of the templates */ - out_dec ("if ( yy_current_state >= %d )\n", lastdfa + 2); - - ++indent_level; - indent_puts ("yy_c = yy_meta[yy_c];"); - --indent_level; - } - - indent_puts ("}"); - --indent_level; - - indent_puts - ("yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];"); -} - - -/* Generate the code to make a NUL transition. */ - -void gen_NUL_trans (void) -{ /* NOTE - changes in here should be reflected in gen_next_match() */ - /* Only generate a definition for "yy_cp" if we'll generate code - * that uses it. Otherwise lint and the like complain. - */ - int need_backing_up = (num_backing_up > 0 && !reject); - - if (need_backing_up && (!nultrans || fullspd || fulltbl)) - /* We're going to need yy_cp lying around for the call - * below to gen_backing_up(). - */ - indent_puts ("char *yy_cp = YY_G(yy_c_buf_p);"); - - outc ('\n'); - - if (nultrans) { - indent_puts - ("yy_current_state = yy_NUL_trans[yy_current_state];"); - indent_puts ("yy_is_jam = (yy_current_state == 0);"); - } - - else if (fulltbl) { - do_indent (); - if (gentables) - outn ("yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];"); - else - outn ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];"); - indent_puts ("yy_is_jam = (yy_current_state <= 0);"); - } - - else if (fullspd) { - do_indent (); - outn ("int yy_c = YY_NUL_EC;"); - - indent_puts - ("const struct yy_trans_info *yy_trans_info;\n"); - indent_puts - ("yy_trans_info = &yy_current_state[(unsigned int) yy_c];"); - indent_puts ("yy_current_state += yy_trans_info->yy_nxt;"); - - indent_puts - ("yy_is_jam = (yy_trans_info->yy_verify != yy_c);"); - } - - else { - char NUL_ec_str[20]; - - snprintf (NUL_ec_str, sizeof(NUL_ec_str), "%d", NUL_ec); - gen_next_compressed_state (NUL_ec_str); - - indent_puts ("yy_is_jam = (yy_current_state == YY_JAMSTATE);"); - - if (reject) { - /* Only stack this state if it's a transition we - * actually make. If we stack it on a jam, then - * the state stack and yy_c_buf_p get out of sync. - */ - indent_puts ("if ( ! yy_is_jam )"); - ++indent_level; - indent_puts - ("*YY_G(yy_state_ptr)++ = yy_current_state;"); - --indent_level; - } - } - - /* If we've entered an accepting state, back up; note that - * compressed tables have *already* done such backing up, so - * we needn't bother with it again. - */ - if (need_backing_up && (fullspd || fulltbl)) { - outc ('\n'); - indent_puts ("if ( ! yy_is_jam )"); - ++indent_level; - indent_puts ("{"); - outn ("M4_GEN_BACKING_UP"); - indent_puts ("}"); - --indent_level; - } -} - - /* gentabs - generate data statements for the transition tables */ void gentabs (void) @@ -1533,7 +1405,84 @@ void make_tables (void) set_indent (1); skelout (); /* %% [17.0] - break point in skel */ - gen_NUL_trans (); + + /* Generate the code to make a NUL transition. */ + + /* Only generate a definition for "yy_cp" if we'll generate code + * that uses it. Otherwise lint and the like complain. + */ + int need_backing_up = (num_backing_up > 0 && !reject); + + if (need_backing_up && (!nultrans || fullspd || fulltbl)) + /* We're going to need yy_cp lying around for the call + * below to gen_backing_up(). + */ + indent_puts ("char *yy_cp = YY_G(yy_c_buf_p);"); + + outc ('\n'); + + if (nultrans) { + indent_puts + ("yy_current_state = yy_NUL_trans[yy_current_state];"); + indent_puts ("yy_is_jam = (yy_current_state == 0);"); + } + + else if (fulltbl) { + do_indent (); + if (gentables) + outn ("yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];"); + else + outn ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];"); + indent_puts ("yy_is_jam = (yy_current_state <= 0);"); + } + + else if (fullspd) { + do_indent (); + outn ("int yy_c = YY_NUL_EC;"); + + indent_puts + ("const struct yy_trans_info *yy_trans_info;\n"); + indent_puts + ("yy_trans_info = &yy_current_state[(unsigned int) yy_c];"); + indent_puts ("yy_current_state += yy_trans_info->yy_nxt;"); + + indent_puts + ("yy_is_jam = (yy_trans_info->yy_verify != yy_c);"); + } + + else { + char NUL_ec_str[20]; + + out ("M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC)"); + + indent_puts ("yy_is_jam = (yy_current_state == YY_JAMSTATE);"); + + if (reject) { + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + indent_puts ("if ( ! yy_is_jam )"); + ++indent_level; + indent_puts + ("*YY_G(yy_state_ptr)++ = yy_current_state;"); + --indent_level; + } + } + + /* If we've entered an accepting state, back up; note that + * compressed tables have *already* done such backing up, so + * we needn't bother with it again. + */ + if (need_backing_up && (fullspd || fulltbl)) { + outc ('\n'); + indent_puts ("if ( ! yy_is_jam )"); + ++indent_level; + indent_puts ("{"); + outn ("M4_GEN_BACKING_UP"); + indent_puts ("}"); + --indent_level; + } skelout (); /* %% [18.0] - break point in skel */ skelout (); /* %% [19.0] - break point in skel */ -- cgit v1.2.1 From feeba9873f80dafbe96ff35787ac77ca7f2223cf Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 12:52:32 -0400 Subject: Tie up loose ends in the abstraction of table initializer syntax... ...and case statements. Add guidance to backend.adoc. This is the "eventually" promised in the comment on #10 of this series. No diffs in generated code. #25 in the retargeting patch series --- src/backend.adoc | 24 +++++++++++++++++++----- src/cpp_backend.c | 3 +++ src/dfa.c | 4 ++-- src/flexdef.h | 5 ++++- src/gen.c | 5 ++++- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/backend.adoc b/src/backend.adoc index f098516..e8d8323 100644 --- a/src/backend.adoc +++ b/src/backend.adoc @@ -35,24 +35,24 @@ Read the definition of struct backend_t in src/flexdefs.h, and attached comments, to get a feel for the methods. Don't worry about understandng table generator names at first. -To write support for a langusge, you'll want to do the following +To write support for a language, you'll want to do the following steps: 1. Clone one of the existing back-end/skeleton pairs. If the language - you are supporting is names "foo", you should create files named + you are supporting is named "foo", you should create files named foo_backend.c and foo-flex.skl. 2. Add foo_backend.c to COMMON_SOURCES in src.Makefile.am. Add the name of your skeleton file to EXTRA_DIST. 3. Add a production to src/Makefile.am parallel to the one that - priduces cpp-skel.h. Your objecting is to make s string list + priduces cpp-skel.h. Your objecting is to make a string list initializer from your skeleton file that can be linked with flex and is opointed at by the skel nember of your language back end. 4. Add some logic to main.c that enables the new back end with a new command-line option. Following this step you should be - able to run flex on a specification and fet code out in the + able to run flex on a specification and get code out in the language of whatever back end you cloned. 5. The interesting part: mutate your new back end and skeleton so they @@ -60,7 +60,7 @@ steps: 6. Write a test suite for your back end. You should be able to clone one of the existing sets of test loads to get good coverage. Note - that is highly unliely your back end will be accepted into the + that is highly unlikely your back end will be accepted into the flex distribution without a test suite. A hint about step 5: @@ -70,6 +70,20 @@ A hint about step 5: needs to be supported in C for backwards compatibility, but there +The following assumptions in the code might trip you up and +require fixes outside a back end. +1. The language has a case-arm syntax that looks like + a (possibly empty) prefix, followed by a value + expression, followed by a colon. + +2. Either case arms can be stacked as in C; that is, there is + an implicit fallthrough if the case arm has no code. Or, + there is an explicit fallthrough keyword that enables this, + as in Go. + +By putting a yyterminate() call in the fallthrough member +and a null pointer in the endcase member, you could handle +languages like Pascal diff --git a/src/cpp_backend.c b/src/cpp_backend.c index a784b22..0c77f0b 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -594,6 +594,7 @@ struct flex_backend_t cpp_backend = { .int_define_fmt = "#define %s %d\n", .string_define_fmt = "#define %s %s\n", .table_opener = " {", + .table_continuation = " },\n", .table_closer = " };\n", .get_int16_decl = cpp_get_int16_decl, .get_int32_decl = cpp_get_int32_decl, @@ -618,4 +619,6 @@ struct flex_backend_t cpp_backend = { .gentabs_yy_chk = cpp_gentabs_yy_chk, .nultrans = cpp_nultrans, .caseprefix = "case ", + .fallthrough = NULL, + .endcase = "yyterminate();" }; diff --git a/src/dfa.c b/src/dfa.c index 7611812..2dc324c 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -530,7 +530,7 @@ void ntod (void) dataflush (); if (gentables) - out (" },\n\n"); + outn (backend->table_continuation); } /* Create the first states. */ @@ -711,7 +711,7 @@ void ntod (void) dataflush (); if (gentables) - outn (" },\n"); + out (backend->table_continuation); } else if (fullspd) diff --git a/src/flexdef.h b/src/flexdef.h index 63cc030..629d7e4 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -316,7 +316,8 @@ struct flex_backend_t { char *int_define_fmt; // Format for integer constant definitions char *string_define_fmt; // Format for string constant definitions char *table_opener; // Open an array initializer with this - char *table_closer; // Close an array initializer with this + char *table_continuation; // Open an array initializer with this + char *table_closer; // How to continue a two-level initializer const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s const char *(*get_int32_decl)(void); // Format for declaring array initializer of int32s const char *(*get_state_decl)(void); // Format for declaring array initializer of state values @@ -341,6 +342,8 @@ struct flex_backend_t { void (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer void (*nultrans)(int); // Generate nulltrans initializer char *caseprefix; // Prefix of an arm in the language's case construct + char *fallthrough; // Finish a case arm with this to fall through + char *endcase; // What to ship after all EOF-state case arms }; extern bool gentables; diff --git a/src/gen.c b/src/gen.c index 8d551c1..8724713 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1385,12 +1385,15 @@ void make_tables (void) if (!sceof[i]) { do_indent (); out_str3 ("%sYY_STATE_EOF(%s):\n", backend->caseprefix, scname[i], ""); + if (backend->fallthrough != NULL) { + indent_puts(backend->fallthrough); + } did_eof_rule = true; } if (did_eof_rule) { ++indent_level; - indent_puts ("yyterminate();"); + indent_puts (backend->endcase); --indent_level; } -- cgit v1.2.1 From d5574c7387573404129ea48be830094b8a67cc2c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 5 Sep 2020 05:48:45 -0400 Subject: Banish gcc warnings so errors won't get lost in the clutter. --- src/filter.c | 2 +- src/misc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filter.c b/src/filter.c index a7e69ec..9a5e777 100644 --- a/src/filter.c +++ b/src/filter.c @@ -337,7 +337,7 @@ static bool is_blank_line (const char *str) */ int filter_fix_linedirs (struct filter *chain) { - char buf[512]; + char buf[4096]; const size_t readsz = sizeof buf; int lineno = 1; bool in_gen = true; /* in generated code */ diff --git a/src/misc.c b/src/misc.c index 426b1c7..6ee1e5a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -341,7 +341,7 @@ void lerr_fatal (const char *msg, ...) void line_directive_out (FILE *output_file, int do_infile) { - char directive[MAXLINE], filename[MAXLINE]; + char directive[MAXLINE*2], filename[MAXLINE]; char *s1, *s2, *s3; if (!gen_line_dirs) -- cgit v1.2.1 From b101188a767f589340deed97125571db945d4865 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 19:36:51 -0400 Subject: Push the definition of struct yy_trans_info out to m4. Required defining a new method table entry and shuffling the order in which things are generated a bit, but the generated-code diffs are all trivial. Some comments from the previous C code are now in the skeleton. #26 in the retargeting patch series --- src/cpp-flex.skl | 28 +++++++++++++++++++++++ src/cpp_backend.c | 7 ++++++ src/flexdef.h | 1 + src/gen.c | 68 ++++++++++--------------------------------------------- src/main.c | 6 +++++ 5 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 55dcd8b..22c2e42 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -670,6 +670,34 @@ static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); %endif +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ +struct yy_trans_info + { + /* We require that yy_verify and yy_nxt must be of the same size int. */ +m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ + YY_OFFSET_TYPE yy_verify; + + /* In cases where its sister yy_verify *is* a "yes, there is + * a transition", yy_nxt is the offset (in records) to the + * next state. In most cases where there is no transition, + * the value of yy_nxt is irrelevant. If yy_nxt is the -1th + * record of a state, though, then yy_nxt is the action number + * for that state. + */ + YY_OFFSET_TYPE yy_nxt; +]]) +m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ + /* We generate a bogus 'struct yy_trans_info' data type + * so we can guarantee that it is always declared in the skel. + * This is so we can compile "sizeof(struct yy_trans_info)" + * in any scanner. + */ + flex_int32_t yy_verify; + flex_int32_t yy_nxt; +]]) + }; +]]) + m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* Done after the current pattern has been matched and before the diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 0c77f0b..c868749 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -578,6 +578,12 @@ static void cpp_nultrans(int fullspd) "flex_int32_t"); } +static const char *cpp_trans_offset_type(int total_table_size) +{ + return (total_table_size >= INT16_MAX || long_align) ? + "flex_int32_t" : "flex_int16_t"; +} + const char *cpp_skel[] = { #include "cpp-skel.h" 0, @@ -618,6 +624,7 @@ struct flex_backend_t cpp_backend = { .gentabs_yy_nxt = cpp_gentabs_yy_nxt, .gentabs_yy_chk = cpp_gentabs_yy_chk, .nultrans = cpp_nultrans, + .trans_offset_type = cpp_trans_offset_type, .caseprefix = "case ", .fallthrough = NULL, .endcase = "yyterminate();" diff --git a/src/flexdef.h b/src/flexdef.h index 629d7e4..6bed71d 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -341,6 +341,7 @@ struct flex_backend_t { void (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer void (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer void (*nultrans)(int); // Generate nulltrans initializer + const char *(*trans_offset_type)(int); // Compute an efficient type for transition tables char *caseprefix; // Prefix of an arm in the language's case construct char *fallthrough; // Finish a case arm with this to fall through char *endcase; // What to ship after all EOF-state case arms diff --git a/src/gen.c b/src/gen.c index 8724713..076cdb8 100644 --- a/src/gen.c +++ b/src/gen.c @@ -896,6 +896,18 @@ void make_tables (void) int did_eof_rule = false; struct yytbl_data *yynultrans_tbl = NULL; + out_dec ("#define YY_NUM_RULES %d\n", num_rules); + out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); + + fprintf (stdout, backend->int_define_fmt, "YY_JAMBASE", jambase); + fprintf (stdout, backend->int_define_fmt, "YY_JAMSTATE", jamstate); + + fprintf (stdout, backend->int_define_fmt, "YY_NUL_EC", NUL_ec); + + /* Need to define the transet type as a size large + * enough to hold the biggest offset. + */ + fprintf (stdout, backend->string_define_fmt, "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1)); skelout (); /* %% [2.0] - break point in skel */ @@ -945,64 +957,8 @@ void make_tables (void) skelout (); /* %% [4.0] - break point in skel */ - /* This is where we REALLY begin generating the tables. */ - out_dec ("#define YY_NUM_RULES %d\n", num_rules); - out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); - - fprintf (stdout, backend->int_define_fmt, "YY_JAMBASE", jambase); - fprintf (stdout, backend->int_define_fmt, "YY_JAMSTATE", jamstate); - - fprintf (stdout, backend->int_define_fmt, "YY_NUL_EC", NUL_ec); - - if (fullspd) { - /* Need to define the transet type as a size large - * enough to hold the biggest offset. - */ - int total_table_size = tblend + numecs + 1; - char *trans_offset_type = - (total_table_size >= INT16_MAX || long_align) ? - "flex_int32_t" : "flex_int16_t"; - - set_indent (0); - indent_puts ("struct yy_trans_info"); - ++indent_level; - indent_puts ("{"); - - /* We require that yy_verify and yy_nxt must be of the same size int. */ - indent_put2s ("%s yy_verify;", trans_offset_type); - - /* In cases where its sister yy_verify *is* a "yes, there is - * a transition", yy_nxt is the offset (in records) to the - * next state. In most cases where there is no transition, - * the value of yy_nxt is irrelevant. If yy_nxt is the -1th - * record of a state, though, then yy_nxt is the action number - * for that state. - */ - - indent_put2s ("%s yy_nxt;", trans_offset_type); - indent_puts ("};"); - --indent_level; - } - else { - /* We generate a bogus 'struct yy_trans_info' data type - * so we can guarantee that it is always declared in the skel. - * This is so we can compile "sizeof(struct yy_trans_info)" - * in any scanner. - */ - indent_puts - ("/* This struct is not used in this scanner,"); - indent_puts (" but its presence is necessary. */"); - indent_puts ("struct yy_trans_info"); - ++indent_level; - indent_puts ("{"); - indent_puts ("flex_int32_t yy_verify;"); - indent_puts ("flex_int32_t yy_nxt;"); - indent_puts ("};"); - --indent_level; - } - if (fullspd) { genctbl (); if (tablesext) { diff --git a/src/main.c b/src/main.c index e4fc498..5e63318 100644 --- a/src/main.c +++ b/src/main.c @@ -1420,6 +1420,12 @@ void readin (void) // stuff out to the skeleton file we make it easier // to retarget the code generation. + // mode switches for yy_trans_info specification + if (fullspd) + out_m4_define( "M4_MODE_REAL_FULLSPD", NULL); + else + out_m4_define( "M4_MODE_NO_REAL_FULLSPD", NULL); + // mode switches for next-action code if (variable_trailing_context_rules) { out_m4_define( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES", NULL); -- cgit v1.2.1 From 0f2a58a818598559f150a7d9d42a7d8ba0b3bc16 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 22 Sep 2020 22:54:43 -0400 Subject: Partial m4ization of nultrans code. Also, remove two insertion points in the skel file that are no longer used because we're now using m4 conditionals instead. In the generated C, two magic comments from the insertion points go away. #27 in the retargeting patch series --- src/cpp-flex.skl | 3 --- src/gen.c | 47 +++++++++++++++++------------------------------ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 22c2e42..064974f 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -2142,7 +2142,6 @@ m4_ifdef( [[M4_YY_NO_UNPUT]],, *--yy_cp = (char) c; -%% [18.0] update yylineno here m4_ifdef( [[M4_YY_USE_LINENO]], [[ if ( c == '\n' ){ @@ -2235,8 +2234,6 @@ m4_ifdef( [[M4_YY_USE_LINENO]], *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); -%% [19.0] update BOL and yylineno - m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ diff --git a/src/gen.c b/src/gen.c index 076cdb8..9141c58 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1361,8 +1361,6 @@ void make_tables (void) skelout (); /* %% [14.0] - break point in skel */ skelout (); /* %% [15.0] - break point in skel */ skelout (); /* %% [16.0] - break point in skel */ - - set_indent (1); skelout (); /* %% [17.0] - break point in skel */ /* Generate the code to make a NUL transition. */ @@ -1370,16 +1368,11 @@ void make_tables (void) /* Only generate a definition for "yy_cp" if we'll generate code * that uses it. Otherwise lint and the like complain. */ - int need_backing_up = (num_backing_up > 0 && !reject); - - if (need_backing_up && (!nultrans || fullspd || fulltbl)) - /* We're going to need yy_cp lying around for the call - * below to gen_backing_up(). - */ - indent_puts ("char *yy_cp = YY_G(yy_c_buf_p);"); + indent_puts ("m4_ifdef([[M4_MODE_NEED_YY_CP]], [[ char *yy_cp = YY_G(yy_c_buf_p);]])"); outc ('\n'); + set_indent (1); if (nultrans) { indent_puts ("yy_current_state = yy_NUL_trans[yy_current_state];"); @@ -1388,10 +1381,8 @@ void make_tables (void) else if (fulltbl) { do_indent (); - if (gentables) - outn ("yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];"); - else - outn ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];"); + outn ("m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]])"); + outn ("m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]])"); indent_puts ("yy_is_jam = (yy_current_state <= 0);"); } @@ -1410,30 +1401,28 @@ void make_tables (void) } else { - char NUL_ec_str[20]; - out ("M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC)"); indent_puts ("yy_is_jam = (yy_current_state == YY_JAMSTATE);"); - if (reject) { - /* Only stack this state if it's a transition we - * actually make. If we stack it on a jam, then - * the state stack and yy_c_buf_p get out of sync. - */ - indent_puts ("if ( ! yy_is_jam )"); - ++indent_level; - indent_puts - ("*YY_G(yy_state_ptr)++ = yy_current_state;"); - --indent_level; - } + indent_puts ("m4_ifdef([[M4_MODE_USES_REJECT]], [["); + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + indent_puts ("if ( ! yy_is_jam )"); + ++indent_level; + indent_puts + ("*YY_G(yy_state_ptr)++ = yy_current_state;"); + --indent_level; + indent_puts ("]])"); } /* If we've entered an accepting state, back up; note that * compressed tables have *already* done such backing up, so * we needn't bother with it again. */ - if (need_backing_up && (fullspd || fulltbl)) { + indent_puts ("m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [["); outc ('\n'); indent_puts ("if ( ! yy_is_jam )"); ++indent_level; @@ -1441,10 +1430,8 @@ void make_tables (void) outn ("M4_GEN_BACKING_UP"); indent_puts ("}"); --indent_level; - } + indent_puts("]])"); - skelout (); /* %% [18.0] - break point in skel */ - skelout (); /* %% [19.0] - break point in skel */ skelout (); /* Copy remainder of input to output. */ -- cgit v1.2.1 From 9cfe5b9b09fdf6b4714113183c745d11a524902a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 10:50:07 -0400 Subject: All the M4_MODE settings now live in one place where they can be audited. No changes in generated code. #28 in the retargeting patch series --- src/gen.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 87 -------------------------------------------------------------- 2 files changed, 81 insertions(+), 87 deletions(-) diff --git a/src/gen.c b/src/gen.c index 9141c58..5b1bee4 100644 --- a/src/gen.c +++ b/src/gen.c @@ -896,6 +896,87 @@ void make_tables (void) int did_eof_rule = false; struct yytbl_data *yynultrans_tbl = NULL; + // These are used to conditionalize code in the lex skeleton + // that historically used to be generated by C code in flex + // itself; by shoving all this stuff out to the skeleton file + // we make it easier to retarget the code generation. + + // mode switches for yy_trans_info specification + if (fullspd) + out_m4_define( "M4_MODE_REAL_FULLSPD", NULL); + else + out_m4_define( "M4_MODE_NO_REAL_FULLSPD", NULL); + + // mode switches for next-action code + if (variable_trailing_context_rules) { + out_m4_define( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES", NULL); + } else { + out_m4_define( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES", NULL); + } + if (real_reject) + out_m4_define( "M4_MODE_REAL_REJECT", NULL); + if (reject_really_used) + out_m4_define( "M4_MODE_REJECT_REALLY_USED", NULL); + if (reject) + out_m4_define( "M4_MODE_USES_REJECT", NULL); + else + out_m4_define( "M4_MODE_NO_USES_REJECT", NULL); + + // mode switches for computing next compressed state + if (usemecs) + out_m4_define( "M4_MODE_USEMECS", NULL); + + // mode switches for find-action code + if (fullspd) + out_m4_define( "M4_MODE_FULLSPD", NULL); + else if (fulltbl) + out_m4_define( "M4_MODE_FULLTBL", NULL); + else if (reject) + out_m4_define( "M4_MODE_REJECT", NULL); + else + out_m4_define( "M4_MODE_COMPRESSED", NULL); + + // mode switches for backup generation and gen_start_state + if (!fullspd) + out_m4_define( "M4_MODE_NO_FULLSPD", NULL); + if (bol_needed) + out_m4_define( "M4_MODE_BOL_NEEDED", NULL); + else + out_m4_define( "M4_MODE_NO_BOL_NEEDED", NULL); + + // yylineno + if (do_yylineno) + out_m4_define( "M4_MODE_YYLINENO", NULL); + + // Equivalance classes + if (useecs) + out_m4_define( "M4_MODE_USEECS", NULL); + else + out_m4_define( "M4_NOT_MODE_USEECS", NULL); + + // mode switches for getting next action + if (gentables) + out_m4_define( "M4_MODE_GENTABLES", NULL); + else + out_m4_define( "M4_MODE_NO_GENTABLES", NULL); + if (interactive) + out_m4_define( "M4_MODE_INTERACTIVE", NULL); + else + out_m4_define( "M4_MODE_NO_INTERACTIVE", NULL); + if (!(fullspd || fulltbl)) + out_m4_define( "M4_MODE_NO_FULLSPD_OR_FULLTBL", NULL); + if (reject || interactive) + out_m4_define( "M4_MODE_REJECT_OR_INTERACTIVE", NULL); + + // nultrans + if (nultrans) + out_m4_define( "M4_MODE_NULTRANS", NULL); + else + out_m4_define( "M4_MODE_NO_NULTRANS", NULL); + + if (ddebug) + out_m4_define( "M4_MODE_DEBUG", NULL); + out_dec ("#define YY_NUM_RULES %d\n", num_rules); out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); diff --git a/src/main.c b/src/main.c index 5e63318..5fa53da 100644 --- a/src/main.c +++ b/src/main.c @@ -1411,93 +1411,6 @@ void readin (void) if (useecs) ccl2ecl (); - - // Set up macro conditionalization after all - // dependent flags have been computed. These - // are used to conditionalize code in the lex - // skeleton that historically used to be generated - // by C code in flex itself; by shoving all this - // stuff out to the skeleton file we make it easier - // to retarget the code generation. - - // mode switches for yy_trans_info specification - if (fullspd) - out_m4_define( "M4_MODE_REAL_FULLSPD", NULL); - else - out_m4_define( "M4_MODE_NO_REAL_FULLSPD", NULL); - - // mode switches for next-action code - if (variable_trailing_context_rules) { - out_m4_define( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES", NULL); - } else { - out_m4_define( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES", NULL); - } - if (real_reject) - out_m4_define( "M4_MODE_REAL_REJECT", NULL); - if (reject_really_used) - out_m4_define( "M4_MODE_REJECT_REALLY_USED", NULL); - if (reject) - out_m4_define( "M4_MODE_USES_REJECT", NULL); - else - out_m4_define( "M4_MODE_NO_USES_REJECT", NULL); - - // mode switches for computing next compressed state - if (usemecs) - out_m4_define( "M4_MODE_USEMECS", NULL); - - // mode switches for find-action code - if (fullspd) - out_m4_define( "M4_MODE_FULLSPD", NULL); - else if (fulltbl) - out_m4_define( "M4_MODE_FULLTBL", NULL); - else if (reject) - out_m4_define( "M4_MODE_REJECT", NULL); - else - out_m4_define( "M4_MODE_COMPRESSED", NULL); - - // mode switches for backup generation and gen_start_state - if (!fullspd) - out_m4_define( "M4_MODE_NO_FULLSPD", NULL); - if (bol_needed) - out_m4_define( "M4_MODE_BOL_NEEDED", NULL); - else - out_m4_define( "M4_MODE_NO_BOL_NEEDED", NULL); - - // yylineno - if (do_yylineno) - out_m4_define( "M4_MODE_YYLINENO", NULL); - - // Equivalance classes - if (useecs) - out_m4_define( "M4_MODE_USEECS", NULL); - else - out_m4_define( "M4_NOT_MODE_USEECS", NULL); - - // mode switches for getting next action - if (gentables) - out_m4_define( "M4_MODE_GENTABLES", NULL); - else - out_m4_define( "M4_MODE_NO_GENTABLES", NULL); - if (interactive) - out_m4_define( "M4_MODE_INTERACTIVE", NULL); - else - out_m4_define( "M4_MODE_NO_INTERACTIVE", NULL); - if (!(fullspd || fulltbl)) - out_m4_define( "M4_MODE_NO_FULLSPD_OR_FULLTBL", NULL); - if (reject || interactive) - out_m4_define( "M4_MODE_REJECT_OR_INTERACTIVE", NULL); - - // nultrans - if (nultrans) - out_m4_define( "M4_MODE_NULTRANS", NULL); - else - out_m4_define( "M4_MODE_NO_NULTRANS", NULL); - - if (ddebug) - out_m4_define( "M4_MODE_DEBUG", NULL); - - // A few additional mode switches cannot be computed - // until we know whether the automaton has backing-up actions. } /* set_up_initial_allocations - allocate memory for internal tables */ -- cgit v1.2.1 From d694cb8d3f0305b3807cf1895dc08bf25353b72c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 11:24:11 -0400 Subject: Push C-generated code for YYINPUT to the m4 skeleton. Diffs in generated code are trivial, a couple of blank lines with continuations due to % directives. #29 in the retargeting patch series --- src/cpp-flex.skl | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/gen.c | 53 ++++++----------------------------------------------- 2 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 064974f..32e20c9 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1071,6 +1071,50 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ +%if-c-only \ +m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ \ + errno=0; \ + while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + }\ +]]) \ +m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +]]) \ +%endif \ %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ \ %if-c++-only C++ definition \ diff --git a/src/gen.c b/src/gen.c index 5b1bee4..1c5606d 100644 --- a/src/gen.c +++ b/src/gen.c @@ -907,6 +907,12 @@ void make_tables (void) else out_m4_define( "M4_MODE_NO_REAL_FULLSPD", NULL); + // niode switches for YYINPUT code generation + if (use_read) + out_m4_define( "M4_MODE_CPP_USE_READ", NULL); + else + out_m4_define( "M4_MODE_NO_CPP_USE_READ", NULL); + // mode switches for next-action code if (variable_trailing_context_rules) { out_m4_define( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES", NULL); @@ -1312,53 +1318,6 @@ void make_tables (void) line_directive_out (stdout, 0); skelout (); /* %% [5.0] - break point in skel */ - - if (!C_plus_plus) { - if (use_read) { - outn ("\terrno=0; \\"); - outn ("\twhile ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) \\"); - outn ("\t{ \\"); - outn ("\t\tif( errno != EINTR) \\"); - outn ("\t\t{ \\"); - outn ("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\"); - outn ("\t\t\tbreak; \\"); - outn ("\t\t} \\"); - outn ("\t\terrno=0; \\"); - outn ("\t\tclearerr(yyin); \\"); - outn ("\t}\\"); - } - - else { - outn ("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\"); - outn ("\t\t{ \\"); - outn ("\t\tint c = '*'; \\"); - outn ("\t\tint n; \\"); - outn ("\t\tfor ( n = 0; n < max_size && \\"); - outn ("\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\"); - outn ("\t\t\tbuf[n] = (char) c; \\"); - outn ("\t\tif ( c == '\\n' ) \\"); - outn ("\t\t\tbuf[n++] = (char) c; \\"); - outn ("\t\tif ( c == EOF && ferror( yyin ) ) \\"); - outn ("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\"); - outn ("\t\tresult = n; \\"); - outn ("\t\t} \\"); - outn ("\telse \\"); - outn ("\t\t{ \\"); - outn ("\t\terrno=0; \\"); - outn ("\t\twhile ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \\"); - outn ("\t\t\t{ \\"); - outn ("\t\t\tif( errno != EINTR) \\"); - outn ("\t\t\t\t{ \\"); - outn ("\t\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\"); - outn ("\t\t\t\tbreak; \\"); - outn ("\t\t\t\t} \\"); - outn ("\t\t\terrno=0; \\"); - outn ("\t\t\tclearerr(yyin); \\"); - outn ("\t\t\t} \\"); - outn ("\t\t}\\"); - } - } - skelout (); /* %% [6.0] - break point in skel */ skelout (); /* %% [7.0] - break point in skel */ -- cgit v1.2.1 From 2eb82096a4841e220759eed80f3eff1e95a082fa Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 12:34:11 -0400 Subject: Move code generation of YY_DO_BEFORE_ACTION to m4. Generated-code diffs are blank lines with ] continuations and shifted %% commends made by skel breakpoint directives. I could garbage collect those, but I plan to do that all at once in a commit of its own for clarity's sake. #30 in the retargeting patch series --- src/cpp-flex.skl | 20 ++++++++++-- src/gen.c | 96 +++++++++++++++++++------------------------------------- 2 files changed, 51 insertions(+), 65 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 32e20c9..0e75dd1 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -705,11 +705,27 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], */ #define YY_DO_BEFORE_ACTION \ YY_G(yytext_ptr) = yy_bp; \ -%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[YY_G(yytext_ptr) -= YY_G(yy_more_len); + yyleng = (int) (yy_cp - YY_G(yytext_ptr));]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ YY_G(yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ -%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyleng >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyleng += YY_G(yy_more_offset);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[YY_G(yy_prev_more_offset) = YY_G(yy_more_offset);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[YY_G(yy_more_offset) = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG);]]) \ +]]) \ YY_G(yy_c_buf_p) = yy_cp; + +%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ +%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ %% [4.0] data tables for the DFA and the user's section 1 definitions go here ]]) diff --git a/src/gen.c b/src/gen.c index 1c5606d..3e120cf 100644 --- a/src/gen.c +++ b/src/gen.c @@ -901,6 +901,16 @@ void make_tables (void) // itself; by shoving all this stuff out to the skeleton file // we make it easier to retarget the code generation. + // mode switches for YY_DO_BEFORE_ACTION code generation + if (yytext_is_array) + out_m4_define( "M4_MODE_YYTEXT_IS_ARRAY", NULL); + else + out_m4_define( "M4_MODE_NO_YYTEXT_IS_ARRAY", NULL); + if (yymore_used) + out_m4_define( "M4_MODE_YYMORE_USED", NULL); + else + out_m4_define( "M4_MODE_NO_YYMORE_USED", NULL); + // mode switches for yy_trans_info specification if (fullspd) out_m4_define( "M4_MODE_REAL_FULLSPD", NULL); @@ -997,55 +1007,12 @@ void make_tables (void) fprintf (stdout, backend->string_define_fmt, "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1)); skelout (); /* %% [2.0] - break point in skel */ - - /* First, take care of YY_DO_BEFORE_ACTION depending on yymore - * being used. - */ - set_indent (1); - - if (yymore_used && !yytext_is_array) { - indent_puts ("YY_G(yytext_ptr) -= YY_G(yy_more_len); \\"); - indent_puts - ("yyleng = (int) (yy_cp - YY_G(yytext_ptr)); \\"); - } - - else - indent_puts ("yyleng = (int) (yy_cp - yy_bp); \\"); - - /* Now also deal with copying yytext_ptr to yytext if needed. */ skelout (); /* %% [3.0] - break point in skel */ - if (yytext_is_array) { - if (yymore_used) - indent_puts - ("if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \\"); - else - indent_puts ("if ( yyleng >= YYLMAX ) \\"); - - ++indent_level; - indent_puts - ("YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\"); - --indent_level; - - if (yymore_used) { - indent_puts - ("yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\"); - indent_puts ("yyleng += YY_G(yy_more_offset); \\"); - indent_puts - ("YY_G(yy_prev_more_offset) = YY_G(yy_more_offset); \\"); - indent_puts ("YY_G(yy_more_offset) = 0; \\"); - } - else { - indent_puts - ("yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\"); - } - } - - set_indent (0); - skelout (); /* %% [4.0] - break point in skel */ /* This is where we REALLY begin generating the tables. */ + set_indent (0); if (fullspd) { genctbl (); if (tablesext) { @@ -1129,19 +1096,6 @@ void make_tables (void) } } - /* Definitions for backing up. We don't need them if REJECT - * is being used because then we use an alternative backing-up - * technique instead. - */ - if (num_backing_up > 0 && !reject) { - if (!C_plus_plus && !reentrant) { - indent_puts - ("static yy_state_type yy_last_accepting_state;"); - indent_puts - ("static char *yy_last_accepting_cpos;\n"); - } - } - if (nultrans) { flex_int32_t *yynultrans_data = 0; @@ -1160,6 +1114,7 @@ void make_tables (void) for (i = 1; i <= lastdfa; ++i) { if (fullspd) { + // FIXME: dubious - pretty C-specific out_dec (" &yy_transition[%d],\n", base[i]); yynultrans_data[i] = base[i]; @@ -1187,12 +1142,6 @@ void make_tables (void) /* End generating yy_NUL_trans */ } - if (!C_plus_plus && !reentrant) { - indent_puts ("extern int yy_flex_debug;"); - indent_put2s ("int yy_flex_debug = %s;\n", - ddebug ? "1" : "0"); - } - if (ddebug) { /* Spit out table mapping rules to line numbers. */ out_str_dec (long_align ? backend->get_int32_decl () : backend->get_int16_decl (), "yy_rule_linenum", @@ -1202,6 +1151,27 @@ void make_tables (void) dataend (); } + // Remaining language dependencies begin here + + /* Definitions for backing up. We don't need them if REJECT + * is being used because then we use an alternative backing-up + * technique instead. + */ + if (num_backing_up > 0 && !reject) { + if (!C_plus_plus && !reentrant) { + indent_puts + ("static yy_state_type yy_last_accepting_state;"); + indent_puts + ("static char *yy_last_accepting_cpos;\n"); + } + } + + if (!C_plus_plus && !reentrant) { + indent_puts ("extern int yy_flex_debug;"); + indent_put2s ("int yy_flex_debug = %s;\n", + ddebug ? "1" : "0"); + } + if (reject) { outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); /* Declare state buffer variables. */ -- cgit v1.2.1 From d45bd0692ed6c4c6c52ca9e31589075f86624f40 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 17:18:28 -0400 Subject: Code formerly generated at skel breakpoint 8.0 goes to m4. No generated-code diffs from this change. #31 in the retargeting patch series --- src/cpp-flex.skl | 10 ++++++++++ src/gen.c | 15 --------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 0e75dd1..b033ae4 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1445,6 +1445,16 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { +m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ + YY_G(yy_more_len) = 0; + if ( YY_G(yy_more_flag) ) + { + YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); + YY_G(yy_more_flag) = 0; + } +]]) +]]) %% [8.0] yymore()-related code goes here yy_cp = YY_G(yy_c_buf_p); diff --git a/src/gen.c b/src/gen.c index 3e120cf..47bdee8 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1297,21 +1297,6 @@ void make_tables (void) line_directive_out (stdout, 0); skelout (); /* %% [8.0] - break point in skel */ - - set_indent (2); - - if (yymore_used && !yytext_is_array) { - indent_puts ("YY_G(yy_more_len) = 0;"); - indent_puts ("if ( YY_G(yy_more_flag) )"); - ++indent_level; - indent_puts ("{"); - indent_puts - ("YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr));"); - indent_puts ("YY_G(yy_more_flag) = 0;"); - indent_puts ("}"); - --indent_level; - } - skelout (); /* %% [9.0] - break point in skel */ skelout (); /* %% [10.0] - break point in skel */ skelout (); /* %% [11.0] - break point in skel */ -- cgit v1.2.1 From ca94d99782c1b2b0ac27c56b74d997e0906fc133 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 18:25:08 -0400 Subject: m4ize code generation associated with skel breakpoint 11.0. Moves one table initializer in the generated code, but doesn't alter it. Leaves one FIXME. The computation of M4_YYL_BASE really ought to be done in m4, but for some unknown reason I couldn't beat it into dping the right thing. Do be revisited, bu right now finishing off the last bits of code generation is more important. #32 in the retargeting patch series --- src/cpp-flex.skl | 12 ++++++++++++ src/gen.c | 26 ++++---------------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index b033ae4..707e013 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1582,6 +1582,18 @@ m4_ifdef([[M4_MODE_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; YY_DO_BEFORE_ACTION; +m4_ifdef( [[M4_YY_USE_LINENO]],[[ +m4_ifdef( [[M4_MODE_YYMORE_USED]],[[ +]]) + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + M4_YY_INCR_LINENO(); + } +]]) + %% [11.0] code for yylineno update goes here do_action: /* This label is used only to access EOF actions. */ diff --git a/src/gen.c b/src/gen.c index 47bdee8..b22d5c2 100644 --- a/src/gen.c +++ b/src/gen.c @@ -993,6 +993,10 @@ void make_tables (void) if (ddebug) out_m4_define( "M4_MODE_DEBUG", NULL); + // FIXME: This probaby should be done in pure m4 + out_m4_define("M4_YYL_BASE", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : + "YY_G(yy_more_len)") : "0"); + out_dec ("#define YY_NUM_RULES %d\n", num_rules); out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); @@ -1300,28 +1304,6 @@ void make_tables (void) skelout (); /* %% [9.0] - break point in skel */ skelout (); /* %% [10.0] - break point in skel */ skelout (); /* %% [11.0] - break point in skel */ - - set_indent (2); - outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); - indent_puts - ("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )"); - ++indent_level; - indent_puts ("{"); - indent_puts ("int yyl;"); - do_indent (); - out_str ("for ( yyl = %s; yyl < yyleng; ++yyl )\n", - yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : - "YY_G(yy_more_len)") : "0"); - ++indent_level; - indent_puts ("if ( yytext[yyl] == '\\n' )"); - ++indent_level; - indent_puts ("M4_YY_INCR_LINENO();"); - --indent_level; - --indent_level; - indent_puts ("}"); - --indent_level; - outn ("]])"); - skelout (); /* %% [12.0] - break point in skel */ /* Copy actions to output file. */ -- cgit v1.2.1 From c9ade3f92bb952da5fac35f474f445d84dc18bd1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 19:49:31 -0400 Subject: Methodize whether fullspd mode can use a pointer table. Presently only C can do this. Otherwise we fall through to storing numeric indices for a tiny loss of performance. No generated-code changes from this. #33 in the retargeting patch series --- src/cpp_backend.c | 3 ++- src/flexdef.h | 1 + src/gen.c | 9 ++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index c868749..5c208f7 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -627,5 +627,6 @@ struct flex_backend_t cpp_backend = { .trans_offset_type = cpp_trans_offset_type, .caseprefix = "case ", .fallthrough = NULL, - .endcase = "yyterminate();" + .endcase = "yyterminate();", + .c_like = 1, }; diff --git a/src/flexdef.h b/src/flexdef.h index 6bed71d..f8575a6 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -345,6 +345,7 @@ struct flex_backend_t { char *caseprefix; // Prefix of an arm in the language's case construct char *fallthrough; // Finish a case arm with this to fall through char *endcase; // What to ship after all EOF-state case arms + int c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; extern bool gentables; diff --git a/src/gen.c b/src/gen.c index b22d5c2..e5a8db4 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1109,7 +1109,9 @@ void make_tables (void) backend->nultrans(fullspd); yynultrans_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); - if (fullspd) + // Performance kludge for C. Gives a small improvement + // in table loading time. + if (fullspd && backend->c_like) yynultrans_tbl->td_flags |= YYTD_PTRANS; yynultrans_tbl->td_lolen = (flex_uint32_t) (lastdfa + 1); yynultrans_tbl->td_data = yynultrans_data = @@ -1117,13 +1119,14 @@ void make_tables (void) sizeof (flex_int32_t)); for (i = 1; i <= lastdfa; ++i) { - if (fullspd) { - // FIXME: dubious - pretty C-specific + if ((yynultrans_tbl->td_flags & YYTD_PTRANS) != 0) { + // Only works in very C-like languages out_dec (" &yy_transition[%d],\n", base[i]); yynultrans_data[i] = base[i]; } else { + // This will work anywhere mkdata (nultrans[i]); yynultrans_data[i] = nultrans[i]; } -- cgit v1.2.1 From 5cb26ac3f98c1e72cc3785a929e7b2ce00dd3bbe Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 23 Sep 2020 22:06:32 -0400 Subject: Conditionalization of the debug flag moves to m4. Turned out to be mildly trick because %if/%endif pairs have push/pop behavior rather than combining. In generated code, the location of the debug declarations moves, and that's all. #34 in the retargeting patch series --- src/cpp-flex.skl | 8 ++++++++ src/flexdef.h | 2 ++ src/gen.c | 17 +++++++++++------ src/main.c | 2 -- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 707e013..b3838b1 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -724,6 +724,14 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ ]]) \ YY_G(yy_c_buf_p) = yy_cp; +%if-not-reentrant +m4_ifdef( [[M4_MODE_C_ONLY]], +[[ +extern int yy_flex_debug; +int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]])m4_ifdef([[M4_MODE_NO_DEBUG]],[[1]]); +]]) +%endif + %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ %% [4.0] data tables for the DFA and the user's section 1 definitions go here diff --git a/src/flexdef.h b/src/flexdef.h index f8575a6..15250b6 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -350,6 +350,8 @@ struct flex_backend_t { extern bool gentables; +extern struct flex_backend_t cpp_backend; + /* Declarations for global variables. */ diff --git a/src/gen.c b/src/gen.c index e5a8db4..e3de32e 100644 --- a/src/gen.c +++ b/src/gen.c @@ -992,11 +992,22 @@ void make_tables (void) if (ddebug) out_m4_define( "M4_MODE_DEBUG", NULL); + else + out_m4_define( "M4_MODE_NO_DEBUG", NULL); + + // Kluge to get around the fact that the %if-not-reentrant and + // %if-c-only gates can;t be combined by nesting one inside the + // other. + if (backend == &cpp_backend && !C_plus_plus) + out_m4_define( "M4_MODE_C_ONLY", NULL); // FIXME: This probaby should be done in pure m4 out_m4_define("M4_YYL_BASE", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : "YY_G(yy_more_len)") : "0"); + // There are a couple more modes we can't compute until after + // tables have been generated. + out_dec ("#define YY_NUM_RULES %d\n", num_rules); out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); @@ -1173,12 +1184,6 @@ void make_tables (void) } } - if (!C_plus_plus && !reentrant) { - indent_puts ("extern int yy_flex_debug;"); - indent_put2s ("int yy_flex_debug = %s;\n", - ddebug ? "1" : "0"); - } - if (reject) { outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); /* Declare state buffer variables. */ diff --git a/src/main.c b/src/main.c index 5fa53da..2ba677b 100644 --- a/src/main.c +++ b/src/main.c @@ -46,8 +46,6 @@ void flexinit(int, char **); void readin(void); void set_up_initial_allocations(void); -extern struct flex_backend_t cpp_backend; - /* these globals are all defined and commented in flexdef.h */ int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; int interactive, lex_compat, posix_compat, do_yylineno, -- cgit v1.2.1 From d7cb3bf631ae1197359f4ce698c73763a5b5ac46 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 24 Sep 2020 05:14:05 -0400 Subject: Dump the state of the m4 conditionals near start of generated code. Of course, this produces exactly that in diffs. #35 in the retargeting patch series --- src/cpp_backend.c | 6 ++++ src/flexdef.h | 1 + src/gen.c | 98 ++++++++++++++++++++++++++++++++----------------------- 3 files changed, 64 insertions(+), 41 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 5c208f7..ad46b0d 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -388,6 +388,11 @@ static const char *cpp_yy_int_aligned(void) return long_align ? "long int" : "short int"; } +static void cpp_comment(const char *txt) +{ + out_str("/* [[%s]] */\n", txt); +} + static const char *cpp_get_int16_decl (void) { return (gentables) @@ -602,6 +607,7 @@ struct flex_backend_t cpp_backend = { .table_opener = " {", .table_continuation = " },\n", .table_closer = " };\n", + .comment = cpp_comment, .get_int16_decl = cpp_get_int16_decl, .get_int32_decl = cpp_get_int32_decl, .get_state_decl = cpp_get_state_decl, diff --git a/src/flexdef.h b/src/flexdef.h index 15250b6..84365b9 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -318,6 +318,7 @@ struct flex_backend_t { char *table_opener; // Open an array initializer with this char *table_continuation; // Open an array initializer with this char *table_closer; // How to continue a two-level initializer + void (*comment)(const char *); // Wrap a comment line const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s const char *(*get_int32_decl)(void); // Format for declaring array initializer of int32s const char *(*get_state_decl)(void); // Format for declaring array initializer of state values diff --git a/src/gen.c b/src/gen.c index e3de32e..15f00c6 100644 --- a/src/gen.c +++ b/src/gen.c @@ -887,6 +887,12 @@ void indent_puts (const char *str) } +static void visible_define (const char *symname) +{ + out_m4_define(symname, NULL); + backend->comment(symname); +} + /* make_tables - generate transition tables and finishes generating output file */ @@ -901,108 +907,113 @@ void make_tables (void) // itself; by shoving all this stuff out to the skeleton file // we make it easier to retarget the code generation. + backend->comment("m4 controls begin"); + // mode switches for YY_DO_BEFORE_ACTION code generation if (yytext_is_array) - out_m4_define( "M4_MODE_YYTEXT_IS_ARRAY", NULL); + visible_define ( "M4_MODE_YYTEXT_IS_ARRAY"); else - out_m4_define( "M4_MODE_NO_YYTEXT_IS_ARRAY", NULL); + visible_define ( "M4_MODE_NO_YYTEXT_IS_ARRAY"); if (yymore_used) - out_m4_define( "M4_MODE_YYMORE_USED", NULL); + visible_define ( "M4_MODE_YYMORE_USED"); else - out_m4_define( "M4_MODE_NO_YYMORE_USED", NULL); + visible_define ( "M4_MODE_NO_YYMORE_USED"); // mode switches for yy_trans_info specification if (fullspd) - out_m4_define( "M4_MODE_REAL_FULLSPD", NULL); + visible_define ( "M4_MODE_REAL_FULLSPD"); else - out_m4_define( "M4_MODE_NO_REAL_FULLSPD", NULL); + visible_define ( "M4_MODE_NO_REAL_FULLSPD"); // niode switches for YYINPUT code generation if (use_read) - out_m4_define( "M4_MODE_CPP_USE_READ", NULL); + visible_define ( "M4_MODE_CPP_USE_READ"); else - out_m4_define( "M4_MODE_NO_CPP_USE_READ", NULL); + visible_define ( "M4_MODE_NO_CPP_USE_READ"); // mode switches for next-action code if (variable_trailing_context_rules) { - out_m4_define( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES", NULL); + visible_define ( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES"); } else { - out_m4_define( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES", NULL); + visible_define ( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES"); } if (real_reject) - out_m4_define( "M4_MODE_REAL_REJECT", NULL); + visible_define ( "M4_MODE_REAL_REJECT"); if (reject_really_used) - out_m4_define( "M4_MODE_REJECT_REALLY_USED", NULL); + visible_define ( "M4_MODE_REJECT_REALLY_USED"); if (reject) - out_m4_define( "M4_MODE_USES_REJECT", NULL); + visible_define ( "M4_MODE_USES_REJECT"); else - out_m4_define( "M4_MODE_NO_USES_REJECT", NULL); + visible_define ( "M4_MODE_NO_USES_REJECT"); // mode switches for computing next compressed state if (usemecs) - out_m4_define( "M4_MODE_USEMECS", NULL); + visible_define ( "M4_MODE_USEMECS"); // mode switches for find-action code if (fullspd) - out_m4_define( "M4_MODE_FULLSPD", NULL); + visible_define ( "M4_MODE_FULLSPD"); else if (fulltbl) - out_m4_define( "M4_MODE_FULLTBL", NULL); + visible_define ( "M4_MODE_FULLTBL"); else if (reject) - out_m4_define( "M4_MODE_REJECT", NULL); + visible_define ( "M4_MODE_REJECT"); else - out_m4_define( "M4_MODE_COMPRESSED", NULL); + visible_define ( "M4_MODE_COMPRESSED"); // mode switches for backup generation and gen_start_state if (!fullspd) - out_m4_define( "M4_MODE_NO_FULLSPD", NULL); + visible_define ( "M4_MODE_NO_FULLSPD"); if (bol_needed) - out_m4_define( "M4_MODE_BOL_NEEDED", NULL); + visible_define ( "M4_MODE_BOL_NEEDED"); else - out_m4_define( "M4_MODE_NO_BOL_NEEDED", NULL); + visible_define ( "M4_MODE_NO_BOL_NEEDED"); // yylineno if (do_yylineno) - out_m4_define( "M4_MODE_YYLINENO", NULL); + visible_define ( "M4_MODE_YYLINENO"); - // Equivalance classes + // Equivelance classes if (useecs) - out_m4_define( "M4_MODE_USEECS", NULL); + visible_define ( "M4_MODE_USEECS"); else - out_m4_define( "M4_NOT_MODE_USEECS", NULL); + visible_define ( "M4_NOT_MODE_USEECS"); // mode switches for getting next action if (gentables) - out_m4_define( "M4_MODE_GENTABLES", NULL); + visible_define ( "M4_MODE_GENTABLES"); else - out_m4_define( "M4_MODE_NO_GENTABLES", NULL); + visible_define ( "M4_MODE_NO_GENTABLES"); if (interactive) - out_m4_define( "M4_MODE_INTERACTIVE", NULL); + visible_define ( "M4_MODE_INTERACTIVE"); else - out_m4_define( "M4_MODE_NO_INTERACTIVE", NULL); + visible_define ( "M4_MODE_NO_INTERACTIVE"); if (!(fullspd || fulltbl)) - out_m4_define( "M4_MODE_NO_FULLSPD_OR_FULLTBL", NULL); + visible_define ( "M4_MODE_NO_FULLSPD_OR_FULLTBL"); if (reject || interactive) - out_m4_define( "M4_MODE_REJECT_OR_INTERACTIVE", NULL); + visible_define ( "M4_MODE_REJECT_OR_INTERACTIVE"); // nultrans if (nultrans) - out_m4_define( "M4_MODE_NULTRANS", NULL); + visible_define ( "M4_MODE_NULTRANS"); else - out_m4_define( "M4_MODE_NO_NULTRANS", NULL); + visible_define ( "M4_MODE_NO_NULTRANS"); if (ddebug) - out_m4_define( "M4_MODE_DEBUG", NULL); + visible_define ( "M4_MODE_DEBUG"); else - out_m4_define( "M4_MODE_NO_DEBUG", NULL); + visible_define ( "M4_MODE_NO_DEBUG"); // Kluge to get around the fact that the %if-not-reentrant and // %if-c-only gates can;t be combined by nesting one inside the // other. if (backend == &cpp_backend && !C_plus_plus) - out_m4_define( "M4_MODE_C_ONLY", NULL); + visible_define ( "M4_MODE_C_ONLY"); + + backend->comment("m4 controls end"); + out ("\n"); // FIXME: This probaby should be done in pure m4 - out_m4_define("M4_YYL_BASE", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : + out_m4_define ("M4_YYL_BASE", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : "YY_G(yy_more_len)") : "0"); // There are a couple more modes we can't compute until after @@ -1086,14 +1097,19 @@ void make_tables (void) // Only at this point do we know if the automaton has backups. // Some m4 conditionals require this information. + backend->comment("m4 controls begin"); + if (num_backing_up > 0) - out_m4_define( "M4_MODE_HAS_BACKING_UP", NULL); + visible_define ( "M4_MODE_HAS_BACKING_UP"); // These are used for NUL transitions if ((num_backing_up > 0 && !reject) && (!nultrans || fullspd || fulltbl)) - out_m4_define( "M4_MODE_NEED_YY_CP", NULL); + visible_define ( "M4_MODE_NEED_YY_CP"); if ((num_backing_up > 0 && !reject) && (fullspd || fulltbl)) - out_m4_define( "M4_MODE_NULTRANS_WRAP", NULL); + visible_define ( "M4_MODE_NULTRANS_WRAP"); + + backend->comment("m4 controls end"); + out ("\n"); if (do_yylineno) { -- cgit v1.2.1 From 31b751703fa3589dab34ff3ed93c3f3074ff8bf4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 24 Sep 2020 05:44:31 -0400 Subject: Chase down some methodization details missed earlier. No generated-code diffs from this change. #36 in the retargeting patch series --- src/backend.adoc | 7 ++++++- src/cpp_backend.c | 1 + src/dfa.c | 4 +--- src/flexdef.h | 1 + src/gen.c | 2 +- src/misc.c | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/backend.adoc b/src/backend.adoc index e8d8323..f1876d3 100644 --- a/src/backend.adoc +++ b/src/backend.adoc @@ -82,8 +82,13 @@ require fixes outside a back end. there is an explicit fallthrough keyword that enables this, as in Go. +3. The item separator in data initializers is a comma. + By putting a yyterminate() call in the fallthrough member and a null pointer in the endcase member, you could handle -languages like Pascal +languages like Pascal. + +// end + diff --git a/src/cpp_backend.c b/src/cpp_backend.c index ad46b0d..96e4894 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -607,6 +607,7 @@ struct flex_backend_t cpp_backend = { .table_opener = " {", .table_continuation = " },\n", .table_closer = " };\n", + .dyad = " {%4d,%4d },", .comment = cpp_comment, .get_int16_decl = cpp_get_int16_decl, .get_int32_decl = cpp_get_int32_decl, diff --git a/src/dfa.c b/src/dfa.c index 2dc324c..83ff70a 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -683,10 +683,8 @@ void ntod (void) yynxt_tbl->td_hilen * yynxt_tbl->td_lolen * sizeof (flex_int32_t)); - - if (gentables) - outn (" {"); + outn (backend->table_opener); /* Supply array's 0-element. */ if (ds == end_of_buffer_state) { diff --git a/src/flexdef.h b/src/flexdef.h index 84365b9..b3468ea 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -318,6 +318,7 @@ struct flex_backend_t { char *table_opener; // Open an array initializer with this char *table_continuation; // Open an array initializer with this char *table_closer; // How to continue a two-level initializer + char *dyad; // How to format and int[2] initializer void (*comment)(const char *); // Wrap a comment line const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s const char *(*get_int32_decl)(void); // Format for declaring array initializer of int32s diff --git a/src/gen.c b/src/gen.c index 15f00c6..130581a 100644 --- a/src/gen.c +++ b/src/gen.c @@ -106,7 +106,7 @@ static void geneoltbl (void) if ((i % 20) == 19) out ("\n "); } - out (" };\n"); + outn (backend->table_closer); } outn ("]])"); } diff --git a/src/misc.c b/src/misc.c index 6ee1e5a..97bc83e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -827,7 +827,7 @@ void transition_struct_out (int element_v, int element_n) if (!gentables) return; - out_dec2 (" {%4d,%4d },", element_v, element_n); + out_dec2 (backend->dyad, element_v, element_n); datapos += TRANS_STRUCT_PRINT_LENGTH; -- cgit v1.2.1 From efeb6ef019c221dfb725bb5ad83ac5556dd94c68 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 24 Sep 2020 13:59:17 -0400 Subject: m4ize the code for handling NUL transitions. Finally, scavenge trailing skel breakpoints that are no longer used, as theey no longer carry information. Diffs in generated code are all comments and whitesoace, as usual #37 in the retargeting patch series --- src/cpp-flex.skl | 92 +++++++++++++++++++++++++++++++++++++++--------- src/gen.c | 104 ++++++++++--------------------------------------------- 2 files changed, 94 insertions(+), 102 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index b3838b1..c919b81 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -651,7 +651,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) ]]) -%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here +%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. definitions & init go here m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -1480,7 +1480,7 @@ yy_match: %% [9.0] code to set up and find next match goes here /* Generate the code to find the next match. */ -m4_ifdef([[M4_MODE_FULLTBL]], [[ +m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ m4_ifdef([[M4_MODE_GENTABLES]], [[ while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { ]]) @@ -1522,11 +1522,11 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ yy_find_action: %% [10.0] code to find the action number goes here m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) - m4_ifdef([[M4_MODE_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) -m4_ifdef([[M4_MODE_REJECT]], [[ + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ yy_current_state = *--YY_G(yy_state_ptr); YY_G(yy_lp) = yy_accept[yy_current_state]; -m4_ifdef([[M4_MODE_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) for ( ; ; ) { /* loop until we find out what rule we matched */ if (YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1]) { yy_act = yy_acclist[YY_G(yy_lp)]; @@ -1579,7 +1579,7 @@ m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ YY_G(yy_lp) = yy_accept[yy_current_state]; } ]]) -m4_ifdef([[M4_MODE_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; +m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = YY_G(yy_last_accepting_cpos); @@ -1666,7 +1666,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* *\/ */ yy_cp = YY_G(yy_last_accepting_cpos); m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) - m4_ifdef([[M4_MODE_FULLTBL]], [[yy_cp++;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) yy_current_state = YY_G(yy_last_accepting_state); goto yy_find_action; @@ -1742,9 +1742,9 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ else { -%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here +%# Disguised case statement on table modes m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = YY_G(yy_c_buf_p);]]) - m4_ifdef([[M4_MODE_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ @@ -1755,7 +1755,8 @@ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ yy_current_state = YY_G(yy_last_accepting_state); ]]) ]]) -m4_ifdef([[M4_MODE_REJECT_OR_INTERACTIVE]], [[ +%# Disguised case statement on table modes ends +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ /* Still need to initialize yy_cp, though * yy_current_state was set up by * yy_get_previous_state(). @@ -2132,11 +2133,8 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], M4_YY_DECL_GUTS_VAR(); M4_GEN_START_STATE -%% [15.0] code to get the start state into yy_current_state goes here - for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) { -%% [16.0] code to find the next state goes here /* Generate the code to find the next state. */ m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) @@ -2147,7 +2145,7 @@ M4_GEN_START_STATE if ( *yy_cp ) { ]]) - m4_ifdef([[M4_MODE_FULLTBL]], [[ + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) ]]) @@ -2161,7 +2159,7 @@ M4_GEN_START_STATE } ]]) - m4_ifdef([[M4_MODE_FULLTBL]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) } @@ -2184,7 +2182,69 @@ M4_GEN_START_STATE { int yy_is_jam; M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ -%% [17.0] code to find the next state, and perhaps do backing up, goes here + /* Generate code for handling NUL's, if needed. */ + + /* First, deal with backing up and setting up yy_cp if the scanner + * finds that it should JAM on the NUL. + * + * Only generate a definition for "yy_cp" if we'll generate code + * that uses it. Otherwise lint and the like complain. + */ + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = YY_G(yy_c_buf_p);]]) + +%# Note that this statement block and the following three are +%# not executed serially but are an if-then-else cascade +%# for different table modes. + m4_ifdef([[M4_MODE_NULTRANS]], [[ + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); + ]]) + + m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ + m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ + m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) + yy_is_jam = (yy_current_state <= 0); + ]]) + + m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ + m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ + int yy_c = YY_NUL_EC; + + const struct yy_trans_info *yy_trans_info; + + yy_trans_info = &yy_current_state[(unsigned int) yy_c]; + yy_current_state += yy_trans_info->yy_nxt; + yy_is_jam = (yy_trans_info->yy_verify != yy_c); + ]]) + + m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ + M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) + yy_is_jam = (yy_current_state == YY_JAMSTATE); + m4_ifdef([[M4_MODE_USES_REJECT]], [[ + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + if ( ! yy_is_jam ) + *YY_G(yy_state_ptr)++ = yy_current_state; + ]]) + ]]) + ]]) + ]]) +%# End of if-else cascade + + /* If we've entered an accepting state, back up; note that + * compressed tables have *already* done such backing up, so + * we needn't bother with it again. + */ + m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ + + if ( ! yy_is_jam ) + { + M4_GEN_BACKING_UP + } + ]]) M4_YY_NOOP_GUTS_VAR(); return yy_is_jam ? 0 : yy_current_state; diff --git a/src/gen.c b/src/gen.c index 130581a..c47d6fe 100644 --- a/src/gen.c +++ b/src/gen.c @@ -940,7 +940,7 @@ void make_tables (void) if (real_reject) visible_define ( "M4_MODE_REAL_REJECT"); if (reject_really_used) - visible_define ( "M4_MODE_REJECT_REALLY_USED"); + visible_define ( "M4_MODE_FIND_ACTION_REJECT_REALLY_USED"); if (reject) visible_define ( "M4_MODE_USES_REJECT"); else @@ -954,11 +954,11 @@ void make_tables (void) if (fullspd) visible_define ( "M4_MODE_FULLSPD"); else if (fulltbl) - visible_define ( "M4_MODE_FULLTBL"); + visible_define ( "M4_MODE_FIND_ACTION_FULLTBL"); else if (reject) - visible_define ( "M4_MODE_REJECT"); + visible_define ( "M4_MODE_FIND_ACTION_REJECT"); else - visible_define ( "M4_MODE_COMPRESSED"); + visible_define ( "M4_MODE_FIND_ACTION_COMPRESSED"); // mode switches for backup generation and gen_start_state if (!fullspd) @@ -990,14 +990,23 @@ void make_tables (void) if (!(fullspd || fulltbl)) visible_define ( "M4_MODE_NO_FULLSPD_OR_FULLTBL"); if (reject || interactive) - visible_define ( "M4_MODE_REJECT_OR_INTERACTIVE"); + visible_define ( "M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE"); // nultrans if (nultrans) visible_define ( "M4_MODE_NULTRANS"); - else + else { visible_define ( "M4_MODE_NO_NULTRANS"); - + if (fulltbl) + visible_define ( "M4_MODE_NULTRANS_FULLTBL"); + else + visible_define ( "M4_MODE_NO_NULTRANS_FULLTBL"); + if (fullspd) + visible_define ( "M4_MODE_NULTRANS_FULLSPD"); + else + visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); + } + if (ddebug) visible_define ( "M4_MODE_DEBUG"); else @@ -1186,6 +1195,7 @@ void make_tables (void) } // Remaining language dependencies begin here + outn("// C-GENERATED BEGINS"); /* Definitions for backing up. We don't need them if REJECT * is being used because then we use an alternative backing-up @@ -1310,6 +1320,7 @@ void make_tables (void) outn ("char *yytext;"); } } + outn("// C-GENERATED ENDS"); out (&action_array[defs1_offset]); @@ -1354,85 +1365,6 @@ void make_tables (void) --indent_level; } - /* Generate code for handling NUL's, if needed. */ - - /* First, deal with backing up and setting up yy_cp if the scanner - * finds that it should JAM on the NUL. - */ - skelout (); /* %% [14.0] - break point in skel */ - skelout (); /* %% [15.0] - break point in skel */ - skelout (); /* %% [16.0] - break point in skel */ - skelout (); /* %% [17.0] - break point in skel */ - - /* Generate the code to make a NUL transition. */ - - /* Only generate a definition for "yy_cp" if we'll generate code - * that uses it. Otherwise lint and the like complain. - */ - indent_puts ("m4_ifdef([[M4_MODE_NEED_YY_CP]], [[ char *yy_cp = YY_G(yy_c_buf_p);]])"); - - outc ('\n'); - - set_indent (1); - if (nultrans) { - indent_puts - ("yy_current_state = yy_NUL_trans[yy_current_state];"); - indent_puts ("yy_is_jam = (yy_current_state == 0);"); - } - - else if (fulltbl) { - do_indent (); - outn ("m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]])"); - outn ("m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]])"); - indent_puts ("yy_is_jam = (yy_current_state <= 0);"); - } - - else if (fullspd) { - do_indent (); - outn ("int yy_c = YY_NUL_EC;"); - - indent_puts - ("const struct yy_trans_info *yy_trans_info;\n"); - indent_puts - ("yy_trans_info = &yy_current_state[(unsigned int) yy_c];"); - indent_puts ("yy_current_state += yy_trans_info->yy_nxt;"); - - indent_puts - ("yy_is_jam = (yy_trans_info->yy_verify != yy_c);"); - } - - else { - out ("M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC)"); - - indent_puts ("yy_is_jam = (yy_current_state == YY_JAMSTATE);"); - - indent_puts ("m4_ifdef([[M4_MODE_USES_REJECT]], [["); - /* Only stack this state if it's a transition we - * actually make. If we stack it on a jam, then - * the state stack and yy_c_buf_p get out of sync. - */ - indent_puts ("if ( ! yy_is_jam )"); - ++indent_level; - indent_puts - ("*YY_G(yy_state_ptr)++ = yy_current_state;"); - --indent_level; - indent_puts ("]])"); - } - - /* If we've entered an accepting state, back up; note that - * compressed tables have *already* done such backing up, so - * we needn't bother with it again. - */ - indent_puts ("m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [["); - outc ('\n'); - indent_puts ("if ( ! yy_is_jam )"); - ++indent_level; - indent_puts ("{"); - outn ("M4_GEN_BACKING_UP"); - indent_puts ("}"); - --indent_level; - indent_puts("]])"); - skelout (); /* Copy remainder of input to output. */ -- cgit v1.2.1 From 219db78e6aedaa3e31f2e3884988a074abaa9b44 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 24 Sep 2020 22:03:21 -0400 Subject: Last procedural-code generation in C goes to m4. Diffs are comments and whiespace, as usual. #38 in the retargeting patch series --- src/cpp-flex.skl | 113 +++++++++++++++++++++++++++++++++++++++++++++++ src/gen.c | 130 +------------------------------------------------------ 2 files changed, 115 insertions(+), 128 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index c919b81..da2f38d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -737,6 +737,119 @@ int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]])m4_ifdef([[M4_MODE_NO_DEBUG %% [4.0] data tables for the DFA and the user's section 1 definitions go here ]]) +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +/* Definitions for backing up. We don't need them if REJECT + * is being used because then we use an alternative backing-up + * technique instead. + */ +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +]]) +]]) +]]) + +m4_ifdef( [[M4_MODE_USES_REJECT]],[[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +/* Declare state buffer variables. */ +static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; +static char *yy_full_match; +static int yy_lp; +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ +static int yy_looking_for_trail_begin = 0; +static int yy_full_lp; +static int *yy_full_state; +%# These must match the values in the file flexdef.h +%# of the flex source code, otherwise havoc will ensue. +#define YY_TRAILING_MASK 0x2000 +#define YY_TRAILING_HEAD_MASK 0x4000 +]]) +]]) +]]) +#define REJECT \ +{ \ +*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \ +yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ +YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \ +YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \ +yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \ +]]) \ +++YY_G(yy_lp); \ +goto find_rule; \ +} +]]) +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +]]) + +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +static int yy_more_offset = 0; +static int yy_prev_more_offset = 0; +]]) +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +static int yy_more_flag = 0; +static int yy_more_len = 0; +]]) +]]) +]]) +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext M4_YY_CALL_LAST_ARG)) +#define YY_NEED_STRLEN +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET \ +{ \ +YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \ +yyleng -= YY_G(yy_more_offset); \ +} +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +#define yymore() (YY_G(yy_more_flag) = 1) +#define YY_MORE_ADJ YY_G(yy_more_len) +#define YY_RESTORE_YY_MORE_OFFSET +]]) +]]) + +m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +]]) + +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +#ifndef YYLMAX +#define YYLMAX 8192 +#endif + +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +char yytext[YYLMAX]; +char *yytext_ptr; +]]) +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +char *yytext; +]]) +]]) +]]) + +%% [4.1] static declarations conditional on mode switches go here +]]) + m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) M4_YY_SC_DEFS m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) diff --git a/src/gen.c b/src/gen.c index c47d6fe..8db0971 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1043,7 +1043,7 @@ void make_tables (void) skelout (); /* %% [2.0] - break point in skel */ skelout (); /* %% [3.0] - break point in skel */ - skelout (); /* %% [4.0] - break point in skel */ + skelout (); /* %% [4.0] - tables get dumped here */ /* This is where we REALLY begin generating the tables. */ @@ -1194,133 +1194,7 @@ void make_tables (void) dataend (); } - // Remaining language dependencies begin here - outn("// C-GENERATED BEGINS"); - - /* Definitions for backing up. We don't need them if REJECT - * is being used because then we use an alternative backing-up - * technique instead. - */ - if (num_backing_up > 0 && !reject) { - if (!C_plus_plus && !reentrant) { - indent_puts - ("static yy_state_type yy_last_accepting_state;"); - indent_puts - ("static char *yy_last_accepting_cpos;\n"); - } - } - - if (reject) { - outn ("m4_ifdef( [[M4_MODE_USES_REJECT]],\n[["); - /* Declare state buffer variables. */ - if (!C_plus_plus && !reentrant) { - outn ("static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;"); - outn ("static char *yy_full_match;"); - outn ("static int yy_lp;"); - } - - if (variable_trailing_context_rules) { - if (!C_plus_plus && !reentrant) { - outn ("static int yy_looking_for_trail_begin = 0;"); - outn ("static int yy_full_lp;"); - outn ("static int *yy_full_state;"); - } - - out_hex ("#define YY_TRAILING_MASK 0x%x\n", - (unsigned int) YY_TRAILING_MASK); - out_hex ("#define YY_TRAILING_HEAD_MASK 0x%x\n", - (unsigned int) YY_TRAILING_HEAD_MASK); - } - - outn ("#define REJECT \\"); - outn ("{ \\"); - outn ("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \\"); - outn ("yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \\"); - - if (variable_trailing_context_rules) { - outn ("YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \\"); - outn ("YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \\"); - outn ("yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \\"); - } - - outn ("++YY_G(yy_lp); \\"); - outn ("goto find_rule; \\"); - - outn ("}"); - outn ("]])\n"); - } - - else { - outn ("/* The intent behind this definition is that it'll catch"); - outn (" * any uses of REJECT which flex missed."); - outn (" */"); - outn ("#define REJECT reject_used_but_not_detected"); - } - - if (yymore_used) { - if (!C_plus_plus) { - if (yytext_is_array) { - if (!reentrant){ - indent_puts ("static int yy_more_offset = 0;"); - indent_puts ("static int yy_prev_more_offset = 0;"); - } - } - else if (!reentrant) { - indent_puts - ("static int yy_more_flag = 0;"); - indent_puts - ("static int yy_more_len = 0;"); - } - } - - if (yytext_is_array) { - indent_puts - ("#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext M4_YY_CALL_LAST_ARG))"); - indent_puts ("#define YY_NEED_STRLEN"); - indent_puts ("#define YY_MORE_ADJ 0"); - indent_puts - ("#define YY_RESTORE_YY_MORE_OFFSET \\"); - ++indent_level; - indent_puts ("{ \\"); - indent_puts - ("YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\"); - indent_puts ("yyleng -= YY_G(yy_more_offset); \\"); - indent_puts ("}"); - --indent_level; - } - else { - indent_puts - ("#define yymore() (YY_G(yy_more_flag) = 1)"); - indent_puts - ("#define YY_MORE_ADJ YY_G(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) { - if (yytext_is_array) { - outn ("#ifndef YYLMAX"); - outn ("#define YYLMAX 8192"); - outn ("#endif\n"); - if (!reentrant){ - outn ("char yytext[YYLMAX];"); - outn ("char *yytext_ptr;"); - } - } - - else { - if(! reentrant) - outn ("char *yytext;"); - } - } - outn("// C-GENERATED ENDS"); + skelout (); /* %% [4.1] - mode-dependent static declarations get dumped here */ out (&action_array[defs1_offset]); -- cgit v1.2.1 From 8521281aef33b47df7e372d16a495cec7f9a7e62 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 25 Sep 2020 15:40:03 -0400 Subject: indent_puts and friends go away, they're no longer needed. I did some indentation of the end-of-file case statements with tabs to make the generated code a bit more readable. So there are trivial whitespace diffs in generated code. #39 in the retargeting patch series --- src/gen.c | 65 ++++++--------------------------------------------------------- 1 file changed, 6 insertions(+), 59 deletions(-) diff --git a/src/gen.c b/src/gen.c index 8db0971..5cca3d3 100644 --- a/src/gen.c +++ b/src/gen.c @@ -39,35 +39,6 @@ void genecs(void); - -static int indent_level = 0; /* each level is 8 spaces */ - -#define set_indent(indent_val) indent_level = indent_val - -/* Almost everything is done in terms of arrays starting at 1, so provide - * a null entry for the zero element of all C arrays. (The exception - * to this is that the fast table representation generally uses the - * 0 elements of its arrays, too.) - */ - -/* Indent to the current level. */ - -void do_indent (void) -{ - int i = indent_level * 8; - - while (i >= 8) { - outc ('\t'); - i -= 8; - } - - while (i > 0) { - outc (' '); - --i; - } -} - - /** Make the table for possible eol matches. * @return the newly allocated rule_can_match_eol table */ @@ -864,29 +835,6 @@ void gentabs (void) } -/* Write out a formatted string (with a secondary string argument) at the - * current indentation level, adding a final newline. - */ - -void indent_put2s (const char *fmt, const char *arg) -{ - do_indent (); - out_str (fmt, arg); - outn (""); -} - - -/* Write out a string at the current indentation level, adding a final - * newline. - */ - -void indent_puts (const char *str) -{ - do_indent (); - outn (str); -} - - static void visible_define (const char *symname) { out_m4_define(symname, NULL); @@ -1047,7 +995,6 @@ void make_tables (void) /* This is where we REALLY begin generating the tables. */ - set_indent (0); if (fullspd) { genctbl (); if (tablesext) { @@ -1222,21 +1169,21 @@ void make_tables (void) line_directive_out (stdout, 0); /* generate cases for any missing EOF rules */ - set_indent(0); for (i = 1; i <= lastsc; ++i) if (!sceof[i]) { - do_indent (); + outc ('\t'); out_str3 ("%sYY_STATE_EOF(%s):\n", backend->caseprefix, scname[i], ""); if (backend->fallthrough != NULL) { - indent_puts(backend->fallthrough); + outc ('\t'); + outn (backend->fallthrough); } did_eof_rule = true; } if (did_eof_rule) { - ++indent_level; - indent_puts (backend->endcase); - --indent_level; + outc ('\t'); + outc ('\t'); + outn (backend->endcase); } skelout (); -- cgit v1.2.1 From c842b49f83a4fd07a261a05195e440765b8df585 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 25 Sep 2020 16:34:18 -0400 Subject: Finish the retargeting patch series with a couple of small fixups. Pull the C mode setting for M4_YYL_BASE into m4. Use if/then/else extension of m4_ifdef to simplify how yy_flex_debug is set. In the process, fix a bug introduced earlier in this patchest where yy_flex_debug initialization was inverted. Remove unused skel breakpoints and renumber those left. Diffs have only commenmt and whitespace changes *except* for the corrected initialzation of yy_flex_debug. #40 in the retargeting patch series --- src/cpp-flex.skl | 27 +++++++++------------------ src/gen.c | 27 ++++++--------------------- 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index da2f38d..c9f1bfd 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -728,13 +728,11 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef( [[M4_MODE_C_ONLY]], [[ extern int yy_flex_debug; -int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]])m4_ifdef([[M4_MODE_NO_DEBUG]],[[1]]); +int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); ]]) %endif -%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ -%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ -%% [4.0] data tables for the DFA and the user's section 1 definitions go here +%% [2.0] data tables for the DFA are inserted here ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], @@ -847,7 +845,7 @@ char *yytext; ]]) ]]) -%% [4.1] static declarations conditional on mode switches go here +%% [3.0] static declarations conditional on mode switches go here ]]) m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) @@ -1252,7 +1250,6 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ \ }\ ]]) \ %endif \ -%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ \ %if-c++-only C++ definition \ if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ @@ -1390,7 +1387,6 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ -%% [6.0] YY_RULE_SETUP definition goes here #define YY_RULE_SETUP \ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ @@ -1562,7 +1558,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], } { -%% [7.0] user's declarations go here +%% [4.0] user's declarations go here while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1576,7 +1572,6 @@ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ } ]]) ]]) -%% [8.0] yymore()-related code goes here yy_cp = YY_G(yy_c_buf_p); /* Support of yytext. */ @@ -1591,7 +1586,6 @@ M4_GEN_START_STATE yy_match: -%% [9.0] code to set up and find next match goes here /* Generate the code to find the next match. */ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ m4_ifdef([[M4_MODE_GENTABLES]], [[ @@ -1633,7 +1627,7 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ ]]) yy_find_action: -%% [10.0] code to find the action number goes here + /* code to find the action number goes here */ m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ @@ -1704,8 +1698,9 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s YY_DO_BEFORE_ACTION; m4_ifdef( [[M4_YY_USE_LINENO]],[[ -m4_ifdef( [[M4_MODE_YYMORE_USED]],[[ -]]) +m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], + [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], + [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; @@ -1715,12 +1710,8 @@ m4_ifdef( [[M4_MODE_YYMORE_USED]],[[ } ]]) -%% [11.0] code for yylineno update goes here - do_action: /* This label is used only to access EOF actions. */ -%% [12.0] debug code goes here - m4_ifdef([[M4_MODE_DEBUG]], [[ if ( yy_flex_debug ) { if ( yy_act == 0 ) { @@ -1785,7 +1776,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ goto yy_find_action; ]]) ]]) -%% [13.0] actions go here +%% [5.0] user actions get inserted here case YY_END_OF_BUFFER: { diff --git a/src/gen.c b/src/gen.c index 5cca3d3..df0080c 100644 --- a/src/gen.c +++ b/src/gen.c @@ -920,7 +920,7 @@ void make_tables (void) if (do_yylineno) visible_define ( "M4_MODE_YYLINENO"); - // Equivelance classes + // Equivalence classes if (useecs) visible_define ( "M4_MODE_USEECS"); else @@ -957,11 +957,9 @@ void make_tables (void) if (ddebug) visible_define ( "M4_MODE_DEBUG"); - else - visible_define ( "M4_MODE_NO_DEBUG"); // Kluge to get around the fact that the %if-not-reentrant and - // %if-c-only gates can;t be combined by nesting one inside the + // %if-c-only gates can't be combined by nesting one inside the // other. if (backend == &cpp_backend && !C_plus_plus) visible_define ( "M4_MODE_C_ONLY"); @@ -969,10 +967,6 @@ void make_tables (void) backend->comment("m4 controls end"); out ("\n"); - // FIXME: This probaby should be done in pure m4 - out_m4_define ("M4_YYL_BASE", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : - "YY_G(yy_more_len)") : "0"); - // There are a couple more modes we can't compute until after // tables have been generated. @@ -989,9 +983,7 @@ void make_tables (void) */ fprintf (stdout, backend->string_define_fmt, "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1)); - skelout (); /* %% [2.0] - break point in skel */ - skelout (); /* %% [3.0] - break point in skel */ - skelout (); /* %% [4.0] - tables get dumped here */ + skelout (); /* %% [2.0] - tables get dumped here */ /* This is where we REALLY begin generating the tables. */ @@ -1141,29 +1133,22 @@ void make_tables (void) dataend (); } - skelout (); /* %% [4.1] - mode-dependent static declarations get dumped here */ + skelout (); /* %% [3.0] - mode-dependent static declarations get dumped here */ out (&action_array[defs1_offset]); line_directive_out (stdout, 0); - skelout (); /* %% [5.0] - break point in skel */ - skelout (); /* %% [6.0] - break point in skel */ - skelout (); /* %% [7.0] - break point in skel */ + skelout (); /* %% [4.0] - various random yylex internals get dumped here */ /* Copy prolog to output file. */ out (&action_array[prolog_offset]); line_directive_out (stdout, 0); - skelout (); /* %% [8.0] - break point in skel */ - skelout (); /* %% [9.0] - break point in skel */ - skelout (); /* %% [10.0] - break point in skel */ - skelout (); /* %% [11.0] - break point in skel */ - skelout (); /* %% [12.0] - break point in skel */ + skelout (); /* %% [5.0] - main loop of matching-emngine code gets dumped here */ /* Copy actions to output file. */ - skelout (); /* %% [13.0] - break point in skel */ out (&action_array[action_offset]); line_directive_out (stdout, 0); -- cgit v1.2.1 From 42a39df0f5663c038b5fd875041d177ae57ea560 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 25 Sep 2020 22:14:32 -0400 Subject: Fo;d documentation on how to write bac ends into the Texinfo manual. --- doc/flex.texi | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++---- src/Makefile.am | 3 +- src/backend.adoc | 94 ---------------------------------------- 3 files changed, 119 insertions(+), 105 deletions(-) delete mode 100644 src/backend.adoc diff --git a/doc/flex.texi b/doc/flex.texi index e814acd..1f7192b 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -192,7 +192,7 @@ FAQ * How can I build a two-pass scanner?:: * How do I match any string not matched in the preceding rules?:: * I am trying to port code from AT&T lex that uses yysptr and yysbuf.:: -* Is there a way to make flex treat NULL like a regular character?:: +* Is there a way to make flex treat NUL like a regular character?:: * Whenever flex can not match the input it says "flex scanner jammed".:: * Why doesn't flex have non-greedy operators like perl does?:: * Memory leak - 16386 bytes allocated by malloc.:: @@ -269,6 +269,7 @@ Appendices * Bison Bridge:: * M4 Dependency:: * Common Patterns:: +* Adding More Target Languages Indices @@ -734,7 +735,7 @@ if X is @samp{a}, @samp{b}, @samp{f}, @samp{n}, @samp{r}, @samp{t}, or @samp{v}, then the ANSI-C interpretation of @samp{\x}. Otherwise, a literal @samp{X} (used to escape operators such as @samp{*}) -@cindex NULL character in patterns, syntax of +@cindex NUL character in patterns, syntax of @item \0 a NUL character (ASCII code 0) @@ -5148,10 +5149,10 @@ the version of flex that was used to create the serialized tables. @item th_name[] Contains the name of this table set. The default is @samp{yytables}, -and is prefixed accordingly, e.g., @samp{footables}. Must be NULL-terminated. +and is prefixed accordingly, e.g., @samp{footables}. Must be NUL-terminated. @item th_pad64[] -Zero or more NULL bytes, padding the entire header to the next 64-bit boundary +Zero or more NUL bytes, padding the entire header to the next 64-bit boundary as calculated from the beginning of the header. @end table @@ -5239,7 +5240,7 @@ The table data. This array may be a one- or two-dimensional array, of type @code{td_flags}, @code{td_hilen}, and @code{td_lolen} fields. @item td_pad64[] -Zero or more NULL bytes, padding the entire table to the next 64-bit boundary as +Zero or more NUL bytes, padding the entire table to the next 64-bit boundary as calculated from the beginning of this table. @end table @@ -5447,7 +5448,7 @@ publish them here. * How can I build a two-pass scanner?:: * How do I match any string not matched in the preceding rules?:: * I am trying to port code from AT&T lex that uses yysptr and yysbuf.:: -* Is there a way to make flex treat NULL like a regular character?:: +* Is there a way to make flex treat NUL like a regular character?:: * Whenever flex can not match the input it says "flex scanner jammed".:: * Why doesn't flex have non-greedy operators like perl does?:: * Memory leak - 16386 bytes allocated by malloc.:: @@ -6060,8 +6061,8 @@ what they're doing, and then replace @code{input()} with an appropriate definiti @code{YY_INPUT}. You shouldn't need to (and must not) replace @code{flex}'s @code{unput()} function. -@node Is there a way to make flex treat NULL like a regular character? -@unnumberedsec Is there a way to make flex treat NULL like a regular character? +@node Is there a way to make flex treat NUL like a regular character? +@unnumberedsec Is there a way to make flex treat NUL like a regular character? Yes, @samp{\0} and @samp{\x00} should both do the trick. Perhaps you have an ancient version of @code{flex}. The latest release is version @value{VERSION}. @@ -8167,6 +8168,7 @@ See @ref{Top, , , bison, the GNU Bison Manual}. * Bison Bridge:: * M4 Dependency:: * Common Patterns:: +* Retargeting Flex:: @end menu @node Makefiles and Flex, Bison Bridge, Appendices, Appendices @@ -8413,7 +8415,7 @@ removing such sequences from your code. @code{m4} is only required at the time you run @code{flex}. The generated scanner is ordinary C or C++, and does @emph{not} require @code{m4}. -@node Common Patterns, ,M4 Dependency, Appendices +@node Common Patterns,Retargeting Flex,M4 Dependency, Appendices @section Common Patterns @cindex patterns, common @@ -8561,6 +8563,113 @@ to appear in a URI, including spaces and control characters. See @end table +@node Retargeting Flex, ,Common Patterns, Appendices +@section Retargeting Flex +@cindex retargeting +@cindex language independence + +This appendix describes how to add support for a new target language +to Flex. + +The flex code has been factored to isolate knowledge of the specifics +of each target language from the logic for building the lexer state +tables. + +The only assumption that is absolutely baked into all of Flex is that +the bodies of initializers for arrays of integers consist of decimal +numeric literals separated by commas (and optional whitespace). + +Otherwise, knowledge of each target langage's syntax lives in two +places: (1) a table of language-specific syntax-generator methods, +and (2) A language-specific skeleton file. + +For example: The methods for the C and C++ back end live in a source +file named @file{cpp_backend.c} (so named because both languages use the C +preprocessor), and in a skeleton file named @file{cpp-flex.skl}. + +All the code that accesses language-specific code generators goes +through a global pointer named "backend" to a method table. The +results of these generators are used to fill in some parts of the +language-specific skeleton file and conditionalize others. + +Read the definition of struct backend_t in @file{src/flexdefs.h}, and +attached comments, to get a feel for the methods. Don't worry +about understandng table generator names at first. + +To write support for a language, you'll want to do the following +steps: + +@enumerate +@item +Clone one of the existing back-end/skeleton pairs. If the language +you are supporting is named @var{foo}, you should create files named +@file{foo_backend.c} and @file{foo-flex.skl}. + +@item +Add @file{foo_backend.c} to COMMON_SOURCES in @file{src/Makefile.am}. Add the +name of your skeleton file to EXTRA_DIST. + +@item +Add a production to @file{src/Makefile.am} parallel to the one that +produces @file{cpp-skel.h}. Your objective is to make a string list +initializer from your skeleton file that can be linked with flex and +is pointed at by the skel nember of your language back end. + +@item +Add some logic to @file{main.c} that enables the new back end with a +new command-line option. Following this step you should be +able to run Flex on a specification and get code out in the +language of whatever back end you cloned. + +@item +The interesting part: mutate your new back end and skeleton so they +produce code in your desired target langage. + +@item +Add a test suite for your back end. You should be able to clone +one of the existing sets of test loads to get good coverage. Note +that is highly unlikely your back end will be accepted into the +flex distribution without a test suite. +@end enumerate + +Syntactically C-like languages such as Go, Rust, and Java should be easy +targets. Almost anything generally descended from Algol shouldn't be +much more difficult; this certainly includes the whole +Pascal/Modula/Oberon family. + +A hint about the interesting part: + +@itemize +@item +Don't bother supporting non-reentrant parser generation. +The interface of original Lex with all those globals hanging out +needs to be supported in C for backwards compatibility, but +there is no need to carry it forward. +@end itemize + +The following assumptions in the code might trip you up and +require fixes outside a back end. + +@enumerate +@item +The item separator in data initializers is a comma. + +@item +The language has a case-arm syntax that looks like +a (possibly empty) prefix, followed by a value +expression, followed by a colon. + +@item +Either case arms can be stacked as in C; that is, there is +an implicit fallthrough if the case arm has no code. Or, +there is an explicit fallthrough keyword that enables this, +as in Go. +@end enumerate + +By putting a @code{yyterminate()} call in the fallthrough member +and a null pointer in the endcase member, you could handle +languages like Pascal. + @node Indices, , Appendices, Top @unnumbered Indices diff --git a/src/Makefile.am b/src/Makefile.am index 171549a..40ca850 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,8 +91,7 @@ include_HEADERS = \ EXTRA_DIST = \ cpp-flex.skl \ mkskel.sh \ - gettext.h \ - backend.adoc + gettext.h CLEANFILES = stage1scan.c stage1flex$(EXEEXT) diff --git a/src/backend.adoc b/src/backend.adoc deleted file mode 100644 index f1876d3..0000000 --- a/src/backend.adoc +++ /dev/null @@ -1,94 +0,0 @@ -= How to add a support for a new language to flex - -= Theory - -The flex code was historically written to generate parsers in C, but -it has factored to isolate knowledge of the specifics of each target -languageas from the logic for byukilding the lexer state tables much -as possible. - -The only assumption that is absolutely baked into all of flex is that -the bodies of initializers for arrays of integers consist of decimal -numeric kiterals sepaerated by commas (and optional whitespace). - -Otherwise, knowledge of each target langage's syntax lives in two -places: (1) a table of langyuge-specific syntax-generator methods, -and (2) A language-specific skeleton file. - -For example: The methods for the C and C++ back end live in a source -file named cpp_backend.c (so named because both languages use the C -preprocessor), and in a skeleton file names cpp-flex.skl. - -Syntactically C-like languages such as Go, Rust, and Java should be easy -target. Alnost anything generally descended from Algol shouldn't be -much more difficult; this certainly includes the whole -Pascal/Modula/Oberon family. - -= Writing a new backend - -All the code that accesses language-specific code generators goes -through a global pointer named "backend" to a method table. The -results of these generators are used to fill in some parts of the -language-specifoc skeleton file amd conditionalize other. - -Read the definition of struct backend_t in src/flexdefs.h, and -attached comments, to get a feel for the methods. Don't worry -about understandng table generator names at first. - -To write support for a language, you'll want to do the following -steps: - -1. Clone one of the existing back-end/skeleton pairs. If the language - you are supporting is named "foo", you should create files named - foo_backend.c and foo-flex.skl. - -2. Add foo_backend.c to COMMON_SOURCES in src.Makefile.am. Add the - name of your skeleton file to EXTRA_DIST. - -3. Add a production to src/Makefile.am parallel to the one that - priduces cpp-skel.h. Your objecting is to make a string list - initializer from your skeleton file that can be linked with flex - and is opointed at by the skel nember of your language back end. - -4. Add some logic to main.c that enables the new back end with a - new command-line option. Following this step you should be - able to run flex on a specification and get code out in the - language of whatever back end you cloned. - -5. The interesting part: mutate your new back end and skeleton so they - produce code in your desired target langage. - -6. Write a test suite for your back end. You should be able to clone - one of the existing sets of test loads to get good coverage. Note - that is highly unlikely your back end will be accepted into the - flex distribution without a test suite. - -A hint about step 5: - -* Don't bother supporting non-reentrant parser generation. - The interface of original lex with all those globals hanging out - needs to be supported in C for backwards compatibility, but - there - -The following assumptions in the code might trip you up and -require fixes outside a back end. - -1. The language has a case-arm syntax that looks like - a (possibly empty) prefix, followed by a value - expression, followed by a colon. - -2. Either case arms can be stacked as in C; that is, there is - an implicit fallthrough if the case arm has no code. Or, - there is an explicit fallthrough keyword that enables this, - as in Go. - -3. The item separator in data initializers is a comma. - -By putting a yyterminate() call in the fallthrough member -and a null pointer in the endcase member, you could handle -languages like Pascal. - -// end - - - -- cgit v1.2.1 From 103634e4ca84ff014b20ef0e9cf726ef5980592d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 26 Sep 2020 21:50:06 -0400 Subject: Clean up the indentation and brace usage in the skeleton file. It was in a mix of several different styles tht made it hard to read. I've massaged it all ibto K&R with tabs and mandatory braces. No logic changes. --- src/cpp-flex.skl | 2277 ++++++++++++++++++++++++++---------------------------- 1 file changed, 1099 insertions(+), 1178 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index c9f1bfd..ac433ce 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -21,6 +21,12 @@ %# The exception to this rule is YY_G, which is an m4 macro, %# but it needs to be remain short because it is used everywhere. %# +%# The m4 macros complicate reading this code enough that being +%# prescriptive about whitespace and braces is more than usually +%# important. So please set your C style to K&R, aka 1TBS with +%# tabs when editing this file. Braces around single-statement +%# if/while/fo/do/switch/break bodies are mandatory. +%# /* A lexical scanner generated by flex */ %# Macros for preproc stage. @@ -484,12 +490,9 @@ struct yy_buffer_state %if-c-only FILE *yy_input_file; %endif - %if-c++-only std::streambuf* yy_input_file; %endif - - char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -522,9 +525,8 @@ struct yy_buffer_state */ int yy_at_bol; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. @@ -885,71 +887,61 @@ m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; +struct yyguts_t { + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; -m4_ifdef( [[M4_MODE_USES_REJECT]], -[[ - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; - int yy_lp; + int yylineno_r; + int yy_flex_debug_r; - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ - int yy_looking_for_trail_begin; - int yy_full_lp; - int *yy_full_state; -]]) +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], -[[ - char yytext_r[YYLMAX]; - char *yytext_ptr; - int yy_more_offset; - int yy_prev_more_offset; -]], -[[ - char *yytext_r; - int yy_more_flag; - int yy_more_len; + /* These are only needed for trailing context rules, + * but there's no conditional variable for that yet. */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; ]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - YYSTYPE * yylval_r; +m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], [[ + char yytext_r[YYLMAX]; + char *yytext_ptr; + int yy_more_offset; + int yy_prev_more_offset; +]], [[ + char *yytext_r; + int yy_more_flag; + int yy_more_len; ]]) - -m4_ifdef( [[]], -[[ - YYLTYPE * yylloc_r; +m4_ifdef( [[M4_YY_BISON_LVAL]], [[ + YYSTYPE * yylval_r; ]]) - }; /* end struct yyguts_t */ +m4_ifdef( [[]], [[ + YYLTYPE * yylloc_r; +]]) +}; /* end struct yyguts_t */ ]]) @@ -1309,8 +1301,7 @@ struct yytbl_dmap { }; /** A {0,0,0}-terminated list of structs, forming the map */ -static struct yytbl_dmap yydmap[] = -{ +static struct yytbl_dmap yydmap[] = { %tables-yydmap generated elements {0,0,0} }; @@ -1483,8 +1474,7 @@ m4_ifdef([[M4_NOT_MODE_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) %not-for-header /** The main scanner function which does all the work. */ -YY_DECL -{ +YY_DECL { yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; @@ -1512,8 +1502,7 @@ m4_ifdef( [[]], yylloc = yylloc_param; ]]) - if ( !YY_G(yy_init) ) - { + if ( !YY_G(yy_init) ) { YY_G(yy_init) = 1; #ifdef YY_USER_INIT @@ -1523,31 +1512,33 @@ m4_ifdef( [[]], m4_ifdef( [[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! YY_G(yy_state_buf) ) + if ( ! YY_G(yy_state_buf) ) { YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_state_buf) ) + } + if ( ! YY_G(yy_state_buf) ) { YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); + } ]]) - if ( ! YY_G(yy_start) ) + if ( ! YY_G(yy_start) ) { YY_G(yy_start) = 1; /* first start state */ - - if ( ! yyin ) + } + if ( ! yyin ) { %if-c-only yyin = stdin; %endif %if-c++-only yyin.rdbuf(std::cin.rdbuf()); %endif - - if ( ! yyout ) + } + if ( ! yyout ) { %if-c-only yyout = stdout; %endif %if-c++-only yyout.rdbuf(std::cout.rdbuf()); %endif - + } if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); YY_CURRENT_BUFFER_LVALUE = @@ -1555,381 +1546,359 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], } yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - } + } + /* open scope of user declarationns */ { %% [4.0] user's declarations go here - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { + while ( /*CONSTCOND*/1 ) { /* loops until end-of-file is reached */ m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ - YY_G(yy_more_len) = 0; - if ( YY_G(yy_more_flag) ) - { - YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); - YY_G(yy_more_flag) = 0; + YY_G(yy_more_len) = 0; + if ( YY_G(yy_more_flag) ) { + YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); + YY_G(yy_more_flag) = 0; } ]]) ]]) - yy_cp = YY_G(yy_c_buf_p); + yy_cp = YY_G(yy_c_buf_p); - /* Support of yytext. */ - *yy_cp = YY_G(yy_hold_char); + /* Support of yytext. */ + *yy_cp = YY_G(yy_hold_char); - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; M4_GEN_START_STATE -yy_match: - - /* Generate the code to find the next match. */ + yy_match: + /* Generate the code to find the next match. */ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ m4_ifdef([[M4_MODE_GENTABLES]], [[ - while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { + while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { ]]) m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ - while ((yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) - { + while ((yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { ]]) M4_GEN_BACKING_UP - yy_cp++; + yy_cp++; } - yy_current_state = -yy_current_state; + yy_current_state = -yy_current_state; ]]) m4_ifdef([[M4_MODE_FULLSPD]], [[ - M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yy_cp)), M4_EC(YY_SC_TO_UI(*++yy_cp))) + M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yy_cp)), M4_EC(YY_SC_TO_UI(*++yy_cp))) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ - do - { - M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) + do { + M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) - ++yy_cp; + m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) + ++yy_cp; } - m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yy_current_state] != YY_JAMBASE );]]) - m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yy_current_state != YY_JAMSTATE );]]) + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yy_current_state] != YY_JAMBASE );]]) + m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yy_current_state != YY_JAMSTATE );]]) m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ - /* Do the guaranteed-needed backing up to figure out - * the match. - */ - yy_cp = YY_G(yy_last_accepting_cpos); - yy_current_state = YY_G(yy_last_accepting_state); + /* Do the guaranteed-needed backing up to figure out + * the match. + */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); ]]) ]]) ]]) -yy_find_action: - /* code to find the action number goes here */ - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) + yy_find_action: + /* code to find the action number goes here */ + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ - yy_current_state = *--YY_G(yy_state_ptr); - YY_G(yy_lp) = yy_accept[yy_current_state]; + yy_current_state = *--YY_G(yy_state_ptr); + YY_G(yy_lp) = yy_accept[yy_current_state]; m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) - for ( ; ; ) { /* loop until we find out what rule we matched */ - if (YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1]) { - yy_act = yy_acclist[YY_G(yy_lp)]; + for ( ; ; ) { /* loop until we find out what rule we matched */ + if (YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1]) { + yy_act = yy_acclist[YY_G(yy_lp)]; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || YY_G(yy_looking_for_trail_begin)) { - if (yy_act == YY_G(yy_looking_for_trail_begin)) { - YY_G(yy_looking_for_trail_begin) = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; - break; - } - } - else if (( yy_act & YY_TRAILING_MASK) != 0) { - YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; - YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; + if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || YY_G(yy_looking_for_trail_begin)) { + if (yy_act == YY_G(yy_looking_for_trail_begin)) { + YY_G(yy_looking_for_trail_begin) = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } else if (( yy_act & YY_TRAILING_MASK) != 0) { + YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; + YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; m4_ifdef([[M4_MODE_REAL_REJECT]], [[ - /* Remember matched text in case we back up - * due to REJECT. - */ - YY_G(yy_full_match) = yy_cp; - YY_G(yy_full_state) = YY_G(yy_state_ptr); - YY_G(yy_full_lp) = YY_G(yy_lp); -]]) - } - else - { - YY_G(yy_full_match) = yy_cp; - YY_G(yy_full_state) = YY_G(yy_state_ptr); - YY_G(yy_full_lp) = YY_G(yy_lp); - break; - } - ++YY_G(yy_lp); - goto find_rule; + /* Remember matched text in case we back up + * due to REJECT. + */ + YY_G(yy_full_match) = yy_cp; + YY_G(yy_full_state) = YY_G(yy_state_ptr); + YY_G(yy_full_lp) = YY_G(yy_lp); +]]) + } else { + YY_G(yy_full_match) = yy_cp; + YY_G(yy_full_state) = YY_G(yy_state_ptr); + YY_G(yy_full_lp) = YY_G(yy_lp); + break; + } + ++YY_G(yy_lp); + goto find_rule; ]]) m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - /* Remember matched text in case we back up due to - * trailing context plus REJECT. - */ - YY_G(yy_full_match) = yy_cp; - break; + /* Remember matched text in case we back up due to + * trailing context plus REJECT. + */ + YY_G(yy_full_match) = yy_cp; + break; ]]) - } + } - --yy_cp; + --yy_cp; - /* We could consolidate the following two lines with those at - * the beginning, but at the cost of complaints that we're - * branching inside a loop. - */ - yy_current_state = *--YY_G(yy_state_ptr); - YY_G(yy_lp) = yy_accept[yy_current_state]; - } + /* We could consolidate the following two lines with those at + * the beginning, but at the cost of complaints that we're + * branching inside a loop. + */ + yy_current_state = *--YY_G(yy_state_ptr); + YY_G(yy_lp) = yy_accept[yy_current_state]; + } /* close for */ ]]) m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = YY_G(yy_last_accepting_cpos); - yy_current_state = YY_G(yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) { /* have to back up */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; } ]]) - YY_DO_BEFORE_ACTION; + YY_DO_BEFORE_ACTION; m4_ifdef( [[M4_YY_USE_LINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) - { - int yyl; - for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) - if ( yytext[yyl] == '\n' ) - M4_YY_INCR_LINENO(); - } + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { + int yyl; + for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) { + if ( yytext[yyl] == '\n' ) { + M4_YY_INCR_LINENO(); + + } + } + } ]]) -do_action: /* This label is used only to access EOF actions. */ + do_action: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ - if ( yy_flex_debug ) { - if ( yy_act == 0 ) { + if ( yy_flex_debug ) { + if ( yy_act == 0 ) { %if-c++-only - std::cerr << "--scanner backing up\n"; + std::cerr << "--scanner backing up\n"; %endif %if-c-only - fprintf( stderr, "--scanner backing up\n" ); + fprintf( stderr, "--scanner backing up\n" ); %endif - } else if ( yy_act < YY_NUM_RULES ) { + } else if ( yy_act < YY_NUM_RULES ) { %if-c++-only - std::cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << - "(\"" << yytext << "\")\n"; + std::cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << + "(\"" << yytext << "\")\n"; %endif %if-c-only - fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yytext ); + fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", + (long)yy_rule_linenum[yy_act], yytext ); %endif - } else if ( yy_act == YY_NUM_RULES ) { + } else if ( yy_act == YY_NUM_RULES ) { %if-c++-only - std::cerr << "--accepting default rule (\"" << yytext << "\")\n"; + std::cerr << "--accepting default rule (\"" << yytext << "\")\n"; %endif %if-c-only - fprintf( stderr, "--accepting default rule (\"%s\")\n", + fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); %endif - } else if ( yy_act == YY_NUM_RULES + 1 ) { + } else if ( yy_act == YY_NUM_RULES + 1 ) { %if-c++-only - std::cerr << "--(end of buffer or a NUL)\n"; + std::cerr << "--(end of buffer or a NUL)\n"; %endif %if-c-only - fprintf( stderr, "--(end of buffer or a NUL)\n" ); + fprintf( stderr, "--(end of buffer or a NUL)\n" ); %endif - } else { + } else { %if-c++-only - std::cerr << "--EOF (start condition " << YY_START << ")\n"; + std::cerr << "--EOF (start condition " << YY_START << ")\n"; %endif %if-c-only - fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); %endif + } } - } ]]) - switch ( yy_act ) - { /* beginning of action switch */ + switch ( yy_act ) { /* beginning of action switch */ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = YY_G(yy_hold_char); + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = YY_G(yy_hold_char); - /* /\* Backing-up info for compressed tables is taken \after/ */ - /* * yy_cp has been incremented for the next state. */ - /* *\/ */ - yy_cp = YY_G(yy_last_accepting_cpos); - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) + /* /\* Backing-up info for compressed tables is taken \after/ */ + /* * yy_cp has been incremented for the next state. */ + /* *\/ */ + yy_cp = YY_G(yy_last_accepting_cpos); + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) - yy_current_state = YY_G(yy_last_accepting_state); - goto yy_find_action; + yy_current_state = YY_G(yy_last_accepting_state); + goto yy_find_action; ]]) ]]) %% [5.0] user actions get inserted here - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = YY_G(yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + case YY_END_OF_BUFFER: { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = YY_G(yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; %if-c-only - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; %endif %if-c++-only - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); %endif - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) { /* This was really a NUL. */ + yy_state_type yy_next_state; - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++YY_G(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - else - { + if ( yy_next_state ) { + /* Consume the NUL. */ + yy_cp = ++YY_G(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } else { %# Disguised case statement on table modes - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = YY_G(yy_c_buf_p);]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ - /* Do the guaranteed-needed backing up to figure - * out the match. - */ - yy_cp = YY_G(yy_last_accepting_cpos); - yy_current_state = YY_G(yy_last_accepting_state); + /* Do the guaranteed-needed backing up to figure + * out the match. + */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); ]]) ]]) %# Disguised case statement on table modes ends m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ - /* Still need to initialize yy_cp, though - * yy_current_state was set up by - * yy_get_previous_state(). - */ - yy_cp = YY_G(yy_c_buf_p); + /* Still need to initialize yy_cp, though + * yy_current_state was set up by + * yy_get_previous_state(). + */ + yy_cp = YY_G(yy_c_buf_p); ]]) ]]) - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) - { - case EOB_ACT_END_OF_FILE: - { - YY_G(yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; + goto yy_find_action; } + } else { /* not a NUL */ + switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) { + case EOB_ACT_END_OF_FILE: + YY_G(yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } else { + if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { + YY_NEW_FILE; + } + } + break; + case EOB_ACT_CONTINUE_SCAN: + YY_G(yy_c_buf_p) = + YY_G(yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + yy_cp = YY_G(yy_c_buf_p); + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + YY_G(yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + yy_cp = YY_G(yy_c_buf_p); + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } /* end EOB inner switch */ + } /* end if */ break; - } - - case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = - YY_G(yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - YY_G(yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); - - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ + } /* case YY_END_OF_BUFFER */ + default: + YY_FATAL_ERROR("fatal flex scanner internal error--no action found" ); + } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ } /* end of yylex */ @@ -1959,8 +1928,7 @@ yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): /* The contents of this function are C++ specific, so the YY_G macro is not used. */ -void yyFlexLexer::ctor_common() -{ +void yyFlexLexer::ctor_common() { yy_c_buf_p = 0; yy_init = 0; yy_start = 0; @@ -1993,8 +1961,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], /* The contents of this function are C++ specific, so the YY_G macro is not used. */ -yyFlexLexer::~yyFlexLexer() -{ +yyFlexLexer::~yyFlexLexer() { delete [] yy_state_buf; yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); @@ -2003,8 +1970,7 @@ yyFlexLexer::~yyFlexLexer() /* The contents of this function are C++ specific, so the YY_G macro is not used. */ -void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) -{ +void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) { // was if( new_in ) yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); @@ -2034,32 +2000,32 @@ int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) int yyFlexLexer::LexerInput( char* buf, int max_size ) #endif { - if ( yyin.eof() || yyin.fail() ) + if ( yyin.eof() || yyin.fail() ) { return 0; - + } #ifdef YY_INTERACTIVE yyin.get( buf[0] ); - if ( yyin.eof() ) + if ( yyin.eof() ) { return 0; - - if ( yyin.bad() ) + } + if ( yyin.bad() ) { return -1; - + } return 1; #else (void) yyin.read( buf, max_size ); - if ( yyin.bad() ) + if ( yyin.bad() ) { return -1; - else + } else { return yyin.gcount(); + } #endif } -void yyFlexLexer::LexerOutput( const char* buf, int size ) -{ +void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout.write( buf, size ); } %ok-for-header @@ -2081,56 +2047,48 @@ static int yy_get_next_buffer (M4_YY_DEF_ONLY_ARG) int yyFlexLexer::yy_get_next_buffer() %endif { - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = YY_G(yytext_ptr); int number_to_move, i; int ret_val; - if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) - { + if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) { + YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); + } + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; - } - - else - { + } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; - } } + } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - 1); - for ( i = 0; i < number_to_move; ++i ) + for ( i = 0; i < number_to_move; ++i ) { *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + } + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; - - else - { - int num_to_read = + } else { + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ + while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ YY_FATAL_ERROR( @@ -2143,71 +2101,63 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], int yy_c_buf_p_offset = (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); - if ( b->yy_is_our_buffer ) - { + if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; - if ( new_size <= 0 ) + if ( new_size <= 0 ) { b->yy_buf_size += b->yy_buf_size / 8; - else + } else { b->yy_buf_size *= 2; - + } b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc( (void *) b->yy_ch_buf, (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); - } - else + } else { /* Can't grow it, we don't own it. */ b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) + } + if ( ! b->yy_ch_buf ) { YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - + } YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; ]]) - } + } - if ( num_to_read > YY_READ_BUF_SIZE ) + if ( num_to_read > YY_READ_BUF_SIZE ) { num_to_read = YY_READ_BUF_SIZE; - + } /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), YY_G(yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } + } - if ( YY_G(yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { + if ( YY_G(yy_n_chars) == 0 ) { + if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin M4_YY_CALL_LAST_ARG); - } - - else - { + } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; - } } - - else + } else { ret_val = EOB_ACT_CONTINUE_SCAN; - + } if ((YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) { YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } /* "- 2" to take care of EOB's */ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } @@ -2226,19 +2176,18 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], %if-c-only %not-for-header - static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) +static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) %endif %if-c++-only - yy_state_type yyFlexLexer::yy_get_previous_state() +yy_state_type yyFlexLexer::yy_get_previous_state() %endif { yy_state_type yy_current_state; char *yy_cp; - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); -M4_GEN_START_STATE - for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) - { + M4_GEN_START_STATE + for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) { /* Generate the code to find the next state. */ m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) @@ -2257,16 +2206,16 @@ M4_GEN_START_STATE m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) - m4_ifdef([[M4_MODE_NULTRANS]], [[ - } else { - yy_current_state = yy_NUL_trans[yy_current_state]; - } - ]]) +m4_ifdef([[M4_MODE_NULTRANS]], [[ + } else { + yy_current_state = yy_NUL_trans[yy_current_state]; + } +]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) - } + } return yy_current_state; } @@ -2278,14 +2227,14 @@ M4_GEN_START_STATE * next_state = yy_try_NUL_trans( current_state ); */ %if-c-only - static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) +static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) %endif %if-c++-only - yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) %endif { int yy_is_jam; - M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ + M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ /* Generate code for handling NUL's, if needed. */ /* First, deal with backing up and setting up yy_cp if the scanner @@ -2299,59 +2248,58 @@ M4_GEN_START_STATE %# Note that this statement block and the following three are %# not executed serially but are an if-then-else cascade %# for different table modes. - m4_ifdef([[M4_MODE_NULTRANS]], [[ +m4_ifdef([[M4_MODE_NULTRANS]], [[ yy_current_state = yy_NUL_trans[yy_current_state]; yy_is_jam = (yy_current_state == 0); - ]]) +]]) - m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ - m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ - m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) - m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) yy_is_jam = (yy_current_state <= 0); - ]]) +]]) - m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ - m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ - int yy_c = YY_NUL_EC; +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ + int yy_c = YY_NUL_EC; - const struct yy_trans_info *yy_trans_info; + const struct yy_trans_info *yy_trans_info; - yy_trans_info = &yy_current_state[(unsigned int) yy_c]; - yy_current_state += yy_trans_info->yy_nxt; - yy_is_jam = (yy_trans_info->yy_verify != yy_c); - ]]) + yy_trans_info = &yy_current_state[(unsigned int) yy_c]; + yy_current_state += yy_trans_info->yy_nxt; + yy_is_jam = (yy_trans_info->yy_verify != yy_c); +]]) - m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ - M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) - yy_is_jam = (yy_current_state == YY_JAMSTATE); - m4_ifdef([[M4_MODE_USES_REJECT]], [[ - /* Only stack this state if it's a transition we - * actually make. If we stack it on a jam, then - * the state stack and yy_c_buf_p get out of sync. - */ - if ( ! yy_is_jam ) - *YY_G(yy_state_ptr)++ = yy_current_state; - ]]) - ]]) - ]]) +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ +M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) +yy_is_jam = (yy_current_state == YY_JAMSTATE); +m4_ifdef([[M4_MODE_USES_REJECT]], [[ + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + if ( ! yy_is_jam ) { + *YY_G(yy_state_ptr)++ = yy_current_state; + } ]]) +]]) +]]) +]]) %# End of if-else cascade +m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ /* If we've entered an accepting state, back up; note that * compressed tables have *already* done such backing up, so * we needn't bother with it again. */ - m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ - - if ( ! yy_is_jam ) - { - M4_GEN_BACKING_UP - } - ]]) + if ( ! yy_is_jam ) { + M4_GEN_BACKING_UP + } +]]) M4_YY_NOOP_GUTS_VAR(); -return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } @@ -2359,22 +2307,22 @@ return yy_is_jam ? 0 : yy_current_state; %if-c-only m4_ifdef( [[M4_YY_NO_UNPUT]],, [[ - static void yyunput YYFARGS2( int,c, char *,yy_bp) +static void yyunput YYFARGS2( int,c, char *,yy_bp) %endif %if-c++-only - void yyFlexLexer::yyunput( int c, char* yy_bp) +void yyFlexLexer::yyunput( int c, char* yy_bp) %endif { char *yy_cp; - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); - yy_cp = YY_G(yy_c_buf_p); + yy_cp = YY_G(yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = YY_G(yy_hold_char); - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { + /* need to shift things up to make room */ /* +2 for EOB chars. */ int number_to_move = YY_G(yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ @@ -2382,25 +2330,26 @@ m4_ifdef( [[M4_YY_NO_UNPUT]],, char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) { *--dest = *--source; - + } yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { YY_FATAL_ERROR( "flex scanner push-back overflow" ); } + } *--yy_cp = (char) c; m4_ifdef( [[M4_YY_USE_LINENO]], [[ - if ( c == '\n' ){ - --yylineno; - } + if ( c == '\n' ){ + --yylineno; + } ]]) YY_G(yytext_ptr) = yy_bp; @@ -2415,74 +2364,70 @@ m4_ifdef( [[M4_YY_USE_LINENO]], %if-c-only #ifndef YY_NO_INPUT #ifdef __cplusplus - static int yyinput (M4_YY_DEF_ONLY_ARG) +static int yyinput (M4_YY_DEF_ONLY_ARG) #else - static int input (M4_YY_DEF_ONLY_ARG) +static int input (M4_YY_DEF_ONLY_ARG) #endif %endif %if-c++-only - int yyFlexLexer::yyinput() +int yyFlexLexer::yyinput() %endif { int c; - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { + if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) + if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) { /* This was really a NUL. */ *YY_G(yy_c_buf_p) = '\0'; - - else - { /* need more input */ + } else { + /* need more input */ int offset = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); ++YY_G(yy_c_buf_p); - switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin M4_YY_CALL_LAST_ARG); + switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ - /*FALLTHROUGH*/ + /* Reset buffer status. */ + yyrestart( yyin M4_YY_CALL_LAST_ARG); - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) - return 0; + /*FALLTHROUGH*/ - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; + case EOB_ACT_END_OF_FILE: + if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) { + return 0; + } + if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { + YY_NEW_FILE; + } #ifdef __cplusplus - return yyinput(M4_YY_CALL_ONLY_ARG); + return yyinput(M4_YY_CALL_ONLY_ARG); #else - return input(M4_YY_CALL_ONLY_ARG); + return input(M4_YY_CALL_ONLY_ARG); #endif - } - case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; - break; - } + case EOB_ACT_CONTINUE_SCAN: + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; + break; } } + } c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ @@ -2491,15 +2436,17 @@ m4_ifdef( [[M4_YY_USE_LINENO]], m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) { M4_YY_INCR_LINENO(); + } ]]) ]]) m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( c == '\n' ) + if ( c == '\n' ) { M4_YY_INCR_LINENO(); -]]) + } + ]]) ]]) return c; @@ -2514,18 +2461,18 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ * @note This function does not reset the start condition to @c INITIAL . */ %if-c-only - void yyrestart YYFARGS1( FILE *,input_file) +void yyrestart YYFARGS1( FILE *,input_file) %endif %if-c++-only - void yyFlexLexer::yyrestart( std::istream& input_file ) +void yyFlexLexer::yyrestart( std::istream& input_file ) %endif { - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); } yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); @@ -2552,30 +2499,29 @@ void yyFlexLexer::yyrestart( std::istream* input_file ) * M4_YY_DOC_PARAM */ %if-c-only - void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) +void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) %endif %if-c++-only - void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) %endif { - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); - */ + */ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - if ( YY_CURRENT_BUFFER == new_buffer ) + if ( YY_CURRENT_BUFFER == new_buffer ) { return; - - if ( YY_CURRENT_BUFFER ) - { + } + if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } + } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); @@ -2593,10 +2539,10 @@ void yyFlexLexer::yyrestart( std::istream* input_file ) static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) %endif %if-c++-only - void yyFlexLexer::yy_load_buffer_state() +void yyFlexLexer::yy_load_buffer_state() %endif { - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; %if-c-only @@ -2615,28 +2561,28 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) * @return the allocated buffer state. */ %if-c-only - YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) +YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) %endif %if-c++-only - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) +YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) %endif { YY_BUFFER_STATE b; - m4_dnl M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) + if ( ! b ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - + } b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); - if ( ! b->yy_ch_buf ) + if ( ! b->yy_ch_buf ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - + } b->yy_is_our_buffer = 1; yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); @@ -2651,7 +2597,7 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) * M4_YY_DOC_PARAM * @return the allocated buffer state. */ - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { return yy_create_buffer( *file, size ); } @@ -2662,23 +2608,23 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) * M4_YY_DOC_PARAM */ %if-c-only - void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) +void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) %endif %if-c++-only - void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) %endif { - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); - if ( ! b ) + if ( ! b ) { return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + } + if ( b == YY_CURRENT_BUFFER ) { /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) + } + if ( b->yy_is_our_buffer ) { yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); - + } yyfree( (void *) b M4_YY_CALL_LAST_ARG ); } @@ -2688,15 +2634,14 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) * such as during a yyrestart() or at EOF. */ %if-c-only - static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) +static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) %endif %if-c++-only - void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) +void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) %endif - { int oerrno = errno; - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); yy_flush_buffer( b M4_YY_CALL_LAST_ARG); @@ -2708,14 +2653,14 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) %endif b->yy_fill_buffer = 1; - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } %if-c-only m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], @@ -2743,16 +2688,16 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], * M4_YY_DOC_PARAM */ %if-c-only - void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) +void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) %endif %if-c++-only - void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) %endif { - M4_YY_DECL_GUTS_VAR(); - if ( ! b ) + M4_YY_DECL_GUTS_VAR(); + if ( ! b ) { return; - + } b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes @@ -2767,8 +2712,9 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == YY_CURRENT_BUFFER ) + if ( b == YY_CURRENT_BUFFER ) { yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + } } %if-c-or-c++ @@ -2785,24 +2731,24 @@ void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) %endif { - M4_YY_DECL_GUTS_VAR(); - if (new_buffer == NULL) + M4_YY_DECL_GUTS_VAR(); + if (new_buffer == NULL) { return; - + } yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { + if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); - } + } /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) + if (YY_CURRENT_BUFFER) { YY_G(yy_buffer_stack_top)++; + } YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ @@ -2824,15 +2770,15 @@ void yypop_buffer_state (M4_YY_DEF_ONLY_ARG) void yyFlexLexer::yypop_buffer_state (void) %endif { - M4_YY_DECL_GUTS_VAR(); - if (!YY_CURRENT_BUFFER) + M4_YY_DECL_GUTS_VAR(); + if (!YY_CURRENT_BUFFER) { return; - + } yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); YY_CURRENT_BUFFER_LVALUE = NULL; - if (YY_G(yy_buffer_stack_top) > 0) + if (YY_G(yy_buffer_stack_top) > 0) { --YY_G(yy_buffer_stack_top); - + } if (YY_CURRENT_BUFFER) { yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); YY_G(yy_did_buffer_switch_on_eof) = 1; @@ -2853,21 +2799,20 @@ void yyFlexLexer::yyensure_buffer_stack(void) %endif { yy_size_t num_to_alloc; - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); if (!YY_G(yy_buffer_stack)) { - /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) + if ( ! YY_G(yy_buffer_stack) ) { YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + } memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -2876,8 +2821,7 @@ void yyFlexLexer::yyensure_buffer_stack(void) return; } - if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){ - + if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1) { /* Increase the buffer to prepare for a possible push. */ yy_size_t grow_size = 8 /* arbitrary grow size */; @@ -2886,9 +2830,9 @@ void yyFlexLexer::yyensure_buffer_stack(void) (YY_G(yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) + if ( ! YY_G(yy_buffer_stack) ) { YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + } /* zero only the new slots.*/ memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); YY_G(yy_buffer_stack_max) = num_to_alloc; @@ -2911,18 +2855,18 @@ m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) { YY_BUFFER_STATE b; - m4_dnl M4_YY_DECL_GUTS_VAR(); + m4_dnl M4_YY_DECL_GUTS_VAR(); if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) + base[size-1] != YY_END_OF_BUFFER_CHAR ) { /* They forgot to leave room for the EOB's. */ return NULL; - + } b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) + if ( ! b ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - + } b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; @@ -2954,7 +2898,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, */ YY_BUFFER_STATE yy_scan_string YYFARGS1( const char *, yystr) { - m4_dnl M4_YY_DECL_GUTS_VAR(); + m4_dnl M4_YY_DECL_GUTS_VAR(); return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); } @@ -2972,29 +2916,28 @@ m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, * M4_YY_DOC_PARAM * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) -{ +YY_BUFFER_STATE yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; - m4_dnl M4_YY_DECL_GUTS_VAR(); + m4_dnl M4_YY_DECL_GUTS_VAR(); /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); - if ( ! buf ) + if ( ! buf ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) + } + for ( i = 0; i < _yybytes_len; ++i ) { buf[i] = yybytes[i]; - + } buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); - if ( ! b ) + if ( ! b ) { YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - + } /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ @@ -3009,31 +2952,30 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ %if-c-only - static void yy_push_state YYFARGS1( int ,_new_state) +static void yy_push_state YYFARGS1( int ,_new_state) %endif %if-c++-only - void yyFlexLexer::yy_push_state( int _new_state ) +void yyFlexLexer::yy_push_state( int _new_state ) %endif { - M4_YY_DECL_GUTS_VAR(); - if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) - { + M4_YY_DECL_GUTS_VAR(); + if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) { yy_size_t new_size; YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; new_size = (yy_size_t) YY_G(yy_start_stack_depth) * sizeof( int ); - if ( ! YY_G(yy_start_stack) ) + if ( ! YY_G(yy_start_stack) ) { YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); - else + } else { YY_G(yy_start_stack) = (int *) yyrealloc( (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); - - if ( ! YY_G(yy_start_stack) ) + } + if ( ! YY_G(yy_start_stack) ) { YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } - + } YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; BEGIN(_new_state); @@ -3044,16 +2986,16 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, m4_ifdef( [[M4_YY_NO_POP_STATE]],, [[ %if-c-only - static void yy_pop_state (M4_YY_DEF_ONLY_ARG) +static void yy_pop_state (M4_YY_DEF_ONLY_ARG) %endif %if-c++-only - void yyFlexLexer::yy_pop_state() +void yyFlexLexer::yy_pop_state() %endif { - M4_YY_DECL_GUTS_VAR(); - if ( --YY_G(yy_start_stack_ptr) < 0 ) + M4_YY_DECL_GUTS_VAR(); + if ( --YY_G(yy_start_stack_ptr) < 0 ) { YY_FATAL_ERROR( "start-condition stack underflow" ); - + } BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); } ]]) @@ -3062,13 +3004,13 @@ m4_ifdef( [[M4_YY_NO_POP_STATE]],, m4_ifdef( [[M4_YY_NO_TOP_STATE]],, [[ %if-c-only - static int yy_top_state (M4_YY_DEF_ONLY_ARG) +static int yy_top_state (M4_YY_DEF_ONLY_ARG) %endif %if-c++-only - int yyFlexLexer::yy_top_state() +int yyFlexLexer::yy_top_state() %endif { - M4_YY_DECL_GUTS_VAR(); + M4_YY_DECL_GUTS_VAR(); return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; } ]]) @@ -3078,8 +3020,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, #endif %if-c-only -static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) -{ +static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); fprintf( stderr, "%s\n", msg ); @@ -3087,9 +3028,8 @@ static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) } %endif %if-c++-only -void yyFlexLexer::LexerError( const char* msg ) -{ - M4_YY_DECL_GUTS_VAR(); +void yyFlexLexer::LexerError( const char* msg ) { + M4_YY_DECL_GUTS_VAR(); std::cerr << msg << std::endl; exit( YY_EXIT_FAILURE ); } @@ -3099,18 +3039,16 @@ void yyFlexLexer::LexerError( const char* msg ) #undef yyless #define yyless(n) \ - do \ - { \ + do { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = YY_G(yy_hold_char); \ - YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ - *YY_G(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = YY_G(yy_hold_char); \ + YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ + YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ + *YY_G(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } while ( 0 ) @@ -3123,10 +3061,9 @@ m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, /** Get the user-defined data for this scanner. * M4_YY_DOC_PARAM */ -YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyextra; +YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyextra; } ]]) %endif @@ -3136,16 +3073,15 @@ m4_ifdef( [[M4_YY_NO_GET_LINENO]],, /** Get the current line number. * M4_YY_DOC_PARAM */ -int yyget_lineno (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); +int yyget_lineno (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (! YY_CURRENT_BUFFER) - return 0; - ]]) - return yylineno; + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + if (! YY_CURRENT_BUFFER) + return 0; + ]]) + return yylineno; } ]]) @@ -3156,16 +3092,15 @@ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, /** Get the current column number. * M4_YY_DOC_PARAM */ -int yyget_column (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); +int yyget_column (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (! YY_CURRENT_BUFFER) - return 0; - ]]) - return yycolumn; +m4_ifdef( [[M4_YY_REENTRANT]], [[ + if (! YY_CURRENT_BUFFER) { + return 0; + } +]]) + return yycolumn; } ]]) ]]) @@ -3175,10 +3110,9 @@ m4_ifdef( [[M4_YY_NO_GET_IN]],, /** Get the input stream. * M4_YY_DOC_PARAM */ -FILE *yyget_in (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyin; +FILE *yyget_in (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyin; } ]]) @@ -3187,10 +3121,9 @@ m4_ifdef( [[M4_YY_NO_GET_OUT]],, /** Get the output stream. * M4_YY_DOC_PARAM */ -FILE *yyget_out (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyout; +FILE *yyget_out (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyout; } ]]) @@ -3199,10 +3132,9 @@ m4_ifdef( [[M4_YY_NO_GET_LENG]],, /** Get the length of the current token. * M4_YY_DOC_PARAM */ -int yyget_leng (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yyleng; +int yyget_leng (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyleng; } ]]) @@ -3211,10 +3143,9 @@ int yyget_leng (M4_YY_DEF_ONLY_ARG) */ m4_ifdef( [[M4_YY_NO_GET_TEXT]],, [[ -char *yyget_text (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yytext; +char *yyget_text (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yytext; } ]]) @@ -3225,10 +3156,9 @@ m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, * @param user_defined The data to be associated with this scanner. * M4_YY_DOC_PARAM */ -void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) -{ - M4_YY_DECL_GUTS_VAR(); - yyextra = user_defined ; +void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) { + M4_YY_DECL_GUTS_VAR(); + yyextra = user_defined ; } ]]) %endif @@ -3239,17 +3169,17 @@ m4_ifdef( [[M4_YY_NO_SET_LINENO]],, * @param _line_number line number * M4_YY_DOC_PARAM */ -void yyset_lineno YYFARGS1( int ,_line_number) -{ - M4_YY_DECL_GUTS_VAR(); +void yyset_lineno YYFARGS1( int ,_line_number) { + M4_YY_DECL_GUTS_VAR(); - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - ]]) - yylineno = _line_number; + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) { + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + } + ]]) + yylineno = _line_number; } ]]) @@ -3261,17 +3191,16 @@ m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, * @param _column_no column number * M4_YY_DOC_PARAM */ -void yyset_column YYFARGS1( int , _column_no) -{ - M4_YY_DECL_GUTS_VAR(); +void yyset_column YYFARGS1( int , _column_no) { + M4_YY_DECL_GUTS_VAR(); - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - ]]) - yycolumn = _column_no; +m4_ifdef( [[M4_YY_REENTRANT]], [[ + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) { + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + } +]]) + yycolumn = _column_no; } ]]) ]]) @@ -3285,38 +3214,34 @@ m4_ifdef( [[M4_YY_NO_SET_IN]],, * M4_YY_DOC_PARAM * @see yy_switch_to_buffer */ -void yyset_in YYFARGS1( FILE * ,_in_str) -{ - M4_YY_DECL_GUTS_VAR(); - yyin = _in_str ; +void yyset_in YYFARGS1( FILE * ,_in_str) { + M4_YY_DECL_GUTS_VAR(); + yyin = _in_str ; } ]]) m4_ifdef( [[M4_YY_NO_SET_OUT]],, [[ -void yyset_out YYFARGS1( FILE * ,_out_str) -{ - M4_YY_DECL_GUTS_VAR(); - yyout = _out_str ; +void yyset_out YYFARGS1( FILE * ,_out_str) { + M4_YY_DECL_GUTS_VAR(); + yyout = _out_str ; } ]]) m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ -int yyget_debug (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yy_flex_debug; +int yyget_debug (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yy_flex_debug; } ]]) m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ -void yyset_debug YYFARGS1( int ,_bdebug) -{ - M4_YY_DECL_GUTS_VAR(); - yy_flex_debug = _bdebug ; +void yyset_debug YYFARGS1( int ,_bdebug) { + M4_YY_DECL_GUTS_VAR(); + yy_flex_debug = _bdebug ; } ]]) %endif @@ -3327,41 +3252,37 @@ void yyset_debug YYFARGS1( int ,_bdebug) %if-bison-bridge m4_ifdef( [[M4_YY_NO_GET_LVAL]],, [[ -YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yylval; +YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yylval; } ]]) m4_ifdef( [[M4_YY_NO_SET_LVAL]],, [[ -void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) -{ - M4_YY_DECL_GUTS_VAR(); - yylval = yylval_param; +void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) { + M4_YY_DECL_GUTS_VAR(); + yylval = yylval_param; } ]]) m4_ifdef( [[]], [[ - m4_ifdef( [[M4_YY_NO_GET_LLOC]],, - [[ -YYLTYPE *yyget_lloc (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - return yylloc; +m4_ifdef( [[M4_YY_NO_GET_LLOC]],, +[[ +YYLTYPE *yyget_lloc (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yylloc; } - ]]) +]]) - m4_ifdef( [[M4_YY_NO_SET_LLOC]],, - [[ -void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) -{ - M4_YY_DECL_GUTS_VAR(); - yylloc = yylloc_param; +m4_ifdef( [[M4_YY_NO_SET_LLOC]],, +[[ +void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) { + M4_YY_DECL_GUTS_VAR(); + yylloc = yylloc_param; } - ]]) +]]) ]]) %endif @@ -3373,24 +3294,23 @@ void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } +int yylex_init(yyscan_t* ptr_yy_globals) { + if (ptr_yy_globals == NULL) { + errno = EINVAL; + return 1; + } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } + if (*ptr_yy_globals == NULL) { + errno = ENOMEM; + return 1; + } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - return yy_init_globals ( *ptr_yy_globals ); + return yy_init_globals ( *ptr_yy_globals ); } @@ -3401,106 +3321,103 @@ int yylex_init(yyscan_t* ptr_yy_globals) * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { + struct yyguts_t dummy_yyguts; - yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); - return yy_init_globals ( *ptr_yy_globals ); + return yy_init_globals ( *ptr_yy_globals ); } %endif if-c-only %# Actually, that ended an if-rentrant section %if-c-only -static int yy_init_globals (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ +static int yy_init_globals (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ m4_ifdef( [[M4_YY_USE_LINENO]], [[ m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ - /* We do not touch yylineno unless the option is enabled. */ - yylineno = 1; + /* We do not touch yylineno unless the option is enabled. */ + yylineno = 1; ]]) ]]) - YY_G(yy_buffer_stack) = NULL; - YY_G(yy_buffer_stack_top) = 0; - YY_G(yy_buffer_stack_max) = 0; - YY_G(yy_c_buf_p) = NULL; - YY_G(yy_init) = 0; - YY_G(yy_start) = 0; + YY_G(yy_buffer_stack) = NULL; + YY_G(yy_buffer_stack_top) = 0; + YY_G(yy_buffer_stack_max) = 0; + YY_G(yy_c_buf_p) = NULL; + YY_G(yy_init) = 0; + YY_G(yy_start) = 0; m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], [[ - YY_G(yy_start_stack_ptr) = 0; - YY_G(yy_start_stack_depth) = 0; - YY_G(yy_start_stack) = NULL; + YY_G(yy_start_stack_ptr) = 0; + YY_G(yy_start_stack_depth) = 0; + YY_G(yy_start_stack) = NULL; ]]) m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - YY_G(yy_state_buf) = 0; - YY_G(yy_state_ptr) = 0; - YY_G(yy_full_match) = 0; - YY_G(yy_lp) = 0; + YY_G(yy_state_buf) = 0; + YY_G(yy_state_ptr) = 0; + YY_G(yy_full_match) = 0; + YY_G(yy_lp) = 0; ]]) m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], [[ - YY_G(yytext_ptr) = 0; - YY_G(yy_more_offset) = 0; - YY_G(yy_prev_more_offset) = 0; + YY_G(yytext_ptr) = 0; + YY_G(yy_more_offset) = 0; + YY_G(yy_prev_more_offset) = 0; ]]) /* Defined in main.c */ #ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; + yyin = stdin; + yyout = stdout; #else - yyin = NULL; - yyout = NULL; + yyin = NULL; + yyout = NULL; #endif - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; } %endif %if-c-only SNIP! this currently causes conflicts with the c++ scanner /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (M4_YY_DEF_ONLY_ARG) -{ - M4_YY_DECL_GUTS_VAR(); +int yylex_destroy (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER) { yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(M4_YY_CALL_ONLY_ARG); @@ -3512,27 +3429,27 @@ int yylex_destroy (M4_YY_DEF_ONLY_ARG) m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], [[ - /* Destroy the start condition stack. */ + /* Destroy the start condition stack. */ yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); YY_G(yy_start_stack) = NULL; ]]) m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); - YY_G(yy_state_buf) = NULL; + yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); + YY_G(yy_state_buf) = NULL; ]]) - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( M4_YY_CALL_ONLY_ARG); + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( M4_YY_CALL_ONLY_ARG); %if-reentrant - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); - yyscanner = NULL; + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); + yyscanner = NULL; %endif - return 0; + return 0; } %endif @@ -3547,14 +3464,14 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ #ifndef yytext_ptr -static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) -{ +static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); int i; - for ( i = 0; i < n; ++i ) + for ( i = 0; i < n; ++i ) { s1[i] = s2[i]; + } } #endif ]]) @@ -3575,8 +3492,7 @@ static int yy_flex_strlen YYFARGS1( const char *,s) m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, [[ -void *yyalloc YYFARGS1( yy_size_t ,size) -{ +void *yyalloc YYFARGS1( yy_size_t ,size) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); return malloc(size); @@ -3585,8 +3501,7 @@ void *yyalloc YYFARGS1( yy_size_t ,size) m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, [[ -void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) -{ +void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); @@ -3603,8 +3518,7 @@ void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, [[ -void yyfree YYFARGS1( void *,ptr) -{ +void yyfree YYFARGS1( void *,ptr) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ @@ -3614,394 +3528,397 @@ void yyfree YYFARGS1( void *,ptr) %if-tables-serialization definitions m4preproc_include(`tables_shared.c') -static int yytbl_read8 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - rd->bread += (flex_uint32_t) sizeof(flex_uint8_t); - return 0; +static int yytbl_read8 (void *v, struct yytbl_reader * rd) { + errno = 0; + if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ + errno = EIO; + return -1; + } + rd->bread += (flex_uint32_t) sizeof(flex_uint8_t); + return 0; } -static int yytbl_read16 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); - rd->bread += (flex_uint32_t) sizeof(flex_uint16_t); - return 0; +static int yytbl_read16 (void *v, struct yytbl_reader * rd) { + errno = 0; + if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ + errno = EIO; + return -1; + } + *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); + rd->bread += (flex_uint32_t) sizeof(flex_uint16_t); + return 0; } -static int yytbl_read32 (void *v, struct yytbl_reader * rd) -{ - errno = 0; - if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ - errno = EIO; - return -1; - } - *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); - rd->bread += (flex_uint32_t) sizeof(flex_uint32_t); - return 0; +static int yytbl_read32 (void *v, struct yytbl_reader * rd) { + errno = 0; + if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ + errno = EIO; + return -1; + } + *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); + rd->bread += (flex_uint32_t) sizeof(flex_uint32_t); + return 0; } /** Read the header */ -static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) -{ - size_t bytes; - memset (th, 0, sizeof (struct yytbl_hdr)); - - if (yytbl_read32 (&(th->th_magic), rd) != 0) - return -1; - - if (th->th_magic != YYTBL_MAGIC){ - YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ - return -1; - } - - if (yytbl_read32 (&(th->th_hsize), rd) != 0 - || yytbl_read32 (&(th->th_ssize), rd) != 0 - || yytbl_read16 (&(th->th_flags), rd) != 0) - return -1; - - /* Sanity check on header size. Greater than 1k suggests some funny business. */ - if (th->th_hsize < 16 || th->th_hsize > 1024){ - YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate enough space for the version and name fields */ - bytes = th->th_hsize - 14; - th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! th->th_version ) - YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); - - /* we read it all into th_version, and point th_name into that data */ - if (fread (th->th_version, 1, bytes, rd->fp) != bytes){ - errno = EIO; - yyfree(th->th_version M4_YY_CALL_LAST_ARG); - th->th_version = NULL; - return -1; - } - else - rd->bread += (flex_uint32_t) bytes; - - th->th_name = th->th_version + strlen (th->th_version) + 1; - return 0; +static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) { + size_t bytes; + memset (th, 0, sizeof (struct yytbl_hdr)); + + if (yytbl_read32 (&(th->th_magic), rd) != 0) { + return -1; + } + if (th->th_magic != YYTBL_MAGIC) { + YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ + return -1; + } + + if (yytbl_read32 (&(th->th_hsize), rd) != 0 + || yytbl_read32 (&(th->th_ssize), rd) != 0 + || yytbl_read16 (&(th->th_flags), rd) != 0) { + return -1; + } + /* Sanity check on header size. Greater than 1k suggests some funny business. */ + if (th->th_hsize < 16 || th->th_hsize > 1024) { + YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ + return -1; + } + + /* Allocate enough space for the version and name fields */ + bytes = th->th_hsize - 14; + th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); + if ( ! th->th_version ) { + YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); + } + /* we read it all into th_version, and point th_name into that data */ + if (fread (th->th_version, 1, bytes, rd->fp) != bytes) { + errno = EIO; + yyfree(th->th_version M4_YY_CALL_LAST_ARG); + th->th_version = NULL; + return -1; + } else { + rd->bread += (flex_uint32_t) bytes; + } + th->th_name = th->th_version + strlen (th->th_version) + 1; + return 0; } /** lookup id in the dmap list. * @param dmap pointer to first element in list * @return NULL if not found. */ -static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, - int, id) -{ - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); +static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, int, id) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); - while (dmap->dm_id) - if ((int)(dmap->dm_id) == id) - return dmap; - else - dmap++; - return NULL; + while (dmap->dm_id) { + if ((int)(dmap->dm_id) == id) { + return dmap; + } else { + dmap++; + } + } + return NULL; } /** Read a table while mapping its contents to the local array. * @param dmap used to performing mapping * @return 0 on success */ -static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) -{ - struct yytbl_data td; - struct yytbl_dmap *transdmap=0; - int len, i, rv, inner_loop_count; - void *p=0; - - memset (&td, 0, sizeof (struct yytbl_data)); - - if (yytbl_read16 (&td.td_id, rd) != 0 - || yytbl_read16 (&td.td_flags, rd) != 0 - || yytbl_read32 (&td.td_hilen, rd) != 0 - || yytbl_read32 (&td.td_lolen, rd) != 0) - return -1; - - /* Lookup the map for the transition table so we have it in case we need it - * inside the loop below. This scanner might not even have a transition - * table, which is ok. - */ - transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); +static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) { + struct yytbl_data td; + struct yytbl_dmap *transdmap=0; + int len, i, rv, inner_loop_count; + void *p=0; + + memset (&td, 0, sizeof (struct yytbl_data)); + + if (yytbl_read16 (&td.td_id, rd) != 0 + || yytbl_read16 (&td.td_flags, rd) != 0 + || yytbl_read32 (&td.td_hilen, rd) != 0 + || yytbl_read32 (&td.td_lolen, rd) != 0) { + return -1; + } + /* Lookup the map for the transition table so we have it in case we need it + * inside the loop below. This scanner might not even have a transition + * table, which is ok. + */ + transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); + + if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL) { + YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ + return -1; + } - if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){ - YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ - return -1; - } + /* Allocate space for table. + * The --full yy_transition table is a special case, since we + * need the dmap.dm_sz entry to tell us the sizeof the individual + * struct members. + */ + { + size_t bytes; - /* Allocate space for table. - * The --full yy_transition table is a special case, since we - * need the dmap.dm_sz entry to tell us the sizeof the individual - * struct members. - */ - { - size_t bytes; - - if ((td.td_flags & YYTD_STRUCT)) - bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); - else - bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; - - if(M4_YY_TABLES_VERIFY) - /* We point to the array itself */ - p = dmap->dm_arr; - else - /* We point to the address of a pointer. */ - *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! p ) - YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); - } - - /* If it's a struct, we read 2 integers to get one element */ - if ((td.td_flags & YYTD_STRUCT) != 0) - inner_loop_count = 2; - else - inner_loop_count = 1; - - /* read and map each element. - * This loop iterates once for each element of the td_data array. - * Notice that we increment 'i' in the inner loop. - */ - len = yytbl_calc_total_len (&td); - for (i = 0; i < len; ){ - int j; - - - /* This loop really executes exactly 1 or 2 times. - * The second time is to handle the second member of the - * YYTD_STRUCT for the yy_transition array. - */ - for (j = 0; j < inner_loop_count; j++, i++) { - flex_int32_t t32; - - /* read into t32 no matter what the real size is. */ - { - flex_int16_t t16; - flex_int8_t t8; - - switch (YYTDFLAGS2BYTES (td.td_flags)) { - case sizeof (flex_int32_t): - rv = yytbl_read32 (&t32, rd); - break; - case sizeof (flex_int16_t): - rv = yytbl_read16 (&t16, rd); - t32 = t16; - break; - case sizeof (flex_int8_t): - rv = yytbl_read8 (&t8, rd); - t32 = t8; - break; - default: - YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ - return -1; - } - } - if (rv != 0) - return -1; - - /* copy into the deserialized array... */ - - if ((td.td_flags & YYTD_STRUCT)) { - /* t32 is the j'th member of a two-element struct. */ - void *v; - - v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) - : &(((struct yy_trans_info *) p)->yy_nxt); - - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if (M4_YY_TABLES_VERIFY){ - if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); - }else - ((flex_int32_t *) v)[0] = (flex_int32_t) t32; - break; - case sizeof (flex_int16_t): - if (M4_YY_TABLES_VERIFY ){ - if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); - }else - ((flex_int16_t *) v)[0] = (flex_int16_t) t32; - break; - case sizeof(flex_int8_t): - if (M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); - }else - ((flex_int8_t *) v)[0] = (flex_int8_t) t32; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ - return -1; - } - - /* if we're done with j, increment p */ - if (j == 1) - p = (struct yy_trans_info *) p + 1; - } - else if ((td.td_flags & YYTD_PTRANS)) { - /* t32 is an index into the transition array. */ - struct yy_trans_info *v; - - - if (!transdmap){ - YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ - return -1; - } - - if( M4_YY_TABLES_VERIFY) - v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); - else - v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); - - if(M4_YY_TABLES_VERIFY ){ - if( ((struct yy_trans_info **) p)[0] != v) - YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); - }else - ((struct yy_trans_info **) p)[0] = v; - - /* increment p */ - p = (struct yy_trans_info **) p + 1; - } - else { - /* t32 is a plain int. copy data, then incrememnt p. */ - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); - }else - ((flex_int32_t *) p)[0] = (flex_int32_t) t32; - p = ((flex_int32_t *) p) + 1; - break; - case sizeof (flex_int16_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); - }else - ((flex_int16_t *) p)[0] = (flex_int16_t) t32; - p = ((flex_int16_t *) p) + 1; - break; - case sizeof (flex_int8_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); - }else - ((flex_int8_t *) p)[0] = (flex_int8_t) t32; - p = ((flex_int8_t *) p) + 1; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ - return -1; - } - } - } - - } - - /* Now eat padding. */ - { - while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) { - flex_int8_t t8; - if(yytbl_read8(&t8,rd) != 0) - return -1; - } - } - - return 0; + if ((td.td_flags & YYTD_STRUCT)) { + bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); + } else { + bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; + } + if (M4_YY_TABLES_VERIFY) { + /* We point to the array itself */ + p = dmap->dm_arr; + } else { + /* We point to the address of a pointer. */ + *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); + } + if ( ! p ) { + YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); + } + } + + /* If it's a struct, we read 2 integers to get one element */ + if ((td.td_flags & YYTD_STRUCT) != 0) { + inner_loop_count = 2; + } else { + inner_loop_count = 1; + } + /* read and map each element. + * This loop iterates once for each element of the td_data array. + * Notice that we increment 'i' in the inner loop. + */ + len = yytbl_calc_total_len (&td); + for (i = 0; i < len; ) { + int j; + + /* This loop really executes exactly 1 or 2 times. + * The second time is to handle the second member of the + * YYTD_STRUCT for the yy_transition array. + */ + for (j = 0; j < inner_loop_count; j++, i++) { + flex_int32_t t32; + + /* read into t32 no matter what the real size is. */ + { + flex_int16_t t16; + flex_int8_t t8; + + switch (YYTDFLAGS2BYTES (td.td_flags)) { + case sizeof (flex_int32_t): + rv = yytbl_read32 (&t32, rd); + break; + case sizeof (flex_int16_t): + rv = yytbl_read16 (&t16, rd); + t32 = t16; + break; + case sizeof (flex_int8_t): + rv = yytbl_read8 (&t8, rd); + t32 = t8; + break; + default: + YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ + return -1; + } + } + if (rv != 0) { + return -1; + } + /* copy into the deserialized array... */ + + if ((td.td_flags & YYTD_STRUCT)) { + /* t32 is the j'th member of a two-element struct. */ + void *v; + + v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) + : &(((struct yy_trans_info *) p)->yy_nxt); + + switch (dmap->dm_sz) { + case sizeof (flex_int32_t): + if (M4_YY_TABLES_VERIFY) { + if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); + } else { + ((flex_int32_t *) v)[0] = (flex_int32_t) t32; + } + break; + case sizeof (flex_int16_t): + if (M4_YY_TABLES_VERIFY ) { + if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); + } else { + ((flex_int16_t *) v)[0] = (flex_int16_t) t32; + } + break; + case sizeof(flex_int8_t): + if (M4_YY_TABLES_VERIFY ) { + if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); + } else { + ((flex_int8_t *) v)[0] = (flex_int8_t) t32; + } + break; + default: + YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ + return -1; + } + + /* if we're done with j, increment p */ + if (j == 1) { + p = (struct yy_trans_info *) p + 1; + } + } + else if ((td.td_flags & YYTD_PTRANS)) { + /* t32 is an index into the transition array. */ + struct yy_trans_info *v; + + if (!transdmap) { + YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ + return -1; + } + + if( M4_YY_TABLES_VERIFY) { + v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); + } else { + v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); + } + if(M4_YY_TABLES_VERIFY ) { + if( ((struct yy_trans_info **) p)[0] != v) + YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); + } else { + ((struct yy_trans_info **) p)[0] = v; + } + /* increment p */ + p = (struct yy_trans_info **) p + 1; + } + else { + /* t32 is a plain int. copy data, then incrememnt p. */ + switch (dmap->dm_sz) { + case sizeof (flex_int32_t): + if(M4_YY_TABLES_VERIFY ) { + if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) { + YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); + } + } else { + ((flex_int32_t *) p)[0] = (flex_int32_t) t32; + } + p = ((flex_int32_t *) p) + 1; + break; + case sizeof (flex_int16_t): + if(M4_YY_TABLES_VERIFY ) { + if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) { + YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); + } + } else { + ((flex_int16_t *) p)[0] = (flex_int16_t) t32; + } + p = ((flex_int16_t *) p) + 1; + break; + case sizeof (flex_int8_t): + if(M4_YY_TABLES_VERIFY ){ + if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) { + YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); + } + } else { + ((flex_int8_t *) p)[0] = (flex_int8_t) t32; + } + p = ((flex_int8_t *) p) + 1; + break; + default: + YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ + return -1; + } + } + } + + } + + /* Now eat padding. */ + { + while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) { + flex_int8_t t8; + if(yytbl_read8(&t8,rd) != 0) + return -1; + } + } + + return 0; } %define-yytables The name for this specific scanner's tables. /* Find the key and load the DFA tables from the given stream. */ -static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) -{ - int rv=0; - struct yytbl_hdr th; - struct yytbl_reader rd; - - rd.fp = fp; - th.th_version = NULL; - - /* Keep trying until we find the right set of tables or end of file. */ - while (!feof(rd.fp)) { - rd.bread = 0; - if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - - /* A NULL key means choose the first set of tables. */ - if (key == NULL) - break; - - if (strcmp(th.th_name,key) != 0){ - /* Skip ahead to next set */ - fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - else - break; - } - - while (rd.bread < th.th_ssize){ - /* Load the data tables */ - if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - } +static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) { + int rv=0; + struct yytbl_hdr th; + struct yytbl_reader rd; + + rd.fp = fp; + th.th_version = NULL; + + /* Keep trying until we find the right set of tables or end of file. */ + while (!feof(rd.fp)) { + rd.bread = 0; + if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ + rv = -1; + goto return_rv; + } + + /* A NULL key means choose the first set of tables. */ + if (key == NULL) { + break; + } + + if (strcmp(th.th_name,key) != 0) { + /* Skip ahead to next set */ + fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); + yyfree(th.th_version M4_YY_CALL_LAST_ARG); + th.th_version = NULL; + } + else { + break; + } + } + + while (rd.bread < th.th_ssize) { + /* Load the data tables */ + if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ + rv = -1; + goto return_rv; + } + } return_rv: - if(th.th_version){ - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } + if(th.th_version) { + yyfree(th.th_version M4_YY_CALL_LAST_ARG); + th.th_version = NULL; + } - return rv; + return rv; } /** Load the DFA tables for this scanner from the given stream. */ -int yytables_fload YYFARGS1(FILE *, fp) -{ - - if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) - return -1; - return 0; +int yytables_fload YYFARGS1(FILE *, fp) { + if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) { + return -1; + } + return 0; } /** Destroy the loaded tables, freeing memory, etc.. */ -int yytables_destroy (M4_YY_DEF_ONLY_ARG) -{ - struct yytbl_dmap *dmap=0; - - if(!M4_YY_TABLES_VERIFY){ - /* Walk the dmap, freeing the pointers */ - for(dmap=yydmap; dmap->dm_id; dmap++) { - void * v; - v = dmap->dm_arr; - if(v && *(char**)v){ - yyfree(*(char**)v M4_YY_CALL_LAST_ARG); - *(char**)v = NULL; - } - } - } +int yytables_destroy (M4_YY_DEF_ONLY_ARG) { + struct yytbl_dmap *dmap=0; + + if(!M4_YY_TABLES_VERIFY){ + /* Walk the dmap, freeing the pointers */ + for(dmap=yydmap; dmap->dm_id; dmap++) { + void * v; + v = dmap->dm_arr; + if(v && *(char**)v){ + yyfree(*(char**)v M4_YY_CALL_LAST_ARG); + *(char**)v = NULL; + } + } + } - return 0; + return 0; } /* end table serialization code definitions */ @@ -4011,14 +3928,12 @@ int yytables_destroy (M4_YY_DEF_ONLY_ARG) m4_ifdef([[M4_YY_MAIN]], [[ int main (void); -int main () -{ - +int main () { %if-reentrant - yyscan_t lexer; - yylex_init(&lexer); - yylex( lexer ); - yylex_destroy( lexer); + yyscan_t lexer; + yylex_init(&lexer); + yylex( lexer ); + yylex_destroy( lexer); %endif %if-not-reentrant @@ -4045,3 +3960,9 @@ m4_ifdef( [[M4_YY_IN_HEADER]], #endif m4preproc_undivert(1) ]]) + +%# Local Variables: +%# mode:c +%# c-file-style:"k&r" +%# c-basic-offset:8 +%# End: -- cgit v1.2.1 From 34b84d582361a6ce44b0bb4328cb45f5b07071fb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 28 Sep 2020 08:31:19 -0400 Subject: Narrow the driver interface. This patch is a pure refactoring step. It changes the interface between gen.c and the back end so that the method table can shed a number of methods and no headers are generated in gen.c any more. Most methods now return the amount of memory they allocate. Eventually this will be used to add a report on this to the generated code. No diffs in generated code, even without ignoring whitespace. #43 in the retargeting patch series, which turned out not to be finished after all. These is ugly magic in skelout() that needs to be factored out. --- src/cpp_backend.c | 239 ++++++++++++++++++++++++++++++++++-------------------- src/dfa.c | 7 +- src/flexdef.h | 44 +++++----- src/gen.c | 66 ++++----------- src/main.c | 3 +- 5 files changed, 198 insertions(+), 161 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 96e4894..ed1f156 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -33,8 +33,47 @@ #include "flexdef.h" +#include "tables.h" -/* Code specific to the C/C++ back end starts here */ +/* These typedefs are only used for computing footprint sizes, + * You need to make sure they match reality in the skeleton file to + * get accurate numbers, but they don't otherwise matter. + */ +typedef char YY_CHAR; +struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; + +/* Helper fubctions */ + +static const char *cpp_get_int16_decl (void) +{ + return (gentables) + ? "static const flex_int16_t %s[%d] =\n { 0,\n" + : "static const flex_int16_t * %s = 0;\n"; +} + + +static const char *cpp_get_int32_decl (void) +{ + return (gentables) + ? "static const flex_int32_t %s[%d] =\n { 0,\n" + : "static const flex_int32_t * %s = 0;\n"; +} + +static const char *cpp_get_state_decl (void) +{ + return (gentables) + ? "static const yy_state_type %s[%d] =\n { 0,\n" + : "static const yy_state_type * %s = 0;\n"; +} + +static const char *cpp_get_yy_char_decl (void) +{ + return (gentables) + ? "static const YY_CHAR %s[%d] =\n { 0,\n" + : "static const YY_CHAR * %s = 0;\n"; +} + +/* Methods */ static const char *cpp_suffix (void) { @@ -96,6 +135,9 @@ static void cpp_prolog (void) } else { + + + OUT_BEGIN_CODE (); /* In reentrant scanner, stdinit is handled in flex.skl. */ if (do_stdinit) { @@ -393,35 +435,6 @@ static void cpp_comment(const char *txt) out_str("/* [[%s]] */\n", txt); } -static const char *cpp_get_int16_decl (void) -{ - return (gentables) - ? "static const flex_int16_t %s[%d] =\n { 0,\n" - : "static const flex_int16_t * %s = 0;\n"; -} - - -static const char *cpp_get_int32_decl (void) -{ - return (gentables) - ? "static const flex_int32_t %s[%d] =\n { 0,\n" - : "static const flex_int32_t * %s = 0;\n"; -} - -static const char *cpp_get_state_decl (void) -{ - return (gentables) - ? "static const yy_state_type %s[%d] =\n { 0,\n" - : "static const yy_state_type * %s = 0;\n"; -} - -static const char *cpp_get_yy_char_decl (void) -{ - return (gentables) - ? "static const YY_CHAR %s[%d] =\n { 0,\n" - : "static const YY_CHAR * %s = 0;\n"; -} - static void cpp_ntod(size_t num_full_table_rows) // Generate nxt table for ntod { @@ -442,21 +455,21 @@ static void cpp_ntod(size_t num_full_table_rows) out_str ("static const %s *yy_nxt =0;\n", long_align ? "flex_int32_t" : "flex_int16_t"); } + /* It would be no good trying to return an allocation size here, + * as it's not known before table generation is finished. + */ } -static void cpp_mkeoltbl() -// Make end-of-line-table - only used when yylinemo tracking is on -{ - buf_prints (&yydmap_buf, - "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", - "flex_int32_t"); -} - -static void cpp_geneoltbl(size_t sz) +static size_t cpp_geneoltbl(size_t sz) // Generate end-of-line-transitions - only used when yylineno tracking is on { outn ("/* Table of booleans, true if rule could match eol. */"); + if (tablesext) + buf_prints (&yydmap_buf, + "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", + "flex_int32_t"); out_str_dec (cpp_get_int32_decl (), "yy_rule_can_match_eol", sz); + return sizeof(int32_t) * sz; } static void cpp_mkctbl (size_t sz) @@ -476,16 +489,17 @@ static void cpp_mkssltbl (void) "struct yy_trans_info*"); } -static void cpp_gen_yy_trans(size_t sz) +static size_t cpp_gen_yy_trans(size_t sz) // Table of verify for transition and offset to next state. (sic) { if (gentables) out_dec ("static const struct yy_trans_info yy_transition[%d] =\n {\n", sz); else outn ("static const struct yy_trans_info *yy_transition = 0;"); + return sz * sizeof(struct yy_trans_info); } -static void cpp_start_state_list(size_t sz) +static size_t cpp_start_state_list(size_t sz) // Start initializer for table of pointers to start state { /* Table of pointers to start states. */ @@ -493,94 +507,145 @@ static void cpp_start_state_list(size_t sz) out_dec ("static const struct yy_trans_info *yy_start_state_list[%d] =\n", sz); else outn ("static const struct yy_trans_info **yy_start_state_list =0;"); + return sz * sizeof(struct yy_trans_info *); } static void cpp_mkecstbl(void) // Make equivalence-class tables { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", - "YY_CHAR"); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", + "YY_CHAR"); } static void cpp_mkftbl(void) // Make full table { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + // FIXME: why are there two places this is emitted, here and in cpp_gentabs_accept()? + buf_prints (&yydmap_buf, + "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); +} + +static size_t cpp_genftbl(size_t sz) +{ + out_str_dec (long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), + "yy_accept", sz); + return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_gentabs_acclist(void) + +static size_t cpp_gentabs_acclist(size_t sz) // Generate accept list initializer { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + out_str_dec (long_align ? cpp_get_int32_decl () : + cpp_get_int16_decl (), "yy_acclist", sz); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); + return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_gentabs_accept(void) +static size_t cpp_gentabs_accept(size_t sz) // Generate accept table initializer { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + out_str_dec (long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), + "yy_accept", sz); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", + long_align ? "flex_int32_t" : "flex_int16_t"); + return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_gentabs_yy_meta(void) +static size_t cpp_gentabs_yy_meta(size_t sz) // Generate yy_meta table initializer { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", - "YY_CHAR"); + out_str_dec (cpp_get_yy_char_decl (), "yy_meta", sz); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", + "YY_CHAR"); + return sz * sizeof(YY_CHAR); } -static void cpp_gentabs_yy_base(void) +static size_t cpp_gentabs_yy_base(size_t sz) // Generate yy_meta base initializer { - buf_prints (&yydmap_buf, + out_str_dec ((tblend >= INT16_MAX || long_align) ? + cpp_get_int32_decl () : cpp_get_int16_decl (), + "yy_base", sz); + buf_prints (&yydmap_buf, "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", - (tblend >= INT16_MAX + (sz >= INT16_MAX || long_align) ? "flex_int32_t" : "flex_int16_t"); + return sz * ((sz >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_gentabs_yy_def(size_t total_states) +static size_t cpp_gentabs_yy_def(size_t sz) // Generate yy_def initializer { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + out_str_dec ((sz >= INT16_MAX || long_align) ? + cpp_get_int32_decl () : cpp_get_int16_decl (), + "yy_def", sz); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", + (sz >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); + return sz * ((sz >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_gentabs_yy_nxt(size_t total_states) +static size_t cpp_gentabs_yy_nxt(size_t tblafter) // Generate yy_nxt initializer { - buf_prints (&yydmap_buf, + /* Begin generating yy_nxt */ + out_str_dec ((tblafter >= INT16_MAX || long_align) ? + cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_nxt", + tblafter); + buf_prints (&yydmap_buf, "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - (total_states >= INT16_MAX + (tblafter >= INT16_MAX || long_align) ? "flex_int32_t" : "flex_int16_t"); + return tblafter * ((tblafter >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_gentabs_yy_chk(size_t total_states) +static size_t cpp_gentabs_yy_chk(size_t tblafter) // Generate yy_chk initializer { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", - (total_states >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + out_str_dec ((tblafter >= INT16_MAX || long_align) ? + cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_chk", + tblafter); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", + (tblafter >= INT16_MAX + || long_align) ? "flex_int32_t" : "flex_int16_t"); + return tblafter * ((tblafter >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); } -static void cpp_nultrans(int fullspd) +static size_t cpp_nultrans(int fullspd, size_t afterdfa) // Generate nulltrans initializer { - // Making this a backend method may be overzealous. - // How many other languages have to sprcial-case NUL - // because it's a string terminator? - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", - (fullspd) ? "struct yy_trans_info*" : - "flex_int32_t"); + // Making this a backend method may be overzealous. + // How many other languages have to sprcial-case NUL + // because it's a string terminator? + out_str_dec (cpp_get_state_decl (), "yy_NUL_trans", afterdfa); + buf_prints (&yydmap_buf, + "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", + (fullspd) ? "struct yy_trans_info*" : "flex_int32_t"); + return afterdfa * (fullspd ? sizeof(struct yy_trans_info *) : sizeof(int32_t)); +} + +static size_t cpp_debug_header(size_t sz) +{ + out_str_dec (long_align ? cpp_get_int32_decl () : + cpp_get_int16_decl (), "yy_rule_linenum", + sz); + return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); +} + + +static size_t cpp_genecs(size_t size) +{ + out_str_dec (cpp_get_yy_char_decl (), "yy_ec", csize); + return sizeof(YY_CHAR) * size; } static const char *cpp_trans_offset_type(int total_table_size) @@ -609,12 +674,7 @@ struct flex_backend_t cpp_backend = { .table_closer = " };\n", .dyad = " {%4d,%4d },", .comment = cpp_comment, - .get_int16_decl = cpp_get_int16_decl, - .get_int32_decl = cpp_get_int32_decl, - .get_state_decl = cpp_get_state_decl, - .get_yy_char_decl = cpp_get_yy_char_decl, .ntod = cpp_ntod, - .mkeoltbl = cpp_mkeoltbl, .geneoltbl = cpp_geneoltbl, .mkctbl = cpp_mkctbl, .mkssltbl = cpp_mkssltbl, @@ -623,6 +683,7 @@ struct flex_backend_t cpp_backend = { .state_entry_fmt = " &yy_transition[%d],\n", .mkecstbl = cpp_mkecstbl, .mkftbl = cpp_mkftbl, + .genftbl = cpp_genftbl, .gentabs_acclist = cpp_gentabs_acclist, .gentabs_accept = cpp_gentabs_accept, .gentabs_yy_meta = cpp_gentabs_yy_meta, @@ -630,8 +691,10 @@ struct flex_backend_t cpp_backend = { .gentabs_yy_def = cpp_gentabs_yy_def, .gentabs_yy_nxt = cpp_gentabs_yy_nxt, .gentabs_yy_chk = cpp_gentabs_yy_chk, + .genecs = cpp_genecs, .nultrans = cpp_nultrans, .trans_offset_type = cpp_trans_offset_type, + .debug_header = cpp_debug_header, .caseprefix = "case ", .fallthrough = NULL, .endcase = "yyterminate();", diff --git a/src/dfa.c b/src/dfa.c index 83ff70a..ad16de9 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -366,9 +366,12 @@ void increase_max_dfas (void) * * Creates the dfa corresponding to the ndfa we've constructed. The * dfa starts out in state #1. + * + * Return the amound of space, in byyes, allocated for the bxt table. + * In some modes this can be zero. */ -void ntod (void) +size_t ntod (void) { int *accset, ds, nacc, newds; int sym, hashval, numstates, dsize; @@ -771,6 +774,8 @@ void ntod (void) free(accset); free(nset); + + return (yynxt_tbl != NULL) ? (yynxt_tbl->td_hilen * sizeof(int32_t)) : 0; } diff --git a/src/flexdef.h b/src/flexdef.h index b3468ea..38da923 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -320,37 +320,35 @@ struct flex_backend_t { char *table_closer; // How to continue a two-level initializer char *dyad; // How to format and int[2] initializer void (*comment)(const char *); // Wrap a comment line - const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s - const char *(*get_int32_decl)(void); // Format for declaring array initializer of int32s - const char *(*get_state_decl)(void); // Format for declaring array initializer of state values - const char *(*get_yy_char_decl)(void); // Format for declaring array initializer of input chars // Flex table generation - void (*ntod)(size_t); // Generate nxt table for ntod - void (*mkeoltbl)(void); // Make end-of-line table - void (*geneoltbl)(size_t); // Generate end-of-line transitions - void (*mkctbl)(size_t); // Make full-speed compressed table - void (*mkssltbl)(void); // Make start_state_list table - void (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic) - void (*start_state_list)(size_t); // Start initializer for table of pointers to start states - void (*mkftbl)(); // Make full table + void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) + size_t (*geneoltbl)(size_t); // Generate end-of-line transition table initializer start + void (*mkctbl)(size_t); // Make full-speed compressed table initializer start + void (*mkssltbl)(void); // Make start_state_list table initializer start + size_t (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic) + size_t (*start_state_list)(size_t); // Start initializer for table of pointers to start states + void (*mkftbl)(); // Make full table serialization entry + size_t (*genftbl)(size_t); // Make full table initializer start const char *state_entry_fmt; // Format of state table entry - void (*mkecstbl)(void); // Make equivalence-class tables - void (*gentabs_acclist)(void); // Generate accept list initializer - void (*gentabs_accept)(void); // Generate accept table initializer - void (*gentabs_yy_meta)(void); // Generate yy_meta table initializer - void (*gentabs_yy_base)(void); // Generate yy_base table initializer - void (*gentabs_yy_def)(size_t); // Generate yy_def initializer - void (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer - void (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer - void (*nultrans)(int); // Generate nulltrans initializer + void (*mkecstbl)(void); // Make equivalence-class table initializer start + size_t (*gentabs_acclist)(size_t); // Generate accept list initializer start + size_t (*gentabs_accept)(size_t); // Generate accept table initializer start + size_t (*gentabs_yy_meta)(size_t); // Generate yy_meta table initializer start + size_t (*gentabs_yy_base)(size_t); // Generate yy_base table initializer start + size_t (*gentabs_yy_def)(size_t); // Generate yy_def initializer start + size_t (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer start + size_t (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer start + size_t (*genecs)(size_t); // Generates tart of equivalence-class-table initializer + size_t (*nultrans)(int, size_t); // Generate nulltrans initializer const char *(*trans_offset_type)(int); // Compute an efficient type for transition tables + size_t (*debug_header)(size_t); // Start initializer for rule-to-line mappings char *caseprefix; // Prefix of an arm in the language's case construct char *fallthrough; // Finish a case arm with this to fall through char *endcase; // What to ship after all EOF-state case arms int c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; -extern bool gentables; +extern size_t footprint; extern struct flex_backend_t cpp_backend; @@ -759,7 +757,7 @@ extern int *epsclosure(int *, int *, int[], int *, int *); /* Increase the maximum number of dfas. */ extern void increase_max_dfas(void); -extern void ntod(void); /* convert a ndfa to a dfa */ +extern size_t ntod(void); /* convert a ndfa to a dfa */ /* Converts a set of ndfa states into a dfa state. */ extern int snstods(int[], int, int[], int, int, int *); diff --git a/src/gen.c b/src/gen.c index df0080c..de60942 100644 --- a/src/gen.c +++ b/src/gen.c @@ -34,7 +34,6 @@ #include "flexdef.h" #include "tables.h" - /* declare functions that have forward references */ void genecs(void); @@ -58,7 +57,6 @@ static struct yytbl_data *mkeoltbl (void) for (i = 1; i <= num_rules; i++) tdata[i] = rule_has_nl[i] ? 1 : 0; - backend->mkeoltbl(); return tbl; } @@ -68,7 +66,7 @@ static void geneoltbl (void) int i; outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); - backend->geneoltbl(num_rules + 1); + footprint += backend->geneoltbl(num_rules + 1); if (gentables) { for (i = 1; i <= num_rules; i++) { @@ -222,7 +220,7 @@ void genctbl (void) int end_of_buffer_action = num_rules + 1; /* Table of verify for transition and offset to next state. */ - backend->gen_yy_trans(tblend + numecs + 1); + footprint += backend->gen_yy_trans(tblend + numecs + 1); /* We want the transition to be represented as the offset to the * next state, not the actual state number, which is what it currently @@ -292,7 +290,7 @@ void genctbl (void) if (gentables) outn (backend->table_closer); - backend->start_state_list(lastsc * 2 + 1); + footprint += backend->start_state_list(lastsc * 2 + 1); if (gentables) { outn (backend->table_opener); @@ -342,7 +340,7 @@ void genecs (void) int ch, row; int numrows; - out_str_dec (backend->get_yy_char_decl (), "yy_ec", csize); + footprint += backend->genecs(csize); for (ch = 1; ch < csize; ++ch) { ecgroup[ch] = ABS (ecgroup[ch]); @@ -414,9 +412,7 @@ void genftbl (void) int i; int end_of_buffer_action = num_rules + 1; - out_str_dec (long_align ? backend->get_int32_decl () : backend->get_int16_decl (), - "yy_accept", lastdfa + 1); - + footprint += backend->genftbl(lastdfa+1); dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; for (i = 1; i <= lastdfa; ++i) { @@ -477,11 +473,7 @@ void gentabs (void) dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list; - out_str_dec (long_align ? backend->get_int32_decl () : - backend->get_int16_decl (), "yy_acclist", MAX (numas, - 1) + 1); - - backend->gentabs_acclist(); + footprint += backend->gentabs_acclist(MAX (numas, 1) + 1); yyacclist_tbl = calloc(1,sizeof(struct yytbl_data)); yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST); @@ -585,10 +577,7 @@ void gentabs (void) */ ++k; - out_str_dec (long_align ? backend->get_int32_decl () : backend->get_int16_decl (), - "yy_accept", k); - - backend->gentabs_accept(); + footprint += backend->gentabs_accept(k); yyacc_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT); @@ -658,8 +647,7 @@ void gentabs (void) fputs (_("\n\nMeta-Equivalence Classes:\n"), stderr); - out_str_dec (backend->get_yy_char_decl (), "yy_meta", numecs + 1); - backend->gentabs_yy_meta(); + footprint += backend->gentabs_yy_meta(numecs + 1); for (i = 1; i <= numecs; ++i) { if (trace) @@ -684,11 +672,7 @@ void gentabs (void) total_states = lastdfa + numtemps; /* Begin generating yy_base */ - out_str_dec ((tblend >= INT16_MAX || long_align) ? - backend->get_int32_decl () : backend->get_int16_decl (), - "yy_base", total_states + 1); - - backend->gentabs_yy_base(); + footprint += backend->gentabs_yy_base(total_states + 1); yybase_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yybase_tbl, YYTD_ID_BASE); yybase_tbl->td_lolen = (flex_uint32_t) (total_states + 1); @@ -738,15 +722,11 @@ void gentabs (void) /* Begin generating yy_def */ - out_str_dec ((total_states >= INT16_MAX || long_align) ? - backend->get_int32_decl () : backend->get_int16_decl (), - "yy_def", total_states + 1); - - backend->gentabs_yy_def(total_states); + footprint += backend->gentabs_yy_def(total_states +1); yydef_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yydef_tbl, YYTD_ID_DEF); - yydef_tbl->td_lolen = (flex_uint32_t) (total_states + 1); + yydef_tbl->td_lolen = (flex_uint32_t)(total_states + 1); yydef_tbl->td_data = yydef_data = calloc(yydef_tbl->td_lolen, sizeof (flex_int32_t)); @@ -766,12 +746,7 @@ void gentabs (void) /* End generating yy_def */ - /* Begin generating yy_nxt */ - out_str_dec ((total_states >= INT16_MAX || long_align) ? - backend->get_int32_decl () : backend->get_int16_decl (), "yy_nxt", - tblend + 1); - - backend->gentabs_yy_nxt(total_states); + footprint += backend->gentabs_yy_nxt(tblend + 1); yynxt_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); @@ -801,11 +776,7 @@ void gentabs (void) /* End generating yy_nxt */ /* Begin generating yy_chk */ - out_str_dec ((total_states >= INT16_MAX || long_align) ? - backend->get_int32_decl () : backend->get_int16_decl (), "yy_chk", - tblend + 1); - - backend->gentabs_yy_chk(total_states); + footprint += backend->gentabs_yy_chk(tblend + 1); yychk_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yychk_tbl, YYTD_ID_CHK); @@ -1079,9 +1050,7 @@ void make_tables (void) flex_int32_t *yynultrans_data = 0; /* Begin generating yy_NUL_trans */ - out_str_dec (backend->get_state_decl (), "yy_NUL_trans", - lastdfa + 1); - backend->nultrans(fullspd); + footprint += backend->nultrans(fullspd, lastdfa + 1); yynultrans_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); // Performance kludge for C. Gives a small improvement @@ -1125,9 +1094,10 @@ void make_tables (void) } if (ddebug) { /* Spit out table mapping rules to line numbers. */ - out_str_dec (long_align ? backend->get_int32_decl () : - backend->get_int16_decl (), "yy_rule_linenum", - num_rules); + /* Policy choice: this returns the table size + * but we don't include it in the table metering. + */ + backend->debug_header(num_rules); for (i = 1; i < num_rules; ++i) mkdata (rule_linenum[i]); dataend (); diff --git a/src/main.c b/src/main.c index 2ba677b..d0851f2 100644 --- a/src/main.c +++ b/src/main.c @@ -111,6 +111,7 @@ struct flex_backend_t *backend; bool tablesext, tablesverify, gentables; char *tablesfilename=0,*tablesname=0; struct yytbl_writer tableswr; +size_t footprint; /* Make sure program_name is initialized so we don't crash if writing * out an error message before getting the program name from argv[0]. @@ -175,7 +176,7 @@ int flex_main (int argc, char *argv[]) skelout (); /* %% [1.5] DFA */ - ntod (); + footprint += ntod (); for (i = 1; i <= num_rules; ++i) if (!rule_useful[i] && i != default_rule) -- cgit v1.2.1 From 4b952cbf80e76c57545611e4a0cccb48a73d0a71 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 29 Sep 2020 05:36:46 -0400 Subject: Eliminate ugly %define-yytables magic in skelout(). This feature is better implemented with m4 macroexpansion; that way skelout() does not have to know that #define is a thing. Also in skelout(), use the backend comment method rather than embedding knowledge about /* and */, and int_format_define to factor out knowedge about #define. Produces only comment diffs in the generated test code. #44 in the retargeting patch series --- src/cpp-flex.skl | 3 +- src/cpp_backend.c | 12 +++++- src/gen.c | 14 +++++-- src/misc.c | 122 +++++++++++++++++++++++++++--------------------------- 4 files changed, 85 insertions(+), 66 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index ac433ce..4090a50 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -3842,7 +3842,8 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read return 0; } -%define-yytables The name for this specific scanner's tables. +/* The name for this specific scanner's tables. */ +#define YYTABLES_NAME "m4_ifdef([[M4_MODE_PREFIX]], M4_MODE_PREFIX, [[yy]])tables" /* Find the key and load the DFA tables from the given stream. */ static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) { diff --git a/src/cpp_backend.c b/src/cpp_backend.c index ed1f156..0c03177 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -432,7 +432,17 @@ static const char *cpp_yy_int_aligned(void) static void cpp_comment(const char *txt) { - out_str("/* [[%s]] */\n", txt); + char buf[MAXLINE]; + bool eol; + + strncpy(buf, txt, MAXLINE-1); + eol = buf[strlen(buf)-1] == '\n'; + + if (eol) + buf[strlen(buf)-1] = '\0'; + out_str("/* [[%s]] */", buf); + if (eol) + outc ('\n'); } static void cpp_ntod(size_t num_full_table_rows) diff --git a/src/gen.c b/src/gen.c index de60942..b49cb1b 100644 --- a/src/gen.c +++ b/src/gen.c @@ -810,6 +810,7 @@ static void visible_define (const char *symname) { out_m4_define(symname, NULL); backend->comment(symname); + outc ('\n'); } /* make_tables - generate transition tables and finishes generating output file @@ -826,7 +827,7 @@ void make_tables (void) // itself; by shoving all this stuff out to the skeleton file // we make it easier to retarget the code generation. - backend->comment("m4 controls begin"); + backend->comment("m4 controls begin\n"); // mode switches for YY_DO_BEFORE_ACTION code generation if (yytext_is_array) @@ -935,7 +936,12 @@ void make_tables (void) if (backend == &cpp_backend && !C_plus_plus) visible_define ( "M4_MODE_C_ONLY"); - backend->comment("m4 controls end"); + if (tablesext) + visible_define ( "M4_MODE_TABLESEXT"); + if (prefix != NULL) + out_m4_define ( "M4_MODE_PREFIX", prefix); // FIXME: should be visible + + backend->comment("m4 controls end\n"); out ("\n"); // There are a couple more modes we can't compute until after @@ -1016,7 +1022,7 @@ void make_tables (void) // Only at this point do we know if the automaton has backups. // Some m4 conditionals require this information. - backend->comment("m4 controls begin"); + backend->comment("m4 controls begin\n"); if (num_backing_up > 0) visible_define ( "M4_MODE_HAS_BACKING_UP"); @@ -1027,7 +1033,7 @@ void make_tables (void) if ((num_backing_up > 0 && !reject) && (fullspd || fulltbl)) visible_define ( "M4_MODE_NULTRANS_WRAP"); - backend->comment("m4 controls end"); + backend->comment("m4 controls end\n"); out ("\n"); if (do_yylineno) { diff --git a/src/misc.c b/src/misc.c index 97bc83e..f4bd807 100644 --- a/src/misc.c +++ b/src/misc.c @@ -35,7 +35,6 @@ #define CMD_IF_TABLES_SER "%if-tables-serialization" #define CMD_TABLES_YYDMAP "%tables-yydmap" -#define CMD_DEFINE_YYTABLES "%define-yytables" #define CMD_IF_CPP_ONLY "%if-c++-only" #define CMD_IF_C_ONLY "%if-c-only" #define CMD_IF_C_OR_CPP "%if-c-or-c++" @@ -102,7 +101,7 @@ void action_define (const char *defname, int value) return; } - snprintf (buf, sizeof(buf), "#define %s %d\n", defname, value); + snprintf (buf, sizeof(buf), backend->int_define_fmt, defname, value); add_action (buf); /* track #defines so we can undef them when we're done. */ @@ -694,11 +693,11 @@ void skelout (void) char *buf = buf_storage; bool do_copy = true; - /* "reset" the state by clearing the buffer and pushing a '1' */ - if(sko_len > 0) - sko_peek(&do_copy); - sko_len = 0; - sko_push(do_copy=true); + /* "reset" the state by clearing the buffer and pushing a '1' */ + if(sko_len > 0) + sko_peek(&do_copy); + sko_len = 0; + sko_push(do_copy=true); /* Loop pulling lines either from the skelfile, if we're using @@ -715,84 +714,87 @@ void skelout (void) if (buf[0] == '%') { /* control line */ /* print the control line as a comment. */ if (ddebug && buf[1] != '#') { - if (buf[strlen (buf) - 1] == '\\') - out_str ("/* %s */\\\n", buf); - else - out_str ("/* %s */\n", buf); + bool escaped = buf[strlen (buf) - 1] == '\\'; + if (escaped) { + backend->comment(buf); + out ("\\\n"); + } else { + backend->comment(buf); + outc ('\n'); + } } /* We've been accused of using cryptic markers in the skel. * So we'll use emacs-style-hyphenated-commands. - * We might consider a hash if this if-else-if-else - * chain gets too large. + * We might consider a hash if this if-else-if-else + * chain gets too large. */ #define cmd_match(s) (strncmp(buf,(s),strlen(s))==0) - if (buf[1] == '#') { - /* %# indicates comment line to be ignored */ - } - else if (buf[1] == '%') { + if (buf[1] == '#') { + /* %# indicates comment line to be ignored */ + } + else if (buf[1] == '%') { /* %% is a break point for skelout() */ return; } - else if (cmd_match (CMD_PUSH)){ - sko_push(do_copy); - if(ddebug){ - out_str("/*(state = (%s) */",do_copy?"true":"false"); - } - out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); - } - else if (cmd_match (CMD_POP)){ - sko_pop(&do_copy); - if(ddebug){ - out_str("/*(state = (%s) */",do_copy?"true":"false"); - } - out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); - } - else if (cmd_match (CMD_IF_REENTRANT)){ - sko_push(do_copy); - do_copy = reentrant && do_copy; - } - else if (cmd_match (CMD_IF_NOT_REENTRANT)){ - sko_push(do_copy); - do_copy = !reentrant && do_copy; - } - else if (cmd_match(CMD_IF_BISON_BRIDGE)){ - sko_push(do_copy); - do_copy = bison_bridge_lval && do_copy; - } - else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)){ - sko_push(do_copy); - do_copy = !bison_bridge_lval && do_copy; - } - else if (cmd_match (CMD_ENDIF)){ - sko_pop(&do_copy); - } + else if (cmd_match (CMD_PUSH)){ + sko_push(do_copy); + if(ddebug){ + char buf2[MAXLINE]; + snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); + backend->comment(buf2); + } + out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); + } + else if (cmd_match (CMD_POP)){ + sko_pop(&do_copy); + if(ddebug){ + char buf2[MAXLINE]; + snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); + backend->comment(buf2); + } + out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); + } + else if (cmd_match (CMD_IF_REENTRANT)){ + sko_push(do_copy); + do_copy = reentrant && do_copy; + } + else if (cmd_match (CMD_IF_NOT_REENTRANT)){ + sko_push(do_copy); + do_copy = !reentrant && do_copy; + } + else if (cmd_match(CMD_IF_BISON_BRIDGE)){ + sko_push(do_copy); + do_copy = bison_bridge_lval && do_copy; + } + else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)){ + sko_push(do_copy); + do_copy = !bison_bridge_lval && do_copy; + } + else if (cmd_match (CMD_ENDIF)){ + sko_pop(&do_copy); + } else if (cmd_match (CMD_IF_TABLES_SER)) { - do_copy = do_copy && tablesext; + do_copy = do_copy && tablesext; } else if (cmd_match (CMD_TABLES_YYDMAP)) { if (tablesext && yydmap_buf.elts) outn ((char *) (yydmap_buf.elts)); } - else if (cmd_match (CMD_DEFINE_YYTABLES)) { - if ( tablesext ) - out_str( "#define YYTABLES_NAME \"%s\"\n", - tablesname ? tablesname : "yytables" ); - } else if (cmd_match (CMD_IF_CPP_ONLY)) { /* only for C++ */ - sko_push(do_copy); + sko_push(do_copy); do_copy = C_plus_plus; } else if (cmd_match (CMD_IF_C_ONLY)) { /* %- only for C */ - sko_push(do_copy); + sko_push(do_copy); do_copy = !C_plus_plus; } else if (cmd_match (CMD_IF_C_OR_CPP)) { /* %* for C and C++ */ - sko_push(do_copy); + sko_push(do_copy); do_copy = true; } else if (cmd_match (CMD_NOT_FOR_HEADER)) { @@ -809,7 +811,7 @@ void skelout (void) } else if (do_copy) - outn (buf); + outn (buf); } /* end while */ } -- cgit v1.2.1 From a9e86a3299fb5871306b36906b7c4f908f1520f0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 29 Sep 2020 08:53:23 -0400 Subject: Eliminate two backend methods in favor of m4 expansion. Produces only whitespace diffs in generated code for tests, except the order of items in the initializer for table serialization changes. #45 in the retargeting patch series --- src/cpp-flex.skl | 3 +++ src/cpp_backend.c | 22 ---------------------- src/flexdef.h | 2 -- src/gen.c | 4 ---- 4 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4090a50..015c462 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1302,6 +1302,9 @@ struct yytbl_dmap { /** A {0,0,0}-terminated list of structs, forming the map */ static struct yytbl_dmap yydmap[] = { +m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]]) +m4_ifdef([[M4_YY_USE_LINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(flex_int32_t)},]]) +m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]]) %tables-yydmap generated elements {0,0,0} }; diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 0c03177..d7d8a99 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -474,10 +474,6 @@ static size_t cpp_geneoltbl(size_t sz) // Generate end-of-line-transitions - only used when yylineno tracking is on { outn ("/* Table of booleans, true if rule could match eol. */"); - if (tablesext) - buf_prints (&yydmap_buf, - "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", - "flex_int32_t"); out_str_dec (cpp_get_int32_decl (), "yy_rule_can_match_eol", sz); return sizeof(int32_t) * sz; } @@ -491,14 +487,6 @@ static void cpp_mkctbl (size_t sz) || long_align) ? "flex_int32_t" : "flex_int16_t"); } -static void cpp_mkssltbl (void) -// Make start_state_list table -{ - buf_prints (&yydmap_buf, - "\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n", - "struct yy_trans_info*"); -} - static size_t cpp_gen_yy_trans(size_t sz) // Table of verify for transition and offset to next state. (sic) { @@ -520,14 +508,6 @@ static size_t cpp_start_state_list(size_t sz) return sz * sizeof(struct yy_trans_info *); } -static void cpp_mkecstbl(void) -// Make equivalence-class tables -{ - buf_prints (&yydmap_buf, - "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", - "YY_CHAR"); -} - static void cpp_mkftbl(void) // Make full table { @@ -687,11 +667,9 @@ struct flex_backend_t cpp_backend = { .ntod = cpp_ntod, .geneoltbl = cpp_geneoltbl, .mkctbl = cpp_mkctbl, - .mkssltbl = cpp_mkssltbl, .gen_yy_trans = cpp_gen_yy_trans, .start_state_list = cpp_start_state_list, .state_entry_fmt = " &yy_transition[%d],\n", - .mkecstbl = cpp_mkecstbl, .mkftbl = cpp_mkftbl, .genftbl = cpp_genftbl, .gentabs_acclist = cpp_gentabs_acclist, diff --git a/src/flexdef.h b/src/flexdef.h index 38da923..f2be31a 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -324,13 +324,11 @@ struct flex_backend_t { void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) size_t (*geneoltbl)(size_t); // Generate end-of-line transition table initializer start void (*mkctbl)(size_t); // Make full-speed compressed table initializer start - void (*mkssltbl)(void); // Make start_state_list table initializer start size_t (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic) size_t (*start_state_list)(size_t); // Start initializer for table of pointers to start states void (*mkftbl)(); // Make full table serialization entry size_t (*genftbl)(size_t); // Make full table initializer start const char *state_entry_fmt; // Format of state table entry - void (*mkecstbl)(void); // Make equivalence-class table initializer start size_t (*gentabs_acclist)(size_t); // Generate accept list initializer start size_t (*gentabs_accept)(size_t); // Generate accept table initializer start size_t (*gentabs_yy_meta)(size_t); // Generate yy_meta table initializer start diff --git a/src/gen.c b/src/gen.c index b49cb1b..07d95e9 100644 --- a/src/gen.c +++ b/src/gen.c @@ -205,8 +205,6 @@ static struct yytbl_data *mkssltbl (void) for (i = 0; i <= lastsc * 2; ++i) tdata[i] = base[i]; - backend->mkssltbl(); - return tbl; } @@ -328,8 +326,6 @@ static struct yytbl_data *mkecstbl (void) tdata[i] = ecgroup[i]; } - backend->mkecstbl(); - return tbl; } -- cgit v1.2.1 From abe2c1fe700dadb0dcdf52a649ef659a96a9fe3d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 29 Sep 2020 19:16:59 -0400 Subject: Transplant where the mode controls are shipped to earlier. This should make it possible to eliminate much of the C-specific prolog code. Sadly, because of the moves of the generated comments this makes a rather noisy diff. All comments and whitespace, though; what looks like being other than that is pieces of generated code being shifteed around. #46 in the retargeting patch series --- src/cpp-flex.skl | 12 +- src/cpp_backend.c | 1 - src/flexdef.h | 3 + src/gen.c | 104 +---------- src/main.c | 519 +++++++++++++++++++++++++++++++++--------------------- src/misc.c | 2 + 6 files changed, 327 insertions(+), 314 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 015c462..51f3993 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1470,10 +1470,6 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ } ]]) -%# Conditional indirection through an equivalence map -m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) -m4_ifdef([[M4_NOT_MODE_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) - %not-for-header /** The main scanner function which does all the work. */ @@ -1579,8 +1575,12 @@ M4_GEN_START_STATE yy_match: /* Generate the code to find the next match. */ -m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ -m4_ifdef([[M4_MODE_GENTABLES]], [[ +%# Conditional indirection through an equivalence map +m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) +m4_ifdef([[M4_NOT_MODE_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) + +m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl +m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { ]]) m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ diff --git a/src/cpp_backend.c b/src/cpp_backend.c index d7d8a99..1841375 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -473,7 +473,6 @@ static void cpp_ntod(size_t num_full_table_rows) static size_t cpp_geneoltbl(size_t sz) // Generate end-of-line-transitions - only used when yylineno tracking is on { - outn ("/* Table of booleans, true if rule could match eol. */"); out_str_dec (cpp_get_int32_decl (), "yy_rule_can_match_eol", sz); return sizeof(int32_t) * sz; } diff --git a/src/flexdef.h b/src/flexdef.h index f2be31a..d4e7e2b 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -780,6 +780,9 @@ extern void mkechar(int, int[], int[]); extern void do_indent(void); /* indent to the current level */ +/* Set a conmditional amd make it visible in generated code */ +extern void visible_define (const char *symname); + /* Generate full speed compressed transition table. */ extern void genctbl(void); diff --git a/src/gen.c b/src/gen.c index 07d95e9..4084c56 100644 --- a/src/gen.c +++ b/src/gen.c @@ -66,6 +66,7 @@ static void geneoltbl (void) int i; outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); + backend->comment ("Table of booleans, true if rule could match eol.\n"); footprint += backend->geneoltbl(num_rules + 1); if (gentables) { @@ -802,7 +803,7 @@ void gentabs (void) } -static void visible_define (const char *symname) +void visible_define (const char *symname) { out_m4_define(symname, NULL); backend->comment(symname); @@ -818,96 +819,9 @@ void make_tables (void) int did_eof_rule = false; struct yytbl_data *yynultrans_tbl = NULL; - // These are used to conditionalize code in the lex skeleton - // that historically used to be generated by C code in flex - // itself; by shoving all this stuff out to the skeleton file - // we make it easier to retarget the code generation. - backend->comment("m4 controls begin\n"); - // mode switches for YY_DO_BEFORE_ACTION code generation - if (yytext_is_array) - visible_define ( "M4_MODE_YYTEXT_IS_ARRAY"); - else - visible_define ( "M4_MODE_NO_YYTEXT_IS_ARRAY"); - if (yymore_used) - visible_define ( "M4_MODE_YYMORE_USED"); - else - visible_define ( "M4_MODE_NO_YYMORE_USED"); - // mode switches for yy_trans_info specification - if (fullspd) - visible_define ( "M4_MODE_REAL_FULLSPD"); - else - visible_define ( "M4_MODE_NO_REAL_FULLSPD"); - - // niode switches for YYINPUT code generation - if (use_read) - visible_define ( "M4_MODE_CPP_USE_READ"); - else - visible_define ( "M4_MODE_NO_CPP_USE_READ"); - - // mode switches for next-action code - if (variable_trailing_context_rules) { - visible_define ( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES"); - } else { - visible_define ( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES"); - } - if (real_reject) - visible_define ( "M4_MODE_REAL_REJECT"); - if (reject_really_used) - visible_define ( "M4_MODE_FIND_ACTION_REJECT_REALLY_USED"); - if (reject) - visible_define ( "M4_MODE_USES_REJECT"); - else - visible_define ( "M4_MODE_NO_USES_REJECT"); - - // mode switches for computing next compressed state - if (usemecs) - visible_define ( "M4_MODE_USEMECS"); - - // mode switches for find-action code - if (fullspd) - visible_define ( "M4_MODE_FULLSPD"); - else if (fulltbl) - visible_define ( "M4_MODE_FIND_ACTION_FULLTBL"); - else if (reject) - visible_define ( "M4_MODE_FIND_ACTION_REJECT"); - else - visible_define ( "M4_MODE_FIND_ACTION_COMPRESSED"); - - // mode switches for backup generation and gen_start_state - if (!fullspd) - visible_define ( "M4_MODE_NO_FULLSPD"); - if (bol_needed) - visible_define ( "M4_MODE_BOL_NEEDED"); - else - visible_define ( "M4_MODE_NO_BOL_NEEDED"); - - // yylineno - if (do_yylineno) - visible_define ( "M4_MODE_YYLINENO"); - - // Equivalence classes - if (useecs) - visible_define ( "M4_MODE_USEECS"); - else - visible_define ( "M4_NOT_MODE_USEECS"); - - // mode switches for getting next action - if (gentables) - visible_define ( "M4_MODE_GENTABLES"); - else - visible_define ( "M4_MODE_NO_GENTABLES"); - if (interactive) - visible_define ( "M4_MODE_INTERACTIVE"); - else - visible_define ( "M4_MODE_NO_INTERACTIVE"); - if (!(fullspd || fulltbl)) - visible_define ( "M4_MODE_NO_FULLSPD_OR_FULLTBL"); - if (reject || interactive) - visible_define ( "M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE"); - // nultrans if (nultrans) visible_define ( "M4_MODE_NULTRANS"); @@ -923,20 +837,6 @@ void make_tables (void) visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); } - if (ddebug) - visible_define ( "M4_MODE_DEBUG"); - - // Kluge to get around the fact that the %if-not-reentrant and - // %if-c-only gates can't be combined by nesting one inside the - // other. - if (backend == &cpp_backend && !C_plus_plus) - visible_define ( "M4_MODE_C_ONLY"); - - if (tablesext) - visible_define ( "M4_MODE_TABLESEXT"); - if (prefix != NULL) - out_m4_define ( "M4_MODE_PREFIX", prefix); // FIXME: should be visible - backend->comment("m4 controls end\n"); out ("\n"); diff --git a/src/main.c b/src/main.c index d0851f2..863739a 100644 --- a/src/main.c +++ b/src/main.c @@ -150,29 +150,32 @@ int flex_main (int argc, char *argv[]) */ exit_status = setjmp (flex_main_jmp_buf); if (exit_status){ - if (stdout && !_stdout_closed && !ferror(stdout)){ - fflush(stdout); - fclose(stdout); - } - while (wait(&child_status) > 0){ - if (!WIFEXITED (child_status) - || WEXITSTATUS (child_status) != 0){ - /* report an error of a child - */ - if( exit_status <= 1 ) - exit_status = 2; - - } - } - return exit_status - 1; - } + if (stdout && !_stdout_closed && !ferror(stdout)){ + fflush(stdout); + fclose(stdout); + } + while (wait(&child_status) > 0){ + if (!WIFEXITED (child_status) + || WEXITSTATUS (child_status) != 0){ + /* report an error of a child + */ + if( exit_status <= 1 ) + exit_status = 2; + + } + } + return exit_status - 1; + } flexinit (argc, argv); readin (); - if (backend->prolog) + if (backend->prolog) { + backend->comment("prolog begins\n"); backend->prolog (); + backend->comment("prolog ends\n"); + } skelout (); /* %% [1.5] DFA */ @@ -219,7 +222,7 @@ int main (int argc, char *argv[]) void check_options (void) { int i; - const char * m4 = NULL; + const char * m4 = NULL; if (lex_compat) { if (C_plus_plus) @@ -337,10 +340,10 @@ void check_options (void) } - /* Setup the filter chain. */ - output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); - if ( !(m4 = getenv("M4"))) { - char *slash; + /* Setup the filter chain. */ + output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); + if ( !(m4 = getenv("M4"))) { + char *slash; m4 = M4; if ((slash = strrchr(M4, '/')) != NULL) { m4 = slash+1; @@ -365,7 +368,7 @@ void check_options (void) m4_path[endOfDir-path] = '/'; memcpy(m4_path + (endOfDir-path) + 1, m4, m4_length + 1); if (stat(m4_path, &sbuf) == 0 && - (S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) { + (S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) { m4 = m4_path; break; } @@ -374,19 +377,19 @@ void check_options (void) path = endOfDir+1; } while (path[0]); if (!path[0]) - m4 = M4; + m4 = M4; } } } - filter_create_ext(output_chain, m4, "-P", 0); - filter_create_int(output_chain, filter_fix_linedirs, NULL); + filter_create_ext(output_chain, m4, "-P", 0); + filter_create_int(output_chain, filter_fix_linedirs, NULL); - /* For debugging, only run the requested number of filters. */ - if (preproc_level > 0) { - filter_truncate(output_chain, preproc_level); - filter_apply_chain(output_chain); - } - yyout = stdout; + /* For debugging, only run the requested number of filters. */ + if (preproc_level > 0) { + filter_truncate(output_chain, preproc_level); + filter_apply_chain(output_chain); + } + yyout = stdout; /* always generate the tablesverify flag. */ @@ -433,7 +436,7 @@ void check_options (void) lerr (_("can't open skeleton file %s"), skelname); if (reentrant) { - buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL); + buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL); if (yytext_is_array) buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL); } @@ -442,11 +445,11 @@ void check_options (void) buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); if ( bison_bridge_lloc) - buf_m4_define (&m4defs_buf, "", NULL); + buf_m4_define (&m4defs_buf, "", NULL); - if (strchr(prefix, '[') || strchr(prefix, ']')) - flexerror(_("Prefix cannot include '[' or ']'")); - buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix); + if (strchr(prefix, '[') || strchr(prefix, ']')) + flexerror(_("Prefix cannot include '[' or ']'")); + buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix); if (did_outfilename) line_directive_out (stdout, 0); @@ -459,29 +462,29 @@ void check_options (void) /* Define the start condition macros. */ { - struct Buf tmpbuf; - buf_init(&tmpbuf, sizeof(char)); - for (i = 1; i <= lastsc; i++) { - char *str, *fmt = backend->int_define_fmt; - size_t strsz; - - strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; - str = malloc(strsz); - if (!str) - flexfatal(_("allocation of macro definition failed")); - snprintf(str, strsz, fmt, scname[i], i - 1); - buf_strappend(&tmpbuf, str); - free(str); - } - buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); - buf_destroy(&tmpbuf); + struct Buf tmpbuf; + buf_init(&tmpbuf, sizeof(char)); + for (i = 1; i <= lastsc; i++) { + char *str, *fmt = backend->int_define_fmt; + size_t strsz; + + strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; + str = malloc(strsz); + if (!str) + flexfatal(_("allocation of macro definition failed")); + snprintf(str, strsz, fmt, scname[i], i - 1); + buf_strappend(&tmpbuf, str); + free(str); + } + buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); + buf_destroy(&tmpbuf); } /* This is where we begin writing to the file. */ /* Dump the %top code. */ if( top_buf.elts) - outn((char*) top_buf.elts); + outn((char*) top_buf.elts); /* Dump the m4 definitions. */ buf_print_strings(&m4defs_buf, stdout); @@ -766,11 +769,11 @@ void flexinit (int argc, char **argv) printstats = syntaxerror = trace = spprdflt = false; lex_compat = posix_compat = C_plus_plus = backing_up_report = - ddebug = fulltbl = false; + ddebug = fulltbl = false; fullspd = long_align = nowarn = yymore_used = continued_action = - false; + false; do_yylineno = yytext_is_array = in_rule = reject = do_stdinit = - false; + false; yymore_really_used = reject_really_used = unspecified; interactive = csize = unspecified; do_yywrap = gen_line_dirs = usemecs = useecs = true; @@ -798,17 +801,17 @@ void flexinit (int argc, char **argv) buf_init (&yydmap_buf, sizeof (char)); /* one long string */ buf_init (&top_buf, sizeof (char)); /* one long string */ - { - const char * m4defs_init_str[] = {"m4_changequote\n", - "m4_changequote([[, ]])\n"}; - buf_init (&m4defs_buf, sizeof (char *)); - buf_append (&m4defs_buf, &m4defs_init_str, 2); - } + { + const char * m4defs_init_str[] = {"m4_changequote\n", + "m4_changequote([[, ]])\n"}; + buf_init (&m4defs_buf, sizeof (char *)); + buf_append (&m4defs_buf, &m4defs_init_str, 2); + } - sf_init (); + sf_init (); - /* initialize regex lib */ - flex_init_regex(); + /* initialize regex lib */ + flex_init_regex(); /* Enable C++ if program name ends with '+'. */ program_name = argv[0]; @@ -838,27 +841,27 @@ void flexinit (int argc, char **argv) } switch ((enum flexopt_flag_t) rv) { - case OPT_CPLUSPLUS: + case OPT_CPLUSPLUS: C_plus_plus = true; break; - case OPT_BATCH: + case OPT_BATCH: interactive = false; break; - case OPT_BACKUP: + case OPT_BACKUP: backing_up_report = true; break; - case OPT_BACKUP_FILE: + case OPT_BACKUP_FILE: backing_up_report = true; backing_name = arg; break; - case OPT_DONOTHING: + case OPT_DONOTHING: break; - case OPT_COMPRESSION: + case OPT_COMPRESSION: if (!sawcmpflag) { useecs = false; usemecs = false; @@ -868,390 +871,390 @@ void flexinit (int argc, char **argv) for (i = 0; arg && arg[i] != '\0'; i++) switch (arg[i]) { - case 'a': + case 'a': long_align = true; break; - case 'e': + case 'e': useecs = true; break; - case 'F': + case 'F': fullspd = true; break; - case 'f': + case 'f': fulltbl = true; break; - case 'm': + case 'm': usemecs = true; break; - case 'r': + case 'r': use_read = true; break; - default: + default: lerr (_ - ("unknown -C option '%c'"), - arg[i]); + ("unknown -C option '%c'"), + arg[i]); break; } break; - case OPT_DEBUG: + case OPT_DEBUG: ddebug = true; break; - case OPT_NO_DEBUG: + case OPT_NO_DEBUG: ddebug = false; break; - case OPT_FULL: + case OPT_FULL: useecs = usemecs = false; use_read = fulltbl = true; break; - case OPT_FAST: + case OPT_FAST: useecs = usemecs = false; use_read = fullspd = true; break; - case OPT_HELP: + case OPT_HELP: usage (); FLEX_EXIT (0); - case OPT_INTERACTIVE: + case OPT_INTERACTIVE: interactive = true; break; - case OPT_CASE_INSENSITIVE: + case OPT_CASE_INSENSITIVE: sf_set_case_ins(true); break; - case OPT_LEX_COMPAT: + case OPT_LEX_COMPAT: lex_compat = true; break; - case OPT_POSIX_COMPAT: + case OPT_POSIX_COMPAT: posix_compat = true; break; - case OPT_PREPROC_LEVEL: - preproc_level = (int) strtol(arg,NULL,0); - break; + case OPT_PREPROC_LEVEL: + preproc_level = (int) strtol(arg,NULL,0); + break; - case OPT_MAIN: + case OPT_MAIN: buf_strdefine (&userdef_buf, "YY_MAIN", "1"); do_yywrap = false; break; - case OPT_NO_MAIN: + case OPT_NO_MAIN: buf_strdefine (&userdef_buf, "YY_MAIN", "0"); break; - case OPT_NO_LINE: + case OPT_NO_LINE: gen_line_dirs = false; break; - case OPT_OUTFILE: + case OPT_OUTFILE: outfilename = arg; did_outfilename = 1; break; - case OPT_PREFIX: + case OPT_PREFIX: prefix = arg; break; - case OPT_PERF_REPORT: + case OPT_PERF_REPORT: ++performance_report; break; - case OPT_BISON_BRIDGE: + case OPT_BISON_BRIDGE: bison_bridge_lval = true; break; - case OPT_BISON_BRIDGE_LOCATIONS: + case OPT_BISON_BRIDGE_LOCATIONS: bison_bridge_lval = bison_bridge_lloc = true; break; - case OPT_REENTRANT: + case OPT_REENTRANT: reentrant = true; break; - case OPT_NO_REENTRANT: + case OPT_NO_REENTRANT: reentrant = false; break; - case OPT_SKEL: + case OPT_SKEL: skelname = arg; break; - case OPT_DEFAULT: + case OPT_DEFAULT: spprdflt = false; break; - case OPT_NO_DEFAULT: + case OPT_NO_DEFAULT: spprdflt = true; break; - case OPT_STDOUT: + case OPT_STDOUT: use_stdout = true; break; - case OPT_NO_UNISTD_H: + case OPT_NO_UNISTD_H: //buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0); break; - case OPT_TABLES_FILE: + case OPT_TABLES_FILE: tablesext = true; tablesfilename = arg; break; - case OPT_TABLES_VERIFY: + case OPT_TABLES_VERIFY: tablesverify = true; break; - case OPT_TRACE: + case OPT_TRACE: trace = true; break; - case OPT_VERBOSE: + case OPT_VERBOSE: printstats = true; break; - case OPT_VERSION: + case OPT_VERSION: printf ("%s %s\n", (C_plus_plus ? "flex++" : "flex"), flex_version); FLEX_EXIT (0); - case OPT_WARN: + case OPT_WARN: nowarn = false; break; - case OPT_NO_WARN: + case OPT_NO_WARN: nowarn = true; break; - case OPT_7BIT: + case OPT_7BIT: csize = 128; break; - case OPT_8BIT: + case OPT_8BIT: csize = CSIZE; break; - case OPT_ALIGN: + case OPT_ALIGN: long_align = true; break; - case OPT_NO_ALIGN: + case OPT_NO_ALIGN: long_align = false; break; - case OPT_ALWAYS_INTERACTIVE: + case OPT_ALWAYS_INTERACTIVE: buf_m4_define (&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0); break; - case OPT_NEVER_INTERACTIVE: - buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0); + case OPT_NEVER_INTERACTIVE: + buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0); break; - case OPT_ARRAY: + case OPT_ARRAY: yytext_is_array = true; break; - case OPT_POINTER: + case OPT_POINTER: yytext_is_array = false; break; - case OPT_ECS: + case OPT_ECS: useecs = true; break; - case OPT_NO_ECS: + case OPT_NO_ECS: useecs = false; break; - case OPT_HEADER_FILE: + case OPT_HEADER_FILE: headerfilename = arg; break; - case OPT_META_ECS: + case OPT_META_ECS: usemecs = true; break; - case OPT_NO_META_ECS: + case OPT_NO_META_ECS: usemecs = false; break; - case OPT_PREPROCDEFINE: - { - /* arg is "symbol" or "symbol=definition". */ - char *def; - char buf2[4096]; + case OPT_PREPROCDEFINE: + { + /* arg is "symbol" or "symbol=definition". */ + char *def; + char buf2[4096]; - for (def = arg; - *def != '\0' && *def != '='; ++def) + for (def = arg; + *def != '\0' && *def != '='; ++def) continue; - if (*def == '\0') + if (*def == '\0') def = "1"; - snprintf(buf2, sizeof(buf2), backend->string_define_fmt, arg, def); - buf_strappend (&userdef_buf, buf2); - } - break; + snprintf(buf2, sizeof(buf2), backend->string_define_fmt, arg, def); + buf_strappend (&userdef_buf, buf2); + } + break; - case OPT_READ: + case OPT_READ: use_read = true; break; - case OPT_STACK: + case OPT_STACK: //buf_strdefine (&userdef_buf, "YY_STACK_USED", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0); + buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0); break; - case OPT_STDINIT: + case OPT_STDINIT: do_stdinit = true; break; - case OPT_NO_STDINIT: + case OPT_NO_STDINIT: do_stdinit = false; break; - case OPT_YYCLASS: + case OPT_YYCLASS: yyclass = arg; break; - case OPT_YYLINENO: + case OPT_YYLINENO: do_yylineno = true; break; - case OPT_NO_YYLINENO: + case OPT_NO_YYLINENO: do_yylineno = false; break; - case OPT_YYWRAP: + case OPT_YYWRAP: do_yywrap = true; break; - case OPT_NO_YYWRAP: + case OPT_NO_YYWRAP: do_yywrap = false; break; - case OPT_YYMORE: + case OPT_YYMORE: yymore_really_used = true; break; - case OPT_NO_YYMORE: + case OPT_NO_YYMORE: yymore_really_used = false; break; - case OPT_REJECT: + case OPT_REJECT: reject_really_used = true; break; - case OPT_NO_REJECT: + case OPT_NO_REJECT: reject_really_used = false; break; - case OPT_NO_YY_PUSH_STATE: + case OPT_NO_YY_PUSH_STATE: //buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0); break; - case OPT_NO_YY_POP_STATE: + case OPT_NO_YY_POP_STATE: //buf_strdefine (&userdef_buf, "YY_NO_POP_STATE", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0); break; - case OPT_NO_YY_TOP_STATE: + case OPT_NO_YY_TOP_STATE: //buf_strdefine (&userdef_buf, "YY_NO_TOP_STATE", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0); break; - case OPT_NO_UNPUT: + case OPT_NO_UNPUT: //buf_strdefine (&userdef_buf, "YY_NO_UNPUT", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0); break; - case OPT_NO_YY_SCAN_BUFFER: + case OPT_NO_YY_SCAN_BUFFER: //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BUFFER", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0); break; - case OPT_NO_YY_SCAN_BYTES: + case OPT_NO_YY_SCAN_BYTES: //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BYTES", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0); break; - case OPT_NO_YY_SCAN_STRING: + case OPT_NO_YY_SCAN_STRING: //buf_strdefine (&userdef_buf, "YY_NO_SCAN_STRING", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0); break; - case OPT_NO_YYGET_EXTRA: + case OPT_NO_YYGET_EXTRA: //buf_strdefine (&userdef_buf, "YY_NO_GET_EXTRA", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0); break; - case OPT_NO_YYSET_EXTRA: + case OPT_NO_YYSET_EXTRA: //buf_strdefine (&userdef_buf, "YY_NO_SET_EXTRA", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0); break; - case OPT_NO_YYGET_LENG: + case OPT_NO_YYGET_LENG: //buf_strdefine (&userdef_buf, "YY_NO_GET_LENG", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0); break; - case OPT_NO_YYGET_TEXT: + case OPT_NO_YYGET_TEXT: //buf_strdefine (&userdef_buf, "YY_NO_GET_TEXT", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0); break; - case OPT_NO_YYGET_LINENO: + case OPT_NO_YYGET_LINENO: //buf_strdefine (&userdef_buf, "YY_NO_GET_LINENO", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0); break; - case OPT_NO_YYSET_LINENO: + case OPT_NO_YYSET_LINENO: //buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0); break; - case OPT_NO_YYGET_COLUMN: + case OPT_NO_YYGET_COLUMN: //buf_strdefine (&userdef_buf, "YY_NO_GET_COLUMN", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_COLUMN",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_COLUMN",0); break; - case OPT_NO_YYSET_COLUMN: + case OPT_NO_YYSET_COLUMN: //buf_strdefine (&userdef_buf, "YY_NO_SET_COLUMN", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_COLUMN",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_COLUMN",0); break; - case OPT_NO_YYGET_IN: + case OPT_NO_YYGET_IN: //buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0); break; - case OPT_NO_YYSET_IN: + case OPT_NO_YYSET_IN: //buf_strdefine (&userdef_buf, "YY_NO_SET_IN", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0); break; - case OPT_NO_YYGET_OUT: + case OPT_NO_YYGET_OUT: //buf_strdefine (&userdef_buf, "YY_NO_GET_OUT", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0); break; - case OPT_NO_YYSET_OUT: + case OPT_NO_YYSET_OUT: //buf_strdefine (&userdef_buf, "YY_NO_SET_OUT", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0); break; - case OPT_NO_YYGET_LVAL: + case OPT_NO_YYGET_LVAL: //buf_strdefine (&userdef_buf, "YY_NO_GET_LVAL", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0); break; - case OPT_NO_YYSET_LVAL: + case OPT_NO_YYSET_LVAL: //buf_strdefine (&userdef_buf, "YY_NO_SET_LVAL", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0); break; - case OPT_NO_YYGET_LLOC: + case OPT_NO_YYGET_LLOC: //buf_strdefine (&userdef_buf, "YY_NO_GET_LLOC", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0); break; - case OPT_NO_YYSET_LLOC: + case OPT_NO_YYSET_LLOC: //buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1"); - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0); + buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0); break; - case OPT_HEX: + case OPT_HEX: trace_hex = 1; break; - case OPT_NO_SECT3_ESCAPE: + case OPT_NO_SECT3_ESCAPE: no_section3_escape = true; break; } /* switch */ @@ -1267,7 +1270,7 @@ void flexinit (int argc, char **argv) num_rules = num_eof_rules = default_rule = 0; numas = numsnpairs = tmpuses = 0; numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst = - 0; + 0; numuniq = numdup = hshsave = eofseen = datapos = dataline = 0; num_backing_up = onesp = numprots = 0; variable_trailing_context_rules = bol_needed = false; @@ -1410,6 +1413,112 @@ void readin (void) if (useecs) ccl2ecl (); + + // These are used to conditionalize code in the lex skeleton + // that historically used to be generated by C code in flex + // itself; by shoving all this stuff out to the skeleton file + // we make it easier to retarget the code generation. + + backend->comment("m4 controls begin\n"); + + // mode switches for YY_DO_BEFORE_ACTION code generation + if (yytext_is_array) + visible_define ( "M4_MODE_YYTEXT_IS_ARRAY"); + else + visible_define ( "M4_MODE_NO_YYTEXT_IS_ARRAY"); + if (yymore_used) + visible_define ( "M4_MODE_YYMORE_USED"); + else + visible_define ( "M4_MODE_NO_YYMORE_USED"); + + if (fullspd) + visible_define ( "M4_MODE_REAL_FULLSPD"); + else + visible_define ( "M4_MODE_NO_REAL_FULLSPD"); + + // niode switches for YYINPUT code generation + if (use_read) + visible_define ( "M4_MODE_CPP_USE_READ"); + else + visible_define ( "M4_MODE_NO_CPP_USE_READ"); + + // mode switches for next-action code + if (variable_trailing_context_rules) { + visible_define ( "M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES"); + } else { + visible_define ( "M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES"); + } + if (real_reject) + visible_define ( "M4_MODE_REAL_REJECT"); + if (reject_really_used) + visible_define ( "M4_MODE_FIND_ACTION_REJECT_REALLY_USED"); + if (reject) + visible_define ( "M4_MODE_USES_REJECT"); + else + visible_define ( "M4_MODE_NO_USES_REJECT"); + + // mode switches for computing next compressed state + if (usemecs) + visible_define ( "M4_MODE_USEMECS"); + + // mode switches for find-action code + if (fullspd) + visible_define ( "M4_MODE_FULLSPD"); + else if (fulltbl) + visible_define ( "M4_MODE_FIND_ACTION_FULLTBL"); + else if (reject) + visible_define ( "M4_MODE_FIND_ACTION_REJECT"); + else + visible_define ( "M4_MODE_FIND_ACTION_COMPRESSED"); + + // mode switches for backup generation and gen_start_state + if (!fullspd) + visible_define ( "M4_MODE_NO_FULLSPD"); + if (bol_needed) + visible_define ( "M4_MODE_BOL_NEEDED"); + else + visible_define ( "M4_MODE_NO_BOL_NEEDED"); + + // yylineno + if (do_yylineno) + visible_define ( "M4_MODE_YYLINENO"); + + // Equivalence classes + if (useecs) + visible_define ( "M4_MODE_USEECS"); + else + visible_define ( "M4_NOT_MODE_USEECS"); + + // mode switches for getting next action + if (gentables) + visible_define ( "M4_MODE_GENTABLES"); + else + visible_define ( "M4_MODE_NO_GENTABLES"); + if (interactive) + visible_define ( "M4_MODE_INTERACTIVE"); + else + visible_define ( "M4_MODE_NO_INTERACTIVE"); + if (!(fullspd || fulltbl)) + visible_define ( "M4_MODE_NO_FULLSPD_OR_FULLTBL"); + if (reject || interactive) + visible_define ( "M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE"); + + if (ddebug) + visible_define ( "M4_MODE_DEBUG"); + + // Kluge to get around the fact that the %if-not-reentrant and + // %if-c-only gates can't be combined by nesting one inside the + // other. + if (backend == &cpp_backend && !C_plus_plus) + visible_define ( "M4_MODE_C_ONLY"); + + if (tablesext) + visible_define ( "M4_MODE_TABLESEXT"); + if (prefix != NULL) + out_m4_define ( "M4_MODE_PREFIX", prefix); // FIXME: should be visible + + backend->comment("m4 controls end\n"); + out ("\n"); } /* set_up_initial_allocations - allocate memory for internal tables */ diff --git a/src/misc.c b/src/misc.c index f4bd807..8bf4609 100644 --- a/src/misc.c +++ b/src/misc.c @@ -736,6 +736,8 @@ void skelout (void) } else if (buf[1] == '%') { /* %% is a break point for skelout() */ + backend->comment(buf); + outc ('\n'); return; } else if (cmd_match (CMD_PUSH)){ -- cgit v1.2.1 From 31c3f7703dd0254558685669b5b6b3089b639e2d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 30 Sep 2020 05:45:09 -0400 Subject: Methodize section marker output and refactor initialization. The point of this change is to move the setting of the M4_MODE_* controls up to the front of the generated code so that they can be used for conditionalization earlier, notably in replacing the prolog method. I tried to do this in #46 but dididn't move the mode setting far enough up. (Also, rename instances of a duplicated mode switch.) In generated code, the m4 controls move but nothing else changes. #47 in the retargeting patch series --- src/cpp-flex.skl | 11 ++- src/main.c | 231 ++++++++++++++++++++++++++++--------------------------- src/scan.l | 1 - 3 files changed, 122 insertions(+), 121 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 51f3993..4040a58 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -27,7 +27,6 @@ %# tabs when editing this file. Braces around single-statement %# if/while/fo/do/switch/break bodies are mandatory. %# -/* A lexical scanner generated by flex */ %# Macros for preproc stage. m4preproc_changecom @@ -439,7 +438,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - m4_ifdef( [[M4_YY_USE_LINENO]], + m4_ifdef( [[M4_MODE_YYLINENO]], [[ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break @@ -1303,7 +1302,7 @@ struct yytbl_dmap { /** A {0,0,0}-terminated list of structs, forming the map */ static struct yytbl_dmap yydmap[] = { m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]]) -m4_ifdef([[M4_YY_USE_LINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(flex_int32_t)},]]) +m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(flex_int32_t)},]]) m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]]) %tables-yydmap generated elements {0,0,0} @@ -1683,7 +1682,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s YY_DO_BEFORE_ACTION; -m4_ifdef( [[M4_YY_USE_LINENO]],[[ +m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) @@ -2348,7 +2347,7 @@ void yyFlexLexer::yyunput( int c, char* yy_bp) *--yy_cp = (char) c; -m4_ifdef( [[M4_YY_USE_LINENO]], +m4_ifdef( [[M4_MODE_YYLINENO]], [[ if ( c == '\n' ){ --yylineno; @@ -3360,7 +3359,7 @@ static int yy_init_globals (M4_YY_DEF_ONLY_ARG) { * This function is called from yylex_destroy(), so don't allocate here. */ -m4_ifdef( [[M4_YY_USE_LINENO]], +m4_ifdef( [[M4_MODE_YYLINENO]], [[ m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ diff --git a/src/main.c b/src/main.c index 863739a..126d374 100644 --- a/src/main.c +++ b/src/main.c @@ -389,120 +389,6 @@ void check_options (void) filter_truncate(output_chain, preproc_level); filter_apply_chain(output_chain); } - yyout = stdout; - - - /* always generate the tablesverify flag. */ - buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); - if (tablesext) - gentables = false; - - if (tablesverify) - /* force generation of C tables. */ - gentables = true; - - - if (tablesext) { - FILE *tablesout; - struct yytbl_hdr hdr; - char *pname = 0; - size_t nbytes = 0; - - buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL); - - if (!tablesfilename) { - nbytes = strlen (prefix) + strlen (tablesfile_template) + 2; - tablesfilename = pname = calloc(nbytes, 1); - snprintf (pname, nbytes, tablesfile_template, prefix); - } - - if ((tablesout = fopen (tablesfilename, "w")) == NULL) - lerr (_("could not create %s"), tablesfilename); - free(pname); - tablesfilename = 0; - - yytbl_writer_init (&tableswr, tablesout); - - nbytes = strlen (prefix) + strlen ("tables") + 2; - tablesname = calloc(nbytes, 1); - snprintf (tablesname, nbytes, "%stables", prefix); - yytbl_hdr_init (&hdr, flex_version, tablesname); - - if (yytbl_hdr_fwrite (&tableswr, &hdr) <= 0) - flexerror (_("could not write tables header")); - } - - if (skelname && (skelfile = fopen (skelname, "r")) == NULL) - lerr (_("can't open skeleton file %s"), skelname); - - if (reentrant) { - buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL); - if (yytext_is_array) - buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL); - } - - if ( bison_bridge_lval) - buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); - - if ( bison_bridge_lloc) - buf_m4_define (&m4defs_buf, "", NULL); - - if (strchr(prefix, '[') || strchr(prefix, ']')) - flexerror(_("Prefix cannot include '[' or ']'")); - buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix); - - if (did_outfilename) - line_directive_out (stdout, 0); - - if (do_yylineno) - buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL); - - /* Create the alignment type. */ - buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", backend->yy_int_aligned()); - - /* Define the start condition macros. */ - { - struct Buf tmpbuf; - buf_init(&tmpbuf, sizeof(char)); - for (i = 1; i <= lastsc; i++) { - char *str, *fmt = backend->int_define_fmt; - size_t strsz; - - strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; - str = malloc(strsz); - if (!str) - flexfatal(_("allocation of macro definition failed")); - snprintf(str, strsz, fmt, scname[i], i - 1); - buf_strappend(&tmpbuf, str); - free(str); - } - buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); - buf_destroy(&tmpbuf); - } - - /* This is where we begin writing to the file. */ - - /* Dump the %top code. */ - if( top_buf.elts) - outn((char*) top_buf.elts); - - /* Dump the m4 definitions. */ - buf_print_strings(&m4defs_buf, stdout); - m4defs_buf.nelts = 0; /* memory leak here. */ - - /* Place a bogus line directive, it will be fixed in the filter. */ - if (gen_line_dirs && backend->trace_fmt) { - char buf2[4096]; - snprintf(buf2, sizeof(buf2), backend->trace_fmt, 0, "M4_YY_OUTFILE_NAME"); - outn(buf2); - } - - /* Dump the user defined preproc directives. */ - if (userdef_buf.elts) - outn ((char *) (userdef_buf.elts)); - - skelout (); - /* %% [1.0] */ } /* flexend - terminate flex @@ -1303,6 +1189,118 @@ void readin (void) if (syntaxerror) flexend (1); + yyout = stdout; + + + /* always generate the tablesverify flag. */ + buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); + if (tablesext) + gentables = false; + + if (tablesverify) + /* force generation of C tables. */ + gentables = true; + + + if (tablesext) { + FILE *tablesout; + struct yytbl_hdr hdr; + char *pname = 0; + size_t nbytes = 0; + + buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL); + + if (!tablesfilename) { + nbytes = strlen (prefix) + strlen (tablesfile_template) + 2; + tablesfilename = pname = calloc(nbytes, 1); + snprintf (pname, nbytes, tablesfile_template, prefix); + } + + if ((tablesout = fopen (tablesfilename, "w")) == NULL) + lerr (_("could not create %s"), tablesfilename); + free(pname); + tablesfilename = 0; + + yytbl_writer_init (&tableswr, tablesout); + + nbytes = strlen (prefix) + strlen ("tables") + 2; + tablesname = calloc(nbytes, 1); + snprintf (tablesname, nbytes, "%stables", prefix); + yytbl_hdr_init (&hdr, flex_version, tablesname); + + if (yytbl_hdr_fwrite (&tableswr, &hdr) <= 0) + flexerror (_("could not write tables header")); + } + + if (skelname && (skelfile = fopen (skelname, "r")) == NULL) + lerr (_("can't open skeleton file %s"), skelname); + + if (reentrant) { + buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL); + if (yytext_is_array) + buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL); + } + + if ( bison_bridge_lval) + buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); + + if ( bison_bridge_lloc) + buf_m4_define (&m4defs_buf, "", NULL); + + if (strchr(prefix, '[') || strchr(prefix, ']')) + flexerror(_("Prefix cannot include '[' or ']'")); + buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix); + + if (did_outfilename) + line_directive_out (stdout, 0); + + /* Create the alignment type. */ + buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", backend->yy_int_aligned()); + + /* Define the start condition macros. */ + { + struct Buf tmpbuf; + int i; + buf_init(&tmpbuf, sizeof(char)); + for (i = 1; i <= lastsc; i++) { + char *str, *fmt = backend->int_define_fmt; + size_t strsz; + + strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; + str = malloc(strsz); + if (!str) + flexfatal(_("allocation of macro definition failed")); + snprintf(str, strsz, fmt, scname[i], i - 1); + buf_strappend(&tmpbuf, str); + free(str); + } + buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); + buf_destroy(&tmpbuf); + } + + /* This is where we begin writing to the file. */ + + backend->comment("A lexical scanner generated by flex\n"); + + /* Dump the %top code. */ + if( top_buf.elts) + outn((char*) top_buf.elts); + + /* Dump the m4 definitions. */ + buf_print_strings(&m4defs_buf, stdout); + m4defs_buf.nelts = 0; /* memory leak here. */ + + /* Place a bogus line directive, it will be fixed in the filter. */ + if (gen_line_dirs && backend->trace_fmt) { + char buf2[4096]; + snprintf(buf2, sizeof(buf2), backend->trace_fmt, 0, "M4_YY_OUTFILE_NAME"); + outn(buf2); + } + + /* Dump the user defined preproc directives. */ + if (userdef_buf.elts) + outn ((char *) (userdef_buf.elts)); + /* If the user explicitly requested posix compatibility by specifing the * posix-compat option, then we check for conflicting options. However, if * the POSIXLY_CORRECT variable is set, then we quietly make flex as @@ -1519,6 +1517,11 @@ void readin (void) backend->comment("m4 controls end\n"); out ("\n"); + + skelout (); + /* %% [1.0] */ + + backend->comment("Begin user sect3\n"); } /* set_up_initial_allocations - allocate memory for internal tables */ diff --git a/src/scan.l b/src/scan.l index f4b44b8..f914186 100644 --- a/src/scan.l +++ b/src/scan.l @@ -634,7 +634,6 @@ M4QEND "]""]" ^"%%".* { sectnum = 3; BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3); - outn("/* Begin user sect3 */"); yyterminate(); /* to stop the parser */ } -- cgit v1.2.1 From 981867ff1519a807f9b69d8468f6f83fe2abec9f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 30 Sep 2020 08:05:09 -0400 Subject: Land the footprint-reporting feature. Also, clean up some unused and duplicative symbols. In generated test code, comment and whitespace diffs only except for YY_INT_ALIGNED going away. #48 in the retargeting patch series --- src/cpp_backend.c | 6 ------ src/flexdef.h | 1 - src/gen.c | 5 +++++ src/main.c | 3 --- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 1841375..eb1963e 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -425,11 +425,6 @@ static void cpp_epilog (void) #endif } -static const char *cpp_yy_int_aligned(void) -{ - return long_align ? "long int" : "short int"; -} - static void cpp_comment(const char *txt) { char buf[MAXLINE]; @@ -654,7 +649,6 @@ struct flex_backend_t cpp_backend = { .prolog = cpp_prolog, .skel = cpp_skel, .epilog = cpp_epilog, - .yy_int_aligned = cpp_yy_int_aligned, .trace_fmt = "#line %d \"%s\"\n", .int_define_fmt = "#define %s %d\n", .string_define_fmt = "#define %s %s\n", diff --git a/src/flexdef.h b/src/flexdef.h index d4e7e2b..0781746 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -310,7 +310,6 @@ struct flex_backend_t { void (*prolog)(void); const char **skel; void (*epilog)(void); - const char *(*yy_int_aligned)(void); // Generate aligned type for this back end char *trace_fmt; // Trace message format // Language syntax generation char *int_define_fmt; // Format for integer constant definitions diff --git a/src/gen.c b/src/gen.c index 4084c56..6ebad19 100644 --- a/src/gen.c +++ b/src/gen.c @@ -815,6 +815,7 @@ void visible_define (const char *symname) void make_tables (void) { + char buf[128]; int i; int did_eof_rule = false; struct yytbl_data *yynultrans_tbl = NULL; @@ -915,6 +916,10 @@ void make_tables (void) else gentabs (); + snprintf(buf, sizeof(buf), "footprint: %ld bytes\n", footprint); + backend->comment(buf); + outc ('\n'); + // Only at this point do we know if the automaton has backups. // Some m4 conditionals require this information. diff --git a/src/main.c b/src/main.c index 126d374..7346c03 100644 --- a/src/main.c +++ b/src/main.c @@ -1254,9 +1254,6 @@ void readin (void) if (did_outfilename) line_directive_out (stdout, 0); - /* Create the alignment type. */ - buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", backend->yy_int_aligned()); - /* Define the start condition macros. */ { struct Buf tmpbuf; -- cgit v1.2.1 From 8c2d23d9a8679961e9ca559d9fcca2a3d4e629c5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 30 Sep 2020 10:47:57 -0400 Subject: Eliminate the prolog method from the method table. Now that all the mode conditionals are visible early, wverything that used to be done in the prolog can be done as conditionalized code in the skeleton. Whitespace and comment diffs only. #49 in the retargeting patch series --- src/cpp-flex.skl | 107 +++++++++++++++++++++++++++++++++++++++ src/cpp_backend.c | 148 ------------------------------------------------------ src/flexdef.h | 1 - src/main.c | 33 +++++++++--- 4 files changed, 133 insertions(+), 156 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4040a58..9229365 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -654,6 +654,113 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. definitions & init go here +m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ +%if-c-only +m4_ifdef([[M4_YY_REENTRANT]], [[ +#define M4_YY_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) +]]) +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +#define M4_YY_PREFIX[[wrap]]() (/*CONSTCOND*/1) +]])m4_dnl +%endif +#define YY_SKIP_YYWRAP +]]) +m4_ifdef( [[M4_MODE_DEBUG]], [[ +#define FLEX_DEBUG +]]) +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl +typedef flex_uint8_t YY_CHAR; +]])m4_dnl +%if-c-only +m4_define([[M4_TMP_STDINIT]], [[FILE *yyin = stdin, *yyout = stdout;]]) +m4_define([[M4_TMP_NO_STDINIT]], [[FILE *yyin = NULL, *yyout = NULL;]]) +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ +m4_ifdef( [[M4_MODE_DO_STDINIT]], [[m4_dnl +m4_ifdef([[M4_YY_REENTRANT]], [[ +#ifdef VMS +#ifdef __VMS_POSIX +#define YY_STDINIT +#endif +#else +#define YY_STDINIT +#endif +]]) +#ifdef VMS"); +#ifndef __VMS_POSIX +M4_TMP_NO_STDINIT +#else +M4_TMP_STDINIT +#endif +#else +M4_TMP_STDINIT +#endif +]]) +m4_ifdef( [[M4_MODE_NO_DO_STDINIT]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +M4_TMP_NO_STDINIT +]]) +]]) +]]) +m4_undefine([[M4_TMP_STDINIT]]) +m4_undefine([[M4_TMP_NO_STDINIT]]) +%endif +%if-c++-only +#define yytext_ptr yytext +m4_ifdef( [[M4_MODE_INTERACTIVE]], [[#define YY_INTERACTIVE]]) +%endif +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl +m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl +typedef const struct yy_trans_info *yy_state_type; +]], [[ +%if-c-only +typedef int yy_state_type; +%endif +]]) +]]) +m4_ifdef([[M4_MODE_LEX_COMPAT]], [[#define YY_FLEX_LEX_COMPAT]]) +%if-c-only +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +extern int yylineno; +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +int yylineno = 1; +]]) +]]) +%endif +%if-c++-only + +#include +m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ +int yyFlexLexer::yywrap() { return 1;} +]]) +m4_ifdef([[M4_MODE_YYCLASS]], [[ +int yyFlexLexer::yylex() + { + LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); + return 0; + } + +#define YY_DECL int M4_YY_CLASS_NAME::yylex() +]]) +%endif +%if-c-only +/* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[extern char yytext[];]]) +]]) +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_YY_REENTRANT]], [[#define yytext_ptr yytext_r]],[[ +extern char *yytext; + +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext +]]) +]]) +%endif + m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ %% [1.5] DFA diff --git a/src/cpp_backend.c b/src/cpp_backend.c index eb1963e..9f6f625 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -87,153 +87,6 @@ static const char *cpp_suffix (void) return suffix; } -/* cpp_prolog - make rules prolog specific to cpp-using languages. - * - * If you don't ship this, you will effectively be assuming that your - * parsers are always reentrant, always allow reject, always have a - * yywrap() method, have a debug member in the wrapper class, and are - * interactive. This eliminates most of the boilerplate in the C/C++ - * scanner prolog. It means such parsers will be a bit larger and - * slower than C/C++ ones, but since we're not running on 1987's - * hardware we officially do not care. - * - * A detail to beware of: If you're not issuing this prologue, you may - * want to write your own definition of YY_CHAR in your skel - * file. It's a typedef to an unsigned octet in C/C++, but if your - * target language has a Unicode code-point type like Go's 'rune' is - * may be appropriate. - */ - -static void cpp_prolog (void) -{ - static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; - static char yy_nostdinit[] = - "FILE *yyin = NULL, *yyout = NULL;"; - - if (!do_yywrap) { - if (!C_plus_plus) { - if (reentrant) - out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix); - else - out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix); - } - outn ("#define YY_SKIP_YYWRAP"); - } - - if (ddebug) - outn ("\n#define FLEX_DEBUG"); - - OUT_BEGIN_CODE (); - outn ("typedef flex_uint8_t YY_CHAR;"); - OUT_END_CODE (); - - if (C_plus_plus) { - outn ("#define yytext_ptr yytext"); - - if (interactive) - outn ("#define YY_INTERACTIVE"); - } - - else { - - - - OUT_BEGIN_CODE (); - /* In reentrant scanner, stdinit is handled in flex.skl. */ - if (do_stdinit) { - if (reentrant){ - outn ("#ifdef VMS"); - outn ("#ifdef __VMS_POSIX"); - outn ("#define YY_STDINIT"); - outn ("#endif"); - outn ("#else"); - outn ("#define YY_STDINIT"); - outn ("#endif"); - } - - outn ("#ifdef VMS"); - outn ("#ifndef __VMS_POSIX"); - outn (yy_nostdinit); - outn ("#else"); - outn (yy_stdinit); - outn ("#endif"); - outn ("#else"); - outn (yy_stdinit); - outn ("#endif"); - } - - else { - if(!reentrant) - outn (yy_nostdinit); - } - OUT_END_CODE (); - } - - OUT_BEGIN_CODE (); - if (fullspd) - outn ("typedef const struct yy_trans_info *yy_state_type;"); - else if (!C_plus_plus) - outn ("typedef int yy_state_type;"); - OUT_END_CODE (); - - if (lex_compat) - outn ("#define YY_FLEX_LEX_COMPAT"); - - if (!C_plus_plus && !reentrant) { - outn ("extern int yylineno;"); - OUT_BEGIN_CODE (); - outn ("int yylineno = 1;"); - OUT_END_CODE (); - } - - if (C_plus_plus) { - outn ("\n#include "); - - if (!do_yywrap) { - outn("\nint yyFlexLexer::yywrap() { return 1; }"); - } - - if (yyclass) { - outn ("int yyFlexLexer::yylex()"); - outn ("\t{"); - outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );"); - outn ("\treturn 0;"); - outn ("\t}"); - - out_str ("\n#define YY_DECL int %s::yylex()\n", - yyclass); - } - } - - else { - - /* Watch out: yytext_ptr is a variable when yytext is an array, - * but it's a macro when yytext is a pointer. - */ - if (yytext_is_array) { - if (!reentrant) - outn ("extern char yytext[];\n"); - } - else { - if (reentrant) { - outn ("#define yytext_ptr yytext_r"); - } - else { - outn ("extern char *yytext;"); - - outn("#ifdef yytext_ptr"); - outn("#undef yytext_ptr"); - outn("#endif"); - outn ("#define yytext_ptr yytext"); - } - } - - if (yyclass) - flexerror (_ - ("%option yyclass only meaningful for C++ scanners")); - } -} - static void cpp_epilog (void) { #if 0 @@ -646,7 +499,6 @@ const char *cpp_skel[] = { /* This backend is only accessed through this method table */ struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, - .prolog = cpp_prolog, .skel = cpp_skel, .epilog = cpp_epilog, .trace_fmt = "#line %d \"%s\"\n", diff --git a/src/flexdef.h b/src/flexdef.h index 0781746..29e9505 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -307,7 +307,6 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code - void (*prolog)(void); const char **skel; void (*epilog)(void); char *trace_fmt; // Trace message format diff --git a/src/main.c b/src/main.c index 7346c03..5d19140 100644 --- a/src/main.c +++ b/src/main.c @@ -171,12 +171,6 @@ int flex_main (int argc, char *argv[]) readin (); - if (backend->prolog) { - backend->comment("prolog begins\n"); - backend->prolog (); - backend->comment("prolog ends\n"); - } - skelout (); /* %% [1.5] DFA */ footprint += ntod (); @@ -405,6 +399,9 @@ void flexend (int exit_status) if (++called_before) FLEX_EXIT (exit_status); + if (yyclass && !C_plus_plus) + flexerror (_("%option yyclass only meaningful for C++ scanners")); + if (skelfile != NULL) { if (ferror (skelfile)) lerr (_("input error reading skeleton file %s"), @@ -1239,7 +1236,8 @@ void readin (void) buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL); if (yytext_is_array) buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL); - } + } else + buf_m4_define (&m4defs_buf, "M4_YY_NOT_REENTRANT", NULL); if ( bison_bridge_lval) buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); @@ -1416,6 +1414,11 @@ void readin (void) backend->comment("m4 controls begin\n"); + if (do_stdinit) + visible_define ( "M4_MODE_DO_STDINIT"); + else + visible_define ( "M4_MODE_NO_DO_STDINIT"); + // mode switches for YY_DO_BEFORE_ACTION code generation if (yytext_is_array) visible_define ( "M4_MODE_YYTEXT_IS_ARRAY"); @@ -1498,9 +1501,25 @@ void readin (void) if (reject || interactive) visible_define ( "M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE"); + if (yyclass != NULL) { + visible_define ( "M4_MODE_YYCLASS"); + out_m4_define("M4_YY_CLASS_NAME", yyclass); + } + if (ddebug) visible_define ( "M4_MODE_DEBUG"); + if (lex_compat) + visible_define ( "M4_LEX_COMPAT"); + + if (do_yywrap) + visible_define ( "M4_MODE_YYWRAP"); + else + visible_define ( "M4_MODE_NO_YYWRAP"); + + if (interactive) + visible_define ( "M4_MODE_INTERACTIVE"); + // Kluge to get around the fact that the %if-not-reentrant and // %if-c-only gates can't be combined by nesting one inside the // other. -- cgit v1.2.1 From 7877454e423c0707479b20316432df8dddbed738 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 30 Sep 2020 21:18:34 -0400 Subject: Eliminate the epilog member from the method table. It was a no-op anyway in the C version, there as a placeholder in case other languages needed it. But in the new organization of things, with everything being done by conditional expansion in the skeleton file, there's no point. No diffs at all in generated test code. Thios does remove some cpde that was conditioned out, an abandoned attempt to undefine all #defines at the end of code generation. --- src/cpp_backend.c | 192 ------------------------------------------------------ src/flexdef.h | 1 - src/main.c | 3 - 3 files changed, 196 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 9f6f625..1ee1f66 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -87,197 +87,6 @@ static const char *cpp_suffix (void) return suffix; } -static void cpp_epilog (void) -{ -#if 0 - fprintf (header_out, - "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n"); - fprintf (header_out, - "/* Beware! Start conditions are not prefixed. */\n"); - - /* Special case for "INITIAL" */ - fprintf (header_out, - "#undef INITIAL\n#define INITIAL 0\n"); - for (i = 2; i <= lastsc; i++) - fprintf (header_out, "#define %s %d\n", scname[i], i - 1); - fprintf (header_out, - "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); - - /* Kill ALL flex-related macros. This is so the user - * can #include more than one generated header file. */ - fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n"); - fprintf (header_out, - "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n"); - - { - const char * undef_list[] = { - - "BEGIN", - "ECHO", - "EOB_ACT_CONTINUE_SCAN", - "EOB_ACT_END_OF_FILE", - "EOB_ACT_LAST_MATCH", - "FLEX_SCANNER", - "REJECT", - "YYFARGS0", - "YYFARGS1", - "YYFARGS2", - "YYFARGS3", - "YYLMAX", - "YYSTATE", - "YY_AT_BOL", - "YY_BREAK", - "YY_BUFFER_EOF_PENDING", - "YY_BUFFER_NEW", - "YY_BUFFER_NORMAL", - "YY_BUF_SIZE", - "M4_YY_CALL_LAST_ARG", - "M4_YY_CALL_ONLY_ARG", - "YY_CURRENT_BUFFER", - "YY_DECL", - "M4_YY_DECL_LAST_ARG", - "M4_YY_DEF_LAST_ARG", - "M4_YY_DEF_ONLY_ARG", - "YY_DO_BEFORE_ACTION", - "YY_END_OF_BUFFER", - "YY_END_OF_BUFFER_CHAR", - "YY_EXIT_FAILURE", - "YY_EXTRA_TYPE", - "YY_FATAL_ERROR", - "YY_FLEX_DEFINED_ECHO", - "YY_FLEX_LEX_COMPAT", - "YY_FLEX_MAJOR_VERSION", - "YY_FLEX_MINOR_VERSION", - "YY_FLEX_SUBMINOR_VERSION", - "YY_FLUSH_BUFFER", - "YY_G", - "YY_INPUT", - "YY_INTERACTIVE", - "YY_INT_ALIGNED", - "YY_LAST_ARG", - "YY_LESS_LINENO", - "YY_LEX_ARGS", - "YY_LEX_DECLARATION", - "YY_LEX_PROTO", - "YY_MAIN", - "YY_MORE_ADJ", - "YY_NEED_STRLEN", - "YY_NEW_FILE", - "YY_NULL", - "YY_NUM_RULES", - "YY_ONLY_ARG", - "YY_PARAMS", - "YY_PROTO", - "M4_YY_PROTO_LAST_ARG", - "M4_YY_PROTO_ONLY_ARG void", - "YY_READ_BUF_SIZE", - "YY_REENTRANT", - "YY_RESTORE_YY_MORE_OFFSET", - "YY_RULE_SETUP", - "YY_SC_TO_UI", - "YY_SKIP_YYWRAP", - "YY_START", - "YY_START_STACK_INCR", - "YY_STATE_EOF", - "YY_STDINIT", - "YY_TRAILING_HEAD_MASK", - "YY_TRAILING_MASK", - "YY_USER_ACTION", - "YY_USE_CONST", - "YY_USE_PROTOS", - "unput", - "yyTABLES_NAME", - "yy_create_buffer", - "yy_delete_buffer", - "yy_flex_debug", - "yy_flush_buffer", - "yy_init_buffer", - "yy_load_buffer_state", - "yy_new_buffer", - "yy_scan_buffer", - "yy_scan_bytes", - "yy_scan_string", - "yy_set_bol", - "yy_set_interactive", - "yy_switch_to_buffer", - "yypush_buffer_state", - "yypop_buffer_state", - "yyensure_buffer_stack", - "yyalloc", - "const", - "yyextra", - "yyfree", - "yyget_debug", - "yyget_extra", - "yyget_in", - "yyget_leng", - "yyget_column", - "yyget_lineno", - "yyget_lloc", - "yyget_lval", - "yyget_out", - "yyget_text", - "yyin", - "yyleng", - "yyless", - "yylex", - "yylex_destroy", - "yylex_init", - "yylex_init_extra", - "yylineno", - "yylloc", - "yylval", - "yymore", - "yyout", - "yyrealloc", - "yyrestart", - "yyset_debug", - "yyset_extra", - "yyset_in", - "yyset_column", - "yyset_lineno", - "yyset_lloc", - "yyset_lval", - "yyset_out", - "yytables_destroy", - "yytables_fload", - "yyterminate", - "yytext", - "yytext_ptr", - "yywrap", - - /* must be null-terminated */ - NULL}; - - - for (i=0; undef_list[i] != NULL; i++) - fprintf (header_out, "#undef %s\n", undef_list[i]); - } - - /* undef any of the auto-generated symbols. */ - for (i = 0; i < defs_buf.nelts; i++) { - - /* don't undef start conditions */ - if (sclookup (((char **) defs_buf.elts)[i]) > 0) - continue; - fprintf (header_out, "#undef %s\n", - ((char **) defs_buf.elts)[i]); - } - - fprintf (header_out, - "#endif /* !YY_HEADER_NO_UNDEFS */\n"); - fprintf (header_out, "\n"); - fprintf (header_out, "#undef %sIN_HEADER\n", prefix); - fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix); - - if (ferror (header_out)) - lerr (_("error creating header file %s"), - headerfilename); - fflush (header_out); - fclose (header_out); -#endif -} - static void cpp_comment(const char *txt) { char buf[MAXLINE]; @@ -500,7 +309,6 @@ const char *cpp_skel[] = { struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, - .epilog = cpp_epilog, .trace_fmt = "#line %d \"%s\"\n", .int_define_fmt = "#define %s %d\n", .string_define_fmt = "#define %s %s\n", diff --git a/src/flexdef.h b/src/flexdef.h index 29e9505..22262c6 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -308,7 +308,6 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code const char **skel; - void (*epilog)(void); char *trace_fmt; // Trace message format // Language syntax generation char *int_define_fmt; // Format for integer constant definitions diff --git a/src/main.c b/src/main.c index 5d19140..5184c74 100644 --- a/src/main.c +++ b/src/main.c @@ -412,9 +412,6 @@ void flexend (int exit_status) skelname); } - if (backend->epilog) - backend->epilog(); - if (exit_status != 0 && outfile_created) { if (ferror (stdout)) lerr (_("error writing output file %s"), -- cgit v1.2.1 From 5c6661bb2eb65fab3924a493ee979b960708583f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 30 Sep 2020 22:14:07 -0400 Subject: Eliminate all uses of buf_strdefine(). There were only two left, for YY_MAIN, and that definition was moved so it's in the visible controls. This is a step towards making *all* conditionalization symbols viible in generated comments. This commit also cleans up some misnamed mode symbols. There are still a couple of duplicative pairs, to be cleaned up in a later commit. We can now report generated M4 symbols with values in the "m4 controls" part of a generated file. Partly as a result, the following symbols become visible in generare code from the tests: M4_MODE_PREFIX, M4_YY_TABLES_VERIFY, M4_YY_REENTRANT, and M4_MODE_PREFIX. No other diffs. #51 in the retargeting patch series. #50 was accidentally unnumbered. --- src/buf.c | 12 ---------- src/cpp-flex.skl | 2 +- src/flexdef.h | 10 ++++++--- src/gen.c | 9 ++++++++ src/main.c | 67 ++++++++++++++++++++------------------------------------ src/misc.c | 6 +++-- 6 files changed, 45 insertions(+), 61 deletions(-) diff --git a/src/buf.c b/src/buf.c index 185083c..c0d53a4 100644 --- a/src/buf.c +++ b/src/buf.c @@ -146,18 +146,6 @@ struct Buf *buf_strappend (struct Buf *buf, const char *str) return buf_strnappend (buf, str, (int) strlen (str)); } -/* appends "#define str def\n" */ -struct Buf *buf_strdefine (struct Buf *buf, const char *str, const char *def) -{ - buf_strappend (buf, "#define "); - buf_strappend (buf, " "); - buf_strappend (buf, str); - buf_strappend (buf, " "); - buf_strappend (buf, def); - buf_strappend (buf, "\n"); - return buf; -} - /** Pushes "m4_define( [[def]], [[val]])m4_dnl" to end of buffer. * @param buf A buffer as a list of strings. * @param def The m4 symbol to define. diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 9229365..4d3af2c 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1683,7 +1683,7 @@ M4_GEN_START_STATE /* Generate the code to find the next match. */ %# Conditional indirection through an equivalence map m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) -m4_ifdef([[M4_NOT_MODE_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) +m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl diff --git a/src/flexdef.h b/src/flexdef.h index 22262c6..f7c2cf6 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -384,6 +384,8 @@ extern struct flex_backend_t cpp_backend; * yytext as a array instead of a character pointer. Nice and inefficient. * do_yywrap - do yywrap() processing on EOF. If false, EOF treated as * "no more files". + * do_main - generate a trivial main part to make the lexer standalone. + * Note that 0 is unset, 1 corresponds to --no-main, and 2 to --main. * csize - size of character set for the scanner we're generating; * 128 for 7-bit chars and 256 for 8-bit * yymore_used - if true, yymore() is used in input rules @@ -406,7 +408,7 @@ extern int useecs, fulltbl, usemecs, fullspd; extern int gen_line_dirs, performance_report, backing_up_report; extern int reentrant, bison_bridge_lval, bison_bridge_lloc; extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap; -extern int csize; +extern int csize, do_main; extern int yymore_used, reject, real_reject, continued_action, in_rule; extern int yymore_really_used, reject_really_used; @@ -778,7 +780,10 @@ extern void mkechar(int, int[], int[]); extern void do_indent(void); /* indent to the current level */ /* Set a conmditional amd make it visible in generated code */ -extern void visible_define (const char *symname); +extern void visible_define (const char *); + +/* And again, with an explicit value part. */ +extern void visible_define_str (const char *, const char *); /* Generate full speed compressed transition table. */ extern void genctbl(void); @@ -1071,7 +1076,6 @@ extern struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem); extern struct Buf *buf_concat(struct Buf* dest, const struct Buf* src); extern struct Buf *buf_strappend(struct Buf *, const char *str); extern struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars); -extern struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def); extern struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s); extern struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val); extern struct Buf *buf_m4_undefine(struct Buf *buf, const char* def); diff --git a/src/gen.c b/src/gen.c index 6ebad19..a8e20a5 100644 --- a/src/gen.c +++ b/src/gen.c @@ -810,6 +810,15 @@ void visible_define (const char *symname) outc ('\n'); } +void visible_define_str (const char *symname, const char *val) +{ + char buf[128]; + out_m4_define(symname, val); + snprintf(buf, sizeof(buf), "%s = %s", symname, val); + backend->comment(buf); + outc ('\n'); +} + /* make_tables - generate transition tables and finishes generating output file */ diff --git a/src/main.c b/src/main.c index 5184c74..b95b181 100644 --- a/src/main.c +++ b/src/main.c @@ -51,7 +51,7 @@ int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; int interactive, lex_compat, posix_compat, do_yylineno, useecs, fulltbl, usemecs; int fullspd, gen_line_dirs, performance_report, backing_up_report; -int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap, +int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap, do_main, csize; int reentrant, bison_bridge_lval, bison_bridge_lloc; int yymore_used, reject, real_reject, continued_action, in_rule; @@ -312,9 +312,6 @@ void check_options (void) } } - if (extra_type) - buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type); - if (!use_stdout) { FILE *prev_stdout; @@ -826,12 +823,12 @@ void flexinit (int argc, char **argv) break; case OPT_MAIN: - buf_strdefine (&userdef_buf, "YY_MAIN", "1"); do_yywrap = false; + do_main = 2; break; case OPT_NO_MAIN: - buf_strdefine (&userdef_buf, "YY_MAIN", "0"); + do_main = 1; break; case OPT_NO_LINE: @@ -884,7 +881,6 @@ void flexinit (int argc, char **argv) break; case OPT_NO_UNISTD_H: - //buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0); break; @@ -991,7 +987,6 @@ void flexinit (int argc, char **argv) break; case OPT_STACK: - //buf_strdefine (&userdef_buf, "YY_STACK_USED", "1"); buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0); break; @@ -1040,95 +1035,72 @@ void flexinit (int argc, char **argv) break; case OPT_NO_YY_PUSH_STATE: - //buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0); break; case OPT_NO_YY_POP_STATE: - //buf_strdefine (&userdef_buf, "YY_NO_POP_STATE", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0); break; case OPT_NO_YY_TOP_STATE: - //buf_strdefine (&userdef_buf, "YY_NO_TOP_STATE", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0); break; case OPT_NO_UNPUT: - //buf_strdefine (&userdef_buf, "YY_NO_UNPUT", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0); break; case OPT_NO_YY_SCAN_BUFFER: - //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BUFFER", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0); break; case OPT_NO_YY_SCAN_BYTES: - //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BYTES", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0); break; case OPT_NO_YY_SCAN_STRING: - //buf_strdefine (&userdef_buf, "YY_NO_SCAN_STRING", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0); break; case OPT_NO_YYGET_EXTRA: - //buf_strdefine (&userdef_buf, "YY_NO_GET_EXTRA", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0); break; case OPT_NO_YYSET_EXTRA: - //buf_strdefine (&userdef_buf, "YY_NO_SET_EXTRA", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0); break; case OPT_NO_YYGET_LENG: - //buf_strdefine (&userdef_buf, "YY_NO_GET_LENG", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0); break; case OPT_NO_YYGET_TEXT: - //buf_strdefine (&userdef_buf, "YY_NO_GET_TEXT", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0); break; case OPT_NO_YYGET_LINENO: - //buf_strdefine (&userdef_buf, "YY_NO_GET_LINENO", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0); break; case OPT_NO_YYSET_LINENO: - //buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0); break; case OPT_NO_YYGET_COLUMN: - //buf_strdefine (&userdef_buf, "YY_NO_GET_COLUMN", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_COLUMN",0); break; case OPT_NO_YYSET_COLUMN: - //buf_strdefine (&userdef_buf, "YY_NO_SET_COLUMN", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_COLUMN",0); break; case OPT_NO_YYGET_IN: - //buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0); break; case OPT_NO_YYSET_IN: - //buf_strdefine (&userdef_buf, "YY_NO_SET_IN", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0); break; case OPT_NO_YYGET_OUT: - //buf_strdefine (&userdef_buf, "YY_NO_GET_OUT", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0); break; case OPT_NO_YYSET_OUT: - //buf_strdefine (&userdef_buf, "YY_NO_SET_OUT", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0); break; case OPT_NO_YYGET_LVAL: - //buf_strdefine (&userdef_buf, "YY_NO_GET_LVAL", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0); break; case OPT_NO_YYSET_LVAL: - //buf_strdefine (&userdef_buf, "YY_NO_SET_LVAL", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0); break; case OPT_NO_YYGET_LLOC: - //buf_strdefine (&userdef_buf, "YY_NO_GET_LLOC", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0); break; case OPT_NO_YYSET_LLOC: - //buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1"); buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0); break; case OPT_HEX: @@ -1186,8 +1158,6 @@ void readin (void) yyout = stdout; - /* always generate the tablesverify flag. */ - buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); if (tablesext) gentables = false; @@ -1229,13 +1199,6 @@ void readin (void) if (skelname && (skelfile = fopen (skelname, "r")) == NULL) lerr (_("can't open skeleton file %s"), skelname); - if (reentrant) { - buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL); - if (yytext_is_array) - buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL); - } else - buf_m4_define (&m4defs_buf, "M4_YY_NOT_REENTRANT", NULL); - if ( bison_bridge_lval) buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); @@ -1411,6 +1374,24 @@ void readin (void) backend->comment("m4 controls begin\n"); + if (extra_type != NULL) + visible_define_str ("M4_EXTRA_TYPE_DEFS", extra_type); + + /* always generate the tablesverify flag. */ + visible_define_str ("M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); + + if (reentrant) { + visible_define ("M4_YY_REENTRANT"); + if (yytext_is_array) + visible_define ("M4_YY_TEXT_IS_ARRAY"); + } else + visible_define ("M4_YY_NOT_REENTRANT"); + + if (do_main == 2) + visible_define_str ( "YY_MAIN", "1"); + else if (do_main == 1) + visible_define_str ( "YY_MAIN", "0"); + if (do_stdinit) visible_define ( "M4_MODE_DO_STDINIT"); else @@ -1482,7 +1463,7 @@ void readin (void) if (useecs) visible_define ( "M4_MODE_USEECS"); else - visible_define ( "M4_NOT_MODE_USEECS"); + visible_define ( "M4_MODE_NO_USEECS"); // mode switches for getting next action if (gentables) @@ -1507,7 +1488,7 @@ void readin (void) visible_define ( "M4_MODE_DEBUG"); if (lex_compat) - visible_define ( "M4_LEX_COMPAT"); + visible_define ( "M4_MODE_LEX_COMPAT"); if (do_yywrap) visible_define ( "M4_MODE_YYWRAP"); @@ -1526,7 +1507,7 @@ void readin (void) if (tablesext) visible_define ( "M4_MODE_TABLESEXT"); if (prefix != NULL) - out_m4_define ( "M4_MODE_PREFIX", prefix); // FIXME: should be visible + visible_define_str ( "M4_MODE_PREFIX", prefix); backend->comment("m4 controls end\n"); out ("\n"); diff --git a/src/misc.c b/src/misc.c index 8bf4609..eb3e8d1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -88,7 +88,7 @@ static void sko_pop(bool* dc) flex_die("popped too many times in skeleton."); } -/* Append "#define defname value\n" to the running buffer. */ +/* Append a constant declaration to the running buffer. */ void action_define (const char *defname, int value) { char buf[MAXLINE]; @@ -104,7 +104,9 @@ void action_define (const char *defname, int value) snprintf (buf, sizeof(buf), backend->int_define_fmt, defname, value); add_action (buf); - /* track #defines so we can undef them when we're done. */ + /* track definitions so we can naybe undef them when we're done; + * this is only ever likely to work with the cpp back end. + */ cpy = xstrdup(defname); buf_append (&defs_buf, &cpy, 1); } -- cgit v1.2.1 From 99e6b1c89a8e889991acf5de3da4a665dfeda023 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 1 Oct 2020 02:30:43 -0400 Subject: Impose some namespace control on the global variables. As I was working on some layer separation. I realized that I was getting confused a lot by the huge pile of globals that control this program. In particular, I need to be able to clearly distinguish those that set m4 conditional symbols from those that don't. So I've done something about it. Almost all globals that can be set by options are now bundled into two context structures, "ctrl" for options that have corresponding m4 symbols and "env" for options that don't. The few I haven't moved have sufficiently tricky interdependencies that I'm going to break out any changes related to them into smaller patches that can be easier to review. In this one I did only the bulk of straightforward changes that could be done mechanically with search and replace. I changed one varuable name to reflext its senantics better; the performance_report global is now env.performance_hint. Ideally there ought to be a third structure that bundles all the shared state used by DFA/NDFSA table computation, so all globals would live in one of three context structures. I may do that in a later commit, but this patch is already unpleasantly large as it is. No diffs in generated test code, nor any logic changes. #52 in the retargeting patch series. --- src/Makefile.am | 2 +- src/buf.c | 2 +- src/ccl.c | 10 +- src/cpp_backend.c | 60 +++---- src/dfa.c | 48 +++--- src/filter.c | 24 +-- src/flexdef.h | 131 ++++++++------- src/gen.c | 60 +++---- src/main.c | 483 ++++++++++++++++++++++++++---------------------------- src/misc.c | 30 ++-- src/nfa.c | 6 +- src/options.c | 2 +- src/parse.y | 38 ++--- src/scan.l | 128 +++++++-------- src/scanopt.c | 10 +- src/scanopt.h | 4 +- src/tblcmp.c | 8 +- src/yylex.c | 4 +- 18 files changed, 524 insertions(+), 526 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 40ca850..2fefc38 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,7 +65,7 @@ COMMON_SOURCES = \ main.c \ misc.c \ nfa.c \ - options.c \ + ctrl.c \ options.h \ parse.y \ regex.c \ diff --git a/src/buf.c b/src/buf.c index c0d53a4..0ed7d06 100644 --- a/src/buf.c +++ b/src/buf.c @@ -95,7 +95,7 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno) const char *src; size_t tsz; - if (gen_line_dirs) + if (ctrl.gen_line_dirs) return buf; tsz = strlen("#line \"\"\n") + /* constant parts */ diff --git a/src/ccl.c b/src/ccl.c index 5c5af13..8df3125 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -101,7 +101,7 @@ static void dump_cclp (FILE* file, int cclp) putc ('[', file); - for (i = 0; i < csize; ++i) { + for (i = 0; i < ctrl.csize; ++i) { if (ccl_contains(cclp, i)){ int start_char = i; @@ -109,7 +109,7 @@ static void dump_cclp (FILE* file, int cclp) fputs (readable_form (i), file); - while (++i < csize && ccl_contains(cclp,i)) ; + while (++i < ctrl.csize && ccl_contains(cclp,i)) ; if (i - 1 > start_char) /* this was a run */ @@ -138,7 +138,7 @@ ccl_set_diff (int a, int b) * addding each char in a that is not in b. * (This could be O(n^2), but n is small and bounded.) */ - for ( ch = 0; ch < csize; ++ch ) + for ( ch = 0; ch < ctrl.csize; ++ch ) if (ccl_contains (a, ch) && !ccl_contains(b, ch)) ccladd (d, ch); @@ -250,7 +250,7 @@ void list_character_set (FILE *file, int cset[]) putc ('[', file); - for (i = 0; i < csize; ++i) { + for (i = 0; i < ctrl.csize; ++i) { if (cset[i]) { int start_char = i; @@ -258,7 +258,7 @@ void list_character_set (FILE *file, int cset[]) fputs (readable_form (i), file); - while (++i < csize && cset[i]) ; + while (++i < ctrl.csize && cset[i]) ; if (i - 1 > start_char) /* this was a run */ diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 1ee1f66..7342cae 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -79,7 +79,7 @@ static const char *cpp_suffix (void) { char *suffix; - if (C_plus_plus) + if (ctrl.C_plus_plus) suffix = "cc"; else suffix = "c"; @@ -107,7 +107,7 @@ static void cpp_ntod(size_t num_full_table_rows) { buf_prints (&yydmap_buf, "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); /* Unless -Ca, declare it "short" because it's a real * long-shot that that won't be large enough. @@ -115,12 +115,12 @@ static void cpp_ntod(size_t num_full_table_rows) if (gentables) out_str_dec ("static const %s yy_nxt[][%d] =\n {\n", - long_align ? "flex_int32_t" : "flex_int16_t", + ctrl.long_align ? "flex_int32_t" : "flex_int16_t", num_full_table_rows); else { out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); out_str ("static const %s *yy_nxt =0;\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); } /* It would be no good trying to return an allocation size here, * as it's not known before table generation is finished. @@ -140,7 +140,7 @@ static void cpp_mkctbl (size_t sz) buf_prints (&yydmap_buf, "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n", (sz >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); + || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); } static size_t cpp_gen_yy_trans(size_t sz) @@ -170,37 +170,37 @@ static void cpp_mkftbl(void) // FIXME: why are there two places this is emitted, here and in cpp_gentabs_accept()? buf_prints (&yydmap_buf, "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); + ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); } static size_t cpp_genftbl(size_t sz) { - out_str_dec (long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), + out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_accept", sz); - return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); + return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_gentabs_acclist(size_t sz) // Generate accept list initializer { - out_str_dec (long_align ? cpp_get_int32_decl () : + out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_acclist", sz); buf_prints (&yydmap_buf, "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); + ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); + return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_gentabs_accept(size_t sz) // Generate accept table initializer { - out_str_dec (long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), + out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_accept", sz); buf_prints (&yydmap_buf, "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "flex_int32_t" : "flex_int16_t"); - return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); + ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); + return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_gentabs_yy_meta(size_t sz) @@ -216,54 +216,54 @@ static size_t cpp_gentabs_yy_meta(size_t sz) static size_t cpp_gentabs_yy_base(size_t sz) // Generate yy_meta base initializer { - out_str_dec ((tblend >= INT16_MAX || long_align) ? + out_str_dec ((tblend >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_base", sz); buf_prints (&yydmap_buf, "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", (sz >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - return sz * ((sz >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); + || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); + return sz * ((sz >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_gentabs_yy_def(size_t sz) // Generate yy_def initializer { - out_str_dec ((sz >= INT16_MAX || long_align) ? + out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_def", sz); buf_prints (&yydmap_buf, "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", (sz >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - return sz * ((sz >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); + || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); + return sz * ((sz >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_gentabs_yy_nxt(size_t tblafter) // Generate yy_nxt initializer { /* Begin generating yy_nxt */ - out_str_dec ((tblafter >= INT16_MAX || long_align) ? + out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_nxt", tblafter); buf_prints (&yydmap_buf, "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", (tblafter >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - return tblafter * ((tblafter >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); + || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); + return tblafter * ((tblafter >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_gentabs_yy_chk(size_t tblafter) // Generate yy_chk initializer { - out_str_dec ((tblafter >= INT16_MAX || long_align) ? + out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_chk", tblafter); buf_prints (&yydmap_buf, "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", (tblafter >= INT16_MAX - || long_align) ? "flex_int32_t" : "flex_int16_t"); - return tblafter * ((tblafter >= INT16_MAX || long_align) ? sizeof(int32_t) : sizeof(int16_t)); + || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); + return tblafter * ((tblafter >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_nultrans(int fullspd, size_t afterdfa) @@ -281,22 +281,22 @@ static size_t cpp_nultrans(int fullspd, size_t afterdfa) static size_t cpp_debug_header(size_t sz) { - out_str_dec (long_align ? cpp_get_int32_decl () : + out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_rule_linenum", sz); - return sz * (long_align ? sizeof(int32_t) : sizeof(int16_t)); + return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); } static size_t cpp_genecs(size_t size) { - out_str_dec (cpp_get_yy_char_decl (), "yy_ec", csize); + out_str_dec (cpp_get_yy_char_decl (), "yy_ec", ctrl.csize); return sizeof(YY_CHAR) * size; } static const char *cpp_trans_offset_type(int total_table_size) { - return (total_table_size >= INT16_MAX || long_align) ? + return (total_table_size >= INT16_MAX || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"; } diff --git a/src/dfa.c b/src/dfa.c index ad16de9..2b44017 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -54,19 +54,19 @@ void check_for_backing_up (int ds, int state[]) if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */ ++num_backing_up; - if (backing_up_report) { - fprintf (backing_up_file, + if (env.backing_up_report) { + fprintf (ctrl.backing_up_file, _("State #%d is non-accepting -\n"), ds); /* identify the state */ - dump_associated_rules (backing_up_file, ds); + dump_associated_rules (ctrl.backing_up_file, ds); /* Now identify it further using the out- and * jam-transitions. */ - dump_transitions (backing_up_file, state); + dump_transitions (ctrl.backing_up_file, state); - putc ('\n', backing_up_file); + putc ('\n', ctrl.backing_up_file); } } } @@ -185,7 +185,7 @@ void dump_transitions (FILE *file, int state[]) int i, ec; int out_char_set[CSIZE]; - for (i = 0; i < csize; ++i) { + for (i = 0; i < ctrl.csize; ++i) { ec = ABS (ecgroup[i]); out_char_set[i] = state[ec]; } @@ -195,7 +195,7 @@ void dump_transitions (FILE *file, int state[]) list_character_set (file, out_char_set); /* now invert the members of the set to get the jam transitions */ - for (i = 0; i < csize; ++i) + for (i = 0; i < ctrl.csize; ++i) out_char_set[i] = !out_char_set[i]; fprintf (file, _("\n jam-transitions: EOF ")); @@ -409,7 +409,7 @@ size_t ntod (void) */ todo_head = todo_next = 0; - for (i = 0; i <= csize; ++i) { + for (i = 0; i <= ctrl.csize; ++i) { duplist[i] = NIL; symlist[i] = false; } @@ -417,7 +417,7 @@ size_t ntod (void) for (i = 0; i <= num_rules; ++i) accset[i] = NIL; - if (trace) { + if (env.trace) { dumpnfa (scset[1]); fputs (_("\n\nDFA Dump:\n\n"), stderr); } @@ -456,17 +456,17 @@ size_t ntod (void) /* Note that the test for ecgroup[0] == numecs below accomplishes * both (1) and (2) above */ - if (!fullspd && ecgroup[0] == numecs) { + if (!ctrl.fullspd && ecgroup[0] == numecs) { /* NUL is alone in its equivalence class, which is the * last one. */ - int use_NUL_table = (numecs == csize); + int use_NUL_table = (numecs == ctrl.csize); - if (fulltbl && !use_NUL_table) { + if (ctrl.fulltbl && !use_NUL_table) { /* We still may want to use the table if numecs * is a power of 2. */ - if (numecs <= csize && is_power_of_2(numecs)) { + if (numecs <= ctrl.csize && is_power_of_2(numecs)) { use_NUL_table = true; } } @@ -481,7 +481,7 @@ size_t ntod (void) } - if (fullspd) { + if (ctrl.fullspd) { for (i = 0; i <= numecs; ++i) state[i] = 0; @@ -489,7 +489,7 @@ size_t ntod (void) dfaacc[0].dfaacc_state = 0; } - else if (fulltbl) { + else if (ctrl.fulltbl) { if (nultrans) /* We won't be including NUL's transitions in the * table, so build it for entries from 0 .. numecs - 1. @@ -567,7 +567,7 @@ size_t ntod (void) } } - if (!fullspd) { + if (!ctrl.fullspd) { if (!snstods (nset, 0, accset, 0, 0, &end_of_buffer_state)) flexfatal (_ ("could not create unique end-of-buffer state")); @@ -590,7 +590,7 @@ size_t ntod (void) dset = dss[ds]; dsize = dfasiz[ds]; - if (trace) + if (env.trace) fprintf (stderr, _("state # %d:\n"), ds); sympartition (dset, dsize, symlist, duplist); @@ -627,7 +627,7 @@ size_t ntod (void) state[sym] = newds; - if (trace) + if (env.trace) fprintf (stderr, "\t%d\t%d\n", sym, newds); @@ -645,7 +645,7 @@ size_t ntod (void) targ = state[duplist[sym]]; state[sym] = targ; - if (trace) + if (env.trace) fprintf (stderr, "\t%d\t%d\n", sym, targ); @@ -677,7 +677,7 @@ size_t ntod (void) state[NUL_ec] = 0; /* remove transition */ } - if (fulltbl) { + if (ctrl.fulltbl) { /* Each time we hit here, it's another td_hilen, so we realloc. */ yynxt_tbl->td_hilen++; @@ -715,7 +715,7 @@ size_t ntod (void) out (backend->table_continuation); } - else if (fullspd) + else if (ctrl.fullspd) place_state (state, ds, totaltrans); else if (ds == end_of_buffer_state) @@ -743,7 +743,7 @@ size_t ntod (void) } } - if (fulltbl) { + if (ctrl.fulltbl) { dataend (); if (tablesext) { yytbl_data_compress (yynxt_tbl); @@ -757,7 +757,7 @@ size_t ntod (void) } } - else if (!fullspd) { + else if (!ctrl.fullspd) { cmptmps (); /* create compressed template entries */ /* Create tables for all the states with only one @@ -1009,7 +1009,7 @@ void sympartition (int ds[], int numstates, int symlist[], int duplist[]) tch = transchar[ns]; if (tch != SYM_EPSILON) { - if (tch < -lastccl || tch >= csize) { + if (tch < -lastccl || tch >= ctrl.csize) { flexfatal (_ ("bad transition character detected in sympartition()")); } diff --git a/src/filter.c b/src/filter.c index 9a5e777..edf1ed8 100644 --- a/src/filter.c +++ b/src/filter.c @@ -263,9 +263,9 @@ int filter_tee_header (struct filter *chain) fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); - fprintf (to_h, "#ifndef %sHEADER_H\n", prefix); - fprintf (to_h, "#define %sHEADER_H 1\n", prefix); - fprintf (to_h, "#define %sIN_HEADER 1\n\n", prefix); + fprintf (to_h, "#ifndef %sHEADER_H\n", ctrl.prefix); + fprintf (to_h, "#define %sHEADER_H 1\n", ctrl.prefix); + fprintf (to_h, "#define %sIN_HEADER 1\n\n", ctrl.prefix); fprintf (to_h, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", headerfilename ? headerfilename : ""); @@ -278,7 +278,7 @@ int filter_tee_header (struct filter *chain) fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c); fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_c); fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", - outfilename ? outfilename : ""); + env.outfilename != NULL ? env.outfilename : ""); while (fgets (buf, sizeof buf, stdin)) { fputs (buf, to_c); @@ -290,11 +290,11 @@ int filter_tee_header (struct filter *chain) fprintf (to_h, "\n"); /* write a fake line number. It will get fixed by the linedir filter. */ - if (gen_line_dirs) + if (ctrl.gen_line_dirs) fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n"); - fprintf (to_h, "#undef %sIN_HEADER\n", prefix); - fprintf (to_h, "#endif /* %sHEADER_H */\n", prefix); + fprintf (to_h, "#undef %sIN_HEADER\n", ctrl.prefix); + fprintf (to_h, "#endif /* %sHEADER_H */\n", ctrl.prefix); fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h); fflush (to_h); @@ -310,11 +310,11 @@ int filter_tee_header (struct filter *chain) fflush (to_c); if (ferror (to_c)) lerr (_("error writing output file %s"), - outfilename ? outfilename : ""); + env.outfilename != NULL ? env.outfilename : ""); else if (fclose (to_c)) lerr (_("error closing output file %s"), - outfilename ? outfilename : ""); + env.outfilename != NULL ? env.outfilename : ""); while (wait (0) > 0) ; @@ -360,7 +360,7 @@ int filter_fix_linedirs (struct filter *chain) fname = regmatch_dup (&m[2], buf); if (strcmp (fname, - outfilename ? outfilename : "") + env.outfilename != NULL ? env.outfilename : "") == 0 || strcmp (fname, headerfilename ? headerfilename : "") @@ -418,11 +418,11 @@ int filter_fix_linedirs (struct filter *chain) fflush (stdout); if (ferror (stdout)) lerr (_("error writing output file %s"), - outfilename ? outfilename : ""); + env.outfilename != NULL ? env.outfilename : ""); else if (fclose (stdout)) lerr (_("error closing output file %s"), - outfilename ? outfilename : ""); + env.outfilename != NULL ? env.outfilename : ""); return 0; } diff --git a/src/flexdef.h b/src/flexdef.h index f7c2cf6..929baf7 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -113,8 +113,6 @@ /* Whether an integer is a power of two */ #define is_power_of_2(n) ((n) > 0 && ((n) & ((n) - 1)) == 0) -#define unspecified -1 - /* Special chk[] values marking the slots taking by end-of-buffer and action * numbers. */ @@ -345,50 +343,83 @@ struct flex_backend_t { extern size_t footprint; +typedef enum trit_t { + trit_unspecified = -1, + trit_false = 0, + trit_true = 1, +} trit; + extern struct flex_backend_t cpp_backend; +/* Control variables. These are in a struct to avoid having to replicate definitions + * twice for each option, instead a single struct can be declared and externed. + * If it;s in this structure, it has a corresponding m4 symbol. + */ +struct ctrl_bundle_t { + FILE *backing_up_file; // file to summarize backing-up states to + bool bison_bridge_lval; // (--bison-bridge), bison pure calling convention. + bool bison_bridge_lloc; // (--bison-locations), bison yylloc. + bool C_plus_plus; // (-+ flag) generate a C++ scanner class + int csize; // size of character set for the scanner + // 128 for 7-bit chars and 256 for 8-bit + bool ddebug; // (-d) make a "debug" scanner + trit do_main; // generate main part to make lexer standalone. + bool do_stdinit; // whether to initialize yyin/yyout to stdin/stdout + bool do_yylineno; // if true, generate code to maintain yylineno + bool do_yywrap; // do yywrap() processing on EOF. + // If false, EOF treated as "no more files" + bool fullspd; // (-F flag) use Jacobson method of table representation + bool fulltbl; // (-Cf flag) don't compress the DFA state table + bool gen_line_dirs; // (no -L flag) generate #line directives + trit interactive; // (-I) generate an interactive scanner + bool lex_compat; // (-l), maximize compatibility with AT&T lex + bool long_align; // (-Ca flag), favor long-word alignment for speed + bool posix_compat; // (-X) maximize compatibility with POSIX lex + char *prefix; // prefix for externally visible names, default "yy" + bool reentrant; // if true (-R), generate a reentrant C scanner + bool spprdflt; // (-s) suppress the default rule + bool useecs; // (-Ce flag) use equivalence classes + bool usemecs; // (-Cm flag), use meta-equivalence classes + bool use_read; // (-f, -F, or -Cr) use read() for scanner input + // otherwise, use fread(). + char *yyclass; // yyFlexLexer subclass to use for YY_DECL +}; + +/* Environment variables. These control the lexer operation, but do + * not have corresponding m4 symbols and do not affect the behavior of + * the generated parser. + */ +struct env_bundle_t { + bool backing_up_report; // (-b flag), generate "lex.backup" file + // listing backing-up states + bool did_outfilename; // whether outfilename was explicitly set + bool nowarn; // (-w) do not generate warnings + int performance_hint; // if > 0 (i.e., -p flag), generate a report + // relating to scanner performance; + // if > 1 (-p -p), report + // on minor performance problems, too. + char *outfilename; // output file name + bool printstats; // (-v) dump statistics + char *skelname; // name of skeleton for code generation + FILE *skelfile; // the skeleton file'd descriptor + bool trace; // (-T) env.trace processing + bool trace_hex; // use hex in trace/debug outputs not octal + bool use_stdout; // the -t flag +}; + +extern struct ctrl_bundle_t ctrl; +extern struct env_bundle_t env; + /* Declarations for global variables. */ /* Variables for flags: - * printstats - if true (-v), dump statistics * syntaxerror - true if a syntax error has been found * eofseen - true if we've seen an eof in the input file - * ddebug - if true (-d), make a "debug" scanner - * trace - if true (-T), trace processing - * nowarn - if true (-w), do not generate warnings - * spprdflt - if true (-s), suppress the default rule - * interactive - if true (-I), generate an interactive scanner - * lex_compat - if true (-l), maximize compatibility with AT&T lex - * posix_compat - if true (-X), maximize compatibility with POSIX lex - * do_yylineno - if true, generate code to maintain yylineno - * useecs - if true (-Ce flag), use equivalence classes - * fulltbl - if true (-Cf flag), don't compress the DFA state table - * usemecs - if true (-Cm flag), use meta-equivalence classes - * fullspd - if true (-F flag), use Jacobson method of table representation - * gen_line_dirs - if true (i.e., no -L flag), generate #line directives - * performance_report - if > 0 (i.e., -p flag), generate a report relating - * to scanner performance; if > 1 (-p -p), report on minor performance - * problems, too - * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file - * listing backing-up states - * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class; - * otherwise, a standard C scanner - * reentrant - if true (-R), generate a reentrant C scanner. - * bison_bridge_lval - if true (--bison-bridge), bison pure calling convention. - * bison_bridge_lloc - if true (--bison-locations), bison yylloc. - * long_align - if true (-Ca flag), favor long-word alignment. - * use_read - if true (-f, -F, or -Cr) then use read() for scanner input; - * otherwise, use fread(). * yytext_is_array - if true (i.e., %array directive), then declare * yytext as a array instead of a character pointer. Nice and inefficient. - * do_yywrap - do yywrap() processing on EOF. If false, EOF treated as - * "no more files". - * do_main - generate a trivial main part to make the lexer standalone. * Note that 0 is unset, 1 corresponds to --no-main, and 2 to --main. - * csize - size of character set for the scanner we're generating; - * 128 for 7-bit chars and 256 for 8-bit - * yymore_used - if true, yymore() is used in input rules +ya * yymore_used - if true, yymore() is used in input rules * reject - if true, generate back-up tables for REJECT macro * real_reject - if true, scanner really uses REJECT (as opposed to just * having "reject" set for variable trailing context) @@ -398,21 +429,12 @@ extern struct flex_backend_t cpp_backend; * yymore_really_used - whether to treat yymore() as really used, regardless * of what we think based on references to it in the user's actions. * reject_really_used - same for REJECT - * trace_hex - use hexadecimal numbers in trace/debug outputs instead of octals - */ + */ -extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, - spprdflt; -extern int interactive, lex_compat, posix_compat, do_yylineno; -extern int useecs, fulltbl, usemecs, fullspd; -extern int gen_line_dirs, performance_report, backing_up_report; -extern int reentrant, bison_bridge_lval, bison_bridge_lloc; -extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap; -extern int csize, do_main; +extern int syntaxerror, eofseen; +extern int yytext_is_array; extern int yymore_used, reject, real_reject, continued_action, in_rule; - extern int yymore_really_used, reject_really_used; -extern int trace_hex; extern struct flex_backend_t *backend; @@ -421,19 +443,12 @@ extern struct flex_backend_t *backend; * dataline - number of contiguous lines of data in current data * statement. Used to generate readable -f output * linenum - current input line number - * skelfile - the skeleton file * skel - compiled-in skeleton array * skel_ind - index into "skel" array, if skelfile is nil * yyin - input file - * backing_up_file - file to summarize backing-up states to * infilename - name of input file * outfilename - name of output file * headerfilename - name of the .h file to generate - * did_outfilename - whether outfilename was explicitly set - * prefix - the prefix used for externally visible names ("yy" by default) - * yyclass - yyFlexLexer subclass to use for YY_DECL - * do_stdinit - whether to initialize yyin/yyout to stdin/stdout - * use_stdout - the -t flag * input_files - array holding names of input files * num_input_files - size of input_files array * program_name - name with which program was invoked @@ -449,13 +464,9 @@ extern struct flex_backend_t *backend; */ extern int datapos, dataline, linenum; -extern FILE *skelfile, *backing_up_file; -extern const char *skel[]; extern int skel_ind; -extern char *infilename, *outfilename, *headerfilename; -extern int did_outfilename; -extern char *prefix, *yyclass, *extra_type; -extern int do_stdinit, use_stdout; +extern char *infilename, *headerfilename; +extern char *extra_type; extern char **input_files; extern int num_input_files; extern char *program_name; diff --git a/src/gen.c b/src/gen.c index a8e20a5..940801a 100644 --- a/src/gen.c +++ b/src/gen.c @@ -300,7 +300,7 @@ void genctbl (void) dataend (); } - if (useecs) + if (ctrl.useecs) genecs (); } @@ -317,12 +317,12 @@ static struct yytbl_data *mkecstbl (void) yytbl_data_init (tbl, YYTD_ID_EC); tbl->td_flags |= YYTD_DATA32; tbl->td_hilen = 0; - tbl->td_lolen = (flex_uint32_t) csize; + tbl->td_lolen = (flex_uint32_t) ctrl.csize; tbl->td_data = tdata = calloc(tbl->td_lolen, sizeof (flex_int32_t)); - for (i = 1; i < csize; ++i) { + for (i = 1; i < ctrl.csize; ++i) { ecgroup[i] = ABS (ecgroup[i]); tdata[i] = ecgroup[i]; } @@ -337,23 +337,23 @@ void genecs (void) int ch, row; int numrows; - footprint += backend->genecs(csize); + footprint += backend->genecs(ctrl.csize); - for (ch = 1; ch < csize; ++ch) { + for (ch = 1; ch < ctrl.csize; ++ch) { ecgroup[ch] = ABS (ecgroup[ch]); mkdata (ecgroup[ch]); } dataend (); - if (trace) { + if (env.trace) { fputs (_("\n\nEquivalence Classes:\n\n"), stderr); /* Print in 8 columns */ - numrows = csize / 8; + numrows = ctrl.csize / 8; for (row = 0; row < numrows; ++row) { - for (ch = row; ch < csize; ch += numrows) { + for (ch = row; ch < ctrl.csize; ch += numrows) { fprintf (stderr, "%4s = %-2d", readable_form (ch), ecgroup[ch]); @@ -392,7 +392,7 @@ struct yytbl_data *mkftbl (void) tdata[i] = anum; - if (trace && anum) + if (env.trace && anum) fprintf (stderr, _("state # %d accepts: [%d]\n"), i, anum); } @@ -417,14 +417,14 @@ void genftbl (void) mkdata (anum); - if (trace && anum) + if (env.trace && anum) fprintf (stderr, _("state # %d accepts: [%d]\n"), i, anum); } dataend (); - if (useecs) + if (ctrl.useecs) genecs (); /* Don't have to dump the actual full table entries - they were @@ -488,7 +488,7 @@ void gentabs (void) accset = dfaacc[i].dfaacc_set; nacc = accsiz[i]; - if (trace) + if (env.trace) fprintf (stderr, _("state # %d accepts: "), i); @@ -515,7 +515,7 @@ void gentabs (void) mkdata (accnum); yyacclist_data[yyacclist_curr++] = accnum; - if (trace) { + if (env.trace) { fprintf (stderr, "[%d]", accset[k]); @@ -587,7 +587,7 @@ void gentabs (void) mkdata (acc_array[i]); yyacc_data[yyacc_curr++] = acc_array[i]; - if (!reject && trace && acc_array[i]) + if (!reject && env.trace && acc_array[i]) fprintf (stderr, _("state # %d accepts: [%d]\n"), i, acc_array[i]); } @@ -612,7 +612,7 @@ void gentabs (void) yyacc_tbl = NULL; /* End generating yy_accept */ - if (useecs) { + if (ctrl.useecs) { genecs (); if (tablesext) { @@ -627,7 +627,7 @@ void gentabs (void) } } - if (usemecs) { + if (ctrl.usemecs) { /* Begin generating yy_meta */ /* Write out meta-equivalence classes (used to index * templates with). @@ -640,14 +640,14 @@ void gentabs (void) calloc(yymeta_tbl->td_lolen, sizeof (flex_int32_t)); - if (trace) + if (env.trace) fputs (_("\n\nMeta-Equivalence Classes:\n"), stderr); footprint += backend->gentabs_yy_meta(numecs + 1); for (i = 1; i <= numecs; ++i) { - if (trace) + if (env.trace) fprintf (stderr, "%d = %d\n", i, ABS (tecbck[i])); @@ -837,11 +837,11 @@ void make_tables (void) visible_define ( "M4_MODE_NULTRANS"); else { visible_define ( "M4_MODE_NO_NULTRANS"); - if (fulltbl) + if (ctrl.fulltbl) visible_define ( "M4_MODE_NULTRANS_FULLTBL"); else visible_define ( "M4_MODE_NO_NULTRANS_FULLTBL"); - if (fullspd) + if (ctrl.fullspd) visible_define ( "M4_MODE_NULTRANS_FULLSPD"); else visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); @@ -870,7 +870,7 @@ void make_tables (void) /* This is where we REALLY begin generating the tables. */ - if (fullspd) { + if (ctrl.fullspd) { genctbl (); if (tablesext) { struct yytbl_data *tbl; @@ -888,7 +888,7 @@ void make_tables (void) yytbl_data_destroy (tbl); tbl = 0; - if (useecs) { + if (ctrl.useecs) { tbl = mkecstbl (); yytbl_data_compress (tbl); if (yytbl_data_fwrite (&tableswr, tbl) < 0) @@ -899,7 +899,7 @@ void make_tables (void) } } } - else if (fulltbl) { + else if (ctrl.fulltbl) { genftbl (); if (tablesext) { struct yytbl_data *tbl; @@ -911,7 +911,7 @@ void make_tables (void) yytbl_data_destroy (tbl); tbl = 0; - if (useecs) { + if (ctrl.useecs) { tbl = mkecstbl (); yytbl_data_compress (tbl); if (yytbl_data_fwrite (&tableswr, tbl) < 0) @@ -938,15 +938,15 @@ void make_tables (void) visible_define ( "M4_MODE_HAS_BACKING_UP"); // These are used for NUL transitions - if ((num_backing_up > 0 && !reject) && (!nultrans || fullspd || fulltbl)) + if ((num_backing_up > 0 && !reject) && (!nultrans || ctrl.fullspd || ctrl.fulltbl)) visible_define ( "M4_MODE_NEED_YY_CP"); - if ((num_backing_up > 0 && !reject) && (fullspd || fulltbl)) + if ((num_backing_up > 0 && !reject) && (ctrl.fullspd || ctrl.fulltbl)) visible_define ( "M4_MODE_NULTRANS_WRAP"); backend->comment("m4 controls end\n"); out ("\n"); - if (do_yylineno) { + if (ctrl.do_yylineno) { geneoltbl (); @@ -966,12 +966,12 @@ void make_tables (void) flex_int32_t *yynultrans_data = 0; /* Begin generating yy_NUL_trans */ - footprint += backend->nultrans(fullspd, lastdfa + 1); + footprint += backend->nultrans(ctrl.fullspd, lastdfa + 1); yynultrans_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); // Performance kludge for C. Gives a small improvement // in table loading time. - if (fullspd && backend->c_like) + if (ctrl.fullspd && backend->c_like) yynultrans_tbl->td_flags |= YYTD_PTRANS; yynultrans_tbl->td_lolen = (flex_uint32_t) (lastdfa + 1); yynultrans_tbl->td_data = yynultrans_data = @@ -1009,7 +1009,7 @@ void make_tables (void) /* End generating yy_NUL_trans */ } - if (ddebug) { /* Spit out table mapping rules to line numbers. */ + if (ctrl.ddebug) { /* Spit out table mapping rules to line numbers. */ /* Policy choice: this returns the table size * but we don't include it in the table metering. */ diff --git a/src/main.c b/src/main.c index b95b181..122b113 100644 --- a/src/main.c +++ b/src/main.c @@ -47,26 +47,17 @@ void readin(void); void set_up_initial_allocations(void); /* these globals are all defined and commented in flexdef.h */ -int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; -int interactive, lex_compat, posix_compat, do_yylineno, - useecs, fulltbl, usemecs; -int fullspd, gen_line_dirs, performance_report, backing_up_report; -int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap, do_main, - csize; -int reentrant, bison_bridge_lval, bison_bridge_lloc; +int syntaxerror, eofseen, yytext_is_array; int yymore_used, reject, real_reject, continued_action, in_rule; int yymore_really_used, reject_really_used; -int trace_hex = 0; int datapos, dataline, linenum; FILE *skelfile = NULL; int skel_ind = 0; char *action_array; int action_size, defs1_offset, prolog_offset, action_offset, action_index; -char *infilename = NULL, *outfilename = NULL, *headerfilename = NULL; -int did_outfilename; -char *prefix, *yyclass, *extra_type = NULL; -int do_stdinit, use_stdout; +char *infilename = NULL, *headerfilename = NULL; +char *extra_type = NULL; int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; int maximum_mns, current_mns, current_max_rules; @@ -98,7 +89,6 @@ char nmstr[MAXLINE]; int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; int num_backing_up, bol_needed; -FILE *backing_up_file; int end_of_buffer_state; char **input_files; int num_input_files; @@ -113,6 +103,9 @@ char *tablesfilename=0,*tablesname=0; struct yytbl_writer tableswr; size_t footprint; +struct ctrl_bundle_t ctrl; +struct env_bundle_t env; + /* Make sure program_name is initialized so we don't crash if writing * out an error message before getting the program name from argv[0]. */ @@ -127,7 +120,6 @@ extern FILE* yyout; static char outfile_path[MAXLINE]; static int outfile_created = 0; -static char *skelname = NULL; static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */ const char *escaped_qstart = "]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[["; const char *escaped_qend = "]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[["; @@ -180,7 +172,7 @@ int flex_main (int argc, char *argv[]) line_warning (_("rule cannot be matched"), rule_linenum[i]); - if (spprdflt && !reject && rule_useful[default_rule]) + if (ctrl.spprdflt && !reject && rule_useful[default_rule]) line_warning (_ ("-s option given but default rule can be matched"), rule_linenum[default_rule]); @@ -218,114 +210,114 @@ void check_options (void) int i; const char * m4 = NULL; - if (lex_compat) { - if (C_plus_plus) + if (ctrl.lex_compat) { + if (ctrl.C_plus_plus) flexerror (_("Can't use -+ with -l option")); - if (fulltbl || fullspd) + if (ctrl.fulltbl || ctrl.fullspd) flexerror (_("Can't use -f or -F with -l option")); - if (reentrant || bison_bridge_lval) + if (ctrl.reentrant || ctrl.bison_bridge_lval) flexerror (_ - ("Can't use --reentrant or --bison-bridge with -l option")); + ("Can't use --ctrl.reentrant or --bison-bridge with -l option")); yytext_is_array = true; - do_yylineno = true; - use_read = false; + ctrl.do_yylineno = true; + ctrl.use_read = false; } #if 0 /* This makes no sense whatsoever. I'm removing it. */ - if (do_yylineno) + if (ctrl.do_yylineno) /* This should really be "maintain_backup_tables = true" */ reject_really_used = true; #endif - if (csize == unspecified) { - if ((fulltbl || fullspd) && !useecs) - csize = DEFAULT_CSIZE; + if (ctrl.csize == trit_unspecified) { + if ((ctrl.fulltbl || ctrl.fullspd) && !ctrl.useecs) + ctrl.csize = DEFAULT_CSIZE; else - csize = CSIZE; + ctrl.csize = CSIZE; } - if (interactive == unspecified) { - if (fulltbl || fullspd) - interactive = false; + if (ctrl.interactive == trit_unspecified) { + if (ctrl.fulltbl || ctrl.fullspd) + ctrl.interactive = trit_false; else - interactive = true; + ctrl.interactive = trit_true; } - if (fulltbl || fullspd) { - if (usemecs) + if (ctrl.fulltbl || ctrl.fullspd) { + if (ctrl.usemecs) flexerror (_ ("-Cf/-CF and -Cm don't make sense together")); - if (interactive) + if (ctrl.interactive != trit_false) flexerror (_("-Cf/-CF and -I are incompatible")); - if (lex_compat) + if (ctrl.lex_compat) flexerror (_ ("-Cf/-CF are incompatible with lex-compatibility mode")); - if (fulltbl && fullspd) + if (ctrl.fulltbl && ctrl.fullspd) flexerror (_ ("-Cf and -CF are mutually exclusive")); } - if (C_plus_plus && fullspd) + if (ctrl.C_plus_plus && ctrl.fullspd) flexerror (_("Can't use -+ with -CF option")); - if (C_plus_plus && yytext_is_array) { + if (ctrl.C_plus_plus && yytext_is_array) { lwarn (_("%array incompatible with -+ option")); yytext_is_array = false; } - if (C_plus_plus && (reentrant)) + if (ctrl.C_plus_plus && (ctrl.reentrant)) flexerror (_("Options -+ and --reentrant are mutually exclusive.")); - if (C_plus_plus && bison_bridge_lval) + if (ctrl.C_plus_plus && ctrl.bison_bridge_lval) flexerror (_("bison bridge not supported for the C++ scanner.")); - if (useecs) { /* Set up doubly-linked equivalence classes. */ + if (ctrl.useecs) { /* Set up doubly-linked equivalence classes. */ - /* We loop all the way up to csize, since ecgroup[csize] is + /* We loop all the way up to ctrl.csize, since ecgroup[ctrl.csize] is * the position used for NUL characters. */ ecgroup[1] = NIL; - for (i = 2; i <= csize; ++i) { + for (i = 2; i <= ctrl.csize; ++i) { ecgroup[i] = i - 1; nextecm[i - 1] = i; } - nextecm[csize] = NIL; + nextecm[ctrl.csize] = NIL; } else { /* Put everything in its own equivalence class. */ - for (i = 1; i <= csize; ++i) { + for (i = 1; i <= ctrl.csize; ++i) { ecgroup[i] = i; nextecm[i] = BAD_SUBSCRIPT; /* to catch errors */ } } - if (!use_stdout) { + if (!env.use_stdout) { FILE *prev_stdout; - if (!did_outfilename) { + if (!env.did_outfilename) { snprintf (outfile_path, sizeof(outfile_path), outfile_template, - prefix, backend->suffix()); + ctrl.prefix, backend->suffix()); - outfilename = outfile_path; + env.outfilename = outfile_path; } - prev_stdout = freopen (outfilename, "w+", stdout); + prev_stdout = freopen (env.outfilename, "w+", stdout); if (prev_stdout == NULL) - lerr (_("could not create %s"), outfilename); + lerr (_("could not create %s"), env.outfilename); outfile_created = 1; } @@ -396,135 +388,135 @@ void flexend (int exit_status) if (++called_before) FLEX_EXIT (exit_status); - if (yyclass && !C_plus_plus) + if (ctrl.yyclass != NULL && !ctrl.C_plus_plus) flexerror (_("%option yyclass only meaningful for C++ scanners")); if (skelfile != NULL) { if (ferror (skelfile)) lerr (_("input error reading skeleton file %s"), - skelname); + env.skelname); else if (fclose (skelfile)) lerr (_("error closing skeleton file %s"), - skelname); + env.skelname); } if (exit_status != 0 && outfile_created) { if (ferror (stdout)) lerr (_("error writing output file %s"), - outfilename); + env.outfilename); else if ((_stdout_closed = 1) && fclose (stdout)) lerr (_("error closing output file %s"), - outfilename); + env.outfilename); - else if (unlink (outfilename)) + else if (unlink (env.outfilename)) lerr (_("error deleting output file %s"), - outfilename); + env.outfilename); } - if (backing_up_report && backing_up_file) { + if (env.backing_up_report && ctrl.backing_up_file) { if (num_backing_up == 0) - fprintf (backing_up_file, _("No backing up.\n")); - else if (fullspd || fulltbl) - fprintf (backing_up_file, + fprintf (ctrl.backing_up_file, _("No backing up.\n")); + else if (ctrl.fullspd || ctrl.fulltbl) + fprintf (ctrl.backing_up_file, _ ("%d backing up (non-accepting) states.\n"), num_backing_up); else - fprintf (backing_up_file, + fprintf (ctrl.backing_up_file, _("Compressed tables always back up.\n")); - if (ferror (backing_up_file)) + if (ferror (ctrl.backing_up_file)) lerr (_("error writing backup file %s"), backing_name); - else if (fclose (backing_up_file)) + else if (fclose (ctrl.backing_up_file)) lerr (_("error closing backup file %s"), backing_name); } - if (printstats) { + if (env.printstats) { fprintf (stderr, _("%s version %s usage statistics:\n"), program_name, flex_version); fprintf (stderr, _(" scanner options: -")); - if (C_plus_plus) + if (ctrl.C_plus_plus) putc ('+', stderr); - if (backing_up_report) + if (env.backing_up_report) putc ('b', stderr); - if (ddebug) + if (ctrl.ddebug) putc ('d', stderr); if (sf_case_ins()) putc ('i', stderr); - if (lex_compat) + if (ctrl.lex_compat) putc ('l', stderr); - if (posix_compat) + if (ctrl.posix_compat) putc ('X', stderr); - if (performance_report > 0) + if (env.performance_hint > 0) putc ('p', stderr); - if (performance_report > 1) + if (env.performance_hint > 1) putc ('p', stderr); - if (spprdflt) + if (ctrl.spprdflt) putc ('s', stderr); - if (reentrant) + if (ctrl.reentrant) fputs ("--reentrant", stderr); - if (bison_bridge_lval) + if (ctrl.bison_bridge_lval) fputs ("--bison-bridge", stderr); - if (bison_bridge_lloc) + if (ctrl.bison_bridge_lloc) fputs ("--bison-locations", stderr); - if (use_stdout) + if (env.use_stdout) putc ('t', stderr); - if (printstats) + if (env.printstats) putc ('v', stderr); /* always true! */ - if (nowarn) + if (env.nowarn) putc ('w', stderr); - if (interactive == false) + if (ctrl.interactive == trit_false) putc ('B', stderr); - if (interactive == true) + if (ctrl.interactive == trit_true) putc ('I', stderr); - if (!gen_line_dirs) + if (!ctrl.gen_line_dirs) putc ('L', stderr); - if (trace) + if (env.trace) putc ('T', stderr); - if (csize == unspecified) - /* We encountered an error fairly early on, so csize + if (ctrl.csize == trit_unspecified) + /* We encountered an error fairly early on, so ctrl.csize * never got specified. Define it now, to prevent * bogus table sizes being written out below. */ - csize = 256; + ctrl.csize = 256; - if (csize == 128) + if (ctrl.csize == 128) putc ('7', stderr); else putc ('8', stderr); fprintf (stderr, " -C"); - if (long_align) + if (ctrl.long_align) putc ('a', stderr); - if (fulltbl) + if (ctrl.fulltbl) putc ('f', stderr); - if (fullspd) + if (ctrl.fullspd) putc ('F', stderr); - if (useecs) + if (ctrl.useecs) putc ('e', stderr); - if (usemecs) + if (ctrl.usemecs) putc ('m', stderr); - if (use_read) + if (ctrl.use_read) putc ('r', stderr); - if (did_outfilename) - fprintf (stderr, " -o%s", outfilename); + if (env.did_outfilename) + fprintf (stderr, " -o%s", env.outfilename); - if (skelname) - fprintf (stderr, " -S%s", skelname); + if (env.skelname != NULL) + fprintf (stderr, " -S%s", env.skelname); - if (strcmp (prefix, "yy")) - fprintf (stderr, " -P%s", prefix); + if (strcmp (ctrl.prefix, "yy")) + fprintf (stderr, " -P%s", ctrl.prefix); putc ('\n', stderr); @@ -538,7 +530,7 @@ void flexend (int exit_status) if (num_backing_up == 0) fprintf (stderr, _(" No backing up\n")); - else if (fullspd || fulltbl) + else if (ctrl.fullspd || ctrl.fulltbl) fprintf (stderr, _ (" %d backing-up (non-accepting) states\n"), @@ -575,7 +567,7 @@ void flexend (int exit_status) _(" %d/%d unique/duplicate transitions\n"), numuniq, numdup); - if (fulltbl) { + if (ctrl.fulltbl) { tblsiz = lastdfa * numecs; fprintf (stderr, _(" %d table entries\n"), tblsiz); @@ -606,20 +598,20 @@ void flexend (int exit_status) numtemps, tmpuses); } - if (useecs) { - tblsiz = tblsiz + csize; + if (ctrl.useecs) { + tblsiz = tblsiz + ctrl.csize; fprintf (stderr, _ (" %d/%d equivalence classes created\n"), - numecs, csize); + numecs, ctrl.csize); } - if (usemecs) { + if (ctrl.usemecs) { tblsiz = tblsiz + numecs; fprintf (stderr, _ (" %d/%d meta-equivalence classes created\n"), - nummecs, csize); + nummecs, ctrl.csize); } fprintf (stderr, @@ -644,22 +636,17 @@ void flexinit (int argc, char **argv) char *arg; scanopt_t sopt; - printstats = syntaxerror = trace = spprdflt = false; - lex_compat = posix_compat = C_plus_plus = backing_up_report = - ddebug = fulltbl = false; - fullspd = long_align = nowarn = yymore_used = continued_action = - false; - do_yylineno = yytext_is_array = in_rule = reject = do_stdinit = - false; - yymore_really_used = reject_really_used = unspecified; - interactive = csize = unspecified; - do_yywrap = gen_line_dirs = usemecs = useecs = true; - reentrant = bison_bridge_lval = bison_bridge_lloc = false; - performance_report = 0; - did_outfilename = 0; - prefix = "yy"; - yyclass = 0; - use_read = use_stdout = false; + memset(&ctrl, '\0', sizeof(ctrl)); + syntaxerror = false; + yymore_used = continued_action = false; + yytext_is_array = in_rule = reject = false; + yymore_really_used = reject_really_used = trit_unspecified; + ctrl.do_main = trit_unspecified; + ctrl.interactive = ctrl.csize = trit_unspecified; + ctrl.do_yywrap = ctrl.gen_line_dirs = ctrl.usemecs = ctrl.useecs = true; + ctrl.reentrant = ctrl.bison_bridge_lval = ctrl.bison_bridge_lloc = false; + env.performance_hint = 0; + ctrl.prefix = "yy"; tablesext = tablesverify = false; gentables = true; tablesfilename = tablesname = NULL; @@ -695,7 +682,7 @@ void flexinit (int argc, char **argv) if (program_name != NULL && program_name[strlen (program_name) - 1] == '+') - C_plus_plus = true; + ctrl.C_plus_plus = true; /* read flags */ sopt = scanopt_init (flexopts, argc, argv, 0); @@ -719,19 +706,19 @@ void flexinit (int argc, char **argv) switch ((enum flexopt_flag_t) rv) { case OPT_CPLUSPLUS: - C_plus_plus = true; + ctrl.C_plus_plus = true; break; case OPT_BATCH: - interactive = false; + ctrl.interactive = trit_false; break; case OPT_BACKUP: - backing_up_report = true; + env.backing_up_report = trit_true; break; case OPT_BACKUP_FILE: - backing_up_report = true; + env.backing_up_report = true; backing_name = arg; break; @@ -740,36 +727,36 @@ void flexinit (int argc, char **argv) case OPT_COMPRESSION: if (!sawcmpflag) { - useecs = false; - usemecs = false; - fulltbl = false; + ctrl.useecs = false; + ctrl.usemecs = false; + ctrl.fulltbl = false; sawcmpflag = true; } for (i = 0; arg && arg[i] != '\0'; i++) switch (arg[i]) { case 'a': - long_align = true; + ctrl.long_align = true; break; case 'e': - useecs = true; + ctrl.useecs = true; break; case 'F': - fullspd = true; + ctrl.fullspd = true; break; case 'f': - fulltbl = true; + ctrl.fulltbl = true; break; case 'm': - usemecs = true; + ctrl.usemecs = true; break; case 'r': - use_read = true; + ctrl.use_read = true; break; default: @@ -781,21 +768,21 @@ void flexinit (int argc, char **argv) break; case OPT_DEBUG: - ddebug = true; + ctrl.ddebug = true; break; case OPT_NO_DEBUG: - ddebug = false; + ctrl.ddebug = false; break; case OPT_FULL: - useecs = usemecs = false; - use_read = fulltbl = true; + ctrl.useecs = ctrl.usemecs = false; + ctrl.use_read = ctrl.fulltbl = true; break; case OPT_FAST: - useecs = usemecs = false; - use_read = fullspd = true; + ctrl.useecs = ctrl.usemecs = false; + ctrl.use_read = ctrl.fullspd = true; break; case OPT_HELP: @@ -803,7 +790,7 @@ void flexinit (int argc, char **argv) FLEX_EXIT (0); case OPT_INTERACTIVE: - interactive = true; + ctrl.interactive = true; break; case OPT_CASE_INSENSITIVE: @@ -811,11 +798,11 @@ void flexinit (int argc, char **argv) break; case OPT_LEX_COMPAT: - lex_compat = true; + ctrl.lex_compat = true; break; case OPT_POSIX_COMPAT: - posix_compat = true; + ctrl.posix_compat = true; break; case OPT_PREPROC_LEVEL: @@ -823,61 +810,61 @@ void flexinit (int argc, char **argv) break; case OPT_MAIN: - do_yywrap = false; - do_main = 2; + ctrl.do_yywrap = false; + ctrl.do_main = trit_true; break; case OPT_NO_MAIN: - do_main = 1; + ctrl.do_main = trit_false; break; case OPT_NO_LINE: - gen_line_dirs = false; + ctrl.gen_line_dirs = false; break; case OPT_OUTFILE: - outfilename = arg; - did_outfilename = 1; + env.outfilename = arg; + env.did_outfilename = 1; break; case OPT_PREFIX: - prefix = arg; + ctrl.prefix = arg; break; case OPT_PERF_REPORT: - ++performance_report; + ++env.performance_hint; break; case OPT_BISON_BRIDGE: - bison_bridge_lval = true; + ctrl.bison_bridge_lval = true; break; case OPT_BISON_BRIDGE_LOCATIONS: - bison_bridge_lval = bison_bridge_lloc = true; + ctrl.bison_bridge_lval = ctrl.bison_bridge_lloc = true; break; case OPT_REENTRANT: - reentrant = true; + ctrl.reentrant = true; break; case OPT_NO_REENTRANT: - reentrant = false; + ctrl.reentrant = false; break; case OPT_SKEL: - skelname = arg; + env.skelname = arg; break; case OPT_DEFAULT: - spprdflt = false; + ctrl.spprdflt = false; break; case OPT_NO_DEFAULT: - spprdflt = true; + ctrl.spprdflt = true; break; case OPT_STDOUT: - use_stdout = true; + env.use_stdout = true; break; case OPT_NO_UNISTD_H: @@ -894,39 +881,39 @@ void flexinit (int argc, char **argv) break; case OPT_TRACE: - trace = true; + env.trace = true; break; case OPT_VERBOSE: - printstats = true; + env.printstats = true; break; case OPT_VERSION: - printf ("%s %s\n", (C_plus_plus ? "flex++" : "flex"), flex_version); + printf ("%s %s\n", (ctrl.C_plus_plus ? "flex++" : "flex"), flex_version); FLEX_EXIT (0); case OPT_WARN: - nowarn = false; + env.nowarn = false; break; case OPT_NO_WARN: - nowarn = true; + env.nowarn = true; break; case OPT_7BIT: - csize = 128; + ctrl.csize = 128; break; case OPT_8BIT: - csize = CSIZE; + ctrl.csize = CSIZE; break; case OPT_ALIGN: - long_align = true; + ctrl.long_align = true; break; case OPT_NO_ALIGN: - long_align = false; + ctrl.long_align = false; break; case OPT_ALWAYS_INTERACTIVE: @@ -946,11 +933,11 @@ void flexinit (int argc, char **argv) break; case OPT_ECS: - useecs = true; + ctrl.useecs = true; break; case OPT_NO_ECS: - useecs = false; + ctrl.useecs = false; break; case OPT_HEADER_FILE: @@ -958,11 +945,11 @@ void flexinit (int argc, char **argv) break; case OPT_META_ECS: - usemecs = true; + ctrl.usemecs = true; break; case OPT_NO_META_ECS: - usemecs = false; + ctrl.usemecs = false; break; case OPT_PREPROCDEFINE: @@ -983,7 +970,7 @@ void flexinit (int argc, char **argv) break; case OPT_READ: - use_read = true; + ctrl.use_read = true; break; case OPT_STACK: @@ -991,31 +978,31 @@ void flexinit (int argc, char **argv) break; case OPT_STDINIT: - do_stdinit = true; + ctrl.do_stdinit = true; break; case OPT_NO_STDINIT: - do_stdinit = false; + ctrl.do_stdinit = false; break; case OPT_YYCLASS: - yyclass = arg; + ctrl.yyclass = arg; break; case OPT_YYLINENO: - do_yylineno = true; + ctrl.do_yylineno = true; break; case OPT_NO_YYLINENO: - do_yylineno = false; + ctrl.do_yylineno = false; break; case OPT_YYWRAP: - do_yywrap = true; + ctrl.do_yywrap = true; break; case OPT_NO_YYWRAP: - do_yywrap = false; + ctrl.do_yywrap = false; break; case OPT_YYMORE: @@ -1104,7 +1091,7 @@ void flexinit (int argc, char **argv) buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0); break; case OPT_HEX: - trace_hex = 1; + env.trace_hex = true; break; case OPT_NO_SECT3_ESCAPE: no_section3_escape = true; @@ -1175,9 +1162,9 @@ void readin (void) buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL); if (!tablesfilename) { - nbytes = strlen (prefix) + strlen (tablesfile_template) + 2; + nbytes = strlen (ctrl.prefix) + strlen (tablesfile_template) + 2; tablesfilename = pname = calloc(nbytes, 1); - snprintf (pname, nbytes, tablesfile_template, prefix); + snprintf (pname, nbytes, tablesfile_template, ctrl.prefix); } if ((tablesout = fopen (tablesfilename, "w")) == NULL) @@ -1187,29 +1174,29 @@ void readin (void) yytbl_writer_init (&tableswr, tablesout); - nbytes = strlen (prefix) + strlen ("tables") + 2; + nbytes = strlen (ctrl.prefix) + strlen ("tables") + 2; tablesname = calloc(nbytes, 1); - snprintf (tablesname, nbytes, "%stables", prefix); + snprintf (tablesname, nbytes, "%stables", ctrl.prefix); yytbl_hdr_init (&hdr, flex_version, tablesname); if (yytbl_hdr_fwrite (&tableswr, &hdr) <= 0) flexerror (_("could not write tables header")); } - if (skelname && (skelfile = fopen (skelname, "r")) == NULL) - lerr (_("can't open skeleton file %s"), skelname); + if (env.skelname && (skelfile = fopen (env.skelname, "r")) == NULL) + lerr (_("can't open skeleton file %s"), env.skelname); - if ( bison_bridge_lval) + if ( ctrl.bison_bridge_lval) buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); - if ( bison_bridge_lloc) + if ( ctrl.bison_bridge_lloc) buf_m4_define (&m4defs_buf, "", NULL); - if (strchr(prefix, '[') || strchr(prefix, ']')) + if (strchr(ctrl.prefix, '[') || strchr(ctrl.prefix, ']')) flexerror(_("Prefix cannot include '[' or ']'")); - buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix); + buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", ctrl.prefix); - if (did_outfilename) + if (env.did_outfilename) line_directive_out (stdout, 0); /* Define the start condition macros. */ @@ -1246,7 +1233,7 @@ void readin (void) m4defs_buf.nelts = 0; /* memory leak here. */ /* Place a bogus line directive, it will be fixed in the filter. */ - if (gen_line_dirs && backend->trace_fmt) { + if (ctrl.gen_line_dirs && backend->trace_fmt) { char buf2[4096]; snprintf(buf2, sizeof(buf2), backend->trace_fmt, 0, "M4_YY_OUTFILE_NAME"); outn(buf2); @@ -1257,7 +1244,7 @@ void readin (void) outn ((char *) (userdef_buf.elts)); /* If the user explicitly requested posix compatibility by specifing the - * posix-compat option, then we check for conflicting options. However, if + * posix-compat option, then we check for conflicting ctrl. However, if * the POSIXLY_CORRECT variable is set, then we quietly make flex as * posix-compatible as possible. This is the recommended behavior * according to the GNU Coding Standards. @@ -1265,28 +1252,28 @@ void readin (void) * Note: The posix option was added to flex to provide the posix behavior * of the repeat operator in regular expressions, e.g., `ab{3}' */ - if (posix_compat) { + if (ctrl.posix_compat) { /* TODO: This is where we try to make flex behave according to - * posiz, AND check for conflicting options. How far should we go + * posiz, AND check for conflicting ctrl. How far should we go * with this? Should we disable all the neat-o flex features? */ /* Update: Estes says no, since other flex features don't violate posix. */ } if (getenv ("POSIXLY_CORRECT")) { - posix_compat = true; + ctrl.posix_compat = true; } - if (backing_up_report) { - backing_up_file = fopen (backing_name, "w"); - if (backing_up_file == NULL) + if (env.backing_up_report) { + ctrl.backing_up_file = fopen (backing_name, "w"); + if (ctrl.backing_up_file == NULL) lerr (_ ("could not create backing-up info file %s"), backing_name); } else - backing_up_file = NULL; + ctrl.backing_up_file = NULL; if (yymore_really_used == true) yymore_used = true; @@ -1298,8 +1285,8 @@ void readin (void) else if (reject_really_used == false) reject = false; - if (performance_report > 0) { - if (lex_compat) { + if (env.performance_hint > 0) { + if (ctrl.lex_compat) { fprintf (stderr, _ ("-l AT&T lex compatibility option entails a large performance penalty\n")); @@ -1308,14 +1295,14 @@ void readin (void) (" and may be the actual source of other reported performance penalties\n")); } - else if (do_yylineno) { + else if (ctrl.do_yylineno) { fprintf (stderr, _ ("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n")); } - if (performance_report > 1) { - if (interactive) + if (env.performance_hint > 1) { + if (ctrl.interactive == trit_true) fprintf (stderr, _ ("-I (interactive) entails a minor performance penalty\n")); @@ -1343,11 +1330,11 @@ void readin (void) if (variable_trailing_context_rules) reject = true; - if ((fulltbl || fullspd) && reject) { + if ((ctrl.fulltbl || ctrl.fullspd) && reject) { if (real_reject) flexerror (_ ("REJECT cannot be used with -f or -F")); - else if (do_yylineno) + else if (ctrl.do_yylineno) flexerror (_ ("%option yylineno cannot be used with REJECT")); else @@ -1355,16 +1342,16 @@ void readin (void) ("variable trailing context rules cannot be used with -f or -F")); } - if (useecs) - numecs = cre8ecs (nextecm, ecgroup, csize); + if (ctrl.useecs) + numecs = cre8ecs (nextecm, ecgroup, ctrl.csize); else - numecs = csize; + numecs = ctrl.csize; /* Now map the equivalence class for NUL to its expected place. */ - ecgroup[0] = ecgroup[csize]; + ecgroup[0] = ecgroup[ctrl.csize]; NUL_ec = ABS (ecgroup[0]); - if (useecs) + if (ctrl.useecs) ccl2ecl (); // These are used to conditionalize code in the lex skeleton @@ -1380,19 +1367,19 @@ void readin (void) /* always generate the tablesverify flag. */ visible_define_str ("M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); - if (reentrant) { + if (ctrl.reentrant) { visible_define ("M4_YY_REENTRANT"); if (yytext_is_array) visible_define ("M4_YY_TEXT_IS_ARRAY"); } else visible_define ("M4_YY_NOT_REENTRANT"); - if (do_main == 2) + if (ctrl.do_main == trit_true) visible_define_str ( "YY_MAIN", "1"); - else if (do_main == 1) + else if (ctrl.do_main == trit_false) visible_define_str ( "YY_MAIN", "0"); - if (do_stdinit) + if (ctrl.do_stdinit) visible_define ( "M4_MODE_DO_STDINIT"); else visible_define ( "M4_MODE_NO_DO_STDINIT"); @@ -1407,13 +1394,13 @@ void readin (void) else visible_define ( "M4_MODE_NO_YYMORE_USED"); - if (fullspd) + if (ctrl.fullspd) visible_define ( "M4_MODE_REAL_FULLSPD"); else visible_define ( "M4_MODE_NO_REAL_FULLSPD"); // niode switches for YYINPUT code generation - if (use_read) + if (ctrl.use_read) visible_define ( "M4_MODE_CPP_USE_READ"); else visible_define ( "M4_MODE_NO_CPP_USE_READ"); @@ -1434,13 +1421,13 @@ void readin (void) visible_define ( "M4_MODE_NO_USES_REJECT"); // mode switches for computing next compressed state - if (usemecs) + if (ctrl.usemecs) visible_define ( "M4_MODE_USEMECS"); // mode switches for find-action code - if (fullspd) + if (ctrl.fullspd) visible_define ( "M4_MODE_FULLSPD"); - else if (fulltbl) + else if (ctrl.fulltbl) visible_define ( "M4_MODE_FIND_ACTION_FULLTBL"); else if (reject) visible_define ( "M4_MODE_FIND_ACTION_REJECT"); @@ -1448,7 +1435,7 @@ void readin (void) visible_define ( "M4_MODE_FIND_ACTION_COMPRESSED"); // mode switches for backup generation and gen_start_state - if (!fullspd) + if (!ctrl.fullspd) visible_define ( "M4_MODE_NO_FULLSPD"); if (bol_needed) visible_define ( "M4_MODE_BOL_NEEDED"); @@ -1456,11 +1443,11 @@ void readin (void) visible_define ( "M4_MODE_NO_BOL_NEEDED"); // yylineno - if (do_yylineno) + if (ctrl.do_yylineno) visible_define ( "M4_MODE_YYLINENO"); // Equivalence classes - if (useecs) + if (ctrl.useecs) visible_define ( "M4_MODE_USEECS"); else visible_define ( "M4_MODE_NO_USEECS"); @@ -1470,44 +1457,44 @@ void readin (void) visible_define ( "M4_MODE_GENTABLES"); else visible_define ( "M4_MODE_NO_GENTABLES"); - if (interactive) + if (ctrl.interactive == trit_true) visible_define ( "M4_MODE_INTERACTIVE"); else visible_define ( "M4_MODE_NO_INTERACTIVE"); - if (!(fullspd || fulltbl)) + if (!(ctrl.fullspd || ctrl.fulltbl)) visible_define ( "M4_MODE_NO_FULLSPD_OR_FULLTBL"); - if (reject || interactive) + if (reject || ctrl.interactive == trit_true) visible_define ( "M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE"); - if (yyclass != NULL) { + if (ctrl.yyclass != NULL) { visible_define ( "M4_MODE_YYCLASS"); - out_m4_define("M4_YY_CLASS_NAME", yyclass); + out_m4_define("M4_YY_CLASS_NAME", ctrl.yyclass); } - if (ddebug) + if (ctrl.ddebug) visible_define ( "M4_MODE_DEBUG"); - if (lex_compat) - visible_define ( "M4_MODE_LEX_COMPAT"); + if (ctrl.lex_compat) + visible_define ( "M4_MODE_OPTIONS.LEX_COMPAT"); - if (do_yywrap) + if (ctrl.do_yywrap) visible_define ( "M4_MODE_YYWRAP"); else visible_define ( "M4_MODE_NO_YYWRAP"); - if (interactive) + if (ctrl.interactive == trit_true) visible_define ( "M4_MODE_INTERACTIVE"); // Kluge to get around the fact that the %if-not-reentrant and // %if-c-only gates can't be combined by nesting one inside the // other. - if (backend == &cpp_backend && !C_plus_plus) + if (backend == &cpp_backend && !ctrl.C_plus_plus) visible_define ( "M4_MODE_C_ONLY"); if (tablesext) visible_define ( "M4_MODE_TABLESEXT"); - if (prefix != NULL) - visible_define_str ( "M4_MODE_PREFIX", prefix); + if (ctrl.prefix != NULL) + visible_define_str ( "M4_MODE_PREFIX", ctrl.prefix); backend->comment("m4 controls end\n"); out ("\n"); @@ -1522,7 +1509,7 @@ void readin (void) void set_up_initial_allocations (void) { - maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS); + maximum_mns = (ctrl.long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS); current_mns = INITIAL_MNS; firstst = allocate_integer_array (current_mns); lastst = allocate_integer_array (current_mns); @@ -1582,10 +1569,10 @@ void usage (void) { FILE *f = stdout; - if (!did_outfilename) { + if (!env.did_outfilename) { snprintf (outfile_path, sizeof(outfile_path), outfile_template, - prefix, C_plus_plus ? "cc" : "c"); - outfilename = outfile_path; + ctrl.prefix, ctrl.C_plus_plus ? "cc" : "c"); + env.outfilename = outfile_path; } fprintf (f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name); @@ -1607,7 +1594,7 @@ void usage (void) " -b, --backup write backing-up information to %s\n" " -p, --perf-report write performance report to stderr\n" " -s, --nodefault suppress default rule to ECHO unmatched text\n" - " -T, --trace %s should run in trace mode\n" + " -T, --env.trace %s should run in env.trace mode\n" " -w, --nowarn do not generate warnings\n" " -v, --verbose write summary of scanner statistics to stdout\n" " --hex use hexadecimal numbers instead of octal in debug outputs\n" @@ -1633,8 +1620,8 @@ void usage (void) " -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" - " --bison-bridge scanner for bison pure parser.\n" + " -R, --reentrant generate a reentrant scanner\n" + " --bison-bridge scanner for Bison pure parser.\n" " --bison-locations include yylloc support.\n" " --stdinit initialize yyin/yyout to stdin/stdout\n" " --nounistd do not include \n" diff --git a/src/misc.c b/src/misc.c index eb3e8d1..931db51 100644 --- a/src/misc.c +++ b/src/misc.c @@ -209,7 +209,7 @@ void check_char (int c) lerr (_("bad character '%s' detected in check_char()"), readable_form (c)); - if (c >= csize) + if (c >= ctrl.csize) lerr (_ ("scanner requires -8 flag to use the character %s"), readable_form (c)); @@ -345,7 +345,7 @@ void line_directive_out (FILE *output_file, int do_infile) char directive[MAXLINE*2], filename[MAXLINE]; char *s1, *s2, *s3; - if (!gen_line_dirs) + if (!ctrl.gen_line_dirs) return; s1 = do_infile ? infilename : "M4_YY_OUTFILE_NAME"; @@ -638,7 +638,7 @@ char *readable_form (int c) case '\v': return "\\v"; default: - if(trace_hex) + if(env.trace_hex) snprintf (rform, sizeof(rform), "\\x%.2x", (unsigned int) c); else snprintf (rform, sizeof(rform), "\\%.3o", (unsigned int) c); @@ -705,17 +705,17 @@ void skelout (void) /* Loop pulling lines either from the skelfile, if we're using * one, or from the selected back end's skel[] array. */ - while (skelfile ? - (fgets (buf, MAXLINE, skelfile) != NULL) : + while (env.skelfile != NULL ? + (fgets (buf, MAXLINE, env.skelfile) != NULL) : ((buf = (char *) backend->skel[skel_ind++]) != 0)) { - if (skelfile) + if (env.skelfile != NULL) chomp (buf); /* copy from skel array */ if (buf[0] == '%') { /* control line */ /* print the control line as a comment. */ - if (ddebug && buf[1] != '#') { + if (ctrl.ddebug && buf[1] != '#') { bool escaped = buf[strlen (buf) - 1] == '\\'; if (escaped) { backend->comment(buf); @@ -744,7 +744,7 @@ void skelout (void) } else if (cmd_match (CMD_PUSH)){ sko_push(do_copy); - if(ddebug){ + if(ctrl.ddebug){ char buf2[MAXLINE]; snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); backend->comment(buf2); @@ -753,7 +753,7 @@ void skelout (void) } else if (cmd_match (CMD_POP)){ sko_pop(&do_copy); - if(ddebug){ + if(ctrl.ddebug){ char buf2[MAXLINE]; snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); backend->comment(buf2); @@ -762,19 +762,19 @@ void skelout (void) } else if (cmd_match (CMD_IF_REENTRANT)){ sko_push(do_copy); - do_copy = reentrant && do_copy; + do_copy = ctrl.reentrant && do_copy; } else if (cmd_match (CMD_IF_NOT_REENTRANT)){ sko_push(do_copy); - do_copy = !reentrant && do_copy; + do_copy = !ctrl.reentrant && do_copy; } else if (cmd_match(CMD_IF_BISON_BRIDGE)){ sko_push(do_copy); - do_copy = bison_bridge_lval && do_copy; + do_copy = ctrl.bison_bridge_lval && do_copy; } else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)){ sko_push(do_copy); - do_copy = !bison_bridge_lval && do_copy; + do_copy = !ctrl.bison_bridge_lval && do_copy; } else if (cmd_match (CMD_ENDIF)){ sko_pop(&do_copy); @@ -789,12 +789,12 @@ void skelout (void) else if (cmd_match (CMD_IF_CPP_ONLY)) { /* only for C++ */ sko_push(do_copy); - do_copy = C_plus_plus; + do_copy = ctrl.C_plus_plus; } else if (cmd_match (CMD_IF_C_ONLY)) { /* %- only for C */ sko_push(do_copy); - do_copy = !C_plus_plus; + do_copy = !ctrl.C_plus_plus; } else if (cmd_match (CMD_IF_C_OR_CPP)) { /* %* for C and C++ */ diff --git a/src/nfa.c b/src/nfa.c index 3d9bf24..57a6634 100644 --- a/src/nfa.c +++ b/src/nfa.c @@ -228,7 +228,7 @@ void finish_rule (int mach, int variable_trail_rule, int headcnt, int trailcn if (variable_trail_rule) { rule_type[num_rules] = RULE_VARIABLE; - if (performance_report > 0) + if (env.performance_hint > 0) fprintf (stderr, _ ("Variable trailing context rule at line %d\n"), @@ -646,9 +646,9 @@ current_mns); else { check_char (sym); - if (useecs) + if (ctrl.useecs) /* Map NUL's to csize. */ - mkechar (sym ? sym : csize, nextecm, ecgroup); + mkechar (sym ? sym : ctrl.csize, nextecm, ecgroup); } return lastnfa; diff --git a/src/options.c b/src/options.c index e98159c..283fa08 100644 --- a/src/options.c +++ b/src/options.c @@ -33,7 +33,7 @@ #include "options.h" -/* Be sure to synchronize these options with those defined in "options.h", +/* Be sure to synchronize these options with those defined in "ctrl.h", * the giant switch() statement in "main.c", and the %option processing in * "scan.l". */ diff --git a/src/parse.y b/src/parse.y index 5a07320..ae4b82f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -87,7 +87,7 @@ int previous_continued_action; /* whether the previous rule's action was '|' */ #define CCL_EXPR(func) \ do{ \ int c; \ - for ( c = 0; c < csize; ++c ) \ + for ( c = 0; c < ctrl.csize; ++c ) \ if ( isascii(c) && func(c) ) \ ccladd( currccl, c ); \ }while(0) @@ -96,7 +96,7 @@ int previous_continued_action; /* whether the previous rule's action was '|' */ #define CCL_NEG_EXPR(func) \ do{ \ int c; \ - for ( c = 0; c < csize; ++c ) \ + for ( c = 0; c < ctrl.csize; ++c ) \ if ( !func(c) ) \ ccladd( currccl, c ); \ }while(0) @@ -134,7 +134,7 @@ goal : initlex sect1 sect1end sect2 initforrule for ( i = 1; i <= lastsc; ++i ) scset[i] = mkbranch( scset[i], def_rule ); - if ( spprdflt ) + if ( ctrl.spprdflt ) add_action( "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); else @@ -193,17 +193,17 @@ optionlist : optionlist option option : TOK_OUTFILE '=' NAME { - outfilename = xstrdup(nmstr); - did_outfilename = 1; + env.outfilename = xstrdup(nmstr); + env.did_outfilename = 1; } | TOK_EXTRA_TYPE '=' NAME { extra_type = xstrdup(nmstr); } | TOK_PREFIX '=' NAME - { prefix = xstrdup(nmstr); - if (strchr(prefix, '[') || strchr(prefix, ']')) + { ctrl.prefix = xstrdup(nmstr); + if (strchr(ctrl.prefix, '[') || strchr(ctrl.prefix, ']')) flexerror(_("Prefix must not contain [ or ]")); } | TOK_YYCLASS '=' NAME - { yyclass = xstrdup(nmstr); } + { ctrl.yyclass = xstrdup(nmstr); } | TOK_HEADER_FILE '=' NAME { headerfilename = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME @@ -260,7 +260,7 @@ flexrule : '^' rule { bol_needed = true; - if ( performance_report > 1 ) + if ( env.performance_hint > 1 ) pinpoint_message( "'^' operator results in sub-optimal performance" ); } @@ -409,7 +409,7 @@ rule : re2 re } - if ( lex_compat || (varlength && headcnt == 0) ) + if ( ctrl.lex_compat || (varlength && headcnt == 0) ) { /* variable trailing context rule */ /* Mark the first part of the rule as the * accepting "head" part of a trailing @@ -461,7 +461,7 @@ rule : re2 re varlength = true; } - if ( lex_compat || varlength ) + if ( ctrl.lex_compat || varlength ) { /* Again, see the comment in the rule for * "re2 re" above. @@ -484,7 +484,7 @@ rule : re2 re if ( trlcontxt ) { - if ( lex_compat || (varlength && headcnt == 0) ) + if ( ctrl.lex_compat || (varlength && headcnt == 0) ) /* Both head and trail are * variable-length. */ @@ -698,19 +698,19 @@ singleton : singleton '*' ccladd( ccldot, '\n' ); cclnegate( ccldot ); - if ( useecs ) + if ( ctrl.useecs ) mkeccl( ccltbl + cclmap[ccldot], ccllen[ccldot], nextecm, - ecgroup, csize, csize ); + ecgroup, ctrl.csize, ctrl.csize ); /* Create the (?s:'.') character class. */ cclany = cclinit(); cclnegate( cclany ); - if ( useecs ) + if ( ctrl.useecs ) mkeccl( ccltbl + cclmap[cclany], ccllen[cclany], nextecm, - ecgroup, csize, csize ); + ecgroup, ctrl.csize, ctrl.csize ); madeany = true; } @@ -729,9 +729,9 @@ singleton : singleton '*' */ qsort( ccltbl + cclmap[$1], (size_t) ccllen[$1], sizeof (*ccltbl), cclcmp ); - if ( useecs ) + if ( ctrl.useecs ) mkeccl( ccltbl + cclmap[$1], ccllen[$1], - nextecm, ecgroup, csize, csize ); + nextecm, ecgroup, ctrl.csize, ctrl.csize); ++rulelen; @@ -1056,7 +1056,7 @@ void line_warning( const char *str, int line ) { char warning[MAXLINE]; - if ( ! nowarn ) + if ( ! env.nowarn ) { snprintf( warning, sizeof(warning), "warning, %s", str ); line_pinpoint( warning, line ); diff --git a/src/scan.l b/src/scan.l index f914186..4c426b1 100644 --- a/src/scan.l +++ b/src/scan.l @@ -104,7 +104,7 @@ extern const char *escaped_qstart, *escaped_qend; #define YY_USER_INIT \ if ( getenv("POSIXLY_CORRECT") ) \ - posix_compat = true; + ctrl.posix_compat = true; #define START_CODEBLOCK(x) do { \ /* Emit the needed line directive... */\ @@ -359,66 +359,66 @@ M4QEND "]""]" no option_sense = ! option_sense; - 7bit csize = option_sense ? 128 : 256; - 8bit csize = option_sense ? 256 : 128; + 7bit ctrl.csize = option_sense ? 128 : 256; + 8bit ctrl.csize = option_sense ? 256 : 128; - align long_align = option_sense; + align ctrl.long_align = option_sense; always-interactive { ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense ); - interactive = option_sense; + ctrl.interactive = (trit)option_sense; } array yytext_is_array = option_sense; - backup backing_up_report = option_sense; - batch interactive = ! option_sense; - bison-bridge bison_bridge_lval = option_sense; - bison-locations { if((bison_bridge_lloc = option_sense)) - bison_bridge_lval = true; + backup env.backing_up_report = option_sense; + batch ctrl.interactive = (trit)!option_sense; + bison-bridge ctrl.bison_bridge_lval = option_sense; + bison-locations { if((ctrl.bison_bridge_lloc = option_sense)) + ctrl.bison_bridge_lval = true; } - "c++" C_plus_plus = option_sense; + "c++" ctrl.C_plus_plus = option_sense; caseful|case-sensitive sf_set_case_ins(!option_sense); caseless|case-insensitive sf_set_case_ins(option_sense); - debug ddebug = option_sense; - default spprdflt = ! option_sense; - ecs useecs = option_sense; + debug ctrl.ddebug = option_sense; + default ctrl.spprdflt = ! option_sense; + ecs ctrl.useecs = option_sense; fast { - useecs = usemecs = false; - use_read = fullspd = true; + ctrl.useecs = ctrl.usemecs = false; + ctrl.use_read = ctrl.fullspd = true; } full { - useecs = usemecs = false; - use_read = fulltbl = true; + ctrl.useecs = ctrl.usemecs = false; + ctrl.use_read = ctrl.fulltbl = true; } input ACTION_IFDEF("YY_NO_INPUT", ! option_sense); - interactive interactive = option_sense; - lex-compat lex_compat = option_sense; - posix-compat posix_compat = option_sense; - line gen_line_dirs = option_sense; + interactive ctrl.interactive = (trit)option_sense; + lex-compat ctrl.posix_compat = option_sense; + posix-compat ctrl.posix_compat = option_sense; + line ctrl.gen_line_dirs = option_sense; main { ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense); - /* Override yywrap */ - if( option_sense == true ) - do_yywrap = false; + /* Override yywrap */ + if( option_sense == true ) + ctrl.do_yywrap = false; } - meta-ecs usemecs = option_sense; + meta-ecs ctrl.usemecs = option_sense; never-interactive { ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense ); - interactive = !option_sense; + ctrl.interactive = (trit)!option_sense; } - perf-report performance_report += option_sense ? 1 : -1; + perf-report env.performance_hint += option_sense ? 1 : -1; pointer yytext_is_array = ! option_sense; - read use_read = option_sense; - reentrant reentrant = option_sense; + read ctrl.use_read = option_sense; + reentrant ctrl.reentrant = option_sense; reject reject_really_used = option_sense; stack ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense ); - stdinit do_stdinit = option_sense; - stdout use_stdout = option_sense; - unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); + stdinit ctrl.do_stdinit = option_sense; + stdout env.use_stdout = option_sense; + unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); unput ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense); - verbose printstats = option_sense; - warn nowarn = ! option_sense; - yylineno do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense); + verbose env.printstats = option_sense; + warn env.nowarn = ! option_sense; + yylineno ctrl.do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense); yymore yymore_really_used = option_sense; - yywrap do_yywrap = option_sense; + yywrap ctrl.do_yywrap = option_sense; yy_push_state ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense); yy_pop_state ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense); @@ -428,28 +428,28 @@ M4QEND "]""]" yy_scan_bytes ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense); yy_scan_string ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense); - yyalloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense); - yyrealloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense); - yyfree ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense); - - yyget_debug ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense); - yyset_debug ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense); - yyget_extra ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense); - yyset_extra ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense); - yyget_leng ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense); - yyget_text ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense); - yyget_column ACTION_M4_IFDEF("M4""_YY_NO_GET_COLUMN", ! option_sense); - yyset_column ACTION_M4_IFDEF("M4""_YY_NO_SET_COLUMN", ! option_sense); - yyget_lineno ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense); - yyset_lineno ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense); - yyget_in ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense); - yyset_in ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense); - yyget_out ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense); - yyset_out ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense); - yyget_lval ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense); - yyset_lval ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense); - yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense); - yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense); + yyalloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense); + yyrealloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense); + yyfree ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense); + + yyget_debug ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense); + yyset_debug ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense); + yyget_extra ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense); + yyset_extra ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense); + yyget_leng ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense); + yyget_text ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense); + yyget_column ACTION_M4_IFDEF("M4""_YY_NO_GET_COLUMN", ! option_sense); + yyset_column ACTION_M4_IFDEF("M4""_YY_NO_SET_COLUMN", ! option_sense); + yyget_lineno ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense); + yyset_lineno ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense); + yyget_in ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense); + yyset_in ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense); + yyget_out ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense); + yyset_out ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense); + yyget_lval ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense); + yyset_lval ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense); + yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense); + yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense); extra-type return TOK_EXTRA_TYPE; outfile return TOK_OUTFILE; @@ -537,7 +537,7 @@ M4QEND "]""]" "\"" BEGIN(QUOTE); return '"'; "{"/[[:digit:]] { BEGIN(NUM); - if ( lex_compat || posix_compat ) + if ( ctrl.posix_compat || ctrl.posix_compat ) return BEGIN_REPEAT_POSIX; else return BEGIN_REPEAT_FLEX; @@ -721,7 +721,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ if (end_is_ws) unput(end_ch); - if ( lex_compat || nmdefptr[0] == '^' || + if ( ctrl.posix_compat || nmdefptr[0] == '^' || (len > 0 && nmdefptr[len - 1] == '$') || (end_is_ws && trlcontxt && !sf_skip_ws())) { /* don't use ()'s after all */ @@ -751,7 +751,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ } "(?#" { - if (lex_compat || posix_compat){ + if (ctrl.posix_compat || ctrl.posix_compat){ /* Push back the "?#" and treat it like a normal parens. */ yyless(1); sf_push(); @@ -762,7 +762,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ } "(?" { sf_push(); - if (lex_compat || posix_compat) + if (ctrl.posix_compat || ctrl.posix_compat) /* Push back the "?" and treat it like a normal parens. */ yyless(1); else @@ -884,7 +884,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ "," return ','; "}" { BEGIN(SECT2); - if ( lex_compat || posix_compat ) + if ( ctrl.posix_compat || ctrl.posix_compat ) return END_REPEAT_POSIX; else return END_REPEAT_FLEX; diff --git a/src/scanopt.c b/src/scanopt.c index 7a91178..55e2a73 100644 --- a/src/scanopt.c +++ b/src/scanopt.c @@ -50,9 +50,9 @@ struct _aux { struct _scanopt_t { - const optspec_t *options; /* List of options. */ - struct _aux *aux; /* Auxiliary data about options. */ - int optc; /* Number of options. */ + const optspec_t *options; /* List of ctrl. */ + struct _aux *aux; /* Auxiliary data about ctrl. */ + int optc; /* Number of ctrl. */ int argc; /* Number of args. */ char **argv; /* Array of strings. */ int index; /* Used as: argv[index][subscript]. */ @@ -345,8 +345,8 @@ int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage) fprintf((fp), "%*s", (n), "") /* Second pass (same as above loop), this time we print. */ - /* Sloppy hack: We iterate twice. The first time we print short and long options. - The second time we print those lines that have ONLY long options. */ + /* Sloppy hack: We iterate twice. The first time we print short and long ctrl. + The second time we print those lines that have ONLY long ctrl. */ while (print_run++ < 2) { for (ue = byr_val; ue; ue = ue->next) { usg_elem *ap; diff --git a/src/scanopt.h b/src/scanopt.h index c6e7dec..06b7c60 100644 --- a/src/scanopt.h +++ b/src/scanopt.h @@ -76,7 +76,7 @@ extern "C" { /* Initializes scanner and checks option list for errors. * Parameters: - * options - Array of options. + * options - Array of ctrl. * argc - Same as passed to main(). * argv - Same as passed to main(). First element is skipped. * flags - Control behavior. @@ -110,7 +110,7 @@ extern "C" { * If return is zero, then optindex is the NEXT valid option index. * * Return: > 0 on success. Return value is from optspec_t->rval. - * == 0 if at end of options. + * == 0 if at end of ctrl. * < 0 on error (return value is an error code). * */ diff --git a/src/tblcmp.c b/src/tblcmp.c index 81dfbc1..cd61c80 100644 --- a/src/tblcmp.c +++ b/src/tblcmp.c @@ -228,7 +228,7 @@ void cmptmps (void) peakpairs = numtemps * numecs + tblend; - if (usemecs) { + if (ctrl.usemecs) { /* Create equivalence classes based on data gathered on * template transitions. */ @@ -250,7 +250,7 @@ void cmptmps (void) for (j = 1; j <= numecs; ++j) { trans = tnxt[numecs * i + j]; - if (usemecs) { + if (ctrl.usemecs) { /* The absolute value of tecbck is the * meta-equivalence class of a given * equivalence class, as set up by cre8ecs(). @@ -426,7 +426,7 @@ void inittbl (void) firstfree = tblend + 1; numtemps = 0; - if (usemecs) { + if (ctrl.usemecs) { /* Set up doubly-linked meta-equivalence classes; these * are sets of equivalence classes which all have identical * transitions out of TEMPLATES. @@ -708,7 +708,7 @@ void mktemplate (int state[], int statenum, int comstate) tnxt[tmpbase + i] = comstate; } - if (usemecs) + if (ctrl.usemecs) mkeccl (transset, tsptr, tecfwd, tecbck, numecs, 0); mkprot (tnxt + tmpbase, -numtemps, comstate); diff --git a/src/yylex.c b/src/yylex.c index 521db7f..9a2e59f 100644 --- a/src/yylex.c +++ b/src/yylex.c @@ -63,7 +63,7 @@ int yylex (void) toktype = 0; } - if (trace) { + if (env.trace) { if (beglin) { fprintf (stderr, "%d\t", num_rules + 1); beglin = 0; @@ -152,7 +152,7 @@ int yylex (void) default: if (!isascii (yylval) || !isprint (yylval)) { - if(trace_hex) + if(env.trace_hex) fprintf (stderr, "\\x%02x", (unsigned int) yylval); else fprintf (stderr, "\\%.3o", (unsigned int) yylval); -- cgit v1.2.1 From 9dbc704ad47129dcd2c4846b94473d618e6869a8 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 2 Oct 2020 00:17:31 -0400 Subject: yytext_is_array moves to the ctrl structure. This is separate from the big reorganization in commit #52 because there's a comment about this variable in flexdef.h that makes me nervous. According to the comment this variable is a trit, but it looks to me like flexinit sets it to false and I can't find anywhere in the code that sets it to a non-boolean value. This commit asumes that the comment is stale and the member can be typed boolean. Should be audited. --- src/flexdef.h | 9 ++++----- src/main.c | 18 +++++++++--------- src/scan.l | 8 ++++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/flexdef.h b/src/flexdef.h index 929baf7..ea049c1 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -383,6 +383,9 @@ struct ctrl_bundle_t { bool use_read; // (-f, -F, or -Cr) use read() for scanner input // otherwise, use fread(). char *yyclass; // yyFlexLexer subclass to use for YY_DECL + bool yytext_is_array; // if true (i.e., %array directive), then declare + // yytext as a array instead of a character pointer. + // Nice and inefficient. }; /* Environment variables. These control the lexer operation, but do @@ -416,10 +419,7 @@ extern struct env_bundle_t env; /* Variables for flags: * syntaxerror - true if a syntax error has been found * eofseen - true if we've seen an eof in the input file - * yytext_is_array - if true (i.e., %array directive), then declare - * yytext as a array instead of a character pointer. Nice and inefficient. - * Note that 0 is unset, 1 corresponds to --no-main, and 2 to --main. -ya * yymore_used - if true, yymore() is used in input rules + * yymore_used - if true, yymore() is used in input rules * reject - if true, generate back-up tables for REJECT macro * real_reject - if true, scanner really uses REJECT (as opposed to just * having "reject" set for variable trailing context) @@ -432,7 +432,6 @@ ya * yymore_used - if true, yymore() is used in input rules */ extern int syntaxerror, eofseen; -extern int yytext_is_array; extern int yymore_used, reject, real_reject, continued_action, in_rule; extern int yymore_really_used, reject_really_used; diff --git a/src/main.c b/src/main.c index 122b113..1750607 100644 --- a/src/main.c +++ b/src/main.c @@ -47,7 +47,7 @@ void readin(void); void set_up_initial_allocations(void); /* these globals are all defined and commented in flexdef.h */ -int syntaxerror, eofseen, yytext_is_array; +int syntaxerror, eofseen; int yymore_used, reject, real_reject, continued_action, in_rule; int yymore_really_used, reject_really_used; int datapos, dataline, linenum; @@ -221,7 +221,7 @@ void check_options (void) flexerror (_ ("Can't use --ctrl.reentrant or --bison-bridge with -l option")); - yytext_is_array = true; + ctrl.yytext_is_array = true; ctrl.do_yylineno = true; ctrl.use_read = false; } @@ -269,9 +269,9 @@ void check_options (void) if (ctrl.C_plus_plus && ctrl.fullspd) flexerror (_("Can't use -+ with -CF option")); - if (ctrl.C_plus_plus && yytext_is_array) { + if (ctrl.C_plus_plus && ctrl.yytext_is_array) { lwarn (_("%array incompatible with -+ option")); - yytext_is_array = false; + ctrl.yytext_is_array = false; } if (ctrl.C_plus_plus && (ctrl.reentrant)) @@ -639,7 +639,7 @@ void flexinit (int argc, char **argv) memset(&ctrl, '\0', sizeof(ctrl)); syntaxerror = false; yymore_used = continued_action = false; - yytext_is_array = in_rule = reject = false; + in_rule = reject = false; yymore_really_used = reject_really_used = trit_unspecified; ctrl.do_main = trit_unspecified; ctrl.interactive = ctrl.csize = trit_unspecified; @@ -925,11 +925,11 @@ void flexinit (int argc, char **argv) break; case OPT_ARRAY: - yytext_is_array = true; + ctrl.yytext_is_array = true; break; case OPT_POINTER: - yytext_is_array = false; + ctrl.yytext_is_array = false; break; case OPT_ECS: @@ -1369,7 +1369,7 @@ void readin (void) if (ctrl.reentrant) { visible_define ("M4_YY_REENTRANT"); - if (yytext_is_array) + if (ctrl.yytext_is_array) visible_define ("M4_YY_TEXT_IS_ARRAY"); } else visible_define ("M4_YY_NOT_REENTRANT"); @@ -1385,7 +1385,7 @@ void readin (void) visible_define ( "M4_MODE_NO_DO_STDINIT"); // mode switches for YY_DO_BEFORE_ACTION code generation - if (yytext_is_array) + if (ctrl.yytext_is_array) visible_define ( "M4_MODE_YYTEXT_IS_ARRAY"); else visible_define ( "M4_MODE_NO_YYTEXT_IS_ARRAY"); diff --git a/src/scan.l b/src/scan.l index 4c426b1..00cbb6e 100644 --- a/src/scan.l +++ b/src/scan.l @@ -198,8 +198,8 @@ M4QEND "]""]" return SECTEND; } - ^"%pointer".*{NL} yytext_is_array = false; ++linenum; - ^"%array".*{NL} yytext_is_array = true; ++linenum; + ^"%pointer".*{NL} ctrl.yytext_is_array = false; ++linenum; + ^"%array".*{NL} ctrl.yytext_is_array = true; ++linenum; ^"%option" BEGIN(OPTION); return TOK_OPTION; @@ -367,7 +367,7 @@ M4QEND "]""]" ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense ); ctrl.interactive = (trit)option_sense; } - array yytext_is_array = option_sense; + array ctrl.yytext_is_array = option_sense; backup env.backing_up_report = option_sense; batch ctrl.interactive = (trit)!option_sense; bison-bridge ctrl.bison_bridge_lval = option_sense; @@ -405,7 +405,7 @@ M4QEND "]""]" ctrl.interactive = (trit)!option_sense; } perf-report env.performance_hint += option_sense ? 1 : -1; - pointer yytext_is_array = ! option_sense; + pointer ctrl.yytext_is_array = ! option_sense; read ctrl.use_read = option_sense; reentrant ctrl.reentrant = option_sense; reject reject_really_used = option_sense; -- cgit v1.2.1 From c5d0e408e2e1bb6587cb0d6986964fab78f43c0f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 2 Oct 2020 00:35:24 -0400 Subject: Methodize a suffix computation and move headerfile into ctrl. This cleans up some loose ends before the next big move. #54 in the retargeting patch series. #53 slipped out unnumbered. --- src/filter.c | 4 ++-- src/flexdef.h | 6 +++--- src/main.c | 8 ++++---- src/parse.y | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/filter.c b/src/filter.c index edf1ed8..b9782f0 100644 --- a/src/filter.c +++ b/src/filter.c @@ -268,7 +268,7 @@ int filter_tee_header (struct filter *chain) fprintf (to_h, "#define %sIN_HEADER 1\n\n", ctrl.prefix); fprintf (to_h, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", - headerfilename ? headerfilename : ""); + env.headerfilename != NULL ? env.headerfilename : ""); } @@ -363,7 +363,7 @@ int filter_fix_linedirs (struct filter *chain) env.outfilename != NULL ? env.outfilename : "") == 0 || strcmp (fname, - headerfilename ? headerfilename : "") + env.headerfilename != NULL ? env.headerfilename : "") == 0) { char *s1, *s2; diff --git a/src/flexdef.h b/src/flexdef.h index ea049c1..c39bacc 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -384,7 +384,7 @@ struct ctrl_bundle_t { // otherwise, use fread(). char *yyclass; // yyFlexLexer subclass to use for YY_DECL bool yytext_is_array; // if true (i.e., %array directive), then declare - // yytext as a array instead of a character pointer. + // yytext as array instead of a character pointer. // Nice and inefficient. }; @@ -396,6 +396,7 @@ struct env_bundle_t { bool backing_up_report; // (-b flag), generate "lex.backup" file // listing backing-up states bool did_outfilename; // whether outfilename was explicitly set + char *headerfilename; // name of the .h file to generate bool nowarn; // (-w) do not generate warnings int performance_hint; // if > 0 (i.e., -p flag), generate a report // relating to scanner performance; @@ -447,7 +448,6 @@ extern struct flex_backend_t *backend; * yyin - input file * infilename - name of input file * outfilename - name of output file - * headerfilename - name of the .h file to generate * input_files - array holding names of input files * num_input_files - size of input_files array * program_name - name with which program was invoked @@ -464,7 +464,7 @@ extern struct flex_backend_t *backend; extern int datapos, dataline, linenum; extern int skel_ind; -extern char *infilename, *headerfilename; +extern char *infilename; extern char *extra_type; extern char **input_files; extern int num_input_files; diff --git a/src/main.c b/src/main.c index 1750607..f6a4d2c 100644 --- a/src/main.c +++ b/src/main.c @@ -56,7 +56,7 @@ int skel_ind = 0; char *action_array; int action_size, defs1_offset, prolog_offset, action_offset, action_index; -char *infilename = NULL, *headerfilename = NULL; +char *infilename = NULL; char *extra_type = NULL; int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; @@ -324,7 +324,7 @@ void check_options (void) /* Setup the filter chain. */ - output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); + output_chain = filter_create_int(NULL, filter_tee_header, env.headerfilename); if ( !(m4 = getenv("M4"))) { char *slash; m4 = M4; @@ -941,7 +941,7 @@ void flexinit (int argc, char **argv) break; case OPT_HEADER_FILE: - headerfilename = arg; + env.headerfilename = arg; break; case OPT_META_ECS: @@ -1571,7 +1571,7 @@ void usage (void) if (!env.did_outfilename) { snprintf (outfile_path, sizeof(outfile_path), outfile_template, - ctrl.prefix, ctrl.C_plus_plus ? "cc" : "c"); + ctrl.prefix, backend->suffix()); env.outfilename = outfile_path; } diff --git a/src/parse.y b/src/parse.y index ae4b82f..1a7e1bb 100644 --- a/src/parse.y +++ b/src/parse.y @@ -205,7 +205,7 @@ option : TOK_OUTFILE '=' NAME | TOK_YYCLASS '=' NAME { ctrl.yyclass = xstrdup(nmstr); } | TOK_HEADER_FILE '=' NAME - { headerfilename = xstrdup(nmstr); } + { env.headerfilename = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME { tablesext = true; tablesfilename = xstrdup(nmstr); } ; -- cgit v1.2.1 From 7e77d8f4759724a125bc9ca53366fd1b760c7c9e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 2 Oct 2020 05:15:54 -0400 Subject: Move almost all m4 symbol setting to one spot. Formerly, Flex's own lexer and the logic for pocessing command-line options both did calls to write M4 conditionals to a buffer that was later dumped into the befinning of the text that m4 expands, before the body of the skel file. This was bad layering. Instead, both these places now set flags in the ctrl structure. Later, (almost) all the generated m4 conditionals are shipped at once. It's "almost" because there are a couple of awkward cases to be cleaned up. Again, this was the part that could be done simply via almost mechanical cut and paste. In generated code, there are some comment diffs because symbols that used to be invisibly set are now visibly set - that is, shown at the beginning of the generated C. #55 in the retargeting patch series --- src/flexdef.h | 29 ++++++++++++++++ src/main.c | 104 +++++++++++++++++++++++++++++++++++++++++++++------------- src/scan.l | 64 ++++++++++++++++++------------------ 3 files changed, 142 insertions(+), 55 deletions(-) diff --git a/src/flexdef.h b/src/flexdef.h index c39bacc..07d6078 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -386,6 +386,35 @@ struct ctrl_bundle_t { bool yytext_is_array; // if true (i.e., %array directive), then declare // yytext as array instead of a character pointer. // Nice and inefficient. + // flags corresponding to the huge mass of --no-yy options + bool no_yy_push_state; + bool no_yy_pop_state; + bool no_yy_top_state; + bool no_unput; + bool no_yy_scan_buffer; + bool no_yy_scan_bytes; + bool no_yy_scan_string; + bool no_yyget_extra; + bool no_yyset_extra; + bool no_yyget_leng; + bool no_yyget_text; + bool no_yyget_lineno; + bool no_yyset_lineno; + bool no_yyget_column; + bool no_yyset_column; + bool no_yyget_in; + bool no_yyset_in; + bool no_yyget_out; + bool no_yyset_out; + bool no_yyget_lval; + bool no_yyset_lval; + bool no_yyget_lloc; + bool no_yyset_lloc; + bool no_flex_alloc; + bool no_flex_realloc; + bool no_flex_free; + bool no_get_debug; + bool no_set_debug; }; /* Environment variables. These control the lexer operation, but do diff --git a/src/main.c b/src/main.c index f6a4d2c..ffbf721 100644 --- a/src/main.c +++ b/src/main.c @@ -1022,74 +1022,75 @@ void flexinit (int argc, char **argv) break; case OPT_NO_YY_PUSH_STATE: - buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0); + ctrl.no_yy_push_state = true; break; case OPT_NO_YY_POP_STATE: - buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0); + ctrl.no_yy_pop_state = true; break; case OPT_NO_YY_TOP_STATE: - buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0); + ctrl.no_yy_top_state = true; break; case OPT_NO_UNPUT: - buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0); + ctrl.no_unput = true; break; case OPT_NO_YY_SCAN_BUFFER: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0); + ctrl.no_yy_scan_buffer = true; break; case OPT_NO_YY_SCAN_BYTES: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0); + ctrl.no_yy_scan_bytes = true; break; case OPT_NO_YY_SCAN_STRING: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0); + ctrl.no_yy_scan_string = true; break; case OPT_NO_YYGET_EXTRA: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0); + ctrl.no_yyget_extra = true; break; case OPT_NO_YYSET_EXTRA: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0); + ctrl.no_yyset_extra = true; break; case OPT_NO_YYGET_LENG: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0); + ctrl.no_yyget_leng = true; break; case OPT_NO_YYGET_TEXT: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0); + ctrl.no_yyget_text = true; break; case OPT_NO_YYGET_LINENO: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0); + ctrl.no_yyget_lineno = true; break; case OPT_NO_YYSET_LINENO: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0); + ctrl.no_yyset_lineno = true; break; case OPT_NO_YYGET_COLUMN: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_COLUMN",0); + ctrl.no_yyget_column = true; break; case OPT_NO_YYSET_COLUMN: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_COLUMN",0); + ctrl.no_yyset_column = true; break; case OPT_NO_YYGET_IN: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0); + ctrl.no_yyget_in = true; break; case OPT_NO_YYSET_IN: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0); + ctrl.no_yyset_in = true; break; case OPT_NO_YYGET_OUT: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0); + ctrl.no_yyget_out = true; break; case OPT_NO_YYSET_OUT: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0); + ctrl.no_yyset_out = true; break; case OPT_NO_YYGET_LVAL: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0); + ctrl.no_yyget_lval = true; break; case OPT_NO_YYSET_LVAL: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0); + ctrl.no_yyset_lval = true; break; case OPT_NO_YYGET_LLOC: - buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0); + ctrl.no_yyget_lloc = true; break; case OPT_NO_YYSET_LLOC: - buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0); + ctrl.no_yyset_lloc = true; break; + case OPT_HEX: env.trace_hex = true; break; @@ -1496,6 +1497,63 @@ void readin (void) if (ctrl.prefix != NULL) visible_define_str ( "M4_MODE_PREFIX", ctrl.prefix); + if (ctrl.no_yy_push_state) + visible_define("M4_YY_NO_PUSH_STATE"); + if (ctrl.no_yy_pop_state) + visible_define("M4_YY_NO_POP_STATE"); + if (ctrl.no_yy_top_state) + visible_define("M4_YY_NO_TOP_STATE"); + if (ctrl.no_unput) + visible_define("M4_YY_NO_UNPUT"); + if (ctrl.no_yy_scan_buffer) + visible_define("M4_YY_NO_SCAN_BUFFER"); + if (ctrl.no_yy_scan_bytes) + visible_define("M4_YY_NO_SCAN_BYTES"); + if (ctrl.no_yy_scan_string) + visible_define("M4_YY_NO_SCAN_STRING"); + if (ctrl.no_yyget_extra) + visible_define("M4_YY_NO_GET_EXTRA"); + if (ctrl.no_yyset_extra) + visible_define("M4_YY_NO_SET_EXTRA"); + if (ctrl.no_yyget_leng) + visible_define("M4_YY_NO_GET_LENG"); + if (ctrl.no_yyget_text) + visible_define("M4_YY_NO_GET_TEXT"); + if (ctrl.no_yyget_lineno) + visible_define("M4_YY_NO_GET_LINENO"); + if (ctrl.no_yyset_lineno) + visible_define("M4_YY_NO_SET_LINENO"); + if (ctrl.no_yyget_column) + visible_define("M4_YY_NO_GET_COLUMN"); + if (ctrl.no_yyset_column) + visible_define("M4_YY_NO_SET_COLUMN"); + if (ctrl.no_yyget_in) + visible_define("M4_YY_NO_GET_IN"); + if (ctrl.no_yyset_in) + visible_define("M4_YY_NO_SET_IN"); + if (ctrl.no_yyget_out) + visible_define("M4_YY_NO_GET_OUT"); + if (ctrl.no_yyset_out) + visible_define("M4_YY_NO_SET_OUT"); + if (ctrl.no_yyget_lval) + visible_define("M4_YY_NO_GET_LVAL"); + if (ctrl.no_yyset_lval) + visible_define("M4_YY_NO_SET_LVAL"); + if (ctrl.no_yyget_lloc) + visible_define("M4_YY_NO_GET_LLOC"); + if (ctrl.no_yyset_lloc) + visible_define("M4_YY_NO_SET_LLOC"); + if (ctrl.no_flex_alloc) + visible_define("M4_YY_NO_FLEX_ALLOC"); + if (ctrl.no_flex_realloc) + visible_define("M4_YY_NO_FLEX_REALLOC"); + if (ctrl.no_flex_free) + visible_define("M4_YY_NO_FLEX_FREE"); + if (ctrl.no_get_debug) + visible_define("M4_YY_NO_GET_DEBUG"); + if (ctrl.no_set_debug) + visible_define("M4_YY_NO_SET_DEBUG"); + backend->comment("m4 controls end\n"); out ("\n"); diff --git a/src/scan.l b/src/scan.l index 00cbb6e..cb1a477 100644 --- a/src/scan.l +++ b/src/scan.l @@ -394,7 +394,7 @@ M4QEND "]""]" posix-compat ctrl.posix_compat = option_sense; line ctrl.gen_line_dirs = option_sense; main { - ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense); + ctrl.do_main = option_sense; /* Override yywrap */ if( option_sense == true ) ctrl.do_yywrap = false; @@ -413,43 +413,43 @@ M4QEND "]""]" stdinit ctrl.do_stdinit = option_sense; stdout env.use_stdout = option_sense; unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); - unput ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense); + unput ctrl.no_unput = ! option_sense; verbose env.printstats = option_sense; warn env.nowarn = ! option_sense; yylineno ctrl.do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense); yymore yymore_really_used = option_sense; yywrap ctrl.do_yywrap = option_sense; - yy_push_state ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense); - yy_pop_state ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense); - yy_top_state ACTION_M4_IFDEF("M4""_YY_NO_TOP_STATE", ! option_sense); - - yy_scan_buffer ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BUFFER", ! option_sense); - yy_scan_bytes ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense); - yy_scan_string ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense); - - yyalloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense); - yyrealloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense); - yyfree ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense); - - yyget_debug ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense); - yyset_debug ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense); - yyget_extra ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense); - yyset_extra ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense); - yyget_leng ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense); - yyget_text ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense); - yyget_column ACTION_M4_IFDEF("M4""_YY_NO_GET_COLUMN", ! option_sense); - yyset_column ACTION_M4_IFDEF("M4""_YY_NO_SET_COLUMN", ! option_sense); - yyget_lineno ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense); - yyset_lineno ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense); - yyget_in ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense); - yyset_in ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense); - yyget_out ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense); - yyset_out ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense); - yyget_lval ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense); - yyset_lval ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense); - yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense); - yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense); + yy_push_state ctrl.no_yy_push_state = ! option_sense; + yy_pop_state ctrl.no_yy_pop_state = ! option_sense; + yy_top_state ctrl.no_yy_top_state = ! option_sense; + + yy_scan_buffer ctrl.no_yy_scan_buffer = ! option_sense; + yy_scan_bytes ctrl.no_yy_scan_bytes = ! option_sense; + yy_scan_string ctrl.no_yy_scan_string = ! option_sense; + + yyalloc ctrl.no_flex_alloc = ! option_sense; + yyrealloc ctrl.no_flex_realloc = ! option_sense; + yyfree ctrl.no_flex_free = ! option_sense; + + yyget_debug ctrl.no_get_debug = ! option_sense; + yyset_debug ctrl.no_set_debug = ! option_sense; + yyget_extra ctrl.no_yyget_extra = ! option_sense; + yyset_extra ctrl.no_yyset_extra = ! option_sense; + yyget_leng ctrl.no_yyget_leng = ! option_sense; + yyget_text ctrl.no_yyget_text = ! option_sense; + yyget_column ctrl.no_yyget_column = ! option_sense; + yyset_column ctrl.no_yyset_column = ! option_sense; + yyget_lineno ctrl.no_yyget_lineno = ! option_sense; + yyset_lineno ctrl.no_yyset_lineno = ! option_sense; + yyget_in ctrl.no_yyget_in = ! option_sense; + yyset_in ctrl.no_yyset_in = ! option_sense; + yyget_out ctrl.no_yyget_out = ! option_sense; + yyset_out ctrl.no_yyset_out = ! option_sense; + yyget_lval ctrl.no_yyget_lval = ! option_sense; + yyset_lval ctrl.no_yyset_lval = ! option_sense; + yyget_lloc ctrl.no_yyget_lloc = ! option_sense; + yyset_lloc ctrl.no_yyset_lloc = ! option_sense; extra-type return TOK_EXTRA_TYPE; outfile return TOK_OUTFILE; -- cgit v1.2.1 From 0fc45ce97ce30c74f1a8b2024bed2ac3e491665e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 2 Oct 2020 10:48:21 -0400 Subject: Clean up various sporadic symbol definitions that weren't going through ctrl. Includes handling of --nounistd, --always_interactive, --never_interactive, --stack, their corresponding lexer items, and and noinput. An unavoidable side effect is that the place where "#define YY_NO_INPUT 1" is inserted, if it's inserted. has to move because it's done by a different route - m4 expansion rather than the action_define function (which is now gone - this was the last use). I have put the new insertion point just iin time for the first reference to the macro. Otherwise the only diffs in generarted test code are symbol definitions becoming visible. #56 in the retargeting patch series --- src/cpp-flex.skl | 2 ++ src/flexdef.h | 12 +++++++----- src/gen.c | 2 +- src/main.c | 23 ++++++++++++++++++----- src/misc.c | 23 ----------------------- src/scan.l | 26 ++++++-------------------- 6 files changed, 34 insertions(+), 54 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4d3af2c..1042b02 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1219,6 +1219,8 @@ static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); #endif +m4_ifdef([[M4_MODE_NO_INPUT]], [[#define YY_NO_INPUT 1]]) + #ifndef YY_NO_INPUT %if-c-only Standard (non-C++) definition %not-for-header diff --git a/src/flexdef.h b/src/flexdef.h index 07d6078..29d8dc3 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -356,6 +356,7 @@ extern struct flex_backend_t cpp_backend; * If it;s in this structure, it has a corresponding m4 symbol. */ struct ctrl_bundle_t { + bool always_interactive;// always use cheacter-by-character input FILE *backing_up_file; // file to summarize backing-up states to bool bison_bridge_lval; // (--bison-bridge), bison pure calling convention. bool bison_bridge_lloc; // (--bison-locations), bison yylloc. @@ -371,18 +372,22 @@ struct ctrl_bundle_t { bool fullspd; // (-F flag) use Jacobson method of table representation bool fulltbl; // (-Cf flag) don't compress the DFA state table bool gen_line_dirs; // (no -L flag) generate #line directives - trit interactive; // (-I) generate an interactive scanner + trit interactive; // (-I) generate an interactive scanner + bool never_interactive; // always use buffered input, don't check for tty/ bool lex_compat; // (-l), maximize compatibility with AT&T lex bool long_align; // (-Ca flag), favor long-word alignment for speed + bool no_input; // Suppress use of imnput() + bool no_unistd; // suppress inclusion of unistd.h bool posix_compat; // (-X) maximize compatibility with POSIX lex char *prefix; // prefix for externally visible names, default "yy" bool reentrant; // if true (-R), generate a reentrant C scanner + bool stack_used; // Enable use of start-condition stacks bool spprdflt; // (-s) suppress the default rule bool useecs; // (-Ce flag) use equivalence classes bool usemecs; // (-Cm flag), use meta-equivalence classes bool use_read; // (-f, -F, or -Cr) use read() for scanner input // otherwise, use fread(). - char *yyclass; // yyFlexLexer subclass to use for YY_DECL + char *yyclass; // yyFlexLexer subclass to use for YY_DECL bool yytext_is_array; // if true (i.e., %array directive), then declare // yytext as array instead of a character pointer. // Nice and inefficient. @@ -851,9 +856,6 @@ extern void usage(void); /* from file misc.c */ -/* Add a #define to the action file. */ -extern void action_define(const char *defname, int value); - /* Add the given text to the stored actions. */ extern void add_action(const char *new_text); diff --git a/src/gen.c b/src/gen.c index 940801a..925b195 100644 --- a/src/gen.c +++ b/src/gen.c @@ -65,7 +65,7 @@ static void geneoltbl (void) { int i; - outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[["); + outn ("m4_ifdef( [[M4_MODE_YYLINENO]],[["); backend->comment ("Table of booleans, true if rule could match eol.\n"); footprint += backend->geneoltbl(num_rules + 1); diff --git a/src/main.c b/src/main.c index ffbf721..559d8cd 100644 --- a/src/main.c +++ b/src/main.c @@ -868,7 +868,7 @@ void flexinit (int argc, char **argv) break; case OPT_NO_UNISTD_H: - buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0); + ctrl.no_unistd = true; break; case OPT_TABLES_FILE: @@ -917,11 +917,11 @@ void flexinit (int argc, char **argv) break; case OPT_ALWAYS_INTERACTIVE: - buf_m4_define (&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0); + ctrl.always_interactive = true; break; case OPT_NEVER_INTERACTIVE: - buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0); + ctrl.never_interactive = true; break; case OPT_ARRAY: @@ -974,7 +974,7 @@ void flexinit (int argc, char **argv) break; case OPT_STACK: - buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0); + ctrl.stack_used = true; break; case OPT_STDINIT: @@ -1496,7 +1496,10 @@ void readin (void) visible_define ( "M4_MODE_TABLESEXT"); if (ctrl.prefix != NULL) visible_define_str ( "M4_MODE_PREFIX", ctrl.prefix); - + + if (ctrl.no_input) + visible_define("M4_MODE_NO_INPUT"); + if (ctrl.no_yy_push_state) visible_define("M4_YY_NO_PUSH_STATE"); if (ctrl.no_yy_pop_state) @@ -1554,6 +1557,16 @@ void readin (void) if (ctrl.no_set_debug) visible_define("M4_YY_NO_SET_DEBUG"); + if (ctrl.no_unistd) + visible_define("M4_YY_NO_UNISTD_H"); + + if (ctrl.always_interactive) + visible_define("M4_YY_ALWAYS_INTERACTIVE"); + if (ctrl.never_interactive) + visible_define("M4_YY_NEVER_INTERACTIVE"); + if (ctrl.stack_used) + visible_define("M4_YY_STACK_USED"); + backend->comment("m4 controls end\n"); out ("\n"); diff --git a/src/misc.c b/src/misc.c index 931db51..40c23ca 100644 --- a/src/misc.c +++ b/src/misc.c @@ -88,29 +88,6 @@ static void sko_pop(bool* dc) flex_die("popped too many times in skeleton."); } -/* Append a constant declaration to the running buffer. */ -void action_define (const char *defname, int value) -{ - char buf[MAXLINE]; - char *cpy; - - if ((int) strlen (defname) > MAXLINE / 2) { - format_pinpoint_message (_ - ("name \"%s\" ridiculously long"), - defname); - return; - } - - snprintf (buf, sizeof(buf), backend->int_define_fmt, defname, value); - add_action (buf); - - /* track definitions so we can naybe undef them when we're done; - * this is only ever likely to work with the cpp back end. - */ - cpy = xstrdup(defname); - buf_append (&defs_buf, &cpy, 1); -} - /* Append "new_text" to the running buffer. */ void add_action (const char *new_text) { diff --git a/src/scan.l b/src/scan.l index cb1a477..099d153 100644 --- a/src/scan.l +++ b/src/scan.l @@ -50,23 +50,9 @@ extern const char *escaped_qstart, *escaped_qend; #define ESCAPED_QEND M4QEND "]" M4QSTART M4QEND "]" M4QSTART #define ACTION_ECHO add_action( yytext ) -#define ACTION_IFDEF(def, should_define) \ - { \ - if ( should_define ) \ - action_define( def, 1 ); \ - } - #define ACTION_ECHO_QSTART add_action (ESCAPED_QSTART) #define ACTION_ECHO_QEND add_action (ESCAPED_QEND) -#define ACTION_M4_IFDEF(def, should_define) \ - do{ \ - if ( should_define ) \ - buf_m4_define( &m4defs_buf, def, NULL);\ - else \ - buf_m4_undefine( &m4defs_buf, def);\ - } while(0) - #define MARK_END_OF_PROLOG mark_prolog(); #define YY_DECL \ @@ -364,7 +350,7 @@ M4QEND "]""]" align ctrl.long_align = option_sense; always-interactive { - ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense ); + ctrl.always_interactive = option_sense; ctrl.interactive = (trit)option_sense; } array ctrl.yytext_is_array = option_sense; @@ -388,7 +374,7 @@ M4QEND "]""]" ctrl.useecs = ctrl.usemecs = false; ctrl.use_read = ctrl.fulltbl = true; } - input ACTION_IFDEF("YY_NO_INPUT", ! option_sense); + input ctrl.no_input = ! option_sense; interactive ctrl.interactive = (trit)option_sense; lex-compat ctrl.posix_compat = option_sense; posix-compat ctrl.posix_compat = option_sense; @@ -401,7 +387,7 @@ M4QEND "]""]" } meta-ecs ctrl.usemecs = option_sense; never-interactive { - ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense ); + ctrl.never_interactive = option_sense; ctrl.interactive = (trit)!option_sense; } perf-report env.performance_hint += option_sense ? 1 : -1; @@ -409,14 +395,14 @@ M4QEND "]""]" read ctrl.use_read = option_sense; reentrant ctrl.reentrant = option_sense; reject reject_really_used = option_sense; - stack ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense ); + stack ctrl.stack_used = option_sense; stdinit ctrl.do_stdinit = option_sense; stdout env.use_stdout = option_sense; - unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); + unistd ctrl.no_unistd = ! option_sense; unput ctrl.no_unput = ! option_sense; verbose env.printstats = option_sense; warn env.nowarn = ! option_sense; - yylineno ctrl.do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense); + yylineno ctrl.do_yylineno = option_sense; yymore yymore_really_used = option_sense; yywrap ctrl.do_yywrap = option_sense; -- cgit v1.2.1 From ea32296019ed0ce028bd018fcca4697c702a0022 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 2 Oct 2020 15:45:46 -0400 Subject: As of this commit, all mode symbolds are finally visible. All symbols except a handful dependent on nultrans and the number of backups are now written in one visible group right at the start of m4 generation. The exception are exceptions because their values are not known until after DFA computation. Has comment diffs in generated test code due to one symbol rename and symbols beoming visible. Should be the last time the latter happens. #57 in the retargeting patch series --- src/buf.c | 1 - src/cpp-flex.skl | 76 ++++++++++++++++++++++++++++---------------------------- src/flexdef.h | 2 -- src/main.c | 75 ++++++++++++++++++++++++------------------------------- 4 files changed, 70 insertions(+), 84 deletions(-) diff --git a/src/buf.c b/src/buf.c index 0ed7d06..04fad26 100644 --- a/src/buf.c +++ b/src/buf.c @@ -49,7 +49,6 @@ struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */ struct Buf defs_buf; /**< for #define's autogenerated. List of strings. */ struct Buf yydmap_buf; /**< string buffer to hold yydmap elements */ -struct Buf m4defs_buf; /**< m4 definitions. List of strings. */ struct Buf top_buf; /**< contains %top code. String buffer. */ struct Buf *buf_print_strings(struct Buf * buf, FILE* out) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 1042b02..ae8adfc 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -65,31 +65,31 @@ m4_changequote([[, ]]) %not-for-header %if-c-only %if-not-reentrant -m4_ifelse(M4_YY_PREFIX,yy,, -#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]] -#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]] -#define yy_scan_buffer M4_YY_PREFIX[[_scan_buffer]] -#define yy_scan_string M4_YY_PREFIX[[_scan_string]] -#define yy_scan_bytes M4_YY_PREFIX[[_scan_bytes]] -#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]] -#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]] -#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]] -#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]] -#define yypush_buffer_state M4_YY_PREFIX[[push_buffer_state]] -#define yypop_buffer_state M4_YY_PREFIX[[pop_buffer_state]] -#define yyensure_buffer_stack M4_YY_PREFIX[[ensure_buffer_stack]] -#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]] -#define yyin M4_YY_PREFIX[[in]] -#define yyleng M4_YY_PREFIX[[leng]] -#define yylex M4_YY_PREFIX[[lex]] -#define yylineno M4_YY_PREFIX[[lineno]] -#define yyout M4_YY_PREFIX[[out]] -#define yyrestart M4_YY_PREFIX[[restart]] -#define yytext M4_YY_PREFIX[[text]] -#define yywrap M4_YY_PREFIX[[wrap]] -#define yyalloc M4_YY_PREFIX[[alloc]] -#define yyrealloc M4_YY_PREFIX[[realloc]] -#define yyfree M4_YY_PREFIX[[free]] +m4_ifelse(M4_MODE_PREFIX,yy,, +#define yy_create_buffer M4_MODE_PREFIX[[_create_buffer]] +#define yy_delete_buffer M4_MODE_PREFIX[[_delete_buffer]] +#define yy_scan_buffer M4_MODE_PREFIX[[_scan_buffer]] +#define yy_scan_string M4_MODE_PREFIX[[_scan_string]] +#define yy_scan_bytes M4_MODE_PREFIX[[_scan_bytes]] +#define yy_init_buffer M4_MODE_PREFIX[[_init_buffer]] +#define yy_flush_buffer M4_MODE_PREFIX[[_flush_buffer]] +#define yy_load_buffer_state M4_MODE_PREFIX[[_load_buffer_state]] +#define yy_switch_to_buffer M4_MODE_PREFIX[[_switch_to_buffer]] +#define yypush_buffer_state M4_MODE_PREFIX[[push_buffer_state]] +#define yypop_buffer_state M4_MODE_PREFIX[[pop_buffer_state]] +#define yyensure_buffer_stack M4_MODE_PREFIX[[ensure_buffer_stack]] +#define yy_flex_debug M4_MODE_PREFIX[[_flex_debug]] +#define yyin M4_MODE_PREFIX[[in]] +#define yyleng M4_MODE_PREFIX[[leng]] +#define yylex M4_MODE_PREFIX[[lex]] +#define yylineno M4_MODE_PREFIX[[lineno]] +#define yyout M4_MODE_PREFIX[[out]] +#define yyrestart M4_MODE_PREFIX[[restart]] +#define yytext M4_MODE_PREFIX[[text]] +#define yywrap M4_MODE_PREFIX[[wrap]] +#define yyalloc M4_MODE_PREFIX[[alloc]] +#define yyrealloc M4_MODE_PREFIX[[realloc]] +#define yyfree M4_MODE_PREFIX[[free]] ) %endif %endif @@ -116,16 +116,16 @@ m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) %# the argument lists to each C function. -m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]]) +m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) m4preproc_define(`M4_GEN_PREFIX',`` [[#ifdef yy$1 -#define ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED +#define ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED #else -#define yy$1 ]]M4_YY_PREFIX[[$1 +#define yy$1 ]]M4_MODE_PREFIX[[$1 #endif]] 'm4preproc_divert(1)` -[[#ifndef ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED +[[#ifndef ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED #undef yy$1 #endif]]'m4preproc_divert(0)') @@ -136,11 +136,11 @@ m4preproc_define(`M4_GEN_PREFIX',`` * We will address this in a future release of flex, or omit the C++ scanner * altogether. */ - #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]] + #define yyFlexLexer M4_MODE_PREFIX[[FlexLexer]] %endif %if-c-only -m4_ifelse(M4_YY_PREFIX,yy,, +m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`_create_buffer') M4_GEN_PREFIX(`_delete_buffer') M4_GEN_PREFIX(`_scan_buffer') @@ -192,14 +192,14 @@ m4_ifdef( [[]], ]]) -m4_ifelse(M4_YY_PREFIX,yy,, +m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`alloc') M4_GEN_PREFIX(`realloc') M4_GEN_PREFIX(`free') ) %if-c-only -m4_ifelse(M4_YY_PREFIX,yy,, +m4_ifelse(M4_MODE_PREFIX,yy,, m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ M4_GEN_PREFIX(`text') @@ -213,7 +213,7 @@ m4_ifdef( [[M4_YY_NOT_REENTRANT]], %endif -m4_ifdef( [[M4_YY_TABLES_EXTERNAL]], +m4_ifdef( [[M4_MODE_TABLESEXT]], [[ M4_GEN_PREFIX(`tables_fload') M4_GEN_PREFIX(`tables_destroy') @@ -657,10 +657,10 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ %if-c-only m4_ifdef([[M4_YY_REENTRANT]], [[ -#define M4_YY_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) +#define M4_MODE_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) ]]) m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -#define M4_YY_PREFIX[[wrap]]() (/*CONSTCOND*/1) +#define M4_MODE_PREFIX[[wrap]]() (/*CONSTCOND*/1) ]])m4_dnl %endif #define YY_SKIP_YYWRAP @@ -1030,7 +1030,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ int yy_full_lp; int *yy_full_state; ]]) -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], [[ char yytext_r[YYLMAX]; char *yytext_ptr; int yy_more_offset; @@ -3498,7 +3498,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], YY_G(yy_lp) = 0; ]]) -m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], +m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], [[ YY_G(yytext_ptr) = 0; YY_G(yy_more_offset) = 0; diff --git a/src/flexdef.h b/src/flexdef.h index 29d8dc3..c6e8661 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -1124,9 +1124,7 @@ extern struct Buf *buf_print_strings(struct Buf * buf, FILE* out); extern struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno); extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */ -extern struct Buf defs_buf; /* a char* buffer to save #define'd some symbols generated by flex. */ extern struct Buf yydmap_buf; /* a string buffer to hold yydmap elements */ -extern struct Buf m4defs_buf; /* Holds m4 definitions. */ extern struct Buf top_buf; /* contains %top code. String buffer. */ extern bool no_section3_escape; /* True if the undocumented option --unsafe-no-m4-sect3-escape was passed */ diff --git a/src/main.c b/src/main.c index 559d8cd..adda856 100644 --- a/src/main.c +++ b/src/main.c @@ -661,17 +661,9 @@ void flexinit (int argc, char **argv) /* Initialize any buffers. */ buf_init (&userdef_buf, sizeof (char)); /* one long string */ - buf_init (&defs_buf, sizeof (char *)); /* list of strings */ buf_init (&yydmap_buf, sizeof (char)); /* one long string */ buf_init (&top_buf, sizeof (char)); /* one long string */ - { - const char * m4defs_init_str[] = {"m4_changequote\n", - "m4_changequote([[, ]])\n"}; - buf_init (&m4defs_buf, sizeof (char *)); - buf_append (&m4defs_buf, &m4defs_init_str, 2); - } - sf_init (); /* initialize regex lib */ @@ -1160,8 +1152,6 @@ void readin (void) char *pname = 0; size_t nbytes = 0; - buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL); - if (!tablesfilename) { nbytes = strlen (ctrl.prefix) + strlen (tablesfile_template) + 2; tablesfilename = pname = calloc(nbytes, 1); @@ -1187,40 +1177,12 @@ void readin (void) if (env.skelname && (skelfile = fopen (env.skelname, "r")) == NULL) lerr (_("can't open skeleton file %s"), env.skelname); - if ( ctrl.bison_bridge_lval) - buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL); - - if ( ctrl.bison_bridge_lloc) - buf_m4_define (&m4defs_buf, "", NULL); - if (strchr(ctrl.prefix, '[') || strchr(ctrl.prefix, ']')) flexerror(_("Prefix cannot include '[' or ']'")); - buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", ctrl.prefix); if (env.did_outfilename) line_directive_out (stdout, 0); - /* Define the start condition macros. */ - { - struct Buf tmpbuf; - int i; - buf_init(&tmpbuf, sizeof(char)); - for (i = 1; i <= lastsc; i++) { - char *str, *fmt = backend->int_define_fmt; - size_t strsz; - - strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; - str = malloc(strsz); - if (!str) - flexfatal(_("allocation of macro definition failed")); - snprintf(str, strsz, fmt, scname[i], i - 1); - buf_strappend(&tmpbuf, str); - free(str); - } - buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); - buf_destroy(&tmpbuf); - } - /* This is where we begin writing to the file. */ backend->comment("A lexical scanner generated by flex\n"); @@ -1229,10 +1191,6 @@ void readin (void) if( top_buf.elts) outn((char*) top_buf.elts); - /* Dump the m4 definitions. */ - buf_print_strings(&m4defs_buf, stdout); - m4defs_buf.nelts = 0; /* memory leak here. */ - /* Place a bogus line directive, it will be fixed in the filter. */ if (ctrl.gen_line_dirs && backend->trace_fmt) { char buf2[4096]; @@ -1355,6 +1313,9 @@ void readin (void) if (ctrl.useecs) ccl2ecl (); + out ("m4_changequote\n"); + out ("m4_changequote([[, ]])\n"); + // These are used to conditionalize code in the lex skeleton // that historically used to be generated by C code in flex // itself; by shoving all this stuff out to the skeleton file @@ -1362,6 +1323,34 @@ void readin (void) backend->comment("m4 controls begin\n"); + /* Define the start condition macros. */ + { + struct Buf tmpbuf; + int i; + buf_init(&tmpbuf, sizeof(char)); + for (i = 1; i <= lastsc; i++) { + char *str, *fmt = backend->int_define_fmt; + size_t strsz; + + strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; + str = malloc(strsz); + if (!str) + flexfatal(_("allocation of macro definition failed")); + snprintf(str, strsz, fmt, scname[i], i - 1); + buf_strappend(&tmpbuf, str); + free(str); + } + // FIXME: Not dumped visibly because we plan to do away with the indirection + out_m4_define("M4_YY_SC_DEFS", tmpbuf.elts); + buf_destroy(&tmpbuf); + } + + if (ctrl.bison_bridge_lval) + visible_define("M4_YY_BISON_LVAL"); + + if (ctrl.bison_bridge_lloc) + visible_define(""); + if (extra_type != NULL) visible_define_str ("M4_EXTRA_TYPE_DEFS", extra_type); @@ -1371,7 +1360,7 @@ void readin (void) if (ctrl.reentrant) { visible_define ("M4_YY_REENTRANT"); if (ctrl.yytext_is_array) - visible_define ("M4_YY_TEXT_IS_ARRAY"); + visible_define ("M4_MODE_REENTRANT_TEXT_IS_ARRAY"); } else visible_define ("M4_YY_NOT_REENTRANT"); -- cgit v1.2.1 From 6c1b4a95f9f81b4b381e7aff1cf998efe7906663 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 3 Oct 2020 06:22:16 -0400 Subject: Begin replacing method table entries with hook macros Do this for table opener/closer/continuation syntax, the trace-format string, the state entry string, constant definitions, the state-dyad format, and the three pieces of EOF state syntax. The documentation appendix on how to write a back end is also updated. There are comment diffs because I decided generating an explicit fallthrough marker and some other new explanatory comments was a good idea. #58 in the retargeting patch series --- doc/flex.texi | 15 ++++++++------- src/cpp-flex.skl | 27 +++++++++++++++++++++++++++ src/cpp_backend.c | 13 +------------ src/dfa.c | 8 ++++---- src/flexdef.h | 13 +------------ src/gen.c | 43 +++++++++++++++++++------------------------ src/main.c | 16 ++++++---------- src/misc.c | 19 ++++++++++--------- 8 files changed, 76 insertions(+), 78 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 1f7192b..570fd7c 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8596,6 +8596,11 @@ Read the definition of struct backend_t in @file{src/flexdefs.h}, and attached comments, to get a feel for the methods. Don't worry about understandng table generator names at first. +You'll also need to look at the @code{M4_HOOK_*} macros near the top +of the skeleton file. Rather than emit literal language syntax, as +often as possible Flex ships calls to these which are expected to be +expanded within the skeleton. + To write support for a language, you'll want to do the following steps: @@ -8654,11 +8659,6 @@ require fixes outside a back end. @item The item separator in data initializers is a comma. -@item -The language has a case-arm syntax that looks like -a (possibly empty) prefix, followed by a value -expression, followed by a colon. - @item Either case arms can be stacked as in C; that is, there is an implicit fallthrough if the case arm has no code. Or, @@ -8666,8 +8666,9 @@ there is an explicit fallthrough keyword that enables this, as in Go. @end enumerate -By putting a @code{yyterminate()} call in the fallthrough member -and a null pointer in the endcase member, you could handle +By putting a @code{yyterminate()} call in the expansion of +@code{M4_HOOK_EOF_STATE_CASE_FALLTHROUGH} and defining an empty +@code{M4_HOOK_EOF_STATE_CASE_TERMINATE} macro, you could handle languages like Pascal. @node Indices, , Appendices, Top diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index ae8adfc..f6efd70 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -62,6 +62,33 @@ m4_changequote([[, ]]) %# edit the skeleton. %# +%# Macro hooks used by Flex start here + +%# If this is not defined, no trace lines will be generated. +m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" +]]) + +m4_define([[M4_HOOK_TABLE_OPENER]], [[ {]]) +m4_define([[M4_HOOK_TABLE_CONTINUE]], [[ }, +]]) +m4_define([[M4_HOOK_TABLE_CLOSER]], [[ }; +]]) + +m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], +]]) + +m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); +]]) + +m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 +]]) + +m4_define([[M4_HOOK_STATE_DYAD]], [[ {$1, $2},]]) + +%# Macro hooks used by lex end here + %not-for-header %if-c-only %if-not-reentrant diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 7342cae..a430f2e 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -309,20 +309,12 @@ const char *cpp_skel[] = { struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, - .trace_fmt = "#line %d \"%s\"\n", - .int_define_fmt = "#define %s %d\n", - .string_define_fmt = "#define %s %s\n", - .table_opener = " {", - .table_continuation = " },\n", - .table_closer = " };\n", - .dyad = " {%4d,%4d },", .comment = cpp_comment, .ntod = cpp_ntod, .geneoltbl = cpp_geneoltbl, .mkctbl = cpp_mkctbl, .gen_yy_trans = cpp_gen_yy_trans, .start_state_list = cpp_start_state_list, - .state_entry_fmt = " &yy_transition[%d],\n", .mkftbl = cpp_mkftbl, .genftbl = cpp_genftbl, .gentabs_acclist = cpp_gentabs_acclist, @@ -336,8 +328,5 @@ struct flex_backend_t cpp_backend = { .nultrans = cpp_nultrans, .trans_offset_type = cpp_trans_offset_type, .debug_header = cpp_debug_header, - .caseprefix = "case ", - .fallthrough = NULL, - .endcase = "yyterminate();", - .c_like = 1, + .c_like = true, }; diff --git a/src/dfa.c b/src/dfa.c index 2b44017..60097c3 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -523,7 +523,7 @@ size_t ntod (void) backend->ntod(num_full_table_rows); if (gentables) - outn (backend->table_opener); + outn ("M4_HOOK_TABLE_OPENER"); /* Generate 0 entries for state #0. */ for (i = 0; i < num_full_table_rows; ++i) { @@ -533,7 +533,7 @@ size_t ntod (void) dataflush (); if (gentables) - outn (backend->table_continuation); + outn ("M4_HOOK_TABLE_CONTINUE"); } /* Create the first states. */ @@ -687,7 +687,7 @@ size_t ntod (void) yynxt_tbl->td_lolen * sizeof (flex_int32_t)); if (gentables) - outn (backend->table_opener); + outn ("M4_HOOK_TABLE_OPENER"); /* Supply array's 0-element. */ if (ds == end_of_buffer_state) { @@ -712,7 +712,7 @@ size_t ntod (void) dataflush (); if (gentables) - out (backend->table_continuation); + outn ("M4_HOOK_TABLE_CONTINUE"); } else if (ctrl.fullspd) diff --git a/src/flexdef.h b/src/flexdef.h index c6e8661..2bb8371 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,14 +306,7 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code const char **skel; - char *trace_fmt; // Trace message format // Language syntax generation - char *int_define_fmt; // Format for integer constant definitions - char *string_define_fmt; // Format for string constant definitions - char *table_opener; // Open an array initializer with this - char *table_continuation; // Open an array initializer with this - char *table_closer; // How to continue a two-level initializer - char *dyad; // How to format and int[2] initializer void (*comment)(const char *); // Wrap a comment line // Flex table generation void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) @@ -323,7 +316,6 @@ struct flex_backend_t { size_t (*start_state_list)(size_t); // Start initializer for table of pointers to start states void (*mkftbl)(); // Make full table serialization entry size_t (*genftbl)(size_t); // Make full table initializer start - const char *state_entry_fmt; // Format of state table entry size_t (*gentabs_acclist)(size_t); // Generate accept list initializer start size_t (*gentabs_accept)(size_t); // Generate accept table initializer start size_t (*gentabs_yy_meta)(size_t); // Generate yy_meta table initializer start @@ -335,10 +327,7 @@ struct flex_backend_t { size_t (*nultrans)(int, size_t); // Generate nulltrans initializer const char *(*trans_offset_type)(int); // Compute an efficient type for transition tables size_t (*debug_header)(size_t); // Start initializer for rule-to-line mappings - char *caseprefix; // Prefix of an arm in the language's case construct - char *fallthrough; // Finish a case arm with this to fall through - char *endcase; // What to ship after all EOF-state case arms - int c_like; // Will &yy_transition[%d]," produce a pointer table entry? + bool c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; extern size_t footprint; diff --git a/src/gen.c b/src/gen.c index 925b195..dad4cdb 100644 --- a/src/gen.c +++ b/src/gen.c @@ -76,7 +76,7 @@ static void geneoltbl (void) if ((i % 20) == 19) out ("\n "); } - outn (backend->table_closer); + outn ("M4_HOOK_TABLE_CLOSER"); } outn ("]])"); } @@ -287,15 +287,15 @@ void genctbl (void) transition_struct_out (chk[tblend + 2], nxt[tblend + 2]); if (gentables) - outn (backend->table_closer); + outn ("M4_HOOK_TABLE_CLOSER"); footprint += backend->start_state_list(lastsc * 2 + 1); if (gentables) { - outn (backend->table_opener); + outn ("M4_HOOK_TABLE_OPENER"); for (i = 0; i <= lastsc * 2; ++i) - out_dec (backend->state_entry_fmt, base[i]); + out_dec ("M4_HOOK_STATE_ENTRY_FORMAT(%d)", base[i]); dataend (); } @@ -829,7 +829,7 @@ void make_tables (void) int did_eof_rule = false; struct yytbl_data *yynultrans_tbl = NULL; - backend->comment("m4 controls begin\n"); + backend->comment("START of m4 controls\n"); // mode switches for yy_trans_info specification // nultrans @@ -847,24 +847,23 @@ void make_tables (void) visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); } - backend->comment("m4 controls end\n"); + backend->comment("END of m4 controls\n"); out ("\n"); // There are a couple more modes we can't compute until after // tables have been generated. - out_dec ("#define YY_NUM_RULES %d\n", num_rules); - out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1); - - fprintf (stdout, backend->int_define_fmt, "YY_JAMBASE", jambase); - fprintf (stdout, backend->int_define_fmt, "YY_JAMSTATE", jamstate); - - fprintf (stdout, backend->int_define_fmt, "YY_NUL_EC", NUL_ec); - + backend->comment("START of Flex-generated definitions\n"); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUM_RULES", num_rules); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_END_OF_BUFFER", num_rules + 1); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMBASE", jambase); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMSTATE", jamstate); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUL_EC", NUL_ec); /* Need to define the transet type as a size large * enough to hold the biggest offset. */ - fprintf (stdout, backend->string_define_fmt, "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1)); + out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1), ""); + backend->comment("END of Flex-generated definitions\n"); skelout (); /* %% [2.0] - tables get dumped here */ @@ -1042,19 +1041,15 @@ void make_tables (void) /* generate cases for any missing EOF rules */ for (i = 1; i <= lastsc; ++i) if (!sceof[i]) { - outc ('\t'); - out_str3 ("%sYY_STATE_EOF(%s):\n", backend->caseprefix, scname[i], ""); - if (backend->fallthrough != NULL) { - outc ('\t'); - outn (backend->fallthrough); - } + out_str ("M4_HOOK_EOF_STATE_CASE_ARM(%s)", scname[i]); + outc('\n'); + out ("M4_HOOK_EOF_STATE_CASE_FALLTHROUGH"); + outc('\n'); did_eof_rule = true; } if (did_eof_rule) { - outc ('\t'); - outc ('\t'); - outn (backend->endcase); + out ("M4_HOOK_EOF_STATE_CASE_TERMINATE"); } skelout (); diff --git a/src/main.c b/src/main.c index adda856..c1e322e 100644 --- a/src/main.c +++ b/src/main.c @@ -956,7 +956,7 @@ void flexinit (int argc, char **argv) if (*def == '\0') def = "1"; - snprintf(buf2, sizeof(buf2), backend->string_define_fmt, arg, def); + snprintf(buf2, sizeof(buf2), "M4_HOOK_CONST_DEFINE(%s, %s)", arg, def); buf_strappend (&userdef_buf, buf2); } break; @@ -1192,11 +1192,7 @@ void readin (void) outn((char*) top_buf.elts); /* Place a bogus line directive, it will be fixed in the filter. */ - if (ctrl.gen_line_dirs && backend->trace_fmt) { - char buf2[4096]; - snprintf(buf2, sizeof(buf2), backend->trace_fmt, 0, "M4_YY_OUTFILE_NAME"); - outn(buf2); - } + line_directive_out(0, false); /* Dump the user defined preproc directives. */ if (userdef_buf.elts) @@ -1321,7 +1317,7 @@ void readin (void) // itself; by shoving all this stuff out to the skeleton file // we make it easier to retarget the code generation. - backend->comment("m4 controls begin\n"); + backend->comment("START of m4 controls\n"); /* Define the start condition macros. */ { @@ -1329,14 +1325,14 @@ void readin (void) int i; buf_init(&tmpbuf, sizeof(char)); for (i = 1; i <= lastsc; i++) { - char *str, *fmt = backend->int_define_fmt; + char *str, *fmt = "M4_HOOK_CONST_DEFINE(%s, %d)"; size_t strsz; strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; str = malloc(strsz); if (!str) flexfatal(_("allocation of macro definition failed")); - snprintf(str, strsz, fmt, scname[i], i - 1); + snprintf(str, strsz, fmt, scname[i], i - 1); buf_strappend(&tmpbuf, str); free(str); } @@ -1556,7 +1552,7 @@ void readin (void) if (ctrl.stack_used) visible_define("M4_YY_STACK_USED"); - backend->comment("m4 controls end\n"); + backend->comment("END of m4 controls\n"); out ("\n"); skelout (); diff --git a/src/misc.c b/src/misc.c index 40c23ca..dc2d0b1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -238,7 +238,7 @@ void dataend (void) dataflush (); /* add terminator for initialization; { for vi */ - outn (backend->table_closer); + outn ("M4_HOOK_TABLE_CLOSER"); } dataline = 0; datapos = 0; @@ -319,6 +319,7 @@ void lerr_fatal (const char *msg, ...) void line_directive_out (FILE *output_file, int do_infile) { + char *trace_fmt = "m4_ifdef([[M4_HOOK_TRACE_LINE_FORMAT]], [[M4_HOOK_TRACE_LINE_FORMAT([[%d]], [[%s]])]])"; char directive[MAXLINE*2], filename[MAXLINE]; char *s1, *s2, *s3; @@ -328,7 +329,7 @@ void line_directive_out (FILE *output_file, int do_infile) s1 = do_infile ? infilename : "M4_YY_OUTFILE_NAME"; if (do_infile && !s1) - s1 = ""; + s1 = ""; s2 = filename; s3 = &filename[sizeof (filename) - 2]; @@ -343,12 +344,11 @@ void line_directive_out (FILE *output_file, int do_infile) *s2 = '\0'; - if (backend->trace_fmt) - if (do_infile) - snprintf (directive, sizeof(directive), backend->trace_fmt, linenum, filename); - else { - snprintf (directive, sizeof(directive), backend->trace_fmt, 0, filename); - } + if (do_infile) + snprintf (directive, sizeof(directive), trace_fmt, linenum, filename); + else { + snprintf (directive, sizeof(directive), trace_fmt, 0, filename); + } /* If output_file is nil then we should put the directive in * the accumulated actions. @@ -810,7 +810,8 @@ void transition_struct_out (int element_v, int element_n) if (!gentables) return; - out_dec2 (backend->dyad, element_v, element_n); + out_dec2 ("M4_HOOK_STATE_DYAD([[%4d]],[[%4d]])", element_v, element_n); + outc ('\n'); datapos += TRANS_STRUCT_PRINT_LENGTH; -- cgit v1.2.1 From e5386ba36835b7ffab67bd30cb28a116bb1cea5c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 3 Oct 2020 12:23:14 -0400 Subject: Refactor so all skelout calls are in visible sequence in flex_main(). This makes the overall control flow easier to understand. #59 in the retargeting patch series --- src/gen.c | 91 +-------------------------------------------------------- src/main.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 97 deletions(-) diff --git a/src/gen.c b/src/gen.c index dad4cdb..0fb283f 100644 --- a/src/gen.c +++ b/src/gen.c @@ -819,54 +819,15 @@ void visible_define_str (const char *symname, const char *val) outc ('\n'); } -/* make_tables - generate transition tables and finishes generating output file +/* make_tables - generate transition tables */ void make_tables (void) { char buf[128]; int i; - int did_eof_rule = false; struct yytbl_data *yynultrans_tbl = NULL; - backend->comment("START of m4 controls\n"); - - // mode switches for yy_trans_info specification - // nultrans - if (nultrans) - visible_define ( "M4_MODE_NULTRANS"); - else { - visible_define ( "M4_MODE_NO_NULTRANS"); - if (ctrl.fulltbl) - visible_define ( "M4_MODE_NULTRANS_FULLTBL"); - else - visible_define ( "M4_MODE_NO_NULTRANS_FULLTBL"); - if (ctrl.fullspd) - visible_define ( "M4_MODE_NULTRANS_FULLSPD"); - else - visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); - } - - backend->comment("END of m4 controls\n"); - out ("\n"); - - // There are a couple more modes we can't compute until after - // tables have been generated. - - backend->comment("START of Flex-generated definitions\n"); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUM_RULES", num_rules); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_END_OF_BUFFER", num_rules + 1); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMBASE", jambase); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMSTATE", jamstate); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUL_EC", NUL_ec); - /* Need to define the transet type as a size large - * enough to hold the biggest offset. - */ - out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1), ""); - backend->comment("END of Flex-generated definitions\n"); - - skelout (); /* %% [2.0] - tables get dumped here */ - /* This is where we REALLY begin generating the tables. */ if (ctrl.fullspd) { @@ -1017,54 +978,4 @@ void make_tables (void) mkdata (rule_linenum[i]); dataend (); } - - skelout (); /* %% [3.0] - mode-dependent static declarations get dumped here */ - - out (&action_array[defs1_offset]); - - line_directive_out (stdout, 0); - - skelout (); /* %% [4.0] - various random yylex internals get dumped here */ - - /* Copy prolog to output file. */ - out (&action_array[prolog_offset]); - - line_directive_out (stdout, 0); - - skelout (); /* %% [5.0] - main loop of matching-emngine code gets dumped here */ - - /* Copy actions to output file. */ - out (&action_array[action_offset]); - - line_directive_out (stdout, 0); - - /* generate cases for any missing EOF rules */ - for (i = 1; i <= lastsc; ++i) - if (!sceof[i]) { - out_str ("M4_HOOK_EOF_STATE_CASE_ARM(%s)", scname[i]); - outc('\n'); - out ("M4_HOOK_EOF_STATE_CASE_FALLTHROUGH"); - outc('\n'); - did_eof_rule = true; - } - - if (did_eof_rule) { - out ("M4_HOOK_EOF_STATE_CASE_TERMINATE"); - } - - skelout (); - - /* Copy remainder of input to output. */ - - line_directive_out (stdout, 1); - - if (sectnum == 3) { - OUT_BEGIN_CODE (); - if (!no_section3_escape) - fputs("[[", stdout); - (void) flexscan (); /* copy remainder of input to output */ - if (!no_section3_escape) - fputs("]]", stdout); - OUT_END_CODE (); - } } diff --git a/src/main.c b/src/main.c index c1e322e..2be00f9 100644 --- a/src/main.c +++ b/src/main.c @@ -132,6 +132,7 @@ int flex_main (int argc, char *argv[]); int flex_main (int argc, char *argv[]) { int i, exit_status, child_status; + int did_eof_rule = false; /* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The * return value of setjmp, if non-zero, is the desired exit code PLUS ONE. @@ -163,8 +164,11 @@ int flex_main (int argc, char *argv[]) readin (); - skelout (); - /* %% [1.5] DFA */ + skelout (); /* %% [1.0] */ + + backend->comment("Begin user sect3\n"); + + skelout (); /* %% [1.5] DFA */ footprint += ntod (); for (i = 1; i <= num_rules; ++i) @@ -177,9 +181,94 @@ int flex_main (int argc, char *argv[]) ("-s option given but default rule can be matched"), rule_linenum[default_rule]); + backend->comment("START of m4 controls\n"); + + // mode switches for yy_trans_info specification + // nultrans + if (nultrans) + visible_define ( "M4_MODE_NULTRANS"); + else { + visible_define ( "M4_MODE_NO_NULTRANS"); + if (ctrl.fulltbl) + visible_define ( "M4_MODE_NULTRANS_FULLTBL"); + else + visible_define ( "M4_MODE_NO_NULTRANS_FULLTBL"); + if (ctrl.fullspd) + visible_define ( "M4_MODE_NULTRANS_FULLSPD"); + else + visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); + } + + backend->comment("END of m4 controls\n"); + out ("\n"); + + backend->comment("START of Flex-generated definitions\n"); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUM_RULES", num_rules); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_END_OF_BUFFER", num_rules + 1); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMBASE", jambase); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMSTATE", jamstate); + out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUL_EC", NUL_ec); + /* Need to define the transet type as a size large + * enough to hold the biggest offset. + */ + out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1), ""); + backend->comment("END of Flex-generated definitions\n"); + + skelout (); /* %% [2.0] - tables get dumped here */ + /* Generate the C state transition tables from the DFA. */ make_tables (); + skelout (); /* %% [3.0] - mode-dependent static declarations get dumped here */ + + out (&action_array[defs1_offset]); + + line_directive_out (stdout, 0); + + skelout (); /* %% [4.0] - various random yylex internals get dumped here */ + + /* Copy prolog to output file. */ + out (&action_array[prolog_offset]); + + line_directive_out (stdout, 0); + + skelout (); /* %% [5.0] - main loop of matching-engine code gets dumped here */ + + /* Copy actions to output file. */ + out (&action_array[action_offset]); + + line_directive_out (stdout, 0); + + /* generate cases for any missing EOF rules */ + for (i = 1; i <= lastsc; ++i) + if (!sceof[i]) { + out_str ("M4_HOOK_EOF_STATE_CASE_ARM(%s)", scname[i]); + outc('\n'); + out ("M4_HOOK_EOF_STATE_CASE_FALLTHROUGH"); + outc('\n'); + did_eof_rule = true; + } + + if (did_eof_rule) { + out ("M4_HOOK_EOF_STATE_CASE_TERMINATE"); + } + + skelout (); + + /* Copy remainder of input to output. */ + + line_directive_out (stdout, 1); + + if (sectnum == 3) { + OUT_BEGIN_CODE (); + if (!no_section3_escape) + fputs("[[", stdout); + (void) flexscan (); /* copy remainder of input to output */ + if (!no_section3_escape) + fputs("]]", stdout); + OUT_END_CODE (); + } + /* Note, flexend does not return. It exits with its argument * as status. */ @@ -1554,11 +1643,6 @@ void readin (void) backend->comment("END of m4 controls\n"); out ("\n"); - - skelout (); - /* %% [1.0] */ - - backend->comment("Begin user sect3\n"); } /* set_up_initial_allocations - allocate memory for internal tables */ -- cgit v1.2.1 From aea91d7e4b0c025b33f62284cff5b14b6a0b9a75 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 4 Oct 2020 00:17:17 -0400 Subject: Reopair a buuld recipe bug introduced in #52... ...by an icatous replace operation. Insidious because it's undetectibe until you run configure again, Two-phase build systems suck. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2fefc38..40ca850 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,7 +65,7 @@ COMMON_SOURCES = \ main.c \ misc.c \ nfa.c \ - ctrl.c \ + options.c \ options.h \ parse.y \ regex.c \ -- cgit v1.2.1 From 83d8bd5fb9a3b46810099dd8d50ad4de49540b1e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 4 Oct 2020 01:00:15 -0400 Subject: Enliminate several backend methods by shipping hook macros instead. They were: geneol, fulltable, eecs, and debug. To accomplish this, dataend's emission of trailing } needed to be suppressable. Also, remove a %% mark that is no longer required. This doesn't change any of the generated tables, but does change the orer in which they're generated, froducing large diffs in the generated test code that don't actually mean anything. The reason for this is that tables used to come out in a variable order as functions like geneecs were called ar variable times depending on the compressuion mode. Now, instead, the order is fixed by where the tanle-body macros these functions define are expanded. More methods remain to be turnerd into macro generators. #61 in the retargeting patch series, following an unnumbered bugfix patch that I shipped in too much of a hurry. --- src/cpp-flex.skl | 43 +++++++++++++++++++++++++++- src/cpp_backend.c | 37 ++---------------------- src/dfa.c | 2 +- src/flexdef.h | 5 +--- src/gen.c | 86 +++++++++++++++++++++++++++++++++++++++++-------------- src/main.c | 11 +++---- src/misc.c | 5 ++-- 7 files changed, 120 insertions(+), 69 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index f6efd70..5a466f8 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -679,7 +679,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) ]]) -%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. definitions & init go here +/* Begin user sect3 */ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ %if-c-only @@ -868,6 +868,47 @@ int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); %endif %% [2.0] data tables for the DFA are inserted here +m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl +/* Table of booleans, true if rule could match eol. */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = + { 0, +M4_HOOK_EOLTABLE_BODY[[]]}; +]], [[ +static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; +]]) +]]) + +m4_ifdef( [[M4_MODE_REAL_FULLTBL]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_FULLTABLE_TYPE yy_accept[M4_HOOK_FULLTABLE_SIZE] = + { 0, +M4_HOOK_FULLTABLE_BODY[[]]}; +]], [[ +static const M4_HOOK_FULLTABLE_TYPE * yy_accept = 0; +]]) +]]) + +m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = + { 0, +M4_HOOK_ECSTABLE_BODY[[]]}; +]], [[ +static const YY_CHAR * yy_ec = 0; +]]) +]]) + +m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = + { 0, +M4_HOOK_DEBUGTABLE_BODY[[]]}; +]], [[ +static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; +]]) +]]) + ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], diff --git a/src/cpp_backend.c b/src/cpp_backend.c index a430f2e..49b5a8e 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -38,6 +38,7 @@ /* These typedefs are only used for computing footprint sizes, * You need to make sure they match reality in the skeleton file to * get accurate numbers, but they don't otherwise matter. + * FIXME" This shiould go away when tFkex ships only macros. */ typedef char YY_CHAR; struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; @@ -127,13 +128,6 @@ static void cpp_ntod(size_t num_full_table_rows) */ } -static size_t cpp_geneoltbl(size_t sz) -// Generate end-of-line-transitions - only used when yylineno tracking is on -{ - out_str_dec (cpp_get_int32_decl (), "yy_rule_can_match_eol", sz); - return sizeof(int32_t) * sz; -} - static void cpp_mkctbl (size_t sz) // Make full-speed compressed transition table { @@ -173,14 +167,6 @@ static void cpp_mkftbl(void) ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); } -static size_t cpp_genftbl(size_t sz) -{ - out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), - "yy_accept", sz); - return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); -} - - static size_t cpp_gentabs_acclist(size_t sz) // Generate accept list initializer { @@ -270,7 +256,7 @@ static size_t cpp_nultrans(int fullspd, size_t afterdfa) // Generate nulltrans initializer { // Making this a backend method may be overzealous. - // How many other languages have to sprcial-case NUL + // How many other languages have to special-case NUL // because it's a string terminator? out_str_dec (cpp_get_state_decl (), "yy_NUL_trans", afterdfa); buf_prints (&yydmap_buf, @@ -279,21 +265,6 @@ static size_t cpp_nultrans(int fullspd, size_t afterdfa) return afterdfa * (fullspd ? sizeof(struct yy_trans_info *) : sizeof(int32_t)); } -static size_t cpp_debug_header(size_t sz) -{ - out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : - cpp_get_int16_decl (), "yy_rule_linenum", - sz); - return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); -} - - -static size_t cpp_genecs(size_t size) -{ - out_str_dec (cpp_get_yy_char_decl (), "yy_ec", ctrl.csize); - return sizeof(YY_CHAR) * size; -} - static const char *cpp_trans_offset_type(int total_table_size) { return (total_table_size >= INT16_MAX || ctrl.long_align) ? @@ -311,12 +282,10 @@ struct flex_backend_t cpp_backend = { .skel = cpp_skel, .comment = cpp_comment, .ntod = cpp_ntod, - .geneoltbl = cpp_geneoltbl, .mkctbl = cpp_mkctbl, .gen_yy_trans = cpp_gen_yy_trans, .start_state_list = cpp_start_state_list, .mkftbl = cpp_mkftbl, - .genftbl = cpp_genftbl, .gentabs_acclist = cpp_gentabs_acclist, .gentabs_accept = cpp_gentabs_accept, .gentabs_yy_meta = cpp_gentabs_yy_meta, @@ -324,9 +293,7 @@ struct flex_backend_t cpp_backend = { .gentabs_yy_def = cpp_gentabs_yy_def, .gentabs_yy_nxt = cpp_gentabs_yy_nxt, .gentabs_yy_chk = cpp_gentabs_yy_chk, - .genecs = cpp_genecs, .nultrans = cpp_nultrans, .trans_offset_type = cpp_trans_offset_type, - .debug_header = cpp_debug_header, .c_like = true, }; diff --git a/src/dfa.c b/src/dfa.c index 60097c3..c24bc43 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -744,7 +744,7 @@ size_t ntod (void) } if (ctrl.fulltbl) { - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yynxt_tbl); if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0) diff --git a/src/flexdef.h b/src/flexdef.h index 2bb8371..dd600eb 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -310,7 +310,6 @@ struct flex_backend_t { void (*comment)(const char *); // Wrap a comment line // Flex table generation void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) - size_t (*geneoltbl)(size_t); // Generate end-of-line transition table initializer start void (*mkctbl)(size_t); // Make full-speed compressed table initializer start size_t (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic) size_t (*start_state_list)(size_t); // Start initializer for table of pointers to start states @@ -323,10 +322,8 @@ struct flex_backend_t { size_t (*gentabs_yy_def)(size_t); // Generate yy_def initializer start size_t (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer start size_t (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer start - size_t (*genecs)(size_t); // Generates tart of equivalence-class-table initializer size_t (*nultrans)(int, size_t); // Generate nulltrans initializer const char *(*trans_offset_type)(int); // Compute an efficient type for transition tables - size_t (*debug_header)(size_t); // Start initializer for rule-to-line mappings bool c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; @@ -870,7 +867,7 @@ extern char *xstrdup(const char *); extern int cclcmp(const void *, const void *); /* Finish up a block of data declarations. */ -extern void dataend(void); +extern void dataend(const char *); /* Flush generated data statements. */ extern void dataflush(void); diff --git a/src/gen.c b/src/gen.c index 0fb283f..53ad678 100644 --- a/src/gen.c +++ b/src/gen.c @@ -34,10 +34,37 @@ #include "flexdef.h" #include "tables.h" +/* These typedefs are only used for computing footprint sizes, + * You need to make sure they match reality in the skeleton file to + * get accurate numbers, but they don't otherwise matter. + */ +typedef char YY_CHAR; +struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; + /* declare functions that have forward references */ void genecs(void); +struct packtype_t { + char *name; + size_t width; +}; + + +static struct packtype_t *optimize_pack(size_t sz) +{ + /* FIXME: There's a 32-bit assumption lurking here */ + static struct packtype_t out; + if (sz == 0) { + out.name = ctrl.long_align ? "flex_int32_t" : "flex_int16_t"; + out.width = ctrl.long_align ? 32 : 16; + } else { + out.name = (ctrl.long_align || sz <= INT16_MAX) ? "flex_int32_t" : "flex_ini16_t"; + out.width = (ctrl.long_align || sz <= INT16_MAX) ? 32 : 16; + } + return &out; +} + /** Make the table for possible eol matches. * @return the newly allocated rule_can_match_eol table */ @@ -65,9 +92,12 @@ static void geneoltbl (void) { int i; + /* FIXME: this table could be typically be packed into int16 */ outn ("m4_ifdef( [[M4_MODE_YYLINENO]],[["); - backend->comment ("Table of booleans, true if rule could match eol.\n"); - footprint += backend->geneoltbl(num_rules + 1); + outn ("m4_define([[M4_HOOK_EOLTABLE_TYPE]], [[flex_int32_t]])"); + out_dec ("m4_define([[M4_HOOK_EOLTABLE_SIZE]], [[%d]])", num_rules + 1); + outn ("m4_define([[M4_HOOK_EOLTABLE_BODY]], [[m4_dnl"); + footprint += sizeof(int32_t) * (num_rules + 1); if (gentables) { for (i = 1; i <= num_rules; i++) { @@ -76,9 +106,9 @@ static void geneoltbl (void) if ((i % 20) == 19) out ("\n "); } - outn ("M4_HOOK_TABLE_CLOSER"); } outn ("]])"); + outn ("]])"); } @@ -173,7 +203,6 @@ static struct yytbl_data *mkctbl (void) } } - /* Here's the final, end-of-buffer state. */ tdata[curr++] = chk[tblend + 1]; tdata[curr++] = nxt[tblend + 1]; @@ -297,7 +326,7 @@ void genctbl (void) for (i = 0; i <= lastsc * 2; ++i) out_dec ("M4_HOOK_STATE_ENTRY_FORMAT(%d)", base[i]); - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); } if (ctrl.useecs) @@ -337,14 +366,17 @@ void genecs (void) int ch, row; int numrows; - footprint += backend->genecs(ctrl.csize); + out_dec ("m4_define([[M4_HOOK_ECSTABLE_SIZE]], [[%d]])", ctrl.csize); + outn ("m4_define([[M4_HOOK_ECSTABLE_BODY]], [[m4_dnl"); for (ch = 1; ch < ctrl.csize; ++ch) { ecgroup[ch] = ABS (ecgroup[ch]); mkdata (ecgroup[ch]); } - dataend (); + dataend (NULL); + outn("]])"); + footprint += sizeof(YY_CHAR) * ctrl.csize; if (env.trace) { fputs (_("\n\nEquivalence Classes:\n\n"), stderr); @@ -408,10 +440,14 @@ void genftbl (void) { int i; int end_of_buffer_action = num_rules + 1; + struct packtype_t *ptype = optimize_pack(0); - footprint += backend->genftbl(lastdfa+1); dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; + out_str ("m4_define([[M4_HOOK_FULLTABLE_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_FULLTABLE_SIZE]], [[%d]])", lastdfa + 1); + outn ("m4_define([[M4_HOOK_FULLTABLE_BODY]], [[m4_dnl"); + for (i = 1; i <= lastdfa; ++i) { int anum = dfaacc[i].dfaacc_state; @@ -422,7 +458,9 @@ void genftbl (void) i, anum); } - dataend (); + dataend (NULL); + outn("]])"); + footprint += (lastdfa + 1) * ptype->width; if (ctrl.useecs) genecs (); @@ -533,7 +571,7 @@ void gentabs (void) /* add accepting number for the "jam" state */ acc_array[i] = j; - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yyacclist_tbl); if (yytbl_data_fwrite (&tableswr, yyacclist_tbl) < 0) @@ -602,7 +640,7 @@ void gentabs (void) yyacc_data[yyacc_curr++] = acc_array[i]; } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yyacc_tbl); if (yytbl_data_fwrite (&tableswr, yyacc_tbl) < 0) @@ -655,7 +693,7 @@ void gentabs (void) yymecs_data[i] = ABS (tecbck[i]); } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yymeta_tbl); if (yytbl_data_fwrite (&tableswr, yymeta_tbl) < 0) @@ -707,7 +745,7 @@ void gentabs (void) def[i] = jamstate; } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yybase_tbl); if (yytbl_data_fwrite (&tableswr, yybase_tbl) < 0) @@ -732,7 +770,7 @@ void gentabs (void) yydef_data[i] = def[i]; } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yydef_tbl); if (yytbl_data_fwrite (&tableswr, yydef_tbl) < 0) @@ -762,7 +800,7 @@ void gentabs (void) yynxt_data[i] = nxt[i]; } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yynxt_tbl); if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0) @@ -789,7 +827,7 @@ void gentabs (void) yychk_data[i] = chk[i]; } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yychk_tbl); if (yytbl_data_fwrite (&tableswr, yychk_tbl) < 0) @@ -952,7 +990,7 @@ void make_tables (void) } } - dataend (); + dataend ("M4_HOOK_TABLE_CLOSER"); if (tablesext) { yytbl_data_compress (yynultrans_tbl); if (yytbl_data_fwrite (&tableswr, yynultrans_tbl) < @@ -970,12 +1008,18 @@ void make_tables (void) } if (ctrl.ddebug) { /* Spit out table mapping rules to line numbers. */ - /* Policy choice: this returns the table size - * but we don't include it in the table metering. + /* Policy choice: we don't include this space + * in the table metering. */ - backend->debug_header(num_rules); + struct packtype_t *ptype = optimize_pack(0); + + out_str ("m4_define([[M4_HOOK_DEBUGTABLE_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_DEBUGTABLE_SIZE]], [[%d]])", num_rules); + outn ("m4_define([[M4_HOOK_DEBUGTABLE_BODY]], [[m4_dnl"); + for (i = 1; i < num_rules; ++i) mkdata (rule_linenum[i]); - dataend (); + dataend (NULL); + outn("]])"); } } diff --git a/src/main.c b/src/main.c index 2be00f9..24b6003 100644 --- a/src/main.c +++ b/src/main.c @@ -164,11 +164,7 @@ int flex_main (int argc, char *argv[]) readin (); - skelout (); /* %% [1.0] */ - - backend->comment("Begin user sect3\n"); - - skelout (); /* %% [1.5] DFA */ + skelout (); /* %% [1.0] DFA */ footprint += ntod (); for (i = 1; i <= num_rules; ++i) @@ -1474,6 +1470,11 @@ void readin (void) else visible_define ( "M4_MODE_NO_REAL_FULLSPD"); + if (ctrl.fulltbl) + visible_define ( "M4_MODE_REAL_FULLTBL"); + else + visible_define ( "M4_MODE_NO_REAL_FULLTBL"); + // niode switches for YYINPUT code generation if (ctrl.use_read) visible_define ( "M4_MODE_CPP_USE_READ"); diff --git a/src/misc.c b/src/misc.c index dc2d0b1..b26e01f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -229,7 +229,7 @@ int cclcmp (const void *a, const void *b) /* dataend - finish up a block of data declarations */ -void dataend (void) +void dataend (const char *endit) { /* short circuit any output */ if (gentables) { @@ -238,7 +238,8 @@ void dataend (void) dataflush (); /* add terminator for initialization; { for vi */ - outn ("M4_HOOK_TABLE_CLOSER"); + if (endit) + outn (endit); } dataline = 0; datapos = 0; -- cgit v1.2.1 From fafc0ef10cc9b2f1c7f758cd6ad42939bf6d5d1f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 5 Oct 2020 09:00:02 -0400 Subject: Replace the comment method with a hook macro. This required addin a new 0.0 breakpoint right after the M4_HOOK_* definitions so they will be visible early. Produces no diffs in generated test code. #62 in the retargeting patch series --- src/cpp-flex.skl | 5 ++++- src/cpp_backend.c | 16 ---------------- src/flexdef.h | 6 +++--- src/gen.c | 10 +++++----- src/main.c | 31 +++++++++++++++---------------- src/misc.c | 32 +++++++++++++++++++++++++------- 6 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 5a466f8..43b9c20 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -64,6 +64,9 @@ m4_changequote([[, ]]) %# Macro hooks used by Flex start here +m4_define([[M4_HOOK_COMMENT_OPEN]], [[/*]]) +m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) + %# If this is not defined, no trace lines will be generated. m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" ]]) @@ -87,7 +90,7 @@ m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 m4_define([[M4_HOOK_STATE_DYAD]], [[ {$1, $2},]]) -%# Macro hooks used by lex end here +%% [0.0] Make hook macros available to Flex %not-for-header %if-c-only diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 49b5a8e..40a0549 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -88,21 +88,6 @@ static const char *cpp_suffix (void) return suffix; } -static void cpp_comment(const char *txt) -{ - char buf[MAXLINE]; - bool eol; - - strncpy(buf, txt, MAXLINE-1); - eol = buf[strlen(buf)-1] == '\n'; - - if (eol) - buf[strlen(buf)-1] = '\0'; - out_str("/* [[%s]] */", buf); - if (eol) - outc ('\n'); -} - static void cpp_ntod(size_t num_full_table_rows) // Generate nxt table for ntod { @@ -280,7 +265,6 @@ const char *cpp_skel[] = { struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, - .comment = cpp_comment, .ntod = cpp_ntod, .mkctbl = cpp_mkctbl, .gen_yy_trans = cpp_gen_yy_trans, diff --git a/src/flexdef.h b/src/flexdef.h index dd600eb..9a4090c 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,8 +306,6 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code const char **skel; - // Language syntax generation - void (*comment)(const char *); // Wrap a comment line // Flex table generation void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) void (*mkctbl)(size_t); // Make full-speed compressed table initializer start @@ -953,7 +951,7 @@ extern void out_m4_define(const char* def, const char* val); extern char *readable_form(int); /* Write out one section of the skeleton file. */ -extern void skelout(void); +extern void skelout(bool); /* Output a yy_trans_info structure. */ extern void transition_struct_out(int, int); @@ -1029,6 +1027,8 @@ extern void lwarn(const char *); /* report a warning */ extern void yyerror(const char *); /* report a parse error */ extern int yyparse(void); /* the YACC parser */ +/* Ship a comment to the generated output */ +extern void comment(const char *); /* from file scan.l */ diff --git a/src/gen.c b/src/gen.c index 53ad678..7bd258b 100644 --- a/src/gen.c +++ b/src/gen.c @@ -844,7 +844,7 @@ void gentabs (void) void visible_define (const char *symname) { out_m4_define(symname, NULL); - backend->comment(symname); + comment(symname); outc ('\n'); } @@ -853,7 +853,7 @@ void visible_define_str (const char *symname, const char *val) char buf[128]; out_m4_define(symname, val); snprintf(buf, sizeof(buf), "%s = %s", symname, val); - backend->comment(buf); + comment(buf); outc ('\n'); } @@ -924,13 +924,13 @@ void make_tables (void) gentabs (); snprintf(buf, sizeof(buf), "footprint: %ld bytes\n", footprint); - backend->comment(buf); + comment(buf); outc ('\n'); // Only at this point do we know if the automaton has backups. // Some m4 conditionals require this information. - backend->comment("m4 controls begin\n"); + comment("m4 controls begin\n"); if (num_backing_up > 0) visible_define ( "M4_MODE_HAS_BACKING_UP"); @@ -941,7 +941,7 @@ void make_tables (void) if ((num_backing_up > 0 && !reject) && (ctrl.fullspd || ctrl.fulltbl)) visible_define ( "M4_MODE_NULTRANS_WRAP"); - backend->comment("m4 controls end\n"); + comment("m4 controls end\n"); out ("\n"); if (ctrl.do_yylineno) { diff --git a/src/main.c b/src/main.c index 24b6003..02a8d2c 100644 --- a/src/main.c +++ b/src/main.c @@ -164,7 +164,7 @@ int flex_main (int argc, char *argv[]) readin (); - skelout (); /* %% [1.0] DFA */ + skelout (true); /* %% [1.0] DFA */ footprint += ntod (); for (i = 1; i <= num_rules; ++i) @@ -177,7 +177,7 @@ int flex_main (int argc, char *argv[]) ("-s option given but default rule can be matched"), rule_linenum[default_rule]); - backend->comment("START of m4 controls\n"); + comment("START of m4 controls\n"); // mode switches for yy_trans_info specification // nultrans @@ -195,10 +195,10 @@ int flex_main (int argc, char *argv[]) visible_define ( "M4_MODE_NO_NULTRANS_FULLSPD"); } - backend->comment("END of m4 controls\n"); + comment("END of m4 controls\n"); out ("\n"); - backend->comment("START of Flex-generated definitions\n"); + comment("START of Flex-generated definitions\n"); out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUM_RULES", num_rules); out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_END_OF_BUFFER", num_rules + 1); out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMBASE", jambase); @@ -208,27 +208,27 @@ int flex_main (int argc, char *argv[]) * enough to hold the biggest offset. */ out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1), ""); - backend->comment("END of Flex-generated definitions\n"); + comment("END of Flex-generated definitions\n"); - skelout (); /* %% [2.0] - tables get dumped here */ + skelout (true); /* %% [2.0] - tables get dumped here */ /* Generate the C state transition tables from the DFA. */ make_tables (); - skelout (); /* %% [3.0] - mode-dependent static declarations get dumped here */ + skelout (true); /* %% [3.0] - mode-dependent static declarations get dumped here */ out (&action_array[defs1_offset]); line_directive_out (stdout, 0); - skelout (); /* %% [4.0] - various random yylex internals get dumped here */ + skelout (true); /* %% [4.0] - various random yylex internals get dumped here */ /* Copy prolog to output file. */ out (&action_array[prolog_offset]); line_directive_out (stdout, 0); - skelout (); /* %% [5.0] - main loop of matching-engine code gets dumped here */ + skelout (true); /* %% [5.0] - main loop of matching-engine code gets dumped here */ /* Copy actions to output file. */ out (&action_array[action_offset]); @@ -249,7 +249,7 @@ int flex_main (int argc, char *argv[]) out ("M4_HOOK_EOF_STATE_CASE_TERMINATE"); } - skelout (); + skelout (true); /* Copy remainder of input to output. */ @@ -1270,7 +1270,9 @@ void readin (void) /* This is where we begin writing to the file. */ - backend->comment("A lexical scanner generated by flex\n"); + skelout(false); /* [0.0] Make hook macros available, silently */ + + comment("A lexical scanner generated by flex\n"); /* Dump the %top code. */ if( top_buf.elts) @@ -1394,15 +1396,12 @@ void readin (void) if (ctrl.useecs) ccl2ecl (); - out ("m4_changequote\n"); - out ("m4_changequote([[, ]])\n"); - // These are used to conditionalize code in the lex skeleton // that historically used to be generated by C code in flex // itself; by shoving all this stuff out to the skeleton file // we make it easier to retarget the code generation. - backend->comment("START of m4 controls\n"); + comment("START of m4 controls\n"); /* Define the start condition macros. */ { @@ -1642,7 +1641,7 @@ void readin (void) if (ctrl.stack_used) visible_define("M4_YY_STACK_USED"); - backend->comment("END of m4 controls\n"); + comment("END of m4 controls\n"); out ("\n"); } diff --git a/src/misc.c b/src/misc.c index b26e01f..120a4e7 100644 --- a/src/misc.c +++ b/src/misc.c @@ -667,7 +667,7 @@ void *reallocate_array (void *array, int size, size_t element_size) * Copies skelfile or skel array to stdout until a line beginning with * "%%" or EOF is found. */ -void skelout (void) +void skelout (bool announce) { char buf_storage[MAXLINE]; char *buf = buf_storage; @@ -696,10 +696,10 @@ void skelout (void) if (ctrl.ddebug && buf[1] != '#') { bool escaped = buf[strlen (buf) - 1] == '\\'; if (escaped) { - backend->comment(buf); + comment(buf); out ("\\\n"); } else { - backend->comment(buf); + comment(buf); outc ('\n'); } } @@ -716,8 +716,10 @@ void skelout (void) } else if (buf[1] == '%') { /* %% is a break point for skelout() */ - backend->comment(buf); - outc ('\n'); + if (announce) { + comment(buf); + outc ('\n'); + } return; } else if (cmd_match (CMD_PUSH)){ @@ -725,7 +727,7 @@ void skelout (void) if(ctrl.ddebug){ char buf2[MAXLINE]; snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); - backend->comment(buf2); + comment(buf2); } out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); } @@ -734,7 +736,7 @@ void skelout (void) if(ctrl.ddebug){ char buf2[MAXLINE]; snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); - backend->comment(buf2); + comment(buf2); } out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); } @@ -865,3 +867,19 @@ char *chomp (char *str) *p-- = 0; return str; } + +void comment(const char *txt) +{ + char buf[MAXLINE]; + bool eol; + + strncpy(buf, txt, MAXLINE-1); + eol = buf[strlen(buf)-1] == '\n'; + + if (eol) + buf[strlen(buf)-1] = '\0'; + out_str("M4_HOOK_COMMENT_OPEN [[%s]] M4_HOOK_COMMENT_CLOSE", buf); + if (eol) + outc ('\n'); +} + -- cgit v1.2.1 From 64cf0328063cd97dec09536a8f2bb35ce7350ffe Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 5 Oct 2020 10:59:29 -0400 Subject: Eliminate a lurking cpp-ism from scan.l Also, remove now-unused functions from buf.c. And corral another global. Produces no diffs in generated test code. #63 in the retargeting patch series --- src/buf.c | 106 ------------------------------------------------------ src/cpp_backend.c | 4 +-- src/flexdef.h | 10 ++---- src/main.c | 6 ++-- src/scan.l | 8 +++-- 5 files changed, 13 insertions(+), 121 deletions(-) diff --git a/src/buf.c b/src/buf.c index 04fad26..6f049b4 100644 --- a/src/buf.c +++ b/src/buf.c @@ -47,25 +47,9 @@ /* global buffers. */ struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */ -struct Buf defs_buf; /**< for #define's autogenerated. List of strings. */ struct Buf yydmap_buf; /**< string buffer to hold yydmap elements */ struct Buf top_buf; /**< contains %top code. String buffer. */ -struct Buf *buf_print_strings(struct Buf * buf, FILE* out) -{ - int i; - - if(!buf || !out) - return buf; - - for (i=0; i < buf->nelts; i++){ - const char * s = ((char**)buf->elts)[i]; - if(s) - fprintf(out, "%s", s); - } - return buf; -} - /* Append a "%s" formatted string to a string buffer */ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s) { @@ -82,52 +66,6 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s) return buf; } -/** Append a line directive to the string buffer. - * @param buf A string buffer. - * @param filename file name - * @param lineno line number - * @return buf - */ -struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno) -{ - char *dst, *t; - const char *src; - size_t tsz; - - if (ctrl.gen_line_dirs) - return buf; - - tsz = strlen("#line \"\"\n") + /* constant parts */ - 2 * strlen (filename) + /* filename with possibly all backslashes escaped */ - (size_t) (1 + ceil (log10 (abs (lineno)))) + /* line number */ - 1; /* NUL */ - t = malloc(tsz); - if (!t) - flexfatal (_("Allocation of buffer for line directive failed")); - for (dst = t + snprintf (t, tsz, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++) - if (*src == '\\') /* escape backslashes */ - *dst++ = '\\'; - *dst++ = '"'; - *dst++ = '\n'; - *dst = '\0'; - buf = buf_strappend (buf, t); - free(t); - return buf; -} - - -/** Append the contents of @a src to @a dest. - * @param @a dest the destination buffer - * @param @a dest the source buffer - * @return @a dest - */ -struct Buf *buf_concat(struct Buf* dest, const struct Buf* src) -{ - buf_append(dest, src->elts, src->nelts); - return dest; -} - - /* Appends n characters in str to buf. */ struct Buf *buf_strnappend (struct Buf *buf, const char *str, int n) { @@ -145,50 +83,6 @@ struct Buf *buf_strappend (struct Buf *buf, const char *str) return buf_strnappend (buf, str, (int) strlen (str)); } -/** Pushes "m4_define( [[def]], [[val]])m4_dnl" to end of buffer. - * @param buf A buffer as a list of strings. - * @param def The m4 symbol to define. - * @param val The definition; may be NULL. - * @return buf - */ -struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val) -{ - const char * fmt = "m4_define( [[%s]], [[[[%s]]]])m4_dnl\n"; - char * str; - size_t strsz; - - val = val?val:""; - strsz = strlen(fmt) + strlen(def) + strlen(val) + 2; - str = malloc(strsz); - if (!str) - flexfatal (_("Allocation of buffer for m4 def failed")); - - snprintf(str, strsz, fmt, def, val); - buf_append(buf, &str, 1); - return buf; -} - -/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer. - * @param buf A buffer as a list of strings. - * @param def The m4 symbol to undefine. - * @return buf - */ -struct Buf *buf_m4_undefine (struct Buf *buf, const char* def) -{ - const char * fmt = "m4_undefine( [[%s]])m4_dnl\n"; - char * str; - size_t strsz; - - strsz = strlen(fmt) + strlen(def) + 2; - str = malloc(strsz); - if (!str) - flexfatal (_("Allocation of buffer for m4 undef failed")); - - snprintf(str, strsz, fmt, def); - buf_append(buf, &str, 1); - return buf; -} - /* create buf with 0 elements, each of size elem_size. */ void buf_init (struct Buf *buf, size_t elem_size) { diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 40a0549..8446b71 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -38,12 +38,12 @@ /* These typedefs are only used for computing footprint sizes, * You need to make sure they match reality in the skeleton file to * get accurate numbers, but they don't otherwise matter. - * FIXME" This shiould go away when tFkex ships only macros. + * FIXME: This shiould go away when tFkex ships only macros. */ typedef char YY_CHAR; struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; -/* Helper fubctions */ +/* Helper functions */ static const char *cpp_get_int16_decl (void) { diff --git a/src/flexdef.h b/src/flexdef.h index 9a4090c..4e44ba5 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -357,7 +357,7 @@ struct ctrl_bundle_t { bool fulltbl; // (-Cf flag) don't compress the DFA state table bool gen_line_dirs; // (no -L flag) generate #line directives trit interactive; // (-I) generate an interactive scanner - bool never_interactive; // always use buffered input, don't check for tty/ + bool never_interactive; // always use buffered input, don't check for tty. bool lex_compat; // (-l), maximize compatibility with AT&T lex bool long_align; // (-Ca flag), favor long-word alignment for speed bool no_input; // Suppress use of imnput() @@ -366,6 +366,7 @@ struct ctrl_bundle_t { char *prefix; // prefix for externally visible names, default "yy" bool reentrant; // if true (-R), generate a reentrant C scanner bool stack_used; // Enable use of start-condition stacks + bool no_section3_escape;// True if the undocumented option --unsafe-no-m4-sect3-escape was passed bool spprdflt; // (-s) suppress the default rule bool useecs; // (-Ce flag) use equivalence classes bool usemecs; // (-Cm flag), use meta-equivalence classes @@ -461,7 +462,6 @@ extern struct flex_backend_t *backend; * dataline - number of contiguous lines of data in current data * statement. Used to generate readable -f output * linenum - current input line number - * skel - compiled-in skeleton array * skel_ind - index into "skel" array, if skelfile is nil * yyin - input file * infilename - name of input file @@ -1100,19 +1100,13 @@ struct Buf { extern void buf_init(struct Buf * buf, size_t elem_size); extern void buf_destroy(struct Buf * buf); extern struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem); -extern struct Buf *buf_concat(struct Buf* dest, const struct Buf* src); extern struct Buf *buf_strappend(struct Buf *, const char *str); extern struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars); extern struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s); -extern struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val); -extern struct Buf *buf_m4_undefine(struct Buf *buf, const char* def); -extern struct Buf *buf_print_strings(struct Buf * buf, FILE* out); -extern struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno); extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */ extern struct Buf yydmap_buf; /* a string buffer to hold yydmap elements */ extern struct Buf top_buf; /* contains %top code. String buffer. */ -extern bool no_section3_escape; /* True if the undocumented option --unsafe-no-m4-sect3-escape was passed */ /* For blocking out code from the header file. */ #define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl") diff --git a/src/main.c b/src/main.c index 02a8d2c..0d612dc 100644 --- a/src/main.c +++ b/src/main.c @@ -257,10 +257,10 @@ int flex_main (int argc, char *argv[]) if (sectnum == 3) { OUT_BEGIN_CODE (); - if (!no_section3_escape) + if (!ctrl.no_section3_escape) fputs("[[", stdout); (void) flexscan (); /* copy remainder of input to output */ - if (!no_section3_escape) + if (!ctrl.no_section3_escape) fputs("]]", stdout); OUT_END_CODE (); } @@ -1172,7 +1172,7 @@ void flexinit (int argc, char **argv) env.trace_hex = true; break; case OPT_NO_SECT3_ESCAPE: - no_section3_escape = true; + ctrl.no_section3_escape = true; break; } /* switch */ } /* while scanopt() */ diff --git a/src/scan.l b/src/scan.l index 099d153..82d57df 100644 --- a/src/scan.l +++ b/src/scan.l @@ -164,9 +164,13 @@ M4QEND "]""]" ^"%x"{NAME}? return XSCDECL; ^"%{".*{NL} START_CODEBLOCK(false); ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} { + char trampoline[512]; brace_start_line = linenum; ++linenum; - buf_linedir( &top_buf, infilename?infilename:"", linenum); + snprintf(trampoline, sizeof(trampoline), + "M4_HOOK_TRACE_LINE_FORMAT(%d, [[%s]])", + linenum, infilename?infilename:""); + buf_strappend(&top_buf, trampoline); brace_depth = 1; yy_push_state(CODEBLOCK_MATCH_BRACE); } @@ -619,7 +623,7 @@ M4QEND "]""]" ^"%%".* { sectnum = 3; - BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3); + BEGIN(ctrl.no_section3_escape ? SECT3_NOESCAPE : SECT3); yyterminate(); /* to stop the parser */ } -- cgit v1.2.1 From 96e004a296edf2a6f6e0b60b3da6e5d8e09428de Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 5 Oct 2020 15:03:03 -0400 Subject: Macroize the yy_meta, gen_yy_trans and start_state_list methods. Also macro-generate yydmap entry for the yymeta table. We're npw about 75% of the way through pushing all C syntax out of the method table. Permutes table order in the generated code. #64 in the retargeting patch series --- src/cpp-flex.skl | 36 ++++++++++++++++++++++++++++++++++++ src/cpp_backend.c | 46 ++-------------------------------------------- src/flexdef.h | 3 --- src/gen.c | 24 ++++++++++++++---------- 4 files changed, 52 insertions(+), 57 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 43b9c20..a66e67d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -893,6 +893,7 @@ static const M4_HOOK_FULLTABLE_TYPE * yy_accept = 0; ]]) m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl +/* Character equivalence-class mapping */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, @@ -903,6 +904,7 @@ static const YY_CHAR * yy_ec = 0; ]]) m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl +/* Rule to line-number mapping */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, @@ -912,6 +914,39 @@ static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; ]]) ]]) +m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl +/* Character meta-equivalence-class mappings */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = + { 0, +M4_HOOK_MECSTABLE_BODY[[]]}; +]], [[ +static const YY_CHAR * yy_meta = 0; +]]) +]]) + +m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl +/* The transition table */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = + { +M4_HOOK_TRANSTABLE_BODY[[]]}; +]], [[ +static const struct yy_trans_info *yy_transition = 0; +]]) +]]) + +m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl +/* Table of pointers to start states. */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = + { +M4_HOOK_STARTTABLE_BODY[[]]}; +]], [[ +static const struct yy_trans_info **yy_start_state_list =0; +]]) +]]) + ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], @@ -1484,6 +1519,7 @@ static struct yytbl_dmap yydmap[] = { m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]]) m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(flex_int32_t)},]]) m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]]) +m4_ifdef([[M4_MODE_USEMECS]], [[ {YYTD_ID_META, (void**)&yy_meta, sizeof(YY_CHAR)},]]) %tables-yydmap generated elements {0,0,0} }; diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 8446b71..6a02f1a 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -35,12 +35,11 @@ #include "flexdef.h" #include "tables.h" -/* These typedefs are only used for computing footprint sizes, +/* This typedef is only used for computing footprint sizes, * You need to make sure they match reality in the skeleton file to * get accurate numbers, but they don't otherwise matter. - * FIXME: This shiould go away when tFkex ships only macros. + * FIXME: This should go away when Flex ships only macros. */ -typedef char YY_CHAR; struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; /* Helper functions */ @@ -67,13 +66,6 @@ static const char *cpp_get_state_decl (void) : "static const yy_state_type * %s = 0;\n"; } -static const char *cpp_get_yy_char_decl (void) -{ - return (gentables) - ? "static const YY_CHAR %s[%d] =\n { 0,\n" - : "static const YY_CHAR * %s = 0;\n"; -} - /* Methods */ static const char *cpp_suffix (void) @@ -122,27 +114,6 @@ static void cpp_mkctbl (size_t sz) || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); } -static size_t cpp_gen_yy_trans(size_t sz) -// Table of verify for transition and offset to next state. (sic) -{ - if (gentables) - out_dec ("static const struct yy_trans_info yy_transition[%d] =\n {\n", sz); - else - outn ("static const struct yy_trans_info *yy_transition = 0;"); - return sz * sizeof(struct yy_trans_info); -} - -static size_t cpp_start_state_list(size_t sz) -// Start initializer for table of pointers to start state -{ - /* Table of pointers to start states. */ - if (gentables) - out_dec ("static const struct yy_trans_info *yy_start_state_list[%d] =\n", sz); - else - outn ("static const struct yy_trans_info **yy_start_state_list =0;"); - return sz * sizeof(struct yy_trans_info *); -} - static void cpp_mkftbl(void) // Make full table { @@ -174,16 +145,6 @@ static size_t cpp_gentabs_accept(size_t sz) return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); } -static size_t cpp_gentabs_yy_meta(size_t sz) -// Generate yy_meta table initializer -{ - out_str_dec (cpp_get_yy_char_decl (), "yy_meta", sz); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", - "YY_CHAR"); - return sz * sizeof(YY_CHAR); -} - static size_t cpp_gentabs_yy_base(size_t sz) // Generate yy_meta base initializer { @@ -267,12 +228,9 @@ struct flex_backend_t cpp_backend = { .skel = cpp_skel, .ntod = cpp_ntod, .mkctbl = cpp_mkctbl, - .gen_yy_trans = cpp_gen_yy_trans, - .start_state_list = cpp_start_state_list, .mkftbl = cpp_mkftbl, .gentabs_acclist = cpp_gentabs_acclist, .gentabs_accept = cpp_gentabs_accept, - .gentabs_yy_meta = cpp_gentabs_yy_meta, .gentabs_yy_base = cpp_gentabs_yy_base, .gentabs_yy_def = cpp_gentabs_yy_def, .gentabs_yy_nxt = cpp_gentabs_yy_nxt, diff --git a/src/flexdef.h b/src/flexdef.h index 4e44ba5..87038ad 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -309,13 +309,10 @@ struct flex_backend_t { // Flex table generation void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) void (*mkctbl)(size_t); // Make full-speed compressed table initializer start - size_t (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic) - size_t (*start_state_list)(size_t); // Start initializer for table of pointers to start states void (*mkftbl)(); // Make full table serialization entry size_t (*genftbl)(size_t); // Make full table initializer start size_t (*gentabs_acclist)(size_t); // Generate accept list initializer start size_t (*gentabs_accept)(size_t); // Generate accept table initializer start - size_t (*gentabs_yy_meta)(size_t); // Generate yy_meta table initializer start size_t (*gentabs_yy_base)(size_t); // Generate yy_base table initializer start size_t (*gentabs_yy_def)(size_t); // Generate yy_def initializer start size_t (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer start diff --git a/src/gen.c b/src/gen.c index 7bd258b..e042a4f 100644 --- a/src/gen.c +++ b/src/gen.c @@ -248,7 +248,8 @@ void genctbl (void) int end_of_buffer_action = num_rules + 1; /* Table of verify for transition and offset to next state. */ - footprint += backend->gen_yy_trans(tblend + numecs + 1); + out_dec ("m4_define([[M4_HOOK_TRANSTABLE_SIZE]], [[%d]])", tblend + numecs + 1); + outn ("m4_define([[M4_HOOK_TRANSTABLE_BODY]], [[m4_dnl"); /* We want the transition to be represented as the offset to the * next state, not the actual state number, which is what it currently @@ -315,18 +316,19 @@ void genctbl (void) transition_struct_out (chk[tblend + 1], nxt[tblend + 1]); transition_struct_out (chk[tblend + 2], nxt[tblend + 2]); - if (gentables) - outn ("M4_HOOK_TABLE_CLOSER"); + outn ("]])"); + footprint += sizeof(struct yy_trans_info) * (tblend + numecs + 1); - footprint += backend->start_state_list(lastsc * 2 + 1); + out_dec ("m4_define([[M4_HOOK_STARTTABLE_SIZE]], [[%d]])", lastsc * 2 + 1); if (gentables) { - outn ("M4_HOOK_TABLE_OPENER"); - + outn ("m4_define([[M4_HOOK_STARTTABLE_BODY]], [[m4_dnl"); for (i = 0; i <= lastsc * 2; ++i) out_dec ("M4_HOOK_STATE_ENTRY_FORMAT(%d)", base[i]); - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn("]])"); + footprint += sizeof(struct yy_trans_info *) * (lastsc * 2 + 1); } if (ctrl.useecs) @@ -681,8 +683,8 @@ void gentabs (void) if (env.trace) fputs (_("\n\nMeta-Equivalence Classes:\n"), stderr); - - footprint += backend->gentabs_yy_meta(numecs + 1); + out_dec ("m4_define([[M4_HOOK_MECSTABLE_SIZE]], [[%d]])", numecs+1); + outn ("m4_define([[M4_HOOK_MECSTABLE_BODY]], [["); for (i = 1; i <= numecs; ++i) { if (env.trace) @@ -693,7 +695,9 @@ void gentabs (void) yymecs_data[i] = ABS (tecbck[i]); } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn ("]])"); + footprint += sizeof(YY_CHAR) * (numecs + 1); if (tablesext) { yytbl_data_compress (yymeta_tbl); if (yytbl_data_fwrite (&tableswr, yymeta_tbl) < 0) -- cgit v1.2.1 From 716cb63ff210f082418c96f726a6d165eae565a5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 6 Oct 2020 01:17:19 -0400 Subject: Tweak the indent style of tables with macroexpanded bodies... ...to have an indent style uniform with the rest of the code, and one that makes it easier noy to miss the trailing table delimiters. Not all tables are generated this way yet. I'm working on it. Is isolated in its own commit so the format change can't confuse a reviewer's eyeballs out of noticing real mutations in the table data. #65 in the retargeting patch series --- src/cpp-flex.skl | 57 ++++++++++++++++++++++++++++++------------------------- src/cpp_backend.c | 6 +++--- src/gen.c | 4 ++-- src/misc.c | 17 +++++++++-------- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index a66e67d..ccea2f5 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -71,11 +71,9 @@ m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" ]]) -m4_define([[M4_HOOK_TABLE_OPENER]], [[ {]]) -m4_define([[M4_HOOK_TABLE_CONTINUE]], [[ }, -]]) -m4_define([[M4_HOOK_TABLE_CLOSER]], [[ }; -]]) +m4_define([[M4_HOOK_TABLE_OPENER]], [[{]]) +m4_define([[M4_HOOK_TABLE_CONTINUE]], [[},]]) +m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], ]]) @@ -874,77 +872,84 @@ int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl /* Table of booleans, true if rule could match eol. */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = - { 0, -M4_HOOK_EOLTABLE_BODY[[]]}; +static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, +M4_HOOK_EOLTABLE_BODY[[]]m4_dnl +}; ]], [[ static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; ]]) + ]]) m4_ifdef( [[M4_MODE_REAL_FULLTBL]],[[m4_dnl m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_FULLTABLE_TYPE yy_accept[M4_HOOK_FULLTABLE_SIZE] = - { 0, -M4_HOOK_FULLTABLE_BODY[[]]}; +static const M4_HOOK_FULLTABLE_TYPE yy_accept[M4_HOOK_FULLTABLE_SIZE] = { 0, +M4_HOOK_FULLTABLE_BODY[[]]m4_dnl +}; ]], [[ static const M4_HOOK_FULLTABLE_TYPE * yy_accept = 0; ]]) + ]]) m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl /* Character equivalence-class mapping */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = - { 0, -M4_HOOK_ECSTABLE_BODY[[]]}; +static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, +M4_HOOK_ECSTABLE_BODY[[]]m4_dnl +}; ]], [[ static const YY_CHAR * yy_ec = 0; ]]) + ]]) m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl /* Rule to line-number mapping */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = - { 0, -M4_HOOK_DEBUGTABLE_BODY[[]]}; +static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, +M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl +}; ]], [[ static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; ]]) + ]]) m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl /* Character meta-equivalence-class mappings */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = - { 0, -M4_HOOK_MECSTABLE_BODY[[]]}; +static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, +M4_HOOK_MECSTABLE_BODY[[]]m4_dnl +}; ]], [[ static const YY_CHAR * yy_meta = 0; ]]) + ]]) m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl /* The transition table */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = - { -M4_HOOK_TRANSTABLE_BODY[[]]}; +static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = { +M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl +}; ]], [[ static const struct yy_trans_info *yy_transition = 0; ]]) + ]]) m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl /* Table of pointers to start states. */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = - { -M4_HOOK_STARTTABLE_BODY[[]]}; +static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { +M4_HOOK_STARTTABLE_BODY[[]]m4_dnl +}; ]], [[ static const struct yy_trans_info **yy_start_state_list =0; ]]) + ]]) ]]) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 6a02f1a..f56488a 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -47,7 +47,7 @@ struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; static const char *cpp_get_int16_decl (void) { return (gentables) - ? "static const flex_int16_t %s[%d] =\n { 0,\n" + ? "static const flex_int16_t %s[%d] = { 0,\n" : "static const flex_int16_t * %s = 0;\n"; } @@ -55,14 +55,14 @@ static const char *cpp_get_int16_decl (void) static const char *cpp_get_int32_decl (void) { return (gentables) - ? "static const flex_int32_t %s[%d] =\n { 0,\n" + ? "static const flex_int32_t %s[%d] = { 0,\n" : "static const flex_int32_t * %s = 0;\n"; } static const char *cpp_get_state_decl (void) { return (gentables) - ? "static const yy_state_type %s[%d] =\n { 0,\n" + ? "static const yy_state_type %s[%d] = { 0,\n" : "static const yy_state_type * %s = 0;\n"; } diff --git a/src/gen.c b/src/gen.c index e042a4f..bfbf2cc 100644 --- a/src/gen.c +++ b/src/gen.c @@ -684,8 +684,8 @@ void gentabs (void) fputs (_("\n\nMeta-Equivalence Classes:\n"), stderr); out_dec ("m4_define([[M4_HOOK_MECSTABLE_SIZE]], [[%d]])", numecs+1); - outn ("m4_define([[M4_HOOK_MECSTABLE_BODY]], [["); - + outn ("m4_define([[M4_HOOK_MECSTABLE_BODY]], [[m4_dnl"); + for (i = 1; i <= numecs; ++i) { if (env.trace) fprintf (stderr, "%d = %d\n", diff --git a/src/misc.c b/src/misc.c index 120a4e7..a5214fa 100644 --- a/src/misc.c +++ b/src/misc.c @@ -217,13 +217,13 @@ char *xstrdup(const char *s) int cclcmp (const void *a, const void *b) { - if (!*(const unsigned char *) a) - return 1; - else - if (!*(const unsigned char *) b) - return - 1; + if (!*(const unsigned char *) a) + return 1; else - return *(const unsigned char *) a - *(const unsigned char *) b; + if (!*(const unsigned char *) b) + return - 1; + else + return *(const unsigned char *) a - *(const unsigned char *) b; } @@ -254,7 +254,8 @@ void dataflush (void) if (!gentables) return; - outc ('\n'); + if (datapos > 0) + outc ('\n'); if (++dataline >= NUMDATALINES) { /* Put out a blank line so that the table is grouped into @@ -432,7 +433,7 @@ void mkdata (int value) if (datapos == 0) /* Indent. */ - out (" "); + out (" "); else outc (','); -- cgit v1.2.1 From fd8748a311ed2f3f849d4b0fb12ea8198c8039ac Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 6 Oct 2020 02:55:43 -0400 Subject: Preparationn for macroizing the last eight methods. This commit collects several minor changes: * Fix a minor type specification bug in a tablesext initializer. * macroize the trans_offset, mkctbl, and mkftbl methods. * Fix a bug in footprint computation. This commit oroduces no code diffs in the generated test code, but the footprint reports change due to the bug fix. #66 in the retargeting patch series --- src/cpp-flex.skl | 4 ++- src/cpp_backend.c | 105 ++++++++++++++++++++---------------------------------- src/flexdef.h | 15 +++++--- src/gen.c | 20 +++++------ src/main.c | 2 +- 5 files changed, 62 insertions(+), 84 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index ccea2f5..efa70ac 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1522,9 +1522,11 @@ struct yytbl_dmap { /** A {0,0,0}-terminated list of structs, forming the map */ static struct yytbl_dmap yydmap[] = { m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]]) -m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(flex_int32_t)},]]) +m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(M4_HOOK_EOLTABLE_TYPE)},]]) m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]]) m4_ifdef([[M4_MODE_USEMECS]], [[ {YYTD_ID_META, (void**)&yy_meta, sizeof(YY_CHAR)},]]) +m4_ifdef([[M4_HOOK_MKCTBL_TYPE]], [[ {YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(M4_HOOK_MKCTBL_TYPE)},]]) +m4_ifdef([[M4_HOOK_MKFTBL_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_MKFTBL_TYPE)},]]) %tables-yydmap generated elements {0,0,0} }; diff --git a/src/cpp_backend.c b/src/cpp_backend.c index f56488a..a71d044 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -83,119 +83,101 @@ static const char *cpp_suffix (void) static void cpp_ntod(size_t num_full_table_rows) // Generate nxt table for ntod { - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); + struct packtype_t *ptype = optimize_pack(0); + out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_TYPE)},\n"); /* Unless -Ca, declare it "short" because it's a real * long-shot that that won't be large enough. */ if (gentables) - out_str_dec - ("static const %s yy_nxt[][%d] =\n {\n", - ctrl.long_align ? "flex_int32_t" : "flex_int16_t", - num_full_table_rows); + out_dec + ("static const M4_HOOK_NXT_TYPE yy_nxt[][%d] =\n {\n", num_full_table_rows); else { out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); - out_str ("static const %s *yy_nxt =0;\n", - ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); + out ("static const M4_HOOK_NXT_TYPE *yy_nxt =0;\n"); } /* It would be no good trying to return an allocation size here, * as it's not known before table generation is finished. */ } -static void cpp_mkctbl (size_t sz) -// Make full-speed compressed transition table -{ - buf_prints (&yydmap_buf, - "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n", - (sz >= INT16_MAX - || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); -} - -static void cpp_mkftbl(void) -// Make full table -{ - // FIXME: why are there two places this is emitted, here and in cpp_gentabs_accept()? - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); -} - static size_t cpp_gentabs_acclist(size_t sz) // Generate accept list initializer { + struct packtype_t *ptype = optimize_pack(0); + out_str ("m4_define([[M4_HOOK_ACCLIST_TYPE]], [[%s]])", ptype->name); out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_acclist", sz); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", - ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); - return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(M4_HOOK_ACCLIST_TYPE)},\n"); + return sz * ptype->width; } static size_t cpp_gentabs_accept(size_t sz) // Generate accept table initializer { + /* FIXME: Could pack tighter by passing the size limit to optimize_pack()_ */ + struct packtype_t *ptype = optimize_pack(0); + out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_accept", sz); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - ctrl.long_align ? "flex_int32_t" : "flex_int16_t"); - return sz * (ctrl.long_align ? sizeof(int32_t) : sizeof(int16_t)); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_ACCEPT_TYPE)},\n"); + return sz * ptype->width; } static size_t cpp_gentabs_yy_base(size_t sz) // Generate yy_meta base initializer { - out_str_dec ((tblend >= INT16_MAX || ctrl.long_align) ? + struct packtype_t *ptype = optimize_pack(sz); + out_str ("m4_define([[M4_HOOK_BASE_TYPE]], [[%s]])", ptype->name); + out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_base", sz); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", - (sz >= INT16_MAX - || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); - return sz * ((sz >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(M4_HOOK_BASE_TYPE)},\n"); + return sz * ptype->width; } static size_t cpp_gentabs_yy_def(size_t sz) // Generate yy_def initializer { + struct packtype_t *ptype = optimize_pack(sz); + out_str ("m4_define([[M4_HOOK_DEF_BASE_TYPE]], [[%s]])", ptype->name); out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_def", sz); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", - (sz >= INT16_MAX - || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); - return sz * ((sz >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(M4_HOOK_DEF_BASE_TYPE)},\n"); + return sz * ptype->width; } static size_t cpp_gentabs_yy_nxt(size_t tblafter) // Generate yy_nxt initializer { - /* Begin generating yy_nxt */ + struct packtype_t *ptype = optimize_pack(tblafter); + out_str ("m4_define([[M4_HOOK_NXT_BASE_TYPE]], [[%s]])", ptype->name); out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_nxt", tblafter); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - (tblafter >= INT16_MAX - || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); - return tblafter * ((tblafter >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_BASE_TYPE)},\n"); + return tblafter * ptype->width; } static size_t cpp_gentabs_yy_chk(size_t tblafter) // Generate yy_chk initializer { + struct packtype_t *ptype = optimize_pack(tblafter); + out_str ("m4_define([[M4_HOOK_IDCHK_BASE_TYPE]], [[%s]])", ptype->name); out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_chk", tblafter); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", - (tblafter >= INT16_MAX - || ctrl.long_align) ? "flex_int32_t" : "flex_int16_t"); - return tblafter * ((tblafter >= INT16_MAX || ctrl.long_align) ? sizeof(int32_t) : sizeof(int16_t)); + buf_strappend (&yydmap_buf, + "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_IDCHK_BASE_TYPE)},\n"); + return tblafter * ptype->width; } static size_t cpp_nultrans(int fullspd, size_t afterdfa) @@ -211,12 +193,6 @@ static size_t cpp_nultrans(int fullspd, size_t afterdfa) return afterdfa * (fullspd ? sizeof(struct yy_trans_info *) : sizeof(int32_t)); } -static const char *cpp_trans_offset_type(int total_table_size) -{ - return (total_table_size >= INT16_MAX || ctrl.long_align) ? - "flex_int32_t" : "flex_int16_t"; -} - const char *cpp_skel[] = { #include "cpp-skel.h" 0, @@ -227,8 +203,6 @@ struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, .ntod = cpp_ntod, - .mkctbl = cpp_mkctbl, - .mkftbl = cpp_mkftbl, .gentabs_acclist = cpp_gentabs_acclist, .gentabs_accept = cpp_gentabs_accept, .gentabs_yy_base = cpp_gentabs_yy_base, @@ -236,6 +210,5 @@ struct flex_backend_t cpp_backend = { .gentabs_yy_nxt = cpp_gentabs_yy_nxt, .gentabs_yy_chk = cpp_gentabs_yy_chk, .nultrans = cpp_nultrans, - .trans_offset_type = cpp_trans_offset_type, .c_like = true, }; diff --git a/src/flexdef.h b/src/flexdef.h index 87038ad..b913cfe 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,10 +306,7 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code const char **skel; - // Flex table generation void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) - void (*mkctbl)(size_t); // Make full-speed compressed table initializer start - void (*mkftbl)(); // Make full table serialization entry size_t (*genftbl)(size_t); // Make full table initializer start size_t (*gentabs_acclist)(size_t); // Generate accept list initializer start size_t (*gentabs_accept)(size_t); // Generate accept table initializer start @@ -318,7 +315,6 @@ struct flex_backend_t { size_t (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer start size_t (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer start size_t (*nultrans)(int, size_t); // Generate nulltrans initializer - const char *(*trans_offset_type)(int); // Compute an efficient type for transition tables bool c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; @@ -427,6 +423,12 @@ struct env_bundle_t { bool use_stdout; // the -t flag }; +/* Name and byte-width information on a type for code-generation purposes. */ +struct packtype_t { + char *name; + size_t width; +}; + extern struct ctrl_bundle_t ctrl; extern struct env_bundle_t env; @@ -825,8 +827,11 @@ extern void indent_put2s(const char *, const char *); /* Write out a string + newline at the current indentation level. */ extern void indent_puts(const char *); -extern void make_tables(void); /* generate transition tables */ +/* generate transition tables */ +extern void make_tables(void); +/* Select a type for optimal packing */ +struct packtype_t *optimize_pack(size_t); /* from file main.c */ diff --git a/src/gen.c b/src/gen.c index bfbf2cc..9757de2 100644 --- a/src/gen.c +++ b/src/gen.c @@ -45,13 +45,7 @@ struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; void genecs(void); -struct packtype_t { - char *name; - size_t width; -}; - - -static struct packtype_t *optimize_pack(size_t sz) +struct packtype_t *optimize_pack(size_t sz) { /* FIXME: There's a 32-bit assumption lurking here */ static struct packtype_t out; @@ -59,8 +53,8 @@ static struct packtype_t *optimize_pack(size_t sz) out.name = ctrl.long_align ? "flex_int32_t" : "flex_int16_t"; out.width = ctrl.long_align ? 32 : 16; } else { - out.name = (ctrl.long_align || sz <= INT16_MAX) ? "flex_int32_t" : "flex_ini16_t"; - out.width = (ctrl.long_align || sz <= INT16_MAX) ? 32 : 16; + out.name = (ctrl.long_align || sz >= INT16_MAX) ? "flex_int32_t" : "flex_int16_t"; + out.width = (ctrl.long_align || sz >= INT16_MAX) ? 32 : 16; } return &out; } @@ -126,7 +120,8 @@ static struct yytbl_data *mkctbl (void) flex_int32_t *tdata = 0, curr = 0; int end_of_buffer_action = num_rules + 1; - backend->mkctbl(tblend + numecs + 1); + struct packtype_t *ptype = optimize_pack(tblend + numecs + 1); + out_str ("m4_define([[M4_HOOK_MKCTBL_TYPE]], [[%s]])", ptype->name); tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (tbl, YYTD_ID_TRANSITION); @@ -431,7 +426,6 @@ struct yytbl_data *mkftbl (void) i, anum); } - backend->mkftbl(); return tbl; } @@ -442,6 +436,7 @@ void genftbl (void) { int i; int end_of_buffer_action = num_rules + 1; + /* FIXME: Could make this smaller by passing the table size to pack_optimize(). */ struct packtype_t *ptype = optimize_pack(0); dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; @@ -906,6 +901,8 @@ void make_tables (void) if (tablesext) { struct yytbl_data *tbl; + struct packtype_t *ptype = optimize_pack(0); + out_str ("m4_define([[M4_HOOK_MKFTBL_TYPE]], [[%s]])", ptype->name); tbl = mkftbl (); yytbl_data_compress (tbl); if (yytbl_data_fwrite (&tableswr, tbl) < 0) @@ -1014,6 +1011,7 @@ void make_tables (void) if (ctrl.ddebug) { /* Spit out table mapping rules to line numbers. */ /* Policy choice: we don't include this space * in the table metering. + * FIXME: Could make this smaller by passing the table size to optimize_pack(). */ struct packtype_t *ptype = optimize_pack(0); diff --git a/src/main.c b/src/main.c index 0d612dc..fdb718a 100644 --- a/src/main.c +++ b/src/main.c @@ -207,7 +207,7 @@ int flex_main (int argc, char *argv[]) /* Need to define the transet type as a size large * enough to hold the biggest offset. */ - out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", backend->trans_offset_type(tblend + numecs + 1), ""); + out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", optimize_pack(tblend + numecs + 1)->name, ""); comment("END of Flex-generated definitions\n"); skelout (true); /* %% [2.0] - tables get dumped here */ -- cgit v1.2.1 From 34771445d5891e9d4adc1146c9e55858793ed770 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 6 Oct 2020 20:48:28 -0400 Subject: Inline all yydmap entries, get rid of %tables-yydmap. What it used to do is now handled entirely by macro conditionals. Besides being a good complexoty reduction in itself, this is one of the last steps in turning C backend methods into macro deliveries. Order of the yydmap table is perturbed. No other non-whitespace diffs and no logic changes, #67 in the retargeting patch series --- src/buf.c | 1 - src/cpp-flex.skl | 20 +++++++++++++------- src/cpp_backend.c | 41 ++++++++++------------------------------- src/flexdef.h | 1 - src/gen.c | 3 ++- src/main.c | 1 - src/misc.c | 5 ----- 7 files changed, 25 insertions(+), 47 deletions(-) diff --git a/src/buf.c b/src/buf.c index 6f049b4..eee1d3b 100644 --- a/src/buf.c +++ b/src/buf.c @@ -47,7 +47,6 @@ /* global buffers. */ struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */ -struct Buf yydmap_buf; /**< string buffer to hold yydmap elements */ struct Buf top_buf; /**< contains %top code. String buffer. */ /* Append a "%s" formatted string to a string buffer */ diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index efa70ac..6e23a0d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1521,13 +1521,19 @@ struct yytbl_dmap { /** A {0,0,0}-terminated list of structs, forming the map */ static struct yytbl_dmap yydmap[] = { -m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]]) -m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(M4_HOOK_EOLTABLE_TYPE)},]]) -m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]]) -m4_ifdef([[M4_MODE_USEMECS]], [[ {YYTD_ID_META, (void**)&yy_meta, sizeof(YY_CHAR)},]]) -m4_ifdef([[M4_HOOK_MKCTBL_TYPE]], [[ {YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(M4_HOOK_MKCTBL_TYPE)},]]) -m4_ifdef([[M4_HOOK_MKFTBL_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_MKFTBL_TYPE)},]]) -%tables-yydmap generated elements +m4_ifdef([[M4_HOOK_NXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(M4_HOOK_EOLTABLE_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_USEMECS]], [[ {YYTD_ID_META, (void**)&yy_meta, sizeof(YY_CHAR)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_ACCLIST_TYPE]], [[ {YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(M4_HOOK_ACCLIST_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_MKCTBL_TYPE]], [[ {YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(M4_HOOK_MKCTBL_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_MKFTBL_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_MKFTBL_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_ACCEPT_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_ACCEPT_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_BASE_TYPE]], [[ {YYTD_ID_BASE, (void**)&yy_base, sizeof(M4_HOOK_BASE_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_DEF_TYPE]], [[ {YYTD_ID_DEF, (void**)&yy_def, sizeof(M4_HOOK_DEF_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_IDCHK_TYPE]], [[ {YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_IDCHK_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_NULTRANS_TYPE]], [[ {YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(M4_HOOK_NULTRANS_TYPE)},]],[[m4_dnl]]) {0,0,0} }; diff --git a/src/cpp_backend.c b/src/cpp_backend.c index a71d044..d12a4da 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -35,13 +35,6 @@ #include "flexdef.h" #include "tables.h" -/* This typedef is only used for computing footprint sizes, - * You need to make sure they match reality in the skeleton file to - * get accurate numbers, but they don't otherwise matter. - * FIXME: This should go away when Flex ships only macros. - */ -struct yy_trans_info {int32_t yy_verify; int32_t yy_nxt;}; - /* Helper functions */ static const char *cpp_get_int16_decl (void) @@ -84,9 +77,8 @@ static void cpp_ntod(size_t num_full_table_rows) // Generate nxt table for ntod { struct packtype_t *ptype = optimize_pack(0); + /* Note: Used when ctrl.fulltbl is on. Alternately defined elsewhere */ out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_TYPE)},\n"); /* Unless -Ca, declare it "short" because it's a real * long-shot that that won't be large enough. @@ -110,21 +102,18 @@ static size_t cpp_gentabs_acclist(size_t sz) out_str ("m4_define([[M4_HOOK_ACCLIST_TYPE]], [[%s]])", ptype->name); out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_acclist", sz); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(M4_HOOK_ACCLIST_TYPE)},\n"); return sz * ptype->width; } static size_t cpp_gentabs_accept(size_t sz) // Generate accept table initializer { - /* FIXME: Could pack tighter by passing the size limit to optimize_pack()_ */ + /* FIXME: Could pack tighter by passing the size limit to optimize_pack() */ + /* But note that this is alternately defined if ctrl.fulltbl */ struct packtype_t *ptype = optimize_pack(0); out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_accept", sz); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_ACCEPT_TYPE)},\n"); return sz * ptype->width; } @@ -136,8 +125,6 @@ static size_t cpp_gentabs_yy_base(size_t sz) out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_base", sz); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(M4_HOOK_BASE_TYPE)},\n"); return sz * ptype->width; } @@ -145,12 +132,10 @@ static size_t cpp_gentabs_yy_def(size_t sz) // Generate yy_def initializer { struct packtype_t *ptype = optimize_pack(sz); - out_str ("m4_define([[M4_HOOK_DEF_BASE_TYPE]], [[%s]])", ptype->name); + out_str ("m4_define([[M4_HOOK_DEF_TYPE]], [[%s]])", ptype->name); out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_def", sz); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(M4_HOOK_DEF_BASE_TYPE)},\n"); return sz * ptype->width; } @@ -158,12 +143,13 @@ static size_t cpp_gentabs_yy_nxt(size_t tblafter) // Generate yy_nxt initializer { struct packtype_t *ptype = optimize_pack(tblafter); - out_str ("m4_define([[M4_HOOK_NXT_BASE_TYPE]], [[%s]])", ptype->name); + /* Note: Osed wheen !ctrl.fulltbl && !ctrl.fullspd). + * (Alternately defined wjen ctrl.fullspd + */ + out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_nxt", tblafter); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_BASE_TYPE)},\n"); return tblafter * ptype->width; } @@ -171,25 +157,18 @@ static size_t cpp_gentabs_yy_chk(size_t tblafter) // Generate yy_chk initializer { struct packtype_t *ptype = optimize_pack(tblafter); - out_str ("m4_define([[M4_HOOK_IDCHK_BASE_TYPE]], [[%s]])", ptype->name); + out_str ("m4_define([[M4_HOOK_IDCHK_TYPE]], [[%s]])", ptype->name); out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_chk", tblafter); - buf_strappend (&yydmap_buf, - "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_IDCHK_BASE_TYPE)},\n"); return tblafter * ptype->width; } static size_t cpp_nultrans(int fullspd, size_t afterdfa) // Generate nulltrans initializer { - // Making this a backend method may be overzealous. - // How many other languages have to special-case NUL - // because it's a string terminator? + out_str ("m4_define([[M4_HOOK_NULTRANS_TYPE]], [[%s]])", (fullspd) ? "struct yy_trans_info*" : "flex_int32_t"); out_str_dec (cpp_get_state_decl (), "yy_NUL_trans", afterdfa); - buf_prints (&yydmap_buf, - "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", - (fullspd) ? "struct yy_trans_info*" : "flex_int32_t"); return afterdfa * (fullspd ? sizeof(struct yy_trans_info *) : sizeof(int32_t)); } diff --git a/src/flexdef.h b/src/flexdef.h index b913cfe..5fbb887 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -1107,7 +1107,6 @@ extern struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars); extern struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s); extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */ -extern struct Buf yydmap_buf; /* a string buffer to hold yydmap elements */ extern struct Buf top_buf; /* contains %top code. String buffer. */ /* For blocking out code from the header file. */ diff --git a/src/gen.c b/src/gen.c index 9757de2..550967b 100644 --- a/src/gen.c +++ b/src/gen.c @@ -902,7 +902,8 @@ void make_tables (void) struct yytbl_data *tbl; struct packtype_t *ptype = optimize_pack(0); - out_str ("m4_define([[M4_HOOK_MKFTBL_TYPE]], [[%s]])", ptype->name); + // Alternately defined if + out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); tbl = mkftbl (); yytbl_data_compress (tbl); if (yytbl_data_fwrite (&tableswr, tbl) < 0) diff --git a/src/main.c b/src/main.c index fdb718a..970a93d 100644 --- a/src/main.c +++ b/src/main.c @@ -746,7 +746,6 @@ void flexinit (int argc, char **argv) /* Initialize any buffers. */ buf_init (&userdef_buf, sizeof (char)); /* one long string */ - buf_init (&yydmap_buf, sizeof (char)); /* one long string */ buf_init (&top_buf, sizeof (char)); /* one long string */ sf_init (); diff --git a/src/misc.c b/src/misc.c index a5214fa..7db330d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -34,7 +34,6 @@ #include "tables.h" #define CMD_IF_TABLES_SER "%if-tables-serialization" -#define CMD_TABLES_YYDMAP "%tables-yydmap" #define CMD_IF_CPP_ONLY "%if-c++-only" #define CMD_IF_C_ONLY "%if-c-only" #define CMD_IF_C_OR_CPP "%if-c-or-c++" @@ -763,10 +762,6 @@ void skelout (bool announce) else if (cmd_match (CMD_IF_TABLES_SER)) { do_copy = do_copy && tablesext; } - else if (cmd_match (CMD_TABLES_YYDMAP)) { - if (tablesext && yydmap_buf.elts) - outn ((char *) (yydmap_buf.elts)); - } else if (cmd_match (CMD_IF_CPP_ONLY)) { /* only for C++ */ sko_push(do_copy); -- cgit v1.2.1 From de769336588d2537f0d1b5c36ccc3c4fe24d1107 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Oct 2020 06:39:15 -0400 Subject: Macroize all the remaining code-generation methods. Produces a tediously large diff in generated test code that is all table moving around. This is due to them being shipped as macros and being substitured in a fixed order determined by the calls in the skell file, rather than veing generated as the functrions originally emitting the tables are called. #68 in the retargeting patch series --- src/cpp-flex.skl | 114 +++++++++++++++++++++++++++++++++++++++------- src/cpp_backend.c | 133 ------------------------------------------------------ src/dfa.c | 14 ++++-- src/flexdef.h | 9 ---- src/gen.c | 110 ++++++++++++++++++++++++++++++++------------ 5 files changed, 188 insertions(+), 192 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 6e23a0d..f1a5854 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -869,6 +869,19 @@ int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); %endif %% [2.0] data tables for the DFA are inserted here +m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = + { +M4_HOOK_NXT_BODY +]], [[ +#undef YY_NXT_LOLEN +#define YY_NXT_LOLEN ([[]]M4_HOOK_NXT_ROWS[[]]) +static const M4_HOOK_NXT_TYPE *yy_nxt =0; +]]) + +]]) + m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl /* Table of booleans, true if rule could match eol. */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl @@ -881,13 +894,13 @@ static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; ]]) -m4_ifdef( [[M4_MODE_REAL_FULLTBL]],[[m4_dnl +m4_ifdef( [[M4_HOOK_NEED_ACCEPT]],[[m4_dnl m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_FULLTABLE_TYPE yy_accept[M4_HOOK_FULLTABLE_SIZE] = { 0, -M4_HOOK_FULLTABLE_BODY[[]]m4_dnl +static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, +M4_HOOK_ACCEPT_BODY[[]]m4_dnl }; ]], [[ -static const M4_HOOK_FULLTABLE_TYPE * yy_accept = 0; +static const M4_HOOK_ACCEPT_TYPE * yy_accept = 0; ]]) ]]) @@ -904,18 +917,6 @@ static const YY_CHAR * yy_ec = 0; ]]) -m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl -/* Rule to line-number mapping */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, -M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl -}; -]], [[ -static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; -]]) - -]]) - m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl /* Character meta-equivalence-class mappings */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl @@ -952,6 +953,84 @@ static const struct yy_trans_info **yy_start_state_list =0; ]]) +m4_ifdef( [[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, +M4_HOOK_ACCLIST_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_ACCLIST_TYPE * yy_acclist = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_BASE_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, +M4_HOOK_BASE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_BASE_TYPE * yy_base = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_DEF_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, +M4_HOOK_DEF_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_DEF_TYPE * yy_def = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_YYNXT_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, +M4_HOOK_YYNXT_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_YYNXT_TYPE * yy_nxt = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_CHK_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, +M4_HOOK_CHK_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_CHK_TYPE * yy_chk = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const yy_state_type yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, +M4_HOOK_NULTRANS_BODY[[]]m4_dnl +}; +]], [[ +static const yy_state_type * yy_NUL_trans = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl +/* Rule to line-number mapping */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, +M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; +]]) + +]]) + ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], @@ -1522,6 +1601,7 @@ struct yytbl_dmap { /** A {0,0,0}-terminated list of structs, forming the map */ static struct yytbl_dmap yydmap[] = { m4_ifdef([[M4_HOOK_NXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_YYNXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_YYNXT_TYPE)},]],[[m4_dnl]]) m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]],[[m4_dnl]]) m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(M4_HOOK_EOLTABLE_TYPE)},]],[[m4_dnl]]) m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]],[[m4_dnl]]) @@ -1532,7 +1612,7 @@ m4_ifdef([[M4_HOOK_MKFTBL_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof m4_ifdef([[M4_HOOK_ACCEPT_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_ACCEPT_TYPE)},]],[[m4_dnl]]) m4_ifdef([[M4_HOOK_BASE_TYPE]], [[ {YYTD_ID_BASE, (void**)&yy_base, sizeof(M4_HOOK_BASE_TYPE)},]],[[m4_dnl]]) m4_ifdef([[M4_HOOK_DEF_TYPE]], [[ {YYTD_ID_DEF, (void**)&yy_def, sizeof(M4_HOOK_DEF_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_IDCHK_TYPE]], [[ {YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_IDCHK_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_CHK_TYPE]], [[ {YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_CHK_TYPE)},]],[[m4_dnl]]) m4_ifdef([[M4_HOOK_NULTRANS_TYPE]], [[ {YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(M4_HOOK_NULTRANS_TYPE)},]],[[m4_dnl]]) {0,0,0} }; diff --git a/src/cpp_backend.c b/src/cpp_backend.c index d12a4da..5094710 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -35,32 +35,6 @@ #include "flexdef.h" #include "tables.h" -/* Helper functions */ - -static const char *cpp_get_int16_decl (void) -{ - return (gentables) - ? "static const flex_int16_t %s[%d] = { 0,\n" - : "static const flex_int16_t * %s = 0;\n"; -} - - -static const char *cpp_get_int32_decl (void) -{ - return (gentables) - ? "static const flex_int32_t %s[%d] = { 0,\n" - : "static const flex_int32_t * %s = 0;\n"; -} - -static const char *cpp_get_state_decl (void) -{ - return (gentables) - ? "static const yy_state_type %s[%d] = { 0,\n" - : "static const yy_state_type * %s = 0;\n"; -} - -/* Methods */ - static const char *cpp_suffix (void) { char *suffix; @@ -73,105 +47,6 @@ static const char *cpp_suffix (void) return suffix; } -static void cpp_ntod(size_t num_full_table_rows) -// Generate nxt table for ntod -{ - struct packtype_t *ptype = optimize_pack(0); - /* Note: Used when ctrl.fulltbl is on. Alternately defined elsewhere */ - out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); - - /* Unless -Ca, declare it "short" because it's a real - * long-shot that that won't be large enough. - */ - if (gentables) - out_dec - ("static const M4_HOOK_NXT_TYPE yy_nxt[][%d] =\n {\n", num_full_table_rows); - else { - out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); - out ("static const M4_HOOK_NXT_TYPE *yy_nxt =0;\n"); - } - /* It would be no good trying to return an allocation size here, - * as it's not known before table generation is finished. - */ -} - -static size_t cpp_gentabs_acclist(size_t sz) -// Generate accept list initializer -{ - struct packtype_t *ptype = optimize_pack(0); - out_str ("m4_define([[M4_HOOK_ACCLIST_TYPE]], [[%s]])", ptype->name); - out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : - cpp_get_int16_decl (), "yy_acclist", sz); - return sz * ptype->width; -} - -static size_t cpp_gentabs_accept(size_t sz) -// Generate accept table initializer -{ - /* FIXME: Could pack tighter by passing the size limit to optimize_pack() */ - /* But note that this is alternately defined if ctrl.fulltbl */ - struct packtype_t *ptype = optimize_pack(0); - out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); - out_str_dec (ctrl.long_align ? cpp_get_int32_decl () : cpp_get_int16_decl (), - "yy_accept", sz); - return sz * ptype->width; -} - -static size_t cpp_gentabs_yy_base(size_t sz) -// Generate yy_meta base initializer -{ - struct packtype_t *ptype = optimize_pack(sz); - out_str ("m4_define([[M4_HOOK_BASE_TYPE]], [[%s]])", ptype->name); - out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? - cpp_get_int32_decl () : cpp_get_int16_decl (), - "yy_base", sz); - return sz * ptype->width; -} - -static size_t cpp_gentabs_yy_def(size_t sz) -// Generate yy_def initializer -{ - struct packtype_t *ptype = optimize_pack(sz); - out_str ("m4_define([[M4_HOOK_DEF_TYPE]], [[%s]])", ptype->name); - out_str_dec ((sz >= INT16_MAX || ctrl.long_align) ? - cpp_get_int32_decl () : cpp_get_int16_decl (), - "yy_def", sz); - return sz * ptype->width; -} - -static size_t cpp_gentabs_yy_nxt(size_t tblafter) -// Generate yy_nxt initializer -{ - struct packtype_t *ptype = optimize_pack(tblafter); - /* Note: Osed wheen !ctrl.fulltbl && !ctrl.fullspd). - * (Alternately defined wjen ctrl.fullspd - */ - out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); - out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? - cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_nxt", - tblafter); - return tblafter * ptype->width; -} - -static size_t cpp_gentabs_yy_chk(size_t tblafter) -// Generate yy_chk initializer -{ - struct packtype_t *ptype = optimize_pack(tblafter); - out_str ("m4_define([[M4_HOOK_IDCHK_TYPE]], [[%s]])", ptype->name); - out_str_dec ((tblafter >= INT16_MAX || ctrl.long_align) ? - cpp_get_int32_decl () : cpp_get_int16_decl (), "yy_chk", - tblafter); - return tblafter * ptype->width; -} - -static size_t cpp_nultrans(int fullspd, size_t afterdfa) -// Generate nulltrans initializer -{ - out_str ("m4_define([[M4_HOOK_NULTRANS_TYPE]], [[%s]])", (fullspd) ? "struct yy_trans_info*" : "flex_int32_t"); - out_str_dec (cpp_get_state_decl (), "yy_NUL_trans", afterdfa); - return afterdfa * (fullspd ? sizeof(struct yy_trans_info *) : sizeof(int32_t)); -} - const char *cpp_skel[] = { #include "cpp-skel.h" 0, @@ -181,13 +56,5 @@ const char *cpp_skel[] = { struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, - .ntod = cpp_ntod, - .gentabs_acclist = cpp_gentabs_acclist, - .gentabs_accept = cpp_gentabs_accept, - .gentabs_yy_base = cpp_gentabs_yy_base, - .gentabs_yy_def = cpp_gentabs_yy_def, - .gentabs_yy_nxt = cpp_gentabs_yy_nxt, - .gentabs_yy_chk = cpp_gentabs_yy_chk, - .nultrans = cpp_nultrans, .c_like = true, }; diff --git a/src/dfa.c b/src/dfa.c index c24bc43..06bbd63 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -515,12 +515,16 @@ size_t ntod (void) yynxt_tbl->td_hilen = 1; yynxt_tbl->td_lolen = (flex_uint32_t) num_full_table_rows; yynxt_tbl->td_data = yynxt_data = - calloc(yynxt_tbl->td_lolen * - yynxt_tbl->td_hilen, - sizeof (flex_int32_t)); + calloc(yynxt_tbl->td_lolen * + yynxt_tbl->td_hilen, + sizeof (flex_int32_t)); yynxt_curr = 0; - backend->ntod(num_full_table_rows); + struct packtype_t *ptype = optimize_pack(0); + /* Note: Used when ctrl.fulltbl is on. Alternately defined elsewhere */ + out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_NXT_ROWS]], [[%d]])", num_full_table_rows); + outn ("m4_define([[M4_HOOK_NXT_BODY]], [[m4_dnl"); if (gentables) outn ("M4_HOOK_TABLE_OPENER"); @@ -745,6 +749,7 @@ size_t ntod (void) if (ctrl.fulltbl) { dataend ("M4_HOOK_TABLE_CLOSER"); + outn("/* body */]])"); if (tablesext) { yytbl_data_compress (yynxt_tbl); if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0) @@ -772,6 +777,7 @@ size_t ntod (void) mkdeftbl (); } + free(accset); free(nset); diff --git a/src/flexdef.h b/src/flexdef.h index 5fbb887..0377608 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,15 +306,6 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code const char **skel; - void (*ntod)(size_t); // Generate nxt table initializer start (fulltbl mode) - size_t (*genftbl)(size_t); // Make full table initializer start - size_t (*gentabs_acclist)(size_t); // Generate accept list initializer start - size_t (*gentabs_accept)(size_t); // Generate accept table initializer start - size_t (*gentabs_yy_base)(size_t); // Generate yy_base table initializer start - size_t (*gentabs_yy_def)(size_t); // Generate yy_def initializer start - size_t (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer start - size_t (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer start - size_t (*nultrans)(int, size_t); // Generate nulltrans initializer bool c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; diff --git a/src/gen.c b/src/gen.c index 550967b..ce3eb88 100644 --- a/src/gen.c +++ b/src/gen.c @@ -91,7 +91,6 @@ static void geneoltbl (void) outn ("m4_define([[M4_HOOK_EOLTABLE_TYPE]], [[flex_int32_t]])"); out_dec ("m4_define([[M4_HOOK_EOLTABLE_SIZE]], [[%d]])", num_rules + 1); outn ("m4_define([[M4_HOOK_EOLTABLE_BODY]], [[m4_dnl"); - footprint += sizeof(int32_t) * (num_rules + 1); if (gentables) { for (i = 1; i <= num_rules; i++) { @@ -101,6 +100,7 @@ static void geneoltbl (void) out ("\n "); } } + footprint += sizeof(int32_t) * (num_rules + 1); outn ("]])"); outn ("]])"); } @@ -441,9 +441,10 @@ void genftbl (void) dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; - out_str ("m4_define([[M4_HOOK_FULLTABLE_TYPE]], [[%s]])", ptype->name); - out_dec ("m4_define([[M4_HOOK_FULLTABLE_SIZE]], [[%d]])", lastdfa + 1); - outn ("m4_define([[M4_HOOK_FULLTABLE_BODY]], [[m4_dnl"); + outn ("m4_define([[M4_HOOK_NEED_ACCEPT]], 1)"); + out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_ACCEPT_SIZE]], [[%d]])", lastdfa + 1); + outn ("m4_define([[M4_HOOK_ACCEPT_BODY]], [[m4_dnl"); for (i = 1; i <= lastdfa; ++i) { int anum = dfaacc[i].dfaacc_state; @@ -471,13 +472,14 @@ void genftbl (void) void gentabs (void) { - int i, j, k, *accset, nacc, *acc_array, total_states; + int sz, i, j, k, *accset, nacc, *acc_array, total_states; int end_of_buffer_action = num_rules + 1; struct yytbl_data *yyacc_tbl = 0, *yymeta_tbl = 0, *yybase_tbl = 0, *yydef_tbl = 0, *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl=0; flex_int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0, *yynxt_data = 0, *yychk_data = 0, *yyacclist_data=0; flex_int32_t yybase_curr = 0, yyacclist_curr=0,yyacc_curr=0; + struct packtype_t *ptype; acc_array = allocate_integer_array (current_max_dfas); nummt = 0; @@ -505,8 +507,13 @@ void gentabs (void) dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list; - footprint += backend->gentabs_acclist(MAX (numas, 1) + 1); - + sz = MAX (numas, 1) + 1; + /* FIXME: could improve memory usage by passing sz in */ + ptype = optimize_pack(0); + out_str ("m4_define([[M4_HOOK_ACCLIST_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_ACCLIST_SIZE]], [[%d]])", sz); + outn ("m4_define([[M4_HOOK_ACCLIST_BODY]], [[m4_dnl"); + yyacclist_tbl = calloc(1,sizeof(struct yytbl_data)); yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST); yyacclist_tbl->td_lolen = (flex_uint32_t) (MAX(numas,1) + 1); @@ -568,7 +575,9 @@ void gentabs (void) /* add accepting number for the "jam" state */ acc_array[i] = j; - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn("]])"); + footprint += sz * ptype->width; if (tablesext) { yytbl_data_compress (yyacclist_tbl); if (yytbl_data_fwrite (&tableswr, yyacclist_tbl) < 0) @@ -599,7 +608,7 @@ void gentabs (void) /* "lastdfa + 2" is the size of "yy_accept"; includes room for C arrays * beginning at 0 and for "jam" state. */ - k = lastdfa + 2; + sz = lastdfa + 2; if (reject) /* We put a "cap" on the table associating lists of accepting @@ -607,13 +616,19 @@ void gentabs (void) * where the end of an accepting list is by looking at where * the list for the next state starts. */ - ++k; + ++sz; + + /* FIXME: Could pack tighter by passing the size limit to optimize_pack() */ + /* But note that this table is alternately defined if ctrl.fulltbl */ + ptype = optimize_pack(0); + outn ("m4_define([[M4_HOOK_NEED_ACCEPT]], 1)"); + out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_ACCEPT_SIZE]], [[%d]])", sz); + outn ("m4_define([[M4_HOOK_ACCEPT_BODY]], [[m4_dnl"); - footprint += backend->gentabs_accept(k); - yyacc_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT); - yyacc_tbl->td_lolen = (flex_uint32_t) k; + yyacc_tbl->td_lolen = (flex_uint32_t) sz; yyacc_tbl->td_data = yyacc_data = calloc(yyacc_tbl->td_lolen, sizeof (flex_int32_t)); yyacc_curr=1; @@ -637,7 +652,10 @@ void gentabs (void) yyacc_data[yyacc_curr++] = acc_array[i]; } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn ("]])"); + footprint += sz * ptype->width; + if (tablesext) { yytbl_data_compress (yyacc_tbl); if (yytbl_data_fwrite (&tableswr, yyacc_tbl) < 0) @@ -706,7 +724,12 @@ void gentabs (void) total_states = lastdfa + numtemps; /* Begin generating yy_base */ - footprint += backend->gentabs_yy_base(total_states + 1); + sz = total_states + 1; + ptype = optimize_pack(sz); + out_str ("m4_define([[M4_HOOK_BASE_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_BASE_SIZE]], [[%d]])", sz); + outn ("m4_define([[M4_HOOK_BASE_BODY]], [[m4_dnl"); + yybase_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yybase_tbl, YYTD_ID_BASE); yybase_tbl->td_lolen = (flex_uint32_t) (total_states + 1); @@ -744,7 +767,10 @@ void gentabs (void) def[i] = jamstate; } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn ("]])"); + footprint += sz * ptype->width; + if (tablesext) { yytbl_data_compress (yybase_tbl); if (yytbl_data_fwrite (&tableswr, yybase_tbl) < 0) @@ -756,7 +782,10 @@ void gentabs (void) /* Begin generating yy_def */ - footprint += backend->gentabs_yy_def(total_states +1); + ptype = optimize_pack(total_states + 1); + out_str ("m4_define([[M4_HOOK_DEF_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_DEF_SIZE]], [[%d]])", total_states + 1); + outn ("m4_define([[M4_HOOK_DEF_BODY]], [[m4_dnl"); yydef_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yydef_tbl, YYTD_ID_DEF); @@ -769,7 +798,10 @@ void gentabs (void) yydef_data[i] = def[i]; } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn ("]])"); + footprint += (total_states + 1) * ptype->width; + if (tablesext) { yytbl_data_compress (yydef_tbl); if (yytbl_data_fwrite (&tableswr, yydef_tbl) < 0) @@ -780,7 +812,13 @@ void gentabs (void) /* End generating yy_def */ - footprint += backend->gentabs_yy_nxt(tblend + 1); + ptype = optimize_pack(tblend + 1); + /* Note: Osed wheen !ctrl.fulltbl && !ctrl.fullspd). + * (Alternately defined wjen ctrl.fullspd + */ + out_str ("m4_define([[M4_HOOK_YYNXT_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_YYNXT_SIZE]], [[%d]])", tblend + 1); + outn ("m4_define([[M4_HOOK_YYNXT_BODY]], [[m4_dnl"); yynxt_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); @@ -799,7 +837,10 @@ void gentabs (void) yynxt_data[i] = nxt[i]; } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn("]])"); + footprint += ptype->width * (tblend + 1); + if (tablesext) { yytbl_data_compress (yynxt_tbl); if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0) @@ -810,7 +851,10 @@ void gentabs (void) /* End generating yy_nxt */ /* Begin generating yy_chk */ - footprint += backend->gentabs_yy_chk(tblend + 1); + ptype = optimize_pack(tblend + 1); + out_str ("m4_define([[M4_HOOK_CHK_TYPE]], [[%s]])", ptype->name); + out_dec ("m4_define([[M4_HOOK_CHK_SIZE]], [[%d]])", tblend + 1); + outn ("m4_define([[M4_HOOK_CHK_BODY]], [[m4_dnl"); yychk_tbl = calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yychk_tbl, YYTD_ID_CHK); @@ -826,7 +870,10 @@ void gentabs (void) yychk_data[i] = chk[i]; } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn ("]])"); + footprint += ptype->width * (tblend + 1); + if (tablesext) { yytbl_data_compress (yychk_tbl); if (yytbl_data_fwrite (&tableswr, yychk_tbl) < 0) @@ -902,7 +949,7 @@ void make_tables (void) struct yytbl_data *tbl; struct packtype_t *ptype = optimize_pack(0); - // Alternately defined if + /* Alternately defined if !ctrl.ffullspd && !ctrl.fulltbl */ out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); tbl = mkftbl (); yytbl_data_compress (tbl); @@ -966,7 +1013,10 @@ void make_tables (void) flex_int32_t *yynultrans_data = 0; /* Begin generating yy_NUL_trans */ - footprint += backend->nultrans(ctrl.fullspd, lastdfa + 1); + out_str ("m4_define([[M4_HOOK_NULTRANS_TYPE]], [[%s]])", (ctrl.fullspd) ? "struct yy_trans_info*" : "flex_int32_t"); + out_dec ("m4_define([[M4_HOOK_NULTRANS_SIZE]], [[%d]])", lastdfa + 1); + outn ("m4_define([[M4_HOOK_NULTRANS_BODY]], [[m4_dnl"); + yynultrans_tbl = calloc(1, sizeof (struct yytbl_data)); yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); // Performance kludge for C. Gives a small improvement @@ -975,11 +1025,11 @@ void make_tables (void) yynultrans_tbl->td_flags |= YYTD_PTRANS; yynultrans_tbl->td_lolen = (flex_uint32_t) (lastdfa + 1); yynultrans_tbl->td_data = yynultrans_data = - calloc(yynultrans_tbl->td_lolen, - sizeof (flex_int32_t)); + calloc(yynultrans_tbl->td_lolen, + sizeof (flex_int32_t)); for (i = 1; i <= lastdfa; ++i) { - if ((yynultrans_tbl->td_flags & YYTD_PTRANS) != 0) { + if ((yynultrans_tbl->td_flags & YYTD_PTRANS) != 0) { // Only works in very C-like languages out_dec (" &yy_transition[%d],\n", base[i]); @@ -992,7 +1042,9 @@ void make_tables (void) } } - dataend ("M4_HOOK_TABLE_CLOSER"); + dataend (NULL); + outn("]])"); + footprint += (lastdfa + 1) * (ctrl.fullspd ? sizeof(struct yy_trans_info *) : sizeof(int32_t)); if (tablesext) { yytbl_data_compress (yynultrans_tbl); if (yytbl_data_fwrite (&tableswr, yynultrans_tbl) < @@ -1004,7 +1056,7 @@ void make_tables (void) if (yynultrans_tbl != NULL) { yytbl_data_destroy (yynultrans_tbl); yynultrans_tbl = NULL; - } + } /* End generating yy_NUL_trans */ } -- cgit v1.2.1 From 102c7a0149251e24a351742626e8d85453d7c75f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Oct 2020 17:19:31 -0400 Subject: Finish up macro abstraction. Everything Flex ships to the skeleton-file expansion phase is now either a macro expansion or a macro call. This almost finishes the retargeting patch series; the wrapup will be documentation. Sadky, this does not get us *all* the way to target-syntax independence. The probem is the inclusion of tables_shared.c when table serialization is enabled. Which ,eans table serialization is not practical to support outside the C/C++ back end. No diffs in generated test code from this commit. #69 in the retargeting patch series --- src/cpp-flex.skl | 5 +++-- src/gen.c | 6 +++--- src/misc.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index f1a5854..31d84ca 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -64,6 +64,9 @@ m4_changequote([[, ]]) %# Macro hooks used by Flex start here +m4_define([[M4_HOOK_INT32]], [[flex_int32_t]]) +m4_define([[M4_HOOK_INT16]], [[flex_int16_t]]) + m4_define([[M4_HOOK_COMMENT_OPEN]], [[/*]]) m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) @@ -86,8 +89,6 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 ]]) -m4_define([[M4_HOOK_STATE_DYAD]], [[ {$1, $2},]]) - %% [0.0] Make hook macros available to Flex %not-for-header diff --git a/src/gen.c b/src/gen.c index ce3eb88..8e95917 100644 --- a/src/gen.c +++ b/src/gen.c @@ -50,10 +50,10 @@ struct packtype_t *optimize_pack(size_t sz) /* FIXME: There's a 32-bit assumption lurking here */ static struct packtype_t out; if (sz == 0) { - out.name = ctrl.long_align ? "flex_int32_t" : "flex_int16_t"; + out.name = ctrl.long_align ? "M4_HOOK_INT32" : "M4_HOOK_INT16"; out.width = ctrl.long_align ? 32 : 16; } else { - out.name = (ctrl.long_align || sz >= INT16_MAX) ? "flex_int32_t" : "flex_int16_t"; + out.name = (ctrl.long_align || sz >= INT16_MAX) ? "M4_HOOK_INT32" : "M4_HOOK_INT16"; out.width = (ctrl.long_align || sz >= INT16_MAX) ? 32 : 16; } return &out; @@ -1013,7 +1013,7 @@ void make_tables (void) flex_int32_t *yynultrans_data = 0; /* Begin generating yy_NUL_trans */ - out_str ("m4_define([[M4_HOOK_NULTRANS_TYPE]], [[%s]])", (ctrl.fullspd) ? "struct yy_trans_info*" : "flex_int32_t"); + out_str ("m4_define([[M4_HOOK_NULTRANS_TYPE]], [[%s]])", (ctrl.fullspd) ? "struct yy_trans_info*" : "M4_HOOK_INT32"); out_dec ("m4_define([[M4_HOOK_NULTRANS_SIZE]], [[%d]])", lastdfa + 1); outn ("m4_define([[M4_HOOK_NULTRANS_BODY]], [[m4_dnl"); diff --git a/src/misc.c b/src/misc.c index 7db330d..bd6bd25 100644 --- a/src/misc.c +++ b/src/misc.c @@ -809,7 +809,7 @@ void transition_struct_out (int element_v, int element_n) if (!gentables) return; - out_dec2 ("M4_HOOK_STATE_DYAD([[%4d]],[[%4d]])", element_v, element_n); + out_dec2 ("M4_HOOK_TABLE_OPENER[[%4d]],[[%4d]]M4_HOOK_TABLE_CONTINUE", element_v, element_n); outc ('\n'); datapos += TRANS_STRUCT_PRINT_LENGTH; -- cgit v1.2.1 From 8da857acc6f948d69381a3f4d1c68d897c5ed0a7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Oct 2020 19:11:19 -0400 Subject: Update the documentation on writing a back end, It will doubtless need expansion and revision when we actually write one. No diffs in generated test code. #70 and last in the retargeting patch series --- doc/flex.texi | 90 ++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 570fd7c..5ef1218 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8571,35 +8571,57 @@ to appear in a URI, including spaces and control characters. See This appendix describes how to add support for a new target language to Flex. -The flex code has been factored to isolate knowledge of the specifics -of each target language from the logic for building the lexer state -tables. - -The only assumption that is absolutely baked into all of Flex is that -the bodies of initializers for arrays of integers consist of decimal -numeric literals separated by commas (and optional whitespace). - -Otherwise, knowledge of each target langage's syntax lives in two -places: (1) a table of language-specific syntax-generator methods, -and (2) A language-specific skeleton file. +The Flex code has been factored to isolate knowledge of the specifics +of each target language from the logic for building the lexer +state/transition tables. Code in the target language is generated via +m4 expansion of macros in a skeleton. All knowledge of the target +language is isolated in that skeleton; with only one exception, +everything Flex contributes to the output stream is m4 macro definions +that are expanded by m4 after they are introduced. + +The only assumption that is absolutely baked into the macro +definitions Flex ships is that the bodies of initializers for arrays +of integers consist of decimal numeric literals separated by commas +(and optional whitespace). + +Otherwise, knowledge of each target langage's syntax lives in a +language-specific skeleton file that is digested into a data structure +inside Flex when Flex is compiled. The skeleton files are part of the +Flex source distribution; they are not required by the Flex +executable. + +A few poeces of language-specific information that cannot conveniently +be represented in a skeleton file are supplied by a per-language +method table in the C code. All the Flex code that accesses +language-specific information goes through a global pointer named +"backend" to a method table. One method is a function to +generate an appropriate suffix for output files. For example: The methods for the C and C++ back end live in a source file named @file{cpp_backend.c} (so named because both languages use the C -preprocessor), and in a skeleton file named @file{cpp-flex.skl}. - -All the code that accesses language-specific code generators goes -through a global pointer named "backend" to a method table. The -results of these generators are used to fill in some parts of the -language-specific skeleton file and conditionalize others. - -Read the definition of struct backend_t in @file{src/flexdefs.h}, and -attached comments, to get a feel for the methods. Don't worry -about understandng table generator names at first. - -You'll also need to look at the @code{M4_HOOK_*} macros near the top -of the skeleton file. Rather than emit literal language syntax, as -often as possible Flex ships calls to these which are expected to be -expanded within the skeleton. +preprocessor), and in a skeleton file named @file{cpp-flex.skl} which +is digested into a member of the method table when Flex is built. + +To get started on writing a new back end, read the definition of +struct backend_t in @file{src/flexdefs.h}, and attached comments +first. Then read a skeleton file. + +You'll want to start by studying the @code{M4_HOOK_*} macros near the +top of the skeleton file. Rather than emit literal language syntax, +Flex ships calls to these macros which are expected to be expanded +within the skeleton. The other things it ships which appear in the +output code are mostly bodies for table initializers, with associated +macros for typenames and table dimensions. The names of all such +macros have the prefix ``M4_HOOK_''; you can study them in the Flex +code by grepping for that prefix. + +Flex ships another fairly large set of macros that are guard +conditions for conditional macroexpanion. The values of these symbols +don't directly appear in the output, but they control the shape of the +generated code. The names of such macros have the prefixes +``M4_MODE_'' or ``M4_YY_''; you can study them in the Flex code by +grepping for these prefixes. Many of these symbols correspond to Flex +command-line options. To write support for a language, you'll want to do the following steps: @@ -8622,7 +8644,7 @@ is pointed at by the skel nember of your language back end. @item Add some logic to @file{main.c} that enables the new back end with a -new command-line option. Following this step you should be +new Flex option. Following this step you should be able to run Flex on a specification and get code out in the language of whatever back end you cloned. @@ -8642,7 +8664,7 @@ targets. Almost anything generally descended from Algol shouldn't be much more difficult; this certainly includes the whole Pascal/Modula/Oberon family. -A hint about the interesting part: +Two notes about the interesting part: @itemize @item @@ -8652,12 +8674,22 @@ needs to be supported in C for backwards compatibility, but there is no need to carry it forward. @end itemize +@itemize +@item +The ``one exception'' to target-syntax independence hinted at earlier +is some C code spliced into the skeleton when table serialization is +enabled. This option is thus available only with the C back end; you +need not bother supporting it in yours. +@end itemize + The following assumptions in the code might trip you up and require fixes outside a back end. @enumerate @item -The item separator in data initializers is a comma. +As previously noted, the item separator in data initializers is a +comma. Flex does not assume that a trailing comma after the last +initializer element is legal, though it is legal in C/C++. @item Either case arms can be stacked as in C; that is, there is -- cgit v1.2.1 From 700f9d3b6a3bb39d110f4b95e7459f4b9cfe4062 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Oct 2020 22:28:03 -0400 Subject: Eliminate the c_like backend member. No need for it, since the skel content is in core and the relevant hook can be searched for. This is a postscript to the retargeting series. It's not necessary, but it imoroves the code slightly. --- src/cpp_backend.c | 1 - src/flexdef.h | 4 +++- src/gen.c | 2 +- src/misc.c | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index 5094710..c483651 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -56,5 +56,4 @@ const char *cpp_skel[] = { struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, - .c_like = true, }; diff --git a/src/flexdef.h b/src/flexdef.h index 0377608..5005f91 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -306,7 +306,6 @@ struct flex_backend_t { const char *(*suffix)(void); // Generate suffix for lexer source code const char **skel; - bool c_like; // Will &yy_transition[%d]," produce a pointer table entry? }; extern size_t footprint; @@ -863,6 +862,9 @@ extern void dataend(const char *); /* Flush generated data statements. */ extern void dataflush(void); +/* Do we have a state-entry0format macro? */ +extern bool boneseeker(const char *); + /* Report an error message and terminate. */ extern void flexerror(const char *); diff --git a/src/gen.c b/src/gen.c index 8e95917..29cc831 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1021,7 +1021,7 @@ void make_tables (void) yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); // Performance kludge for C. Gives a small improvement // in table loading time. - if (ctrl.fullspd && backend->c_like) + if (ctrl.fullspd && boneseeker("m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]]")) yynultrans_tbl->td_flags |= YYTD_PTRANS; yynultrans_tbl->td_lolen = (flex_uint32_t) (lastdfa + 1); yynultrans_tbl->td_data = yynultrans_data = diff --git a/src/misc.c b/src/misc.c index bd6bd25..d628647 100644 --- a/src/misc.c +++ b/src/misc.c @@ -879,3 +879,20 @@ void comment(const char *txt) outc ('\n'); } +/* Search for a string in the skeleton prolog, where macros are defined. + */ +bool boneseeker(const char *bone) +{ + int i; + + for (i = 0; i < sizeof(backend->skel)/sizeof(backend->skel[0]); i++) { + const char *line = backend->skel[i]; + if (strstr(line, bone) != NULL) + return true; + else if (strncmp(line, "%%", 2) == 0) + break; + } + return false; +} + + -- cgit v1.2.1 From 723fd2c3b416b428664494a3898e91fda14bdf11 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 8 Oct 2020 06:41:59 -0400 Subject: Remove unused code. Indepemdent of the retargeting changes. --- src/flexdef.h | 5 ----- src/misc.c | 20 -------------------- 2 files changed, 25 deletions(-) diff --git a/src/flexdef.h b/src/flexdef.h index 5005f91..d2d61cb 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -296,11 +296,6 @@ */ #define BAD_SUBSCRIPT -32767 -/* Absolute value of largest number that can be stored in a short, with a - * bit of slop thrown in for general paranoia. - */ -#define MAX_SHORT 32700 - /* Method table describing a language-specific back end */ struct flex_backend_t { diff --git a/src/misc.c b/src/misc.c index d628647..9bd2e55 100644 --- a/src/misc.c +++ b/src/misc.c @@ -39,8 +39,6 @@ #define CMD_IF_C_OR_CPP "%if-c-or-c++" #define CMD_NOT_FOR_HEADER "%not-for-header" #define CMD_OK_FOR_HEADER "%ok-for-header" -#define CMD_PUSH "%push" -#define CMD_POP "%pop" #define CMD_IF_REENTRANT "%if-reentrant" #define CMD_IF_NOT_REENTRANT "%if-not-reentrant" #define CMD_IF_BISON_BRIDGE "%if-bison-bridge" @@ -722,24 +720,6 @@ void skelout (bool announce) } return; } - else if (cmd_match (CMD_PUSH)){ - sko_push(do_copy); - if(ctrl.ddebug){ - char buf2[MAXLINE]; - snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); - comment(buf2); - } - out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); - } - else if (cmd_match (CMD_POP)){ - sko_pop(&do_copy); - if(ctrl.ddebug){ - char buf2[MAXLINE]; - snprintf(buf2, sizeof(buf2), "(state = (%s)\n",do_copy?"true":"false"); - comment(buf2); - } - out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : ""); - } else if (cmd_match (CMD_IF_REENTRANT)){ sko_push(do_copy); do_copy = ctrl.reentrant && do_copy; -- cgit v1.2.1 From 1e9c36271ea388cd155f2b7808c71113301e1631 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 8 Oct 2020 16:03:03 -0400 Subject: Do consistent optimal packing of arrays. Flex has a strategy of packing its arrays with in32 or imt32 depending on length, but it wasn't applied consistently. While I don't thinlk this kind of space optimization matters a lot in 2020, if we're going to do it at all we should do it thoroughly. --- src/gen.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/gen.c b/src/gen.c index 29cc831..a2650f6 100644 --- a/src/gen.c +++ b/src/gen.c @@ -85,10 +85,10 @@ static struct yytbl_data *mkeoltbl (void) static void geneoltbl (void) { int i; + struct packtype_t *ptype = optimize_pack(num_rules); - /* FIXME: this table could be typically be packed into int16 */ outn ("m4_ifdef( [[M4_MODE_YYLINENO]],[["); - outn ("m4_define([[M4_HOOK_EOLTABLE_TYPE]], [[flex_int32_t]])"); + out_str ("m4_define([[M4_HOOK_EOLTABLE_TYPE]], [[%s]])\n", ptype->name); out_dec ("m4_define([[M4_HOOK_EOLTABLE_SIZE]], [[%d]])", num_rules + 1); outn ("m4_define([[M4_HOOK_EOLTABLE_BODY]], [[m4_dnl"); @@ -100,7 +100,7 @@ static void geneoltbl (void) out ("\n "); } } - footprint += sizeof(int32_t) * (num_rules + 1); + footprint += num_rules * ptype->width; outn ("]])"); outn ("]])"); } @@ -436,8 +436,7 @@ void genftbl (void) { int i; int end_of_buffer_action = num_rules + 1; - /* FIXME: Could make this smaller by passing the table size to pack_optimize(). */ - struct packtype_t *ptype = optimize_pack(0); + struct packtype_t *ptype = optimize_pack(num_rules + 1); dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; @@ -508,8 +507,7 @@ void gentabs (void) EOB_accepting_list; sz = MAX (numas, 1) + 1; - /* FIXME: could improve memory usage by passing sz in */ - ptype = optimize_pack(0); + ptype = optimize_pack(sz); out_str ("m4_define([[M4_HOOK_ACCLIST_TYPE]], [[%s]])", ptype->name); out_dec ("m4_define([[M4_HOOK_ACCLIST_SIZE]], [[%d]])", sz); outn ("m4_define([[M4_HOOK_ACCLIST_BODY]], [[m4_dnl"); @@ -618,9 +616,8 @@ void gentabs (void) */ ++sz; - /* FIXME: Could pack tighter by passing the size limit to optimize_pack() */ - /* But note that this table is alternately defined if ctrl.fulltbl */ - ptype = optimize_pack(0); + /* Note that this table is alternately defined if ctrl.fulltbl */ + ptype = optimize_pack(sz); outn ("m4_define([[M4_HOOK_NEED_ACCEPT]], 1)"); out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); out_dec ("m4_define([[M4_HOOK_ACCEPT_SIZE]], [[%d]])", sz); @@ -948,11 +945,12 @@ void make_tables (void) if (tablesext) { struct yytbl_data *tbl; - struct packtype_t *ptype = optimize_pack(0); /* Alternately defined if !ctrl.ffullspd && !ctrl.fulltbl */ - out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); + struct packtype_t *ptype; tbl = mkftbl (); yytbl_data_compress (tbl); + ptype = optimize_pack(tbl->td_lolen); + out_str ("m4_define([[M4_HOOK_ACCEPT_TYPE]], [[%s]])", ptype->name); if (yytbl_data_fwrite (&tableswr, tbl) < 0) flexerror (_("Could not write ftbl")); yytbl_data_destroy (tbl); @@ -1064,10 +1062,8 @@ void make_tables (void) if (ctrl.ddebug) { /* Spit out table mapping rules to line numbers. */ /* Policy choice: we don't include this space * in the table metering. - * FIXME: Could make this smaller by passing the table size to optimize_pack(). */ - struct packtype_t *ptype = optimize_pack(0); - + struct packtype_t *ptype = optimize_pack(num_rules); out_str ("m4_define([[M4_HOOK_DEBUGTABLE_TYPE]], [[%s]])", ptype->name); out_dec ("m4_define([[M4_HOOK_DEBUGTABLE_SIZE]], [[%d]])", num_rules); outn ("m4_define([[M4_HOOK_DEBUGTABLE_BODY]], [[m4_dnl"); -- cgit v1.2.1 From 62a13a3a3d45be1c053566fee502302368d4e579 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 9 Oct 2020 08:19:51 -0400 Subject: First step towards an interface independent of C macros. This patch implements and documents a yyreject() macro to replace argumentless REJECT. It does not remove REJECT, but warns that this macro will not be supported in non-C languages and deprecates it. This commit begins a new appendix in the Flex manual, to list deprecated interfaces and explain why they have been superseded. --- doc/flex.texi | 91 ++++++++++++++++++++++++++++++++++++-------------------- src/cpp-flex.skl | 10 ++++--- src/scan.l | 8 +++++ 3 files changed, 73 insertions(+), 36 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 5ef1218..3b3b7a4 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -170,7 +170,7 @@ FAQ * How can I have multiple input sources feed into the same scanner at the same time?:: * Can I build nested parsers that work with the same input file?:: * How can I match text only at the end of a file?:: -* How can I make REJECT cascade across start condition boundaries?:: +* How can I make yyreject() cascade across start condition boundaries?:: * Why cant I use fast or full tables with interactive mode?:: * How much faster is -F or -f than -C?:: * If I have a simple grammar cant I just parse it with flex?:: @@ -1236,8 +1236,8 @@ copies yytext to the scanner's output. followed by the name of a start condition places the scanner in the corresponding start condition (see below). -@item REJECT -@cindex REJECT +@item yyreject() +@cindex yyreject() directs the scanner to proceed on to the ``second best'' rule which matched the input (or a prefix of the input). The rule is chosen as described above in @ref{Matching}, and @code{yytext} and @code{yyleng} @@ -1252,19 +1252,19 @@ whenever @samp{frob} is seen: int word_count = 0; %% - frob special(); REJECT; + frob special(); yyreject(); [^ \t\n]+ ++word_count; @end verbatim @end example -Without the @code{REJECT}, any occurrences of @samp{frob} in the input +Without the @code{yyreject()}, any occurrences of @samp{frob} in the input would not be counted as words, since the scanner normally executes only -one action per token. Multiple uses of @code{REJECT} are allowed, each +one action per token. Multiple uses of @code{yyreject()} are allowed, each one finding the next best choice to the currently active rule. For example, when the following scanner scans the token @samp{abcd}, it will write @samp{abcdabcaba} to the output: -@cindex REJECT, calling multiple times +@cindex yyreject(), calling multiple times @cindex |, use of @example @verbatim @@ -1272,7 +1272,7 @@ write @samp{abcdabcaba} to the output: a | ab | abc | - abcd ECHO; REJECT; + abcd ECHO; yyreject(); .|\n /* eat up any unmatched character */ @end verbatim @end example @@ -1280,13 +1280,13 @@ write @samp{abcdabcaba} to the output: The first three rules share the fourth's action since they use the special @samp{|} action. -@code{REJECT} is a particularly expensive feature in terms of scanner +@code{yyreject()} is a particularly expensive feature in terms of scanner performance; if it is used in @emph{any} of the scanner's actions it will slow down @emph{all} of the scanner's matching. Furthermore, -@code{REJECT} cannot be used with the @samp{-Cf} or @samp{-CF} options +@code{yyreject()} cannot be used with the @samp{-Cf} or @samp{-CF} options (@pxref{Scanner Options}). -Note also that unlike the other special actions, @code{REJECT} is a +Note also that unlike the other special actions, @code{yyreject()} is a @emph{branch}. Code immediately following it in the action will @emph{not} be executed. @@ -2533,7 +2533,7 @@ The names are the same as their long-option equivalents (but without the leading @samp{--} ). @code{flex} scans your rule actions to determine whether you use the -@code{REJECT} or @code{yymore()} features. The @code{REJECT} and +@code{yyreject()} or @code{yymore()} features. The @code{yyreject()} and @code{yymore} options are available to override its decision as to whether you use the options, either by setting them (e.g., @code{%option reject)} to indicate the feature is indeed used, or unsetting them to @@ -3285,7 +3285,7 @@ cause a serious loss of performance in the resulting scanner. If you give the flag twice, you will also get comments regarding features that lead to minor performance losses. -Note that the use of @code{REJECT}, and +Note that the use of @code{yyreject()}, and variable trailing context (@pxref{Limitations}) entails a substantial performance penalty; use of @code{yymore()}, the @samp{^} operator, and the @samp{--interactive} flag entail minor performance penalties. @@ -3386,12 +3386,12 @@ rules. Aside from the effects on scanner speed of the table compression @samp{-C} options outlined above, there are a number of options/actions which degrade performance. These are, from most expensive to least: -@cindex REJECT, performance costs +@cindex yyreject(), performance costs @cindex yylineno, performance costs @cindex trailing context, performance costs @example @verbatim - REJECT + yyreject() arbitrary trailing context pattern sets that require backing up @@ -3412,7 +3412,7 @@ call that potentially does quite a bit of work, while @code{yyless()} is a quite-cheap macro. So if you are just putting back some excess text you scanned, use @code{yyless()}. -@code{REJECT} should be avoided at all costs when performance is +@code{yyreject()} should be avoided at all costs when performance is important. It is a particularly expensive option. There is one case when @code{%option yylineno} can be expensive. That is when @@ -3547,7 +3547,7 @@ Leaving just one means you gain nothing. @emph{Variable} trailing context (where both the leading and trailing parts do not have a fixed length) entails almost the same performance -loss as @code{REJECT} (i.e., substantial). So when possible a rule +loss as @code{yyreject()} (i.e., substantial). So when possible a rule like: @cindex trailing context, variable length @@ -4177,7 +4177,7 @@ always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, see @ref{Reentrant Functions}. Note that preprocessor macros, such as -@code{BEGIN}, @code{ECHO}, and @code{REJECT}, do not take this +@code{BEGIN}, @code{ECHO}, and @code{yyreject()}, do not take this additional argument. @node Global Replacement, Init and Destroy Functions, Extra Reentrant Argument, Reentrant Detail @@ -4818,7 +4818,7 @@ you must @code{#define YY_BUF_SIZE} to whatever number of bytes you want. We don to change this in the near future, but we reserve the right to do so if we ever add a more robust memory management API. -@item 64kb for the REJECT state. This will only be allocated if you use REJECT. +@item 64kb for the yyreject() state. This will only be allocated if you use yyreject(). The size is large enough to hold the same number of states as characters in the input buffer. If you override the size of the input buffer (via @code{YY_BUF_SIZE}), then you automatically override the size of this buffer as well. @@ -5267,7 +5267,7 @@ matched because it comes after an identifier ``catch-all'' rule: @end verbatim @end example -Using @code{REJECT} in a scanner suppresses this warning. +Using @code{yyreject()} in a scanner suppresses this warning. @item @samp{warning, -s option given but default rule can be matched} means @@ -5279,7 +5279,7 @@ not intended. @item @code{reject_used_but_not_detected undefined} or @code{yymore_used_but_not_detected undefined}. These errors can occur -at compile time. They indicate that the scanner uses @code{REJECT} or +at compile time. They indicate that the scanner uses @code{yyreject()} or @code{yymore()} but that @code{flex} failed to notice the fact, meaning that @code{flex} scanned the first two sections looking for occurrences of these actions and failed to find any, but somehow you snuck some in @@ -5316,9 +5316,9 @@ present it does not. @item @samp{input buffer overflow, can't enlarge buffer because scanner uses -REJECT}. the scanner was working on matching an extremely large token +yyreject()}. the scanner was working on matching an extremely large token and needed to expand the input buffer. This doesn't work with scanners -that use @code{REJECT}. +that use @code{yyreject()}. @item @samp{fatal flex scanner internal error--end of buffer missed}. This can @@ -5377,8 +5377,8 @@ with @code{flex} rules and expect it to work. Call @code{input()} instead. The total table entries listed by the @samp{-v} flag excludes the number of table entries needed to determine what rule has been matched. The number of entries is equal to the number of DFA states if -the scanner does not use @code{REJECT}, and somewhat greater than the -number of states if it does. @code{REJECT} cannot be used with the +the scanner does not use @code{yyreject()}, and somewhat greater than the +number of states if it does. @code{yyreject()} cannot be used with the @samp{-f} or @samp{-F} options. The @code{flex} internal algorithms need documentation. @@ -5426,7 +5426,7 @@ publish them here. * How can I have multiple input sources feed into the same scanner at the same time?:: * Can I build nested parsers that work with the same input file?:: * How can I match text only at the end of a file?:: -* How can I make REJECT cascade across start condition boundaries?:: +* How can I make yyreject() cascade across start condition boundaries?:: * Why cant I use fast or full tables with interactive mode?:: * How much faster is -F or -f than -C?:: * If I have a simple grammar cant I just parse it with flex?:: @@ -5709,8 +5709,8 @@ real @code{EOF} next time it's called). Then you could write: @end verbatim @end example -@node How can I make REJECT cascade across start condition boundaries? -@unnumberedsec How can I make REJECT cascade across start condition boundaries? +@node How can I make yyreject() cascade across start condition boundaries? +@unnumberedsec How can I make yyreject() cascade across start condition boundaries? You can do this as follows. Suppose you have a start condition @samp{A}, and after exhausting all of the possible matches in @samp{}, you want to try @@ -5720,13 +5720,13 @@ matches in @samp{}. Then you could use the following: @verbatim %x A %% -rule_that_is_long ...; REJECT; -rule ...; REJECT; /* shorter rule */ +rule_that_is_long ...; yyreject(); +rule ...; yyreject(); /* shorter rule */ etc. ... .|\n { /* Shortest and last rule in , so -* cascaded REJECTs will eventually +* cascaded yyreject()s will eventually * wind up matching this rule. We want * to now switch to the initial state * and try matching from there instead. @@ -8169,6 +8169,7 @@ See @ref{Top, , , bison, the GNU Bison Manual}. * M4 Dependency:: * Common Patterns:: * Retargeting Flex:: +* Deprecated Interfaces:: @end menu @node Makefiles and Flex, Bison Bridge, Appendices, Appendices @@ -8563,7 +8564,7 @@ to appear in a URI, including spaces and control characters. See @end table -@node Retargeting Flex, ,Common Patterns, Appendices +@node Retargeting Flex, Deprecated Interfaces, Common Patterns, Appendices @section Retargeting Flex @cindex retargeting @cindex language independence @@ -8703,6 +8704,32 @@ By putting a @code{yyterminate()} call in the expansion of @code{M4_HOOK_EOF_STATE_CASE_TERMINATE} macro, you could handle languages like Pascal. +@node Deprecated Interfaces, , Retargeting Flex,Appendices +@section Deprecated interfaces, , Retargeting Flex +@cindex interfaces, deprecated + +Long-time users of Flex and its predecessor, Lex, may notice that the +examples in this manual look a little different than they used to. +They have changed because of the support for targeting languages +other than C/C++. + +All the old interfaces are still in place for legacy C code to use. +But some are now deprecated and should not be used in new code. Doing +so will hinder forward portability someday. + +These changes are necessary because the documented Flex interface can +no longer rely on controlling scanner generation by defining +preprocessor macros. Most languages other than C/C++ don't have text +macros, and none of those that do emulate C #define. + +A list of deprecated interfaces and their replacements follows. + +@itemize +@item +REJECT: Replaced by yyreject() +@end itemize + + @node Indices, , Appendices, Top @unnumbered Indices diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 31d84ca..8f48783 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1039,7 +1039,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -/* Definitions for backing up. We don't need them if REJECT +/* Definitions for backing up. We don't need them if yyreject() * is being used because then we use an alternative backing-up * technique instead. */ @@ -1068,7 +1068,7 @@ static int *yy_full_state; ]]) ]]) ]]) -#define REJECT \ +#define yyreject() \ { \ *yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \ yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \ @@ -1080,11 +1080,13 @@ yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \ ++YY_G(yy_lp); \ goto find_rule; \ } +#define REJECT yyreject() ]]) m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ /* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. + * any uses of yyreject() which flex missed. */ +#define yyreject() reject_used_but_not_detected #define REJECT reject_used_but_not_detected ]]) @@ -2404,7 +2406,7 @@ int yyFlexLexer::yy_get_next_buffer() m4_ifdef( [[M4_MODE_USES_REJECT]], [[ YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +"input buffer overflow, can't enlarge buffer because scanner uses yyreject()" ); ]], [[ /* just a shorter name for the current buffer */ diff --git a/src/scan.l b/src/scan.l index 82d57df..6f26e68 100644 --- a/src/scan.l +++ b/src/scan.l @@ -84,6 +84,10 @@ extern const char *escaped_qstart, *escaped_qend; if ( all_upper( str ) ) \ reject = true; +#define CHECK_YYREJECT(str) \ + if ( all_lower( str ) ) \ + reject = true; + #define CHECK_YYMORE(str) \ if ( all_lower( str ) ) \ yymore_used = true; @@ -904,6 +908,10 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ "reject" { ACTION_ECHO; CHECK_REJECT(yytext); + } + "yyreject()" { + ACTION_ECHO; + CHECK_YYREJECT(yytext); } "yymore" { ACTION_ECHO; -- cgit v1.2.1 From 3612bc281e0ee68a8b9b5c609c42ced02366a82e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 9 Oct 2020 19:06:32 -0400 Subject: Deprecate BEGIN in favor of yybegin(). Worst of the awkward squad. --- doc/flex.texi | 109 +++++++++++++++++++----------------- src/cpp-flex.skl | 2 + tests/include_by_buffer.direct.l | 4 +- tests/include_by_push.direct.l | 4 +- tests/include_by_reentrant.direct.l | 4 +- tests/pthread.l | 12 ++-- 6 files changed, 71 insertions(+), 64 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 3b3b7a4..cee94f2 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1231,8 +1231,8 @@ action: @cindex ECHO copies yytext to the scanner's output. -@item BEGIN -@cindex BEGIN +@item yybegin() +@cindex yybegin() followed by the name of a start condition places the scanner in the corresponding start condition (see below). @@ -1345,7 +1345,7 @@ following will write out @samp{foobarbar}: An argument of 0 to @code{yyless()} will cause the entire current input string to be scanned again. Unless you've changed how the scanner will -subsequently process its input (using @code{BEGIN}, for example), this +subsequently process its input (using @code{yybegin()}, for example), this will result in an endless loop. Note that @code{yyless()} is a macro and can only be used in the flex @@ -1628,8 +1628,8 @@ Start conditions are declared in the definitions (first) section of the input using unindented lines beginning with either @samp{%s} or @samp{%x} followed by a list of names. The former declares @dfn{inclusive} start conditions, the latter @dfn{exclusive} start -conditions. A start condition is activated using the @code{BEGIN} -action. Until the next @code{BEGIN} action is executed, rules with the +conditions. A start condition is activated using the @code{yybegin()} +action. Until the next @code{yybegin()} action is executed, rules with the given start condition will be active and rules with other start conditions will be inactive. If the start condition is inclusive, then rules with no start conditions at all will also be active. If it is @@ -1707,21 +1707,20 @@ in start conditions. It is equivalent to: @end verbatim @end example -@cindex BEGIN, explanation -@findex BEGIN +@cindex yybegin(), explanation +@findex yybegin() @vindex INITIAL -@code{BEGIN(0)} returns to the original state where only the rules with +@code{yybegin(0)} returns to the original state where only the rules with no start conditions are active. This state can also be referred to as -the start-condition @code{INITIAL}, so @code{BEGIN(INITIAL)} is -equivalent to @code{BEGIN(0)}. (The parentheses around the start -condition name are not required but are considered good style.) +the start-condition @code{INITIAL}, so @code{yybegin(INITIAL)} is +equivalent to @code{yybegin(0)}. -@code{BEGIN} actions can also be given as indented code at the beginning +@code{yybegin()} actions can also be given as indented code at the beginning of the rules section. For example, the following will cause the scanner to enter the @code{SPECIAL} start condition whenever @code{yylex()} is called and the global variable @code{enter_special} is true: -@cindex start conditions, using BEGIN +@cindex start conditions, using yybegin() @example @verbatim int enter_special; @@ -1729,7 +1728,7 @@ called and the global variable @code{enter_special} is true: %x SPECIAL %% if ( enter_special ) - BEGIN(SPECIAL); + yybegin(SPECIAL); blahblahblah ...more rules follow... @@ -1752,7 +1751,7 @@ treat it as a single token, the floating-point number @samp{123.456}: %s expect %% - expect-floats BEGIN(expect); + expect-floats yybegin(expect); [0-9]+.[0-9]+ { printf( "found a float, = %f\n", @@ -1764,7 +1763,7 @@ treat it as a single token, the floating-point number @samp{123.456}: * before we'll recognize any more * numbers */ - BEGIN(INITIAL); + yybegin(INITIAL); } [0-9]+ { @@ -1787,12 +1786,12 @@ maintaining a count of the current input line. %% int line_num = 1; - "/*" BEGIN(comment); + "/*" yybegin(comment); [^*\n]* /* eat anything that's not a '*' */ "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ \n ++line_num; - "*"+"/" BEGIN(INITIAL); + "*"+"/" yybegin(INITIAL); @end verbatim @end example @@ -1816,20 +1815,20 @@ following fashion: "/*" { comment_caller = INITIAL; - BEGIN(comment); + yybegin(comment); } ... "/*" { comment_caller = foo; - BEGIN(comment); + yybegin(comment); } [^*\n]* /* eat anything that's not a '*' */ "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ \n ++line_num; - "*"+"/" BEGIN(comment_caller); + "*"+"/" yybegin(comment_caller); @end verbatim @end example @@ -1870,10 +1869,10 @@ not including checking for a string that's too long): char *string_buf_ptr; - \" string_buf_ptr = string_buf; BEGIN(str); + \" string_buf_ptr = string_buf; yybegin(str); \" { /* saw closing quote - all done */ - BEGIN(INITIAL); + yybegin(INITIAL); *string_buf_ptr = '\0'; /* return string constant token type and * value to parser @@ -1972,13 +1971,13 @@ pushes the current start condition onto the top of the start condition stack and switches to @code{new_state} as though you had used -@code{BEGIN new_state} +@code{yybegin(new_state)} (recall that start condition names are also integers). @end deftypefun @deftypefun void yy_pop_state () pops the top of the stack and switches to it via -@code{BEGIN}. +@code{yybegin()}. The program execution aborts, if there is no state on the stack. @end deftypefun @@ -2117,7 +2116,7 @@ maintains the stack internally. */ %x incl %% - include BEGIN(incl); + include yybegin(incl); [a-z]+ ECHO; [^a-z\n]*\n? ECHO; @@ -2131,7 +2130,7 @@ maintains the stack internally. yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); - BEGIN(INITIAL); + yybegin(INITIAL); } <> { @@ -2163,7 +2162,7 @@ manages its own input buffer stack manually (instead of letting flex do it). %} %% - include BEGIN(incl); + include yybegin(incl); [a-z]+ ECHO; [^a-z\n]*\n? ECHO; @@ -2187,7 +2186,7 @@ manages its own input buffer stack manually (instead of letting flex do it). yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE ) ); - BEGIN(INITIAL); + yybegin(INITIAL); } <> { @@ -2450,7 +2449,7 @@ returns a @code{YY_BUFFER_STATE} handle to the current buffer. @vindex YY_START @item YY_START returns an integer value corresponding to the current start condition. -You can subsequently use this value with @code{BEGIN} to return to that +You can subsequently use this value with @code{yybegin()} to return to that start condition. @end table @@ -3596,12 +3595,12 @@ additional work of setting up the scanning environment (e.g., %% int line_num = 1; - "/*" BEGIN(comment); + "/*" yybegin(comment); [^*\n]* "*"+[^*/\n]* \n ++line_num; - "*"+"/" BEGIN(INITIAL); + "*"+"/" yybegin(INITIAL); @end verbatim @end example @@ -3613,13 +3612,13 @@ This could be sped up by writing it as: %% int line_num = 1; - "/*" BEGIN(comment); + "/*" yybegin(comment); [^*\n]* [^*\n]*\n ++line_num; "*"+[^*/\n]* "*"+[^*/\n]*\n ++line_num; - "*"+"/" BEGIN(INITIAL); + "*"+"/" yybegin(INITIAL); @end verbatim @end example @@ -4177,7 +4176,7 @@ always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, see @ref{Reentrant Functions}. Note that preprocessor macros, such as -@code{BEGIN}, @code{ECHO}, and @code{yyreject()}, do not take this +@code{yyebegin()}, @code{ECHO}, and @code{yyreject()}, do not take this additional argument. @node Global Replacement, Init and Destroy Functions, Extra Reentrant Argument, Reentrant Detail @@ -5603,7 +5602,7 @@ rule to match more text, then put back the extra: @example @verbatim -data_.* yyless( 5 ); BEGIN BLOCKIDSTATE; +data_.* yyless( 5 ); yybegin(BLOCKIDSTATE); @end verbatim @end example @@ -5732,7 +5731,7 @@ matches in @samp{}. Then you could use the following: * and try matching from there instead. */ yyless(0); /* put back matched text */ -BEGIN(INITIAL); +yybegin(INITIAL); } @end verbatim @end example @@ -5809,10 +5808,10 @@ Here is one way which allows you to track line information: @example @verbatim { -"/*" BEGIN(IN_COMMENT); +"/*" yybegin(IN_COMMENT); } { -"*/" BEGIN(INITIAL); +"*/" yybegin(INITIAL); [^*\n]+ // eat comment in chunks "*" // eat the lone star \n yylineno++; @@ -6101,7 +6100,7 @@ Better is to either introduce a separate parser, or to split the scanner into multiple scanners using (exclusive) start conditions. You might have -a separate start state once you've seen the @samp{BEGIN}. In that state, you +a separate start state once you've seen the @samp{yybegin()}. In that state, you might then have a regex that will match @samp{END} (to kick you out of the state), and perhaps @samp{(.|\n)} to get a single character within the chunk ... @@ -6206,9 +6205,9 @@ In the example below, we want to skip over characters until we see the phrase /* INCORRECT SCANNER */ %x SKIP %% -startskip BEGIN(SKIP); +startskip yybegin(SKIP); ... -"endskip" BEGIN(INITIAL); +"endskip" yybegin(INITIAL); .* ; @end verbatim @end example @@ -6218,7 +6217,7 @@ The simplest (but slow) fix is: @example @verbatim -"endskip" BEGIN(INITIAL); +"endskip" yybegin(INITIAL); . ; @end verbatim @end example @@ -6228,7 +6227,7 @@ making it match "endskip" plus something else. So for example: @example @verbatim -"endskip" BEGIN(INITIAL); +"endskip" yybegin(INITIAL); [^e]+ ; . ;/* so you eat up e's, too */ @end verbatim @@ -6306,11 +6305,11 @@ of the '|' operator automatically makes the pattern variable length, so in this case '[Ff]oot' is preferred to '(F|f)oot'. > 4. I changed a rule that looked like this: -> {and}{bb}/{ROMAN}[^A-Za-z] { BEGIN... +> {and}{bb}/{ROMAN}[^A-Za-z] { yybegin... > > to the next 2 rules: > {and}{bb}/{ROMAN}[A-Za-z] { ECHO;} -> {and}{bb}/{ROMAN} { BEGIN... +> {and}{bb}/{ROMAN} { yybegin... > > Again, I understand the using [^...] will cause a great performance loss @@ -7090,7 +7089,7 @@ From: Vern Paxson > The problem is that when I do this (using %option c++) start > conditions seem to not apply. -The BEGIN macro modifies the yy_start variable. For C scanners, this +The yybegin() macro modifies the yy_start variable. For C scanners, this is a static with scope visible through the whole file. For C++ scanners, it's a member variable, so it only has visible scope within a member function. Your lexbegin() routine is not a member function when you @@ -7168,7 +7167,7 @@ From: Vern Paxson One way to do this is to have the parser call a stub routine that's included in the scanner's .l file, and consequently that has access ot -BEGIN. The only ugliness is that the parser can't pass in the state +yybegin(). The only ugliness is that the parser can't pass in the state it wants, because those aren't visible - but if you don't have many such states, then using a different set of names doesn't seem like to much of a burden. @@ -8512,10 +8511,10 @@ more efficient when used with automatic line number processing. @xref{option-yyl @verbatim { - "/*" BEGIN(COMMENT); + "/*" yybegin(COMMENT); } { - "*/" BEGIN(0); + "*/" yybegin(0); [^*\n]+ ; "*"[^/] ; \n ; @@ -8720,16 +8719,22 @@ so will hinder forward portability someday. These changes are necessary because the documented Flex interface can no longer rely on controlling scanner generation by defining preprocessor macros. Most languages other than C/C++ don't have text -macros, and none of those that do emulate C #define. +macros, and none of those that do emulate C #define. Thus, interface +calls need to be functions, at least syntactically (though many are +still implemented as macros for C/C++). A list of deprecated interfaces and their replacements follows. +Again, all are still available in the default C back end, but not +in any other. @itemize +@item +BEGIN: Replaced by yybegin() + @item REJECT: Replaced by yyreject() @end itemize - @node Indices, , Appendices, Top @unnumbered Indices diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 8f48783..5cd089f 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -407,6 +407,8 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ +#define yybegin(s) YY_G(yy_start) = 1 + 2 * (s) +/* Legacy interface */ #define BEGIN YY_G(yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex diff --git a/tests/include_by_buffer.direct.l b/tests/include_by_buffer.direct.l index 79ff01c..3b5df8a 100644 --- a/tests/include_by_buffer.direct.l +++ b/tests/include_by_buffer.direct.l @@ -47,7 +47,7 @@ int include_stack_ptr = 0; %% { -^"#include"[[:blank:]]+"<" { BEGIN(GET_FILENAME); } +^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } .|\n { ECHO; } } @@ -62,7 +62,7 @@ int include_stack_ptr = 0; yyterminate(); } yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE )); - BEGIN(0); + yybegin(0); } .|\n { fprintf(stderr,"Invalid input \"%s\".\n", yytext); diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l index 8aaea69..b7661f6 100644 --- a/tests/include_by_push.direct.l +++ b/tests/include_by_push.direct.l @@ -42,7 +42,7 @@ int error = 0; %% { -^"#include"[[:blank:]]+"<" { BEGIN(GET_FILENAME); } +^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } .|\n { ECHO; } } @@ -56,7 +56,7 @@ int error = 0; yyterminate(); } testpush_buffer_state( yy_create_buffer( yyin, YY_BUF_SIZE )); - BEGIN(0); + yybegin(0); } .|\n { fprintf(stderr,"Invalid input \"%s\".\n", yytext); diff --git a/tests/include_by_reentrant.direct.l b/tests/include_by_reentrant.direct.l index 7dbad72..a593652 100644 --- a/tests/include_by_reentrant.direct.l +++ b/tests/include_by_reentrant.direct.l @@ -43,7 +43,7 @@ int error = 0; %% { -^"#include"[[:blank:]]+"<" { BEGIN(GET_FILENAME); } +^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } .|\n { ECHO; } } @@ -65,7 +65,7 @@ int error = 0; testlex(scanner); testlex_destroy(scanner); - BEGIN(0); + yybegin(0); } .|\n { fprintf(stderr,"Invalid input \"%s\".\n", yytext); diff --git a/tests/pthread.l b/tests/pthread.l index eb99778..b7e8fa7 100644 --- a/tests/pthread.l +++ b/tests/pthread.l @@ -61,14 +61,14 @@ static int process_text(char* s, yyscan_t scanner); #define NUMBER 200 #define WORD 201 -[[:digit:]]+ { BEGIN(STATE_1); process_text(yytext,yyscanner); return NUMBER; } -[[:alpha:]]+ { BEGIN(STATE_2); process_text(yytext,yyscanner); return WORD; } +[[:digit:]]+ { yybegin(STATE_1); process_text(yytext,yyscanner); return NUMBER; } +[[:alpha:]]+ { yybegin(STATE_2); process_text(yytext,yyscanner); return WORD; } -[[:alpha:]]+ { BEGIN(0); process_text(yytext,yyscanner); return WORD; } -[[:digit:]]+ { BEGIN(0); process_text(yytext,yyscanner); return NUMBER; } +[[:alpha:]]+ { yybegin(0); process_text(yytext,yyscanner); return WORD; } +[[:digit:]]+ { yybegin(0); process_text(yytext,yyscanner); return NUMBER; } -[[:alpha:]]+ { BEGIN(0); process_text(yytext,yyscanner); return WORD; } -[[:digit:]]+ { BEGIN(0); process_text(yytext,yyscanner); return NUMBER; } +[[:alpha:]]+ { yybegin(0); process_text(yytext,yyscanner); return WORD; } +[[:digit:]]+ { yybegin(0); process_text(yytext,yyscanner); return NUMBER; } " "|\t|\r|\n { process_text(yytext,yyscanner); } [^[:alnum:][:space:]\t\r\n] { -- cgit v1.2.1 From 76affdf8942bf5627a815edcb486f9dcc3067ae6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 9 Oct 2020 23:28:42 -0400 Subject: Deprecate ECHO in favor of yyecho(). I changed the tests to use yyecho(), but the ECHO macro is still exercised in the bootstrap scanner. --- doc/flex.texi | 49 ++++++++++++++++++++----------------- src/cpp-flex.skl | 8 +++--- tests/include_by_buffer.direct.l | 2 +- tests/include_by_push.direct.l | 2 +- tests/include_by_reentrant.direct.l | 2 +- tests/quote_in_comment.l | 2 +- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index cee94f2..337de10 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -644,8 +644,8 @@ All the comments in the following example are valid: ruleA /* after regex */ { /* code block */ } /* after code block */ /* Rules Section (indented) */ { -ruleC ECHO; -ruleD ECHO; +ruleC yyecho(); +ruleD yyecho(); %{ /* code block */ %} @@ -1227,8 +1227,8 @@ There are a number of special directives which can be included within an action: @table @code -@item ECHO -@cindex ECHO +@item yyecho() +@cindex yyecho() copies yytext to the scanner's output. @item yybegin() @@ -1272,7 +1272,7 @@ write @samp{abcdabcaba} to the output: a | ab | abc | - abcd ECHO; yyreject(); + abcd yyecho(); yyreject(); .|\n /* eat up any unmatched character */ @end verbatim @end example @@ -1303,8 +1303,8 @@ the output: @example @verbatim %% - mega- ECHO; yymore(); - kludge ECHO; + mega- yyecho(); yymore(); + kludge yyecho(); @end verbatim @end example @@ -1313,7 +1313,7 @@ is matched, but the previous @samp{mega-} is still hanging around at the beginning of @code{yytext} so the -@code{ECHO} +@code{yyecho()} for the @samp{kludge} rule will actually write @samp{mega-kludge}. @end table @@ -1338,8 +1338,8 @@ following will write out @samp{foobarbar}: @example @verbatim %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; + foobar yyecho(); yyless(3); + [a-z]+ yyecho(); @end verbatim @end example @@ -1584,10 +1584,10 @@ obtain the default version of the routine, which always returns 1. For scanning from in-memory buffers (e.g., scanning strings), see @ref{Scanning Strings}. @xref{Multiple Input Buffers}. -@cindex ECHO, and yyout +@cindex yyecho(), and yyout @cindex yyout @cindex stdout, as default for yyout -The scanner writes its @code{ECHO} output to the @file{yyout} global +The scanner writes its @code{yyecho()} output to the @file{yyout} global (default, @file{stdout}), which may be redefined by the user simply by assigning it to some other @code{FILE} pointer. @@ -1697,13 +1697,13 @@ have been written: @end verbatim @end example -The default rule (to @code{ECHO} any unmatched character) remains active +The default rule (to @code{yyecho()} any unmatched character) remains active in start conditions. It is equivalent to: @cindex start conditions, behavior of default rule @example @verbatim - <*>.|\n ECHO; + <*>.|\n yyecho(); @end verbatim @end example @@ -2118,8 +2118,8 @@ maintains the stack internally. %% include yybegin(incl); - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; + [a-z]+ yyecho(); + [^a-z\n]*\n? yyecho(); [ \t]* /* eat the whitespace */ [^ \t\n]+ { /* got the include file name */ @@ -2164,8 +2164,8 @@ manages its own input buffer stack manually (instead of letting flex do it). %% include yybegin(incl); - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; + [a-z]+ yyecho(); + [^a-z\n]*\n? yyecho(); [ \t]* /* eat the whitespace */ [^ \t\n]+ { /* got the include file name */ @@ -2439,7 +2439,7 @@ scanning the same input file. @vindex yyout @item FILE *yyout -is the file to which @code{ECHO} actions are done. It can be reassigned +is the file to which @code{yyecho()} actions are done. It can be reassigned by the user. @vindex YY_CURRENT_BUFFER @@ -4176,7 +4176,7 @@ always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, see @ref{Reentrant Functions}. Note that preprocessor macros, such as -@code{yyebegin()}, @code{ECHO}, and @code{yyreject()}, do not take this +@code{yyebegin()}, @code{yyecho()}, and @code{yyreject()}, do not take this additional argument. @node Global Replacement, Init and Destroy Functions, Extra Reentrant Argument, Reentrant Detail @@ -4598,7 +4598,7 @@ reentrant, so if using C++ is an option for you, you should use them instead. @xref{Cxx}, and @ref{Reentrant} for details. @item -@code{output()} is not supported. Output from the @b{ECHO} macro is +@code{output()} is not supported. Output from the @b{yyecho()} macro is done to the file-pointer @code{yyout} (default @file{stdout)}. @item @@ -6308,7 +6308,7 @@ this case '[Ff]oot' is preferred to '(F|f)oot'. > {and}{bb}/{ROMAN}[^A-Za-z] { yybegin... > > to the next 2 rules: -> {and}{bb}/{ROMAN}[A-Za-z] { ECHO;} +> {and}{bb}/{ROMAN}[A-Za-z] { yyecho();} > {and}{bb}/{ROMAN} { yybegin... > > Again, I understand the using [^...] will cause a great performance loss @@ -8724,13 +8724,16 @@ calls need to be functions, at least syntactically (though many are still implemented as macros for C/C++). A list of deprecated interfaces and their replacements follows. -Again, all are still available in the default C back end, but not +Again, all are still available in the default C/C++ back end, but not in any other. @itemize @item BEGIN: Replaced by yybegin() +@item +ECHO: Replaced by yyecho() + @item REJECT: Replaced by yyreject() @end itemize diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 5cd089f..1eced3d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1481,17 +1481,19 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO +#ifndef yyecho %if-c-only Standard (non-C++) definition /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#define yyecho() do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) %endif %if-c++-only C++ definition -#define ECHO LexerOutput( yytext, yyleng ) +#define yyecho() LexerOutput( yytext, yyleng ) %endif #endif +/* Legacy interface */ +#define ECHO yyecho() ]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], diff --git a/tests/include_by_buffer.direct.l b/tests/include_by_buffer.direct.l index 3b5df8a..684d34b 100644 --- a/tests/include_by_buffer.direct.l +++ b/tests/include_by_buffer.direct.l @@ -48,7 +48,7 @@ int include_stack_ptr = 0; { ^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } -.|\n { ECHO; } +.|\n { yyecho(); } } { diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l index b7661f6..5f5fbf3 100644 --- a/tests/include_by_push.direct.l +++ b/tests/include_by_push.direct.l @@ -43,7 +43,7 @@ int error = 0; { ^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } -.|\n { ECHO; } +.|\n { yyecho(); } } { diff --git a/tests/include_by_reentrant.direct.l b/tests/include_by_reentrant.direct.l index a593652..544dd2f 100644 --- a/tests/include_by_reentrant.direct.l +++ b/tests/include_by_reentrant.direct.l @@ -44,7 +44,7 @@ int error = 0; { ^"#include"[[:blank:]]+"<" { yybegin(GET_FILENAME); } -.|\n { ECHO; } +.|\n { yyecho(); } } { diff --git a/tests/quote_in_comment.l b/tests/quote_in_comment.l index a5743c2..cb17e2f 100644 --- a/tests/quote_in_comment.l +++ b/tests/quote_in_comment.l @@ -1,6 +1,6 @@ %option 8bit noyywrap %% -.|\n { ECHO; +.|\n { yyecho(); //' " } %% -- cgit v1.2.1 From 0d1959c5956173060389021e931091269af6216e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 10 Oct 2020 17:21:11 -0400 Subject: Implement and document %yydecl directive to replace #define YY_DECL. Also added a deprecation note abut the old mechanism. --- doc/flex.texi | 47 ++++++++++++++++++----------------------------- src/cpp-flex.skl | 2 ++ src/flexdef.h | 1 + src/main.c | 12 ++++++++++-- src/scan.l | 1 + tests/test-yydecl | 14 ++++++++++++++ 6 files changed, 46 insertions(+), 31 deletions(-) create mode 100755 tests/test-yydecl diff --git a/doc/flex.texi b/doc/flex.texi index 337de10..5c6c04e 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -259,7 +259,6 @@ FAQ * unnamed-faq-99:: * unnamed-faq-100:: * unnamed-faq-101:: -* What is the difference between YYLEX_PARAM and YY_DECL?:: * Why do I get "conflicting types for yylex" error?:: * How do I access the values set in a Flex action from within a Bison action?:: @@ -1474,22 +1473,21 @@ default, @code{yylex()} is declared as follows: @end verbatim @end example -@cindex yylex(), overriding +@cindex yylex(), overriding, %yydecl (If your environment supports function prototypes, then it will be -@code{int yylex( void )}.) This definition may be changed by defining -the @code{YY_DECL} macro. For example, you could use: +@code{int yylex( void )}.) This definition may be changed with the +the @code{%yydecl} directive. For example, you could put this in +among your directives: @cindex yylex, overriding the prototype of @example @verbatim - #define YY_DECL float lexscan( a, b ) float a, b; +%yydecl float lexscan(float a, float b) @end verbatim @end example to give the scanning routine the name @code{lexscan}, returning a float, -and taking two floats as arguments. Note that if you give arguments to -the scanning routine using a K&R-style/non-prototyped function -declaration, you must terminate the definition with a semi-colon (;). +and taking two floats as arguments. @code{flex} generates @samp{C99} function definitions by default. Flex used to have the ability to generate obsolete, er, @@ -4734,7 +4732,7 @@ YY_AT_BOL() @item <*> @item -YY_DECL +%yydecl @item YY_START @item @@ -5514,7 +5512,6 @@ publish them here. * unnamed-faq-99:: * unnamed-faq-100:: * unnamed-faq-101:: -* What is the difference between YYLEX_PARAM and YY_DECL?:: * Why do I get "conflicting types for yylex" error?:: * How do I access the values set in a Flex action from within a Bison action?:: @end menu @@ -6766,6 +6763,9 @@ for sure won't be for many months to come). @c TODO: Evaluate this faq. @node ERASEME55 @unnumberedsec ERASEME55 +(Note: The @code{YY_DECL} macro is deprecated. Use the @code{%yydecl} +option instead.) + @example @verbatim To: Colin Paul Adams @@ -8131,27 +8131,12 @@ then the problem is that the last rule needs to be "{whitespace}" ! @end verbatim @end example -@node What is the difference between YYLEX_PARAM and YY_DECL? -@unnumberedsec What is the difference between YYLEX_PARAM and YY_DECL? - -YYLEX_PARAM is not a flex symbol. It is for Bison. It tells Bison to pass extra -params when it calls yylex() from the parser. - -YY_DECL is the Flex declaration of yylex. The default is similar to this: - -@example -@verbatim -#define int yy_lex () -@end verbatim -@end example - - @node Why do I get "conflicting types for yylex" error? @unnumberedsec Why do I get "conflicting types for yylex" error? This is a compiler error regarding a generated Bison parser, not a Flex scanner. It means you need a prototype of yylex() in the top of the Bison file. -Be sure the prototype matches YY_DECL. +Be sure the prototype matches what you declarted with @code{%yydecl}. @node How do I access the values set in a Flex action from within a Bison action? @unnumberedsec How do I access the values set in a Flex action from within a Bison action? @@ -8719,9 +8704,10 @@ so will hinder forward portability someday. These changes are necessary because the documented Flex interface can no longer rely on controlling scanner generation by defining preprocessor macros. Most languages other than C/C++ don't have text -macros, and none of those that do emulate C #define. Thus, interface -calls need to be functions, at least syntactically (though many are -still implemented as macros for C/C++). +macros, and none of those that do emulate C #define closely enough to +preserve the behavior dependent on it. Thus interface calls in +multi-language Flex need to be functions, at least syntactically +(though many are still implemented as macros for C/C++). A list of deprecated interfaces and their replacements follows. Again, all are still available in the default C/C++ back end, but not @@ -8736,6 +8722,9 @@ ECHO: Replaced by yyecho() @item REJECT: Replaced by yyreject() + +@item +YY_DECL: Replaced by the %yydecl directive. @end itemize @node Indices, , Appendices, Top diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 1eced3d..59a717e 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -89,6 +89,8 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 ]]) +m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1]]) + %% [0.0] Make hook macros available to Flex %not-for-header diff --git a/src/flexdef.h b/src/flexdef.h index d2d61cb..10bc90f 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -351,6 +351,7 @@ struct ctrl_bundle_t { bool use_read; // (-f, -F, or -Cr) use read() for scanner input // otherwise, use fread(). char *yyclass; // yyFlexLexer subclass to use for YY_DECL + char *yydecl; // user-specfied prototype for yylex. bool yytext_is_array; // if true (i.e., %array directive), then declare // yytext as array instead of a character pointer. // Nice and inefficient. diff --git a/src/main.c b/src/main.c index 970a93d..2122bae 100644 --- a/src/main.c +++ b/src/main.c @@ -1280,12 +1280,20 @@ void readin (void) /* Place a bogus line directive, it will be fixed in the filter. */ line_directive_out(0, false); + /* User may want to set the scanner prototype */ + if (ctrl.yydecl != NULL) { + char *cp; + for (cp = ctrl.yydecl; isspace(*cp); cp++) + continue; + out_str ("M4_HOOK_SET_YY_DECL(%s)\n", cp); + } + /* Dump the user defined preproc directives. */ if (userdef_buf.elts) outn ((char *) (userdef_buf.elts)); /* If the user explicitly requested posix compatibility by specifing the - * posix-compat option, then we check for conflicting ctrl. However, if + * posix-compat option, then we check for conflicting options. However, if * the POSIXLY_CORRECT variable is set, then we quietly make flex as * posix-compatible as possible. This is the recommended behavior * according to the GNU Coding Standards. @@ -1295,7 +1303,7 @@ void readin (void) */ if (ctrl.posix_compat) { /* TODO: This is where we try to make flex behave according to - * posiz, AND check for conflicting ctrl. How far should we go + * POSIX, *and* check for conflicting ctrl. How far should we go * with this? Should we disable all the neat-o flex features? */ /* Update: Estes says no, since other flex features don't violate posix. */ diff --git a/src/scan.l b/src/scan.l index 6f26e68..c24c680 100644 --- a/src/scan.l +++ b/src/scan.l @@ -194,6 +194,7 @@ M4QEND "]""]" ^"%pointer".*{NL} ctrl.yytext_is_array = false; ++linenum; ^"%array".*{NL} ctrl.yytext_is_array = true; ++linenum; + ^"%yydecl".* ctrl.yydecl = xstrdup(yytext+7); ^"%option" BEGIN(OPTION); return TOK_OPTION; diff --git a/tests/test-yydecl b/tests/test-yydecl new file mode 100755 index 0000000..1b4efad --- /dev/null +++ b/tests/test-yydecl @@ -0,0 +1,14 @@ +#! /bin/sh +# Test %yydecl option of flex in any cpp-based back end + +trap 'rm /tmp/td$$' EXIT HUP INT QUIT TERM +cat >/tmp/td$$ </dev/null ) || (echo "%yydecl test failed." >&2; exit 1) + + + -- cgit v1.2.1 From 3158c7f0721f8558a1acdcf5c2dad12be0fa0e2e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 10 Oct 2020 19:25:32 -0400 Subject: Implement and document %option yylmax to replace #define YYLMAX. Test in tests/test-yylmax. --- doc/flex.texi | 38 ++++++++++++++++++++------------------ src/cpp-flex.skl | 5 ++++- src/flexdef.h | 4 +++- src/main.c | 6 +++++- src/parse.y | 4 +++- src/scan.l | 2 ++ tests/test-yylmax | 14 ++++++++++++++ 7 files changed, 51 insertions(+), 22 deletions(-) create mode 100755 tests/test-yylmax diff --git a/doc/flex.texi b/doc/flex.texi index 5c6c04e..836018a 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1137,16 +1137,16 @@ for @code{%array}. The @code{%array} declaration defines @code{yytext} to be an array of @code{YYLMAX} characters, which defaults to a fairly large value. You -can change the size by simply #define'ing @code{YYLMAX} to a different -value in the first section of your @code{flex} input. As mentioned -above, with @code{%pointer} yytext grows dynamically to accommodate -large tokens. While this means your @code{%pointer} scanner can -accommodate very large tokens (such as matching entire blocks of -comments), bear in mind that each time the scanner must resize -@code{yytext} it also must rescan the entire token from the beginning, -so matching such tokens can prove slow. @code{yytext} presently does -@emph{not} dynamically grow if a call to @code{unput()} results in too -much text being pushed back; instead, a run-time error results. +can change the size to a different value with @code{%option yylmax += NNN}. As mentioned above, with @code{%pointer} yytext grows +dynamically to accommodate large tokens. While this means your +@code{%pointer} scanner can accommodate very large tokens (such as +matching entire blocks of comments), bear in mind that each time the +scanner must resize @code{yytext} it also must rescan the entire token +from the beginning, so matching such tokens can prove slow. +@code{yytext} presently does @emph{not} dynamically grow if a call to +@code{unput()} results in too much text being pushed back; instead, a +run-time error results. @cindex %array, with C++ Also note that you cannot use @code{%array} with C++ scanner classes @@ -2398,11 +2398,11 @@ lengthened (you cannot append characters to the end). @cindex yytext, default array size @cindex array, default size for yytext -@vindex YYLMAX +@vindex yylmax If the special directive @code{%array} appears in the first section of the scanner description, then @code{yytext} is instead declared -@code{char yytext[YYLMAX]}, where @code{YYLMAX} is a macro definition -that you can redefine in the first section if you don't like the default +to be an array of YYLMAX characters, where @code{YYLMAX} is a parameter +that you can redefine with a @code{%yylmax} option if you don't like the default value (generally 8KB). Using @code{%array} results in somewhat slower scanners, but the value of @code{yytext} becomes immune to calls to @code{unput()}, which potentially destroy its value when @code{yytext} is @@ -5292,9 +5292,8 @@ its rules. This error can also occur due to internal problems. @item @samp{token too large, exceeds YYLMAX}. your scanner uses @code{%array} and one of its rules matched a string longer than the @code{YYLMAX} -constant (8K bytes by default). You can increase the value by -#define'ing @code{YYLMAX} in the definitions section of your @code{flex} -input. +constant (8K bytes by default). You can increase the value with the +@code{%yylmax} option. @item @samp{scanner requires -8 flag to use the character 'x'}. Your scanner @@ -8721,10 +8720,13 @@ BEGIN: Replaced by yybegin() ECHO: Replaced by yyecho() @item -REJECT: Replaced by yyreject() +#define REJECT: Replaced by yyreject() + +@item +#define YY_DECL: Replaced by the %yydecl directive. @item -YY_DECL: Replaced by the %yydecl directive. +#define YYLMAX: Replaced by the %yylmax option. @end itemize @node Indices, , Appendices, Top diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 59a717e..c6b4c9a 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -89,7 +89,10 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 ]]) -m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1]]) +m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 +]]) +m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1 +]]) %% [0.0] Make hook macros available to Flex diff --git a/src/flexdef.h b/src/flexdef.h index 10bc90f..a5f98b4 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -352,6 +352,7 @@ struct ctrl_bundle_t { // otherwise, use fread(). char *yyclass; // yyFlexLexer subclass to use for YY_DECL char *yydecl; // user-specfied prototype for yylex. + int yylmax; // Maximum buffer length if %array bool yytext_is_array; // if true (i.e., %array directive), then declare // yytext as array instead of a character pointer. // Nice and inefficient. @@ -669,6 +670,7 @@ extern unsigned char *ccltbl; /* Variables for miscellaneous information: * nmstr - last NAME scanned by the scanner + * nmval - last numeric scanned by the scanner * sectnum - section number currently being parsed * nummt - number of empty nxt/chk table entries * hshcol - number of hash collisions detected by snstods @@ -688,7 +690,7 @@ extern unsigned char *ccltbl; */ extern char nmstr[MAXLINE]; -extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; +extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs, nmval; extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; extern int num_backing_up, bol_needed; diff --git a/src/main.c b/src/main.c index 2122bae..391d5a1 100644 --- a/src/main.c +++ b/src/main.c @@ -86,7 +86,7 @@ int lastccl, *cclmap, *ccllen, *cclng, cclreuse; int current_maxccls, current_max_ccl_tbl_size; unsigned char *ccltbl; char nmstr[MAXLINE]; -int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; +int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs, nmval; int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; int num_backing_up, bol_needed; int end_of_buffer_state; @@ -1288,6 +1288,10 @@ void readin (void) out_str ("M4_HOOK_SET_YY_DECL(%s)\n", cp); } + if (ctrl.yylmax != 0) { + out_dec ("M4_HOOK_SET_YYLMAX(%d)\n", ctrl.yylmax); + } + /* Dump the user defined preproc directives. */ if (userdef_buf.elts) outn ((char *) (userdef_buf.elts)); diff --git a/src/parse.y b/src/parse.y index 1a7e1bb..f13a36d 100644 --- a/src/parse.y +++ b/src/parse.y @@ -2,7 +2,7 @@ %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP %token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE -%token TOK_TABLES_FILE +%token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC %token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH %token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT @@ -206,6 +206,8 @@ option : TOK_OUTFILE '=' NAME { ctrl.yyclass = xstrdup(nmstr); } | TOK_HEADER_FILE '=' NAME { env.headerfilename = xstrdup(nmstr); } + | TOK_YYLMAX '=' TOK_NUMERIC + { ctrl.yylmax = nmval; } | TOK_TABLES_FILE '=' NAME { tablesext = true; tablesfilename = xstrdup(nmstr); } ; diff --git a/src/scan.l b/src/scan.l index c24c680..975ba41 100644 --- a/src/scan.l +++ b/src/scan.l @@ -351,6 +351,7 @@ M4QEND "]""]" {WS} option_sense = true; "=" return '='; + [[:digit:]]+ {nmval = atoi(yytext); return TOK_NUMERIC;} no option_sense = ! option_sense; @@ -450,6 +451,7 @@ M4QEND "]""]" outfile return TOK_OUTFILE; prefix return TOK_PREFIX; yyclass return TOK_YYCLASS; + yylmax return TOK_YYLMAX; header(-file)? return TOK_HEADER_FILE; tables-file return TOK_TABLES_FILE; tables-verify { diff --git a/tests/test-yylmax b/tests/test-yylmax new file mode 100755 index 0000000..a89fea9 --- /dev/null +++ b/tests/test-yylmax @@ -0,0 +1,14 @@ +#! /bin/sh +# Test %yylmax option of flex in any cpp-based back end + +trap 'rm /tmp/td$$' EXIT HUP INT QUIT TERM +cat >/tmp/td$$ </dev/null ) || (echo "%yylmax test failed." >&2; exit 1) + + + -- cgit v1.2.1 From 1094c2a1370defc57ea14d2398a72f15ce4f9c43 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Oct 2020 05:14:41 -0400 Subject: Revise Flex manual to say useful things about multilanguage support. No specific thing can be said about a non-C/C++ backend yet, but this patch prepares the way by explaining which features and aspects of the Flex interface are specific to C/C++. It also fixes one pre-ANSI prototype - that of non-reentrant yylex(), which should be declared yylex(void) in this day and age. These changes make one new commitment. Observing that the YY_INPUT macro is impossible to port out of the C/C++ context, I have observed that it is probably extinct in the wild (due to the later introduction of the multi-buffer primitives, though I don't say that explicitly). The text says tat people who really need the equivalent of this capability in a non-C/C++ back end should file an issue with the Flex maintainers. I don't actually expect this to happen. --- doc/flex.texi | 141 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 107 insertions(+), 34 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 836018a..90c8aa5 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -306,13 +306,22 @@ GitHub's issue tracking facility at @url{https://github.com/westes/flex/issues/} program which recognizes lexical patterns in text. The @code{flex} program reads the given input files, or its standard input if no file names are given, for a description of a scanner to generate. The -description is in the form of pairs of regular expressions and C code, -called @dfn{rules}. @code{flex} generates as output a C source file, -@file{lex.yy.c} by default, which defines a routine @code{yylex()}. -This file can be compiled and linked with the flex runtime library to +description is in the form of pairs of regular expressions and +fragments of source code +called @dfn{rules}. @code{flex} generates as output a source file +in your target language which defines a routine @code{yylex()}. +This file can be compiled and (if you are using the C/C++ back end) +optionally linked with the flex runtime library to produce an executable. When the executable is run, it analyzes its input for occurrences of the regular expressions. Whenever it finds -one, it executes the corresponding C code. +one, it executes the corresponding rule code. + +When your target language is C, the name of the generated scanner +@file{lex.yy.c} by default. Other languages will glue the suffix they +normally use for source-code files to the prefix @file{lex.yy}. + +The examples in this manual are in C, which is Flex's default target +language and until release 4.6.2 its only one. @node Simple Examples, Format, Introduction, Top @chapter Some Simple Examples @@ -1104,7 +1113,8 @@ a time) to its output. @cindex %array, use of @cindex %pointer, use of @vindex yytext -Note that @code{yytext} can be defined in two different ways: either as +Note that in languages with only fixed-extent arrays (like C/C+) +@code{yytext} can be defined in two different ways: either as a character @emph{pointer} or as a character @emph{array}. You can control which definition @code{flex} uses by including one of the special directives @code{%pointer} or @code{%array} in the first @@ -1152,12 +1162,20 @@ run-time error results. Also note that you cannot use @code{%array} with C++ scanner classes (@pxref{Cxx}). +In target langages with automatic memory allocation and arrays none of +this applies; you can expect @code{yytext} to dynamically resize +itself, calls to the @code{unput()}will not destroy the present +contents of @code{yytext}, and you will never get a run-time error +from calls to the @code{unput()} function destroys the present +contents of @code{yytext} except in the extremely unlikely case that +your scanner cannot allocate more memory. + @node Actions, Generated Scanner, Matching, Top @chapter Actions @cindex actions Each pattern in a rule has a corresponding @dfn{action}, which can be -any arbitrary C statement. The pattern ends at the first non-escaped +any arbitrary target-language statement. The pattern ends at the first non-escaped whitespace character; the remainder of the line is its action. If the action is empty, then when the pattern is matched the input token is simply discarded. For example, here is the specification for a program @@ -1379,7 +1397,9 @@ back-to-front. @cindex %pointer, and unput() @cindex unput(), and %pointer -An important potential problem when using @code{unput()} is that if you +An important potential problem when using @code{unput()} in C (and, +generally, in target languages with C-like manual memory management) is +that if you are using @code{%pointer} (the default), a call to @code{unput()} @emph{destroys} the contents of @code{yytext}, starting with its rightmost character and devouring one character to the left with each @@ -1452,32 +1472,35 @@ Input Buffers}) @code{yyterminate()} can be used in lieu of a return statement in an action. It terminates the scanner and returns a 0 to the scanner's caller, indicating ``all done''. By default, @code{yyterminate()} is -also called when an end-of-file is encountered. It is a macro and may -be redefined. +also called when an end-of-file is encountered. It may be redefined. + +When the target language is C, @code{yyterminate()} is a macro. +Redefining it using the C preprocessor in your definitions section +is allowed, but not recommended as doing this makes code more +difficult to port out of C. In other target languages you can define +@code{yyterminate()} as a function; Flex will notice this and not +generate a default into the scanner. @node Generated Scanner, Start Conditions, Actions, Top @chapter The Generated Scanner @cindex yylex(), in generated scanner -The output of @code{flex} is the file @file{lex.yy.c}, which contains +The output of @code{flex} is a file wity the sem name @file{lex.yy}, which contains the scanning routine @code{yylex()}, a number of tables used by it for matching tokens, and a number of auxiliary routines and macros. By -default, @code{yylex()} is declared as follows: +default in C, @code{yylex()} is declared as follows: @example @verbatim - int yylex() - { + int yylex(void) { ... various definitions and the actions in here ... - } + } @end verbatim @end example @cindex yylex(), overriding, %yydecl -(If your environment supports function prototypes, then it will be -@code{int yylex( void )}.) This definition may be changed with the -the @code{%yydecl} directive. For example, you could put this in -among your directives: +This definition may be changed with the the @code{%yydecl} directive. +For example, you could put this in among your directives: @cindex yylex, overriding the prototype of @example @@ -1499,6 +1522,11 @@ traditional definitions support added extra complexity in the skeleton file. For this reason, current versions of @code{flex} generate standard C99 code only, leaving K&R-style functions to the historians. +In other languages, @code{yylex()} will be generated as a reentrant +function with a scanner context argument added. This can be enabled +in C as well, and specifying your C scanners to be rrentrant is +recommended for portability. + @cindex stdin, default for yyin @cindex yyin Whenever @code{yylex()} is called, it scans tokens from the global input @@ -1512,10 +1540,9 @@ one of its actions executes a @code{return} statement. If the scanner reaches an end-of-file, subsequent calls are undefined unless either @file{yyin} is pointed at a new input file (in which case scanning continues from that file), or @code{yyrestart()} is called. -@code{yyrestart()} takes one argument, a @code{FILE *} pointer (which -can be NULL, if you've set up @code{YY_INPUT} to scan from a source other -than @code{yyin}), and initializes @file{yyin} for scanning from that -file. Essentially there is no difference between just assigning +@code{yyrestart()} takes one argument, an inoput stream, and +initializes @file{yyin} for scanning from that +stream. Essentially there is no difference between just assigning @file{yyin} to a new input file or using @code{yyrestart()} to do so; the latter is available for compatibility with previous versions of @code{flex}, and because it can be used to switch input files in the @@ -1525,13 +1552,17 @@ better to use @code{YY_FLUSH_BUFFER} (@pxref{Actions}). Note that @code{yyrestart()} does @emph{not} reset the start condition to @code{INITIAL} (@pxref{Start Conditions}). +In C, an input stream is a a @code{FILE *} pointer. This pointer +can be NULL, if you've set up @code{YY_INPUT} to scan from a source other +than @code{yyin}. + @cindex RETURN, within actions If @code{yylex()} stops scanning due to executing a @code{return} statement in one of the actions, the scanner may then be called again and it will resume scanning where it left off. @cindex YY_INPUT -By default (and for purposes of efficiency), the scanner uses +By default (and for purposes of efficiency), C/C++ scanners use block-reads rather than simple @code{getc()} calls to read characters from @file{yyin}. The nature of how it gets its input can be controlled by defining the @code{YY_INPUT} macro. The calling sequence for @@ -1561,6 +1592,13 @@ section of the input file): This definition will change the input processing to occur one character at a time. +YY_INPUT is not available in target languages other than C/C++. It +dates from a time in the 1970s when efficiency optimizations were a +far more pressing problem than they are today, and is probably extinct +in the wild. If lack of it poses a problem for a port you are doing, +file an issue report with the Flex mauntainers and we will attempt to +assist you. + @cindex yywrap() When the scanner receives an end-of-file indication from YY_INPUT, it then checks the @code{yywrap()} function. If @code{yywrap()} returns @@ -2023,6 +2061,13 @@ associated with the given file and large enough to hold @code{size} characters (when in doubt, use @code{YY_BUF_SIZE} for the size). It returns a @code{YY_BUFFER_STATE} handle, which may then be passed to other routines (see below). + +In target languages other than C/C++, this prototype will look +different. The buffer-state object may be named differently, and will +not have ``struct'' as part of its name. The input-stream type won't +be @code{FILE *}. But expect the same semamntics wxpressed in native +tytypes. + @tindex YY_BUFFER_STATE The @code{YY_BUFFER_STATE} type is a pointer to an opaque @code{struct yy_buffer_state} structure, so you may @@ -2260,7 +2305,8 @@ by doing one of the following things: @findex YY_NEW_FILE (now obsolete) assigning @file{yyin} to a new input file (in previous versions of @code{flex}, after doing the assignment you had to call the special -action @code{YY_NEW_FILE}. This is no longer necessary.) +action @code{YY_NEW_FILE}. This is no longer necessary.) It is +still supported in the C/C++ back end only. @item executing a @code{return} statement; @@ -2437,7 +2483,7 @@ scanning the same input file. @vindex yyout @item FILE *yyout -is the file to which @code{yyecho()} actions are done. It can be reassigned +is the output stream to which @code{yyecho()} actions are done. It can be reassigned by the user. @vindex YY_CURRENT_BUFFER @@ -2481,6 +2527,11 @@ is @code{TOK_NUMBER}, part of the scanner might look like: @end verbatim @end example +Bison is also retargetable to langages other than C. Outside the +C/C++ back end, it is likely that your Bison module will simply +moduke-level constants that will be make visible to your scanner by +linkage. + @node Scanner Options, Performance, Yacc, Top @chapter Scanner Options @@ -2658,7 +2709,9 @@ implementation. Note that this does not mean @emph{full} compatibility. Use of this option costs a considerable amount of performance, and it cannot be used with the @samp{--c++}, @samp{--full}, @samp{--fast}, @samp{-Cf}, or @samp{-CF} options. For details on the compatibilities it provides, see -@ref{Lex and Posix}. This option also results in the name +@ref{Lex and Posix}. It will usuually be a no-op on back ends other +than C/C++. +This option also results in the name @code{YY_FLEX_LEX_COMPAT} being @code{#define}'d in the generated scanner. @@ -3138,7 +3191,7 @@ array look-up per character scanned). @opindex ---read @opindex read @item -Cr, --read, @code{%option read} -causes the generated scanner to @emph{bypass} use of the standard I/O +causes scanner generated with the C/C++ back end to @emph{bypass} use of the standard I/O library (@code{stdio}) for input. Instead of calling @code{fread()} or @code{getc()}, the scanner will use the @code{read()} system call, resulting in a performance gain which varies from system to system, but @@ -3147,7 +3200,9 @@ or @samp{-CF}. Using @samp{-Cr} can cause strange behavior if, for example, you read from @file{yyin} using @code{stdio} prior to calling the scanner (because the scanner will miss whatever text your previous reads left in the @code{stdio} input buffer). @samp{-Cr} has no effect -if you define @code{YY_INPUT()} (@pxref{Generated Scanner}). +if you define @code{YY_INPUT()} (@pxref{Generated Scanner}). It may +be a no-op or enable different optimizations in back ends other than +the default C/C++ one. @end table The options @samp{-Cf} or @samp{-CF} and @samp{-Cm} do not make sense @@ -3989,6 +4044,9 @@ control. The most common use for reentrant scanners is from within multi-threaded applications. Any thread may create and execute a reentrant @code{flex} scanner without the need for synchronization with other threads. +All scanners generated by back ends other than the default C/C++ back +end are reentrant. + @menu * Reentrant Uses:: * Reentrant Overview:: @@ -4137,7 +4195,7 @@ Here are the things you need to do or know to use the reentrant C API of @node Specify Reentrant, Extra Reentrant Argument, Reentrant Detail, Reentrant Detail @subsection Declaring a Scanner As Reentrant - %option reentrant (--reentrant) must be specified. +When using the default C/C++ back end %option reentrant (--reentrant) must be specified. Notice that @code{%option reentrant} is specified in the above example (@pxref{Reentrant Example}. Had this option not been specified, @@ -4146,6 +4204,8 @@ complaining. You may explicitly specify @code{%option noreentrant}, if you do @emph{not} want a reentrant scanner, although it is not necessary. The default is to generate a non-reentrant scanner. +All scanners made with other back ends are reentrant. + @node Extra Reentrant Argument, Global Replacement, Specify Reentrant, Reentrant Detail @subsection The Extra Argument @@ -4174,9 +4234,12 @@ always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, see @ref{Reentrant Functions}. Note that preprocessor macros, such as -@code{yyebegin()}, @code{yyecho()}, and @code{yyreject()}, do not take this +@code{yybegin()}, @code{yyecho()}, and @code{yyreject()}, do not take this additional argument. +The type name @code{yscan_t} follows C conventions. It mmay differ in +other target languages. + @node Global Replacement, Init and Destroy Functions, Extra Reentrant Argument, Reentrant Detail @subsection Global Variables Replaced By Macros @@ -4228,6 +4291,9 @@ after @code{yylex}, respectively. @end verbatim @end example +(The type name and declaration syntax will be different in target +languages other thab C/C++.) + The function @code{yylex_init} must be called before calling any other function. The argument to @code{yylex_init} is the address of an uninitialized pointer to be filled in by @code{yylex_init}, overwriting @@ -4325,7 +4391,7 @@ The above code may be called from within an action like this: @end verbatim @end example -You may find that @code{%option header-file} is particularly useful for generating +In C and C++, you may find that @code{%option header-file} is particularly useful for generating prototypes of all the accessor functions. @xref{option-header}. @node Extra Data, About yyscan_t, Accessor Methods, Reentrant Detail @@ -4460,7 +4526,7 @@ The following Functions are available in a reentrant scanner: There are no ``set'' functions for yytext and yyleng. This is intentional. -The following Macro shortcuts are available in actions in a reentrant +In the C/C++ back end, the following macro shortcuts are available in actions in a reentrant scanner: @example @@ -4790,7 +4856,12 @@ override the default behavior. @node The Default Memory Management, Overriding The Default Memory Management, Memory Management, Memory Management @section The Default Memory Management -Flex allocates dynamic memory during initialization, and once in a while from +This section applies only to target languages wuth manual memory +allocation, including the default C/C++ back end. If your target +language has garbage collection you can igore it. + +A Flex-generated scanner +allocates dynamic memory during initialization, and once in a while from within a call to yylex(). Initialization takes place during the first call to yylex(). Thereafter, flex may reallocate more memory if it needs to enlarge a buffer. As of version 2.5.9 Flex will clean up all memory when you call @code{yylex_destroy} @@ -4980,6 +5051,8 @@ but none of them at the same time. The serialization feature allows the tables to be loaded at runtime, before scanning begins. The tables may be discarded when scanning is finished. +Note: This feature is available only when using the C/C++ back end. + @menu * Creating Serialized Tables:: * Loading and Unloading Serialized Tables:: -- cgit v1.2.1 From 956ac03b7d84f260ada4a4ddeef7174e827442be Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Oct 2020 11:05:12 -0400 Subject: Refactor YY_INPUT so it calls a new yyread() internal function.... ...rather than splicing a bunch of exposed guts into the middle of yylex(). yyread() is put in the set of functions that gets prefix-modified. This means buffer refill can be documented without C-specific references to YY_INPUT. It should also enable actually having a non-macro replacement for YY_INPUT, with a bit more work. --- src/FlexLexer.h | 3 +- src/cpp-flex.skl | 174 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 93 insertions(+), 84 deletions(-) diff --git a/src/FlexLexer.h b/src/FlexLexer.h index c4dad2b..84de9b5 100644 --- a/src/FlexLexer.h +++ b/src/FlexLexer.h @@ -139,6 +139,7 @@ public: void yypush_buffer_state( yy_buffer_state* new_buffer ); void yypop_buffer_state(); + virtual int yyread(char *buf, size_t); virtual int yylex(); virtual void switch_streams( std::istream& new_in, std::ostream& new_out ); virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 ); @@ -148,7 +149,7 @@ protected: virtual int LexerInput( char* buf, int max_size ); virtual void LexerOutput( const char* buf, int size ); virtual void LexerError( const char* msg ); - + void yyunput( int c, char* buf_ptr ); int yyinput(); diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index c6b4c9a..45932f8 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -124,6 +124,7 @@ m4_ifelse(M4_MODE_PREFIX,yy,, #define yyalloc M4_MODE_PREFIX[[alloc]] #define yyrealloc M4_MODE_PREFIX[[realloc]] #define yyfree M4_MODE_PREFIX[[free]] +#define yyread M4_MODE_PREFIX[[read]] ) %endif %endif @@ -1503,61 +1504,101 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +%if-c-only +static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} +%endif +%if-c++-only +void yyFlexLexer::LexerError( const char* msg ) { + M4_YY_DECL_GUTS_VAR(); + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} +%endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +%if-c-only +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) +%endif +%if-c++-only +#define YY_FATAL_ERROR(msg) LexerError( msg ) +%endif +#endif + +/* Legacy interface */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size M4_YY_CALL_LAST_ARG);} while (0) /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -%if-c-only \ -m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ \ - errno=0; \ - while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - }\ -]]) \ -m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -]]) \ -%endif \ -\ -%if-c++-only C++ definition \ - if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); +%if-c++-only +int yyFlexLexer::yyread(char *buf, size_t max_size) { +%endif +%if-c-only +static int yyread(char *buf, size_t max_size M4_YY_PROTO_LAST_ARG) { +%endif + int result; + M4_YY_DECL_GUTS_VAR(); +%if-c-only +m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ + errno=0; + while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) + { + if( errno != EINTR) + { + YY_FATAL_ERROR( "input in flex scanner failed" ); + break; + } + errno=0; + clearerr(yyin); + } +]]) +m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) + { + int c = '*'; + int n; + for ( n = 0; n < max_size && + (c = getc( yyin )) != EOF && c != '\n'; ++n ) + buf[n] = (char) c; + if ( c == '\n' ) + buf[n++] = (char) c; + if ( c == EOF && ferror( yyin ) ) + YY_FATAL_ERROR( "input in flex scanner failed" ); + result = n; + } + else + { + errno=0; + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) + { + if( errno != EINTR) + { + YY_FATAL_ERROR( "input in flex scanner failed" ); + break; + } + errno=0; + clearerr(yyin); + } + } +]]) %endif +%if-c++-only C++ definition + if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) + YY_FATAL_ERROR( "input in flex scanner failed" ); +%endif + return result; +} #endif ]]) @@ -1577,19 +1618,6 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_START_STACK_INCR 25 #endif -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -%if-c-only -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) -%endif -%if-c++-only -#define YY_FATAL_ERROR(msg) LexerError( msg ) -%endif -#endif -]]) - %if-tables-serialization structures and prototypes m4preproc_include(`tables_shared.h') @@ -3338,26 +3366,6 @@ int yyFlexLexer::yy_top_state() } ]]) -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -%if-c-only -static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} -%endif -%if-c++-only -void yyFlexLexer::LexerError( const char* msg ) { - M4_YY_DECL_GUTS_VAR(); - std::cerr << msg << std::endl; - exit( YY_EXIT_FAILURE ); -} -%endif - /* Redefine yyless() so it works in section 3 code. */ #undef yyless -- cgit v1.2.1 From cecae8b6aa36414dfb390108282a36f82535dfbe Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Oct 2020 13:04:57 -0400 Subject: Implement and document %noyyread, replacing YY_INPUT. --- doc/flex.texi | 75 +++++++++++++++++++++++++++----------------------------- src/cpp-flex.skl | 3 +++ src/flexdef.h | 1 + src/main.c | 3 +++ src/scan.l | 1 + 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 90c8aa5..46844fa 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1164,11 +1164,10 @@ Also note that you cannot use @code{%array} with C++ scanner classes In target langages with automatic memory allocation and arrays none of this applies; you can expect @code{yytext} to dynamically resize -itself, calls to the @code{unput()}will not destroy the present +itself, calls to the @code{unput()} will not destroy the present contents of @code{yytext}, and you will never get a run-time error -from calls to the @code{unput()} function destroys the present -contents of @code{yytext} except in the extremely unlikely case that -your scanner cannot allocate more memory. +from calls to the @code{unput()} function except in the extremely +unlikely case that your scanner cannot allocate more memory. @node Actions, Generated Scanner, Matching, Top @chapter Actions @@ -1460,7 +1459,7 @@ avoid a name clash with the @code{C++} stream by the name of @cindex YY_FLUSH_BUFFER @code{YY_FLUSH_BUFFER;} flushes the scanner's internal buffer so that the next time the scanner attempts to match a token, it will first -refill the buffer using @code{YY_INPUT()} (@pxref{Generated Scanner}). +refill the buffer using @code{yyread()} (@pxref{Generated Scanner}). This action is a special case of the more general @code{yy_flush_buffer;} function, described below (@pxref{Multiple Input Buffers}) @@ -1553,7 +1552,7 @@ better to use @code{YY_FLUSH_BUFFER} (@pxref{Actions}). Note that @code{INITIAL} (@pxref{Start Conditions}). In C, an input stream is a a @code{FILE *} pointer. This pointer -can be NULL, if you've set up @code{YY_INPUT} to scan from a source other +can be NULL, if you've set up a @code{%yyread()} hook to scan from a source other than @code{yyin}. @cindex RETURN, within actions @@ -1561,46 +1560,41 @@ If @code{yylex()} stops scanning due to executing a @code{return} statement in one of the actions, the scanner may then be called again and it will resume scanning where it left off. -@cindex YY_INPUT +@cindex yyread By default (and for purposes of efficiency), C/C++ scanners use block-reads rather than simple @code{getc()} calls to read characters from @file{yyin}. The nature of how it gets its input can be controlled -by defining the @code{YY_INPUT} macro. The calling sequence for -@code{YY_INPUT()} is @code{YY_INPUT(buf,result,max_size)}. Its action +by redefining the @code{yyread} function used to fill the scanner buffer. The calling sequence for +@code{yyread()} is @code{yyread(buf,max_size)}. Its action is to place up to @code{max_size} characters in the character array -@code{buf} and return in the integer variable @code{result} either the +@code{buf} and return either the number of characters read or the constant @code{YY_NULL} (0 on Unix -systems) to indicate @samp{EOF}. The default @code{YY_INPUT} reads from +systems) to indicate @samp{EOF}. The default @code{yyread()} reads from the global file-pointer @file{yyin}. -@cindex YY_INPUT, overriding -Here is a sample definition of @code{YY_INPUT} (in the definitions +@cindex yyread(), overriding +#cindex %noyyread +Here is a sample redefinition of @code{yyread()} (in the definitions section of the input file): @example @verbatim - %{ - #define YY_INPUT(buf,result,max_size) \ - { \ - int c = getchar(); \ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ - } - %} +int yyread(char *buf, size_t max_size) { + int c = getchar(); + return (c == EOF) ? YY_NULL : (buf[0] = c, 1); +} @end verbatim @end example This definition will change the input processing to occur one character at a time. -YY_INPUT is not available in target languages other than C/C++. It -dates from a time in the 1970s when efficiency optimizations were a -far more pressing problem than they are today, and is probably extinct -in the wild. If lack of it poses a problem for a port you are doing, -file an issue report with the Flex mauntainers and we will attempt to -assist you. +When Flex sees the @code{%noyyread} option, it omits the default +definition from the boilerplate in the rest of the parser. Your +@code{yyread()} function then replaces it. @cindex yywrap() -When the scanner receives an end-of-file indication from YY_INPUT, it +When the scanner receives an end-of-file indication from @code{yyread()}, it then checks the @code{yywrap()} function. If @code{yywrap()} returns false (zero), then it is assumed that the function has gone ahead and set up @file{yyin} to point to another input file, and scanning @@ -2042,8 +2036,8 @@ stack} directive (@pxref{Scanner Options}). Some scanners (such as those which support ``include'' files) require reading from several input streams. As @code{flex} scanners do a large amount of buffering, one cannot control where the next input will be -read from by simply writing a @code{YY_INPUT()} which is sensitive to -the scanning context. @code{YY_INPUT()} is only called when the scanner +read from by simply writing a @code{yyread()} which is sensitive to +the scanning context. @code{yyread()} is only called when the scanner reaches the end of its buffer, which may be a long time after scanning a statement such as an @code{include} statement which requires switching the input source. @@ -2076,7 +2070,7 @@ safely initialize @code{YY_BUFFER_STATE} variables to @code{((YY_BUFFER_STATE) correctly declare input buffers in source files other than that of your scanner. Note that the @code{FILE} pointer in the call to @code{yy_create_buffer} is only used as the value of @file{yyin} seen by -@code{YY_INPUT}. If you redefine @code{YY_INPUT()} so it no longer uses +@code{yyread()}. If you redefine @code{yyread()} so it no longer uses @file{yyin}, then you can safely pass a NULL @code{FILE} pointer to @code{yy_create_buffer}. You select a particular buffer to scan from using: @@ -2129,7 +2123,7 @@ becomes the new current state. This function discards the buffer's contents, so the next time the scanner attempts to match a token from the buffer, it will first fill the buffer anew using -@code{YY_INPUT()}. +@code{yyread()}. @deftypefun YY_BUFFER_STATE yy_new_buffer ( FILE *file, int size ) @end deftypefun @@ -3200,7 +3194,7 @@ or @samp{-CF}. Using @samp{-Cr} can cause strange behavior if, for example, you read from @file{yyin} using @code{stdio} prior to calling the scanner (because the scanner will miss whatever text your previous reads left in the @code{stdio} input buffer). @samp{-Cr} has no effect -if you define @code{YY_INPUT()} (@pxref{Generated Scanner}). It may +if you define @code{yyread()} (@pxref{Generated Scanner}). It may be a no-op or enable different optimizations in back ends other than the default C/C++ one. @end table @@ -5723,7 +5717,7 @@ your scanner is free of backtracking (verified using @code{flex}'s @samp{-b} fla AND you run your scanner interactively (@samp{-I} option; default unless using special table compression options), @item -AND you feed it one character at a time by redefining @code{YY_INPUT} to do so, +AND you feed it one character at a time by redefining @code{yyread()} to do so, @end itemize then every time it matches a token, it will have exhausted its input @@ -5739,8 +5733,8 @@ piecemeal; @code{select()} could inform you that the beginning of a token is available, you call @code{yylex()} to get it, but it winds up blocking waiting for the later characters in the token. -Here's another way: Move your input multiplexing inside of @code{YY_INPUT}. That -is, whenever @code{YY_INPUT} is called, it @code{select()}'s to see where input is +Here's another way: Move your input multiplexing inside of @code{yyread()}. That +is, whenever @code{yyread()} is called, it @code{select()}'s to see where input is available. If input is available for the scanner, it reads and returns the next byte. If input is available from another source, it calls whatever function is responsible for reading from that source. (If no input is @@ -5756,7 +5750,7 @@ that @code{flex} block-buffers the input it reads from @code{yyin}. This means ``outermost'' @code{yylex()}, when called, will automatically slurp up the first 8K of input available on yyin, and subsequent calls to other @code{yylex()}'s won't see that input. You might be tempted to work around this problem by -redefining @code{YY_INPUT} to only return a small amount of text, but it turns out +redefining @code{yyread()} to only return a small amount of text, but it turns out that that approach is quite difficult. Instead, the best solution is to combine all of your scanners into one large scanner, using a different exclusive start condition for each. @@ -5767,7 +5761,7 @@ exclusive start condition for each. There is no way to write a rule which is ``match this text, but only if it comes at the end of the file''. You can fake it, though, if you happen to have a character lying around that you don't allow in your input. -Then you redefine @code{YY_INPUT} to call your own routine which, if it sees +Then you redefine @code{yyread()} to call your own routine which, if it sees an @samp{EOF}, returns the magic character first (and remembers to return a real @code{EOF} next time it's called). Then you could write: @@ -6126,7 +6120,7 @@ Those are internal variables pointing into the AT&T scanner's input buffer. I imagine they're being manipulated in user versions of the @code{input()} and @code{unput()} functions. If so, what you need to do is analyze those functions to figure out what they're doing, and then replace @code{input()} with an appropriate definition of -@code{YY_INPUT}. You shouldn't need to (and must not) replace +@code{yyread()}. You shouldn't need to (and must not) replace @code{flex}'s @code{unput()} function. @node Is there a way to make flex treat NUL like a regular character? @@ -6219,7 +6213,7 @@ situation. It is possible that some other globals may need resetting as well. While this is the right idea, it has two problems. The first is that it's possible that @code{flex} will request less than @code{YY_READ_BUF_SIZE} during -an invocation of @code{YY_INPUT} (or that your input source will return less +an invocation of @code{yyread()} (or that your input source will return less even though @code{YY_READ_BUF_SIZE} bytes were requested). The second problem is that when refilling its internal buffer, @code{flex} keeps some characters from the previous buffer (because usually it's in the middle of a match, @@ -8800,6 +8794,9 @@ ECHO: Replaced by yyecho() @item #define YYLMAX: Replaced by the %yylmax option. + +@item +#define YY_INPUT: Replaced by the @code{noyyread} option. @end itemize @node Indices, , Appendices, Top diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 45932f8..0e12f32 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1537,6 +1537,8 @@ void yyFlexLexer::LexerError( const char* msg ) { /* Legacy interface */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size M4_YY_CALL_LAST_ARG);} while (0) + +m4_ifdef( [[M4_MODE_USER_YYREAD]], , [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ @@ -1601,6 +1603,7 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ } #endif ]]) +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ diff --git a/src/flexdef.h b/src/flexdef.h index a5f98b4..75ff950 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -356,6 +356,7 @@ struct ctrl_bundle_t { bool yytext_is_array; // if true (i.e., %array directive), then declare // yytext as array instead of a character pointer. // Nice and inefficient. + bool noyyread; // User supplied a yyread function, don't generate default // flags corresponding to the huge mass of --no-yy options bool no_yy_push_state; bool no_yy_pop_state; diff --git a/src/main.c b/src/main.c index 391d5a1..9865e84 100644 --- a/src/main.c +++ b/src/main.c @@ -1571,6 +1571,9 @@ void readin (void) if (ctrl.interactive == trit_true) visible_define ( "M4_MODE_INTERACTIVE"); + if (ctrl.noyyread) + visible_define("M4_MODE_USER_YYREAD"); + // Kluge to get around the fact that the %if-not-reentrant and // %if-c-only gates can't be combined by nesting one inside the // other. diff --git a/src/scan.l b/src/scan.l index 975ba41..94b5d72 100644 --- a/src/scan.l +++ b/src/scan.l @@ -415,6 +415,7 @@ M4QEND "]""]" yylineno ctrl.do_yylineno = option_sense; yymore yymore_really_used = option_sense; yywrap ctrl.do_yywrap = option_sense; + yyread ctrl.noyyread = !option_sense; yy_push_state ctrl.no_yy_push_state = ! option_sense; yy_pop_state ctrl.no_yy_pop_state = ! option_sense; -- cgit v1.2.1 From f8225f259e5b61b972381ad37c5d386a8119124c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Oct 2020 15:46:05 -0400 Subject: Implement and document yystart(), replacing YY_START. As usual, legacy interface left in place but deprecated. --- doc/flex.texi | 23 +++++++++++++---------- src/cpp-flex.skl | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 46844fa..8b88134 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1862,20 +1862,20 @@ following fashion: @end verbatim @end example -@cindex YY_START, example +@cindex yystart(), example Furthermore, you can access the current start condition using the -integer-valued @code{YY_START} macro. For example, the above +integer-valued @code{yystart()} macro. For example, the above assignments to @code{comment_caller} could instead be written -@cindex getting current start state with YY_START +@cindex getting current start state with yystart() @example @verbatim - comment_caller = YY_START; + comment_caller = yystart(); @end verbatim @end example -@vindex YY_START -Flex provides @code{YYSTATE} as an alias for @code{YY_START} (since that +@vindex yystart() +Flex provides @code{YYSTATE} as an alias for @code{yystart()} (since that is what's used by AT&T @code{lex}). For historical reasons, start conditions do not have their own @@ -2014,7 +2014,7 @@ The program execution aborts, if there is no state on the stack. @deftypefun int yy_top_state () returns the top of the stack without altering the stack's contents if a top state on the stack exists or the current state via -@code{YY_START} +@code{yystart()} otherwise. @end deftypefun @@ -2484,8 +2484,8 @@ by the user. @item YY_CURRENT_BUFFER returns a @code{YY_BUFFER_STATE} handle to the current buffer. -@vindex YY_START -@item YY_START +@vindex yystart() +@item yystart() returns an integer value corresponding to the current start condition. You can subsequently use this value with @code{yybegin()} to return to that start condition. @@ -4794,7 +4794,7 @@ YY_AT_BOL() @item %yydecl @item -YY_START +yystart() @item YY_USER_ACTION @item @@ -8797,6 +8797,9 @@ ECHO: Replaced by yyecho() @item #define YY_INPUT: Replaced by the @code{noyyread} option. + +@item +YYSTART: Replaced by yystart() @end itemize @node Indices, , Appendices, Top diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 0e12f32..e918b22 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -420,6 +420,8 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ +#define yystart() ((YY_G(yy_start) - 1) / 2) +/* Legacy interfaces */ #define YY_START ((YY_G(yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ -- cgit v1.2.1 From 526be1f459bdc907b9867609214e3667c040cdae Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Oct 2020 16:55:08 -0400 Subject: Introduce the term "rule hook" so we can use the term "macro" less. Non-C/C++ back ends won't have macros, so the documentation should treat macro-ness as an implementation detail when it has to be mentioned at all - and usually it doesn't. The key thing about rule hooks like yyless(), yymore() etc. isn't that they're macros, it's that they can only br used in rule actions (e.g. inside the body of the genetated tyylex code. This documentation patch removes the term "macro" where it isn't needed. --- doc/flex.texi | 97 +++++++++++++++++++++++++++++++------------------------- src/cpp-flex.skl | 6 ++-- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 8b88134..a8660e6 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -4,7 +4,7 @@ @include version.texi @settitle Lexical Analysis With Flex, for Flex @value{VERSION} @set authors Vern Paxson, Will Estes and John Millaway -@c "Macro Hooks" index +@c "User Hooks" index @defindex hk @c "Options" index @defindex op @@ -273,7 +273,7 @@ Appendices Indices * Concept Index:: -* Index of Functions and Macros:: +* Index of Functions:: * Index of Variables:: * Index of Data Types:: * Index of Hooks:: @@ -551,8 +551,8 @@ A @code{%top} block is similar to a @samp{%@{} ... @samp{%@}} block, except that the code in a @code{%top} block is relocated to the @emph{top} of the generated file, before any flex definitions @footnote{Actually, @code{yyIN_HEADER} is defined before the @samp{%top} block.}. -The @code{%top} block is useful when you want certain preprocessor macros to be -defined or certain files to be included before the generated code. +The @code{%top} block is useful when you want definitions to be +evaluated or certain files to be included before the generated code. The single characters, @samp{@{} and @samp{@}} are used to delimit the @code{%top} block, as show in the example below: @@ -1238,9 +1238,9 @@ in any way. Actions are free to modify @code{yyleng} except they should not do so if the action also includes use of @code{yymore()} (see below). -@cindex preprocessor macros, for use in actions -There are a number of special directives which can be included within an -action: +@cindex rule hooks, for use in actions +There are a number of special hooks which can be included within an +action. @table @code @item yyecho() @@ -1364,9 +1364,6 @@ string to be scanned again. Unless you've changed how the scanner will subsequently process its input (using @code{yybegin()}, for example), this will result in an endless loop. -Note that @code{yyless()} is a macro and can only be used in the flex -input file, not from other source files. - @cindex unput() @cindex pushing back characters with unput @code{unput(c)} puts the character @code{c} back onto the input stream. @@ -1473,10 +1470,10 @@ action. It terminates the scanner and returns a 0 to the scanner's caller, indicating ``all done''. By default, @code{yyterminate()} is also called when an end-of-file is encountered. It may be redefined. -When the target language is C, @code{yyterminate()} is a macro. -Redefining it using the C preprocessor in your definitions section +When the target language is C/C++, @code{yyterminate()} is a macro. +Redefining it using the C/C++ preprocessor in your definitions section is allowed, but not recommended as doing this makes code more -difficult to port out of C. In other target languages you can define +difficult to port out of C/C++. In other target languages you can define @code{yyterminate()} as a function; Flex will notice this and not generate a default into the scanner. @@ -1486,7 +1483,7 @@ generate a default into the scanner. @cindex yylex(), in generated scanner The output of @code{flex} is a file wity the sem name @file{lex.yy}, which contains the scanning routine @code{yylex()}, a number of tables used by it for -matching tokens, and a number of auxiliary routines and macros. By +matching tokens, and a number of auxiliary routines. By default in C, @code{yylex()} is declared as follows: @example @@ -1864,7 +1861,7 @@ following fashion: @cindex yystart(), example Furthermore, you can access the current start condition using the -integer-valued @code{yystart()} macro. For example, the above +integer-valued @code{yystart()} rule hook. For example, the above assignments to @code{comment_caller} could instead be written @cindex getting current start state with yystart() @@ -1874,17 +1871,11 @@ assignments to @code{comment_caller} could instead be written @end verbatim @end example -@vindex yystart() -Flex provides @code{YYSTATE} as an alias for @code{yystart()} (since that -is what's used by AT&T @code{lex}). - For historical reasons, start conditions do not have their own name-space within the generated scanner. The start condition names are unmodified in the generated scanner and generated header. @xref{option-header}. @xref{option-prefix}. - - Finally, here's an example of how to match C-style quoted strings using exclusive start conditions, including expanded escape sequences (but not including checking for a string that's too long): @@ -2132,9 +2123,10 @@ is an alias for @code{yy_create_buffer()}, provided for compatibility with the C++ use of @code{new} and @code{delete} for creating and destroying dynamic objects. -@cindex YY_CURRENT_BUFFER, and multiple buffers Finally, the macro -@code{YY_CURRENT_BUFFER} macro returns a @code{YY_BUFFER_STATE} handle to the -current buffer. It should not be used as an lvalue. +@cindex YY_CURRENT_BUFFER, and multiple buffers +Finally, the macro @code{YY_CURRENT_BUFFER} macro returns a +@code{YY_BUFFER_STATE} handle to the current buffer. It should not be +used as an lvalue. @cindex EOF, example using multiple input buffers Here are two examples of using these features for writing a scanner @@ -2401,15 +2393,16 @@ the buffer that is (or is not) to be considered interactive. @cindex BOL, setting it @findex yy_set_bol -The macro @code{yy_set_bol(at_bol)} can be used to control whether the +The rule hook @code{yy_set_bol(at_bol)} can be used to control whether the current buffer's scanning context for the next token match is done as though at the beginning of a line. A non-zero macro argument makes rules anchored with @samp{^} active, while a zero argument makes @samp{^} rules inactive. @cindex BOL, checking the BOL flag -@findex YY_AT_BOL -The macro @code{YY_AT_BOL()} returns true if the next token scanned from +@cindex rule hook +@findex yy_at_bol +The rule hook @code{yy_at_bol()} returns true if the next token scanned from the current buffer will have @samp{^} rules active, false otherwise. @cindex actions, redefining YY_BREAK @@ -2459,7 +2452,9 @@ holds the length of the current token. @vindex yyin @item FILE *yyin -is the file which by default @code{flex} reads from. It may be +is the file which by default @code{flex} reads from. +In target languages other than C/C++, expect it to have +whatever tyoe is associated with I/O streams. It may be redefined but doing so only makes sense before scanning begins or after an EOF has been encountered. Changing it in the midst of scanning will have unexpected results since @code{flex} buffers its input; use @@ -2469,7 +2464,9 @@ file and then call the scanner again to continue scanning. @findex yyrestart @item void yyrestart( FILE *new_file ) -may be called to point @file{yyin} at the new input file. The +may be called to point @file{yyin} at the new input file. +In target languages other than C/C++, expect the argument to have +whatever tyoe is associated with I/O streams. The switch-over to the new file is immediate (any previously buffered-up input is lost). Note that calling @code{yyrestart()} with @file{yyin} as an argument thus throws away the current input buffer and continues @@ -2479,6 +2476,8 @@ scanning the same input file. @item FILE *yyout is the output stream to which @code{yyecho()} actions are done. It can be reassigned by the user. +In target languages other than C/C++, expect it to have +whatever tyoe is associated with I/O streams. @vindex YY_CURRENT_BUFFER @item YY_CURRENT_BUFFER @@ -2614,7 +2613,7 @@ you use @code{%option stack)}. @item --header-file=FILE, @code{%option header-file="FILE"} instructs flex to write a C header to @file{FILE}. This file contains function prototypes, extern variables, and types used by the scanner. -Only the external API is exported by the header file. Many macros that +Only the external API is exported by the header file. Many rule hooks that are usable from within scanner actions are not exported to the header file. This is due to namespace problems and the goal of a clean external API. @@ -2625,6 +2624,7 @@ is substituted with the appropriate prefix. The @samp{--header-file} option is not compatible with the @samp{--c++} option, since the C++ scanner provides its own header in @file{yyFlexLexer.h}. +This option will generally be a no-op under other target languages. @anchor{option-outfile} @@ -3454,8 +3454,8 @@ which degrade performance. These are, from most expensive to least: with the first two all being quite expensive and the last two being quite cheap. Note also that @code{unput()} is implemented as a routine -call that potentially does quite a bit of work, while @code{yyless()} is -a quite-cheap macro. So if you are just putting back some excess text +call that potentially does quite a bit of work, while @code{yyless()} +isvery inexpensive. So if you are just putting back some excess text you scanned, use @code{yyless()}. @code{yyreject()} should be avoided at all costs when performance is @@ -4205,7 +4205,7 @@ All scanners made with other back ends are reentrant. @cindex reentrant, calling functions @vindex yyscanner (reentrant only) -All functions take one additional argument: @code{yyscanner}. +All functions other than rule hooks take one additional argument: @code{yyscanner}. Notice that the calls to @code{yy_push_state} and @code{yy_pop_state} both have an argument, @code{yyscanner} , that is not present in a @@ -4227,10 +4227,13 @@ typedef'd to @code{void *}) and it is always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, -see @ref{Reentrant Functions}. Note that preprocessor macros, such as -@code{yybegin()}, @code{yyecho()}, and @code{yyreject()}, do not take this +see @ref{Reentrant Functions}. Note that rule hooks, such as +@code{yybegin()}, @code{yyecho()}, @code{yyreject()}, and @code{yystart()}, do not take this additional argument. +Rule hooks don't need to take a scanner context argument because, +under the hood, the context is supplied by the call location. + The type name @code{yscan_t} follows C conventions. It mmay differ in other target languages. @@ -4483,7 +4486,7 @@ directly. In particular, you should never attempt to free it (use @code{yylex_destroy()} instead.) @node Reentrant Functions, , Reentrant Detail, Reentrant -@section Functions and Macros Available in Reentrant C Scanners +@section Functions Available in Reentrant Scanners The following Functions are available in a reentrant scanner: @@ -4787,7 +4790,7 @@ yy_set_interactive() @item yy_set_bol() @item -YY_AT_BOL() +yy_at_bol() <> @item <*> @@ -7659,7 +7662,7 @@ I agree that this is counter-intuitive for yyless(), given its functional description (it's less so for unput(), depending on whether you're unput()'ing new text or scanned text). But I don't plan to change it any time soon, as it's a pain to do so. Consequently, -you do indeed need to use yy_set_bol() and YY_AT_BOL() to tweak +you do indeed need to use yy_set_bol() and yy_at_bol() to tweak your scanner into the behavior you desire. Sorry for the less-than-completely-satisfactory answer. @@ -8787,7 +8790,7 @@ BEGIN: Replaced by yybegin() ECHO: Replaced by yyecho() @item -#define REJECT: Replaced by yyreject() +REJECT: Replaced by yyreject() @item #define YY_DECL: Replaced by the %yydecl directive. @@ -8800,34 +8803,40 @@ ECHO: Replaced by yyecho() @item YYSTART: Replaced by yystart() + +@item +YY_AT_BOL: Replaced by yy_at_bol() @end itemize +Flex also provides @code{YYSTATE} as an alias for @code{yystart()} +(since that is what's used by AT&T @code{lex}). + @node Indices, , Appendices, Top @unnumbered Indices @menu * Concept Index:: -* Index of Functions and Macros:: +* Index of Functions:: * Index of Variables:: * Index of Data Types:: * Index of Hooks:: * Index of Scanner Options:: @end menu -@node Concept Index, Index of Functions and Macros, Indices, Indices +@node Concept Index, Index of Functions, Indices, Indices @unnumberedsec Concept Index @printindex cp -@node Index of Functions and Macros, Index of Variables, Concept Index, Indices -@unnumberedsec Index of Functions and Macros +@node Index of Functions, Index of Variables, Concept Index, Indices +@unnumberedsec Index of Functions This is an index of functions and preprocessor macros that look like functions. For macros that expand to variables or constants, see @ref{Index of Variables}. @printindex fn -@node Index of Variables, Index of Data Types, Index of Functions and Macros, Indices +@node Index of Variables, Index of Data Types, Index of Functions, Indices @unnumberedsec Index of Variables This is an index of variables, constants, and preprocessor macros diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index e918b22..4af7074 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -688,6 +688,8 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } +#define yy_at_bol() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +/* Legacy interface */ #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) ]]) @@ -1793,12 +1795,12 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + yy_at_bol()];]]) m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[YY_G(yy_start)];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ yy_current_state = YY_G(yy_start); -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += YY_AT_BOL();]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yy_at_bol();]]) /* Set up for storing up states. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ YY_G(yy_state_ptr) = YY_G(yy_state_buf); -- cgit v1.2.1 From dad680611b8373cac2e5dc60e7552535bded79c2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Oct 2020 21:55:00 -0400 Subject: Deprecate input(); document yyinput() for the C back end... ...leaving an "input" macro in place for legacy compatibility. input() had already become yyinput() in the C++ back end in order to avoid collision with predefibed C++ inoput. In a multi-language world, this is good policy in general. There's no real reason for C to be different, and excellent reason to pull all possible entry points into the yy namespace. --- doc/flex.texi | 26 ++++++++++++-------------- src/cpp-flex.skl | 28 +++++++++------------------- src/flexdef.h | 2 +- src/main.c | 5 ++--- src/scan.l | 5 +++-- tests/yyextra.l | 2 +- 6 files changed, 28 insertions(+), 40 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index a8660e6..ac19d10 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1409,8 +1409,8 @@ elsewhere, or build your scanner using @code{%array} instead Finally, note that you cannot put back @samp{EOF} to attempt to mark the input stream with an end-of-file. -@cindex input() -@code{input()} reads the next character from the input stream. For +@cindex yyinput() +@code{yyinput()} reads the next character from the input stream. For example, the following is one way to eat up C comments: @cindex comments, discarding @@ -1423,13 +1423,13 @@ example, the following is one way to eat up C comments: for ( ; ; ) { - while ( (c = input()) != '*' && + while ( (c = yyinput()) != '*' && c != EOF ) ; /* eat up text of comment */ if ( c == '*' ) { - while ( (c = input()) == '*' ) + while ( (c = yyinput()) == '*' ) ; if ( c == '/' ) break; /* found the end */ @@ -1445,13 +1445,6 @@ example, the following is one way to eat up C comments: @end verbatim @end example -@cindex input(), and C++ -@cindex yyinput() -(Note that if the scanner is compiled using @code{C++}, then -@code{input()} is instead referred to as @b{yyinput()}, in order to -avoid a name clash with the @code{C++} stream by the name of -@code{input}.) - @cindex flushing the internal buffer @cindex YY_FLUSH_BUFFER @code{YY_FLUSH_BUFFER;} flushes the scanner's internal buffer so that @@ -4607,7 +4600,8 @@ a per-scanner (single global variable) basis. @code{yylineno} is not part of the POSIX specification. @item -The @code{input()} routine is not redefinable, though it may be called +The @code{input()} routine (which has become @code{yyinput()} in modern +Flex) is not redefinable, though it may be called to read characters following whatever has been matched by a rule. If @code{input()} encounters an end-of-file the normal @code{yywrap()} processing is done. A ``real'' end-of-file is returned by @@ -5439,7 +5433,7 @@ other characters. Dynamic resizing of the input buffer is slow, as it entails rescanning all the text matched so far by the current (generally huge) token. Due to both buffering of input and read-ahead, you cannot intermix calls to @file{} routines, such as, @b{getchar()}, -with @code{flex} rules and expect it to work. Call @code{input()} +with @code{flex} rules and expect it to work. Call @code{yyinput()} instead. The total table entries listed by the @samp{-v} flag excludes the number of table entries needed to determine what rule has been matched. The number of entries is equal to the number of DFA states if @@ -6235,7 +6229,7 @@ example, @end example (You need to be careful to update your bookkeeping if you use @code{yymore(}), -@code{yyless()}, @code{unput()}, or @code{input()}.) +@code{yyless()}, @code{unput()}, or @code{yyinput()}.) @node How do I use my own I/O classes in a C++ scanner? @section How do I use my own I/O classes in a C++ scanner? @@ -8806,6 +8800,10 @@ YYSTART: Replaced by yystart() @item YY_AT_BOL: Replaced by yy_at_bol() + +@item +input(): Replaced by yyinput(). This function was already yyinput() +in the C++ back end. @end itemize Flex also provides @code{YYSTATE} as an alias for @code{yystart()} diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4af7074..fccecd9 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1424,18 +1424,17 @@ static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); #endif -m4_ifdef([[M4_MODE_NO_INPUT]], [[#define YY_NO_INPUT 1]]) +m4_ifdef([[M4_MODE_NO_YYINPUT]], [[#define YY_NO_YYINPUT 1]]) -#ifndef YY_NO_INPUT -%if-c-only Standard (non-C++) definition +#ifndef YY_NO_YYINPUT +//%if-c-only Standard (non-C++) definition %not-for-header -#ifdef __cplusplus static int yyinput ( M4_YY_PROTO_ONLY_ARG ); -#else -static int input ( M4_YY_PROTO_ONLY_ARG ); +#ifndef __cplusplus +#define input yyinput #endif %ok-for-header -%endif +//%endif #endif @@ -2720,13 +2719,8 @@ m4_ifdef( [[M4_MODE_YYLINENO]], #endif %if-c-only -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput (M4_YY_DEF_ONLY_ARG) -#else -static int input (M4_YY_DEF_ONLY_ARG) -#endif - +#ifndef YY_NO_YYINPUT +int yyinput (M4_YY_DEF_ONLY_ARG) %endif %if-c++-only int yyFlexLexer::yyinput() @@ -2774,11 +2768,7 @@ int yyFlexLexer::yyinput() if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { YY_NEW_FILE; } -#ifdef __cplusplus return yyinput(M4_YY_CALL_ONLY_ARG); -#else - return input(M4_YY_CALL_ONLY_ARG); -#endif case EOB_ACT_CONTINUE_SCAN: YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; @@ -2810,7 +2800,7 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ return c; } %if-c-only -#endif /* ifndef YY_NO_INPUT */ +#endif /* ifndef YY_NO_YYINPUT */ %endif /** Immediately switch to a different input stream. diff --git a/src/flexdef.h b/src/flexdef.h index 75ff950..df564fd 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -338,7 +338,7 @@ struct ctrl_bundle_t { bool never_interactive; // always use buffered input, don't check for tty. bool lex_compat; // (-l), maximize compatibility with AT&T lex bool long_align; // (-Ca flag), favor long-word alignment for speed - bool no_input; // Suppress use of imnput() + bool no_yyinput; // suppress use of yyinput() bool no_unistd; // suppress inclusion of unistd.h bool posix_compat; // (-X) maximize compatibility with POSIX lex char *prefix; // prefix for externally visible names, default "yy" diff --git a/src/main.c b/src/main.c index 9865e84..2a7d5c6 100644 --- a/src/main.c +++ b/src/main.c @@ -1585,8 +1585,8 @@ void readin (void) if (ctrl.prefix != NULL) visible_define_str ( "M4_MODE_PREFIX", ctrl.prefix); - if (ctrl.no_input) - visible_define("M4_MODE_NO_INPUT"); + if (ctrl.no_yyinput) + visible_define("M4_MODE_NO_YYINPUT"); if (ctrl.no_yy_push_state) visible_define("M4_YY_NO_PUSH_STATE"); @@ -1789,4 +1789,3 @@ void usage (void) backing_name, "flex", outfile_path, "flex"); } - diff --git a/src/scan.l b/src/scan.l index 94b5d72..31e41fd 100644 --- a/src/scan.l +++ b/src/scan.l @@ -384,7 +384,8 @@ M4QEND "]""]" ctrl.useecs = ctrl.usemecs = false; ctrl.use_read = ctrl.fulltbl = true; } - input ctrl.no_input = ! option_sense; + input ctrl.no_yyinput = ! option_sense; + yyinput ctrl.no_yyinput = ! option_sense; interactive ctrl.interactive = (trit)option_sense; lex-compat ctrl.posix_compat = option_sense; posix-compat ctrl.posix_compat = option_sense; @@ -659,7 +660,7 @@ M4QEND "]""]" */ && (cclval = ccllookup( nmstr )) != 0 ) { - if ( input() != ']' ) + if ( yyinput() != ']' ) synerr( _( "bad character class" ) ); yylval = cclval; diff --git a/tests/yyextra.l b/tests/yyextra.l index bf2a6eb..a1eff11 100644 --- a/tests/yyextra.l +++ b/tests/yyextra.l @@ -48,7 +48,7 @@ static void append_char (char c, yyscan_t scanner ); %} %option 8bit prefix="test" -%option nounput nomain noyywrap nodefault noinput +%option nounput nomain noyywrap nodefault noyyinput %option warn %option reentrant -- cgit v1.2.1 From 721622ea6e6aaf3aa7e55d939679f21e98b76d86 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Oct 2020 06:56:56 -0400 Subject: Rename unput() to yyunput(); follow through in option switches. This change was not strictly necessary to sever a preprocessor dependency nor make the API uniform aross both C and C++. But it cried out to be made, because now *all* the rule hooks are in the yy* namespace. This makes the API easier to document and remember. unput() is left in place as a compatibility macro for existing users, but only documented as a legacy interface. The "unput" variants of switches and options have also been retained. --- doc/flex.texi | 81 +++++++++++++++++++++++++++++--------------------------- src/FlexLexer.h | 2 +- src/cpp-flex.skl | 18 +++++++------ src/flexdef.h | 2 +- src/main.c | 8 +++--- src/options.c | 4 ++- src/options.h | 2 +- src/scan.l | 3 ++- 8 files changed, 64 insertions(+), 56 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index ac19d10..4e60555 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -205,7 +205,7 @@ FAQ * Can I fake multi-byte character support?:: * deleteme01:: * Can you discuss some flex internals?:: -* unput() messes up yy_at_bol:: +* yyunput() messes up yy_at_bol:: * The | operator is not doing what I want:: * Why can't flex understand this variable trailing context pattern?:: * The ^ operator isn't working:: @@ -1124,14 +1124,14 @@ in which case @code{yytext} will be an array. The advantage of using @code{%pointer} is substantially faster scanning and no buffer overflow when matching very large tokens (unless you run out of dynamic memory). The disadvantage is that you are restricted in how your actions can -modify @code{yytext} (@pxref{Actions}), and calls to the @code{unput()} +modify @code{yytext} (@pxref{Actions}), and calls to the @code{yyunput()} function destroys the present contents of @code{yytext}, which can be a considerable porting headache when moving between different @code{lex} versions. @cindex %array, advantages of The advantage of @code{%array} is that you can then modify @code{yytext} -to your heart's content, and calls to @code{unput()} do not destroy +to your heart's content, and calls to @code{yyunput()} do not destroy @code{yytext} (@pxref{Actions}). Furthermore, existing @code{lex} programs sometimes access @code{yytext} externally using declarations of the form: @@ -1155,7 +1155,7 @@ matching entire blocks of comments), bear in mind that each time the scanner must resize @code{yytext} it also must rescan the entire token from the beginning, so matching such tokens can prove slow. @code{yytext} presently does @emph{not} dynamically grow if a call to -@code{unput()} results in too much text being pushed back; instead, a +@code{yyunput()} results in too much text being pushed back; instead, a run-time error results. @cindex %array, with C++ @@ -1164,9 +1164,9 @@ Also note that you cannot use @code{%array} with C++ scanner classes In target langages with automatic memory allocation and arrays none of this applies; you can expect @code{yytext} to dynamically resize -itself, calls to the @code{unput()} will not destroy the present +itself, calls to the @code{yyunput()} will not destroy the present contents of @code{yytext}, and you will never get a run-time error -from calls to the @code{unput()} function except in the extremely +from calls to the @code{yyunput()} function except in the extremely unlikely case that your scanner cannot allocate more memory. @node Actions, Generated Scanner, Matching, Top @@ -1364,43 +1364,43 @@ string to be scanned again. Unless you've changed how the scanner will subsequently process its input (using @code{yybegin()}, for example), this will result in an endless loop. -@cindex unput() -@cindex pushing back characters with unput -@code{unput(c)} puts the character @code{c} back onto the input stream. +@cindex yyunput() +@cindex pushing back characters with yyunput +@code{yyunput(c)} puts the character @code{c} back onto the input stream. It will be the next character scanned. The following action will take the current token and cause it to be rescanned enclosed in parentheses. -@cindex unput(), pushing back characters -@cindex pushing back characters with unput() +@cindex yyunput(), pushing back characters +@cindex pushing back characters with yyunput() @example @verbatim { int i; - /* Copy yytext because unput() trashes yytext */ + /* Copy yytext because yyunput() trashes yytext */ char *yycopy = strdup( yytext ); - unput( ')' ); + yyunput( ')' ); for ( i = yyleng - 1; i >= 0; --i ) - unput( yycopy[i] ); - unput( '(' ); + yyunput( yycopy[i] ); + yyunput( '(' ); free( yycopy ); } @end verbatim @end example -Note that since each @code{unput()} puts the given character back at the +Note that since each @code{yyunput()} puts the given character back at the @emph{beginning} of the input stream, pushing back strings must be done back-to-front. -@cindex %pointer, and unput() -@cindex unput(), and %pointer -An important potential problem when using @code{unput()} in C (and, +@cindex %pointer, and yyunput() +@cindex yyunput(), and %pointer +An important potential problem when using @code{yyunput()} in C (and, generally, in target languages with C-like manual memory management) is that if you -are using @code{%pointer} (the default), a call to @code{unput()} +are using @code{%pointer} (the default), a call to @code{yyunput()} @emph{destroys} the contents of @code{yytext}, starting with its rightmost character and devouring one character to the left with each call. If you need the value of @code{yytext} preserved after a call to -@code{unput()} (as in the above example), you must either first copy it +@code{yyunput()} (as in the above example), you must either first copy it elsewhere, or build your scanner using @code{%array} instead (@pxref{Matching}). @@ -2431,7 +2431,7 @@ to be an array of YYLMAX characters, where @code{YYLMAX} is a parameter that you can redefine with a @code{%yylmax} option if you don't like the default value (generally 8KB). Using @code{%array} results in somewhat slower scanners, but the value of @code{yytext} becomes immune to calls to -@code{unput()}, which potentially destroy its value when @code{yytext} is +@code{yyunput()}, which potentially destroy its value when @code{yytext} is a character pointer. The opposite of @code{%array} is @code{%pointer}, which is the default. @@ -2576,12 +2576,12 @@ indicate it actually is not used (e.g., @code{%option noyymore)}. A number of options are available for lint purists who want to suppress the appearance of unneeded routines in the generated scanner. Each of -the following, if unset (e.g., @code{%option nounput}), results in the +the following, if unset (e.g., @code{%option noyyunput}), results in the corresponding routine not appearing in the generated scanner: @example @verbatim - input, unput + input, yyunput yy_push_state, yy_pop_state, yy_top_state yy_scan_buffer, yy_scan_bytes, yy_scan_string @@ -3446,9 +3446,9 @@ which degrade performance. These are, from most expensive to least: @end example with the first two all being quite expensive and the last two being -quite cheap. Note also that @code{unput()} is implemented as a routine +quite cheap. Note also that @code{yyunput()} is implemented as a routine call that potentially does quite a bit of work, while @code{yyless()} -isvery inexpensive. So if you are just putting back some excess text +is very inexpensive. So if you are just putting back some excess text you scanned, use @code{yyless()}. @code{yyreject()} should be avoided at all costs when performance is @@ -3967,7 +3967,7 @@ Here is an example of a simple C++ scanner: if((c = yyinput()) == '/') break; else - unput(c); + yyunput(c); } } } @@ -4576,7 +4576,7 @@ implementations do not share any code, though), with some extensions and incompatibilities, both of which are of concern to those who wish to write scanners acceptable to both implementations. @code{flex} is fully compliant with the POSIX @code{lex} specification, except that when -using @code{%pointer} (the default), a call to @code{unput()} destroys +using @code{%pointer} (the default), a call to @code{yyunput()} destroys the contents of @code{yytext}, which is counter to the POSIX specification. In this section we discuss all of the known areas of incompatibility between @code{flex}, AT&T @code{lex}, and the POSIX @@ -4617,7 +4617,7 @@ specify any way of controlling the scanner's input other than by making an initial assignment to @file{yyin}. @item -The @code{unput()} routine is not redefinable. This restriction is in +The @code{yyunput()} routine is not redefinable. This restriction is in accordance with POSIX. @item @@ -4717,7 +4717,7 @@ The @code{lex} @code{%r} (generate a Ratfor scanner) option is not supported. It is not part of the POSIX specification. @item -After a call to @code{unput()}, @emph{yytext} is undefined until the +After a call to @code{yyunput()}, @emph{yytext} is undefined until the next token is matched, unless the scanner was built using @code{%array}. This is not the case with @code{lex} or the POSIX specification. The @samp{-l} option does away with this incompatibility. @@ -5368,7 +5368,7 @@ See the discussion of the @samp{-7} flag, @ref{Scanner Options}, for details. @item -@samp{flex scanner push-back overflow}. you used @code{unput()} to push +@samp{flex scanner push-back overflow}. you used @code{yyunput()} to push back so much text that the scanner's buffer could not hold both the pushed-back text and the current token in @code{yytext}. Ideally the scanner should dynamically resize the buffer in this case, but at @@ -5426,7 +5426,7 @@ in @emph{fixed} trailing context being turned into the more expensive @end verbatim @end example -Use of @code{unput()} invalidates yytext and yyleng, unless the +Use of @code{yyunput()} invalidates yytext and yyleng, unless the @code{%array} directive or the @samp{-l} option has been used. Pattern-matching of @code{NUL}s is substantially slower than matching other characters. Dynamic resizing of the input buffer is slow, as it @@ -5521,7 +5521,7 @@ publish them here. * Can I fake multi-byte character support?:: * deleteme01:: * Can you discuss some flex internals?:: -* unput() messes up yy_at_bol:: +* yyunput() messes up yy_at_bol:: * The | operator is not doing what I want:: * Why can't flex understand this variable trailing context pattern?:: * The ^ operator isn't working:: @@ -6114,11 +6114,11 @@ one to match. @unnumberedsec I am trying to port code from AT&T lex that uses yysptr and yysbuf. Those are internal variables pointing into the AT&T scanner's input buffer. I -imagine they're being manipulated in user versions of the @code{input()} and @code{unput()} +imagine they're being manipulated in user versions of the @code{input()} and @code{yyunput()} functions. If so, what you need to do is analyze those functions to figure out what they're doing, and then replace @code{input()} with an appropriate definition of @code{yyread()}. You shouldn't need to (and must not) replace -@code{flex}'s @code{unput()} function. +@code{flex}'s @code{yyunput()} function. @node Is there a way to make flex treat NUL like a regular character? @unnumberedsec Is there a way to make flex treat NUL like a regular character? @@ -6229,7 +6229,7 @@ example, @end example (You need to be careful to update your bookkeeping if you use @code{yymore(}), -@code{yyless()}, @code{unput()}, or @code{yyinput()}.) +@code{yyless()}, @code{yyunput()}, or @code{yyinput()}.) @node How do I use my own I/O classes in a C++ scanner? @section How do I use my own I/O classes in a C++ scanner? @@ -6562,8 +6562,8 @@ See above. @end example @c TODO: Evaluate this faq. -@node unput() messes up yy_at_bol -@unnumberedsec unput() messes up yy_at_bol +@node yyunput() messes up yy_at_bol +@unnumberedsec yyunput() messes up yy_at_bol @example @verbatim To: Xinying Li @@ -6572,7 +6572,7 @@ In-reply-to: Your message of Wed, 13 Nov 1996 17:28:38 PST. Date: Wed, 13 Nov 1996 19:51:54 PST From: Vern Paxson -> "unput()" them to input flow, question occurs. If I do this after I scan +> "yyunput()" them to input flow, question occurs. If I do this after I scan > a carriage, the variable "YY_CURRENT_BUFFER->yy_at_bol" is changed. That > means the carriage flag has gone. @@ -8804,6 +8804,9 @@ YY_AT_BOL: Replaced by yy_at_bol() @item input(): Replaced by yyinput(). This function was already yyinput() in the C++ back end. + +@item: +yunput(): Replaced by yyunput(). @end itemize Flex also provides @code{YYSTATE} as an alias for @code{yystart()} diff --git a/src/FlexLexer.h b/src/FlexLexer.h index 84de9b5..5a1a72f 100644 --- a/src/FlexLexer.h +++ b/src/FlexLexer.h @@ -150,7 +150,7 @@ protected: virtual void LexerOutput( const char* buf, int size ); virtual void LexerError( const char* msg ); - void yyunput( int c, char* buf_ptr ); + void yyunput_r( int c, char* buf_ptr ); int yyinput(); void yy_load_buffer_state(); diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index fccecd9..d843448 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -518,7 +518,9 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) +#define yyunput(c) yyunput_r( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) +/* Legacy interface */ +#define unput(c) yyunput_r( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) ]]) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -1407,10 +1409,10 @@ extern int yywrap ( M4_YY_PROTO_ONLY_ARG ); #endif %not-for-header -#ifndef YY_NO_UNPUT - m4_ifdef( [[M4_YY_NO_UNPUT]],, +#ifndef YY_NO_YYUNPUT + m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ - static void yyunput ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); + static void yyunput_r ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); ]]) #endif %ok-for-header @@ -2660,14 +2662,14 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ } -#ifndef YY_NO_UNPUT +#ifndef YY_NO_YYUNPUT %if-c-only -m4_ifdef( [[M4_YY_NO_UNPUT]],, +m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ -static void yyunput YYFARGS2( int,c, char *,yy_bp) +static void yyunput_r YYFARGS2( int,c, char *,yy_bp) %endif %if-c++-only -void yyFlexLexer::yyunput( int c, char* yy_bp) +void yyFlexLexer::yyunput_r( int c, char* yy_bp) %endif { char *yy_cp; diff --git a/src/flexdef.h b/src/flexdef.h index df564fd..1622792 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -361,7 +361,7 @@ struct ctrl_bundle_t { bool no_yy_push_state; bool no_yy_pop_state; bool no_yy_top_state; - bool no_unput; + bool no_yyunput; bool no_yy_scan_buffer; bool no_yy_scan_bytes; bool no_yy_scan_string; diff --git a/src/main.c b/src/main.c index 2a7d5c6..e369ebe 100644 --- a/src/main.c +++ b/src/main.c @@ -1106,8 +1106,8 @@ void flexinit (int argc, char **argv) case OPT_NO_YY_TOP_STATE: ctrl.no_yy_top_state = true; break; - case OPT_NO_UNPUT: - ctrl.no_unput = true; + case OPT_NO_YYUNPUT: + ctrl.no_yyunput = true; break; case OPT_NO_YY_SCAN_BUFFER: ctrl.no_yy_scan_buffer = true; @@ -1594,8 +1594,8 @@ void readin (void) visible_define("M4_YY_NO_POP_STATE"); if (ctrl.no_yy_top_state) visible_define("M4_YY_NO_TOP_STATE"); - if (ctrl.no_unput) - visible_define("M4_YY_NO_UNPUT"); + if (ctrl.no_yyunput) + visible_define("M4_YY_NO_YYUNPUT"); if (ctrl.no_yy_scan_buffer) visible_define("M4_YY_NO_SCAN_BUFFER"); if (ctrl.no_yy_scan_bytes) diff --git a/src/options.c b/src/options.c index 283fa08..fd5904a 100644 --- a/src/options.c +++ b/src/options.c @@ -231,7 +231,9 @@ optspec_t flexopts[] = { {"--yywrap", OPT_YYWRAP, 0} , - {"--nounput", OPT_NO_UNPUT, 0} + {"--nounput", OPT_NO_YYUNPUT, 0} + , + {"--noyyunput", OPT_NO_YYUNPUT, 0} , {"--noyy_push_state", OPT_NO_YY_PUSH_STATE, 0} , diff --git a/src/options.h b/src/options.h index acee275..c5abbdf 100644 --- a/src/options.h +++ b/src/options.h @@ -78,7 +78,7 @@ enum flexopt_flag_t { OPT_NO_REENTRANT, OPT_NO_REJECT, OPT_NO_STDINIT, - OPT_NO_UNPUT, + OPT_NO_YYUNPUT, OPT_NO_WARN, OPT_NO_YYGET_EXTRA, OPT_NO_YYGET_IN, diff --git a/src/scan.l b/src/scan.l index 31e41fd..52a6e6f 100644 --- a/src/scan.l +++ b/src/scan.l @@ -410,7 +410,8 @@ M4QEND "]""]" stdinit ctrl.do_stdinit = option_sense; stdout env.use_stdout = option_sense; unistd ctrl.no_unistd = ! option_sense; - unput ctrl.no_unput = ! option_sense; + unput ctrl.no_yyunput = ! option_sense; + yyinput ctrl.no_yyunput = ! option_sense; verbose env.printstats = option_sense; warn env.nowarn = ! option_sense; yylineno ctrl.do_yylineno = option_sense; -- cgit v1.2.1 From aac8fe889600fbd15effeb8526987be34c0264d7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Oct 2020 09:04:29 -0400 Subject: Revise the manual so the reentrant interface is recommended early. Also add the first example friom the manual, and a reentrant variant of it, to the example set. And document how to integrate examples. --- doc/flex.texi | 61 ++++++++++++++++++++++++++++++++++----- examples/manual/Makefile.am | 2 ++ examples/manual/Makefile.examples | 9 ++++++ examples/manual/README | 6 ++++ examples/manual/example_nr.lex | 12 ++++++++ examples/manual/example_r.lex | 20 +++++++++++++ 6 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 examples/manual/example_nr.lex create mode 100644 examples/manual/example_r.lex diff --git a/doc/flex.texi b/doc/flex.texi index 4e60555..c66b295 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -352,29 +352,56 @@ beginning of the rules. Here's another simple example: -@cindex counting characters and lines +@cindex counting characters and lines; reentrant @example @verbatim + %{ int num_lines = 0, num_chars = 0; + %} + %option reentrant + %% + \n ++num_lines; ++num_chars; + . ++num_chars; %% + + int main() { + yyscan_t scanner; + + yylex_init ( &scanner ); + yylex ( scanner ); + yylex_destroy ( scanner ); + + printf( "# of lines = %d, # of chars = %d\n", + num_lines, num_chars ); + } +@end verbatim +@end example + +If you have looked at older versions of the Flex nanual, you might +have seen a version of the above example that looked more like this: + +@cindex counting characters and lines; non-reentrant +@example +@verbatim + int num_lines = 0, num_chars = 0; + %% \n ++num_lines; ++num_chars; . ++num_chars; %% - int main() - { + int main() { yylex(); printf( "# of lines = %d, # of chars = %d\n", num_lines, num_chars ); - } + } @end verbatim @end example -This scanner counts the number of characters and the number of lines in -its input. It produces no output other than the final report on the -character and line counts. The first line declares two globals, +Both versions count the number of characters and the number of lines in +its input. Both produces no output other than the final report on the +character and line counts. The first code line declares two globals, @code{num_lines} and @code{num_chars}, which are accessible both inside @code{yylex()} and in the @code{main()} routine declared after the second @samp{%%}. There are two rules, one which matches a newline @@ -382,6 +409,26 @@ second @samp{%%}. There are two rules, one which matches a newline and one which matches any character other than a newline (indicated by the @samp{.} regular expression). +The difference between these two variants is that the first uses +Flex's @emph{reentrant} interface, which bundles the scanner state +into a yyscan_t structure; the second uses the @emph{non-reentrant} +interface, in which the scanner's state is exposed through global +variables. + +The non-reentrant interface is a relic from the early 1970s when Lex, +the ancestor of Flex, was designed. Modern programming practice frowns +on hidden global variables; thus when Flex generates a scanner in any +language other than the original C/C++ non-reentrancy is not even an +option. + +This, it's a good idea to get used to using the reentrant interface +from the beginning of your Flex prgramming. This is so even though the +reentrant example above is a rather poor one; it avoids exposing the +scanner state in globals but creates globals of its own. There is a +mechanism for including user-defined fields in the scanner structure +which will be explained in detail at @xref{Extra Data}. For now, +consider this: + A somewhat more complicated example: @cindex Pascal-like language diff --git a/examples/manual/Makefile.am b/examples/manual/Makefile.am index 9ab3004..37d91c8 100644 --- a/examples/manual/Makefile.am +++ b/examples/manual/Makefile.am @@ -30,6 +30,8 @@ EXTRA_DIST = \ eof_test01.txt \ eof_test02.txt \ eof_test03.txt \ + example_r.lex \ + example_nr.lex \ expr.lex \ expr.y \ front.lex \ diff --git a/examples/manual/Makefile.examples b/examples/manual/Makefile.examples index f4d8297..57a17c8 100644 --- a/examples/manual/Makefile.examples +++ b/examples/manual/Makefile.examples @@ -18,10 +18,19 @@ ALLOCA = # DO NOT CHANGE ANYTHING FROM HERE ON !!!!!!!!! # ############################################################ +PATH = ${PATH}:/usr/local/bin all: expr front myname eof wc replace user_act string1\ string2 yymore numbers dates cat +example_r: example_r.lex + $(LEX) example_r.lex + $(CC) lex.yy.c -o example_r + +example_nr: example_nr.lex + $(LEX) example_nr.lex + $(CC) lex.yy.c -o example_nr + expr: expr.y expr.lex $(YACC) expr.y $(LEX) expr.lex diff --git a/examples/manual/README b/examples/manual/README index e11569a..5386ca8 100644 --- a/examples/manual/README +++ b/examples/manual/README @@ -10,3 +10,9 @@ To build the programs individually, type For example: make -f Makefile.examples expr + +If you ad an eample to this directory, don't frget these steps: + +* Add it to the EXTRA_DIST list in Makefile.am + +* Add a build recipe to Makefile/examples. diff --git a/examples/manual/example_nr.lex b/examples/manual/example_nr.lex new file mode 100644 index 0000000..ae9e83d --- /dev/null +++ b/examples/manual/example_nr.lex @@ -0,0 +1,12 @@ + int num_lines = 0, num_chars = 0; +%% +\n ++num_lines; ++num_chars; +. ++num_chars; + +%% + +int main() { + yylex(); + printf( "# of lines = %d, # of chars = %d\n", + num_lines, num_chars ); +} diff --git a/examples/manual/example_r.lex b/examples/manual/example_r.lex new file mode 100644 index 0000000..54c7f98 --- /dev/null +++ b/examples/manual/example_r.lex @@ -0,0 +1,20 @@ +%{ + int num_lines = 0, num_chars = 0; +%} +%option reentrant +%% +\n ++num_lines; ++num_chars; +. ++num_chars; + +%% + +int main() { + yyscan_t scanner; + + yylex_init ( &scanner ); + yylex ( scanner ); + yylex_destroy ( scanner ); + + printf( "# of lines = %d, # of chars = %d\n", + num_lines, num_chars ); +} -- cgit v1.2.1 From da0cd947c38cc984a674827669f3396186a60db9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Oct 2020 09:36:44 -0400 Subject: Make flex --help work again. Fixes a stupid, trivial initialization-time bug introduce during methodizatiion. --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index e369ebe..1e36ff3 100644 --- a/src/main.c +++ b/src/main.c @@ -737,6 +737,8 @@ void flexinit (int argc, char **argv) tablesfilename = tablesname = NULL; sawcmpflag = false; + + backend = &cpp_backend; /* Initialize dynamic array for holding the rule actions. */ action_size = 2048; /* default size of action array in bytes */ @@ -1200,8 +1202,6 @@ void flexinit (int argc, char **argv) lastprot = 1; set_up_initial_allocations (); - - backend = &cpp_backend; } -- cgit v1.2.1 From 7bd654ca0c768f2e9f3ba07f1292615a4a3b9269 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Oct 2020 10:38:18 -0400 Subject: Deprecate #define YY_EXTRA_TYPE in favor of the extra-type option. Follow this through in the examples and manual. --- doc/flex.texi | 13 +++++++++++-- tests/yyextra.l | 3 +-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index c66b295..5e1e3b0 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -4328,7 +4328,10 @@ after @code{yylex}, respectively. @end verbatim @end example -(The type name and declaration syntax will be different in target +In these declarations, @code(YY_EXTRA_TYPE} is a placeholder for the type +specifier in the scanner's @code{yyextra} directive. + +(The scanner type and type declaration syntax will be different in target languages other thab C/C++.) The function @code{yylex_init} must be called before calling any other @@ -4464,6 +4467,9 @@ from within the scanner itself. They are defined as follows: @end verbatim @end example +In these declarations, @code{YY_EXTRA_TYPE} is as before a placeolder for the type +specifier in the scanner's @code{yyextra} directive. + In addition, an extra form of @code{yylex_init} is provided, @code{yylex_init_extra}. This function is provided so that the yyextra value can be accessed from within the very first yyalloc, used to allocate @@ -5022,10 +5028,10 @@ custom allocator through @code{yyextra}. /* Suppress the default implementations. */ %option noyyalloc noyyrealloc noyyfree %option reentrant +%option extra-type="struct allocator*" /* Initialize the allocator. */ %{ -#define YY_EXTRA_TYPE struct allocator* #define YY_USER_INIT yyextra = allocator_create(); %} @@ -8854,6 +8860,9 @@ in the C++ back end. @item: yunput(): Replaced by yyunput(). + +@item +#define YY_EXTRA_TYPE: Replaced by the @code{extra-type} option. @end itemize Flex also provides @code{YYSTATE} as an alias for @code{yystart()} diff --git a/tests/yyextra.l b/tests/yyextra.l index a1eff11..5a5a014 100644 --- a/tests/yyextra.l +++ b/tests/yyextra.l @@ -40,7 +40,6 @@ struct Buffer { int grow_len; char * data; }; -#define YY_EXTRA_TYPE struct Buffer * /* Save char into junk array at next position. */ static void append_char (char c, yyscan_t scanner ); @@ -51,7 +50,7 @@ static void append_char (char c, yyscan_t scanner ); %option nounput nomain noyywrap nodefault noyyinput %option warn %option reentrant - +%option extra-type="struct Buffer *" %% -- cgit v1.2.1 From a4dd4772d26aa30a355fd15953c1cb2358143a0b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Oct 2020 11:06:26 -0400 Subject: Make yydecl an ordinary string-valued option rather than a special directive. This corrects a minor mistake I made earlier because I did not yet understand the full generality of the option syntax. Also fixes some minor markup errors in the manual. --- doc/flex.texi | 18 +++++++++--------- src/parse.y | 10 ++++++---- src/scan.l | 2 +- tests/test-yydecl | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 5e1e3b0..9deac54 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1534,14 +1534,14 @@ default in C, @code{yylex()} is declared as follows: @end verbatim @end example -@cindex yylex(), overriding, %yydecl -This definition may be changed with the the @code{%yydecl} directive. +@cindex yylex(), overriding, yydecl +This definition may be changed with the the @code{yydecl} option. For example, you could put this in among your directives: @cindex yylex, overriding the prototype of @example @verbatim -%yydecl float lexscan(float a, float b) +%p[tion yydecl="float lexscan(float a, float b)" @end verbatim @end example @@ -4328,8 +4328,8 @@ after @code{yylex}, respectively. @end verbatim @end example -In these declarations, @code(YY_EXTRA_TYPE} is a placeholder for the type -specifier in the scanner's @code{yyextra} directive. +In these declarations, @code{YY_EXTRA_TYPE} is a placeholder for the type +specifier in the scanner's @code{extra-type} option. (The scanner type and type declaration syntax will be different in target languages other thab C/C++.) @@ -4467,8 +4467,8 @@ from within the scanner itself. They are defined as follows: @end verbatim @end example -In these declarations, @code{YY_EXTRA_TYPE} is as before a placeolder for the type -specifier in the scanner's @code{yyextra} directive. +In these declarations, @code{YY_EXTRA_TYPE} is as before a placeholder for the type +specifier in the scanner's @code{extra-type} option. In addition, an extra form of @code{yylex_init} is provided, @code{yylex_init_extra}. This function is provided so that the yyextra value can @@ -8252,7 +8252,7 @@ then the problem is that the last rule needs to be "{whitespace}" ! This is a compiler error regarding a generated Bison parser, not a Flex scanner. It means you need a prototype of yylex() in the top of the Bison file. -Be sure the prototype matches what you declarted with @code{%yydecl}. +Be sure the prototype matches what you declared with @code{%option yydecl}. @node How do I access the values set in a Flex action from within a Bison action? @unnumberedsec How do I access the values set in a Flex action from within a Bison action? @@ -8840,7 +8840,7 @@ ECHO: Replaced by yyecho() REJECT: Replaced by yyreject() @item -#define YY_DECL: Replaced by the %yydecl directive. +#define YY_DECL: Replaced by the yydecl option. @item #define YYLMAX: Replaced by the %yylmax option. diff --git a/src/parse.y b/src/parse.y index f13a36d..a2025f6 100644 --- a/src/parse.y +++ b/src/parse.y @@ -2,7 +2,7 @@ %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP %token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE -%token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC +%token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC TOK_YYDECL %token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH %token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT @@ -207,9 +207,11 @@ option : TOK_OUTFILE '=' NAME | TOK_HEADER_FILE '=' NAME { env.headerfilename = xstrdup(nmstr); } | TOK_YYLMAX '=' TOK_NUMERIC - { ctrl.yylmax = nmval; } - | TOK_TABLES_FILE '=' NAME - { tablesext = true; tablesfilename = xstrdup(nmstr); } + { ctrl.yylmax = nmval; } + | TOK_YYDECL '=' NAME + { ctrl.yydecl = xstrdup(nmstr); } + | TOK_TABLES_FILE '=' NAME + { tablesext = true; tablesfilename = xstrdup(nmstr); } ; sect2 : sect2 scon initforrule flexrule '\n' diff --git a/src/scan.l b/src/scan.l index 52a6e6f..e32d9e5 100644 --- a/src/scan.l +++ b/src/scan.l @@ -194,7 +194,6 @@ M4QEND "]""]" ^"%pointer".*{NL} ctrl.yytext_is_array = false; ++linenum; ^"%array".*{NL} ctrl.yytext_is_array = true; ++linenum; - ^"%yydecl".* ctrl.yydecl = xstrdup(yytext+7); ^"%option" BEGIN(OPTION); return TOK_OPTION; @@ -455,6 +454,7 @@ M4QEND "]""]" prefix return TOK_PREFIX; yyclass return TOK_YYCLASS; yylmax return TOK_YYLMAX; + yydecl return TOK_YYDECL; header(-file)? return TOK_HEADER_FILE; tables-file return TOK_TABLES_FILE; tables-verify { diff --git a/tests/test-yydecl b/tests/test-yydecl index 1b4efad..ffeef35 100755 --- a/tests/test-yydecl +++ b/tests/test-yydecl @@ -3,7 +3,7 @@ trap 'rm /tmp/td$$' EXIT HUP INT QUIT TERM cat >/tmp/td$$ < Date: Mon, 12 Oct 2020 16:15:28 -0400 Subject: Replace YY_USER_INIT, YY_USER_ACION, and YY_BREAK #defines with Flex options. These were the last preprocessor abuses in the Flex interface. Also, add a TODO listing tests that need to be added. --- TODO | 5 +++ doc/flex.texi | 94 +++++++++++++++++++++++++++++++------------------------- src/cpp-flex.skl | 6 ++++ src/flexdef.h | 3 ++ src/main.c | 15 ++++++--- src/parse.y | 9 +++++- src/scan.l | 3 ++ 7 files changed, 88 insertions(+), 47 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..0f06e37 --- /dev/null +++ b/TODO @@ -0,0 +1,5 @@ +Things to be worked on: + +* Tests for %option user-init, %option pre-action, %option post-action. + + diff --git a/doc/flex.texi b/doc/flex.texi index 9deac54..66790f8 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -92,7 +92,7 @@ This manual was written by @value{authors}. * Start Conditions:: * Multiple Input Buffers:: * EOF:: -* Misc Macros:: +* Misc Controls:: * User Values:: * Yacc:: * Scanner Options:: @@ -2316,7 +2316,7 @@ is an integral type to which you can cast an integer expression reflecting the size of the buffer. @end deftp -@node EOF, Misc Macros, Multiple Input Buffers, Top +@node EOF, Misc Controls, Multiple Input Buffers, Top @chapter End-of-File Rules @cindex EOF, explanation @@ -2327,13 +2327,6 @@ no further files to process). The action must finish by doing one of the following things: @itemize -@item -@findex YY_NEW_FILE (now obsolete) -assigning @file{yyin} to a new input file (in previous versions of -@code{flex}, after doing the assignment you had to call the special -action @code{YY_NEW_FILE}. This is no longer necessary.) It is -still supported in the C/C++ back end only. - @item executing a @code{return} statement; @@ -2381,22 +2374,22 @@ example: @end verbatim @end example -@node Misc Macros, User Values, EOF, Top -@chapter Miscellaneous Macros +@node Misc Controls, User Values, EOF, Top +@chapter Miscellaneous Controls -@hkindex YY_USER_ACTION -The macro @code{YY_USER_ACTION} can be defined to provide an action +@hkindex %option pre-action +This option can be set to provide an code fragment which is always executed prior to the matched rule's action. For -example, it could be #define'd to call a routine to convert yytext to -lower-case. When @code{YY_USER_ACTION} is invoked, the variable +example, it could be set to call a routine to convert @code{yytext} to +lower-case. When the code fragment is invoked, the variable @code{yy_act} gives the number of the matched rule (rules are numbered starting with 1). Suppose you want to profile how often each of your rules is matched. The following would do the trick: -@cindex YY_USER_ACTION to track each time a rule is matched +@cindex pre-action to track each time a rule is matched @example @verbatim - #define YY_USER_ACTION ++ctr[yy_act] + %option pre-action="++ctr[yy_act]" @end verbatim @end example @@ -2412,8 +2405,8 @@ declaration for @code{ctr} is: @end verbatim @end example -@hkindex YY_USER_INIT -The macro @code{YY_USER_INIT} may be defined to provide an action which +@hkindex %option user-init +This option may be defined to provide an action which is always executed before the first scan (and before the scanner's internal initializations are done). For example, it could be used to call a routine to read in a data table or open a logging file. @@ -2445,19 +2438,22 @@ rules anchored with @samp{^} active, while a zero argument makes The rule hook @code{yy_at_bol()} returns true if the next token scanned from the current buffer will have @samp{^} rules active, false otherwise. -@cindex actions, redefining YY_BREAK -@hkindex YY_BREAK +@hkindex %option post-action In the generated scanner, the actions are all gathered in one large -switch statement and separated using @code{YY_BREAK}, which may be -redefined. By default, it is simply a @code{break}, to separate each -rule's action from the following rule's. Redefining @code{YY_BREAK} -allows, for example, C++ users to #define YY_BREAK to do nothing (while -being very careful that every rule ends with a @code{break} or a -@code{return}!) to avoid suffering from unreachable statement warnings -where because a rule's action ends with @code{return}, the -@code{YY_BREAK} is inaccessible. - -@node User Values, Yacc, Misc Macros, Top +switch statement and separated using a postt-action fragment, which +may be redefined. By default, in C it is simply a @code{break}, to +separate each rule's action from the following rule's. Other target +languages may have different defaults for this action, often an empty +string. If a target language has no case statement this option will +probably be ineffective. + +Setting a post-action allows, for example, C++ users to suppress the +trailing break (while being very careful that every rule ends with a +@code{break} or a @code{return}!) to avoid suffering from unreachable +statement warnings where because a rule's action ends with +@code{return}, the @code{YY_BREAK} is inaccessible. + +@node User Values, Yacc, Misc Controls, Top @chapter Values Available To the User This chapter summarizes the various values available to the user in the @@ -4461,7 +4457,7 @@ from within the scanner itself. They are defined as follows: @findex yyset_extra @example @verbatim - #define YY_EXTRA_TYPE void* + option extra-type="void *" YY_EXTRA_TYPE yyget_extra ( yyscan_t scanner ); void yyset_extra ( YY_EXTRA_TYPE arbitrary_data , yyscan_t scanner); @end verbatim @@ -4796,7 +4792,7 @@ The special table-size declarations such as @code{%a} supported by @code{lex} are not required by @code{flex} scanners.. @code{flex} ignores them. @item -The name @code{FLEX_SCANNER} is @code{#define}'d so scanners may be +In the C/C++ back end name @code{FLEX_SCANNER} is @code{#define}'d so scanners may be written for use with either @code{flex} or @code{lex}. Scanners also include @code{YY_FLEX_MAJOR_VERSION}, @code{YY_FLEX_MINOR_VERSION} and @code{YY_FLEX_SUBMINOR_VERSION} @@ -4900,9 +4896,9 @@ override the default behavior. @node The Default Memory Management, Overriding The Default Memory Management, Memory Management, Memory Management @section The Default Memory Management -This section applies only to target languages wuth manual memory +This section applies only to target languages with manual memory allocation, including the default C/C++ back end. If your target -language has garbage collection you can igore it. +language has garbage collection you can ignore it. A Flex-generated scanner allocates dynamic memory during initialization, and once in a while from @@ -5031,10 +5027,7 @@ custom allocator through @code{yyextra}. %option extra-type="struct allocator*" /* Initialize the allocator. */ -%{ -#define YY_USER_INIT yyextra = allocator_create(); -%} - +%option user-init="yyextra = allocator_create();" %% .|\n ; %% @@ -6277,7 +6270,7 @@ example, @example @verbatim -#define YY_USER_ACTION num_chars += yyleng; +%option pre-action="num_chars += yyleng;" @end verbatim @end example @@ -8863,11 +8856,28 @@ yunput(): Replaced by yyunput(). @item #define YY_EXTRA_TYPE: Replaced by the @code{extra-type} option. -@end itemize -Flex also provides @code{YYSTATE} as an alias for @code{yystart()} +@item +#define YY_USER_INIT: Replaced by the @code{user-init} option. + +@item +#define YY_USER_ACTION replaced by @code{pre-action} option. + +@item +#define YY_BREAK replaced by @code{post-action} option. + +@item +YYSTATE: is accepted as an alias for @code{yystart()} (since that is what's used by AT&T @code{lex}). +@item +YY_NEW_FILE: In previous versions of @code{flex}, ehen assigning +@file{yyin} to a new input file, after doing the assignment you had to +call the special action @code{YY_NEW_FILE}. This is no longer +necessary. + +@end itemize + @node Indices, , Appendices, Top @unnumbered Indices diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index d843448..96a317a 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -93,6 +93,12 @@ m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1 ]]) +m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 +]]) +m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 +]]) +m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 +]]) %% [0.0] Make hook macros available to Flex diff --git a/src/flexdef.h b/src/flexdef.h index 1622792..775b6ad 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -357,6 +357,9 @@ struct ctrl_bundle_t { // yytext as array instead of a character pointer. // Nice and inefficient. bool noyyread; // User supplied a yyread function, don't generate default + char *userinit; // Code fragment to be inserted before scanning + char *preaction; // Code fragment to be inserted before each action + char *postaction; // Code fragment to be inserted after each action // flags corresponding to the huge mass of --no-yy options bool no_yy_push_state; bool no_yy_pop_state; diff --git a/src/main.c b/src/main.c index 1e36ff3..46bfdaa 100644 --- a/src/main.c +++ b/src/main.c @@ -1282,10 +1282,17 @@ void readin (void) /* User may want to set the scanner prototype */ if (ctrl.yydecl != NULL) { - char *cp; - for (cp = ctrl.yydecl; isspace(*cp); cp++) - continue; - out_str ("M4_HOOK_SET_YY_DECL(%s)\n", cp); + out_str ("M4_HOOK_SET_YY_DECL(%s)\n", ctrl.yydecl); + } + + if (ctrl.userinit != NULL) { + out_str ("M4_HOOK_SET_USERINIT(%s)\n", ctrl.userinit); + } + if (ctrl.preaction != NULL) { + out_str ("M4_HOOK_SET_PREACTION(%s)\n", ctrl.preaction); + } + if (ctrl.postaction != NULL) { + out_str ("M4_HOOK_SET_POSTACTION(%s)\n", ctrl.postaction); } if (ctrl.yylmax != 0) { diff --git a/src/parse.y b/src/parse.y index a2025f6..2bb9b1c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -2,7 +2,8 @@ %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP %token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE -%token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC TOK_YYDECL +%token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC TOK_YYDECL TOK_PREACTION TOK_POSTACTION +%token TOK_USERINIT %token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH %token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT @@ -210,6 +211,12 @@ option : TOK_OUTFILE '=' NAME { ctrl.yylmax = nmval; } | TOK_YYDECL '=' NAME { ctrl.yydecl = xstrdup(nmstr); } + | TOK_PREACTION '=' NAME + { ctrl.preaction = xstrdup(nmstr); } + | TOK_POSTACTION '=' NAME + { ctrl.postaction = xstrdup(nmstr); } + | TOK_USERINIT '=' NAME + { ctrl.userinit = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME { tablesext = true; tablesfilename = xstrdup(nmstr); } ; diff --git a/src/scan.l b/src/scan.l index e32d9e5..ceb5d7b 100644 --- a/src/scan.l +++ b/src/scan.l @@ -455,6 +455,9 @@ M4QEND "]""]" yyclass return TOK_YYCLASS; yylmax return TOK_YYLMAX; yydecl return TOK_YYDECL; + pre-action return TOK_PREACTION; + post-action return TOK_POSTACTION; + user-init return TOK_USERINIT; header(-file)? return TOK_HEADER_FILE; tables-file return TOK_TABLES_FILE; tables-verify { -- cgit v1.2.1 From 8d0162b80ac39fc3c682d39a14c490baccbcc5e9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Oct 2020 21:07:14 -0400 Subject: Update all the examples to use the new API elements. Add a fully reentrant example. And update to TODO file. --- TODO | 4 +++ doc/flex.texi | 56 ++++++++++++--------------------------- examples/manual/Makefile.am | 1 + examples/manual/Makefile.examples | 6 ++++- examples/manual/dates.lex | 24 ++++++++--------- examples/manual/eof_rules.lex | 8 +++--- examples/manual/example_er.lex | 35 ++++++++++++++++++++++++ examples/manual/example_nr.lex | 6 ++++- examples/manual/example_r.lex | 3 ++- examples/manual/front.lex | 3 --- examples/manual/j2t.lex | 44 +++++++++++++++--------------- examples/manual/pas_include.lex | 16 +++++------ examples/manual/pascal.lex | 8 +++--- examples/manual/reject.lex | 6 ++--- examples/manual/replace.lex | 2 +- examples/manual/string1.lex | 18 ++++++------- examples/manual/string2.lex | 8 +++--- examples/manual/unput.lex | 4 +-- examples/manual/user_act.lex | 7 +++-- examples/manual/userinit.lex | 3 +-- examples/manual/yymore.lex | 8 +++--- examples/manual/yymore2.lex | 8 +++--- 22 files changed, 150 insertions(+), 128 deletions(-) create mode 100644 examples/manual/example_er.lex diff --git a/TODO b/TODO index 0f06e37..2799eca 100644 --- a/TODO +++ b/TODO @@ -2,4 +2,8 @@ Things to be worked on: * Tests for %option user-init, %option pre-action, %option post-action. +* integrate examples directory into tests so that normal testing + proves the examples are up to date. +* Do away with any need for -lfl by generating a default yywrap + if the user doesn't specify one. diff --git a/doc/flex.texi b/doc/flex.texi index 66790f8..8d3d573 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -354,28 +354,7 @@ Here's another simple example: @cindex counting characters and lines; reentrant @example -@verbatim - %{ - int num_lines = 0, num_chars = 0; - %} - %option reentrant - %% - \n ++num_lines; ++num_chars; - . ++num_chars; - - %% - - int main() { - yyscan_t scanner; - - yylex_init ( &scanner ); - yylex ( scanner ); - yylex_destroy ( scanner ); - - printf( "# of lines = %d, # of chars = %d\n", - num_lines, num_chars ); - } -@end verbatim +@verbatiminclude ../examples/manual/example_r.lex @end example If you have looked at older versions of the Flex nanual, you might @@ -383,20 +362,7 @@ have seen a version of the above example that looked more like this: @cindex counting characters and lines; non-reentrant @example -@verbatim - int num_lines = 0, num_chars = 0; - %% - \n ++num_lines; ++num_chars; - . ++num_chars; - - %% - - int main() { - yylex(); - printf( "# of lines = %d, # of chars = %d\n", - num_lines, num_chars ); - } -@end verbatim +@verbatiminclude ../examples/manual/example_nr.lex @end example Both versions count the number of characters and the number of lines in @@ -422,13 +388,24 @@ language other than the original C/C++ non-reentrancy is not even an option. This, it's a good idea to get used to using the reentrant interface -from the beginning of your Flex prgramming. This is so even though the +from the beginning of your Flex programming. This is so even though the reentrant example above is a rather poor one; it avoids exposing the scanner state in globals but creates globals of its own. There is a mechanism for including user-defined fields in the scanner structure which will be explained in detail at @xref{Extra Data}. For now, consider this: +@example +@verbatiminclude ../examples/manual/example_er.lex +@end example + +While it requires a bit more ceremony, several instances of this +scanner can be run concurrently without stepping on each others' +storage. + +(The @code{%option noyywrap} in these examples is helpful in +making them run standalone, but does not change the behavior of the scsnner.) + A somewhat more complicated example: @cindex Pascal-like language @@ -596,7 +573,8 @@ themselves. A @code{%top} block is similar to a @samp{%@{} ... @samp{%@}} block, except that the code in a @code{%top} block is relocated to the @emph{top} of the -generated file, before any flex definitions @footnote{Actually, +generated file, before any flex definitions @footnote{Actually, in the +C/C++ back end, @code{yyIN_HEADER} is defined before the @samp{%top} block.}. The @code{%top} block is useful when you want definitions to be evaluated or certain files to be included before the generated code. @@ -1642,7 +1620,7 @@ condition remains unchanged; it does @emph{not} revert to @cindex yywrap, default for @cindex noyywrap, %option -@cindex %option noyywrapp +@cindex %option noyywrap If you do not supply your own version of @code{yywrap()}, then you must either use @code{%option noyywrap} (in which case the scanner behaves as though @code{yywrap()} returned 1), or you must link with @samp{-lfl} to diff --git a/examples/manual/Makefile.am b/examples/manual/Makefile.am index 37d91c8..24affe1 100644 --- a/examples/manual/Makefile.am +++ b/examples/manual/Makefile.am @@ -30,6 +30,7 @@ EXTRA_DIST = \ eof_test01.txt \ eof_test02.txt \ eof_test03.txt \ + example_er.lex \ example_r.lex \ example_nr.lex \ expr.lex \ diff --git a/examples/manual/Makefile.examples b/examples/manual/Makefile.examples index 57a17c8..472653e 100644 --- a/examples/manual/Makefile.examples +++ b/examples/manual/Makefile.examples @@ -18,7 +18,7 @@ ALLOCA = # DO NOT CHANGE ANYTHING FROM HERE ON !!!!!!!!! # ############################################################ -PATH = ${PATH}:/usr/local/bin +PATH := /usr/local/bin:${PATH} all: expr front myname eof wc replace user_act string1\ string2 yymore numbers dates cat @@ -31,6 +31,10 @@ example_nr: example_nr.lex $(LEX) example_nr.lex $(CC) lex.yy.c -o example_nr +example_er: example_er.lex + $(LEX) example_er.lex + $(CC) lex.yy.c -o example_er + expr: expr.y expr.lex $(YACC) expr.y $(LEX) expr.lex diff --git a/examples/manual/dates.lex b/examples/manual/dates.lex index 9429e1d..f9c648d 100644 --- a/examples/manual/dates.lex +++ b/examples/manual/dates.lex @@ -54,13 +54,13 @@ day_ext (st|nd|rd|th)? /* the default is month-day-year */ {day_of_the_week} strcpy(dow,yytext); -{month} strcpy(month,yytext); BEGIN(DAY); +{month} strcpy(month,yytext); yybegin(DAY); /* handle the form: day-month-year */ -{nday}{day_ext} strcpy(day,yytext); BEGIN(DAY_FIRST); -{month} strcpy(month,yytext); BEGIN(LONG); -{nday}{day_ext} strcpy(day,yytext); BEGIN(LONG); +{nday}{day_ext} strcpy(day,yytext); yybegin(DAY_FIRST); +{month} strcpy(month,yytext); yybegin(LONG); +{nday}{day_ext} strcpy(day,yytext); yybegin(LONG); {nyear}{year_ext} { printf("Long:\n"); @@ -75,15 +75,15 @@ day_ext (st|nd|rd|th)? /* handle dates of the form: day-month-year */ -{nday} strcpy(day,yytext); BEGIN(YEAR_LAST); -{nmonth} strcpy(month,yytext);BEGIN(YLMONTH); -{nyear} strcpy(year,yytext); BEGIN(SHORT); +{nday} strcpy(day,yytext); yybegin(YEAR_LAST); +{nmonth} strcpy(month,yytext);yybegin(YLMONTH); +{nyear} strcpy(year,yytext); yybegin(SHORT); /* handle dates of the form: year-month-day */ -{nyear} strcpy(year,yytext); BEGIN(YEAR_FIRST); -{nmonth} strcpy(month,yytext);BEGIN(YFMONTH); -{nday} strcpy(day,yytext); BEGIN(SHORT); +{nyear} strcpy(year,yytext); yybegin(YEAR_FIRST); +{nmonth} strcpy(month,yytext);yybegin(YFMONTH); +{nday} strcpy(day,yytext); yybegin(SHORT); \n { @@ -96,8 +96,8 @@ day_ext (st|nd|rd|th)? strcpy(month,""); } -long\n BEGIN(LONG); -short\n BEGIN(SHORT); +long\n yybegin(LONG); +short\n yybegin(SHORT); {skip}* \n diff --git a/examples/manual/eof_rules.lex b/examples/manual/eof_rules.lex index b575f2c..e42fda7 100644 --- a/examples/manual/eof_rules.lex +++ b/examples/manual/eof_rules.lex @@ -17,8 +17,8 @@ int include_count = -1; %% -^"#include"[ \t]*\" BEGIN(INCLUDE); -\" BEGIN(INITIAL); +^"#include"[ \t]*\" yybegin(INCLUDE); +\" yybegin(INITIAL); [^\"]+ { /* get the include file name */ if ( include_count >= MAX_NEST){ fprintf( stderr, "Too many include files" ); @@ -35,7 +35,7 @@ int include_count = -1; yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); - BEGIN(INITIAL); + yybegin(INITIAL); } <> { @@ -48,7 +48,7 @@ int include_count = -1; } else { yy_delete_buffer(include_stack[include_count--] ); yy_switch_to_buffer(include_stack[include_count] ); - BEGIN(INCLUDE); + yybegin(INCLUDE); } } [a-z]+ ECHO; diff --git a/examples/manual/example_er.lex b/examples/manual/example_er.lex new file mode 100644 index 0000000..284031c --- /dev/null +++ b/examples/manual/example_er.lex @@ -0,0 +1,35 @@ +/* basic example, fully reentrant thread-safe version */ +%{ + struct stats { + int num_lines; + int num_chars; + }; +%} +%option reentrant noyywrap +%option extra-type="struct stats" +%% +\n { + struct stats ns = yyget_extra(yyscanner); + ++ns.num_lines; ++ns.num_chars; + yyset_extra(ns, yyscanner); + } +. { + struct stats ns = yyget_extra(yyscanner); + ++ns.num_chars; + yyset_extra(ns, yyscanner); + } + +%% + +int main() { + yyscan_t scanner; + struct stats ns; + + yylex_init ( &scanner ); + yylex ( scanner ); + + ns = yyget_extra(scanner); + printf( "# of lines = %d, # of chars = %d\n", + ns.num_lines, ns.num_chars); + yylex_destroy ( scanner ); +} diff --git a/examples/manual/example_nr.lex b/examples/manual/example_nr.lex index ae9e83d..8722b14 100644 --- a/examples/manual/example_nr.lex +++ b/examples/manual/example_nr.lex @@ -1,4 +1,8 @@ - int num_lines = 0, num_chars = 0; +/* basic example - non-reentrant version */ +%{ + int num_lines = 0, num_chars = 0; +%} +%option noyywrap %% \n ++num_lines; ++num_chars; . ++num_chars; diff --git a/examples/manual/example_r.lex b/examples/manual/example_r.lex index 54c7f98..54c94d9 100644 --- a/examples/manual/example_r.lex +++ b/examples/manual/example_r.lex @@ -1,7 +1,8 @@ +/* basic example - flawed reentrant version with global */ %{ int num_lines = 0, num_chars = 0; %} -%option reentrant +%option reentrant noyywrap %% \n ++num_lines; ++num_chars; . ++num_chars; diff --git a/examples/manual/front.lex b/examples/manual/front.lex index 449cb00..0737a37 100644 --- a/examples/manual/front.lex +++ b/examples/manual/front.lex @@ -3,9 +3,6 @@ #include #include "y.tab.h" /* this comes from bison */ -#define TRUE 1 -#define FALSE 0 - #define copy_and_return(token_type) { strcpy(yylval.name,yytext); \ return(token_type); } diff --git a/examples/manual/j2t.lex b/examples/manual/j2t.lex index 08fbd21..eb09eed 100644 --- a/examples/manual/j2t.lex +++ b/examples/manual/j2t.lex @@ -158,7 +158,7 @@ void write_block_header(char *type) printf("\n\n@table @b\n"); } -"Examples:"[^\.]+ ECHO; +"Examples:"[^\.]+ yyecho(); "*"[^*\n]+"*" { /* @emph{}(emphasized) text */ yytext[yyleng-1] = '\0'; @@ -205,12 +205,12 @@ void write_block_header(char *type) yyless(loop+1); statep++; states[statep] = EXAMPLE2; - BEGIN(EXAMPLE2); + yybegin(EXAMPLE2); } ^\n { printf("@end example\n\n"); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } /* @@ -231,7 +231,7 @@ void write_block_header(char *type) yyless(loop); statep++; states[statep] = ENUM; - BEGIN(ENUM); + yybegin(ENUM); } "@" printf("@@"); @@ -239,7 +239,7 @@ void write_block_header(char *type) printf(":\n\n@example\n"); statep++; states[statep] = EXAMPLE; - BEGIN(EXAMPLE); + yybegin(EXAMPLE); } @@ -250,7 +250,7 @@ void write_block_header(char *type) \n\n\n[ \t]+[^0-9] { printf("\n\n@end enumerate\n\n"); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } /* @@ -265,7 +265,7 @@ void write_block_header(char *type) yyless(2); statep++; states[statep] = LITEM2; - BEGIN(LITEM2); + yybegin(LITEM2); } ^":".+":" { (void)check_and_convert(&yytext[1]); @@ -275,9 +275,9 @@ void write_block_header(char *type) \n\n\n+[^:\n] { printf("\n\n@end itemize\n\n"); - ECHO; + yyecho(); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } /* @@ -300,7 +300,7 @@ void write_block_header(char *type) yyless(loop); statep++; states[statep] = LITEM; - BEGIN(LITEM); + yybegin(LITEM); } ^.+":" { (void)check_and_convert(yytext); @@ -318,7 +318,7 @@ void write_block_header(char *type) printf("@end itemize\n\n"); printf("%s",&buffer[loop+1]); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } /* @@ -338,27 +338,27 @@ void write_block_header(char *type) yyless((len-loop)+2); statep++; states[statep] = BITEM; - BEGIN(BITEM); + yybegin(BITEM); } ^" "*"*" { printf("@item"); statep++; states[statep] = BITEM_ITEM; - BEGIN(BITEM_ITEM); + yybegin(BITEM_ITEM); } "@" printf("@@"); ^\n { printf("@end itemize\n\n"); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } [^\:]* { printf(" @b{%s}\n\n",check_and_convert(yytext)); } ":" { statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } /* @@ -369,13 +369,13 @@ void write_block_header(char *type) (void)check_and_convert(&yytext[1]); statep++; states[statep] = HEADING; - BEGIN(HEADING); + yybegin(HEADING); } :[^\n] { printf("@item @b{%s}\n",buffer); write_underline(strlen(buffer),6,'~'); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } :\n"*"* { if(need_closing == TRUE){ @@ -385,7 +385,7 @@ void write_block_header(char *type) printf("@chapter %s\n",buffer); write_underline(strlen(buffer),9,'*'); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } :\n"="* { if(need_closing == TRUE){ @@ -395,7 +395,7 @@ void write_block_header(char *type) printf("@section %s\n",buffer); write_underline(strlen(buffer),9,'='); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } "@" printf("@@"); :\n"-"* { @@ -406,7 +406,7 @@ void write_block_header(char *type) printf("@subsection %s\n",buffer); write_underline(strlen(buffer),12,'-'); statep--; - BEGIN(states[statep]); + yybegin(states[statep]); } /* @@ -417,10 +417,10 @@ void write_block_header(char *type) printf("@example\n"); statep++; states[statep] = EXAMPLE; - BEGIN(EXAMPLE); + yybegin(EXAMPLE); } ^" " -. ECHO; +. yyecho(); %% diff --git a/examples/manual/pas_include.lex b/examples/manual/pas_include.lex index 58cf590..117ad56 100644 --- a/examples/manual/pas_include.lex +++ b/examples/manual/pas_include.lex @@ -19,13 +19,13 @@ int include_count = -1; %% -"{" BEGIN(COMMENT); +"{" yybegin(COMMENT); -"}" BEGIN(INITIAL); -"$include"[ \t]*"(" BEGIN(INCLUDE); +"}" yybegin(INITIAL); +"$include"[ \t]*"(" yybegin(INCLUDE); [ \t]* /* skip whitespace */ -")" BEGIN(COMMENT); +")" yybegin(COMMENT); [ \t]* /* skip whitespace */ [^ \t\n() ]+ { /* get the include file name */ if ( include_count >= MAX_NEST){ @@ -43,7 +43,7 @@ int include_count = -1; yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); - BEGIN(INITIAL); + yybegin(INITIAL); } <> { @@ -61,11 +61,11 @@ int include_count = -1; } else { yy_delete_buffer(include_stack[include_count--] ); yy_switch_to_buffer(include_stack[include_count] ); - BEGIN(INCLUDE); + yybegin(INCLUDE); } } -[a-z]+ ECHO; -.|\n ECHO; +[a-z]+ yyecho(); +.|\n yyecho(); diff --git a/examples/manual/pascal.lex b/examples/manual/pascal.lex index d406bbe..df94313 100644 --- a/examples/manual/pascal.lex +++ b/examples/manual/pascal.lex @@ -31,17 +31,17 @@ bad_string \'([^'\n]|\'\')+ %% -"{" BEGIN(COMMENT1); +"{" yybegin(COMMENT1); [^}\n]+ \n ++line_number; <> yyerror("EOF in comment"); -"}" BEGIN(INITIAL); +"}" yybegin(INITIAL); -"(*" BEGIN(COMMENT2); +"(*" yybegin(COMMENT2); [^)*\n]+ \n ++line_number; <> yyerror("EOF in comment"); -"*)" BEGIN(INITIAL); +"*)" yybegin(INITIAL); [*)] /* note that FILE and BEGIN are already diff --git a/examples/manual/reject.lex b/examples/manual/reject.lex index a7b817f..9e0bbd8 100644 --- a/examples/manual/reject.lex +++ b/examples/manual/reject.lex @@ -1,12 +1,12 @@ /* - * reject.lex: An example of REJECT and unput() + * reject.lex: An example of yyreject() and yyunput() * misuse. */ %% UNIX { - unput('U'); unput('N'); unput('G'); unput('\0'); - REJECT; + yyunput('U'); yyunput('N'); yyunput('G'); yyunput('\0'); + yyreject(); } GNU printf("GNU is Not Unix!\n"); %% diff --git a/examples/manual/replace.lex b/examples/manual/replace.lex index c5c8d87..a7062bc 100644 --- a/examples/manual/replace.lex +++ b/examples/manual/replace.lex @@ -16,7 +16,7 @@ char upper_replace[1024]; "yy" printf("%s",lower_replace); "YY" printf("%s",upper_replace); -, ECHO; +, yyecho(); %% diff --git a/examples/manual/string1.lex b/examples/manual/string1.lex index b62ed88..3a3276d 100644 --- a/examples/manual/string1.lex +++ b/examples/manual/string1.lex @@ -1,5 +1,5 @@ /* - * string1.lex: Handling strings by using input() + * string1.lex: Handling strings by using yyinput() */ %{ @@ -27,13 +27,13 @@ void yyerror(char *message) buffer = malloc(ALLOC_SIZE); max_size = ALLOC_SIZE; - inch = input(); + inch = yyinput(); count = 0; while(inch != EOF && inch != '"' && inch != '\n'){ if(inch == '\\'){ - inch = input(); + inch = yyinput(); switch(inch){ - case '\n': inch = input(); break; + case '\n': inch = yyinput(); break; case 'b' : inch = '\b'; break; case 't' : inch = '\t'; break; case 'n' : inch = '\n'; break; @@ -41,10 +41,10 @@ void yyerror(char *message) case 'f' : inch = '\f'; break; case 'r' : inch = '\r'; break; case 'X' : - case 'x' : inch = input(); + case 'x' : inch = yyinput(); if(isxdigit(inch)){ temp = hextoint(toupper(inch)); - inch = input(); + inch = yyinput(); if(isxdigit(inch)){ temp = (temp << 4) + hextoint(toupper(inch)); } else { @@ -59,14 +59,14 @@ void yyerror(char *message) default: if(isodigit(inch)){ temp = inch - '0'; - inch = input(); + inch = yyinput(); if(isodigit(inch)){ temp = (temp << 3) + (inch - '0'); } else { unput(inch); goto done; } - inch = input(); + inch = yyinput(); if(isodigit(inch)){ temp = (temp << 3) + (inch - '0'); } else { @@ -82,7 +82,7 @@ void yyerror(char *message) buffer = realloc(buffer,max_size + ALLOC_SIZE); max_size += ALLOC_SIZE; } - inch = input(); + inch = yyinput(); } if(inch == EOF || inch == '\n'){ yyerror("Unterminated string."); diff --git a/examples/manual/string2.lex b/examples/manual/string2.lex index 2c9d35f..f6d0c17 100644 --- a/examples/manual/string2.lex +++ b/examples/manual/string2.lex @@ -30,17 +30,17 @@ oct [0-7]{1,3} \" { buffer = malloc(1); buffer_size = 1; strcpy(buffer,""); - BEGIN(STRING); + yybegin(STRING); } \n { yyerror("Unterminated string"); free(buffer); - BEGIN(INITIAL); + yybegin(INITIAL); } <> { yyerror("EOF in string"); free(buffer); - BEGIN(INITIAL); + yybegin(INITIAL); } [^\\\n"] { buffer = realloc(buffer,buffer_size+yyleng+1); @@ -87,7 +87,7 @@ oct [0-7]{1,3} \" { printf("string = \"%s\"",buffer); free(buffer); - BEGIN(INITIAL); + yybegin(INITIAL); } %% diff --git a/examples/manual/unput.lex b/examples/manual/unput.lex index 161471a..21b42dc 100644 --- a/examples/manual/unput.lex +++ b/examples/manual/unput.lex @@ -1,6 +1,6 @@ /* * unput.l : An example of what *not* - * to do with unput(). + * to do with yyunput(). */ @@ -24,7 +24,7 @@ void putback_yytext(void) strcpy(buffer,yytext); printf("Got: %s\n",yytext); for(i=0; i[^\\\n"]* yymore(); -<> yyerror("EOF in string."); BEGIN(INITIAL); -\n yyerror("Unterminated string."); BEGIN(INITIAL); +<> yyerror("EOF in string."); yybegin(INITIAL); +\n yyerror("Unterminated string."); yybegin(INITIAL); \\\n yymore(); \" { yytext[yyleng-1] = '\0'; - printf("string = \"%s\"",yytext); BEGIN(INITIAL); + printf("string = \"%s\"",yytext); yybegin(INITIAL); } %% diff --git a/examples/manual/yymore2.lex b/examples/manual/yymore2.lex index f49ea23..dbe4915 100644 --- a/examples/manual/yymore2.lex +++ b/examples/manual/yymore2.lex @@ -16,11 +16,11 @@ void yyerror(char *message) %x STRING %% -\" BEGIN(STRING); +\" yybegin(STRING); [^\\\n"]* yymore(); -<> yyerror("EOF in string."); BEGIN(INITIAL); -\n yyerror("Unterminated string."); BEGIN(INITIAL); +<> yyerror("EOF in string."); yybegin(INITIAL); +\n yyerror("Unterminated string."); yybegin(INITIAL); \\\n { bcopy(yytext,yytext+2,yyleng-2); yytext += 2; yyleng -= 2; @@ -28,6 +28,6 @@ void yyerror(char *message) } \" { yyleng -= 1; yytext[yyleng] = '\0'; - printf("string = \"%s\"",yytext); BEGIN(INITIAL); + printf("string = \"%s\"",yytext); yybegin(INITIAL); } %% -- cgit v1.2.1 From e7611bea3c14157d8531cd7dd7f439ac997a33bd Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 13 Oct 2020 05:40:59 -0400 Subject: Three more namespace cleanups for multilanguage. Replace YY_FLUSH_BUFFER with yy_flush_current_buffer() Replace YY_CURRENT_BUFFER with yy_current_buffer(). Replace YY_BUFFER_STATE with yybuffer. The following are the all-caps definitions still exposed: YY_FLEX_MAJOR_VERSION YY_FLEX_MINOR_VERSION YY_FLEX_SUBMINOR_VERSION YY_NULL YY_END_OF_BUFFER_CHAR YY_BUF_SIZE YYLMAX It is not idea for this list to be nonempty, but at least these are all actual comple-time constants rather than function calls or type names. --- doc/flex.texi | 105 +++++++++++++++++++-------------- examples/manual/eof_rules.lex | 2 +- examples/manual/pas_include.lex | 2 +- src/cpp-flex.skl | 125 +++++++++++++++++++++------------------- 4 files changed, 130 insertions(+), 104 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 8d3d573..8c1242d 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1471,12 +1471,12 @@ example, the following is one way to eat up C comments: @end example @cindex flushing the internal buffer -@cindex YY_FLUSH_BUFFER -@code{YY_FLUSH_BUFFER;} flushes the scanner's internal buffer so that +@cindex yy_flush_current_buffer() +@code{yy_flush_current_buffer()} flushes the scanner's internal buffer so that the next time the scanner attempts to match a token, it will first refill the buffer using @code{yyread()} (@pxref{Generated Scanner}). This action is a special case of the more general -@code{yy_flush_buffer;} function, described below (@pxref{Multiple +@code{yy_flush_buffer()} function, described below (@pxref{Multiple Input Buffers}) @cindex yyterminate() @@ -1562,7 +1562,7 @@ the latter is available for compatibility with previous versions of @code{flex}, and because it can be used to switch input files in the middle of scanning. It can also be used to throw away the current input buffer, by calling it with an argument of @file{yyin}; but it would be -better to use @code{YY_FLUSH_BUFFER} (@pxref{Actions}). Note that +better to use @code{yy_flush_current_buffer()} (@pxref{Actions}). Note that @code{yyrestart()} does @emph{not} reset the start condition to @code{INITIAL} (@pxref{Start Conditions}). @@ -2056,13 +2056,13 @@ for creating and switching between multiple input buffers. An input buffer is created by using: @cindex memory, allocating input buffers -@deftypefun YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ) +@deftypefun yybuffer yy_create_buffer ( FILE *file, int size ) @end deftypefun which takes a @code{FILE} pointer and a size and creates a buffer associated with the given file and large enough to hold @code{size} characters (when in doubt, use @code{YY_BUF_SIZE} for the size). It -returns a @code{YY_BUFFER_STATE} handle, which may then be passed to +returns a @code{yybuffer} handle, which may then be passed to other routines (see below). In target languages other than C/C++, this prototype will look @@ -2071,11 +2071,11 @@ not have ``struct'' as part of its name. The input-stream type won't be @code{FILE *}. But expect the same semamntics wxpressed in native tytypes. -@tindex YY_BUFFER_STATE -The @code{YY_BUFFER_STATE} type is a -pointer to an opaque @code{struct yy_buffer_state} structure, so you may -safely initialize @code{YY_BUFFER_STATE} variables to @code{((YY_BUFFER_STATE) -0)} if you wish, and also refer to the opaque structure in order to +@tindex yybuffer +The @code{yybuffer} type is a +reference to an opaque buffer state structure, so you may +safely initialize @code{yybuffer} variables to @code{((yybuffer) +NULL)} if you wish, and also refer to the opaque structure in order to correctly declare input buffers in source files other than that of your scanner. Note that the @code{FILE} pointer in the call to @code{yy_create_buffer} is only used as the value of @file{yyin} seen by @@ -2084,7 +2084,7 @@ scanner. Note that the @code{FILE} pointer in the call to @code{yy_create_buffer}. You select a particular buffer to scan from using: -@deftypefun void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ) +@deftypefun void yy_switch_to_buffer ( yybuffer new_buffer ) @end deftypefun The above function switches the scanner's input buffer so subsequent tokens @@ -2097,7 +2097,7 @@ instead of this function. Note also that switching input sources via either start condition. @cindex memory, deleting input buffers -@deftypefun void yy_delete_buffer ( YY_BUFFER_STATE buffer ) +@deftypefun void yy_delete_buffer ( yybuffer buffer ) @end deftypefun is used to reclaim the storage associated with a buffer. (@code{buffer} @@ -2106,7 +2106,7 @@ the current contents of a buffer using: @cindex pushing an input buffer @cindex stack, input buffer push -@deftypefun void yypush_buffer_state ( YY_BUFFER_STATE buffer ) +@deftypefun void yypush_buffer_state ( yybuffer buffer ) @end deftypefun This function pushes the new buffer state onto an internal stack. The pushed @@ -2126,7 +2126,7 @@ becomes the new current state. @cindex clearing an input buffer @cindex flushing an input buffer -@deftypefun void yy_flush_buffer ( YY_BUFFER_STATE buffer ) +@deftypefun void yy_flush_buffer ( yybuffer buffer ) @end deftypefun This function discards the buffer's contents, @@ -2134,17 +2134,18 @@ so the next time the scanner attempts to match a token from the buffer, it will first fill the buffer anew using @code{yyread()}. -@deftypefun YY_BUFFER_STATE yy_new_buffer ( FILE *file, int size ) +@deftypefun yybuffer yy_new_buffer ( FILE *file, int size ) @end deftypefun is an alias for @code{yy_create_buffer()}, provided for compatibility with the C++ use of @code{new} and @code{delete} for creating and destroying dynamic objects. -@cindex YY_CURRENT_BUFFER, and multiple buffers -Finally, the macro @code{YY_CURRENT_BUFFER} macro returns a -@code{YY_BUFFER_STATE} handle to the current buffer. It should not be -used as an lvalue. +@cindex yy_current_buffer(), and multiple buffers +Finally, @code{yy_current_buffer()} returns a +@code{yybuffer} handle to the current buffer. It should not be +used as an lvalue, because it can return NULL to indicate no buffer is +current. @cindex EOF, example using multiple input buffers Here are two examples of using these features for writing a scanner @@ -2183,7 +2184,7 @@ maintains the stack internally. <> { yypop_buffer_state(); - if ( !YY_CURRENT_BUFFER ) + if ( !yy_current_buffer() ) { yyterminate(); } @@ -2204,7 +2205,7 @@ manages its own input buffer stack manually (instead of letting flex do it). %{ #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; + yybuffer include_stack[MAX_INCLUDE_DEPTH]; int include_stack_ptr = 0; %} @@ -2223,7 +2224,7 @@ manages its own input buffer stack manually (instead of letting flex do it). } include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; + yy_current_buffer(); yyin = fopen( yytext, "r" ); @@ -2244,7 +2245,7 @@ manages its own input buffer stack manually (instead of letting flex do it). else { - yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_delete_buffer( yy_current_buffer() ); yy_switch_to_buffer( include_stack[include_stack_ptr] ); } @@ -2257,16 +2258,16 @@ manages its own input buffer stack manually (instead of letting flex do it). The following routines are available for setting up input buffers for scanning in-memory strings instead of files. All of them create a new input buffer for scanning the string, and return a corresponding -@code{YY_BUFFER_STATE} handle (which you should delete with +@code{yybuffer} handle (which you should delete with @code{yy_delete_buffer()} when done with it). They also switch to the new buffer using @code{yy_switch_to_buffer()}, so the next call to @code{yylex()} will start scanning the string. -@deftypefun YY_BUFFER_STATE yy_scan_string ( const char *str ) +@deftypefun yybuffer yy_scan_string ( const char *str ) scans a NUL-terminated string. @end deftypefun -@deftypefun YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ) +@deftypefun yybuffer yy_scan_bytes ( const char *bytes, int len ) scans @code{len} bytes (including possibly @code{NUL}s) starting at location @code{bytes}. @end deftypefun @@ -2277,7 +2278,7 @@ the contents of the buffer it is scanning.) You can avoid the copy by using: @vindex YY_END_OF_BUFFER_CHAR -@deftypefun YY_BUFFER_STATE yy_scan_buffer (char *base, yy_size_t size) +@deftypefun yybuffer yy_scan_buffer (char *base, yy_size_t size) which scans in place the buffer starting at @code{base}, consisting of @code{size} bytes, the last two bytes of which @emph{must} be @code{YY_END_OF_BUFFER_CHAR} (ASCII NUL). These last two bytes are not @@ -2429,7 +2430,7 @@ Setting a post-action allows, for example, C++ users to suppress the trailing break (while being very careful that every rule ends with a @code{break} or a @code{return}!) to avoid suffering from unreachable statement warnings where because a rule's action ends with -@code{return}, the @code{YY_BREAK} is inaccessible. +@code{return}, the break is inaccessible. @node User Values, Yacc, Misc Controls, Top @chapter Values Available To the User @@ -2493,9 +2494,9 @@ by the user. In target languages other than C/C++, expect it to have whatever tyoe is associated with I/O streams. -@vindex YY_CURRENT_BUFFER -@item YY_CURRENT_BUFFER -returns a @code{YY_BUFFER_STATE} handle to the current buffer. +@vindex yy_current_buffer() +@item yy_current_buffer() +returns a @code{yybuffer} handle to the current buffer. @vindex yystart() @item yystart() @@ -3860,7 +3861,7 @@ returns the current setting of the debugging flag. Also provided are member functions equivalent to @code{yy_switch_to_buffer()}, @code{yy_create_buffer()} (though the first argument is an @code{istream&} object reference and not a -@code{FILE*)}, @code{yy_flush_buffer()}, @code{yy_delete_buffer()}, and +@code{FILE*)}, @code{yy_flush_current_buffer()}, @code{yy_delete_buffer()}, and @code{yyrestart()} (again, the first argument is a @code{istream&} object reference). @@ -4105,7 +4106,7 @@ another instance of itself. %% "eval(".+")" { yyscan_t scanner; - YY_BUFFER_STATE buf; + yybuffer buf; yylex_init( &scanner ); yytext[yyleng-1] = ' '; @@ -4917,8 +4918,8 @@ specified. You will rarely need to tune this buffer. The ideal size for this stack is the maximum depth expected. The memory for this stack is automatically destroyed when you call yylex_destroy(). @xref{option-stack}. -@item 40 bytes for each YY_BUFFER_STATE. -Flex allocates memory for each YY_BUFFER_STATE. The buffer state itself +@item 40 bytes for each yybuffer. +Flex allocates memory for each yybuffer. The buffer state itself is about 40 bytes, plus an additional large character buffer (described above.) The initial buffer state is created during initialization, and with each call to yy_create_buffer(). You can't tune the size of this, but you can tune the @@ -6075,7 +6076,7 @@ However, you can do this using multiple input buffers. %% macro/[a-z]+ { /* Saw the macro "macro" followed by extra stuff. */ -main_buffer = YY_CURRENT_BUFFER; +main_buffer = yy_current_buffer(); expansion_buffer = yy_scan_string(expand(yytext)); yy_switch_to_buffer(expansion_buffer); } @@ -6212,7 +6213,7 @@ you might try this: @example @verbatim /* For non-reentrant C scanner only. */ -yy_delete_buffer(YY_CURRENT_BUFFER); +yy_delete_buffer(yy_current_buffer()); yy_init = 1; @end verbatim @end example @@ -6228,7 +6229,7 @@ situation. It is possible that some other globals may need resetting as well. > We thought that it would be possible to have this number through the > evaluation of the following expression: > -> seek_position = (no_buffers)*YY_READ_BUF_SIZE + yy_c_buf_p - YY_CURRENT_BUFFER->yy_ch_buf +> seek_position = (no_buffers)*YY_READ_BUF_SIZE + yy_c_buf_p - yy_current_buffer()->yy_ch_buf @end verbatim @end example @@ -6239,7 +6240,7 @@ even though @code{YY_READ_BUF_SIZE} bytes were requested). The second problem is that when refilling its internal buffer, @code{flex} keeps some characters from the previous buffer (because usually it's in the middle of a match, and needs those characters to construct @code{yytext} for the match once it's -done). Because of this, @code{yy_c_buf_p - YY_CURRENT_BUFFER->yy_ch_buf} won't +done). Because of this, @code{yy_c_buf_p - yy_current_buffer()->yy_ch_buf} won't be exactly the number of characters already read from the current buffer. An alternative solution is to count the number of characters you've matched @@ -6597,7 +6598,7 @@ Date: Wed, 13 Nov 1996 19:51:54 PST From: Vern Paxson > "yyunput()" them to input flow, question occurs. If I do this after I scan -> a carriage, the variable "YY_CURRENT_BUFFER->yy_at_bol" is changed. That +> a carriage, the variable "yy_current_buffer()->yy_at_bol" is changed. That > means the carriage flag has gone. You can control this by calling yy_set_bol(). It's described in the manual. @@ -7026,7 +7027,7 @@ In-reply-to: Your message of Mon, 08 Dec 1997 15:54:15 PST. Date: Mon, 15 Dec 1997 13:21:35 PST From: Vern Paxson -> stdin_handle = YY_CURRENT_BUFFER; +> stdin_handle = yy_current_buffer(); > ifstream fin( "aFile" ); > yy_switch_to_buffer( yy_create_buffer( fin, YY_BUF_SIZE ) ); > @@ -8848,6 +8849,15 @@ yunput(): Replaced by yyunput(). YYSTATE: is accepted as an alias for @code{yystart()} (since that is what's used by AT&T @code{lex}). +@item +YY_FLUSH_BUFFER: replaced by yy_flush_current_buffer(). + +@item +YY_CURRENT_BUFFER: replaced by yy_current_buffer(). + +@item +YY_BUFFER_STATE: replaced by yybuffer. + @item YY_NEW_FILE: In previous versions of @code{flex}, ehen assigning @file{yyin} to a new input file, after doing the assignment you had to @@ -8916,4 +8926,15 @@ to specific locations in the generated scanner, and may be used to insert arbitr @c endf @c nnoremap 1G/@node\s\+unnamed-faq-\d\+mfww"wy5ezt:call Faq2() +@c Remaining problem points for the multilangage interface +@c YY_NUM_RULES +@c YY_FLEX_MAJOR_VERSION +@c YY_FLEX_MINOR_VERSION +@c YY_FLEX_SUBMINOR_VERSION +@c YY_NULL +@c YY_END_OF_BUFFER_CHAR +@c YY_BUF_SIZE +@c YYLMAX + + @bye diff --git a/examples/manual/eof_rules.lex b/examples/manual/eof_rules.lex index e42fda7..14e3181 100644 --- a/examples/manual/eof_rules.lex +++ b/examples/manual/eof_rules.lex @@ -25,7 +25,7 @@ int include_count = -1; exit( 1 ); } - include_stack[++include_count] = YY_CURRENT_BUFFER; + include_stack[++include_count] = yy_current_buffer(); yyin = fopen( yytext, "r" ); if ( ! yyin ){ diff --git a/examples/manual/pas_include.lex b/examples/manual/pas_include.lex index 117ad56..b0a0a48 100644 --- a/examples/manual/pas_include.lex +++ b/examples/manual/pas_include.lex @@ -33,7 +33,7 @@ int include_count = -1; exit( 1 ); } - include_stack[++include_count] = YY_CURRENT_BUFFER; + include_stack[++include_count] = yy_current_buffer(); yyin = fopen( yytext, "r" ); if ( ! yyin ){ diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 96a317a..c776c3e 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -460,6 +460,8 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *yybuffer; +/* Legacy interface */ typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif @@ -606,7 +608,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ +static yybuffer * yy_buffer_stack = NULL; /**< Stack as an array. */ %endif %ok-for-header %endif @@ -619,9 +621,11 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], * * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \ +#define yy_current_buffer() ( YY_G(yy_buffer_stack) \ ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ : NULL) +/* Legacy interface */ +#define YY_CURRENT_BUFFER yy_current_buffer() /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -650,24 +654,25 @@ static int yy_did_buffer_switch_on_eof; %endif void yyrestart ( FILE *input_file M4_YY_PROTO_LAST_ARG ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size M4_YY_PROTO_LAST_ARG ); -void yy_delete_buffer ( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); -void yy_flush_buffer ( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); +void yy_switch_to_buffer ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); +yybuffer yy_create_buffer ( FILE *file, int size M4_YY_PROTO_LAST_ARG ); +void yy_delete_buffer ( yybuffer b M4_YY_PROTO_LAST_ARG ); +void yy_flush_buffer ( yybuffer b M4_YY_PROTO_LAST_ARG ); +void yypush_buffer_state ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); void yypop_buffer_state ( M4_YY_PROTO_ONLY_ARG ); m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ static void yyensure_buffer_stack ( M4_YY_PROTO_ONLY_ARG ); static void yy_load_buffer_state ( M4_YY_PROTO_ONLY_ARG ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG) +static void yy_init_buffer ( yybuffer b, FILE *file M4_YY_PROTO_LAST_ARG ); +#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG) +#define YY_FLUSH_BUFFER yy_flush_current_buffer() ]]) -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); +yybuffer yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); +yybuffer yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); +yybuffer yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); %endif @@ -680,7 +685,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ - if ( ! YY_CURRENT_BUFFER ){ \ + if ( yy_current_buffer() == NULL ){ \ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ @@ -689,7 +694,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], } #define yy_set_bol(at_bol) \ { \ - if ( ! YY_CURRENT_BUFFER ){\ + if ( yy_current_buffer() == NULL ){\ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ @@ -1214,7 +1219,7 @@ struct yyguts_t { FILE *yyin_r, *yyout_r; size_t yy_buffer_stack_top; /**< index of top of stack. */ size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + yybuffer * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; int yy_n_chars; int yyleng_r; @@ -1900,7 +1905,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyout.rdbuf(std::cout.rdbuf()); %endif } - if ( ! YY_CURRENT_BUFFER ) { + if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); @@ -2141,7 +2146,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our + * consistency between yy_current_buffer() and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. @@ -2329,7 +2334,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyFlexLexer::~yyFlexLexer() { delete [] yy_state_buf; yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); + yy_delete_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG); yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); } @@ -2461,7 +2466,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], ]], [[ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + yybuffer b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); @@ -2825,13 +2830,13 @@ void yyFlexLexer::yyrestart( std::istream& input_file ) { M4_YY_DECL_GUTS_VAR(); - if ( ! YY_CURRENT_BUFFER ) { + if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); } - yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); + yy_init_buffer( yy_current_buffer(), input_file M4_YY_CALL_LAST_ARG); yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); } @@ -2855,10 +2860,10 @@ void yyFlexLexer::yyrestart( std::istream* input_file ) * M4_YY_DOC_PARAM */ %if-c-only -void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) +void yy_switch_to_buffer YYFARGS1( yybuffer ,new_buffer) %endif %if-c++-only -void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +void yyFlexLexer::yy_switch_to_buffer( yybuffer new_buffer ) %endif { M4_YY_DECL_GUTS_VAR(); @@ -2869,10 +2874,10 @@ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - if ( YY_CURRENT_BUFFER == new_buffer ) { + if ( yy_current_buffer() == new_buffer ) { return; } - if ( YY_CURRENT_BUFFER ) { + if ( yy_current_buffer() ) { /* Flush out information for old buffer. */ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); @@ -2917,16 +2922,16 @@ void yyFlexLexer::yy_load_buffer_state() * @return the allocated buffer state. */ %if-c-only -YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) +yybuffer yy_create_buffer YYFARGS2( FILE *,file, int ,size) %endif %if-c++-only -YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) +yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) %endif { - YY_BUFFER_STATE b; + yybuffer b; M4_YY_DECL_GUTS_VAR(); - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); if ( ! b ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); } @@ -2953,7 +2958,7 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) * M4_YY_DOC_PARAM * @return the allocated buffer state. */ -YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +yybuffer yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { return yy_create_buffer( *file, size ); } @@ -2964,10 +2969,10 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) * M4_YY_DOC_PARAM */ %if-c-only -void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) +void yy_delete_buffer YYFARGS1( yybuffer ,b) %endif %if-c++-only -void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +void yyFlexLexer::yy_delete_buffer( yybuffer b ) %endif { M4_YY_DECL_GUTS_VAR(); @@ -2975,8 +2980,8 @@ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) if ( ! b ) { return; } - if ( b == YY_CURRENT_BUFFER ) { /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + if ( b == yy_current_buffer() ) { /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (yybuffer) 0; } if ( b->yy_is_our_buffer ) { yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); @@ -2990,10 +2995,10 @@ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) * such as during a yyrestart() or at EOF. */ %if-c-only -static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) +static void yy_init_buffer YYFARGS2( yybuffer ,b, FILE *,file) %endif %if-c++-only -void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) +void yyFlexLexer::yy_init_buffer( yybuffer b, std::istream& file ) %endif { int oerrno = errno; @@ -3013,7 +3018,7 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ - if (b != YY_CURRENT_BUFFER){ + if (b != yy_current_buffer()){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } @@ -3040,14 +3045,14 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param b the buffer state to be flushed, usually @c yy_current_buffer(). * M4_YY_DOC_PARAM */ %if-c-only -void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) +void yy_flush_buffer YYFARGS1( yybuffer ,b) %endif %if-c++-only -void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +void yyFlexLexer::yy_flush_buffer( yybuffer b ) %endif { M4_YY_DECL_GUTS_VAR(); @@ -3068,7 +3073,7 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == YY_CURRENT_BUFFER ) { + if ( b == yy_current_buffer() ) { yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); } } @@ -3081,10 +3086,10 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) * M4_YY_DOC_PARAM */ %if-c-only -void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) +void yypush_buffer_state YYFARGS1(yybuffer,new_buffer) %endif %if-c++-only -void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +void yyFlexLexer::yypush_buffer_state (yybuffer new_buffer) %endif { M4_YY_DECL_GUTS_VAR(); @@ -3094,7 +3099,7 @@ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) { + if ( yy_current_buffer() != NULL ) { /* Flush out information for old buffer. */ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); @@ -3102,7 +3107,7 @@ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) } /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) { + if (yy_current_buffer()) { YY_G(yy_buffer_stack_top)++; } YY_CURRENT_BUFFER_LVALUE = new_buffer; @@ -3127,15 +3132,15 @@ void yyFlexLexer::yypop_buffer_state (void) %endif { M4_YY_DECL_GUTS_VAR(); - if (!YY_CURRENT_BUFFER) { + if (yy_current_buffer() == NULL) { return; } - yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); + yy_delete_buffer(yy_current_buffer() M4_YY_CALL_LAST_ARG); YY_CURRENT_BUFFER_LVALUE = NULL; if (YY_G(yy_buffer_stack_top) > 0) { --YY_G(yy_buffer_stack_top); } - if (YY_CURRENT_BUFFER) { + if (yy_current_buffer()) { yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); YY_G(yy_did_buffer_switch_on_eof) = 1; } @@ -3208,9 +3213,9 @@ m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, * M4_YY_DOC_PARAM * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) +yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) { - YY_BUFFER_STATE b; + yybuffer b; m4_dnl M4_YY_DECL_GUTS_VAR(); if ( size < 2 || @@ -3219,7 +3224,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) /* They forgot to leave room for the EOB's. */ return NULL; } - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); if ( ! b ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); } @@ -3252,7 +3257,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string YYFARGS1( const char *, yystr) +yybuffer yy_scan_string YYFARGS1( const char *, yystr) { m4_dnl M4_YY_DECL_GUTS_VAR(); @@ -3272,8 +3277,8 @@ m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, * M4_YY_DOC_PARAM * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { - YY_BUFFER_STATE b; +yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { + yybuffer b; char *buf; yy_size_t n; int i; @@ -3414,7 +3419,7 @@ int yyget_lineno (M4_YY_DEF_ONLY_ARG) { m4_ifdef( [[M4_YY_REENTRANT]], [[ - if (! YY_CURRENT_BUFFER) + if (yy_current_buffer() == NULL) return 0; ]]) return yylineno; @@ -3432,7 +3437,7 @@ int yyget_column (M4_YY_DEF_ONLY_ARG) { M4_YY_DECL_GUTS_VAR(); m4_ifdef( [[M4_YY_REENTRANT]], [[ - if (! YY_CURRENT_BUFFER) { + if (yy_current_buffer() == NULL) { return 0; } ]]) @@ -3511,7 +3516,7 @@ void yyset_lineno YYFARGS1( int ,_line_number) { m4_ifdef( [[M4_YY_REENTRANT]], [[ /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) { + if (yy_current_buffer() == NULL ) { YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); } ]]) @@ -3532,7 +3537,7 @@ void yyset_column YYFARGS1( int , _column_no) { m4_ifdef( [[M4_YY_REENTRANT]], [[ /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) { + if (yy_current_buffer() == NULL ) { YY_FATAL_ERROR( "yyset_column called with no buffer" ); } ]]) @@ -3753,8 +3758,8 @@ int yylex_destroy (M4_YY_DEF_ONLY_ARG) { M4_YY_DECL_GUTS_VAR(); /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER) { - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); + while(yy_current_buffer()) { + yy_delete_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(M4_YY_CALL_ONLY_ARG); } -- cgit v1.2.1 From bcd857589706e1b91eb2567bd2e68210198b5f4d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 13 Oct 2020 09:29:24 -0400 Subject: Documentation polishing. --- doc/flex.texi | 85 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 8c1242d..9531366 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -387,8 +387,8 @@ on hidden global variables; thus when Flex generates a scanner in any language other than the original C/C++ non-reentrancy is not even an option. -This, it's a good idea to get used to using the reentrant interface -from the beginning of your Flex programming. This is so even though the +It's a good idea to get used to using the reentrant interface from the +beginning of your Flex programming. This is so even though the reentrant example above is a rather poor one; it avoids exposing the scanner state in globals but creates globals of its own. There is a mechanism for including user-defined fields in the scanner structure @@ -640,9 +640,10 @@ The presence of this section is optional; if it is missing, the second @cindex comments, syntax of Flex supports C-style comments, that is, anything between @samp{/*} and @samp{*/} is -considered a comment. Whenever flex encounters a comment, it copies the -entire comment verbatim to the generated source code. Comments may -appear just about anywhere, but with the following exceptions: +considered a comment in the parts of the file Flex +interprets. Whenever flex encounters a comment, it copies the entire +comment verbatim to the generated source code. Comments may appear +just about anywhere, but with the following exceptions: @itemize @cindex comments, in rules section @@ -666,7 +667,7 @@ All the comments in the following example are valid: @example @verbatim %{ -/* code block */ +/* C code block - other target languages might have different comment syntax */ %} /* Definitions Section */ @@ -674,21 +675,23 @@ All the comments in the following example are valid: %% /* Rules Section */ -ruleA /* after regex */ { /* code block */ } /* after code block */ +ruleA /* after regex */ { /* C code block */ } /* after code block */ /* Rules Section (indented) */ { ruleC yyecho(); ruleD yyecho(); %{ -/* code block */ +/* C code block */ %} } %% -/* User Code Section */ - +/* User C Code Section */ @end verbatim @end example +If the target language is something other than C/C++, you will need to use +its normal comment syntax in actions and code blocks. + @node Patterns, Matching, Format, Top @chapter Patterns @@ -1538,7 +1541,7 @@ only, leaving K&R-style functions to the historians. In other languages, @code{yylex()} will be generated as a reentrant function with a scanner context argument added. This can be enabled -in C as well, and specifying your C scanners to be rrentrant is +in C as well, and specifying your C scanners to be reentrant is recommended for portability. @cindex stdin, default for yyin @@ -1557,11 +1560,11 @@ scanning continues from that file), or @code{yyrestart()} is called. @code{yyrestart()} takes one argument, an inoput stream, and initializes @file{yyin} for scanning from that stream. Essentially there is no difference between just assigning -@file{yyin} to a new input file or using @code{yyrestart()} to do so; +@file{yyin} to a new input stream or using @code{yyrestart()} to do so; the latter is available for compatibility with previous versions of @code{flex}, and because it can be used to switch input files in the middle of scanning. It can also be used to throw away the current input -buffer, by calling it with an argument of @file{yyin}; but it would be +buffer, by calling it with an argument of @code{yyin}; but it would be better to use @code{yy_flush_current_buffer()} (@pxref{Actions}). Note that @code{yyrestart()} does @emph{not} reset the start condition to @code{INITIAL} (@pxref{Start Conditions}). @@ -1576,7 +1579,7 @@ statement in one of the actions, the scanner may then be called again and it will resume scanning where it left off. @cindex yyread -By default (and for purposes of efficiency), C/C++ scanners use +By default (and for purposes of efficiency), scanners use block-reads rather than simple @code{getc()} calls to read characters from @file{yyin}. The nature of how it gets its input can be controlled by redefining the @code{yyread} function used to fill the scanner buffer. The calling sequence for @@ -1632,9 +1635,9 @@ For scanning from in-memory buffers (e.g., scanning strings), see @cindex yyecho(), and yyout @cindex yyout @cindex stdout, as default for yyout -The scanner writes its @code{yyecho()} output to the @file{yyout} global +The scanner writes its @code{yyecho()} output to the @code{yyout} global (default, @file{stdout}), which may be redefined by the user simply by -assigning it to some other @code{FILE} pointer. +assigning it to some other sream - in C/C++, a @code{FILE} pointer. @node Start Conditions, Multiple Input Buffers, Generated Scanner, Top @chapter Start Conditions @@ -2263,8 +2266,10 @@ input buffer for scanning the string, and return a corresponding new buffer using @code{yy_switch_to_buffer()}, so the next call to @code{yylex()} will start scanning the string. -@deftypefun yybuffer yy_scan_string ( const char *str ) -scans a NUL-terminated string. +@deftypefun yybuffer yy_scan_string ( char *str ) +scans a string. This declaration is correct for C/C++, in which +strings are simply character seqences terminated by a NUL. In target +languages with a native strbg type, the prototype will change. @end deftypefun @deftypefun yybuffer yy_scan_bytes ( const char *bytes, int len ) @@ -4204,16 +4209,13 @@ Here are the things you need to do or know to use the reentrant C API of @node Specify Reentrant, Extra Reentrant Argument, Reentrant Detail, Reentrant Detail @subsection Declaring a Scanner As Reentrant -When using the default C/C++ back end %option reentrant (--reentrant) must be specified. - Notice that @code{%option reentrant} is specified in the above example -(@pxref{Reentrant Example}. Had this option not been specified, -@code{flex} would have happily generated a non-reentrant scanner without -complaining. You may explicitly specify @code{%option noreentrant}, if -you do @emph{not} want a reentrant scanner, although it is not -necessary. The default is to generate a non-reentrant scanner. - -All scanners made with other back ends are reentrant. +(@pxref{Reentrant Example}. Had this option not been specified with +the default C/C++ back end, @code{flex} would have happily generated a +non-reentrant scanner without complaining. You may explicitly specify +@code{%option noreentrant}, if you do @emph{not} want a reentrant +scanner, although it is not necessary - and not effective in any other +target language. @node Extra Reentrant Argument, Global Replacement, Specify Reentrant, Reentrant Detail @subsection The Extra Argument @@ -4236,13 +4238,16 @@ non-reentrant scanner. Here are the declarations of Notice that the argument @code{yyscanner} appears in the declaration of both functions. In fact, all @code{flex} functions in a reentrant -scanner have this additional argument. It is always the last argument +scanner have this additional argument, except fot rule hooks which +get it supplied implicitly. + +It is always the last argument in the argument list, it is always of type @code{yyscan_t} (which is typedef'd to @code{void *}) and it is always named @code{yyscanner}. As you may have guessed, @code{yyscanner} is a pointer to an opaque data structure encapsulating the current state of the scanner. For a list of function declarations, -see @ref{Reentrant Functions}. Note that rule hooks, such as +see @ref{Reentrant Functions}. Rule hooks, such as @code{yybegin()}, @code{yyecho()}, @code{yyreject()}, and @code{yystart()}, do not take this additional argument. @@ -4307,7 +4312,7 @@ In these declarations, @code{YY_EXTRA_TYPE} is a placeholder for the type specifier in the scanner's @code{extra-type} option. (The scanner type and type declaration syntax will be different in target -languages other thab C/C++.) +languages other than C/C++.) The function @code{yylex_init} must be called before calling any other function. The argument to @code{yylex_init} is the address of an @@ -4431,7 +4436,7 @@ from outside the scanner, and through the shortcut macro @code{yyextra} from within the scanner itself. They are defined as follows: -@tindex YY_EXTRA_TYPE (reentrant only) +@tindex %option extra-type (reentrant only) @findex yyget_extra @findex yyset_extra @example @@ -4450,9 +4455,11 @@ In addition, an extra form of @code{yylex_init} is provided, be accessed from within the very first yyalloc, used to allocate the scanner itself. -By default, @code{YY_EXTRA_TYPE} is defined as type @code{void *}. You -may redefine this type using @code{%option extra-type="your_type"} in -the scanner: +In the deault C/C__ back end, the extra firld in your scanner state +structure is defined as type @code{void *}; in ither target languages +no such field night ne genetated at all. You may redefine or crrate +this extra field using @code{%option extra-type="your_type"} in the +scanner: @cindex YY_EXTRA_TYPE, defining your own type @example @@ -4877,7 +4884,7 @@ override the default behavior. This section applies only to target languages with manual memory allocation, including the default C/C++ back end. If your target -language has garbage collection you can ignore it. +language has garbage collection you can safely ignore it. A Flex-generated scanner allocates dynamic memory during initialization, and once in a while from @@ -4943,6 +4950,8 @@ you call yylex_init(). It is destroyed when the user calls yylex_destroy(). @node Overriding The Default Memory Management, A Note About yytext And Memory, The Default Memory Management, Memory Management @section Overriding The Default Memory Management +Afain, this section applies onlt to languages with manual memory management. + @cindex yyalloc, overriding @cindex yyrealloc, overriding @cindex yyfree, overriding @@ -5033,6 +5042,8 @@ void yyfree (void * ptr, void * yyscanner) { @cindex yytext, memory considerations +This section applies only to target languages with manual memory management. + When flex finds a match, @code{yytext} points to the first character of the match in the input buffer. The string itself is part of the input buffer, and is @emph{NOT} allocated separately. The value of yytext will be overwritten the next @@ -5067,7 +5078,7 @@ but none of them at the same time. The serialization feature allows the tables to be loaded at runtime, before scanning begins. The tables may be discarded when scanning is finished. -Note: This feature is available only when using the C/C++ back end. +Note: This feature is available only when using the default C/C++ back end. @menu * Creating Serialized Tables:: @@ -8663,7 +8674,7 @@ inside Flex when Flex is compiled. The skeleton files are part of the Flex source distribution; they are not required by the Flex executable. -A few poeces of language-specific information that cannot conveniently +A few pieces of language-specific information that cannot conveniently be represented in a skeleton file are supplied by a per-language method table in the C code. All the Flex code that accesses language-specific information goes through a global pointer named -- cgit v1.2.1 From 18ece7e2494dcd5eed3162e71f0f4ff673e6dec4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 13 Oct 2020 09:58:54 -0400 Subject: Modernize the C in the skeleton file. Good modern style in C is to write it as though it were a strongly typed language even though it isn't; thius, it's no l;onger considered good practice to apply ! to non-booleans. Also, fix some indentation annd vraxe usage for uniformity. --- src/cpp-flex.skl | 132 +++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index c776c3e..74e9375 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -25,7 +25,7 @@ %# prescriptive about whitespace and braces is more than usually %# important. So please set your C style to K&R, aka 1TBS with %# tabs when editing this file. Braces around single-statement -%# if/while/fo/do/switch/break bodies are mandatory. +%# if/while/for/do/switch/break bodies are mandatory. %# %# Macros for preproc stage. @@ -497,16 +497,20 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_LESS_LINENO(n) \ do { \ int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl )\ - if ( yytext[yyl] == '\n' )\ - --yylineno;\ + for ( yyl = n; yyl < yyleng; ++yyl ) { \ + if ( yytext[yyl] == '\n' ) { \ + --yylineno;\ + } \ + } \ }while(0) #define YY_LINENO_REWIND_TO(dst) \ do {\ const char *p;\ - for ( p = yy_cp-1; p >= (dst); --p)\ - if ( *p == '\n' )\ - --yylineno;\ + for ( p = yy_cp-1; p >= (dst); --p) { \ + if ( *p == '\n' ) { \ + --yylineno;\ + } \ + } \ }while(0) ]], [[ @@ -683,24 +687,23 @@ void yyfree ( void * M4_YY_PROTO_LAST_ARG ); m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ #define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( yy_current_buffer() == NULL ){ \ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ +#define yy_set_interactive(is_interactive) { \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } +} #define yy_set_bol(at_bol) \ { \ - if ( yy_current_buffer() == NULL ){\ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } +} #define yy_at_bol() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Legacy interface */ #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) @@ -1569,10 +1572,8 @@ static int yyread(char *buf, size_t max_size M4_YY_PROTO_LAST_ARG) { %if-c-only m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) - { - if( errno != EINTR) - { + while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) { + if( errno != EINTR) { YY_FATAL_ERROR( "input in flex scanner failed" ); break; } @@ -1581,39 +1582,38 @@ m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ } ]]) m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) - { + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) { int c = '*'; int n; for ( n = 0; n < max_size && - (c = getc( yyin )) != EOF && c != '\n'; ++n ) + (c = getc( yyin )) != EOF && c != '\n'; ++n ) { buf[n] = (char) c; - if ( c == '\n' ) + } + if ( c == '\n' ) { buf[n++] = (char) c; - if ( c == EOF && ferror( yyin ) ) + } + if ( c == EOF && ferror( yyin ) ) { YY_FATAL_ERROR( "input in flex scanner failed" ); - result = n; } - else - { + result = n; + } else { errno=0; - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) - { - if( errno != EINTR) - { + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) { + if( errno != EINTR) { YY_FATAL_ERROR( "input in flex scanner failed" ); break; - } + } errno=0; clearerr(yyin); - } } + } ]]) %endif %if-c++-only C++ definition - if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) + if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) { YY_FATAL_ERROR( "input in flex scanner failed" ); + } %endif return result; } @@ -1749,9 +1749,9 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ #define YY_RULE_SETUP \ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ + m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) { \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ + } \ ]]) YY_USER_ACTION ]]) @@ -1762,15 +1762,14 @@ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* Generate code to keep backing-up information. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ - if ( yy_current_state[-1].yy_nxt ) + if ( yy_current_state[-1].yy_nxt ) { ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - if ( yy_accept[yy_current_state] ) + if ( yy_accept[yy_current_state] ) { ]]) - { YY_G(yy_last_accepting_state) = yy_current_state; YY_G(yy_last_accepting_cpos) = yy_cp; - } + } ]]) ]]) ]]) @@ -1783,8 +1782,7 @@ m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ */ M4_GEN_BACKING_UP - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; m4_ifdef([[M4_MODE_USEMECS]], [[ @@ -1797,10 +1795,11 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ */ /* lastdfa + 2 == YY_JAMSTATE + 1 is the beginning of the templates */ - if (yy_current_state >= YY_JAMSTATE + 1) + if (yy_current_state >= YY_JAMSTATE + 1) { yy_c = yy_meta[yy_c]; -]]) } +]]) + } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ]]) @@ -2932,7 +2931,7 @@ yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) M4_YY_DECL_GUTS_VAR(); b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) { + if ( b == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); } b->yy_buf_size = size; @@ -2941,7 +2940,7 @@ yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); - if ( ! b->yy_ch_buf ) { + if ( b->yy_ch_buf == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); } b->yy_is_our_buffer = 1; @@ -2977,7 +2976,7 @@ void yyFlexLexer::yy_delete_buffer( yybuffer b ) { M4_YY_DECL_GUTS_VAR(); - if ( ! b ) { + if ( b == NULL ) { return; } if ( b == yy_current_buffer() ) { /* Not sure if we should pop here. */ @@ -3018,7 +3017,7 @@ void yyFlexLexer::yy_init_buffer( yybuffer b, std::istream& file ) * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ - if (b != yy_current_buffer()){ + if (b != yy_current_buffer()) { b->yy_bs_lineno = 1; b->yy_bs_column = 0; } @@ -3056,7 +3055,7 @@ void yyFlexLexer::yy_flush_buffer( yybuffer b ) %endif { M4_YY_DECL_GUTS_VAR(); - if ( ! b ) { + if ( b == NULL ) { return; } b->yy_n_chars = 0; @@ -3140,7 +3139,7 @@ void yyFlexLexer::yypop_buffer_state (void) if (YY_G(yy_buffer_stack_top) > 0) { --YY_G(yy_buffer_stack_top); } - if (yy_current_buffer()) { + if (yy_current_buffer() != NULL) { yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); YY_G(yy_did_buffer_switch_on_eof) = 1; } @@ -3162,7 +3161,7 @@ void yyFlexLexer::yyensure_buffer_stack(void) yy_size_t num_to_alloc; M4_YY_DECL_GUTS_VAR(); - if (!YY_G(yy_buffer_stack)) { + if (YY_G(yy_buffer_stack) == NULL) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. @@ -3171,7 +3170,7 @@ void yyFlexLexer::yyensure_buffer_stack(void) YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) { + if ( YY_G(yy_buffer_stack == NULL) ) { YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); } @@ -3191,7 +3190,7 @@ void yyFlexLexer::yyensure_buffer_stack(void) (YY_G(yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) M4_YY_CALL_LAST_ARG); - if ( ! YY_G(yy_buffer_stack) ) { + if (YY_G(yy_buffer_stack) == NULL) { YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); } /* zero only the new slots.*/ @@ -3225,7 +3224,7 @@ yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) return NULL; } b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); - if ( ! b ) { + if ( b == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); } b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ @@ -3287,7 +3286,7 @@ yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); - if ( ! buf ) { + if ( buf == 0 ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); } for ( i = 0; i < _yybytes_len; ++i ) { @@ -3296,7 +3295,7 @@ yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); - if ( ! b ) { + if ( b == NULL ) { YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); } /* It's okay to grow etc. this buffer, and we should throw it @@ -3419,8 +3418,9 @@ int yyget_lineno (M4_YY_DEF_ONLY_ARG) { m4_ifdef( [[M4_YY_REENTRANT]], [[ - if (yy_current_buffer() == NULL) - return 0; + if (yy_current_buffer() == NULL) { + return 0; + } ]]) return yylineno; } @@ -3667,14 +3667,14 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) yyset_extra (yy_user_defined, &dummy_yyguts); - if (ptr_yy_globals == NULL){ + if (ptr_yy_globals == NULL) { errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - if (*ptr_yy_globals == NULL){ + if (*ptr_yy_globals == NULL) { errno = ENOMEM; return 1; } @@ -3871,7 +3871,7 @@ m4preproc_include(`tables_shared.c') static int yytbl_read8 (void *v, struct yytbl_reader * rd) { errno = 0; - if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ + if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1) { errno = EIO; return -1; } @@ -3881,7 +3881,7 @@ static int yytbl_read8 (void *v, struct yytbl_reader * rd) { static int yytbl_read16 (void *v, struct yytbl_reader * rd) { errno = 0; - if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ + if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1) { errno = EIO; return -1; } @@ -3892,7 +3892,7 @@ static int yytbl_read16 (void *v, struct yytbl_reader * rd) { static int yytbl_read32 (void *v, struct yytbl_reader * rd) { errno = 0; - if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ + if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1) { errno = EIO; return -1; } @@ -4198,7 +4198,7 @@ static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) { /* Keep trying until we find the right set of tables or end of file. */ while (!feof(rd.fp)) { rd.bread = 0; - if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ + if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0) { rv = -1; goto return_rv; } -- cgit v1.2.1 From ee6ae49d671df0b149a9232843785bd51b5852b9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 06:23:17 -0400 Subject: Fix typo introduced when yyunput was added. The bad commit was: "Rename unput() to yyunput(); follow through in option switches." I shouldn't have missed this, but te build has normal warnings that obscured the waning from Flex. --- src/scan.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scan.l b/src/scan.l index ceb5d7b..af6f4ce 100644 --- a/src/scan.l +++ b/src/scan.l @@ -410,7 +410,7 @@ M4QEND "]""]" stdout env.use_stdout = option_sense; unistd ctrl.no_unistd = ! option_sense; unput ctrl.no_yyunput = ! option_sense; - yyinput ctrl.no_yyunput = ! option_sense; + yyunput ctrl.no_yyunput = ! option_sense; verbose env.printstats = option_sense; warn env.nowarn = ! option_sense; yylineno ctrl.do_yylineno = option_sense; -- cgit v1.2.1 From efed8275c5c047f0da75d65e9795d4b8daf56afe Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 05:20:05 -0400 Subject: Replace all conditional markup in the skeleton with macro conditionals. Because having two different consitionalization syntaxes was ugly and conducive to error. After this change there are %% breakpoints and %# comments and nothing else. Comments on %if lines have been preserved. I used the following script: ======================================================================== import sys flagstack = [] for line in sys.stdin: if (not line.startswith("%if")) and (not line.startswith("%endif")) and (not line.startswith("%ok-for")) and (not line.startswith("%not-for")): sys.stdout.write(line) continue elif line.startswith("%endif"): if flagstack.pop(): sys.stdout.write("]])\n") continue fields = line.strip().split() trailer = " ".join(fields[1:]) + "\n" if line.startswith("%if-bison-bridge"): sys.stdout.write("m4_ifdef([[M4_YY_BISON_LVAL]], [[\n") flagstack.append(True) elif line.startswith("%if-c++-only"): sys.stdout.write("m4_ifdef([[M4_MODE_CXX_ONLY]], [[\n") flagstack.append(True) elif line.startswith("%if-c-only"): sys.stdout.write("m4_ifdef([[M4_MODE_C_ONLY]], [[\n") flagstack.append(True) elif line.startswith("%if-c-or-c++"): flagstack.append(False) elif line.startswith("%if-not-reentrant"): sys.stdout.write("m4_ifdef([[M4_YY_NOT_REENTRANT]], [[\n") flagstack.append(True) elif line.startswith("%if-reentrant"): sys.stdout.write("m4_ifdef([[M4_YY_REENTRANT]], [[\n") flagstack.append(True) elif line.startswith("%if-tables-serialization"): sys.stdout.write("m4_ifdef([[M4_MODE_TABLESEXT]], [[\n") flagstack.append(True) elif line.startswith("%not-for-header"): sys.stdout.write("m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl\n") elif line.startswith("%ok-for-header"): sys.stdout.write("]])\n") else: sys.stderr.write("depercent: unrecognized %r\n" % line) raise SystemExit(1) if trailer.strip(): sys.stdout.write("%# " + trailer) ======================================================================== One nasty little abuse if markup around yyread_r had to be fixed up by hand. --- src/cpp-flex.skl | 593 +++++++++++++++++++++++++++---------------------------- src/main.c | 12 +- 2 files changed, 297 insertions(+), 308 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 74e9375..2fea8fb 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -42,24 +42,12 @@ m4_changequote([[, ]]) %# listed and processed in misc.c. %# %# %# - A comment. The current line is omitted from the generated scanner. -%# %if-c++-only - The following lines are printed for C++ scanners ONLY. -%# %if-c-only - The following lines are NOT printed for C++ scanners. -%# %if-c-or-c++ - The following lines are printed in BOTH C and C++ scanners. -%# %if-reentrant - Print for reentrant scanners.(push) -%# %if-not-reentrant - Print for non-reentrant scanners. (push) -%# %if-bison-bridge - Print for bison-bridge. (push) -%# %if-not-bison-bridge - Print for non-bison-bridge. (push) -%# %endif - pop from the previous if code. %# %% - A stop-point, where code is inserted by flex. %# Each stop-point is numbered here and also in the code generator. %# (See gen.c, etc. for details.) -%# %not-for-header - Begin code that should NOT appear in a ".h" file. -%# %ok-for-header - %c and %e are used for building a header file. -%# %if-tables-serialization %# -%# All control-lines EXCEPT comment lines ("%#") will be inserted into -%# the generated scanner as a C-style comment. This is to aid those who -%# edit the skeleton. +%# Stop points will be inserted into the generated scanner as a comment. +%# This is to aid those who edit the skeleton. %# %# Macro hooks used by Flex start here @@ -102,9 +90,9 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 %% [0.0] Make hook macros available to Flex -%not-for-header -%if-c-only -%if-not-reentrant +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ m4_ifelse(M4_MODE_PREFIX,yy,, #define yy_create_buffer M4_MODE_PREFIX[[_create_buffer]] #define yy_delete_buffer M4_MODE_PREFIX[[_delete_buffer]] @@ -132,9 +120,9 @@ m4_ifelse(M4_MODE_PREFIX,yy,, #define yyfree M4_MODE_PREFIX[[free]] #define yyread M4_MODE_PREFIX[[read]] ) -%endif -%endif -%ok-for-header +]]) +]]) +]]) #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION @@ -170,7 +158,7 @@ m4preproc_define(`M4_GEN_PREFIX',`` #undef yy$1 #endif]]'m4preproc_divert(0)') -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ /* The c++ scanner is a mess. The FlexLexer.h header file relies on the * following macro. This is required in order to pass the c++-multiple-scanners * test in the regression suite. We get reports that it breaks inheritance. @@ -178,9 +166,9 @@ m4preproc_define(`M4_GEN_PREFIX',`` * altogether. */ #define yyFlexLexer M4_MODE_PREFIX[[FlexLexer]] -%endif +]]) -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`_create_buffer') M4_GEN_PREFIX(`_delete_buffer') @@ -218,7 +206,7 @@ m4_ifelse(M4_MODE_PREFIX,yy,, ]]) M4_GEN_PREFIX(`wrap') ) -%endif +]]) m4_ifdef( [[M4_YY_BISON_LVAL]], [[ @@ -239,7 +227,7 @@ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`free') ) -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifelse(M4_MODE_PREFIX,yy,, m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ @@ -251,7 +239,7 @@ m4_ifdef( [[M4_YY_NOT_REENTRANT]], M4_GEN_PREFIX(`lineno') ]]) ) -%endif +]]) m4_ifdef( [[M4_MODE_TABLESEXT]], @@ -264,7 +252,7 @@ m4_ifdef( [[M4_MODE_TABLESEXT]], /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , [[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , [[/* Feature test macros. Flex uses functions that require a minimum set of @@ -287,27 +275,25 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #include #include #include -%endif +]]) -%if-tables-serialization +m4_ifdef([[M4_MODE_TABLESEXT]], [[ #include #include -%endif +]]) /* end standard C headers. */ /* begin standard C++ headers. */ -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #include #include #include #include #include /* end standard C++ headers. */ -%endif +]]) -%if-c-or-c++ m4preproc_include(`flexint_shared.h') -%endif /* TODO: this is always defined, so inline it */ #define yyconst const @@ -318,21 +304,21 @@ m4preproc_include(`flexint_shared.h') #define yynoreturn #endif -%not-for-header +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /* Returned upon end-of-file. */ #define YY_NULL 0 -%ok-for-header +]]) -%not-for-header +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /* Promotes a possibly negative, possibly signed char to an * integer in range [0..255] for use as an array index. */ #define YY_SC_TO_UI(c) ((YY_CHAR) (c)) -%ok-for-header +]]) -%if-reentrant +m4_ifdef([[M4_YY_REENTRANT]], [[ /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -380,11 +366,11 @@ m4_define( [[M4_YY_INCR_LINENO]], }while(0) ]]) -%endif +]]) -%if-not-reentrant +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ m4_define( [[M4_YY_INCR_LINENO]], [[ @@ -405,7 +391,7 @@ m4_define([[M4_YY_CALL_LAST_ARG]]) m4_define([[M4_YY_CALL_ONLY_ARG]]) m4_define( [[M4_YY_DOC_PARAM]], ) -%endif +]]) %# Generate C99 function defs. @@ -470,15 +456,15 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -%if-not-reentrant +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ extern int yyleng; -%endif +]]) -%if-c-only -%if-not-reentrant +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ extern FILE *yyin, *yyout; -%endif -%endif +]]) +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -539,12 +525,12 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ FILE *yy_input_file; -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::streambuf* yy_input_file; -%endif +]]) char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -605,17 +591,18 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -%if-c-only Standard (non-C++) definition -%not-for-header -%if-not-reentrant +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static yybuffer * yy_buffer_stack = NULL; /**< Stack as an array. */ -%endif -%ok-for-header -%endif +]]) +]]) +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -636,10 +623,11 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] ]]) -%if-c-only Standard (non-C++) definition +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition -%if-not-reentrant -%not-for-header +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ @@ -654,8 +642,8 @@ static int yy_start = 0; /* start state number */ * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; -%ok-for-header -%endif +]]) +]]) void yyrestart ( FILE *input_file M4_YY_PROTO_LAST_ARG ); void yy_switch_to_buffer ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); @@ -678,7 +666,7 @@ yybuffer yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); yybuffer yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); yybuffer yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); -%endif +]]) void *yyalloc ( yy_size_t M4_YY_PROTO_LAST_ARG ); void *yyrealloc ( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); @@ -712,14 +700,14 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], /* Begin user sect3 */ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef([[M4_YY_REENTRANT]], [[ #define M4_MODE_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) ]]) m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ #define M4_MODE_PREFIX[[wrap]]() (/*CONSTCOND*/1) ]])m4_dnl -%endif +]]) #define YY_SKIP_YYWRAP ]]) m4_ifdef( [[M4_MODE_DEBUG]], [[ @@ -728,7 +716,7 @@ m4_ifdef( [[M4_MODE_DEBUG]], [[ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl typedef flex_uint8_t YY_CHAR; ]])m4_dnl -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_define([[M4_TMP_STDINIT]], [[FILE *yyin = stdin, *yyout = stdout;]]) m4_define([[M4_TMP_NO_STDINIT]], [[FILE *yyin = NULL, *yyout = NULL;]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -760,30 +748,30 @@ M4_TMP_NO_STDINIT ]]) m4_undefine([[M4_TMP_STDINIT]]) m4_undefine([[M4_TMP_NO_STDINIT]]) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #define yytext_ptr yytext m4_ifdef( [[M4_MODE_INTERACTIVE]], [[#define YY_INTERACTIVE]]) -%endif +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl typedef const struct yy_trans_info *yy_state_type; ]], [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ typedef int yy_state_type; -%endif +]]) ]]) ]]) m4_ifdef([[M4_MODE_LEX_COMPAT]], [[#define YY_FLEX_LEX_COMPAT]]) -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ extern int yylineno; m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl int yylineno = 1; ]]) ]]) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #include m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ @@ -798,8 +786,8 @@ int yyFlexLexer::yylex() #define YY_DECL int M4_YY_CLASS_NAME::yylex() ]]) -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ /* Watch out: yytext_ptr is a variable when yytext is an array, * but it's a macro when yytext is a pointer. */ @@ -816,14 +804,15 @@ extern char *yytext; #define yytext_ptr yytext ]]) ]]) -%endif +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ %% [1.5] DFA ]]) -%if-c-only Standard (non-C++) definition +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -833,7 +822,7 @@ static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); ]]) -%endif +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ struct yy_trans_info @@ -889,13 +878,13 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ ]]) \ YY_G(yy_c_buf_p) = yy_cp; -%if-not-reentrant +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ m4_ifdef( [[M4_MODE_C_ONLY]], [[ extern int yy_flex_debug; int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); ]]) -%endif +]]) %% [2.0] data tables for the DFA are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl @@ -1188,12 +1177,12 @@ m4_ifdef( [[M4_YY_NO_UNISTD_H]],, * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ #include -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #include -%endif +]]) #endif ]]) @@ -1208,8 +1197,9 @@ m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], ]] ) -%if-c-only Reentrant structure and macros (non-C++). -%if-reentrant +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Reentrant structure and macros (non-C++). +m4_ifdef([[M4_YY_REENTRANT]], [[ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -1272,14 +1262,14 @@ m4_ifdef( [[]], [[ ]]) -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ static int yy_init_globals ( M4_YY_PROTO_ONLY_ARG ); ]]) -%endif +]]) -%if-reentrant +m4_ifdef([[M4_YY_REENTRANT]], [[ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -1300,9 +1290,9 @@ int yylex_init (yyscan_t* scanner); int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); -%endif +]]) -%endif End reentrant structures and macros. +]]) /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -1388,7 +1378,7 @@ void yyset_column ( int _column_no M4_YY_PROTO_LAST_ARG ); ]]) ]]) -%if-bison-bridge +m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_ifdef( [[M4_YY_NO_GET_LVAL]],, [[ YYSTYPE * yyget_lval ( M4_YY_PROTO_ONLY_ARG ); @@ -1408,7 +1398,7 @@ m4_ifdef( [[]], void yyset_lloc ( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); ]]) ]]) -%endif +]]) /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1422,15 +1412,15 @@ extern int yywrap ( M4_YY_PROTO_ONLY_ARG ); #endif #endif -%not-for-header +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl #ifndef YY_NO_YYUNPUT m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ static void yyunput_r ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); ]]) #endif -%ok-for-header -%endif +]]) +]]) #ifndef yytext_ptr static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); @@ -1443,18 +1433,18 @@ static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); m4_ifdef([[M4_MODE_NO_YYINPUT]], [[#define YY_NO_YYINPUT 1]]) #ifndef YY_NO_YYINPUT -//%if-c-only Standard (non-C++) definition -%not-for-header +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl static int yyinput ( M4_YY_PROTO_ONLY_ARG ); #ifndef __cplusplus #define input yyinput #endif -%ok-for-header -//%endif +]]) +]]) #endif -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ %# TODO: This is messy. m4_ifdef( [[M4_YY_STACK_USED]], [[ @@ -1491,7 +1481,7 @@ m4_define( [[M4_YY_NO_PUSH_STATE]]) m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -%endif +]]) /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE @@ -1507,15 +1497,17 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* Copy whatever the last rule matched to the standard output. */ #ifndef yyecho -%if-c-only Standard (non-C++) definition +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define yyecho() do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -%endif -%if-c++-only C++ definition +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +%# C++ definition #define yyecho() LexerOutput( yytext, yyleng ) -%endif +]]) #endif /* Legacy interface */ #define ECHO yyecho() @@ -1527,30 +1519,30 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_EXIT_FAILURE 2 #endif -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::LexerError( const char* msg ) { M4_YY_DECL_GUTS_VAR(); std::cerr << msg << std::endl; exit( YY_EXIT_FAILURE ); } -%endif +]]) /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #define YY_FATAL_ERROR(msg) LexerError( msg ) -%endif +]]) #endif /* Legacy interface */ @@ -1561,15 +1553,15 @@ m4_ifdef( [[M4_MODE_USER_YYREAD]], , [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ int yyFlexLexer::yyread(char *buf, size_t max_size) { -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ static int yyread(char *buf, size_t max_size M4_YY_PROTO_LAST_ARG) { -%endif +]]) int result; M4_YY_DECL_GUTS_VAR(); -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) { @@ -1608,13 +1600,14 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ } } ]]) -%endif +]]) -%if-c++-only C++ definition +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +%# C++ definition if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) { YY_FATAL_ERROR( "input in flex scanner failed" ); } -%endif +]]) return result; } #endif @@ -1637,7 +1630,8 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_START_STACK_INCR 25 #endif -%if-tables-serialization structures and prototypes +m4_ifdef([[M4_MODE_TABLESEXT]], [[ +%# structures and prototypes m4preproc_include(`tables_shared.h') /* Load the DFA tables from the given stream. */ @@ -1645,7 +1639,7 @@ int yytables_fload (FILE * fp M4_YY_PROTO_LAST_ARG); /* Unload the tables from memory. */ int yytables_destroy (M4_YY_PROTO_ONLY_ARG); -%not-for-header +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /** Describes a mapping from a serialized table id to its deserialized state in * this scanner. This is the bridge between our "generic" deserialization code @@ -1682,17 +1676,18 @@ struct yytbl_reader { flex_uint32_t bread; /**< bytes read since beginning of current tableset */ }; -%endif +]]) /* end tables serialization structures and prototypes */ -%ok-for-header +]]) /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -%if-c-only Standard (non-C++) definition +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition m4_define( [[M4_YY_LEX_PROTO]], [[(M4_YY_PROTO_ONLY_ARG)]]) @@ -1722,10 +1717,11 @@ m4_ifdef( [[]], extern int yylex M4_YY_LEX_PROTO; #define YY_DECL int yylex M4_YY_LEX_DECLARATION -%endif -%if-c++-only C++ definition +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +%# C++ definition #define YY_DECL int yyFlexLexer::yylex() -%endif +]]) #endif /* !YY_DECL */ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], @@ -1836,7 +1832,7 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ } ]]) -%not-for-header +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /** The main scanner function which does all the work. */ YY_DECL { @@ -1889,20 +1885,20 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], YY_G(yy_start) = 1; /* first start state */ } if ( ! yyin ) { -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ yyin = stdin; -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ yyin.rdbuf(std::cin.rdbuf()); -%endif +]]) } if ( ! yyout ) { -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ yyout = stdout; -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ yyout.rdbuf(std::cout.rdbuf()); -%endif +]]) } if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); @@ -2069,44 +2065,44 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], m4_ifdef([[M4_MODE_DEBUG]], [[ if ( yy_flex_debug ) { if ( yy_act == 0 ) { -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::cerr << "--scanner backing up\n"; -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--scanner backing up\n" ); -%endif +]]) } else if ( yy_act < YY_NUM_RULES ) { -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << "(\"" << yytext << "\")\n"; -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); -%endif +]]) } else if ( yy_act == YY_NUM_RULES ) { -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::cerr << "--accepting default rule (\"" << yytext << "\")\n"; -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); -%endif +]]) } else if ( yy_act == YY_NUM_RULES + 1 ) { -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::cerr << "--(end of buffer or a NUL)\n"; -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--(end of buffer or a NUL)\n" ); -%endif +]]) } else { -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::cerr << "--EOF (start condition " << YY_START << ")\n"; -%endif -%if-c-only +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); -%endif +]]) } } ]]) @@ -2151,12 +2147,12 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * back-up) that will match for the new input source. */ YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); -%endif +]]) YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -2271,10 +2267,10 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } /* end of scanning one token */ } /* end of user's declarations */ } /* end of yylex */ -%ok-for-header +]]) -%if-c++-only -%not-for-header +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /* The contents of this function are C++ specific, so the YY_G macro is not used. * This constructor simply maintains backward compatibility. * DEPRECATED @@ -2397,8 +2393,8 @@ int yyFlexLexer::LexerInput( char* buf, int max_size ) void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout.write( buf, size ); } -%ok-for-header -%endif +]]) +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ @@ -2409,12 +2405,12 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static int yy_get_next_buffer (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ int yyFlexLexer::yy_get_next_buffer() -%endif +]]) { M4_YY_DECL_GUTS_VAR(); char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; @@ -2543,13 +2539,13 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], /* yy_get_previous_state - get the state just before the EOB char was reached */ -%if-c-only -%not-for-header +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +m4_ifdef([[M4_MODE_C_ONLY]], [[ static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ yy_state_type yyFlexLexer::yy_get_previous_state() -%endif +]]) { yy_state_type yy_current_state; char *yy_cp; @@ -2595,12 +2591,12 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ * synopsis * next_state = yy_try_NUL_trans( current_state ); */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -%endif +]]) { int yy_is_jam; M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ @@ -2671,16 +2667,14 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ return yy_is_jam ? 0 : yy_current_state; } - -#ifndef YY_NO_YYUNPUT -%if-c-only -m4_ifdef( [[M4_YY_NO_YYUNPUT]],, -[[ +m4_ifdef([[M4_MODE_CXX_ONLY]], [[m4_undefine([[M4_YY_NO_YYUNPUT]])]]) +m4_ifdef( [[M4_YY_NO_YYUNPUT]], , [[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yyunput_r YYFARGS2( int,c, char *,yy_bp) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yyunput_r( int c, char* yy_bp) -%endif +]]) { char *yy_cp; M4_YY_DECL_GUTS_VAR(); @@ -2725,18 +2719,15 @@ m4_ifdef( [[M4_MODE_YYLINENO]], YY_G(yy_hold_char) = *yy_cp; YY_G(yy_c_buf_p) = yy_cp; } -%if-c-only ]]) -%endif -#endif -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ #ifndef YY_NO_YYINPUT int yyinput (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ int yyFlexLexer::yyinput() -%endif +]]) { int c; M4_YY_DECL_GUTS_VAR(); @@ -2811,21 +2802,21 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ return c; } -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ #endif /* ifndef YY_NO_YYINPUT */ -%endif +]]) /** Immediately switch to a different input stream. * @param input_file A readable stream. * M4_YY_DOC_PARAM * @note This function does not reset the start condition to @c INITIAL . */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ void yyrestart YYFARGS1( FILE *,input_file) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yyrestart( std::istream& input_file ) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); @@ -2839,7 +2830,7 @@ void yyFlexLexer::yyrestart( std::istream& input_file ) yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); } -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ /** Delegate to the new version that takes an istream reference. * @param input_file A readable stream. * M4_YY_DOC_PARAM @@ -2852,18 +2843,18 @@ void yyFlexLexer::yyrestart( std::istream* input_file ) } yyrestart( *input_file ); } -%endif +]]) /** Switch to a different input buffer. * @param new_buffer The new input buffer. * M4_YY_DOC_PARAM */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ void yy_switch_to_buffer YYFARGS1( yybuffer ,new_buffer) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_switch_to_buffer( yybuffer new_buffer ) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); @@ -2895,22 +2886,22 @@ void yyFlexLexer::yy_switch_to_buffer( yybuffer new_buffer ) } -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_load_buffer_state() -%endif +]]) { M4_YY_DECL_GUTS_VAR(); YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); -%endif +]]) YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); } @@ -2920,12 +2911,12 @@ void yyFlexLexer::yy_load_buffer_state() * M4_YY_DOC_PARAM * @return the allocated buffer state. */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ yybuffer yy_create_buffer YYFARGS2( FILE *,file, int ,size) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) -%endif +]]) { yybuffer b; M4_YY_DECL_GUTS_VAR(); @@ -2950,7 +2941,7 @@ yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) return b; } -%if-c++-only +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ /** Delegate creation of buffers to the new version that takes an istream reference. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. @@ -2961,18 +2952,18 @@ yybuffer yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { return yy_create_buffer( *file, size ); } -%endif +]]) /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * M4_YY_DOC_PARAM */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ void yy_delete_buffer YYFARGS1( yybuffer ,b) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_delete_buffer( yybuffer b ) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); @@ -2993,24 +2984,24 @@ void yyFlexLexer::yy_delete_buffer( yybuffer b ) * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yy_init_buffer YYFARGS2( yybuffer ,b, FILE *,file) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_init_buffer( yybuffer b, std::istream& file ) -%endif +]]) { int oerrno = errno; M4_YY_DECL_GUTS_VAR(); yy_flush_buffer( b M4_YY_CALL_LAST_ARG); -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ b->yy_input_file = file; -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ b->yy_input_file = file.rdbuf(); -%endif +]]) b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ @@ -3022,7 +3013,7 @@ void yyFlexLexer::yy_init_buffer( yybuffer b, std::istream& file ) b->yy_bs_column = 0; } -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], [[ b->yy_is_interactive = 1; @@ -3036,10 +3027,10 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; ]]) ]]) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ b->yy_is_interactive = 0; -%endif +]]) errno = oerrno; } @@ -3047,12 +3038,12 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], * @param b the buffer state to be flushed, usually @c yy_current_buffer(). * M4_YY_DOC_PARAM */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ void yy_flush_buffer YYFARGS1( yybuffer ,b) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_flush_buffer( yybuffer b ) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); if ( b == NULL ) { @@ -3077,19 +3068,18 @@ void yyFlexLexer::yy_flush_buffer( yybuffer b ) } } -%if-c-or-c++ /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * M4_YY_DOC_PARAM */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ void yypush_buffer_state YYFARGS1(yybuffer,new_buffer) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yypush_buffer_state (yybuffer new_buffer) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); if (new_buffer == NULL) { @@ -3115,20 +3105,18 @@ void yyFlexLexer::yypush_buffer_state (yybuffer new_buffer) yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); YY_G(yy_did_buffer_switch_on_eof) = 1; } -%endif -%if-c-or-c++ /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * M4_YY_DOC_PARAM */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ void yypop_buffer_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yypop_buffer_state (void) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); if (yy_current_buffer() == NULL) { @@ -3144,19 +3132,17 @@ void yyFlexLexer::yypop_buffer_state (void) YY_G(yy_did_buffer_switch_on_eof) = 1; } } -%endif -%if-c-or-c++ /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yyensure_buffer_stack (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yyensure_buffer_stack(void) -%endif +]]) { yy_size_t num_to_alloc; M4_YY_DECL_GUTS_VAR(); @@ -3198,14 +3184,13 @@ void yyFlexLexer::yyensure_buffer_stack(void) YY_G(yy_buffer_stack_max) = num_to_alloc; } } -%endif m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer @@ -3241,13 +3226,13 @@ yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) return b; } -%endif +]]) ]]) m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan @@ -3262,13 +3247,13 @@ yybuffer yy_scan_string YYFARGS1( const char *, yystr) return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); } -%endif +]]) ]]) m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan @@ -3305,18 +3290,18 @@ yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { return b; } -%endif +]]) ]]) m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yy_push_state YYFARGS1( int ,_new_state) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_push_state( int _new_state ) -%endif +]]) { M4_YY_DECL_GUTS_VAR(); if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) { @@ -3345,12 +3330,12 @@ void yyFlexLexer::yy_push_state( int _new_state ) m4_ifdef( [[M4_YY_NO_POP_STATE]],, [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yy_pop_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ void yyFlexLexer::yy_pop_state() -%endif +]]) { M4_YY_DECL_GUTS_VAR(); if ( --YY_G(yy_start_stack_ptr) < 0 ) { @@ -3363,12 +3348,12 @@ void yyFlexLexer::yy_pop_state() m4_ifdef( [[M4_YY_NO_TOP_STATE]],, [[ -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static int yy_top_state (M4_YY_DEF_ONLY_ARG) -%endif -%if-c++-only +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ int yyFlexLexer::yy_top_state() -%endif +]]) { M4_YY_DECL_GUTS_VAR(); return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; @@ -3394,8 +3379,8 @@ int yyFlexLexer::yy_top_state() /* Accessor methods (get/set functions) to struct members. */ -%if-c-only -%if-reentrant +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_REENTRANT]], [[ m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, [[ /** Get the user-defined data for this scanner. @@ -3406,7 +3391,7 @@ YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) { return yyextra; } ]]) -%endif +]]) m4_ifdef( [[M4_YY_NO_GET_LINENO]],, [[ @@ -3490,7 +3475,7 @@ char *yyget_text (M4_YY_DEF_ONLY_ARG) { } ]]) -%if-reentrant +m4_ifdef([[M4_YY_REENTRANT]], [[ m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, [[ /** Set the user-defined data. This data is never touched by the scanner. @@ -3502,7 +3487,7 @@ void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) { yyextra = user_defined ; } ]]) -%endif +]]) m4_ifdef( [[M4_YY_NO_SET_LINENO]],, [[ @@ -3585,12 +3570,12 @@ void yyset_debug YYFARGS1( int ,_bdebug) { yy_flex_debug = _bdebug ; } ]]) -%endif +]]) -%if-reentrant +m4_ifdef([[M4_YY_REENTRANT]], [[ /* Accessor methods for yylval and yylloc */ -%if-bison-bridge +m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_ifdef( [[M4_YY_NO_GET_LVAL]],, [[ YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) { @@ -3626,7 +3611,7 @@ void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) { ]]) ]]) -%endif +]]) /* User-visible API */ @@ -3688,10 +3673,10 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) return yy_init_globals ( *ptr_yy_globals ); } -%endif if-c-only +]]) %# Actually, that ended an if-rentrant section -%if-c-only +m4_ifdef([[M4_MODE_C_ONLY]], [[ static int yy_init_globals (M4_YY_DEF_ONLY_ARG) { M4_YY_DECL_GUTS_VAR(); /* Initialization is the same as for the non-reentrant scanner. @@ -3749,10 +3734,11 @@ m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], */ return 0; } -%endif +]]) -%if-c-only SNIP! this currently causes conflicts with the c++ scanner +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# SNIP! this currently causes conflicts with the c++ scanner /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (M4_YY_DEF_ONLY_ARG) { M4_YY_DECL_GUTS_VAR(); @@ -3785,14 +3771,14 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], * yylex() is called, initialization will occur. */ yy_init_globals( M4_YY_CALL_ONLY_ARG); -%if-reentrant +m4_ifdef([[M4_YY_REENTRANT]], [[ /* Destroy the main struct (reentrant only). */ yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); yyscanner = NULL; -%endif +]]) return 0; } -%endif +]]) m4_ifdef( [[M4_YY_NOT_IN_HEADER]], @@ -3866,7 +3852,8 @@ void yyfree YYFARGS1( void *,ptr) { } ]]) -%if-tables-serialization definitions +m4_ifdef([[M4_MODE_TABLESEXT]], [[ +%# definitions m4preproc_include(`tables_shared.c') static int yytbl_read8 (void *v, struct yytbl_reader * rd) { @@ -4264,29 +4251,29 @@ int yytables_destroy (M4_YY_DEF_ONLY_ARG) { } /* end table serialization code definitions */ -%endif +]]) m4_ifdef([[M4_YY_MAIN]], [[ int main (void); int main () { -%if-reentrant +m4_ifdef([[M4_YY_REENTRANT]], [[ yyscan_t lexer; yylex_init(&lexer); yylex( lexer ); yylex_destroy( lexer); -%endif -%if-not-reentrant +]]) +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ yylex(); -%endif +]]) return 0; } ]]) -%ok-for-header +]]) m4_ifdef( [[M4_YY_IN_HEADER]], [[ #undef YY_NEW_FILE diff --git a/src/main.c b/src/main.c index 46bfdaa..a36339a 100644 --- a/src/main.c +++ b/src/main.c @@ -1581,11 +1581,13 @@ void readin (void) if (ctrl.noyyread) visible_define("M4_MODE_USER_YYREAD"); - // Kluge to get around the fact that the %if-not-reentrant and - // %if-c-only gates can't be combined by nesting one inside the - // other. - if (backend == &cpp_backend && !ctrl.C_plus_plus) - visible_define ( "M4_MODE_C_ONLY"); + if (backend == &cpp_backend) { + if (ctrl.C_plus_plus) { + visible_define ( "M4_MODE_CXX_ONLY"); + } else { + visible_define ( "M4_MODE_C_ONLY"); + } + } if (tablesext) visible_define ( "M4_MODE_TABLESEXT"); -- cgit v1.2.1 From 10daafd5b4fbe8cd8c1b2d4ec34548329b14acd6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 08:31:36 -0400 Subject: Remove interpretation of %-markup. Before this commit, "rm cpp-skel.h" may be required in addition to "make clean". Since there no longer any pusging or poping operations, the sko stack goes away. --- src/misc.c | 104 ---------------------------------------------------- src/tables_shared.h | 4 +- 2 files changed, 2 insertions(+), 106 deletions(-) diff --git a/src/misc.c b/src/misc.c index 9bd2e55..952b4a6 100644 --- a/src/misc.c +++ b/src/misc.c @@ -33,58 +33,6 @@ #include "flexdef.h" #include "tables.h" -#define CMD_IF_TABLES_SER "%if-tables-serialization" -#define CMD_IF_CPP_ONLY "%if-c++-only" -#define CMD_IF_C_ONLY "%if-c-only" -#define CMD_IF_C_OR_CPP "%if-c-or-c++" -#define CMD_NOT_FOR_HEADER "%not-for-header" -#define CMD_OK_FOR_HEADER "%ok-for-header" -#define CMD_IF_REENTRANT "%if-reentrant" -#define CMD_IF_NOT_REENTRANT "%if-not-reentrant" -#define CMD_IF_BISON_BRIDGE "%if-bison-bridge" -#define CMD_IF_NOT_BISON_BRIDGE "%if-not-bison-bridge" -#define CMD_ENDIF "%endif" - -/* we allow the skeleton to push and pop. */ -struct sko_state { - bool dc; /**< do_copy */ -}; -static struct sko_state *sko_stack=0; -static int sko_len=0,sko_sz=0; -static void sko_push(bool dc) -{ - if(!sko_stack){ - sko_sz = 1; - sko_stack = malloc(sizeof(struct sko_state) * (size_t) sko_sz); - if (!sko_stack) - flexfatal(_("allocation of sko_stack failed")); - sko_len = 0; - } - if(sko_len >= sko_sz){ - sko_sz *= 2; - sko_stack = realloc(sko_stack, - sizeof(struct sko_state) * (size_t) sko_sz); - } - - /* initialize to zero and push */ - sko_stack[sko_len].dc = dc; - sko_len++; -} -static void sko_peek(bool *dc) -{ - if(sko_len <= 0) - flex_die("peek attempt when sko stack is empty"); - if(dc) - *dc = sko_stack[sko_len-1].dc; -} -static void sko_pop(bool* dc) -{ - sko_peek(dc); - sko_len--; - if(sko_len < 0) - flex_die("popped too many times in skeleton."); -} - /* Append "new_text" to the running buffer. */ void add_action (const char *new_text) { @@ -671,13 +619,6 @@ void skelout (bool announce) char *buf = buf_storage; bool do_copy = true; - /* "reset" the state by clearing the buffer and pushing a '1' */ - if(sko_len > 0) - sko_peek(&do_copy); - sko_len = 0; - sko_push(do_copy=true); - - /* Loop pulling lines either from the skelfile, if we're using * one, or from the selected back end's skel[] array. */ @@ -720,51 +661,6 @@ void skelout (bool announce) } return; } - else if (cmd_match (CMD_IF_REENTRANT)){ - sko_push(do_copy); - do_copy = ctrl.reentrant && do_copy; - } - else if (cmd_match (CMD_IF_NOT_REENTRANT)){ - sko_push(do_copy); - do_copy = !ctrl.reentrant && do_copy; - } - else if (cmd_match(CMD_IF_BISON_BRIDGE)){ - sko_push(do_copy); - do_copy = ctrl.bison_bridge_lval && do_copy; - } - else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)){ - sko_push(do_copy); - do_copy = !ctrl.bison_bridge_lval && do_copy; - } - else if (cmd_match (CMD_ENDIF)){ - sko_pop(&do_copy); - } - else if (cmd_match (CMD_IF_TABLES_SER)) { - do_copy = do_copy && tablesext; - } - else if (cmd_match (CMD_IF_CPP_ONLY)) { - /* only for C++ */ - sko_push(do_copy); - do_copy = ctrl.C_plus_plus; - } - else if (cmd_match (CMD_IF_C_ONLY)) { - /* %- only for C */ - sko_push(do_copy); - do_copy = !ctrl.C_plus_plus; - } - else if (cmd_match (CMD_IF_C_OR_CPP)) { - /* %* for C and C++ */ - sko_push(do_copy); - do_copy = true; - } - else if (cmd_match (CMD_NOT_FOR_HEADER)) { - /* %c begin linkage-only (non-header) code. */ - OUT_BEGIN_CODE (); - } - else if (cmd_match (CMD_OK_FOR_HEADER)) { - /* %e end linkage-only code. */ - OUT_END_CODE (); - } else { flexfatal (_("bad line in skeleton file")); } diff --git a/src/tables_shared.h b/src/tables_shared.h index feca251..e07207e 100644 --- a/src/tables_shared.h +++ b/src/tables_shared.h @@ -128,11 +128,11 @@ struct yytbl_data { #endif #ifdef FLEX_SCANNER -%not-for-header +m4_ifdef( [[M4_YY_NOT_IN_HEADER]],[[ #endif yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl); #ifdef FLEX_SCANNER -%ok-for-header +]]) #endif /* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */ -- cgit v1.2.1 From 35c1cf34269654f6bf254be7cd5bd46e28d29bd3 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 11:57:24 -0400 Subject: Remove unused code. --- src/misc.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/misc.c b/src/misc.c index 952b4a6..6057587 100644 --- a/src/misc.c +++ b/src/misc.c @@ -633,23 +633,9 @@ void skelout (bool announce) if (buf[0] == '%') { /* control line */ /* print the control line as a comment. */ if (ctrl.ddebug && buf[1] != '#') { - bool escaped = buf[strlen (buf) - 1] == '\\'; - if (escaped) { - comment(buf); - out ("\\\n"); - } else { - comment(buf); - outc ('\n'); - } + comment(buf); + outc ('\n'); } - - /* We've been accused of using cryptic markers in the skel. - * So we'll use emacs-style-hyphenated-commands. - * We might consider a hash if this if-else-if-else - * chain gets too large. - */ -#define cmd_match(s) (strncmp(buf,(s),strlen(s))==0) - if (buf[1] == '#') { /* %# indicates comment line to be ignored */ } -- cgit v1.2.1 From e740e500e21be7a95b5f19835c01bbdfd3f9fe07 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 13:16:44 -0400 Subject: Documentation polishing. --- doc/flex.texi | 74 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 9531366..f4a526b 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -2378,9 +2378,10 @@ rules is matched. The following would do the trick: @end example @vindex YY_NUM_RULES -where @code{ctr} is an array to hold the counts for the different rules. -Note that the macro @code{YY_NUM_RULES} gives the total number of rules -(including the default rule), even if you use @samp{-s)}, so a correct +where @code{ctr} is an array to hold the counts for the different +rules. Note that the public constant @code{YY_NUM_RULES} (a macro in +the default C/C++ back end) gives the total number of rules (including +the default rule), even if you use @samp{-s)}, so a correct declaration for @code{ctr} is: @example @@ -2396,14 +2397,14 @@ internal initializations are done). For example, it could be used to call a routine to read in a data table or open a logging file. @findex yy_set_interactive -The macro @code{yy_set_interactive(is_interactive)} can be used to +The entry point @code{yy_set_interactive(is_interactive)} can be used to control whether the current buffer is considered @dfn{interactive}. An interactive buffer is processed more slowly, but must be used when the scanner's input source is indeed interactive to avoid problems due to waiting to fill buffers (see the discussion of the @samp{-I} flag in -@ref{Scanner Options}). A non-zero value in the macro invocation marks +@ref{Scanner Options}). Passing a boolean true (in C/C++, non-zero) value marks the buffer as interactive, a zero value as non-interactive. Note that -use of this macro overrides @code{%option always-interactive} or +use of this entry point overrides @code{%option always-interactive} or @code{%option never-interactive} (@pxref{Scanner Options}). @code{yy_set_interactive()} must be invoked prior to beginning to scan the buffer that is (or is not) to be considered interactive. @@ -2412,7 +2413,7 @@ the buffer that is (or is not) to be considered interactive. @findex yy_set_bol The rule hook @code{yy_set_bol(at_bol)} can be used to control whether the current buffer's scanning context for the next token match is done as -though at the beginning of a line. A non-zero macro argument makes +though at the beginning of a line. A non-zero argument makes rules anchored with @samp{^} active, while a zero argument makes @samp{^} rules inactive. @@ -2906,7 +2907,7 @@ is performed in @code{yylex_init} at runtime. directs @code{flex} to generate a scanner that maintains the number of the current line read from its input in the global variable @code{yylineno}. This option is implied by @code{%option -lex-compat}. In a reentrant C scanner, the macro @code{yylineno} is +lex-compat}. In a reentrant C scanner, @code{yylineno} is accessible regardless of the value of @code{%option yylineno}, however, its value is not modified by @code{flex} unless @code{%option yylineno} is enabled. @@ -4141,12 +4142,15 @@ scanners. Here is a quick overview of the API: All functions take one additional argument: @code{yyscanner} @item -All global variables are replaced by their macro equivalents. -(We tell you this because it may be important to you during debugging.) +In C/C++, all global variables are replaced by their macro equivalents. +(We tell you this because it may be important to you during +debugging.) This is a historical-compatibilty hack; other back ends +probably will not emulate it. @item -@code{yylex_init} and @code{yylex_destroy} must be called before and -after @code{yylex}, respectively. +In the default C/C++ @code{yylex_init} and @code{yylex_destroy} must +be called before and after @code{yylex}, respectively. Other back ebds +may or may not require this. @item Accessor methods (get/set functions) provide access to common @@ -4193,7 +4197,7 @@ First, an example of a reentrant scanner: @node Reentrant Detail, Reentrant Functions, Reentrant Example, Reentrant @section The Reentrant API in Detail -Here are the things you need to do or know to use the reentrant C API of +Here are the things you need to do or know to use the reentrant API of @code{flex}. @menu @@ -4270,7 +4274,8 @@ equivalents. In particular, @code{yytext}, @code{yyleng}, @code{yylineno}, @code{yyin}, @code{yyout}, @code{yyextra}, @code{yylval}, and @code{yylloc} are macros. You may safely use these macros in actions as if they were plain variables. We only tell you this so you don't expect to link to these variables -externally. Currently, each macro expands to a member of an internal struct, e.g., +externally. Currently, each macro expands to a member of an internal +struct, e.g., in C/C++: @example @verbatim @@ -4296,8 +4301,10 @@ to accomplish this. (See below). @findex yylex_init @findex yylex_destroy -@code{yylex_init} and @code{yylex_destroy} must be called before and -after @code{yylex}, respectively. +In the default C/C++ back end @code{yylex_init} and +@code{yylex_destroy} must be called before and after @code{yylex}, +respectively. This may not be true in other target langages, +especially those with automatic memory management. @example @verbatim @@ -4334,8 +4341,9 @@ takes one argument, which is the value returned (via an argument) by @code{yylex_init}. Otherwise, it behaves the same as the non-reentrant version of @code{yylex}. -Both @code{yylex_init} and @code{yylex_init_extra} returns 0 (zero) on success, -or non-zero on failure, in which case errno is set to one of the following values: +Both @code{yylex_init} and @code{yylex_init_extra} returns 0 (zero) on +success, or non-zero on failure. On error, in the C/C++ back end in +which case errno is set to one of the following values: @itemize @item ENOMEM @@ -4344,6 +4352,8 @@ Memory allocation error. @xref{memory-management}. Invalid argument. @end itemize +Othert target langages may use different means of passing back an +error indication. The function @code{yylex_destroy} should be called to free resources used by the scanner. After @code{yylex_destroy} @@ -4500,7 +4510,7 @@ scanner: @subsection About yyscan_t @tindex yyscan_t (reentrant only) -@code{yyscan_t} is defined as: +On C/C++, @code{yyscan_t} is defined as: @example @verbatim @@ -5462,15 +5472,18 @@ in @emph{fixed} trailing context being turned into the more expensive @end verbatim @end example -Use of @code{yyunput()} invalidates yytext and yyleng, unless the +Some caveats are specific ro the In the C/C++ back end: Use of +@code{yyunput()} invalidates yytext and yyleng, unless the @code{%array} directive or the @samp{-l} option has been used. Pattern-matching of @code{NUL}s is substantially slower than matching other characters. Dynamic resizing of the input buffer is slow, as it -entails rescanning all the text matched so far by the current (generally -huge) token. Due to both buffering of input and read-ahead, you cannot -intermix calls to @file{} routines, such as, @b{getchar()}, -with @code{flex} rules and expect it to work. Call @code{yyinput()} -instead. The total table entries listed by the @samp{-v} flag excludes +entails rescanning all the text matched so far by the current +(generally huge) token. Due to both buffering of input and +read-ahead, you cannot intermix calls to @file{} routines, +such as, @b{getchar()}, with @code{flex} rules and expect it to work. +Call @code{yyinput()} instead. + +The total table entries listed by the @samp{-v} flag excludes the number of table entries needed to determine what rule has been matched. The number of entries is equal to the number of DFA states if the scanner does not use @code{yyreject()}, and somewhat greater than the @@ -8748,7 +8761,7 @@ targets. Almost anything generally descended from Algol shouldn't be much more difficult; this certainly includes the whole Pascal/Modula/Oberon family. -Two notes about the interesting part: +Some notes about the interesting part: @itemize @item @@ -8764,6 +8777,15 @@ The ``one exception'' to target-syntax independence hinted at earlier is some C code spliced into the skeleton when table serialization is enabled. This option is thus available only with the C back end; you need not bother supporting it in yours. + +@item +If your target language has an object system, you probably want your +back end to generate a class named by default FlexLexer (as the +C++ back end does) with all of the controls and query functions as +methods. As in C++, @code{%option yyclass} should modify the +class name. If your target language has a moduke system, the +-P option (which in C/C++ sets a common prefix on exposed entry +points) can be pressed into service to set the module name. @end itemize The following assumptions in the code might trip you up and -- cgit v1.2.1 From f7f447793ab0c440159d51a3483c29463a8cea13 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 13:58:29 -0400 Subject: Typo and markup fixes in the manual. --- doc/flex.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index f4a526b..dda572b 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8845,10 +8845,10 @@ ECHO: Replaced by yyecho() REJECT: Replaced by yyreject() @item -#define YY_DECL: Replaced by the yydecl option. +#define YY_DECL: Replaced by the @code{yydecl} option. @item -#define YYLMAX: Replaced by the %yylmax option. +#define YYLMAX: Replaced by the @code{yylmax} option. @item #define YY_INPUT: Replaced by the @code{noyyread} option. @@ -8864,7 +8864,7 @@ input(): Replaced by yyinput(). This function was already yyinput() in the C++ back end. @item: -yunput(): Replaced by yyunput(). +unput(): Replaced by yyunput(). @item #define YY_EXTRA_TYPE: Replaced by the @code{extra-type} option. -- cgit v1.2.1 From 65b508798fceb28fe0b5a7ddf316d3d728ed80c8 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 Oct 2020 18:59:05 -0400 Subject: More documentation polishing. --- doc/flex.texi | 1202 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 600 insertions(+), 602 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index dda572b..8fceb5d 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -385,15 +385,16 @@ The non-reentrant interface is a relic from the early 1970s when Lex, the ancestor of Flex, was designed. Modern programming practice frowns on hidden global variables; thus when Flex generates a scanner in any language other than the original C/C++ non-reentrancy is not even an -option. +option. Most likely it will make you some kind of scanner class +that you instantiate, with methods and fields rather than exposed globals. -It's a good idea to get used to using the reentrant interface from the -beginning of your Flex programming. This is so even though the -reentrant example above is a rather poor one; it avoids exposing the -scanner state in globals but creates globals of its own. There is a -mechanism for including user-defined fields in the scanner structure -which will be explained in detail at @xref{Extra Data}. For now, -consider this: +Thus it's a good idea to get used to not relying on the exposed +globals of the original interface from the beginning of your Flex +programming. This is so even though the reentrant example above is a +rather poor one; it avoids exposing the scanner state in globals but +creates globals of its own. There is a mechanism for including +user-defined fields in the scanner structure which will be explained +in detail at @xref{Extra Data}. For now, consider this: @example @verbatiminclude ../examples/manual/example_er.lex @@ -411,54 +412,53 @@ A somewhat more complicated example: @cindex Pascal-like language @example @verbatim - /* scanner for a toy Pascal-like language */ +/* scanner for a toy Pascal-like language */ - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* +%{ +/* need this for the call to atof() below */ +#include +%} - %% +DIGIT [0-9] +ID [a-z][a-z0-9]* - {DIGIT}+ { - printf( "An integer: %s (%d)\n", yytext, - atoi( yytext ) ); - } +%% - {DIGIT}+"."{DIGIT}* { - printf( "A float: %s (%g)\n", yytext, - atof( yytext ) ); - } +{DIGIT}+ { + printf( "An integer: %s (%d)\n", yytext, + atoi( yytext ) ); + } - if|then|begin|end|procedure|function { - printf( "A keyword: %s\n", yytext ); - } +{DIGIT}+"."{DIGIT}* { + printf( "A float: %s (%g)\n", yytext, + atof( yytext ) ); + } - {ID} printf( "An identifier: %s\n", yytext ); +if|then|begin|end|procedure|function { + printf( "A keyword: %s\n", yytext ); + } - "+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext ); +{ID} printf( "An identifier: %s\n", yytext ); - "{"[^{}\n]*"}" /* eat up one-line comments */ +"+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext ); - [ \t\n]+ /* eat up whitespace */ +"{"[^{}\n]*"}" /* eat up one-line comments */ - . printf( "Unrecognized character: %s\n", yytext ); +[ \t\n]+ /* eat up whitespace */ - %% +. printf( "Unrecognized character: %s\n", yytext ); - int main( int argc, char **argv ) - { - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; +%% - yylex(); - } +int main( int argc, char **argv ) { + ++argv, --argc; /* skip over program name */ + if ( argc > 0 ) { + yyin = fopen( argv[0], "r" ); + } else { + yyin = stdin; + } + yylex(); +} @end verbatim @end example @@ -621,8 +621,10 @@ meaning is not well-defined and it may well cause compile-time errors Posix}, for other such features). Any @emph{indented} text or text enclosed in @samp{%@{} and @samp{%@}} -is copied verbatim to the output (with the %@{ and %@} symbols removed). -The %@{ and %@} symbols must appear unindented on lines by themselves. +is copied verbatim to the output (with the %@{ and %@} symbols +removed). The %@{ and %@} symbols must appear unindented on lines by +themselves. Because whiteoace is easy to mangle wuthout noticing, +it's good style to use the explicit %@{ and %@} delimiters. @node User Code Section, Comments in the Input, Rules Section, Format @section Format of the User Code Section @@ -690,7 +692,10 @@ ruleD yyecho(); @end example If the target language is something other than C/C++, you will need to use -its normal comment syntax in actions and code blocks. +its normal comment syntax in actions and code blocks. Note that the +optional @{ and @} delimiters around actions a Flex dyntax, not C +syntax; you will be able to use those even if, e,g., your target +language is Pascal-like and delimus blocs with begin/end. @node Patterns, Matching, Format, Top @chapter Patterns @@ -1293,11 +1298,13 @@ whenever @samp{frob} is seen: @example @verbatim - int word_count = 0; - %% +%{ + int word_count = 0; +%} +%% - frob special(); yyreject(); - [^ \t\n]+ ++word_count; +frob special(); yyreject(); +[^ \t\n]+ ++word_count; @end verbatim @end example @@ -1312,12 +1319,12 @@ write @samp{abcdabcaba} to the output: @cindex |, use of @example @verbatim - %% - a | - ab | - abc | - abcd yyecho(); yyreject(); - .|\n /* eat up any unmatched character */ +%% +a | +ab | +abc | +abcd yyecho(); yyreject(); +.|\n /* eat up any unmatched character */ @end verbatim @end example @@ -1346,9 +1353,9 @@ the output: @cindex yymore() to append token to previous token @example @verbatim - %% - mega- yyecho(); yymore(); - kludge yyecho(); +%% +mega- yyecho(); yymore(); +kludge yyecho(); @end verbatim @end example @@ -1381,9 +1388,9 @@ following will write out @samp{foobarbar}: @cindex pushing back characters with yyless @example @verbatim - %% - foobar yyecho(); yyless(3); - [a-z]+ yyecho(); +%% +foobar yyecho(); yyless(3); +[a-z]+ yyecho(); @end verbatim @end example @@ -1402,7 +1409,7 @@ the current token and cause it to be rescanned enclosed in parentheses. @cindex pushing back characters with yyunput() @example @verbatim - { +{ int i; /* Copy yytext because yyunput() trashes yytext */ char *yycopy = strdup( yytext ); @@ -1411,7 +1418,7 @@ the current token and cause it to be rescanned enclosed in parentheses. yyunput( yycopy[i] ); yyunput( '(' ); free( yycopy ); - } +} @end verbatim @end example @@ -1445,31 +1452,27 @@ example, the following is one way to eat up C comments: @cindex discarding C comments @example @verbatim - %% - "/*" { - int c; - - for ( ; ; ) - { - while ( (c = yyinput()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - { - while ( (c = yyinput()) == '*' ) - ; - if ( c == '/' ) - break; /* found the end */ - } - - if ( c == EOF ) - { - error( "EOF in comment" ); - break; - } - } +%% +"/*" { + int c; + + for ( ; ; ) { + while ( (c = yyinput()) != '*' && c != EOF ) + ; /* eat up text of comment */ + + if ( c == '*' ) { + while ( (c = yyinput()) == '*' ) + ; + if ( c == '/' ) + break; /* found the end */ } + + if ( c == EOF ) { + error( "EOF in comment" ); + break; + } + } + } @end verbatim @end example @@ -1650,9 +1653,9 @@ example, @example @verbatim - [^"]* { /* eat up the string body ... */ - ... - } +[^"]* { /* eat up the string body ... */ + ... + } @end verbatim @end example @@ -1662,9 +1665,9 @@ condition, and @cindex start conditions, multiple @example @verbatim - \. { /* handle an escape ... */ - ... - } +\. { /* handle an escape ... */ + ... + } @end verbatim @end example @@ -1696,12 +1699,12 @@ connection between the two. The set of rules: @cindex start conditions, inclusive @example @verbatim - %s example - %% +%s example +%% - foo do_something(); +foo do_something(); - bar something_else(); +bar something_else(); @end verbatim @end example @@ -1710,12 +1713,12 @@ is equivalent to @cindex start conditions, exclusive @example @verbatim - %x example - %% +%x example +%% - foo do_something(); +foo do_something(); - bar something_else(); +bar something_else(); @end verbatim @end example @@ -1736,12 +1739,12 @@ have been written: @cindex start conditions, use of wildcard condition (<*>) @example @verbatim - %x example - %% +%x example +%% - foo do_something(); +foo do_something(); - <*>bar something_else(); +<*>bar something_else(); @end verbatim @end example @@ -1751,7 +1754,7 @@ in start conditions. It is equivalent to: @cindex start conditions, behavior of default rule @example @verbatim - <*>.|\n yyecho(); +<*>.|\n yyecho(); @end verbatim @end example @@ -1771,15 +1774,15 @@ called and the global variable @code{enter_special} is true: @cindex start conditions, using yybegin() @example @verbatim - int enter_special; + int enter_special; - %x SPECIAL - %% - if ( enter_special ) - yybegin(SPECIAL); +%x SPECIAL +%% + if ( enter_special ) + yybegin(SPECIAL); - blahblahblah - ...more rules follow... +blahblahblah +...more rules follow... @end verbatim @end example @@ -1793,33 +1796,33 @@ treat it as a single token, the floating-point number @samp{123.456}: @cindex start conditions, for different interpretations of same input @example @verbatim - %{ - #include - %} - %s expect +%{ +#include +%} +%s expect - %% - expect-floats yybegin(expect); +%% +expect-floats yybegin(expect); - [0-9]+.[0-9]+ { - printf( "found a float, = %f\n", - atof( yytext ) ); - } - \n { - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - yybegin(INITIAL); - } +[0-9]+.[0-9]+ { + printf( "found a float, = %f\n", + atof( yytext ) ); + } +\n { + /* that's the end of the line, so + * we need another "expect-number" + * before we'll recognize any more + * numbers + */ + yybegin(INITIAL); + } - [0-9]+ { - printf( "found an integer, = %d\n", - atoi( yytext ) ); - } +[0-9]+ { + printf( "found an integer, = %d\n", + atoi( yytext ) ); + } - "." printf( "found a dot\n" ); +"." printf( "found a dot\n" ); @end verbatim @end example @@ -1830,16 +1833,16 @@ maintaining a count of the current input line. @cindex recognizing C comments @example @verbatim - %x comment - %% - int line_num = 1; +%x comment +%% + int line_num = 1; - "/*" yybegin(comment); +"/*" yybegin(comment); - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" yybegin(INITIAL); +[^*\n]* /* eat anything that's not a '*' */ +"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ +\n ++line_num; +"*"+"/" yybegin(INITIAL); @end verbatim @end example @@ -1856,27 +1859,27 @@ following fashion: @cindex using integer values of start condition names @example @verbatim - %x comment foo - %% - int line_num = 1; - int comment_caller; +%x comment foo +%% + int line_num = 1; + int comment_caller; - "/*" { - comment_caller = INITIAL; - yybegin(comment); - } +"/*" { + comment_caller = INITIAL; + yybegin(comment); + } - ... +... - "/*" { - comment_caller = foo; - yybegin(comment); - } +"/*" { + comment_caller = foo; + yybegin(comment); + } - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" yybegin(comment_caller); +[^*\n]* /* eat anything that's not a '*' */ +"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ +\n ++line_num; +"*"+"/" yybegin(comment_caller); @end verbatim @end example @@ -1904,60 +1907,60 @@ not including checking for a string that's too long): @cindex matching C-style double-quoted strings @example @verbatim - %x str +%x str - %% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; +%% + char string_buf[MAX_STR_CONST]; + char *string_buf_ptr; - \" string_buf_ptr = string_buf; yybegin(str); +\" string_buf_ptr = string_buf; yybegin(str); - \" { /* saw closing quote - all done */ - yybegin(INITIAL); - *string_buf_ptr = '\0'; - /* return string constant token type and - * value to parser - */ - } +\" { /* saw closing quote - all done */ + yybegin(INITIAL); + *string_buf_ptr = '\0'; + /* return string constant token type and + * value to parser + */ + } - \n { - /* error - unterminated string constant */ - /* generate error message */ - } +\n { + /* error - unterminated string constant */ + /* generate error message */ + } - \\[0-7]{1,3} { - /* octal escape sequence */ - int result; +\\[0-7]{1,3} { + /* octal escape sequence */ + int result; - (void) sscanf( yytext + 1, "%o", &result ); + (void) sscanf( yytext + 1, "%o", &result ); - if ( result > 0xff ) - /* error, constant is out-of-bounds */ + if ( result > 0xff ) + /* error, constant is out-of-bounds */ - *string_buf_ptr++ = result; - } + *string_buf_ptr++ = result; + } - \\[0-9]+ { - /* generate error - bad escape sequence; something - * like '\48' or '\0777777' - */ - } +\\[0-9]+ { + /* generate error - bad escape sequence; something + * like '\48' or '\0777777' + */ + } - \\n *string_buf_ptr++ = '\n'; - \\t *string_buf_ptr++ = '\t'; - \\r *string_buf_ptr++ = '\r'; - \\b *string_buf_ptr++ = '\b'; - \\f *string_buf_ptr++ = '\f'; +\\n *string_buf_ptr++ = '\n'; +\\t *string_buf_ptr++ = '\t'; +\\r *string_buf_ptr++ = '\r'; +\\b *string_buf_ptr++ = '\b'; +\\f *string_buf_ptr++ = '\f'; - \\(.|\n) *string_buf_ptr++ = yytext[1]; +\\(.|\n) *string_buf_ptr++ = yytext[1]; - [^\\\n\"]+ { - char *yptr = yytext; +[^\\\n\"]+ { + char *yptr = yytext; - while ( *yptr ) - *string_buf_ptr++ = *yptr++; - } + while ( *yptr ) + *string_buf_ptr++ = *yptr++; + } @end verbatim @end example @@ -1969,7 +1972,7 @@ condition @dfn{scope}. A start condition scope is begun with: @example @verbatim - { +{ @end verbatim @end example @@ -1981,12 +1984,12 @@ start condition scope, every rule automatically has the prefix @cindex extended scope of start conditions @example @verbatim - { - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - } +{ + "\\n" return '\n'; + "\\r" return '\r'; + "\\f" return '\f'; + "\\0" return '\0'; +} @end verbatim @end example @@ -1994,10 +1997,10 @@ is equivalent to: @example @verbatim - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; +"\\n" return '\n'; +"\\r" return '\r'; +"\\f" return '\f'; +"\\0" return '\0'; @end verbatim @end example @@ -2069,10 +2072,8 @@ returns a @code{yybuffer} handle, which may then be passed to other routines (see below). In target languages other than C/C++, this prototype will look -different. The buffer-state object may be named differently, and will -not have ``struct'' as part of its name. The input-stream type won't -be @code{FILE *}. But expect the same semamntics wxpressed in native -tytypes. +different. The input-stream type won't be @code{FILE *}. But expect +the same semamntics wxpressed in native tytypes. @tindex yybuffer The @code{yybuffer} type is a @@ -2162,36 +2163,35 @@ maintains the stack internally. @cindex handling include files with multiple input buffers @example @verbatim - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl - %% - include yybegin(incl); +/* the "incl" state is used for picking up the name + * of an include file + */ +%x incl +%% +include yybegin(incl); - [a-z]+ yyecho(); - [^a-z\n]*\n? yyecho(); +[a-z]+ yyecho(); +[^a-z\n]*\n? yyecho(); - [ \t]* /* eat the whitespace */ - [^ \t\n]+ { /* got the include file name */ - yyin = fopen( yytext, "r" ); +[ \t]* /* eat the whitespace */ +[^ \t\n]+ { /* got the include file name */ + yyin = fopen( yytext, "r" ); - if ( ! yyin ) - error( ... ); + if ( ! yyin ) + error( ... ); - yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); + yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); - yybegin(INITIAL); - } + yybegin(INITIAL); +} - <> { - yypop_buffer_state(); +<> { + yypop_buffer_state(); - if ( !yy_current_buffer() ) - { - yyterminate(); - } - } + if ( !yy_current_buffer() ) { + yyterminate(); + } +} @end verbatim @end example @@ -2201,58 +2201,53 @@ manages its own input buffer stack manually (instead of letting flex do it). @cindex handling include files with multiple input buffers @example @verbatim - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl +/* the "incl" state is used for picking up the name + * of an include file + */ +%x incl - %{ - #define MAX_INCLUDE_DEPTH 10 - yybuffer include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include yybegin(incl); +%{ +#define MAX_INCLUDE_DEPTH 10 +yybuffer include_stack[MAX_INCLUDE_DEPTH]; +int include_stack_ptr = 0; +%} - [a-z]+ yyecho(); - [^a-z\n]*\n? yyecho(); +%% +include yybegin(incl); - [ \t]* /* eat the whitespace */ - [^ \t\n]+ { /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - { - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - } +[a-z]+ yyecho(); +[^a-z\n]*\n? yyecho(); - include_stack[include_stack_ptr++] = - yy_current_buffer(); +[ \t]* /* eat the whitespace */ +[^ \t\n]+ { /* got the include file name */ + if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) { + fprintf( stderr, "Includes nested too deeply" ); + exit( 1 ); + } - yyin = fopen( yytext, "r" ); + include_stack[include_stack_ptr++] = + yy_current_buffer(); - if ( ! yyin ) - error( ... ); + yyin = fopen( yytext, "r" ); - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); + if ( ! yyin ) + error( ... ); - yybegin(INITIAL); - } + yy_switch_to_buffer( + yy_create_buffer( yyin, YY_BUF_SIZE ) ); - <> { - if ( --include_stack_ptr == 0 ) - { - yyterminate(); - } + yybegin(INITIAL); +} - else - { - yy_delete_buffer( yy_current_buffer() ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - } - } +<> { + if ( --include_stack_ptr == 0 ) { + yyterminate(); + } else { + yy_delete_buffer( yy_current_buffer() ); + yy_switch_to_buffer( + include_stack[include_stack_ptr] ); + } +} @end verbatim @end example @@ -2531,13 +2526,13 @@ is @code{TOK_NUMBER}, part of the scanner might look like: @cindex yacc interface @example @verbatim - %{ - #include "y.tab.h" - %} +%{ +#include "y.tab.h" +%} - %% +%% - [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; +[0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; @end verbatim @end example @@ -2609,14 +2604,14 @@ corresponding routine not appearing in the generated scanner: @example @verbatim - input, yyunput - yy_push_state, yy_pop_state, yy_top_state - yy_scan_buffer, yy_scan_bytes, yy_scan_string +input, yyunput +yy_push_state, yy_pop_state, yy_top_state +yy_scan_buffer, yy_scan_bytes, yy_scan_string - yyget_extra, yyset_extra, yyget_leng, yyget_text, - yyget_lineno, yyset_lineno, yyget_in, yyset_in, - yyget_out, yyset_out, yyget_lval, yyset_lval, - yyget_lloc, yyset_lloc, yyget_debug, yyset_debug +yyget_extra, yyset_extra, yyget_leng, yyget_text, +yyget_lineno, yyset_lineno, yyget_in, yyset_in, +yyget_out, yyset_out, yyget_lval, yyset_lval, +yyget_lloc, yyset_lloc, yyget_debug, yyset_debug @end verbatim @end example @@ -3572,16 +3567,16 @@ The way to remove the backing up is to add ``error'' rules: @cindex backing up, eliminating by adding error rules @example @verbatim - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } +%% +foo return TOK_KEYWORD; +foobar return TOK_KEYWORD; + +fooba | +foob | +fo { + /* false alarm, not really a keyword */ + return TOK_ID; + } @end verbatim @end example @@ -3591,11 +3586,11 @@ Eliminating backing up among a list of keywords can also be done using a @cindex backing up, eliminating with catch-all rule @example @verbatim - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; +%% +foo return TOK_KEYWORD; +foobar return TOK_KEYWORD; - [a-z]+ return TOK_ID; +[a-z]+ return TOK_ID; @end verbatim @end example @@ -3620,8 +3615,8 @@ like: @cindex trailing context, variable length @example @verbatim - %% - mouse|rat/(cat|dog) run(); +%% +mouse|rat/(cat|dog) run(); @end verbatim @end example @@ -3629,9 +3624,9 @@ is better written: @example @verbatim - %% - mouse/cat|dog run(); - rat/cat|dog run(); +%% +mouse/cat|dog run(); +rat/cat|dog run(); @end verbatim @end example @@ -3639,9 +3634,9 @@ or as @example @verbatim - %% - mouse|rat/cat run(); - mouse|rat/dog run(); +%% +mouse|rat/cat run(); +mouse|rat/dog run(); @end verbatim @end example @@ -3659,16 +3654,16 @@ additional work of setting up the scanning environment (e.g., @cindex performance optimization, matching longer tokens @example @verbatim - %x comment - %% - int line_num = 1; +%x comment +%% + int line_num = 1; - "/*" yybegin(comment); +"/*" yybegin(comment); - [^*\n]* - "*"+[^*/\n]* - \n ++line_num; - "*"+"/" yybegin(INITIAL); +[^*\n]* +"*"+[^*/\n]* +\n ++line_num; +"*"+"/" yybegin(INITIAL); @end verbatim @end example @@ -3676,17 +3671,17 @@ This could be sped up by writing it as: @example @verbatim - %x comment - %% - int line_num = 1; +%x comment +%% + int line_num = 1; - "/*" yybegin(comment); +"/*" yybegin(comment); - [^*\n]* - [^*\n]*\n ++line_num; - "*"+[^*/\n]* - "*"+[^*/\n]*\n ++line_num; - "*"+"/" yybegin(INITIAL); +[^*\n]* +[^*\n]*\n ++line_num; +"*"+[^*/\n]* +"*"+[^*/\n]*\n ++line_num; +"*"+"/" yybegin(INITIAL); @end verbatim @end example @@ -3708,15 +3703,15 @@ keywords. A natural first approach is: @cindex performance optimization, recognizing keywords @example @verbatim - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ +%% +asm | +auto | +break | +... etc ... +volatile | +while /* it's a keyword */ - .|\n /* it's not a keyword */ +.|\n /* it's not a keyword */ @end verbatim @end example @@ -3724,16 +3719,16 @@ To eliminate the back-tracking, introduce a catch-all rule: @example @verbatim - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ +%% +asm | +auto | +break | +... etc ... +volatile | +while /* it's a keyword */ - [a-z]+ | - .|\n /* it's not a keyword */ +[a-z]+ | +.|\n /* it's not a keyword */ @end verbatim @end example @@ -3743,16 +3738,16 @@ recognition of newlines with that of the other tokens: @example @verbatim - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ +%% +asm\n | +auto\n | +break\n | +... etc ... +volatile\n | +while\n /* it's a keyword */ - [a-z]+\n | - .|\n /* it's not a keyword */ +[a-z]+\n | +.|\n /* it's not a keyword */ @end verbatim @end example @@ -3774,17 +3769,17 @@ one which doesn't include a newline: @example @verbatim - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ +%% +asm\n | +auto\n | +break\n | +... etc ... +volatile\n | +while\n /* it's a keyword */ - [a-z]+\n | - [a-z]+ | - .|\n /* it's not a keyword */ +[a-z]+\n | +[a-z]+ | +.|\n /* it's not a keyword */ @end verbatim @end example @@ -3957,69 +3952,69 @@ Here is an example of a simple C++ scanner: @cindex C++ scanners, use of @example @verbatim - // An example of using the flex C++ scanner class. + // An example of using the flex C++ scanner class. - %{ - #include - using namespace std; - int mylineno = 0; - %} +%{ +#include +using namespace std; +int mylineno = 0; +%} - %option noyywrap c++ +%option noyywrap c++ - string \"[^\n"]+\" +string \"[^\n"]+\" - ws [ \t]+ +ws [ \t]+ - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])* - num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} +alpha [A-Za-z] +dig [0-9] +name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])* +num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? +num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? +number {num1}|{num2} - %% +%% - {ws} /* skip blanks and tabs */ +{ws} /* skip blanks and tabs */ - "/*" { - int c; +"/*" { + int c; + + while((c = yyinput()) != 0) + { + if(c == '\n') + ++mylineno; - while((c = yyinput()) != 0) + else if(c == '*') { - if(c == '\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - yyunput(c); - } + if((c = yyinput()) == '/') + break; + else + yyunput(c); } } + } - {number} cout << "number " << YYText() << '\n'; +{number} cout << "number " << YYText() << '\n'; - \n mylineno++; +\n mylineno++; - {name} cout << "name " << YYText() << '\n'; +{name} cout << "name " << YYText() << '\n'; - {string} cout << "string " << YYText() << '\n'; +{string} cout << "string " << YYText() << '\n'; - %% +%% - // This include is required if main() is an another source file. - //#include + // This include is required if main() is an another source file. + //#include - int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } +int main( int /* argc */, char** /* argv */ ) +{ + FlexLexer* lexer = new yyFlexLexer; + while(lexer->yylex() != 0) + ; + return 0; +} @end verbatim @end example @@ -4080,18 +4075,18 @@ the token level (i.e., instead of at the character level): @cindex reentrant scanners, multiple interleaved scanners @example @verbatim - /* Example of maintaining more than one active scanner. */ +/* Example of maintaining more than one active scanner. */ - do { - int tok1, tok2; +do { + int tok1, tok2; - tok1 = yylex( scanner_1 ); - tok2 = yylex( scanner_2 ); + tok1 = yylex( scanner_1 ); + tok2 = yylex( scanner_2 ); - if( tok1 != tok2 ) - printf("Files are different."); + if( tok1 != tok2 ) + printf("Files are different."); - } while ( tok1 && tok2 ); +} while ( tok1 && tok2 ); @end verbatim @end example @@ -4105,26 +4100,26 @@ another instance of itself. @cindex reentrant scanners, recursive invocation @example @verbatim - /* Example of recursive invocation. */ +/* Example of recursive invocation. */ - %option reentrant +%option reentrant - %% - "eval(".+")" { - yyscan_t scanner; - yybuffer buf; +%% +"eval(".+")" { + yyscan_t scanner; + yybuffer buf; - yylex_init( &scanner ); - yytext[yyleng-1] = ' '; + yylex_init( &scanner ); + yytext[yyleng-1] = ' '; - buf = yy_scan_string( yytext + 5, scanner ); - yylex( scanner ); + buf = yy_scan_string( yytext + 5, scanner ); + yylex( scanner ); - yy_delete_buffer(buf,scanner); - yylex_destroy( scanner ); - } - ... - %% + yy_delete_buffer(buf,scanner); + yylex_destroy( scanner ); + } +... +%% @end verbatim @end example @@ -4167,30 +4162,30 @@ First, an example of a reentrant scanner: @cindex reentrant, example of @example @verbatim - /* This scanner prints "//" comments. */ +/* This scanner prints "//" comments. */ - %option reentrant stack noyywrap - %x COMMENT +%option reentrant stack noyywrap +%x COMMENT - %% +%% - "//" yy_push_state( COMMENT, yyscanner); - .|\n +"//" yy_push_state( COMMENT, yyscanner); +.|\n - \n yy_pop_state( yyscanner ); - [^\n]+ fprintf( yyout, "%s\n", yytext); +\n yy_pop_state( yyscanner ); +[^\n]+ fprintf( yyout, "%s\n", yytext); - %% +%% - int main ( int argc, char * argv[] ) - { - yyscan_t scanner; +int main ( int argc, char * argv[] ) +{ + yyscan_t scanner; - yylex_init ( &scanner ); - yylex ( scanner ); - yylex_destroy ( scanner ); + yylex_init ( &scanner ); + yylex ( scanner ); + yylex_destroy ( scanner ); return 0; - } +} @end verbatim @end example @@ -4265,9 +4260,12 @@ other target languages. @subsection Global Variables Replaced By Macros @cindex reentrant, accessing flex variables -All global variables in traditional flex have been replaced by macro equivalents. +In the C/C++ back end global variables in traditional flex have been +replaced by macro equivalents. Be aware that this will not be true in target +languages without macros, so rekying on this backward-compatibility +hack will hinder forward portability. -Note that in the above example, @code{yyout} and @code{yytext} are +Accordingly, in the above example, @code{yyout} and @code{yytext} are not plain variables. These are macros that will expand to their equivalent lvalue. All of the familiar @code{flex} globals have been replaced by their macro equivalents. In particular, @code{yytext}, @code{yyleng}, @code{yylineno}, @@ -4474,34 +4472,34 @@ scanner: @cindex YY_EXTRA_TYPE, defining your own type @example @verbatim - /* An example of overriding YY_EXTRA_TYPE. */ - %{ - #include - #include - %} - %option reentrant - %option extra-type="struct stat *" - %% +/* An example of overriding YY_EXTRA_TYPE. */ +%{ +#include +#include +%} +%option reentrant +%option extra-type="struct stat *" +%% - __filesize__ printf( "%ld", yyextra->st_size ); - __lastmod__ printf( "%ld", yyextra->st_mtime ); - %% - void scan_file( char* filename ) - { - yyscan_t scanner; - struct stat buf; - FILE *in; +__filesize__ printf( "%ld", yyextra->st_size ); +__lastmod__ printf( "%ld", yyextra->st_mtime ); +%% +void scan_file( char* filename ) +{ + yyscan_t scanner; + struct stat buf; + FILE *in; - in = fopen( filename, "r" ); - stat( filename, &buf ); + in = fopen( filename, "r" ); + stat( filename, &buf ); - yylex_init_extra( buf, &scanner ); - yyset_in( in, scanner ); - yylex( scanner ); - yylex_destroy( scanner ); + yylex_init_extra( buf, &scanner ); + yyset_in( in, scanner ); + yylex( scanner ); + yylex_destroy( scanner ); - fclose( in ); - } + fclose( in ); +} @end verbatim @end example @@ -6035,20 +6033,22 @@ Just call @code{yyrestart(newfile)}. Be sure to reset the start state if you wan @node How do I execute code only during initialization (only before the first scan)? @unnumberedsec How do I execute code only during initialization (only before the first scan)? -You can specify an initial action by defining the macro @code{YY_USER_INIT} (though -note that @code{yyout} may not be available at the time this macro is executed). Or you -can add to the beginning of your rules section: +You can specify an initial action with @code{%option user-init} +(though note that @code{yyout} may not be available at the time this +option is interpreted). Or you can add to the beginning of your rules +section: @example @verbatim %% - /* Must be indented! */ - static int did_init = 0; +%{ + static bool did_init = false; - if ( ! did_init ){ -do_my_init(); - did_init = 1; + if ( ! did_init ) { + do_my_init(); + did_init = true; } +%} @end verbatim @end example @@ -6060,9 +6060,8 @@ You can specify an action for the @code{<>} rule. @node Where else can I find help? @unnumberedsec Where else can I find help? -You can find the flex homepage on the web at -@uref{http://flex.sourceforge.net/}. See that page for details about flex -mailing lists as well. +You can find the flex repository and issue tracker at +@uref{https://github.com/westes/flex}. @node Can I include comments in the "rules" section of the file? @unnumberedsec Can I include comments in the "rules" section of the file? @@ -6098,25 +6097,24 @@ However, you can do this using multiple input buffers. @example @verbatim %% -macro/[a-z]+ { +macro/[a-z]+ { /* Saw the macro "macro" followed by extra stuff. */ main_buffer = yy_current_buffer(); expansion_buffer = yy_scan_string(expand(yytext)); yy_switch_to_buffer(expansion_buffer); } -<> { -if ( expansion_buffer ) -{ -// We were doing an expansion, return to where -// we were. -yy_switch_to_buffer(main_buffer); -yy_delete_buffer(expansion_buffer); -expansion_buffer = 0; -} -else -yyterminate(); -} +<> { + if ( expansion_buffer ) { + // We were doing an expansion, return to where + // we were. + yy_switch_to_buffer(main_buffer); + yy_delete_buffer(expansion_buffer); + expansion_buffer = 0; + } else { + yyterminate(); + } + } @end verbatim @end example @@ -6187,7 +6185,7 @@ e.g., %% [[a bunch of rules here]] -. printf("bad input character '%s' at line %d\n", yytext, yylineno); +. printf("bad input character '%s' at line %d\n", yytext, yylineno); @end verbatim @end example @@ -6338,7 +6336,7 @@ making it match "endskip" plus something else. So for example: @verbatim "endskip" yybegin(INITIAL); [^e]+ ; -. ;/* so you eat up e's, too */ +. ;/* so you eat up e's, too */ @end verbatim @end example @@ -6431,7 +6429,7 @@ regardless of how complex they are. See the "Performance Considerations" section of the man page, and also the example in MISC/fastwc/. - Vern + Vern @end verbatim @end example @@ -6474,7 +6472,7 @@ Yes. I've appended instructions on how. Before you make this change, though, you should think about whether there are ways to fundamentally simplify your scanner - those are certainly preferable! - Vern + Vern To increase the 32K limit (on a machine with 32 bit integers), you increase the magnitude of the following in flexdef.h: @@ -6512,10 +6510,10 @@ so it won't happen any time soon. In the interim, the best I can suggest (unless you want to try fixing it yourself) is to write your rules in terms of pairs of bytes, using definitions in the first section: - X \xfe\xc2 - ... - %% - foo{X}bar found_foo_fe_c2_bar(); + X \xfe\xc2 + ... + %% + foo{X}bar found_foo_fe_c2_bar(); etc. Definitely a pain - sorry about that. @@ -6523,7 +6521,7 @@ By the way, the email address you used for me is ancient, indicating you have a very old version of flex. You can get the most recent, 2.5.4, from ftp.ee.lbl.gov. - Vern + Vern @end verbatim @end example @@ -6550,7 +6548,7 @@ Fixing flex to handle wider characters is on the long-term to-do list. But since flex is a strictly spare-time project these days, this probably won't happen for quite a while, unless someone else does it first. - Vern + Vern @end verbatim @end example @@ -6606,7 +6604,7 @@ way to compress the tables. See above. - Vern + Vern @end verbatim @end example @@ -6637,7 +6635,7 @@ No, there's no way to put back an end-of-file. The latest release is 2.5.4, by the way. It fixes some bugs in 2.5.2 and 2.5.3. You can get it from ftp.ee.lbl.gov. - Vern + Vern @end verbatim @end example @@ -6661,13 +6659,13 @@ any blanks around it. If you instead want the special '|' *action* (which from your scanner appears to be the case), which is a way of giving two different rules the same action: - foo | - bar matched_foo_or_bar(); + foo | + bar matched_foo_or_bar(); then '|' *must* be separated from the first rule by whitespace and *must* be followed by a new line. You *cannot* write it as: - foo | bar matched_foo_or_bar(); + foo | bar matched_foo_or_bar(); even though you might think you could because yacc supports this syntax. The reason for this unfortunately incompatibility is historical, but it's @@ -6678,7 +6676,7 @@ from your use of '|' later confusing flex. Let me know if you still have problems. - Vern + Vern @end verbatim @end example @@ -6704,7 +6702,7 @@ parentheses. Note that you must also be building the scanner with the -l option for AT&T lex compatibility. Without this option, flex automatically encloses the definitions in parentheses. - Vern + Vern @end verbatim @end example @@ -6728,20 +6726,20 @@ From: Vern Paxson I can't get this problem to reproduce - it works fine for me. Note though that if what you have is slightly different: - COMMENT ^\*.* - %% - {COMMENT} { } + COMMENT ^\*.* + %% + {COMMENT} { } then it won't work, because flex pushes back macro definitions enclosed in ()'s, so the rule becomes - (^\*.*) { } + (^\*.*) { } and now that the '^' operator is not at the immediate beginning of the line, it's interpreted as just a regular character. You can avoid this behavior by using the "-l" lex-compatibility flag, or "%option lex-compat". - Vern + Vern @end verbatim @end example @@ -6772,7 +6770,7 @@ it should be a problem. Lex's matching is clearly wrong, and I'd hope that usually the intent remains the same as expressed with the pattern, so flex's matching will be correct. - Vern + Vern @end verbatim @end example @@ -6813,7 +6811,7 @@ use flex. The latest release is 2.5.4, by the way, available from ftp.ee.lbl.gov. - Vern + Vern @end verbatim @end example @@ -6839,7 +6837,7 @@ even compile ...) You need instead: and that should work fine - there's no restriction on what can go inside of ()'s except for the trailing context operator, '/'. - Vern + Vern @end verbatim @end example @@ -6868,7 +6866,7 @@ have been on the to-do list for a while. As flex is a purely spare-time project for me, no guarantees when this will be added (in particular, it for sure won't be for many months to come). - Vern + Vern @end verbatim @end example @@ -6901,7 +6899,7 @@ What you need to do is derive a subclass from yyFlexLexer that provides the above yylex() method, squirrels away lvalp and parm into member variables, and then invokes yyFlexLexer::yylex() to do the regular scanning. - Vern + Vern @end verbatim @end example @@ -6929,7 +6927,7 @@ even considers the possibility of matching "/*". Example: - '([^']*|{ESCAPE_SEQUENCE})' + '([^']*|{ESCAPE_SEQUENCE})' will match all the text between the ''s (inclusive). So the lexer considers this as a token beginning at the first ', and doesn't even @@ -6938,7 +6936,7 @@ attempt to match other tokens inside it. I thinnk this subtlety is not worth putting in the manual, as I suspect it would confuse more people than it would enlighten. - Vern + Vern @end verbatim @end example @@ -6960,9 +6958,9 @@ From: Vern Paxson What version of flex are you using? If I feed this to 2.5.4, it complains: - "bug.l", line 5: EOF encountered inside an action - "bug.l", line 5: unrecognized rule - "bug.l", line 5: fatal parse error + "bug.l", line 5: EOF encountered inside an action + "bug.l", line 5: unrecognized rule + "bug.l", line 5: fatal parse error Not the world's greatest error message, but it manages to flag the problem. @@ -6971,7 +6969,7 @@ an action on a separate line, since it's ambiguous with an indented rule.) You can get 2.5.4 from ftp.ee.lbl.gov. - Vern + Vern @end verbatim @end example @@ -7020,9 +7018,9 @@ From: Vern Paxson > I took a quick look into the flex-sources and altered some #defines in > flexdefs.h: > -> #define INITIAL_MNS 64000 -> #define MNS_INCREMENT 1024000 -> #define MAXIMUM_MNS 64000 +> #define INITIAL_MNS 64000 +> #define MNS_INCREMENT 1024000 +> #define MAXIMUM_MNS 64000 The things to fix are to add a couple of zeroes to: @@ -7033,8 +7031,8 @@ The things to fix are to add a couple of zeroes to: and, if you get complaints about too many rules, make the following change too: - #define YY_TRAILING_MASK 0x200000 - #define YY_TRAILING_HEAD_MASK 0x400000 + #define YY_TRAILING_MASK 0x200000 + #define YY_TRAILING_HEAD_MASK 0x400000 - Vern @end verbatim @@ -7069,7 +7067,7 @@ You need to pass &fin, to turn it into an ifstream* instead of an ifstream. Then its type will be compatible with the expected istream*, because ifstream is derived from istream. - Vern + Vern @end verbatim @end example @@ -7099,7 +7097,7 @@ No, yyrestart() doesn't imply a rewind, even though its name might sound like it does. It tells the scanner to flush its internal buffers and start reading from the given file at its present location. - Vern + Vern @end verbatim @end example @@ -7126,7 +7124,7 @@ This is a known problem with Solaris C++ (and/or Solaris yacc). I believe the fix is to explicitly insert some 'extern "C"' statements for the corresponding routines/symbols. - Vern + Vern @end verbatim @end example @@ -7157,7 +7155,7 @@ an example in the man page of how this can lead to different matching. Flex's behavior complies with the POSIX standard (or at least with the last POSIX draft I saw). - Vern + Vern @end verbatim @end example @@ -7183,7 +7181,7 @@ yytext as "extern char yytext[]" (which is what lex uses) instead of "extern char *yytext" (which is what flex uses). If it's not that, then I'm afraid I don't know what the problem might be. - Vern + Vern @end verbatim @end example @@ -7211,7 +7209,7 @@ a declaration of yy_start in order to get your scanner to compile when using C++; instead, the correct fix is to make lexbegin() a member function (by deriving from yyFlexLexer). - Vern + Vern @end verbatim @end example @@ -7234,7 +7232,7 @@ YY_USER_ACTION to count the number of characters matched. The latest flex release, by the way, is 2.5.4, available from ftp.ee.lbl.gov. - Vern + Vern @end verbatim @end example @@ -7258,7 +7256,7 @@ you are in the file, by counting the number of characters scanned for each token (available in yyleng). It may prove convenient to do this by redefining YY_USER_ACTION, as described in the manual. - Vern + Vern @end verbatim @end example @@ -7288,7 +7286,7 @@ While generating a .h file like you suggests is certainly cleaner, flex development has come to a virtual stand-still :-(, so a workaround like the above is much more pragmatic than waiting for a new feature. - Vern + Vern @end verbatim @end example @@ -7312,19 +7310,19 @@ name that is also a variable name, or something like that; flex spits out #define's for each start condition name, mapping them to a number, so you can wind up with: - %x foo - %% - ... - %% - void bar() - { - int foo = 3; - } + %x foo + %% + ... + %% + void bar() + { + int foo = 3; + } and the penultimate will turn into "int 1 = 3" after C preprocessing, since flex will put "#define foo 1" in the generated scanner. - Vern + Vern @end verbatim @end example @@ -7351,7 +7349,7 @@ on that and translate it into an RE. Sorry for the less-than-happy news ... - Vern + Vern @end verbatim @end example @@ -7380,7 +7378,7 @@ that the text will often include NUL's. So that's the first thing to look for. - Vern + Vern @end verbatim @end example @@ -7401,7 +7399,7 @@ First, to go fast, you want to match as much text as possible, which your scanners don't in the case that what they're scanning is *not* a tag. So you want a rule like: - [^<]+ + [^<]+ Second, C++ scanners are particularly slow if they're interactive, which they are by default. Using -B speeds it up by a factor of 3-4 @@ -7411,15 +7409,15 @@ Third, C++ scanners that use the istream interface are slow, because of how poorly implemented istream's are. I built two versions of the following scanner: - %% - .*\n - .* - %% + %% + .*\n + .* + %% and the C version inhales a 2.5MB file on my workstation in 0.8 seconds. The C++ istream version, using -B, takes 3.8 seconds. - Vern + Vern @end verbatim @end example @@ -7441,7 +7439,7 @@ From: Vern Paxson There shouldn't be, all it ever does with the date is ask the system for it and then print it out. - Vern + Vern @end verbatim @end example @@ -7465,7 +7463,7 @@ you use fgets instead (which you should anyway, to protect against buffer overflows), then the final \n will be preserved in the string, and you can scan that in order to find the end of the string. - Vern + Vern @end verbatim @end example @@ -7498,7 +7496,7 @@ From: Vern Paxson Derive your own subclass and make mylineno a member variable of it. - Vern + Vern @end verbatim @end example @@ -7546,7 +7544,7 @@ you have to see what problems they missed. No, definitely not. It's meant to be for those situations where you absolutely must squeeze every last cycle out of your scanner. - Vern + Vern @end verbatim @end example @@ -7578,7 +7576,7 @@ correct state and reading at the right point in the input file. I don't - but it seems like a reasonable project to undertake (unlike numerous other flex tweaks :-). - Vern + Vern @end verbatim @end example @@ -7588,11 +7586,11 @@ numerous other flex tweaks :-). @example @verbatim Received: from 131.173.17.11 (131.173.17.11 [131.173.17.11]) - by ee.lbl.gov (8.9.1/8.9.1) with ESMTP id AAA03838 - for ; Thu, 20 Aug 1998 00:47:57 -0700 (PDT) + by ee.lbl.gov (8.9.1/8.9.1) with ESMTP id AAA03838 + for ; Thu, 20 Aug 1998 00:47:57 -0700 (PDT) Received: from hal.cl-ki.uni-osnabrueck.de (hal.cl-ki.Uni-Osnabrueck.DE [131.173.141.2]) - by deimos.rz.uni-osnabrueck.de (8.8.7/8.8.8) with ESMTP id JAA34694 - for ; Thu, 20 Aug 1998 09:47:55 +0200 + by deimos.rz.uni-osnabrueck.de (8.8.7/8.8.8) with ESMTP id JAA34694 + for ; Thu, 20 Aug 1998 09:47:55 +0200 Received: (from georg@localhost) by hal.cl-ki.uni-osnabrueck.de (8.6.12/8.6.12) id JAA34834 for vern@ee.lbl.gov; Thu, 20 Aug 1998 09:47:54 +0200 From: Georg Rehm Message-Id: <199808200747.JAA34834@hal.cl-ki.uni-osnabrueck.de> @@ -7631,7 +7629,7 @@ appeared when flexing the code. Do you have an idea what's going on here? Greetings from Germany, - Georg + Georg -- Georg Rehm georg@cl-ki.uni-osnabrueck.de Institute for Semantic Information Processing, University of Osnabrueck, FRG @@ -7661,7 +7659,7 @@ The fix is to either rethink how come you're using such a big macro and perhaps there's another/better way to do it; or to rebuild flex's own scan.c with a larger value for - #define YY_BUF_SIZE 16384 + #define YY_BUF_SIZE 16384 - Vern @end verbatim @@ -7710,7 +7708,7 @@ your scanner into the behavior you desire. Sorry for the less-than-completely-satisfactory answer. - Vern + Vern @end verbatim @end example @@ -7737,7 +7735,7 @@ up with that token rather than reading a fresh one. If you're using yacc, then the special "error" production can sometimes be used to consume tokens in an attempt to get the parser into a consistent state. - Vern + Vern @end verbatim @end example @@ -7767,11 +7765,11 @@ Simple, no. One approach might be to return a magic character on EWOULDBLOCK and have a rule - .* // put back .*, eat magic character + .* // put back .*, eat magic character This is off the top of my head, not sure it'll work. - Vern + Vern @end verbatim @end example @@ -7800,11 +7798,11 @@ You can't indent your rules like this - that's where the errors are coming from. Flex copies indented text to the output file, it's how you do things like - int num_lines_seen = 0; + int num_lines_seen = 0; to declare local variables. - Vern + Vern @end verbatim @end example @@ -7826,7 +7824,7 @@ From: Vern Paxson It's large to optimize performance when scanning large files. You can safely make it a lot lower if needed. - Vern + Vern @end verbatim @end example @@ -7854,7 +7852,7 @@ ams */ recompile everything, and it should all work. - Vern + Vern @end verbatim @end example @@ -7890,7 +7888,7 @@ Single-rule is nice but will always have the problem of either setting restrictions on comments (like not allowing multi-line comments) and/or running the risk of consuming the entire input stream, as noted above. - Vern + Vern @end verbatim @end example @@ -7900,8 +7898,8 @@ running the risk of consuming the entire input stream, as noted above. @example @verbatim Received: from mc-qout4.whowhere.com (mc-qout4.whowhere.com [209.185.123.18]) - by ee.lbl.gov (8.9.3/8.9.3) with SMTP id IAA05100 - for ; Tue, 15 Jun 1999 08:56:06 -0700 (PDT) + by ee.lbl.gov (8.9.3/8.9.3) with SMTP id IAA05100 + for ; Tue, 15 Jun 1999 08:56:06 -0700 (PDT) Received: from Unknown/Local ([?.?.?.?]) by my-deja.com; Tue Jun 15 08:55:43 1999 To: vern@ee.lbl.gov Date: Tue, 15 Jun 1999 08:55:43 -0700 @@ -7979,7 +7977,7 @@ From: Vern Paxson Derive your own subclass from yyFlexLexer. - Vern + Vern @end verbatim @end example @@ -8004,7 +8002,7 @@ You need to use the parser to build a parse tree (= abstract syntax trwee), and when that's all done you recursively evaluate the tree, binding variables to values at that time. - Vern + Vern @end verbatim @end example @@ -8041,7 +8039,7 @@ Also note that for speed, you'll want to add a ".*" rule at the end, otherwise rules that don't match any of the patterns will be matched very slowly, a character at a time. - Vern + Vern @end verbatim @end example @@ -8083,7 +8081,7 @@ initscan.c to scan.c in order to build flex. Try fetching a fresh distribution from ftp.ee.lbl.gov. (Or you can first try removing ".bootstrap" and doing a make again.) - Vern + Vern @end verbatim @end example @@ -8104,14 +8102,14 @@ From: Vern Paxson Try: - cp initscan.c scan.c - touch scan.c - make scan.o + cp initscan.c scan.c + touch scan.c + make scan.o If this last tries to first build scan.c from scan.l using ./flex, then your "make" is broken, in which case compile scan.c to scan.o by hand. - Vern + Vern @end verbatim @end example @@ -8132,7 +8130,7 @@ The parser relies on calling yylex(), but you're instead using the C++ scanning class, so you need to supply a yylex() "glue" function that calls an instance scanner of the scanner (e.g., "scanner->yylex()"). - Vern + Vern @end verbatim @end example @@ -8156,7 +8154,7 @@ assuming knowledge of the AT&T lex's internal variables. For flex, you can probably do the equivalent using a switch on YYSTATE. - Vern + Vern @end verbatim @end example @@ -8185,7 +8183,7 @@ Again, for flex, no. See the file "COPYING" in the flex distribution for the legalese. - Vern + Vern @end verbatim @end example @@ -8208,7 +8206,7 @@ From: Vern Paxson You can't do this - flex is *not* a parser like yacc (which does indeed allow recursion), it is a scanner that's confined to regular expressions. - Vern + Vern @end verbatim @end example @@ -8239,7 +8237,7 @@ If this is exactly your program: then the problem is that the last rule needs to be "{whitespace}" ! - Vern + Vern @end verbatim @end example @@ -8892,7 +8890,7 @@ YY_CURRENT_BUFFER: replaced by yy_current_buffer(). YY_BUFFER_STATE: replaced by yybuffer. @item -YY_NEW_FILE: In previous versions of @code{flex}, ehen assigning +YY_NEW_FILE: In previous versions of @code{flex}, when assigning @file{yyin} to a new input file, after doing the assignment you had to call the special action @code{YY_NEW_FILE}. This is no longer necessary. -- cgit v1.2.1 From 20779d47a7762e707b07889b48647cd08f97fb0f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 15 Oct 2020 06:13:24 -0400 Subject: Factor C/C++ assumptions out of filter.c. No diffs in generated test code from this commit. --- src/filter.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/filter.c b/src/filter.c index b9782f0..2f31484 100644 --- a/src/filter.c +++ b/src/filter.c @@ -160,13 +160,13 @@ bool filter_apply_chain (struct filter * chain) * to sync the stream. This is a Hail Mary situation. It seems to work. */ close (pipes[1]); -clearerr(stdin); + clearerr(stdin); if (dup2 (pipes[0], fileno (stdin)) == -1) flexfatal (_("dup2(pipes[0],0)")); close (pipes[0]); - fseek (stdin, 0, SEEK_CUR); - ungetc(' ', stdin); /* still an evil hack, but one that works better */ - (void)fgetc(stdin); /* on NetBSD than the fseek attempt does */ + fseek (stdin, 0, SEEK_CUR); + ungetc(' ', stdin); /* still an evil hack, but one that works better */ + (void)fgetc(stdin); /* on NetBSD than the fseek attempt does */ /* run as a filter, either internally or by exec */ if (chain->filter_func) { @@ -179,8 +179,8 @@ clearerr(stdin); else { execvp (chain->argv[0], (char **const) (chain->argv)); - lerr_fatal ( _("exec of %s failed"), - chain->argv[0]); + lerr_fatal ( _("exec of %s failed"), + chain->argv[0]); } FLEX_EXIT (1); @@ -191,7 +191,7 @@ clearerr(stdin); if (dup2 (pipes[1], fileno (stdout)) == -1) flexfatal (_("dup2(pipes[1],1)")); close (pipes[1]); - fseek (stdout, 0, SEEK_CUR); + fseek (stdout, 0, SEEK_CUR); return true; } @@ -256,23 +256,23 @@ int filter_tee_header (struct filter *chain) */ if (write_header) { - fputs (check_4_gnu_m4, to_h); + fputs (check_4_gnu_m4, to_h); fputs ("m4_changecom`'m4_dnl\n", to_h); fputs ("m4_changequote`'m4_dnl\n", to_h); fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h); - fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); - fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", - to_h); - fprintf (to_h, "#ifndef %sHEADER_H\n", ctrl.prefix); - fprintf (to_h, "#define %sHEADER_H 1\n", ctrl.prefix); - fprintf (to_h, "#define %sIN_HEADER 1\n\n", ctrl.prefix); + fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); + fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); + if (backend == &cpp_backend) { + fprintf (to_h, "#ifndef %sHEADER_H\n", ctrl.prefix); + fprintf (to_h, "#define %sHEADER_H 1\n", ctrl.prefix); + fprintf (to_h, "#define %sIN_HEADER 1\n\n", ctrl.prefix); + } fprintf (to_h, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", env.headerfilename != NULL ? env.headerfilename : ""); - } - fputs (check_4_gnu_m4, to_c); + fputs (check_4_gnu_m4, to_c); fputs ("m4_changecom`'m4_dnl\n", to_c); fputs ("m4_changequote`'m4_dnl\n", to_c); fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c); @@ -291,10 +291,12 @@ int filter_tee_header (struct filter *chain) /* write a fake line number. It will get fixed by the linedir filter. */ if (ctrl.gen_line_dirs) - fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n"); + fprintf (to_h, "m4_ifdef([[M4_HOOK_TRACE_LINE_FORMAT]], [[M4_HOOK_TRACE_LINE_FORMAT([[4000]], [[M4_YY_OUTFILE_NAME]])]])"); - fprintf (to_h, "#undef %sIN_HEADER\n", ctrl.prefix); - fprintf (to_h, "#endif /* %sHEADER_H */\n", ctrl.prefix); + if (backend == &cpp_backend) { + fprintf (to_h, "#undef %sIN_HEADER\n", ctrl.prefix); + fprintf (to_h, "#endif /* %sHEADER_H */\n", ctrl.prefix); + } fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h); fflush (to_h); -- cgit v1.2.1 From dd60560bfd804f430924647bab625f9e887c367d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 15 Oct 2020 06:43:21 -0400 Subject: Refactor filter.c to use line_directive_out(). To make this work, use line_directive_out() had to be servered from its deoendence on hidden globaks. Which was a good idea anyway, No diffs in generated test code from this commit. Yet another well-hidden C assumption. I begin to woner if I will expire of old age before fkushing out all of these. --- src/filter.c | 2 +- src/flexdef.h | 2 +- src/main.c | 14 +++++++------- src/misc.c | 11 +++++------ src/nfa.c | 2 +- src/parse.y | 2 +- src/scan.l | 6 +++--- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/filter.c b/src/filter.c index 2f31484..ddf68af 100644 --- a/src/filter.c +++ b/src/filter.c @@ -291,7 +291,7 @@ int filter_tee_header (struct filter *chain) /* write a fake line number. It will get fixed by the linedir filter. */ if (ctrl.gen_line_dirs) - fprintf (to_h, "m4_ifdef([[M4_HOOK_TRACE_LINE_FORMAT]], [[M4_HOOK_TRACE_LINE_FORMAT([[4000]], [[M4_YY_OUTFILE_NAME]])]])"); + line_directive_out (to_h, NULL, 4000); if (backend == &cpp_backend) { fprintf (to_h, "#undef %sIN_HEADER\n", ctrl.prefix); diff --git a/src/flexdef.h b/src/flexdef.h index 775b6ad..2a92f9e 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -909,7 +909,7 @@ extern void lerr_fatal(const char *, ...) ; /* Spit out a "#line" statement. */ -extern void line_directive_out(FILE *, int); +extern void line_directive_out(FILE *, char *, int); /* Mark the current position in the action array as the end of the section 1 * user defs. diff --git a/src/main.c b/src/main.c index a36339a..b6ad5be 100644 --- a/src/main.c +++ b/src/main.c @@ -219,21 +219,21 @@ int flex_main (int argc, char *argv[]) out (&action_array[defs1_offset]); - line_directive_out (stdout, 0); + line_directive_out (stdout, NULL, linenum); skelout (true); /* %% [4.0] - various random yylex internals get dumped here */ /* Copy prolog to output file. */ out (&action_array[prolog_offset]); - line_directive_out (stdout, 0); + line_directive_out (stdout, NULL, linenum); skelout (true); /* %% [5.0] - main loop of matching-engine code gets dumped here */ /* Copy actions to output file. */ out (&action_array[action_offset]); - line_directive_out (stdout, 0); + line_directive_out (stdout, NULL, linenum); /* generate cases for any missing EOF rules */ for (i = 1; i <= lastsc; ++i) @@ -253,7 +253,7 @@ int flex_main (int argc, char *argv[]) /* Copy remainder of input to output. */ - line_directive_out (stdout, 1); + line_directive_out (stdout, infilename, linenum); if (sectnum == 3) { OUT_BEGIN_CODE (); @@ -1209,7 +1209,7 @@ void flexinit (int argc, char **argv) void readin (void) { - line_directive_out(NULL, 1); + line_directive_out(NULL, infilename, linenum); if (yyparse ()) { pinpoint_message (_("fatal parse error")); @@ -1265,7 +1265,7 @@ void readin (void) flexerror(_("Prefix cannot include '[' or ']'")); if (env.did_outfilename) - line_directive_out (stdout, 0); + line_directive_out (stdout, NULL, linenum); /* This is where we begin writing to the file. */ @@ -1278,7 +1278,7 @@ void readin (void) outn((char*) top_buf.elts); /* Place a bogus line directive, it will be fixed in the filter. */ - line_directive_out(0, false); + line_directive_out(NULL, NULL, 0); /* User may want to set the scanner prototype */ if (ctrl.yydecl != NULL) { diff --git a/src/misc.c b/src/misc.c index 6057587..9cecd5c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -262,9 +262,8 @@ void lerr_fatal (const char *msg, ...) } -/* line_directive_out - spit out a "#line" statement */ - -void line_directive_out (FILE *output_file, int do_infile) +/* line_directive_out - spit out a "#line" statement or equivalent */ +void line_directive_out (FILE *output_file, char *path, int linenum) { char *trace_fmt = "m4_ifdef([[M4_HOOK_TRACE_LINE_FORMAT]], [[M4_HOOK_TRACE_LINE_FORMAT([[%d]], [[%s]])]])"; char directive[MAXLINE*2], filename[MAXLINE]; @@ -273,9 +272,9 @@ void line_directive_out (FILE *output_file, int do_infile) if (!ctrl.gen_line_dirs) return; - s1 = do_infile ? infilename : "M4_YY_OUTFILE_NAME"; + s1 = (path != NULL) ? path : "M4_YY_OUTFILE_NAME"; - if (do_infile && !s1) + if ((path != NULL) && !s1) s1 = ""; s2 = filename; @@ -291,7 +290,7 @@ void line_directive_out (FILE *output_file, int do_infile) *s2 = '\0'; - if (do_infile) + if (path != NULL) snprintf (directive, sizeof(directive), trace_fmt, linenum, filename); else { snprintf (directive, sizeof(directive), trace_fmt, 0, filename); diff --git a/src/nfa.c b/src/nfa.c index 57a6634..f6e8300 100644 --- a/src/nfa.c +++ b/src/nfa.c @@ -286,7 +286,7 @@ void finish_rule (int mach, int variable_trail_rule, int headcnt, int trailcn if (!continued_action) add_action ("YY_RULE_SETUP\n"); - line_directive_out(NULL, 1); + line_directive_out(NULL, infilename, linenum); add_action("[["); } diff --git a/src/parse.y b/src/parse.y index 2bb9b1c..9cd764c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -989,7 +989,7 @@ void build_eof_action(void) } } - line_directive_out(NULL, 1); + line_directive_out(NULL, infilename, linenum); add_action("[["); /* This isn't a normal rule after all - don't count it as diff --git a/src/scan.l b/src/scan.l index af6f4ce..08a4842 100644 --- a/src/scan.l +++ b/src/scan.l @@ -100,7 +100,7 @@ extern const char *escaped_qstart, *escaped_qend; /* Emit the needed line directive... */\ if (indented_code == false) { \ linenum++; \ - line_directive_out(NULL, 1); \ + line_directive_out(NULL, infilename, linenum); \ } \ add_action(M4QSTART); \ yy_push_state(CODEBLOCK); \ @@ -110,7 +110,7 @@ extern const char *escaped_qstart, *escaped_qend; #define END_CODEBLOCK do { \ yy_pop_state();\ add_action(M4QEND); \ - if (!indented_code) line_directive_out(NULL, 0);\ + if (!indented_code) line_directive_out(NULL, NULL, linenum); \ } while (0) %} @@ -187,7 +187,7 @@ M4QEND "]""]" sectnum = 2; bracelevel = 0; mark_defs1(); - line_directive_out(NULL, 1); + line_directive_out(NULL, infilename, linenum); BEGIN(SECT2PROLOG); return SECTEND; } -- cgit v1.2.1 From d658c1c167023d74ae8332f8d1b9d62435dbf8f5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 15 Oct 2020 07:20:49 -0400 Subject: Make the format for detecting trace lines a backend property. No changes in generated test code from this commit. --- src/cpp_backend.c | 1 + src/filter.c | 9 +++++---- src/flexdef.h | 5 +++-- src/regex.c | 7 +++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cpp_backend.c b/src/cpp_backend.c index c483651..b002172 100644 --- a/src/cpp_backend.c +++ b/src/cpp_backend.c @@ -56,4 +56,5 @@ const char *cpp_skel[] = { struct flex_backend_t cpp_backend = { .suffix = cpp_suffix, .skel = cpp_skel, + .linedir_re = "^#line ([[:digit:]]+) \"(.*)\"", }; diff --git a/src/filter.c b/src/filter.c index ddf68af..db4ff75 100644 --- a/src/filter.c +++ b/src/filter.c @@ -345,16 +345,17 @@ int filter_fix_linedirs (struct filter *chain) bool in_gen = true; /* in generated code */ bool last_was_blank = false; - if (!chain) + if (!chain || backend->linedir_re == NULL) return 0; while (fgets (buf, (int) readsz, stdin)) { regmatch_t m[10]; - /* Check for #line directive. */ - if (buf[0] == '#' - && regexec (®ex_linedir, buf, 3, m, 0) == 0) { + /* Check for directive. Note wired-in assumption: + * field reference 1 is line number, 2 is filename. + */ + if (regexec (®ex_linedir, buf, 3, m, 0) == 0) { char *fname; diff --git a/src/flexdef.h b/src/flexdef.h index 2a92f9e..0643212 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -299,8 +299,9 @@ /* Method table describing a language-specific back end */ struct flex_backend_t { - const char *(*suffix)(void); // Generate suffix for lexer source code - const char **skel; + const char *(*suffix)(void); // Generate suffix for lexer source code + const char **skel; // Digested skeleton file + const char *linedir_re; // RE to recognize trace lines. May be NULL. }; extern size_t footprint; diff --git a/src/regex.c b/src/regex.c index f4c4163..a75c2b4 100644 --- a/src/regex.c +++ b/src/regex.c @@ -24,8 +24,6 @@ #include "flexdef.h" -static const char* REGEXP_LINEDIR = "^#line ([[:digit:]]+) \"(.*)\""; - regex_t regex_linedir; /**< matches line directives */ @@ -34,7 +32,8 @@ regex_t regex_linedir; /**< matches line directives */ */ bool flex_init_regex(void) { - flex_regcomp(®ex_linedir, REGEXP_LINEDIR, REG_EXTENDED); + if (backend->linedir_re != NULL) + flex_regcomp(®ex_linedir, backend->linedir_re, REG_EXTENDED); return true; } @@ -100,7 +99,7 @@ char *regmatch_cpy (regmatch_t * m, char *dest, const char *src) } snprintf (dest, (size_t) regmatch_len(m), "%s", src + m->rm_so); - return dest; + return dest; } /** Get the length in characters of the match. -- cgit v1.2.1 From 30d0e5f95410fb7590b134e5a816da98d0bdaf2a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 15 Oct 2020 11:39:59 -0400 Subject: Push some C-specific assumptions out of filter.c to the skel file. The way this is done is by adding a capabiiliy to mine string-valued properties out of skel files in Flex's binary. Also, some reorganization to improve the encapsulation of knowledge about skel files. No changes in generated test files from this patch. --- src/Makefile.am | 2 +- src/cpp-flex.skl | 15 +++- src/cpp_backend.c | 60 ---------------- src/filter.c | 24 +++---- src/flexdef.h | 43 +++++------ src/main.c | 10 +-- src/misc.c | 67 ------------------ src/regex.c | 9 +-- src/skeletons.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 261 insertions(+), 177 deletions(-) delete mode 100644 src/cpp_backend.c create mode 100644 src/skeletons.c diff --git a/src/Makefile.am b/src/Makefile.am index 40ca850..6a922e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,7 +53,7 @@ flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS) COMMON_SOURCES = \ buf.c \ ccl.c \ - cpp_backend.c \ + skeletons.c \ cpp_skel.h \ dfa.c \ ecs.c \ diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 2fea8fb..a1eb04c 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -61,7 +61,7 @@ m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) %# If this is not defined, no trace lines will be generated. m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" ]]) - +m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_HOOK_TABLE_OPENER]], [[{]]) m4_define([[M4_HOOK_TABLE_CONTINUE]], [[},]]) m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) @@ -88,8 +88,17 @@ m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 ]]) +%# Not used in the skeleton - meant to be read by the Flex code +m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) + %% [0.0] Make hook macros available to Flex +m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl +#ifndef M4_MODE_PREFIX[[HEADER_H]] +#define M4_MODE_PREFIX[[HEADER_H]] +#define M4_MODE_PREFIX[[IN_HEADER]] 1 + +]]) m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ @@ -123,7 +132,6 @@ m4_ifelse(M4_MODE_PREFIX,yy,, ]]) ]]) ]]) - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION #define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION @@ -4288,6 +4296,9 @@ m4_ifdef( [[M4_YY_IN_HEADER]], #undef YY_DECL #endif m4preproc_undivert(1) +#undef M4_MODE_PREFIX[[IN_HEADER]] +#endif /* M4_MODE_PREFIX[[HEADER_H]] */ +m4_undefine([[M4_YY_IN_HEADER]])m4_dnl ]]) %# Local Variables: diff --git a/src/cpp_backend.c b/src/cpp_backend.c deleted file mode 100644 index b002172..0000000 --- a/src/cpp_backend.c +++ /dev/null @@ -1,60 +0,0 @@ -/* flex - tool to generate fast lexical analyzers */ - -/* Copyright (c) 1990 The Regents of the University of California. */ -/* All rights reserved. */ - -/* This code is derived from software contributed to Berkeley by */ -/* Vern Paxson. */ - -/* The United States Government has rights in this work pursuant */ -/* to contract no. DE-AC03-76SF00098 between the United States */ -/* Department of Energy and the University of California. */ - -/* This file is part of flex. */ - -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions */ -/* are met: */ - -/* 1. Redistributions of source code must retain the above copyright */ -/* notice, this list of conditions and the following disclaimer. */ -/* 2. Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ - -/* Neither the name of the University nor the names of its contributors */ -/* may be used to endorse or promote products derived from this software */ -/* without specific prior written permission. */ - -/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */ -/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ -/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ -/* PURPOSE. */ - - -#include "flexdef.h" -#include "tables.h" - -static const char *cpp_suffix (void) -{ - char *suffix; - - if (ctrl.C_plus_plus) - suffix = "cc"; - else - suffix = "c"; - - return suffix; -} - -const char *cpp_skel[] = { -#include "cpp-skel.h" - 0, -}; - -/* This backend is only accessed through this method table */ -struct flex_backend_t cpp_backend = { - .suffix = cpp_suffix, - .skel = cpp_skel, - .linedir_re = "^#line ([[:digit:]]+) \"(.*)\"", -}; diff --git a/src/filter.c b/src/filter.c index db4ff75..5ca834f 100644 --- a/src/filter.c +++ b/src/filter.c @@ -261,12 +261,7 @@ int filter_tee_header (struct filter *chain) fputs ("m4_changequote`'m4_dnl\n", to_h); fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h); fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); - fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); - if (backend == &cpp_backend) { - fprintf (to_h, "#ifndef %sHEADER_H\n", ctrl.prefix); - fprintf (to_h, "#define %sHEADER_H 1\n", ctrl.prefix); - fprintf (to_h, "#define %sIN_HEADER 1\n\n", ctrl.prefix); - } + fputs ("m4_define([[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); fprintf (to_h, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", env.headerfilename != NULL ? env.headerfilename : ""); @@ -292,13 +287,6 @@ int filter_tee_header (struct filter *chain) /* write a fake line number. It will get fixed by the linedir filter. */ if (ctrl.gen_line_dirs) line_directive_out (to_h, NULL, 4000); - - if (backend == &cpp_backend) { - fprintf (to_h, "#undef %sIN_HEADER\n", ctrl.prefix); - fprintf (to_h, "#endif /* %sHEADER_H */\n", ctrl.prefix); - } - fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h); - fflush (to_h); if (ferror (to_h)) lerr (_("error writing output file %s"), @@ -340,12 +328,17 @@ static bool is_blank_line (const char *str) int filter_fix_linedirs (struct filter *chain) { char buf[4096]; + const char *traceline_template, *cp; const size_t readsz = sizeof buf; int lineno = 1; bool in_gen = true; /* in generated code */ bool last_was_blank = false; - if (!chain || backend->linedir_re == NULL) + if (!chain || ctrl.traceline_re == NULL) + return 0; + + traceline_template = skel_property("M4_PROPERTY_TRACE_LINE_TEMPLATE"); + if (traceline_template == NULL) return 0; while (fgets (buf, (int) readsz, stdin)) { @@ -390,8 +383,9 @@ int filter_fix_linedirs (struct filter *chain) /* Adjust the line directives. */ in_gen = true; - snprintf (buf, readsz, "#line %d \"%s\"\n", + snprintf (buf, readsz, traceline_template, lineno + 1, filename); + strncat(buf, "\n", sizeof(buf)-1); } else { /* it's a #line directive for code we didn't write */ diff --git a/src/flexdef.h b/src/flexdef.h index 0643212..02eb9cd 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -296,27 +296,15 @@ */ #define BAD_SUBSCRIPT -32767 -/* Method table describing a language-specific back end */ - -struct flex_backend_t { - const char *(*suffix)(void); // Generate suffix for lexer source code - const char **skel; // Digested skeleton file - const char *linedir_re; // RE to recognize trace lines. May be NULL. -}; - -extern size_t footprint; - typedef enum trit_t { trit_unspecified = -1, trit_false = 0, trit_true = 1, } trit; -extern struct flex_backend_t cpp_backend; - /* Control variables. These are in a struct to avoid having to replicate definitions * twice for each option, instead a single struct can be declared and externed. - * If it;s in this structure, it has a corresponding m4 symbol. + * If it's in this structure, it has a corresponding m4 symbol. */ struct ctrl_bundle_t { bool always_interactive;// always use cheacter-by-character input @@ -390,6 +378,8 @@ struct ctrl_bundle_t { bool no_flex_free; bool no_get_debug; bool no_set_debug; + // Properties read from the skeleton + const char *traceline_re; // Regular expression for recognizing tracelines */ }; /* Environment variables. These control the lexer operation, but do @@ -446,8 +436,6 @@ extern int syntaxerror, eofseen; extern int yymore_used, reject, real_reject, continued_action, in_rule; extern int yymore_really_used, reject_really_used; -extern struct flex_backend_t *backend; - /* Variables used in the flex input routines: * datapos - characters on current output line * dataline - number of contiguous lines of data in current data @@ -527,6 +515,7 @@ extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; * rule_has_nl - true if rule could possibly match a newline * ccl_has_nl - true if current ccl could match a newline * nlch - default eol char + * footprint - total size of tables, in bytes. */ extern int maximum_mns, current_mns, current_max_rules; @@ -536,6 +525,8 @@ extern int *accptnum, *assoc_rule, *state_type; extern int *rule_type, *rule_linenum, *rule_useful; extern bool *rule_has_nl, *ccl_has_nl; extern int nlch; +extern size_t footprint; + /* Different types of states; values are useful as masks, as well, for * routines like check_trailing_context(). @@ -865,9 +856,6 @@ extern void dataend(const char *); /* Flush generated data statements. */ extern void dataflush(void); -/* Do we have a state-entry0format macro? */ -extern bool boneseeker(const char *); - /* Report an error message and terminate. */ extern void flexerror(const char *); @@ -948,9 +936,6 @@ extern void out_m4_define(const char* def, const char* val); */ extern char *readable_form(int); -/* Write out one section of the skeleton file. */ -extern void skelout(bool); - /* Output a yy_trans_info structure. */ extern void transition_struct_out(int, int); @@ -1036,6 +1021,22 @@ extern int flexscan(void); /* Open the given file (if NULL, stdin) for scanning. */ extern void set_input_file(char *); +/* from file skeletons.c */ + +/* return the correct file suffix for the selrcted back end */ +const char *suffix (void); + +/* Mine a text-valued property out of the skeleton file */ +extern const char *skel_property(const char *); + +/* Is the default back end selected?*/ +extern bool is_default_backend(void); + +/* Do we have a line natching the specified prefix? ? */ +extern bool boneseeker(const char *); + +/* Write out one section of the skeleton file. */ +extern void skelout(bool); /* from file sym.c */ diff --git a/src/main.c b/src/main.c index b6ad5be..2bf2fab 100644 --- a/src/main.c +++ b/src/main.c @@ -96,8 +96,6 @@ jmp_buf flex_main_jmp_buf; bool *rule_has_nl, *ccl_has_nl; int nlch = '\n'; -struct flex_backend_t *backend; - bool tablesext, tablesverify, gentables; char *tablesfilename=0,*tablesname=0; struct yytbl_writer tableswr; @@ -394,7 +392,7 @@ void check_options (void) if (!env.did_outfilename) { snprintf (outfile_path, sizeof(outfile_path), outfile_template, - ctrl.prefix, backend->suffix()); + ctrl.prefix, suffix()); env.outfilename = outfile_path; } @@ -738,8 +736,6 @@ void flexinit (int argc, char **argv) sawcmpflag = false; - backend = &cpp_backend; - /* Initialize dynamic array for holding the rule actions. */ action_size = 2048; /* default size of action array in bytes */ action_array = allocate_character_array (action_size); @@ -1581,7 +1577,7 @@ void readin (void) if (ctrl.noyyread) visible_define("M4_MODE_USER_YYREAD"); - if (backend == &cpp_backend) { + if (is_default_backend()) { if (ctrl.C_plus_plus) { visible_define ( "M4_MODE_CXX_ONLY"); } else { @@ -1734,7 +1730,7 @@ void usage (void) if (!env.did_outfilename) { snprintf (outfile_path, sizeof(outfile_path), outfile_template, - ctrl.prefix, backend->suffix()); + ctrl.prefix, suffix()); env.outfilename = outfile_path; } diff --git a/src/misc.c b/src/misc.c index 9cecd5c..5c1664e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -606,57 +606,6 @@ void *reallocate_array (void *array, int size, size_t element_size) } -/* skelout - write out one section of the skeleton file - * - * Description - * Copies skelfile or skel array to stdout until a line beginning with - * "%%" or EOF is found. - */ -void skelout (bool announce) -{ - char buf_storage[MAXLINE]; - char *buf = buf_storage; - bool do_copy = true; - - /* Loop pulling lines either from the skelfile, if we're using - * one, or from the selected back end's skel[] array. - */ - while (env.skelfile != NULL ? - (fgets (buf, MAXLINE, env.skelfile) != NULL) : - ((buf = (char *) backend->skel[skel_ind++]) != 0)) { - - if (env.skelfile != NULL) - chomp (buf); - - /* copy from skel array */ - if (buf[0] == '%') { /* control line */ - /* print the control line as a comment. */ - if (ctrl.ddebug && buf[1] != '#') { - comment(buf); - outc ('\n'); - } - if (buf[1] == '#') { - /* %# indicates comment line to be ignored */ - } - else if (buf[1] == '%') { - /* %% is a break point for skelout() */ - if (announce) { - comment(buf); - outc ('\n'); - } - return; - } - else { - flexfatal (_("bad line in skeleton file")); - } - } - - else if (do_copy) - outn (buf); - } /* end while */ -} - - /* transition_struct_out - output a yy_trans_info structure * * outputs the yy_trans_info structure with the two elements, element_v and @@ -740,20 +689,4 @@ void comment(const char *txt) outc ('\n'); } -/* Search for a string in the skeleton prolog, where macros are defined. - */ -bool boneseeker(const char *bone) -{ - int i; - - for (i = 0; i < sizeof(backend->skel)/sizeof(backend->skel[0]); i++) { - const char *line = backend->skel[i]; - if (strstr(line, bone) != NULL) - return true; - else if (strncmp(line, "%%", 2) == 0) - break; - } - return false; -} - diff --git a/src/regex.c b/src/regex.c index a75c2b4..7dc1d9f 100644 --- a/src/regex.c +++ b/src/regex.c @@ -32,9 +32,10 @@ regex_t regex_linedir; /**< matches line directives */ */ bool flex_init_regex(void) { - if (backend->linedir_re != NULL) - flex_regcomp(®ex_linedir, backend->linedir_re, REG_EXTENDED); - return true; + ctrl.traceline_re = skel_property("M4_PROPERTY_TRACE_LINE_REGEXP"); + if (ctrl.traceline_re != NULL) + flex_regcomp(®ex_linedir, ctrl.traceline_re, REG_EXTENDED); + return true; } /** Compiles a regular expression or dies trying. @@ -44,7 +45,7 @@ bool flex_init_regex(void) */ void flex_regcomp(regex_t *preg, const char *regex, int cflags) { - int err; + int err; memset (preg, 0, sizeof (regex_t)); diff --git a/src/skeletons.c b/src/skeletons.c new file mode 100644 index 0000000..76989d5 --- /dev/null +++ b/src/skeletons.c @@ -0,0 +1,208 @@ +/* flex - tool to generate fast lexical analyzers */ + +/* Copyright (c) 1990 The Regents of the University of California. */ +/* All rights reserved. */ + +/* This code is derived from software contributed to Berkeley by */ +/* Vern Paxson. */ + +/* The United States Government has rights in this work pursuant */ +/* to contract no. DE-AC03-76SF00098 between the United States */ +/* Department of Energy and the University of California. */ + +/* This file is part of flex. */ + +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions */ +/* are met: */ + +/* 1. Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in the */ +/* documentation and/or other materials provided with the distribution. */ + +/* Neither the name of the University nor the names of its contributors */ +/* may be used to endorse or promote products derived from this software */ +/* without specific prior written permission. */ + +/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */ +/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ +/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ +/* PURPOSE. */ + + +#include "flexdef.h" +#include "tables.h" + +/* START digested skeletons */ + +const char *cpp_skel[] = { +#include "cpp-skel.h" + 0, +}; + +/* END digested skeletons */ + +/* Method table describing a language-specific back end. + * Even if this never gets a member other than the skell + * array, it prevents us from geting lost in a maze of + * twity array referebce levels, all different. + */ +struct flex_backend_t { + const char **skel; // Digested skeleton file +}; + +static struct flex_backend_t cpp_backend = { + .skel = cpp_skel, +}; + +static struct flex_backend_t * backend = &cpp_backend; + +/* Functions for querying skeleton properties. */ + +bool is_default_backend(void) +{ + return backend == &cpp_backend; +} + +const char *suffix (void) +{ + char *suffix; + + if (ctrl.C_plus_plus) + suffix = "cc"; + else + suffix = "c"; + + /* Someday this will search the selected skeketon for a suffix */ + + return suffix; +} + +/* Search for a string in the skeleton prolog, where macros are defined. + */ +bool boneseeker(const char *bone) +{ + int i; + + for (i = 0; backend->skel[i] != NULL; i++) { + const char *line = backend->skel[i]; + if (strstr(line, bone) != NULL) + return true; + else if (strncmp(line, "%%", 2) == 0) + break; + } + return false; +} + +/* Search for a m4 define of the property key, retrieve the value. The + * definition must be single-line. Don't call this a second time before + * stashing away the previous return, we cheat with static buffers. + */ +const char *skel_property(const char *propname) +{ + int i; + static char name[256], value[256], *np, *vp;; + const char *cp; + + for (i = 0; backend->skel[i] != NULL; i++) { + const char *line = backend->skel[i]; + if (line[0] == '\0') + continue; + /* only scan before first skell breakpoint */ + if (strncmp(line, "%%", 2) == 0) + break; + /* ignore anything that's not a definition */ + if (strncmp(line, "m4_define(", 10) != 0) + continue; + /* skip space and quotes before macro name */ + for (cp = line + 10; isspace(*cp) || *cp == '['; *cp++) + continue; + /* copy up to following ] into the name buffer */ + np = name; + while (*cp != ']' && *cp != '\0' && (np < name + sizeof(name)-1)) { + *np++ = *cp++; + } + *np = '\0'; + /* check for valid and matching name */ + if (*cp == ']') { + if (strcmp(name, propname) != 0) + continue; /* try next line */ + } else { + flexerror(_("unterminated or too long property name")); + continue; + } + /* skip to the property value */ + while (*cp != '\0' && (*cp == ']' || isspace(*cp) || *cp == ',')) + cp++; + while (*cp == '[') + cp++; + if (*cp == '\0') + flexerror(_("garbled property line")); + /* extract the value */ + vp = value; + while (*cp != '\0' && vp < value + sizeof(value) - 1 && (cp[0] != ']' || cp[1] != ']')) + *vp++ = *cp++; + if (*cp == ']') { + *vp = '\0'; + return value; + } else { + flexerror(_("unterminated or too long property value")); + } + } + return NULL; +} + +/* skelout - write out one section of the skeleton file + * + * Description + * Copies skelfile or skel array to stdout until a line beginning with + * "%%" or EOF is found. + */ +void skelout (bool announce) +{ + char buf_storage[MAXLINE]; + char *buf = buf_storage; + bool do_copy = true; + + /* Loop pulling lines either from the skelfile, if we're using + * one, or from the selected back end's skel[] array. + */ + while (env.skelfile != NULL ? + (fgets (buf, MAXLINE, env.skelfile) != NULL) : + ((buf = (char *) backend->skel[skel_ind++]) != 0)) { + + if (env.skelfile != NULL) + chomp (buf); + + /* copy from skel array */ + if (buf[0] == '%') { /* control line */ + /* print the control line as a comment. */ + if (ctrl.ddebug && buf[1] != '#') { + comment(buf); + outc ('\n'); + } + if (buf[1] == '#') { + /* %# indicates comment line to be ignored */ + } + else if (buf[1] == '%') { + /* %% is a break point for skelout() */ + if (announce) { + comment(buf); + outc ('\n'); + } + return; + } + else { + flexfatal (_("bad line in skeleton file")); + } + } + + else if (do_copy) + outn (buf); + } /* end while */ +} + + +/* end */ -- cgit v1.2.1 From c99e66b54df7828d48d5752686374df72befcbc5 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Thu, 15 Oct 2020 13:25:52 -0700 Subject: Change inner loops to use int not YY_CHAR, removing need for separate NUL table --- src/cpp-flex.skl | 11 ++++++++++- src/dfa.c | 29 +++++------------------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index a1eb04c..1fa3f0d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1778,8 +1778,17 @@ m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ ]]) ]]) +%# yy_c was formerly YY_CHAR, changed to int because table can now +%# have up to 0x101 entries, since we no longer generate a separate +%# NUL table. +%# +%# Note: on x86-64 architecture with gcc -O2, we save an instruction +%# in the main loop, since the character can now be zero-extended in +%# the process of retrieving it from the input stream or the yy_ec[] +%# or yy_meta[] arrays, whereas previously it was zero-extended by a +%# register-to-register move just prior to the yy_chk[] table lookup m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ - YY_CHAR yy_c = $1; + int yy_c = $1; /* Save the backing-up info \before/ computing the next state * because we always compute one more state than needed - we * always proceed until we reach a jam state diff --git a/src/dfa.c b/src/dfa.c index 06bbd63..baa42ed 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -455,31 +455,12 @@ size_t ntod (void) /* Note that the test for ecgroup[0] == numecs below accomplishes * both (1) and (2) above + * + * New way: we will only use NUL table for fulltbl, because the + * scanner will use an integer instead of YY_CHAR as noted above */ - if (!ctrl.fullspd && ecgroup[0] == numecs) { - /* NUL is alone in its equivalence class, which is the - * last one. - */ - int use_NUL_table = (numecs == ctrl.csize); - - if (ctrl.fulltbl && !use_NUL_table) { - /* We still may want to use the table if numecs - * is a power of 2. - */ - if (numecs <= ctrl.csize && is_power_of_2(numecs)) { - use_NUL_table = true; - } - } - - if (use_NUL_table) - nultrans = - allocate_integer_array (current_max_dfas); - - /* From now on, nultrans != nil indicates that we're - * saving null transitions for later, separate encoding. - */ - } - + if (ctrl.fulltbl && ecgroup[0] == numecs && is_power_of_2(numecs)) + nultrans = allocate_integer_array (current_max_dfas); if (ctrl.fullspd) { for (i = 0; i <= numecs; ++i) -- cgit v1.2.1 From 0e32cd6ce31e509d4d8421b87eb06448181b6590 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 15 Oct 2020 22:12:32 -0400 Subject: Add and document machinery to choose a back end by name. Back end is now reported in the metadata comments near the top of generated files. All is in readiness for the start of direct work on Go support. --- doc/flex.texi | 21 +++++---- src/cpp-flex.skl | 18 +++----- src/filter.c | 12 +++-- src/flexdef.h | 12 +++-- src/gen.c | 2 +- src/main.c | 131 +++++++++++++++++++++++++++++++------------------------ src/options.c | 6 ++- src/options.h | 1 + src/parse.y | 4 +- src/regex.c | 7 ++- src/scan.l | 1 + src/skeletons.c | 64 +++++++++++++++++++-------- 12 files changed, 166 insertions(+), 113 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 8fceb5d..2f59179 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8701,14 +8701,19 @@ To get started on writing a new back end, read the definition of struct backend_t in @file{src/flexdefs.h}, and attached comments first. Then read a skeleton file. -You'll want to start by studying the @code{M4_HOOK_*} macros near the -top of the skeleton file. Rather than emit literal language syntax, -Flex ships calls to these macros which are expected to be expanded -within the skeleton. The other things it ships which appear in the -output code are mostly bodies for table initializers, with associated -macros for typenames and table dimensions. The names of all such -macros have the prefix ``M4_HOOK_''; you can study them in the Flex -code by grepping for that prefix. +You'll want to start by studying the @code{M4_PROPERTY_*} macros near the +top of the skeleton file. They declare properties of the back end like +its name and normal source-code suffix. These aren't used for code +generation; they're for Flex to read and key on. + +Following those are the @code{M4_HOOK_*} macros. Rather than emit +literal language syntax, Flex ships calls to these macros which are +expected to be expanded within the skeleton. The other things it +ships which appear in the output code are mostly bodies for table +initializers, with associated macros for typenames and table +dimensions. The names of all such macros have the prefix +``M4_HOOK_''; you can study them in the Flex code by grepping for that +prefix. Flex ships another fairly large set of macros that are guard conditions for conditional macroexpanion. The values of these symbols diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 1fa3f0d..f1ee072 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -50,33 +50,32 @@ m4_changequote([[, ]]) %# This is to aid those who edit the skeleton. %# -%# Macro hooks used by Flex start here +%# Properties not used in the skeleton - meant to be read by the Flex code +m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C/C++]]) +%#m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[]]) +m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) +m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) +%# Macro hooks used by Flex code generators start here m4_define([[M4_HOOK_INT32]], [[flex_int32_t]]) m4_define([[M4_HOOK_INT16]], [[flex_int16_t]]) - m4_define([[M4_HOOK_COMMENT_OPEN]], [[/*]]) m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) - %# If this is not defined, no trace lines will be generated. m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" ]]) -m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_HOOK_TABLE_OPENER]], [[{]]) m4_define([[M4_HOOK_TABLE_CONTINUE]], [[},]]) m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) - +m4_define([[M4_HOOK_RELATIVIZE]], [[$1]]) m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], ]]) - m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) - m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 ]]) - m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1 @@ -88,9 +87,6 @@ m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 ]]) -%# Not used in the skeleton - meant to be read by the Flex code -m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) - %% [0.0] Make hook macros available to Flex m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl diff --git a/src/filter.c b/src/filter.c index 5ca834f..33e1119 100644 --- a/src/filter.c +++ b/src/filter.c @@ -259,7 +259,7 @@ int filter_tee_header (struct filter *chain) fputs (check_4_gnu_m4, to_h); fputs ("m4_changecom`'m4_dnl\n", to_h); fputs ("m4_changequote`'m4_dnl\n", to_h); - fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h); + fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h); fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); fputs ("m4_define([[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); fprintf (to_h, @@ -334,11 +334,7 @@ int filter_fix_linedirs (struct filter *chain) bool in_gen = true; /* in generated code */ bool last_was_blank = false; - if (!chain || ctrl.traceline_re == NULL) - return 0; - - traceline_template = skel_property("M4_PROPERTY_TRACE_LINE_TEMPLATE"); - if (traceline_template == NULL) + if (!chain) return 0; while (fgets (buf, (int) readsz, stdin)) { @@ -348,7 +344,9 @@ int filter_fix_linedirs (struct filter *chain) /* Check for directive. Note wired-in assumption: * field reference 1 is line number, 2 is filename. */ - if (regexec (®ex_linedir, buf, 3, m, 0) == 0) { + if (ctrl.traceline_re != NULL && + ctrl.traceline_template != NULL && + regexec (®ex_linedir, buf, 3, m, 0) == 0) { char *fname; diff --git a/src/flexdef.h b/src/flexdef.h index 02eb9cd..fd7d6df 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -349,7 +349,8 @@ struct ctrl_bundle_t { char *userinit; // Code fragment to be inserted before scanning char *preaction; // Code fragment to be inserted before each action char *postaction; // Code fragment to be inserted after each action - // flags corresponding to the huge mass of --no-yy options + char *emit; // Specify target language to emit. + // flags corresponding to the huge mass of --no-yy options bool no_yy_push_state; bool no_yy_pop_state; bool no_yy_top_state; @@ -379,7 +380,10 @@ struct ctrl_bundle_t { bool no_get_debug; bool no_set_debug; // Properties read from the skeleton + const char *backend_name; // What the back end tells you its name is const char *traceline_re; // Regular expression for recognizing tracelines */ + const char *traceline_template; // templare for emitting trace lines */ + bool have_state_entry_format; // Do we know how to make a state entry address? }; /* Environment variables. These control the lexer operation, but do @@ -1032,8 +1036,8 @@ extern const char *skel_property(const char *); /* Is the default back end selected?*/ extern bool is_default_backend(void); -/* Do we have a line natching the specified prefix? ? */ -extern bool boneseeker(const char *); +/* Select a backend by name */ +extern void backend_by_name(const char *); /* Write out one section of the skeleton file. */ extern void skelout(bool); @@ -1175,7 +1179,7 @@ extern int filter_fix_linedirs(struct filter *chain); */ extern regex_t regex_linedir; -bool flex_init_regex(void); +bool flex_init_regex(const char *); void flex_regcomp(regex_t *preg, const char *regex, int cflags); char *regmatch_dup (regmatch_t * m, const char *src); char *regmatch_cpy (regmatch_t * m, char *dest, const char *src); diff --git a/src/gen.c b/src/gen.c index a2650f6..b42708b 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1019,7 +1019,7 @@ void make_tables (void) yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS); // Performance kludge for C. Gives a small improvement // in table loading time. - if (ctrl.fullspd && boneseeker("m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]]")) + if (ctrl.fullspd && ctrl.have_state_entry_format) yynultrans_tbl->td_flags |= YYTD_PTRANS; yynultrans_tbl->td_lolen = (flex_uint32_t) (lastdfa + 1); yynultrans_tbl->td_data = yynultrans_data = diff --git a/src/main.c b/src/main.c index 2bf2fab..5eb3d48 100644 --- a/src/main.c +++ b/src/main.c @@ -286,12 +286,68 @@ int main (int argc, char *argv[]) return flex_main (argc, argv); } +/* Set up the output filter chain. */ + +void initialize_output_filters(void) +{ + const char * m4 = NULL; + + output_chain = filter_create_int(NULL, filter_tee_header, env.headerfilename); + if ( !(m4 = getenv("M4"))) { + char *slash; + m4 = M4; + if ((slash = strrchr(M4, '/')) != NULL) { + m4 = slash+1; + /* break up $PATH */ + const char *path = getenv("PATH"); + if (!path) { + m4 = M4; + } else { + int m4_length = strlen(m4); + do { + size_t length = strlen(path); + struct stat sbuf; + + const char *endOfDir = strchr(path, ':'); + if (!endOfDir) + endOfDir = path+length; + + { + char *m4_path = calloc(endOfDir-path + 1 + m4_length + 1, 1); + + memcpy(m4_path, path, endOfDir-path); + m4_path[endOfDir-path] = '/'; + memcpy(m4_path + (endOfDir-path) + 1, m4, m4_length + 1); + if (stat(m4_path, &sbuf) == 0 && + (S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) { + m4 = m4_path; + break; + } + free(m4_path); + } + path = endOfDir+1; + } while (path[0]); + if (!path[0]) + m4 = M4; + } + } + } + filter_create_ext(output_chain, m4, "-P", 0); + filter_create_int(output_chain, filter_fix_linedirs, NULL); + + /* For debugging, only run the requested number of filters. */ + if (preproc_level > 0) { + filter_truncate(output_chain, preproc_level); + filter_apply_chain(output_chain); + } +} + + /* check_options - check user-specified options */ void check_options (void) { int i; - const char * m4 = NULL; if (ctrl.lex_compat) { if (ctrl.C_plus_plus) @@ -404,57 +460,6 @@ void check_options (void) outfile_created = 1; } - - - /* Setup the filter chain. */ - output_chain = filter_create_int(NULL, filter_tee_header, env.headerfilename); - if ( !(m4 = getenv("M4"))) { - char *slash; - m4 = M4; - if ((slash = strrchr(M4, '/')) != NULL) { - m4 = slash+1; - /* break up $PATH */ - const char *path = getenv("PATH"); - if (!path) { - m4 = M4; - } else { - int m4_length = strlen(m4); - do { - size_t length = strlen(path); - struct stat sbuf; - - const char *endOfDir = strchr(path, ':'); - if (!endOfDir) - endOfDir = path+length; - - { - char *m4_path = calloc(endOfDir-path + 1 + m4_length + 1, 1); - - memcpy(m4_path, path, endOfDir-path); - m4_path[endOfDir-path] = '/'; - memcpy(m4_path + (endOfDir-path) + 1, m4, m4_length + 1); - if (stat(m4_path, &sbuf) == 0 && - (S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) { - m4 = m4_path; - break; - } - free(m4_path); - } - path = endOfDir+1; - } while (path[0]); - if (!path[0]) - m4 = M4; - } - } - } - filter_create_ext(output_chain, m4, "-P", 0); - filter_create_int(output_chain, filter_fix_linedirs, NULL); - - /* For debugging, only run the requested number of filters. */ - if (preproc_level > 0) { - filter_truncate(output_chain, preproc_level); - filter_apply_chain(output_chain); - } } /* flexend - terminate flex @@ -748,9 +753,6 @@ void flexinit (int argc, char **argv) sf_init (); - /* initialize regex lib */ - flex_init_regex(); - /* Enable C++ if program name ends with '+'. */ program_name = argv[0]; @@ -1014,6 +1016,10 @@ void flexinit (int argc, char **argv) ctrl.useecs = false; break; + case OPT_EMIT: + ctrl.emit = arg; + break; + case OPT_HEADER_FILE: env.headerfilename = arg; break; @@ -1205,6 +1211,8 @@ void flexinit (int argc, char **argv) void readin (void) { + char buf[256]; + line_directive_out(NULL, infilename, linenum); if (yyparse ()) { @@ -1215,8 +1223,15 @@ void readin (void) if (syntaxerror) flexend (1); - yyout = stdout; + /* On --emit, -e, or %option emit, change backends + * This is where backed properties are collected, + * Which means they can't be set from a cudtom skelfile. + */ + backend_by_name(ctrl.emit); + initialize_output_filters(); + + yyout = stdout; if (tablesext) gentables = false; @@ -1414,7 +1429,8 @@ void readin (void) // that historically used to be generated by C code in flex // itself; by shoving all this stuff out to the skeleton file // we make it easier to retarget the code generation. - + snprintf(buf, sizeof(buf), "Target: %s\n", ctrl.backend_name); + comment(buf); comment("START of m4 controls\n"); /* Define the start condition macros. */ @@ -1777,6 +1793,7 @@ void usage (void) "\n" "Generated code:\n" " -+, --c++ generate C++ scanner class\n" " -Dmacro[=defn] #define macro defn (default defn is '1')\n" + " -e, --emit=LANG Specify target language\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 scanner\n" diff --git a/src/options.c b/src/options.c index fd5904a..56c7f42 100644 --- a/src/options.c +++ b/src/options.c @@ -100,7 +100,11 @@ optspec_t flexopts[] = { {"-n", OPT_DONOTHING, 0} , /* For POSIX lex compatibility. */ {"--ecs", OPT_ECS, 0} - , /* Construct equivalence classes. */ + , + {"--emit=LANG", OPT_EMIT, 0} + , /* select language to emit */ + {"-e LANG", OPT_EMIT, 0} + , {"--noecs", OPT_NO_ECS, 0} , {"-F", OPT_FAST, 0} diff --git a/src/options.h b/src/options.h index c5abbdf..0b905d5 100644 --- a/src/options.h +++ b/src/options.h @@ -57,6 +57,7 @@ enum flexopt_flag_t { OPT_DEFAULT, OPT_DONOTHING, OPT_ECS, + OPT_EMIT, OPT_FAST, OPT_FULL, OPT_HEADER_FILE, diff --git a/src/parse.y b/src/parse.y index 9cd764c..beb3b12 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3,7 +3,7 @@ %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP %token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE %token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC TOK_YYDECL TOK_PREACTION TOK_POSTACTION -%token TOK_USERINIT +%token TOK_USERINIT TOK_EMIT %token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH %token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT @@ -215,6 +215,8 @@ option : TOK_OUTFILE '=' NAME { ctrl.preaction = xstrdup(nmstr); } | TOK_POSTACTION '=' NAME { ctrl.postaction = xstrdup(nmstr); } + | TOK_EMIT '=' NAME + { ctrl.emit = xstrdup(nmstr); } | TOK_USERINIT '=' NAME { ctrl.userinit = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME diff --git a/src/regex.c b/src/regex.c index 7dc1d9f..17a7aa5 100644 --- a/src/regex.c +++ b/src/regex.c @@ -30,11 +30,10 @@ regex_t regex_linedir; /**< matches line directives */ /** Initialize the regular expressions. * @return true upon success. */ -bool flex_init_regex(void) +bool flex_init_regex(const char *traceline_re) { - ctrl.traceline_re = skel_property("M4_PROPERTY_TRACE_LINE_REGEXP"); - if (ctrl.traceline_re != NULL) - flex_regcomp(®ex_linedir, ctrl.traceline_re, REG_EXTENDED); + if (traceline_re != NULL) + flex_regcomp(®ex_linedir, traceline_re, REG_EXTENDED); return true; } diff --git a/src/scan.l b/src/scan.l index 08a4842..67d8466 100644 --- a/src/scan.l +++ b/src/scan.l @@ -449,6 +449,7 @@ M4QEND "]""]" yyget_lloc ctrl.no_yyget_lloc = ! option_sense; yyset_lloc ctrl.no_yyset_lloc = ! option_sense; + emit return TOK_EMIT; extra-type return TOK_EXTRA_TYPE; outfile return TOK_OUTFILE; prefix return TOK_PREFIX; diff --git a/src/skeletons.c b/src/skeletons.c index 76989d5..9015e66 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -42,6 +42,11 @@ const char *cpp_skel[] = { 0, }; +//const char *go_skel[] = { +//#include "go-skel.h" +// 0, +//}; + /* END digested skeletons */ /* Method table describing a language-specific back end. @@ -53,36 +58,24 @@ struct flex_backend_t { const char **skel; // Digested skeleton file }; -static struct flex_backend_t cpp_backend = { - .skel = cpp_skel, +static struct flex_backend_t backends[] = { + {.skel=cpp_skel}, + //{.skel=go_skel}, + {NULL} }; -static struct flex_backend_t * backend = &cpp_backend; +static struct flex_backend_t *backend = &backends[0]; /* Functions for querying skeleton properties. */ bool is_default_backend(void) { - return backend == &cpp_backend; -} - -const char *suffix (void) -{ - char *suffix; - - if (ctrl.C_plus_plus) - suffix = "cc"; - else - suffix = "c"; - - /* Someday this will search the selected skeketon for a suffix */ - - return suffix; + return backend == &backends[0]; } /* Search for a string in the skeleton prolog, where macros are defined. */ -bool boneseeker(const char *bone) +static bool boneseeker(const char *bone) { int i; @@ -96,6 +89,39 @@ bool boneseeker(const char *bone) return false; } +void backend_by_name(const char *name) +{ + if (name != NULL) { + for (backend = &backends[0]; backend->skel != NULL; backend++) { + if (strcasecmp(skel_property("M4_PROPERTY_BACKEND_NAME"), name) == 0) + goto backend_ok; + } + flexerror(_("no such back end")); + } + backend_ok: + ctrl.backend_name = xstrdup(skel_property("M4_PROPERTY_BACKEND_NAME")); + ctrl.traceline_re = xstrdup(skel_property("M4_PROPERTY_TRACE_LINE_REGEXP")); + ctrl.traceline_template = xstrdup(skel_property("M4_PROPERTY_TRACE_LINE_TEMPLATE")); + ctrl.have_state_entry_format = boneseeker("m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]]"); + flex_init_regex(ctrl.traceline_re); +} + +const char *suffix (void) +{ + const char *suffix; + + if (is_default_backend()) { + if (ctrl.C_plus_plus) + suffix = "cc"; + else + suffix = "c"; + } else { + suffix = skel_property("M4_PROPERTY_SOURCE_SUFFIX"); + } + + return suffix; +} + /* Search for a m4 define of the property key, retrieve the value. The * definition must be single-line. Don't call this a second time before * stashing away the previous return, we cheat with static buffers. -- cgit v1.2.1 From 978a4a3a632bb399bb01ceca3007419ce512dc29 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 06:28:49 -0400 Subject: Begin work on a C99 front end. The idea behind this is to exploit the existing test suite - write a stripped-down, cleaned up C skeleton that only does reentrant scanners and tosses out features like loadable tables and header generation that can't be ported to other languages. The C99 skeleton can then serve both as a launch point for the Go back end and a model for back ends in procedural languages without OO. The initial version is identical to the cpp skeleton except for different name and suffix properties abd having M4_MODE_C_OLY forcrd on. The latter means it blows up on the C++ tests. --- src/.gitignore | 1 + src/Makefile.am | 8 +- src/c99-flex.skl | 4314 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/skeletons.c | 10 +- 4 files changed, 4327 insertions(+), 6 deletions(-) create mode 100644 src/c99-flex.skl diff --git a/src/.gitignore b/src/.gitignore index 5e792d7..7cf38a7 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -9,5 +9,6 @@ parse.c parse.h scan.c cpp-skel.h +c99-skel.h stage1scan.[cl] stage1flex diff --git a/src/Makefile.am b/src/Makefile.am index 6a922e6..2b0acd1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,8 @@ COMMON_SOURCES = \ buf.c \ ccl.c \ skeletons.c \ - cpp_skel.h \ + cpp-skel.h \ + c99-skel.h \ dfa.c \ ecs.c \ filter.c \ @@ -90,6 +91,7 @@ include_HEADERS = \ EXTRA_DIST = \ cpp-flex.skl \ + c99-flex.skl \ mkskel.sh \ gettext.h @@ -101,6 +103,10 @@ cpp-skel.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_share $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp mv -f $@.tmp $@ +c99-skel.h: c99-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c + $(SHELL) $(srcdir)/mkskel.sh c99 $(srcdir) $(m4) $(VERSION) > $@.tmp + mv -f $@.tmp $@ + if ENABLE_BOOTSTRAP stage1scan.c: scan.l stage1flex$(EXEEXT) ./stage1flex$(EXEEXT) $(AM_LFLAGS) $(LFLAGS) -o $@ $(srcdir)/scan.l diff --git a/src/c99-flex.skl b/src/c99-flex.skl new file mode 100644 index 0000000..5a1f119 --- /dev/null +++ b/src/c99-flex.skl @@ -0,0 +1,4314 @@ +%# -*-C-*- vi: set ft=c: +%# This file is processed in several stages. +%# Here are the stages, as best as I can describe: +%# +%# 1. This is processed through GNU m4 during the +%# pre-compilation stage of flex. Only macros starting +%# with `m4preproc_' are processed, and quoting is normal. +%# +%# 2. The preprocessed skeleton is translated into a comma-separated +%# list of doublequoted strings which is stuffed into a language- +%# specific method block compiled into the flex binary. The %# comment +%# lines are removed. +%# +%# 3. At runtime, the skeleton is generated and filtered (again) +%# through m4. Macros beginning with `m4_' will be processed. +%# The quoting is "[[" and "]]" so we don't interfere with +%# user code. +%# +%# All generated macros for the m4 stage contain the text "m4" or "M4" +%# in them. This is to distinguish them from CPP macros. +%# The exception to this rule is YY_G, which is an m4 macro, +%# but it needs to be remain short because it is used everywhere. +%# +%# The m4 macros complicate reading this code enough that being +%# prescriptive about whitespace and braces is more than usually +%# important. So please set your C style to K&R, aka 1TBS with +%# tabs when editing this file. Braces around single-statement +%# if/while/for/do/switch/break bodies are mandatory. +%# + +%# Macros for preproc stage. +m4preproc_changecom + +%# Macros for runtime processing stage. +m4_changecom +m4_changequote +m4_changequote([[, ]]) + +%# +%# Lines in this skeleton starting with a "%" character are "control lines" +%# and affect the generation of the scanner. The possible control codes are +%# listed and processed in misc.c. +%# +%# %# - A comment. The current line is omitted from the generated scanner. +%# %% - A stop-point, where code is inserted by flex. +%# Each stop-point is numbered here and also in the code generator. +%# (See gen.c, etc. for details.) +%# +%# Stop points will be inserted into the generated scanner as a comment. +%# This is to aid those who edit the skeleton. +%# + +%# Properties not used in the skeleton - meant to be read by the Flex code +m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C99]]) +m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]]) +m4_define([[M4_MODE_C_ONLY]], [[]]) +m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) +m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) + +%# Macro hooks used by Flex code generators start here +m4_define([[M4_HOOK_INT32]], [[flex_int32_t]]) +m4_define([[M4_HOOK_INT16]], [[flex_int16_t]]) +m4_define([[M4_HOOK_COMMENT_OPEN]], [[/*]]) +m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) +%# If this is not defined, no trace lines will be generated. +m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" +]]) +m4_define([[M4_HOOK_TABLE_OPENER]], [[{]]) +m4_define([[M4_HOOK_TABLE_CONTINUE]], [[},]]) +m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) +m4_define([[M4_HOOK_RELATIVIZE]], [[$1]]) +m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], +]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); +]]) +m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 +]]) +m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 +]]) +m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1 +]]) +m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 +]]) +m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 +]]) +m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 +]]) + +%% [0.0] Make hook macros available to Flex + +m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl +#ifndef M4_MODE_PREFIX[[HEADER_H]] +#define M4_MODE_PREFIX[[HEADER_H]] +#define M4_MODE_PREFIX[[IN_HEADER]] 1 + +]]) +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +m4_ifelse(M4_MODE_PREFIX,yy,, +#define yy_create_buffer M4_MODE_PREFIX[[_create_buffer]] +#define yy_delete_buffer M4_MODE_PREFIX[[_delete_buffer]] +#define yy_scan_buffer M4_MODE_PREFIX[[_scan_buffer]] +#define yy_scan_string M4_MODE_PREFIX[[_scan_string]] +#define yy_scan_bytes M4_MODE_PREFIX[[_scan_bytes]] +#define yy_init_buffer M4_MODE_PREFIX[[_init_buffer]] +#define yy_flush_buffer M4_MODE_PREFIX[[_flush_buffer]] +#define yy_load_buffer_state M4_MODE_PREFIX[[_load_buffer_state]] +#define yy_switch_to_buffer M4_MODE_PREFIX[[_switch_to_buffer]] +#define yypush_buffer_state M4_MODE_PREFIX[[push_buffer_state]] +#define yypop_buffer_state M4_MODE_PREFIX[[pop_buffer_state]] +#define yyensure_buffer_stack M4_MODE_PREFIX[[ensure_buffer_stack]] +#define yy_flex_debug M4_MODE_PREFIX[[_flex_debug]] +#define yyin M4_MODE_PREFIX[[in]] +#define yyleng M4_MODE_PREFIX[[leng]] +#define yylex M4_MODE_PREFIX[[lex]] +#define yylineno M4_MODE_PREFIX[[lineno]] +#define yyout M4_MODE_PREFIX[[out]] +#define yyrestart M4_MODE_PREFIX[[restart]] +#define yytext M4_MODE_PREFIX[[text]] +#define yywrap M4_MODE_PREFIX[[wrap]] +#define yyalloc M4_MODE_PREFIX[[alloc]] +#define yyrealloc M4_MODE_PREFIX[[realloc]] +#define yyfree M4_MODE_PREFIX[[free]] +#define yyread M4_MODE_PREFIX[[read]] +) +]]) +]]) +]]) +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION +#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION +#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +%# Some negated symbols +m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) +m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) + +%# This is the m4 way to say "(stack_used || is_reentrant)" +m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) +m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) + +%# Prefixes. +%# The complexity here is necessary so that m4 preserves +%# the argument lists to each C function. + + +m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) + +m4preproc_define(`M4_GEN_PREFIX',`` +[[#ifdef yy$1 +#define ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED +#else +#define yy$1 ]]M4_MODE_PREFIX[[$1 +#endif]] +'m4preproc_divert(1)` +[[#ifndef ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED +#undef yy$1 +#endif]]'m4preproc_divert(0)') + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer M4_MODE_PREFIX[[FlexLexer]] +]]) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifelse(M4_MODE_PREFIX,yy,, + M4_GEN_PREFIX(`_create_buffer') + M4_GEN_PREFIX(`_delete_buffer') + M4_GEN_PREFIX(`_scan_buffer') + M4_GEN_PREFIX(`_scan_string') + M4_GEN_PREFIX(`_scan_bytes') + M4_GEN_PREFIX(`_init_buffer') + M4_GEN_PREFIX(`_flush_buffer') + M4_GEN_PREFIX(`_load_buffer_state') + M4_GEN_PREFIX(`_switch_to_buffer') + M4_GEN_PREFIX(`push_buffer_state') + M4_GEN_PREFIX(`pop_buffer_state') + M4_GEN_PREFIX(`ensure_buffer_stack') + M4_GEN_PREFIX(`lex') + M4_GEN_PREFIX(`restart') + M4_GEN_PREFIX(`lex_init') + M4_GEN_PREFIX(`lex_init_extra') + M4_GEN_PREFIX(`lex_destroy') + M4_GEN_PREFIX(`get_debug') + M4_GEN_PREFIX(`set_debug') + M4_GEN_PREFIX(`get_extra') + M4_GEN_PREFIX(`set_extra') + M4_GEN_PREFIX(`get_in') + M4_GEN_PREFIX(`set_in') + M4_GEN_PREFIX(`get_out') + M4_GEN_PREFIX(`set_out') + M4_GEN_PREFIX(`get_leng') + M4_GEN_PREFIX(`get_text') + M4_GEN_PREFIX(`get_lineno') + M4_GEN_PREFIX(`set_lineno') + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + M4_GEN_PREFIX(`get_column') + M4_GEN_PREFIX(`set_column') + ]]) + M4_GEN_PREFIX(`wrap') +) +]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + M4_GEN_PREFIX(`get_lval') + M4_GEN_PREFIX(`set_lval') +]]) + +m4_ifdef( [[]], +[[ + M4_GEN_PREFIX(`get_lloc') + M4_GEN_PREFIX(`set_lloc') +]]) + + +m4_ifelse(M4_MODE_PREFIX,yy,, + M4_GEN_PREFIX(`alloc') + M4_GEN_PREFIX(`realloc') + M4_GEN_PREFIX(`free') +) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifelse(M4_MODE_PREFIX,yy,, +m4_ifdef( [[M4_YY_NOT_REENTRANT]], +[[ + M4_GEN_PREFIX(`text') + M4_GEN_PREFIX(`leng') + M4_GEN_PREFIX(`in') + M4_GEN_PREFIX(`out') + M4_GEN_PREFIX(`_flex_debug') + M4_GEN_PREFIX(`lineno') +]]) +) +]]) + + +m4_ifdef( [[M4_MODE_TABLESEXT]], +[[ + M4_GEN_PREFIX(`tables_fload') + M4_GEN_PREFIX(`tables_destroy') + M4_GEN_PREFIX(`TABLES_NAME') +]]) + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , +[[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , +[[/* Feature test macros. Flex uses functions that require a minimum set of + * macros defined. As defining some macros may hide function declarations that + * user code might use, be conservative and respect user's definitions as much + * as possible. In glibc, feature test macros may not be all set up until one + * of the libc header (that includes ) is included. This creates + * a circular dependency when we check the macros. is the safest + * header we can include and does not declare too many functions we don't need. + */ +#if !defined(__GNU_LIBRARY__) && defined(__STDC__) +#include +#endif +#if !(defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_POSIX_SOURCE)) +# define _POSIX_C_SOURCE 1 /* Required for fileno() */ +# define _POSIX_SOURCE 1 +#endif]])]]) +#include +#include +#include +#include +]]) + +m4_ifdef([[M4_MODE_TABLESEXT]], [[ +#include +#include +]]) +/* end standard C headers. */ + +/* begin standard C++ headers. */ +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +#include +#include +#include +#include +#include +/* end standard C++ headers. */ +]]) + +m4preproc_include(`flexint_shared.h') + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +/* Returned upon end-of-file. */ +#define YY_NULL 0 +]]) + +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) +]]) + + + +m4_ifdef([[M4_YY_REENTRANT]], [[ + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +%# Declare yyguts variable +m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]]) +%# Perform a noop access on yyguts to prevent unused variable complains +m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[(void)yyg]]) +%# For use wherever a Global is accessed or assigned. +m4_define( [[YY_G]], [[yyg->$1]]) + +%# For use in function prototypes to append the additional argument. +m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]]) +m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]]) + +m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]]) +m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]]) +m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]]) + +%# For use in function calls to pass the additional argument. +m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]]) +m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]]) + +%# For use in function documentation to adjust for additional argument. +m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin YY_G(yyin_r) +#define yyout YY_G(yyout_r) +#define yyextra YY_G(yyextra_r) +#define yyleng YY_G(yyleng_r) +#define yytext YY_G(yytext_r) +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug YY_G(yy_flex_debug_r) + +m4_define( [[M4_YY_INCR_LINENO]], +[[ + do{ yylineno++; + yycolumn=0; + }while(0) +]]) + +]]) + + + +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ + +m4_define( [[M4_YY_INCR_LINENO]], +[[ + yylineno++; +]]) + +%# Define these macros to be no-ops. +m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]]) +m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[m4_dnl]]) +m4_define( [[YY_G]], [[($1)]]) +m4_define( [[M4_YY_PROTO_LAST_ARG]]) +m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]]) +m4_define( [[M4_YY_DEF_LAST_ARG]]) + +m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]]) +m4_define([[M4_YY_DECL_LAST_ARG]]) +m4_define([[M4_YY_CALL_LAST_ARG]]) +m4_define([[M4_YY_CALL_ONLY_ARG]]) +m4_define( [[M4_YY_DOC_PARAM]], ) + +]]) + + +%# Generate C99 function defs. +m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]]) +m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]]) +m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define yybegin(s) YY_G(yy_start) = 1 + 2 * (s) +/* Legacy interface */ +#define BEGIN YY_G(yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define yystart() ((YY_G(yy_start) - 1) / 2) +/* Legacy interfaces */ +#define YY_START ((YY_G(yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG ) +#define YY_END_OF_BUFFER_CHAR 0 +]]) + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) +]]) + + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *yybuffer; +/* Legacy interface */ +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +extern int yyleng; +]]) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +extern FILE *yyin, *yyout; +]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + m4_ifdef( [[M4_MODE_YYLINENO]], + [[ + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl ) { \ + if ( yytext[yyl] == '\n' ) { \ + --yylineno;\ + } \ + } \ + }while(0) + #define YY_LINENO_REWIND_TO(dst) \ + do {\ + const char *p;\ + for ( p = yy_cp-1; p >= (dst); --p) { \ + if ( *p == '\n' ) { \ + --yylineno;\ + } \ + } \ + }while(0) + ]], + [[ + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + ]]) +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = YY_G(yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define yyunput(c) yyunput_r( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) +/* Legacy interface */ +#define unput(c) yyunput_r( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) +]]) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { +m4_ifdef([[M4_MODE_C_ONLY]], [[ + FILE *yy_input_file; +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + std::streambuf* yy_input_file; +]]) + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 +]]) + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static yybuffer * yy_buffer_stack = NULL; /**< Stack as an array. */ +]]) +]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define yy_current_buffer() ( YY_G(yy_buffer_stack) \ + ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ + : NULL) +/* Legacy interface */ +#define YY_CURRENT_BUFFER yy_current_buffer() +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] +]]) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition + +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; +]]) +]]) + +void yyrestart ( FILE *input_file M4_YY_PROTO_LAST_ARG ); +void yy_switch_to_buffer ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); +yybuffer yy_create_buffer ( FILE *file, int size M4_YY_PROTO_LAST_ARG ); +void yy_delete_buffer ( yybuffer b M4_YY_PROTO_LAST_ARG ); +void yy_flush_buffer ( yybuffer b M4_YY_PROTO_LAST_ARG ); +void yypush_buffer_state ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); +void yypop_buffer_state ( M4_YY_PROTO_ONLY_ARG ); + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +static void yyensure_buffer_stack ( M4_YY_PROTO_ONLY_ARG ); +static void yy_load_buffer_state ( M4_YY_PROTO_ONLY_ARG ); +static void yy_init_buffer ( yybuffer b, FILE *file M4_YY_PROTO_LAST_ARG ); +#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG) +#define YY_FLUSH_BUFFER yy_flush_current_buffer() +]]) + +yybuffer yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); +yybuffer yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); +yybuffer yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); + +]]) + +void *yyalloc ( yy_size_t M4_YY_PROTO_LAST_ARG ); +void *yyrealloc ( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); +void yyfree ( void * M4_YY_PROTO_LAST_ARG ); + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) { \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ +} +#define yy_set_bol(at_bol) \ + { \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ +} +#define yy_at_bol() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +/* Legacy interface */ +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +]]) + +/* Begin user sect3 */ + +m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_REENTRANT]], [[ +#define M4_MODE_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) +]]) +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +#define M4_MODE_PREFIX[[wrap]]() (/*CONSTCOND*/1) +]])m4_dnl +]]) +#define YY_SKIP_YYWRAP +]]) +m4_ifdef( [[M4_MODE_DEBUG]], [[ +#define FLEX_DEBUG +]]) +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl +typedef flex_uint8_t YY_CHAR; +]])m4_dnl +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_define([[M4_TMP_STDINIT]], [[FILE *yyin = stdin, *yyout = stdout;]]) +m4_define([[M4_TMP_NO_STDINIT]], [[FILE *yyin = NULL, *yyout = NULL;]]) +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ +m4_ifdef( [[M4_MODE_DO_STDINIT]], [[m4_dnl +m4_ifdef([[M4_YY_REENTRANT]], [[ +#ifdef VMS +#ifdef __VMS_POSIX +#define YY_STDINIT +#endif +#else +#define YY_STDINIT +#endif +]]) +#ifdef VMS"); +#ifndef __VMS_POSIX +M4_TMP_NO_STDINIT +#else +M4_TMP_STDINIT +#endif +#else +M4_TMP_STDINIT +#endif +]]) +m4_ifdef( [[M4_MODE_NO_DO_STDINIT]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +M4_TMP_NO_STDINIT +]]) +]]) +]]) +m4_undefine([[M4_TMP_STDINIT]]) +m4_undefine([[M4_TMP_NO_STDINIT]]) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +#define yytext_ptr yytext +m4_ifdef( [[M4_MODE_INTERACTIVE]], [[#define YY_INTERACTIVE]]) +]]) +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl +m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl +typedef const struct yy_trans_info *yy_state_type; +]], [[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +typedef int yy_state_type; +]]) +]]) +]]) +m4_ifdef([[M4_MODE_LEX_COMPAT]], [[#define YY_FLEX_LEX_COMPAT]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +extern int yylineno; +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +int yylineno = 1; +]]) +]]) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + +#include +m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ +int yyFlexLexer::yywrap() { return 1;} +]]) +m4_ifdef([[M4_MODE_YYCLASS]], [[ +int yyFlexLexer::yylex() + { + LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); + return 0; + } + +#define YY_DECL int M4_YY_CLASS_NAME::yylex() +]]) +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ +/* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[extern char yytext[];]]) +]]) +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_YY_REENTRANT]], [[#define yytext_ptr yytext_r]],[[ +extern char *yytext; + +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext +]]) +]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +%% [1.5] DFA +]]) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG); +static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); +static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); +]]) + +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ +struct yy_trans_info + { + /* We require that yy_verify and yy_nxt must be of the same size int. */ +m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ + YY_OFFSET_TYPE yy_verify; + + /* In cases where its sister yy_verify *is* a "yes, there is + * a transition", yy_nxt is the offset (in records) to the + * next state. In most cases where there is no transition, + * the value of yy_nxt is irrelevant. If yy_nxt is the -1th + * record of a state, though, then yy_nxt is the action number + * for that state. + */ + YY_OFFSET_TYPE yy_nxt; +]]) +m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ + /* We generate a bogus 'struct yy_trans_info' data type + * so we can guarantee that it is always declared in the skel. + * This is so we can compile "sizeof(struct yy_trans_info)" + * in any scanner. + */ + flex_int32_t yy_verify; + flex_int32_t yy_nxt; +]]) + }; +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + YY_G(yytext_ptr) = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[YY_G(yytext_ptr) -= YY_G(yy_more_len); + yyleng = (int) (yy_cp - YY_G(yytext_ptr));]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ + YY_G(yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyleng >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyleng += YY_G(yy_more_offset);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[YY_G(yy_prev_more_offset) = YY_G(yy_more_offset);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[YY_G(yy_more_offset) = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG);]]) \ +]]) \ + YY_G(yy_c_buf_p) = yy_cp; + +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ +m4_ifdef( [[M4_MODE_C_ONLY]], +[[ +extern int yy_flex_debug; +int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); +]]) +]]) + +%% [2.0] data tables for the DFA are inserted here +m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = + { +M4_HOOK_NXT_BODY +]], [[ +#undef YY_NXT_LOLEN +#define YY_NXT_LOLEN ([[]]M4_HOOK_NXT_ROWS[[]]) +static const M4_HOOK_NXT_TYPE *yy_nxt =0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl +/* Table of booleans, true if rule could match eol. */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, +M4_HOOK_EOLTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_NEED_ACCEPT]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, +M4_HOOK_ACCEPT_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_ACCEPT_TYPE * yy_accept = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl +/* Character equivalence-class mapping */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, +M4_HOOK_ECSTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const YY_CHAR * yy_ec = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl +/* Character meta-equivalence-class mappings */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, +M4_HOOK_MECSTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const YY_CHAR * yy_meta = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl +/* The transition table */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = { +M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const struct yy_trans_info *yy_transition = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl +/* Table of pointers to start states. */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { +M4_HOOK_STARTTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const struct yy_trans_info **yy_start_state_list =0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, +M4_HOOK_ACCLIST_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_ACCLIST_TYPE * yy_acclist = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_BASE_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, +M4_HOOK_BASE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_BASE_TYPE * yy_base = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_DEF_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, +M4_HOOK_DEF_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_DEF_TYPE * yy_def = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_YYNXT_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, +M4_HOOK_YYNXT_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_YYNXT_TYPE * yy_nxt = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_CHK_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, +M4_HOOK_CHK_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_CHK_TYPE * yy_chk = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const yy_state_type yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, +M4_HOOK_NULTRANS_BODY[[]]m4_dnl +}; +]], [[ +static const yy_state_type * yy_NUL_trans = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl +/* Rule to line-number mapping */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, +M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; +]]) + +]]) + +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +/* Definitions for backing up. We don't need them if yyreject() + * is being used because then we use an alternative backing-up + * technique instead. + */ +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +]]) +]]) +]]) + +m4_ifdef( [[M4_MODE_USES_REJECT]],[[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +/* Declare state buffer variables. */ +static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; +static char *yy_full_match; +static int yy_lp; +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ +static int yy_looking_for_trail_begin = 0; +static int yy_full_lp; +static int *yy_full_state; +%# These must match the values in the file flexdef.h +%# of the flex source code, otherwise havoc will ensue. +#define YY_TRAILING_MASK 0x2000 +#define YY_TRAILING_HEAD_MASK 0x4000 +]]) +]]) +]]) +#define yyreject() \ +{ \ +*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \ +yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ +YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \ +YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \ +yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \ +]]) \ +++YY_G(yy_lp); \ +goto find_rule; \ +} +#define REJECT yyreject() +]]) +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +/* The intent behind this definition is that it'll catch + * any uses of yyreject() which flex missed. + */ +#define yyreject() reject_used_but_not_detected +#define REJECT reject_used_but_not_detected +]]) + +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +static int yy_more_offset = 0; +static int yy_prev_more_offset = 0; +]]) +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +static int yy_more_flag = 0; +static int yy_more_len = 0; +]]) +]]) +]]) +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext M4_YY_CALL_LAST_ARG)) +#define YY_NEED_STRLEN +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET \ +{ \ +YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \ +yyleng -= YY_G(yy_more_offset); \ +} +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +#define yymore() (YY_G(yy_more_flag) = 1) +#define YY_MORE_ADJ YY_G(yy_more_len) +#define YY_RESTORE_YY_MORE_OFFSET +]]) +]]) + +m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +]]) + +m4_ifdef( [[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +#ifndef YYLMAX +#define YYLMAX 8192 +#endif + +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +char yytext[YYLMAX]; +char *yytext_ptr; +]]) +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ +char *yytext; +]]) +]]) +]]) + +%% [3.0] static declarations conditional on mode switches go here +]]) + +m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) +M4_YY_SC_DEFS +m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) + +m4_ifdef( [[M4_YY_NO_UNISTD_H]],, +[[ +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +#include +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +#include +]]) +#endif +]]) + +m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], +[[ +#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS +]], +[[ +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif +]] +) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Reentrant structure and macros (non-C++). +m4_ifdef([[M4_YY_REENTRANT]], [[ + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t { + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + yybuffer * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; + + /* These are only needed for trailing context rules, + * but there's no conditional variable for that yet. */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; +]]) +m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], [[ + char yytext_r[YYLMAX]; + char *yytext_ptr; + int yy_more_offset; + int yy_prev_more_offset; +]], [[ + char *yytext_r; + int yy_more_flag; + int yy_more_len; +]]) +m4_ifdef( [[M4_YY_BISON_LVAL]], [[ + YYSTYPE * yylval_r; +]]) + +m4_ifdef( [[]], [[ + YYLTYPE * yylloc_r; +]]) +}; /* end struct yyguts_t */ +]]) + + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +static int yy_init_globals ( M4_YY_PROTO_ONLY_ARG ); +]]) +]]) + +m4_ifdef([[M4_YY_REENTRANT]], [[ + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ + m4_ifdef( [[M4_YY_BISON_LVAL]], + [[ + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval YY_G(yylval_r) + ]]) + + m4_ifdef( [[]], + [[ + # define yylloc YY_G(yylloc_r) + ]]) +]]) + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +]]) + +]]) + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +m4_ifdef( [[M4_YY_NO_DESTROY]],, +[[ +int yylex_destroy ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +[[ +int yyget_debug ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +[[ +void yyset_debug ( int debug_flag M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, +[[ +YY_EXTRA_TYPE yyget_extra ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +[[ +void yyset_extra ( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_IN]],, +[[ +FILE *yyget_in ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_IN]],, +[[ +void yyset_in ( FILE * _in_str M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_OUT]],, +[[ +FILE *yyget_out ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_OUT]],, +[[ +void yyset_out ( FILE * _out_str M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_LENG]],, +[[ + int yyget_leng ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +[[ +char *yyget_text ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_GET_LINENO]],, +[[ +int yyget_lineno ( M4_YY_PROTO_ONLY_ARG ); +]]) + +m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +[[ +void yyset_lineno ( int _line_number M4_YY_PROTO_LAST_ARG ); +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +[[ +int yyget_column ( M4_YY_PROTO_ONLY_ARG ); +]]) +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +[[ +void yyset_column ( int _column_no M4_YY_PROTO_LAST_ARG ); +]]) +]]) + +m4_ifdef([[M4_YY_BISON_LVAL]], [[ +m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +[[ +YYSTYPE * yyget_lval ( M4_YY_PROTO_ONLY_ARG ); +]]) + +void yyset_lval ( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG ); + +m4_ifdef( [[]], +[[ + m4_ifdef( [[M4_YY_NO_GET_LLOC]],, + [[ + YYLTYPE *yyget_lloc ( M4_YY_PROTO_ONLY_ARG ); + ]]) + + m4_ifdef( [[M4_YY_NO_SET_LLOC]],, + [[ + void yyset_lloc ( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); + ]]) +]]) +]]) + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( M4_YY_PROTO_ONLY_ARG ); +#else +extern int yywrap ( M4_YY_PROTO_ONLY_ARG ); +#endif +#endif + +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +#ifndef YY_NO_YYUNPUT + m4_ifdef( [[M4_YY_NO_YYUNPUT]],, + [[ + static void yyunput_r ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); + ]]) +#endif +]]) +]]) + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); +#endif + +m4_ifdef([[M4_MODE_NO_YYINPUT]], [[#define YY_NO_YYINPUT 1]]) + +#ifndef YY_NO_YYINPUT +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +static int yyinput ( M4_YY_PROTO_ONLY_ARG ); +#ifndef __cplusplus +#define input yyinput +#endif +]]) +]]) +#endif + + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# TODO: This is messy. +m4_ifdef( [[M4_YY_STACK_USED]], +[[ + +m4_ifdef( [[M4_YY_NOT_REENTRANT]], +[[ + m4_ifdef( [[M4_YY_NOT_IN_HEADER]], + [[ + static int yy_start_stack_ptr = 0; + static int yy_start_stack_depth = 0; + static int *yy_start_stack = NULL; + ]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ + m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, + [[ + static void yy_push_state ( int _new_state M4_YY_PROTO_LAST_ARG); + ]]) + m4_ifdef( [[M4_YY_NO_POP_STATE]],, + [[ + static void yy_pop_state ( M4_YY_PROTO_ONLY_ARG ); + ]]) + m4_ifdef( [[M4_YY_NO_TOP_STATE]],, + [[ + static int yy_top_state ( M4_YY_PROTO_ONLY_ARG ); + ]]) +]]) + +]], +[[ +m4_define( [[M4_YY_NO_PUSH_STATE]]) +m4_define( [[M4_YY_NO_POP_STATE]]) +m4_define( [[M4_YY_NO_TOP_STATE]]) +]]) +]]) + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Copy whatever the last rule matched to the standard output. */ +#ifndef yyecho +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define yyecho() do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +%# C++ definition +#define yyecho() LexerOutput( yytext, yyleng ) +]]) +#endif +/* Legacy interface */ +#define ECHO yyecho() +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::LexerError( const char* msg ) { + M4_YY_DECL_GUTS_VAR(); + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} +]]) + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +m4_ifdef([[M4_MODE_C_ONLY]], [[ +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +#define YY_FATAL_ERROR(msg) LexerError( msg ) +]]) +#endif + +/* Legacy interface */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size M4_YY_CALL_LAST_ARG);} while (0) + +m4_ifdef( [[M4_MODE_USER_YYREAD]], , [[ +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +int yyFlexLexer::yyread(char *buf, size_t max_size) { +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static int yyread(char *buf, size_t max_size M4_YY_PROTO_LAST_ARG) { +]]) + int result; + M4_YY_DECL_GUTS_VAR(); +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ + errno=0; + while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) { + if( errno != EINTR) { + YY_FATAL_ERROR( "input in flex scanner failed" ); + break; + } + errno=0; + clearerr(yyin); + } +]]) +m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) { + int c = '*'; + int n; + for ( n = 0; n < max_size && + (c = getc( yyin )) != EOF && c != '\n'; ++n ) { + buf[n] = (char) c; + } + if ( c == '\n' ) { + buf[n++] = (char) c; + } + if ( c == EOF && ferror( yyin ) ) { + YY_FATAL_ERROR( "input in flex scanner failed" ); + } + result = n; + } else { + errno=0; + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) { + if( errno != EINTR) { + YY_FATAL_ERROR( "input in flex scanner failed" ); + break; + } + errno=0; + clearerr(yyin); + } + } +]]) +]]) + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +%# C++ definition + if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) { + YY_FATAL_ERROR( "input in flex scanner failed" ); + } +]]) + return result; +} +#endif +]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif +]]) + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +m4_ifdef([[M4_MODE_TABLESEXT]], [[ +%# structures and prototypes +m4preproc_include(`tables_shared.h') + +/* Load the DFA tables from the given stream. */ +int yytables_fload (FILE * fp M4_YY_PROTO_LAST_ARG); + +/* Unload the tables from memory. */ +int yytables_destroy (M4_YY_PROTO_ONLY_ARG); +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl + +/** Describes a mapping from a serialized table id to its deserialized state in + * this scanner. This is the bridge between our "generic" deserialization code + * and the specifics of this scanner. + */ +struct yytbl_dmap { + enum yytbl_id dm_id;/**< table identifier */ + void **dm_arr; /**< address of pointer to store the deserialized table. */ + size_t dm_sz; /**< local sizeof() each element in table. */ +}; + +/** A {0,0,0}-terminated list of structs, forming the map */ +static struct yytbl_dmap yydmap[] = { +m4_ifdef([[M4_HOOK_NXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_YYNXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_YYNXT_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(M4_HOOK_EOLTABLE_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]],[[m4_dnl]]) +m4_ifdef([[M4_MODE_USEMECS]], [[ {YYTD_ID_META, (void**)&yy_meta, sizeof(YY_CHAR)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_ACCLIST_TYPE]], [[ {YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(M4_HOOK_ACCLIST_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_MKCTBL_TYPE]], [[ {YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(M4_HOOK_MKCTBL_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_MKFTBL_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_MKFTBL_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_ACCEPT_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_ACCEPT_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_BASE_TYPE]], [[ {YYTD_ID_BASE, (void**)&yy_base, sizeof(M4_HOOK_BASE_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_DEF_TYPE]], [[ {YYTD_ID_DEF, (void**)&yy_def, sizeof(M4_HOOK_DEF_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_CHK_TYPE]], [[ {YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_CHK_TYPE)},]],[[m4_dnl]]) +m4_ifdef([[M4_HOOK_NULTRANS_TYPE]], [[ {YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(M4_HOOK_NULTRANS_TYPE)},]],[[m4_dnl]]) + {0,0,0} +}; + +/** A tables-reader object to maintain some state in the read. */ +struct yytbl_reader { + FILE * fp; /**< input stream */ + flex_uint32_t bread; /**< bytes read since beginning of current tableset */ +}; + +]]) +/* end tables serialization structures and prototypes */ + +]]) + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# Standard (non-C++) definition + + +m4_define( [[M4_YY_LEX_PROTO]], [[(M4_YY_PROTO_ONLY_ARG)]]) +m4_define( [[M4_YY_LEX_DECLARATION]], [[(M4_YY_DEF_ONLY_ARG)]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + m4_dnl The bison pure parser is used. Redefine yylex to + m4_dnl accept the lval parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[YYFARGS1(YYSTYPE *,yylval_param)]]) +]]) + +m4_ifdef( [[]], +[[ + m4_dnl Locations are used. yylex should also accept the ylloc parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]]) +]]) + +extern int yylex M4_YY_LEX_PROTO; + +#define YY_DECL int yylex M4_YY_LEX_DECLARATION +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +%# C++ definition +#define YY_DECL int yyFlexLexer::yylex() +]]) +#endif /* !YY_DECL */ + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#define YY_RULE_SETUP \ + m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) { \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ + } \ +]]) YY_USER_ACTION +]]) + +%# Code snippets used in various cases of code generation in the main scanner. + +m4_define([[M4_GEN_BACKING_UP]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + /* Generate code to keep backing-up information. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ + if ( yy_current_state[-1].yy_nxt ) { +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + if ( yy_accept[yy_current_state] ) { +]]) + YY_G(yy_last_accepting_state) = yy_current_state; + YY_G(yy_last_accepting_cpos) = yy_cp; + } +]]) +]]) +]]) + +%# yy_c was formerly YY_CHAR, changed to int because table can now +%# have up to 0x101 entries, since we no longer generate a separate +%# NUL table. +%# +%# Note: on x86-64 architecture with gcc -O2, we save an instruction +%# in the main loop, since the character can now be zero-extended in +%# the process of retrieving it from the input stream or the yy_ec[] +%# or yy_meta[] arrays, whereas previously it was zero-extended by a +%# register-to-register move just prior to the yy_chk[] table lookup +m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ + int yy_c = $1; + /* Save the backing-up info \before/ computing the next state + * because we always compute one more state than needed - we + * always proceed until we reach a jam state + */ + M4_GEN_BACKING_UP + + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { + yy_current_state = (int) yy_def[yy_current_state]; + +m4_ifdef([[M4_MODE_USEMECS]], [[ + /* We've arranged it so that templates are never chained + * to one another. This means we can afford to make a + * very simple test to see if we need to convert to + * yy_c's meta-equivalence class without worrying + * about erroneously looking up the meta-equivalence + * class twice + */ + + /* lastdfa + 2 == YY_JAMSTATE + 1 is the beginning of the templates */ + if (yy_current_state >= YY_JAMSTATE + 1) { + yy_c = yy_meta[yy_c]; + } +]]) + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; +]]) + +m4_define([[M4_GEN_START_STATE]], [[ + /* Generate the code to find the start state. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + yy_at_bol()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[YY_G(yy_start)];]]) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + yy_current_state = YY_G(yy_start); +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yy_at_bol();]]) + /* Set up for storing up states. */ + m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + YY_G(yy_state_ptr) = YY_G(yy_state_buf); + *YY_G(yy_state_ptr)++ = yy_current_state; +]]) +]]) +]]) + +m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ + { + const struct yy_trans_info *yy_trans_info; + YY_CHAR yy_c; + + for ( yy_c = $1; + (yy_trans_info = &yy_current_state[yy_c])->yy_verify == yy_c; + yy_c = $2 ) + { + yy_current_state += yy_trans_info->yy_nxt; + + M4_GEN_BACKING_UP + } + } +]]) + +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +/** The main scanner function which does all the work. + */ +YY_DECL { + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + M4_YY_DECL_GUTS_VAR(); + +m4_ifdef( [[M4_YY_NOT_REENTRANT]], +[[ + m4_ifdef( [[M4_YY_BISON_LVAL]], + [[ + YYSTYPE * yylval; + ]]) + m4_ifdef( [[]], + [[ + YYLTYPE * yylloc; + ]]) +]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + yylval = yylval_param; +]]) + +m4_ifdef( [[]], +[[ + yylloc = yylloc_param; +]]) + + if ( !YY_G(yy_init) ) { + YY_G(yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + /* Create the reject buffer large enough to save one state per allowed character. */ + if ( ! YY_G(yy_state_buf) ) { + YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); + } + if ( ! YY_G(yy_state_buf) ) { + YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); + } +]]) + + if ( ! YY_G(yy_start) ) { + YY_G(yy_start) = 1; /* first start state */ + } + if ( ! yyin ) { +m4_ifdef([[M4_MODE_C_ONLY]], [[ + yyin = stdin; +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + yyin.rdbuf(std::cin.rdbuf()); +]]) + } + if ( ! yyout ) { +m4_ifdef([[M4_MODE_C_ONLY]], [[ + yyout = stdout; +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + yyout.rdbuf(std::cout.rdbuf()); +]]) + } + if ( yy_current_buffer() == NULL ) { + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + } + + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + } + + /* open scope of user declarationns */ + { +%% [4.0] user's declarations go here + + while ( /*CONSTCOND*/1 ) { /* loops until end-of-file is reached */ +m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ + YY_G(yy_more_len) = 0; + if ( YY_G(yy_more_flag) ) { + YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); + YY_G(yy_more_flag) = 0; + } +]]) +]]) + yy_cp = YY_G(yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = YY_G(yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + +M4_GEN_START_STATE + + yy_match: + /* Generate the code to find the next match. */ +%# Conditional indirection through an equivalence map +m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) +m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) + +m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl +m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl + while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { +]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ + while ((yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { +]]) +M4_GEN_BACKING_UP + yy_cp++; + } + yy_current_state = -yy_current_state; +]]) +m4_ifdef([[M4_MODE_FULLSPD]], [[ + M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yy_cp)), M4_EC(YY_SC_TO_UI(*++yy_cp))) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ + do { + M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) + + m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) + ++yy_cp; + + } + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yy_current_state] != YY_JAMBASE );]]) + m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yy_current_state != YY_JAMSTATE );]]) + +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ + /* Do the guaranteed-needed backing up to figure out + * the match. + */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); +]]) +]]) +]]) + + yy_find_action: + /* code to find the action number goes here */ + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ + yy_current_state = *--YY_G(yy_state_ptr); + YY_G(yy_lp) = yy_accept[yy_current_state]; +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) + for ( ; ; ) { /* loop until we find out what rule we matched */ + if (YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1]) { + yy_act = yy_acclist[YY_G(yy_lp)]; +m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || YY_G(yy_looking_for_trail_begin)) { + if (yy_act == YY_G(yy_looking_for_trail_begin)) { + YY_G(yy_looking_for_trail_begin) = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } else if (( yy_act & YY_TRAILING_MASK) != 0) { + YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; + YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; +m4_ifdef([[M4_MODE_REAL_REJECT]], [[ + /* Remember matched text in case we back up + * due to REJECT. + */ + YY_G(yy_full_match) = yy_cp; + YY_G(yy_full_state) = YY_G(yy_state_ptr); + YY_G(yy_full_lp) = YY_G(yy_lp); +]]) + } else { + YY_G(yy_full_match) = yy_cp; + YY_G(yy_full_state) = YY_G(yy_state_ptr); + YY_G(yy_full_lp) = YY_G(yy_lp); + break; + } + ++YY_G(yy_lp); + goto find_rule; +]]) +m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + /* Remember matched text in case we back up due to + * trailing context plus REJECT. + */ + YY_G(yy_full_match) = yy_cp; + break; +]]) + } + + --yy_cp; + + /* We could consolidate the following two lines with those at + * the beginning, but at the cost of complaints that we're + * branching inside a loop. + */ + yy_current_state = *--YY_G(yy_state_ptr); + YY_G(yy_lp) = yy_accept[yy_current_state]; + } /* close for */ +]]) +m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) { /* have to back up */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } +]]) + + YY_DO_BEFORE_ACTION; + +m4_ifdef( [[M4_MODE_YYLINENO]],[[ +m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], + [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], + [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { + int yyl; + for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) { + if ( yytext[yyl] == '\n' ) { + M4_YY_INCR_LINENO(); + + } + } + } +]]) + + do_action: /* This label is used only to access EOF actions. */ + +m4_ifdef([[M4_MODE_DEBUG]], [[ + if ( yy_flex_debug ) { + if ( yy_act == 0 ) { +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + std::cerr << "--scanner backing up\n"; +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ + fprintf( stderr, "--scanner backing up\n" ); +]]) + } else if ( yy_act < YY_NUM_RULES ) { +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + std::cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << + "(\"" << yytext << "\")\n"; +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ + fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", + (long)yy_rule_linenum[yy_act], yytext ); +]]) + } else if ( yy_act == YY_NUM_RULES ) { +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + std::cerr << "--accepting default rule (\"" << yytext << "\")\n"; +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yytext ); +]]) + } else if ( yy_act == YY_NUM_RULES + 1 ) { + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + std::cerr << "--(end of buffer or a NUL)\n"; +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ + fprintf( stderr, "--(end of buffer or a NUL)\n" ); +]]) + } else { +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + std::cerr << "--EOF (start condition " << YY_START << ")\n"; +]]) +m4_ifdef([[M4_MODE_C_ONLY]], [[ + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); +]]) + } + } +]]) + + switch ( yy_act ) { /* beginning of action switch */ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = YY_G(yy_hold_char); + + /* /\* Backing-up info for compressed tables is taken \after/ */ + /* * yy_cp has been incremented for the next state. */ + /* *\/ */ + yy_cp = YY_G(yy_last_accepting_cpos); + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) + + yy_current_state = YY_G(yy_last_accepting_state); + goto yy_find_action; +]]) +]]) +%% [5.0] user actions get inserted here + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = YY_G(yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer() and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; +m4_ifdef([[M4_MODE_C_ONLY]], [[ + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); +]]) + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) { /* This was really a NUL. */ + yy_state_type yy_next_state; + + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); + + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) { + /* Consume the NUL. */ + yy_cp = ++YY_G(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } else { +%# Disguised case statement on table modes + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) +m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ + /* Do the guaranteed-needed backing up to figure + * out the match. + */ + yy_cp = YY_G(yy_last_accepting_cpos); + yy_current_state = YY_G(yy_last_accepting_state); +]]) +]]) +%# Disguised case statement on table modes ends +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ + /* Still need to initialize yy_cp, though + * yy_current_state was set up by + * yy_get_previous_state(). + */ + yy_cp = YY_G(yy_c_buf_p); +]]) +]]) + goto yy_find_action; + } + } else { /* not a NUL */ + switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) { + case EOB_ACT_END_OF_FILE: + YY_G(yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } else { + if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { + YY_NEW_FILE; + } + } + break; + case EOB_ACT_CONTINUE_SCAN: + YY_G(yy_c_buf_p) = + YY_G(yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + yy_cp = YY_G(yy_c_buf_p); + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + YY_G(yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + + yy_cp = YY_G(yy_c_buf_p); + yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } /* end EOB inner switch */ + } /* end if */ + break; + } /* case YY_END_OF_BUFFER */ + default: + YY_FATAL_ERROR("fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ +]]) + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +/* The contents of this function are C++ specific, so the YY_G macro is not used. + * This constructor simply maintains backward compatibility. + * DEPRECATED + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): + yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), + yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) +{ + ctor_common(); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): + yyin(arg_yyin.rdbuf()), + yyout(arg_yyout.rdbuf()) +{ + ctor_common(); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +void yyFlexLexer::ctor_common() { + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = NULL; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; +]], +[[ + yy_state_buf = 0; +]]) +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +yyFlexLexer::~yyFlexLexer() { + delete [] yy_state_buf; + yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); + yy_delete_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG); + yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) { + // was if( new_in ) + yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); + + // was if( new_out ) + yyout.rdbuf(new_out.rdbuf()); +} + +/* The contents of this function are C++ specific, so the YY_G macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if( ! new_in ) { + new_in = &yyin; + } + + if ( ! new_out ) { + new_out = &yyout; + } + + switch_streams(*new_in, *new_out); +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin.eof() || yyin.fail() ) { + return 0; + } +#ifdef YY_INTERACTIVE + yyin.get( buf[0] ); + + if ( yyin.eof() ) { + return 0; + } + if ( yyin.bad() ) { + return -1; + } + return 1; + +#else + (void) yyin.read( buf, max_size ); + + if ( yyin.bad() ) { + return -1; + } else { + return yyin.gcount(); + } +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) { + (void) yyout.write( buf, size ); +} +]]) +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static int yy_get_next_buffer (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +int yyFlexLexer::yy_get_next_buffer() +]]) +{ + M4_YY_DECL_GUTS_VAR(); + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = YY_G(yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) { + YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); + } + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) { + *(dest++) = *(source++); + } + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; + } else { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses yyreject()" ); +]], +[[ + /* just a shorter name for the current buffer */ + yybuffer b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) { + b->yy_buf_size += b->yy_buf_size / 8; + } else { + b->yy_buf_size *= 2; + } + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); + } else { + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + } + if ( ! b->yy_ch_buf ) { + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + } + YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; +]]) + } + + if ( num_to_read > YY_READ_BUF_SIZE ) { + num_to_read = YY_READ_BUF_SIZE; + } + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + YY_G(yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + } + + if ( YY_G(yy_n_chars) == 0 ) { + if ( number_to_move == YY_MORE_ADJ ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin M4_YY_CALL_LAST_ARG); + } else { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } else { + ret_val = EOB_ACT_CONTINUE_SCAN; + } + if ((YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) { + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + YY_G(yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} +]]) + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +yy_state_type yyFlexLexer::yy_get_previous_state() +]]) +{ + yy_state_type yy_current_state; + char *yy_cp; + M4_YY_DECL_GUTS_VAR(); + + M4_GEN_START_STATE + for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) { + /* Generate the code to find the next state. */ + m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) + m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) + + m4_ifdef([[M4_MODE_NULTRANS]], [[ + /* Compressed tables back up *before* they match. */ + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) + if ( *yy_cp ) { + ]]) + + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ + m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) + ]]) + + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) + +m4_ifdef([[M4_MODE_NULTRANS]], [[ + } else { + yy_current_state = yy_NUL_trans[yy_current_state]; + } +]]) + + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) + } + + return yy_current_state; +} + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +]]) +{ + int yy_is_jam; + M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ + /* Generate code for handling NUL's, if needed. */ + + /* First, deal with backing up and setting up yy_cp if the scanner + * finds that it should JAM on the NUL. + * + * Only generate a definition for "yy_cp" if we'll generate code + * that uses it. Otherwise lint and the like complain. + */ + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = YY_G(yy_c_buf_p);]]) + +%# Note that this statement block and the following three are +%# not executed serially but are an if-then-else cascade +%# for different table modes. +m4_ifdef([[M4_MODE_NULTRANS]], [[ + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) + yy_is_jam = (yy_current_state <= 0); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ + int yy_c = YY_NUL_EC; + + const struct yy_trans_info *yy_trans_info; + + yy_trans_info = &yy_current_state[(unsigned int) yy_c]; + yy_current_state += yy_trans_info->yy_nxt; + yy_is_jam = (yy_trans_info->yy_verify != yy_c); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ +M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) +yy_is_jam = (yy_current_state == YY_JAMSTATE); +m4_ifdef([[M4_MODE_USES_REJECT]], [[ + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + if ( ! yy_is_jam ) { + *YY_G(yy_state_ptr)++ = yy_current_state; + } + ]]) +]]) +]]) +]]) +%# End of if-else cascade + +m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ + /* If we've entered an accepting state, back up; note that + * compressed tables have *already* done such backing up, so + * we needn't bother with it again. + */ + if ( ! yy_is_jam ) { + M4_GEN_BACKING_UP + } +]]) + + M4_YY_NOOP_GUTS_VAR(); + return yy_is_jam ? 0 : yy_current_state; +} + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[m4_undefine([[M4_YY_NO_YYUNPUT]])]]) +m4_ifdef( [[M4_YY_NO_YYUNPUT]], , [[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yyunput_r YYFARGS2( int,c, char *,yy_bp) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yyunput_r( int c, char* yy_bp) +]]) +{ + char *yy_cp; + M4_YY_DECL_GUTS_VAR(); + + yy_cp = YY_G(yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = YY_G(yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { + /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = YY_G(yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) { + *--dest = *--source; + } + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + YY_G(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + } + + *--yy_cp = (char) c; + +m4_ifdef( [[M4_MODE_YYLINENO]], +[[ + if ( c == '\n' ){ + --yylineno; + } +]]) + + YY_G(yytext_ptr) = yy_bp; + YY_G(yy_hold_char) = *yy_cp; + YY_G(yy_c_buf_p) = yy_cp; +} +]]) + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +#ifndef YY_NO_YYINPUT +int yyinput (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +int yyFlexLexer::yyinput() +]]) +{ + int c; + M4_YY_DECL_GUTS_VAR(); + + *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + + if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) { + /* This was really a NUL. */ + *YY_G(yy_c_buf_p) = '\0'; + } else { + /* need more input */ + int offset = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); + ++YY_G(yy_c_buf_p); + + switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin M4_YY_CALL_LAST_ARG); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) { + return 0; + } + if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { + YY_NEW_FILE; + } + return yyinput(M4_YY_CALL_ONLY_ARG); + + case EOB_ACT_CONTINUE_SCAN: + YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ + *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ + YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); + +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) { + M4_YY_INCR_LINENO(); + } +]]) +]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( c == '\n' ) { + M4_YY_INCR_LINENO(); + } + ]]) +]]) + + return c; +} +m4_ifdef([[M4_MODE_C_ONLY]], [[ +#endif /* ifndef YY_NO_YYINPUT */ +]]) + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * M4_YY_DOC_PARAM + * @note This function does not reset the start condition to @c INITIAL . + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +void yyrestart YYFARGS1( FILE *,input_file) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yyrestart( std::istream& input_file ) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + + if ( yy_current_buffer() == NULL ) { + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + } + + yy_init_buffer( yy_current_buffer(), input_file M4_YY_CALL_LAST_ARG); + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); +} + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +/** Delegate to the new version that takes an istream reference. + * @param input_file A readable stream. + * M4_YY_DOC_PARAM + * @note This function does not reset the start condition to @c INITIAL . + */ +void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + if( ! input_file ) { + input_file = &yyin; + } + yyrestart( *input_file ); +} +]]) + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * M4_YY_DOC_PARAM + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +void yy_switch_to_buffer YYFARGS1( yybuffer ,new_buffer) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_switch_to_buffer( yybuffer new_buffer ) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + if ( yy_current_buffer() == new_buffer ) { + return; + } + if ( yy_current_buffer() ) { + /* Flush out information for old buffer. */ + *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + YY_G(yy_did_buffer_switch_on_eof) = 1; +} + + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_load_buffer_state() +]]) +{ + M4_YY_DECL_GUTS_VAR(); + YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; +m4_ifdef([[M4_MODE_C_ONLY]], [[ + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); +]]) + YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * M4_YY_DOC_PARAM + * @return the allocated buffer state. + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +yybuffer yy_create_buffer YYFARGS2( FILE *,file, int ,size) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) +]]) +{ + yybuffer b; + M4_YY_DECL_GUTS_VAR(); + + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + if ( b == NULL ) { + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + } + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); + if ( b->yy_ch_buf == NULL ) { + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + } + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); + + return b; +} + +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +/** Delegate creation of buffers to the new version that takes an istream reference. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * M4_YY_DOC_PARAM + * @return the allocated buffer state. + */ +yybuffer yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + return yy_create_buffer( *file, size ); +} +]]) + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * M4_YY_DOC_PARAM + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +void yy_delete_buffer YYFARGS1( yybuffer ,b) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_delete_buffer( yybuffer b ) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + + if ( b == NULL ) { + return; + } + if ( b == yy_current_buffer() ) { /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (yybuffer) 0; + } + if ( b->yy_is_our_buffer ) { + yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); + } + yyfree( (void *) b M4_YY_CALL_LAST_ARG ); +} + + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yy_init_buffer YYFARGS2( yybuffer ,b, FILE *,file) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_init_buffer( yybuffer b, std::istream& file ) +]]) +{ + int oerrno = errno; + M4_YY_DECL_GUTS_VAR(); + + yy_flush_buffer( b M4_YY_CALL_LAST_ARG); + +m4_ifdef([[M4_MODE_C_ONLY]], [[ + b->yy_input_file = file; +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + b->yy_input_file = file.rdbuf(); +]]) + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != yy_current_buffer()) { + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], +[[ + b->yy_is_interactive = 1; +]], +[[ + m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], + [[ + b->yy_is_interactive = 0; + ]], + [[ + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + ]]) +]]) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ + b->yy_is_interactive = 0; +]]) + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c yy_current_buffer(). + * M4_YY_DOC_PARAM + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +void yy_flush_buffer YYFARGS1( yybuffer ,b) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_flush_buffer( yybuffer b ) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + if ( b == NULL ) { + return; + } + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer() ) { + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + } +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * M4_YY_DOC_PARAM + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +void yypush_buffer_state YYFARGS1(yybuffer,new_buffer) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yypush_buffer_state (yybuffer new_buffer) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + if (new_buffer == NULL) { + return; + } + yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); + + /* This block is copied from yy_switch_to_buffer. */ + if ( yy_current_buffer() != NULL ) { + /* Flush out information for old buffer. */ + *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (yy_current_buffer()) { + YY_G(yy_buffer_stack_top)++; + } + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + YY_G(yy_did_buffer_switch_on_eof) = 1; +} + + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * M4_YY_DOC_PARAM + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +void yypop_buffer_state (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yypop_buffer_state (void) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + if (yy_current_buffer() == NULL) { + return; + } + yy_delete_buffer(yy_current_buffer() M4_YY_CALL_LAST_ARG); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (YY_G(yy_buffer_stack_top) > 0) { + --YY_G(yy_buffer_stack_top); + } + if (yy_current_buffer() != NULL) { + yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + YY_G(yy_did_buffer_switch_on_eof) = 1; + } +} + + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yyensure_buffer_stack (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yyensure_buffer_stack(void) +]]) +{ + yy_size_t num_to_alloc; + M4_YY_DECL_GUTS_VAR(); + + if (YY_G(yy_buffer_stack) == NULL) { + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + M4_YY_CALL_LAST_ARG); + if ( YY_G(yy_buffer_stack == NULL) ) { + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + } + + memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + YY_G(yy_buffer_stack_max) = num_to_alloc; + YY_G(yy_buffer_stack_top) = 0; + return; + } + + if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1) { + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; + YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + (YY_G(yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + M4_YY_CALL_LAST_ARG); + if (YY_G(yy_buffer_stack) == NULL) { + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + } + /* zero only the new slots.*/ + memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + YY_G(yy_buffer_stack_max) = num_to_alloc; + } +} + + + + +m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, +[[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * M4_YY_DOC_PARAM + * @return the newly allocated buffer state object. + */ +yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) +{ + yybuffer b; + m4_dnl M4_YY_DECL_GUTS_VAR(); + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) { + /* They forgot to leave room for the EOB's. */ + return NULL; + } + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + if ( b == NULL ) { + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + } + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); + + return b; +} +]]) +]]) + + +m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, +[[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * M4_YY_DOC_PARAM + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +yybuffer yy_scan_string YYFARGS1( const char *, yystr) +{ + m4_dnl M4_YY_DECL_GUTS_VAR(); + + return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); +} +]]) +]]) + + +m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, +[[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * M4_YY_DOC_PARAM + * @return the newly allocated buffer state object. + */ +yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { + yybuffer b; + char *buf; + yy_size_t n; + int i; + m4_dnl M4_YY_DECL_GUTS_VAR(); + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); + if ( buf == 0 ) { + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + } + for ( i = 0; i < _yybytes_len; ++i ) { + buf[i] = yybytes[i]; + } + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); + if ( b == NULL ) { + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + } + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} +]]) +]]) + + +m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, +[[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yy_push_state YYFARGS1( int ,_new_state) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_push_state( int _new_state ) +]]) +{ + M4_YY_DECL_GUTS_VAR(); + if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) { + yy_size_t new_size; + + YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_size_t) YY_G(yy_start_stack_depth) * sizeof( int ); + + if ( ! YY_G(yy_start_stack) ) { + YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); + + } else { + YY_G(yy_start_stack) = (int *) yyrealloc( + (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); + } + if ( ! YY_G(yy_start_stack) ) { + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + } + YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; + + BEGIN(_new_state); +} +]]) + + +m4_ifdef( [[M4_YY_NO_POP_STATE]],, +[[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static void yy_pop_state (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +void yyFlexLexer::yy_pop_state() +]]) +{ + M4_YY_DECL_GUTS_VAR(); + if ( --YY_G(yy_start_stack_ptr) < 0 ) { + YY_FATAL_ERROR( "start-condition stack underflow" ); + } + BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); +} +]]) + + +m4_ifdef( [[M4_YY_NO_TOP_STATE]],, +[[ +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static int yy_top_state (M4_YY_DEF_ONLY_ARG) +]]) +m4_ifdef([[M4_MODE_CXX_ONLY]], [[ +int yyFlexLexer::yy_top_state() +]]) +{ + M4_YY_DECL_GUTS_VAR(); + return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; +} +]]) + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = YY_G(yy_hold_char); \ + YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ + YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ + *YY_G(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } while ( 0 ) + + + +/* Accessor methods (get/set functions) to struct members. */ + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +m4_ifdef([[M4_YY_REENTRANT]], [[ +m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, +[[ +/** Get the user-defined data for this scanner. + * M4_YY_DOC_PARAM + */ +YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyextra; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_GET_LINENO]],, +[[ +/** Get the current line number. + * M4_YY_DOC_PARAM + */ +int yyget_lineno (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + if (yy_current_buffer() == NULL) { + return 0; + } + ]]) + return yylineno; +} +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +[[ +/** Get the current column number. + * M4_YY_DOC_PARAM + */ +int yyget_column (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + +m4_ifdef( [[M4_YY_REENTRANT]], [[ + if (yy_current_buffer() == NULL) { + return 0; + } +]]) + return yycolumn; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_GET_IN]],, +[[ +/** Get the input stream. + * M4_YY_DOC_PARAM + */ +FILE *yyget_in (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyin; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_OUT]],, +[[ +/** Get the output stream. + * M4_YY_DOC_PARAM + */ +FILE *yyget_out (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyout; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_LENG]],, +[[ +/** Get the length of the current token. + * M4_YY_DOC_PARAM + */ +int yyget_leng (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yyleng; +} +]]) + +/** Get the current token. + * M4_YY_DOC_PARAM + */ +m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +[[ +char *yyget_text (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yytext; +} +]]) + +m4_ifdef([[M4_YY_REENTRANT]], [[ +m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +[[ +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * M4_YY_DOC_PARAM + */ +void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) { + M4_YY_DECL_GUTS_VAR(); + yyextra = user_defined ; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +[[ +/** Set the current line number. + * @param _line_number line number + * M4_YY_DOC_PARAM + */ +void yyset_lineno YYFARGS1( int ,_line_number) { + M4_YY_DECL_GUTS_VAR(); + + m4_ifdef( [[M4_YY_REENTRANT]], + [[ + /* lineno is only valid if an input buffer exists. */ + if (yy_current_buffer() == NULL ) { + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + } + ]]) + yylineno = _line_number; +} +]]) + +m4_ifdef( [[M4_YY_REENTRANT]], +[[ +m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +[[ +/** Set the current column. + * @param _column_no column number + * M4_YY_DOC_PARAM + */ +void yyset_column YYFARGS1( int , _column_no) { + M4_YY_DECL_GUTS_VAR(); + +m4_ifdef( [[M4_YY_REENTRANT]], [[ + /* column is only valid if an input buffer exists. */ + if (yy_current_buffer() == NULL ) { + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + } +]]) + yycolumn = _column_no; +} +]]) +]]) + + +m4_ifdef( [[M4_YY_NO_SET_IN]],, +[[ +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * M4_YY_DOC_PARAM + * @see yy_switch_to_buffer + */ +void yyset_in YYFARGS1( FILE * ,_in_str) { + M4_YY_DECL_GUTS_VAR(); + yyin = _in_str ; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_OUT]],, +[[ +void yyset_out YYFARGS1( FILE * ,_out_str) { + M4_YY_DECL_GUTS_VAR(); + yyout = _out_str ; +} +]]) + + +m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +[[ +int yyget_debug (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yy_flex_debug; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +[[ +void yyset_debug YYFARGS1( int ,_bdebug) { + M4_YY_DECL_GUTS_VAR(); + yy_flex_debug = _bdebug ; +} +]]) +]]) + +m4_ifdef([[M4_YY_REENTRANT]], [[ +/* Accessor methods for yylval and yylloc */ + +m4_ifdef([[M4_YY_BISON_LVAL]], [[ +m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +[[ +YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yylval; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LVAL]],, +[[ +void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) { + M4_YY_DECL_GUTS_VAR(); + yylval = yylval_param; +} +]]) + +m4_ifdef( [[]], +[[ +m4_ifdef( [[M4_YY_NO_GET_LLOC]],, +[[ +YYLTYPE *yyget_lloc (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + return yylloc; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LLOC]],, +[[ +void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) { + M4_YY_DECL_GUTS_VAR(); + yylloc = yylloc_param; +} +]]) +]]) + +]]) + + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) { + if (ptr_yy_globals == NULL) { + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL) { + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL) { + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL) { + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +]]) +%# Actually, that ended an if-rentrant section + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +static int yy_init_globals (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + +m4_ifdef( [[M4_MODE_YYLINENO]], +[[ + m4_ifdef( [[M4_YY_NOT_REENTRANT]], + [[ + /* We do not touch yylineno unless the option is enabled. */ + yylineno = 1; + ]]) +]]) + YY_G(yy_buffer_stack) = NULL; + YY_G(yy_buffer_stack_top) = 0; + YY_G(yy_buffer_stack_max) = 0; + YY_G(yy_c_buf_p) = NULL; + YY_G(yy_init) = 0; + YY_G(yy_start) = 0; + +m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], +[[ + YY_G(yy_start_stack_ptr) = 0; + YY_G(yy_start_stack_depth) = 0; + YY_G(yy_start_stack) = NULL; +]]) + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + YY_G(yy_state_buf) = 0; + YY_G(yy_state_ptr) = 0; + YY_G(yy_full_match) = 0; + YY_G(yy_lp) = 0; +]]) + +m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], +[[ + YY_G(yytext_ptr) = 0; + YY_G(yy_more_offset) = 0; + YY_G(yy_prev_more_offset) = 0; +]]) + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} +]]) + + +m4_ifdef([[M4_MODE_C_ONLY]], [[ +%# SNIP! this currently causes conflicts with the c++ scanner +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (M4_YY_DEF_ONLY_ARG) { + M4_YY_DECL_GUTS_VAR(); + + /* Pop the buffer stack, destroying each element. */ + while(yy_current_buffer()) { + yy_delete_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(M4_YY_CALL_ONLY_ARG); + } + + /* Destroy the stack itself. */ + yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); + YY_G(yy_buffer_stack) = NULL; + +m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], +[[ + /* Destroy the start condition stack. */ + yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); + YY_G(yy_start_stack) = NULL; +]]) + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); + YY_G(yy_state_buf) = NULL; +]]) + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( M4_YY_CALL_ONLY_ARG); + +m4_ifdef([[M4_YY_REENTRANT]], [[ + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); + yyscanner = NULL; +]]) + return 0; +} +]]) + + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +/* + * Internal utility routines. + */ +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#ifndef yytext_ptr +static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + + int i; + for ( i = 0; i < n; ++i ) { + s1[i] = s2[i]; + } +} +#endif +]]) + +m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +[[ +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YYFARGS1( const char *,s) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc YYFARGS1( yy_size_t ,size) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + return malloc(size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree YYFARGS1( void *,ptr) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} +]]) + +m4_ifdef([[M4_MODE_TABLESEXT]], [[ +%# definitions +m4preproc_include(`tables_shared.c') + +static int yytbl_read8 (void *v, struct yytbl_reader * rd) { + errno = 0; + if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1) { + errno = EIO; + return -1; + } + rd->bread += (flex_uint32_t) sizeof(flex_uint8_t); + return 0; +} + +static int yytbl_read16 (void *v, struct yytbl_reader * rd) { + errno = 0; + if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1) { + errno = EIO; + return -1; + } + *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); + rd->bread += (flex_uint32_t) sizeof(flex_uint16_t); + return 0; +} + +static int yytbl_read32 (void *v, struct yytbl_reader * rd) { + errno = 0; + if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1) { + errno = EIO; + return -1; + } + *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); + rd->bread += (flex_uint32_t) sizeof(flex_uint32_t); + return 0; +} + +/** Read the header */ +static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) { + size_t bytes; + memset (th, 0, sizeof (struct yytbl_hdr)); + + if (yytbl_read32 (&(th->th_magic), rd) != 0) { + return -1; + } + if (th->th_magic != YYTBL_MAGIC) { + YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ + return -1; + } + + if (yytbl_read32 (&(th->th_hsize), rd) != 0 + || yytbl_read32 (&(th->th_ssize), rd) != 0 + || yytbl_read16 (&(th->th_flags), rd) != 0) { + return -1; + } + /* Sanity check on header size. Greater than 1k suggests some funny business. */ + if (th->th_hsize < 16 || th->th_hsize > 1024) { + YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ + return -1; + } + + /* Allocate enough space for the version and name fields */ + bytes = th->th_hsize - 14; + th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); + if ( ! th->th_version ) { + YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); + } + /* we read it all into th_version, and point th_name into that data */ + if (fread (th->th_version, 1, bytes, rd->fp) != bytes) { + errno = EIO; + yyfree(th->th_version M4_YY_CALL_LAST_ARG); + th->th_version = NULL; + return -1; + } else { + rd->bread += (flex_uint32_t) bytes; + } + th->th_name = th->th_version + strlen (th->th_version) + 1; + return 0; +} + +/** lookup id in the dmap list. + * @param dmap pointer to first element in list + * @return NULL if not found. + */ +static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, int, id) { + M4_YY_DECL_GUTS_VAR(); + M4_YY_NOOP_GUTS_VAR(); + + while (dmap->dm_id) { + if ((int)(dmap->dm_id) == id) { + return dmap; + } else { + dmap++; + } + } + return NULL; +} + +/** Read a table while mapping its contents to the local array. + * @param dmap used to performing mapping + * @return 0 on success + */ +static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) { + struct yytbl_data td; + struct yytbl_dmap *transdmap=0; + int len, i, rv, inner_loop_count; + void *p=0; + + memset (&td, 0, sizeof (struct yytbl_data)); + + if (yytbl_read16 (&td.td_id, rd) != 0 + || yytbl_read16 (&td.td_flags, rd) != 0 + || yytbl_read32 (&td.td_hilen, rd) != 0 + || yytbl_read32 (&td.td_lolen, rd) != 0) { + return -1; + } + /* Lookup the map for the transition table so we have it in case we need it + * inside the loop below. This scanner might not even have a transition + * table, which is ok. + */ + transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); + + if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL) { + YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ + return -1; + } + + /* Allocate space for table. + * The --full yy_transition table is a special case, since we + * need the dmap.dm_sz entry to tell us the sizeof the individual + * struct members. + */ + { + size_t bytes; + + if ((td.td_flags & YYTD_STRUCT)) { + bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); + } else { + bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; + } + if (M4_YY_TABLES_VERIFY) { + /* We point to the array itself */ + p = dmap->dm_arr; + } else { + /* We point to the address of a pointer. */ + *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); + } + if ( ! p ) { + YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); + } + } + + /* If it's a struct, we read 2 integers to get one element */ + if ((td.td_flags & YYTD_STRUCT) != 0) { + inner_loop_count = 2; + } else { + inner_loop_count = 1; + } + /* read and map each element. + * This loop iterates once for each element of the td_data array. + * Notice that we increment 'i' in the inner loop. + */ + len = yytbl_calc_total_len (&td); + for (i = 0; i < len; ) { + int j; + + /* This loop really executes exactly 1 or 2 times. + * The second time is to handle the second member of the + * YYTD_STRUCT for the yy_transition array. + */ + for (j = 0; j < inner_loop_count; j++, i++) { + flex_int32_t t32; + + /* read into t32 no matter what the real size is. */ + { + flex_int16_t t16; + flex_int8_t t8; + + switch (YYTDFLAGS2BYTES (td.td_flags)) { + case sizeof (flex_int32_t): + rv = yytbl_read32 (&t32, rd); + break; + case sizeof (flex_int16_t): + rv = yytbl_read16 (&t16, rd); + t32 = t16; + break; + case sizeof (flex_int8_t): + rv = yytbl_read8 (&t8, rd); + t32 = t8; + break; + default: + YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ + return -1; + } + } + if (rv != 0) { + return -1; + } + /* copy into the deserialized array... */ + + if ((td.td_flags & YYTD_STRUCT)) { + /* t32 is the j'th member of a two-element struct. */ + void *v; + + v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) + : &(((struct yy_trans_info *) p)->yy_nxt); + + switch (dmap->dm_sz) { + case sizeof (flex_int32_t): + if (M4_YY_TABLES_VERIFY) { + if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); + } else { + ((flex_int32_t *) v)[0] = (flex_int32_t) t32; + } + break; + case sizeof (flex_int16_t): + if (M4_YY_TABLES_VERIFY ) { + if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); + } else { + ((flex_int16_t *) v)[0] = (flex_int16_t) t32; + } + break; + case sizeof(flex_int8_t): + if (M4_YY_TABLES_VERIFY ) { + if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) + YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); + } else { + ((flex_int8_t *) v)[0] = (flex_int8_t) t32; + } + break; + default: + YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ + return -1; + } + + /* if we're done with j, increment p */ + if (j == 1) { + p = (struct yy_trans_info *) p + 1; + } + } + else if ((td.td_flags & YYTD_PTRANS)) { + /* t32 is an index into the transition array. */ + struct yy_trans_info *v; + + if (!transdmap) { + YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ + return -1; + } + + if( M4_YY_TABLES_VERIFY) { + v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); + } else { + v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); + } + if(M4_YY_TABLES_VERIFY ) { + if( ((struct yy_trans_info **) p)[0] != v) + YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); + } else { + ((struct yy_trans_info **) p)[0] = v; + } + /* increment p */ + p = (struct yy_trans_info **) p + 1; + } + else { + /* t32 is a plain int. copy data, then incrememnt p. */ + switch (dmap->dm_sz) { + case sizeof (flex_int32_t): + if(M4_YY_TABLES_VERIFY ) { + if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) { + YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); + } + } else { + ((flex_int32_t *) p)[0] = (flex_int32_t) t32; + } + p = ((flex_int32_t *) p) + 1; + break; + case sizeof (flex_int16_t): + if(M4_YY_TABLES_VERIFY ) { + if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) { + YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); + } + } else { + ((flex_int16_t *) p)[0] = (flex_int16_t) t32; + } + p = ((flex_int16_t *) p) + 1; + break; + case sizeof (flex_int8_t): + if(M4_YY_TABLES_VERIFY ){ + if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) { + YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); + } + } else { + ((flex_int8_t *) p)[0] = (flex_int8_t) t32; + } + p = ((flex_int8_t *) p) + 1; + break; + default: + YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ + return -1; + } + } + } + + } + + /* Now eat padding. */ + { + while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) { + flex_int8_t t8; + if(yytbl_read8(&t8,rd) != 0) + return -1; + } + } + + return 0; +} + +/* The name for this specific scanner's tables. */ +#define YYTABLES_NAME "m4_ifdef([[M4_MODE_PREFIX]], M4_MODE_PREFIX, [[yy]])tables" + +/* Find the key and load the DFA tables from the given stream. */ +static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) { + int rv=0; + struct yytbl_hdr th; + struct yytbl_reader rd; + + rd.fp = fp; + th.th_version = NULL; + + /* Keep trying until we find the right set of tables or end of file. */ + while (!feof(rd.fp)) { + rd.bread = 0; + if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0) { + rv = -1; + goto return_rv; + } + + /* A NULL key means choose the first set of tables. */ + if (key == NULL) { + break; + } + + if (strcmp(th.th_name,key) != 0) { + /* Skip ahead to next set */ + fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); + yyfree(th.th_version M4_YY_CALL_LAST_ARG); + th.th_version = NULL; + } + else { + break; + } + } + + while (rd.bread < th.th_ssize) { + /* Load the data tables */ + if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ + rv = -1; + goto return_rv; + } + } + +return_rv: + if(th.th_version) { + yyfree(th.th_version M4_YY_CALL_LAST_ARG); + th.th_version = NULL; + } + + return rv; +} + +/** Load the DFA tables for this scanner from the given stream. */ +int yytables_fload YYFARGS1(FILE *, fp) { + if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) { + return -1; + } + return 0; +} + +/** Destroy the loaded tables, freeing memory, etc.. */ +int yytables_destroy (M4_YY_DEF_ONLY_ARG) { + struct yytbl_dmap *dmap=0; + + if(!M4_YY_TABLES_VERIFY){ + /* Walk the dmap, freeing the pointers */ + for(dmap=yydmap; dmap->dm_id; dmap++) { + void * v; + v = dmap->dm_arr; + if(v && *(char**)v){ + yyfree(*(char**)v M4_YY_CALL_LAST_ARG); + *(char**)v = NULL; + } + } + } + + return 0; +} + +/* end table serialization code definitions */ +]]) + + +m4_ifdef([[M4_YY_MAIN]], [[ +int main (void); + +int main () { +m4_ifdef([[M4_YY_REENTRANT]], [[ + yyscan_t lexer; + yylex_init(&lexer); + yylex( lexer ); + yylex_destroy( lexer); + +]]) +m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ + yylex(); +]]) + + return 0; +} +]]) + +]]) +m4_ifdef( [[M4_YY_IN_HEADER]], +[[ +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif +m4preproc_undivert(1) +#undef M4_MODE_PREFIX[[IN_HEADER]] +#endif /* M4_MODE_PREFIX[[HEADER_H]] */ +m4_undefine([[M4_YY_IN_HEADER]])m4_dnl +]]) + +%# Local Variables: +%# mode:c +%# c-file-style:"k&r" +%# c-basic-offset:8 +%# End: diff --git a/src/skeletons.c b/src/skeletons.c index 9015e66..6aa3eb0 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -42,10 +42,10 @@ const char *cpp_skel[] = { 0, }; -//const char *go_skel[] = { -//#include "go-skel.h" -// 0, -//}; +const char *c99_skel[] = { +#include "c99-skel.h" + 0, +}; /* END digested skeletons */ @@ -60,7 +60,7 @@ struct flex_backend_t { static struct flex_backend_t backends[] = { {.skel=cpp_skel}, - //{.skel=go_skel}, + {.skel=c99_skel}, {NULL} }; -- cgit v1.2.1 From 3c9898eb1352388d17bc4cb97f644996b2c736f4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 08:57:36 -0400 Subject: Add first C99 backend test, the C99 spin of basic_r.l. Illustrates how to adapt an exisying test - in this case, basic_r.l - for the new c99 back end. --- tests/.gitignore | 2 ++ tests/Makefile.am | 3 +++ tests/basic_c99.l | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/basic_c99.txt | 4 ++++ 4 files changed, 78 insertions(+) create mode 100644 tests/basic_c99.l create mode 100644 tests/basic_c99.txt diff --git a/tests/.gitignore b/tests/.gitignore index e5c42b3..7ad1086 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -12,6 +12,8 @@ basic_nr basic_nr.c basic_r basic_r.c +basic_c99 +basic_c99.c bison_nr bison_nr_scanner.[ch] bison_nr_parser.[ch] diff --git a/tests/Makefile.am b/tests/Makefile.am index 9093f5e..1c5062c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -66,6 +66,7 @@ simple_tests = \ array_r \ basic_nr \ basic_r \ + basic_c99 \ bison_nr \ bison_yylloc \ bison_yylval \ @@ -127,6 +128,7 @@ array_nr_SOURCES = array_nr.l array_r_SOURCES = array_r.l basic_nr_SOURCES = basic_nr.l basic_r_SOURCES = basic_r.l +basic_c99_SOURCES = basic_c99.l if HAVE_BISON bison_nr_SOURCES = bison_nr_scanner.l bison_nr_parser.y bison_nr_main.c nodist_bison_nr_SOURCES = bison_nr_parser.h bison_nr_scanner.h @@ -198,6 +200,7 @@ CLEANFILES = \ array_r.c \ basic_nr.c \ basic_r.c \ + basic_c99.c \ bison_nr_parser.c \ bison_nr_parser.h \ bison_nr_scanner.c \ diff --git a/tests/basic_c99.l b/tests/basic_c99.l new file mode 100644 index 0000000..168dfd9 --- /dev/null +++ b/tests/basic_c99.l @@ -0,0 +1,69 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* A reentrant scanner. + This file will not compile under flex version <= 2.5.4. + Sample Input: + # this is a comment + foo = true + bar = "string value" + integer = 43 +*/ +%{ +#include "config.h" +%} + +%option emit="c99" +%option prefix="test" +%option nounput noyywrap noyylineno warn nodefault noinput +%option reentrant + +IDENT [[:alnum:]_-] +WS [[:blank:]] +%% + +^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} +^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} +^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} +^{WS}*#.*\r?\n { } +^{WS}*\r?\n { } +.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} + +%% + +int main(void); + +int main (void) +{ + yyscan_t lexer; + testlex_init( &lexer ); + testset_out ( stdout,lexer); + testset_in ( stdin, lexer); + while( testlex(lexer) ) + { + } + testlex_destroy( lexer ); + printf("TEST RETURNING OK.\n"); + return 0; +} + diff --git a/tests/basic_c99.txt b/tests/basic_c99.txt new file mode 100644 index 0000000..2160628 --- /dev/null +++ b/tests/basic_c99.txt @@ -0,0 +1,4 @@ +# this is a comment +foo = "bar" +num = 43 +setting = false -- cgit v1.2.1 From 4724e14e385c438e90699b1a8651e39fff420dc7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 09:33:26 -0400 Subject: Adding more c99 tests: alloc_extra_c99, array_c99, ccl_c99, debug_c99. alloc_extra -> alloc_extra_cpp ccl -> ccl_cpp These rena,es meam that the tests for all backends are in either two parallel series (*_cpp, *_c99) or three (*_nr, *_r, *_c99). --- tests/.gitignore | 16 +- tests/Makefile.am | 30 +- tests/alloc_extra.l | 120 ------- tests/alloc_extra.txt | 795 ---------------------------------------------- tests/alloc_extra_c99.l | 121 +++++++ tests/alloc_extra_c99.txt | 795 ++++++++++++++++++++++++++++++++++++++++++++++ tests/alloc_extra_cpp.l | 120 +++++++ tests/alloc_extra_cpp.txt | 795 ++++++++++++++++++++++++++++++++++++++++++++++ tests/array_c99.l | 63 ++++ tests/array_c99.txt | 2 + tests/ccl.l | 95 ------ tests/ccl.txt | 27 -- tests/ccl_c99.l | 95 ++++++ tests/ccl_c99.txt | 27 ++ tests/ccl_cpp.l | 96 ++++++ tests/ccl_cpp.txt | 27 ++ tests/debug_c99.l | 60 ++++ tests/debug_c99.txt | 2 + 18 files changed, 2237 insertions(+), 1049 deletions(-) delete mode 100644 tests/alloc_extra.l delete mode 100644 tests/alloc_extra.txt create mode 100644 tests/alloc_extra_c99.l create mode 100644 tests/alloc_extra_c99.txt create mode 100644 tests/alloc_extra_cpp.l create mode 100644 tests/alloc_extra_cpp.txt create mode 100644 tests/array_c99.l create mode 100644 tests/array_c99.txt delete mode 100644 tests/ccl.l delete mode 100644 tests/ccl.txt create mode 100644 tests/ccl_c99.l create mode 100644 tests/ccl_c99.txt create mode 100644 tests/ccl_cpp.l create mode 100644 tests/ccl_cpp.txt create mode 100644 tests/debug_c99.l create mode 100644 tests/debug_c99.txt diff --git a/tests/.gitignore b/tests/.gitignore index 7ad1086..af3cf7c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -2,12 +2,16 @@ *.trs *.o *.tables -alloc_extra -alloc_extra.c +alloc_extra_cpp +alloc_extra_cpp.c +alloc_extra_c99 +alloc_extra_c99.c array_nr array_nr.c array_r array_r.c +array_c99 +array_c99.c basic_nr basic_nr.c basic_r @@ -27,8 +31,10 @@ c_cxx_nr c_cxx_nr.cc c_cxx_r c_cxx_r.cc -ccl -ccl.c +ccl_cpp +ccl_cpp.c +ccl_c99 +ccl_c99.c cxx_basic cxx_basic.cc cxx_multiple_scanners @@ -41,6 +47,8 @@ debug_nr debug_nr.c debug_r debug_r.c +debug_c99 +debug_c99.c extended extended.c header_nr diff --git a/tests/Makefile.am b/tests/Makefile.am index 1c5062c..be9541a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -61,9 +61,11 @@ AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src check_PROGRAMS = $(simple_tests) $(reject_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) simple_tests = \ - alloc_extra \ + alloc_extra_cpp \ + alloc_extra_c99 \ array_nr \ array_r \ + array_c99 \ basic_nr \ basic_r \ basic_c99 \ @@ -72,12 +74,14 @@ simple_tests = \ bison_yylval \ c_cxx_nr \ c_cxx_r \ - ccl \ + ccl_cpp \ + ccl_c99 \ cxx_basic \ cxx_multiple_scanners \ cxx_restart \ debug_nr \ debug_r \ + debug_c99 \ extended \ header_nr \ header_r \ @@ -123,9 +127,11 @@ ONE_TESTS = \ lineno_trailing.one quote_in_comment_SOURCES = quote_in_comment.l -alloc_extra_SOURCES = alloc_extra.l +alloc_extra_cpp_SOURCES = alloc_extra_cpp.l +alloc_extra_c99_SOURCES = alloc_extra_c99.l array_nr_SOURCES = array_nr.l array_r_SOURCES = array_r.l +array_c99_SOURCES = array_c99.l basic_nr_SOURCES = basic_nr.l basic_r_SOURCES = basic_r.l basic_c99_SOURCES = basic_c99.l @@ -143,13 +149,15 @@ bison_yylval_SOURCES = no_bison_stub.c endif c_cxx_nr_SOURCES = c_cxx_nr.lll c_cxx_r_SOURCES = c_cxx_r.lll -ccl_SOURCES = ccl.l +ccl_cpp_SOURCES = ccl_cpp.l +ccl_c99_SOURCES = ccl_c99.l cxx_basic_SOURCES = cxx_basic.ll cxx_restart_SOURCES = cxx_restart.ll cxx_multiple_scanners_SOURCES = cxx_multiple_scanners_main.cc cxx_multiple_scanners_1.ll cxx_multiple_scanners_2.ll cxx_yywrap_i3_SOURCES = cxx_yywrap.ll debug_nr_SOURCES = debug_nr.l debug_r_SOURCES = debug_r.l +debug_c99_SOURCES = debug_c99.l extended_SOURCES = extended.l header_nr_SOURCES = header_nr_scanner.l header_nr_main.c nodist_header_nr_SOURCES = header_nr_scanner.h @@ -195,9 +203,11 @@ yyextra_SOURCES = yyextra.l # it. CLEANFILES = \ - alloc_extra.c \ + alloc_extra_cpp.c \ + alloc_extra_c99.c \ array_nr.c \ array_r.c \ + array_c99.c \ basic_nr.c \ basic_r.c \ basic_c99.c \ @@ -215,7 +225,7 @@ CLEANFILES = \ bison_yylval_scanner.h \ c_cxx_nr.cc \ c_cxx_r.cc \ - ccl.c \ + ccl_cpp.c \ cxx_basic.cc \ cxx_multiple_scanners_1.cc \ cxx_multiple_scanners_2.cc \ @@ -223,6 +233,7 @@ CLEANFILES = \ cxx_yywrap.cc \ debug_nr.c \ debug_r.c \ + debug_c99.c \ extended.c \ header_nr_scanner.c \ header_nr_scanner.h \ @@ -275,9 +286,11 @@ dist-hook: EXTRA_DIST = \ README \ - alloc_extra.txt \ + alloc_extra_cpp.txt \ + alloc_extra_c99.txt \ array_nr.txt \ array_r.txt \ + array_c99.txt \ basic_nr.txt \ basic_r.txt \ bison_nr.txt \ @@ -285,13 +298,14 @@ EXTRA_DIST = \ bison_yylval.txt \ c_cxx_nr.txt \ c_cxx_r.txt \ - ccl.txt \ + ccl_cpp.txt \ cxx_basic.txt \ cxx_multiple_scanners.txt \ cxx_restart.txt \ cxx_yywrap.txt \ debug_nr.txt \ debug_r.txt \ + debug_c99.txt \ extended.txt \ header_nr.txt \ header_r.txt \ diff --git a/tests/alloc_extra.l b/tests/alloc_extra.l deleted file mode 100644 index c974777..0000000 --- a/tests/alloc_extra.l +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A file to build "scanner.c". */ -/* This tests that we can use "yyextra". - We buffer all input into a growable array, then print it. - We run diff on the input and output. -*/ - -#include -#include -#include "config.h" - - -/* We'll store the entire input in this buffer, growing as necessary. */ -struct Check { - char foo; - char *bar; - char qux; -}; - -/* Save char into junk array at next position. */ -static void check_extra ( yyscan_t scanner ); - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap nodefault noinput -%option warn -%option extra-type="struct Check *" -%option reentrant -%option noyyalloc - - -%% - -.|\r|\n { check_extra (yyscanner); } - -%% - -int main(void); - -int -main (void) -{ - yyscan_t scanner; - struct Check check; - - check.foo = 'a'; - check.bar = NULL; - check.qux = 'z'; - - testlex_init_extra(&check, &scanner); - testset_in(stdin, scanner); - testset_out(stdout, scanner); - - /* Test to confirm that testalloc was called from - * testlex_init_extra with the testextra argument. - */ - check_extra(scanner); - - testlex(scanner); - - testlex_destroy(scanner); - return 0; -} - -void *testalloc(size_t size, yyscan_t scanner) -{ - struct Check *check; - check = testget_extra(scanner); - - if (!check->bar) - check->bar = "Hello World"; - - check_extra(scanner); - - return malloc(size); -} - -/* Save char into junk array at next position. */ -static void check_extra(yyscan_t scanner) -{ - struct Check *check; - check = testget_extra(scanner); - - if (check->foo != 'a') { - fprintf(stderr, "foo is not 'a'\n"); - exit(1); - } - if (strcmp(check->bar, "Hello World") != 0) { - fprintf(stderr, "bar is not Hello World\n"); - exit(1); - } - if (check->qux != 'z') { - fprintf(stderr, "qux is not 'z'\n"); - exit(1); - } -} diff --git a/tests/alloc_extra.txt b/tests/alloc_extra.txt deleted file mode 100644 index 243df29..0000000 --- a/tests/alloc_extra.txt +++ /dev/null @@ -1,795 +0,0 @@ - - THE UNITED STATES CONSTITUTION - _________________________________________________________________ - - (See Note 1) - - We the People of the United States, in Order to form a more perfect - Union, establish Justice, insure domestic Tranquility, provide for the - common defence, promote the general Welfare, and secure the Blessings - of Liberty to ourselves and our Posterity, do ordain and establish - this Constitution for the United States of America. - -Article. I. - - Section 1. - - All legislative Powers herein granted shall be vested in a Congress of - the United States, which shall consist of a Senate and House of - Representatives. - - Section. 2. - - Clause 1: The House of Representatives shall be composed of Members - chosen every second Year by the People of the several States, and the - Electors in each State shall have the Qualifications requisite for - Electors of the most numerous Branch of the State Legislature. - - Clause 2: No Person shall be a Representative who shall not have - attained to the Age of twenty five Years, and been seven Years a - Citizen of the United States, and who shall not, when elected, be an - Inhabitant of that State in which he shall be chosen. - - Clause 3: Representatives and direct Taxes shall be apportioned among - the several States which may be included within this Union, according - to their respective Numbers, which shall be determined by adding to - the whole Number of free Persons, including those bound to Service for - a Term of Years, and excluding Indians not taxed, three fifths of all - other Persons. (See Note 2) The actual Enumeration shall be made - within three Years after the first Meeting of the Congress of the - United States, and within every subsequent Term of ten Years, in such - Manner as they shall by Law direct. The Number of Representatives - shall not exceed one for every thirty Thousand, but each State shall - have at Least one Representative; and until such enumeration shall be - made, the State of New Hampshire shall be entitled to chuse three, - Massachusetts eight, Rhode-Island and Providence Plantations one, - Connecticut five, New-York six, New Jersey four, Pennsylvania eight, - Delaware one, Maryland six, Virginia ten, North Carolina five, South - Carolina five, and Georgia three. - - Clause 4: When vacancies happen in the Representation from any State, - the Executive Authority thereof shall issue Writs of Election to fill - such Vacancies. - - Clause 5: The House of Representatives shall chuse their Speaker and - other Officers; and shall have the sole Power of Impeachment. - - Section. 3. - - Clause 1: The Senate of the United States shall be composed of two - Senators from each State, chosen by the Legislature thereof, (See Note - 3) for six Years; and each Senator shall have one Vote. - - Clause 2: Immediately after they shall be assembled in Consequence of - the first Election, they shall be divided as equally as may be into - three Classes. The Seats of the Senators of the first Class shall be - vacated at the Expiration of the second Year, of the second Class at - the Expiration of the fourth Year, and of the third Class at the - Expiration of the sixth Year, so that one third may be chosen every - second Year; and if Vacancies happen by Resignation, or otherwise, - during the Recess of the Legislature of any State, the Executive - thereof may make temporary Appointments until the next Meeting of the - Legislature, which shall then fill such Vacancies. (See Note 4) - - Clause 3: No Person shall be a Senator who shall not have attained to - the Age of thirty Years, and been nine Years a Citizen of the United - States, and who shall not, when elected, be an Inhabitant of that - State for which he shall be chosen. - - Clause 4: The Vice President of the United States shall be President - of the Senate, but shall have no Vote, unless they be equally divided. - - Clause 5: The Senate shall chuse their other Officers, and also a - President pro tempore, in the Absence of the Vice President, or when - he shall exercise the Office of President of the United States. - - Clause 6: The Senate shall have the sole Power to try all - Impeachments. When sitting for that Purpose, they shall be on Oath or - Affirmation. When the President of the United States is tried, the - Chief Justice shall preside: And no Person shall be convicted without - the Concurrence of two thirds of the Members present. - - Clause 7: Judgment in Cases of Impeachment shall not extend further - than to removal from Office, and disqualification to hold and enjoy - any Office of honor, Trust or Profit under the United States: but the - Party convicted shall nevertheless be liable and subject to - Indictment, Trial, Judgment and Punishment, according to Law. - - Section. 4. - - Clause 1: The Times, Places and Manner of holding Elections for - Senators and Representatives, shall be prescribed in each State by the - Legislature thereof; but the Congress may at any time by Law make or - alter such Regulations, except as to the Places of chusing Senators. - - Clause 2: The Congress shall assemble at least once in every Year, and - such Meeting shall be on the first Monday in December, (See Note 5) - unless they shall by Law appoint a different Day. - - Section. 5. - - Clause 1: Each House shall be the Judge of the Elections, Returns and - Qualifications of its own Members, and a Majority of each shall - constitute a Quorum to do Business; but a smaller Number may adjourn - from day to day, and may be authorized to compel the Attendance of - absent Members, in such Manner, and under such Penalties as each House - may provide. - - Clause 2: Each House may determine the Rules of its Proceedings, - punish its Members for disorderly Behaviour, and, with the Concurrence - of two thirds, expel a Member. - - Clause 3: Each House shall keep a Journal of its Proceedings, and from - time to time publish the same, excepting such Parts as may in their - Judgment require Secrecy; and the Yeas and Nays of the Members of - either House on any question shall, at the Desire of one fifth of - those Present, be entered on the Journal. - - Clause 4: Neither House, during the Session of Congress, shall, - without the Consent of the other, adjourn for more than three days, - nor to any other Place than that in which the two Houses shall be - sitting. - - Section. 6. - - Clause 1: The Senators and Representatives shall receive a - Compensation for their Services, to be ascertained by Law, and paid - out of the Treasury of the United States. (See Note 6) They shall in - all Cases, except Treason, Felony and Breach of the Peace, - beprivileged from Arrest during their Attendance at the Session of - their respective Houses, and in going to and returning from the same; - and for any Speech or Debate in either House, they shall not be - questioned in any other Place. - - Clause 2: No Senator or Representative shall, during the Time for - which he was elected, be appointed to any civil Office under the - Authority of the United States, which shall have been created, or the - Emoluments whereof shall have been encreased during such time; and no - Person holding any Office under the United States, shall be a Member - of either House during his Continuance in Office. - - Section. 7. - - Clause 1: All Bills for raising Revenue shall originate in the House - of Representatives; but the Senate may propose or concur with - Amendments as on other Bills. - - Clause 2: Every Bill which shall have passed the House of - Representatives and the Senate, shall, before it become a Law, be - presented to the President of the United States; If he approve he - shall sign it, but if not he shall return it, with his Objections to - that House in which it shall have originated, who shall enter the - Objections at large on their Journal, and proceed to reconsider it. If - after such Reconsideration two thirds of that House shall agree to - pass the Bill, it shall be sent, together with the Objections, to the - other House, by which it shall likewise be reconsidered, and if - approved by two thirds of that House, it shall become a Law. But in - all such Cases the Votes of both Houses shall be determined by yeas - and Nays, and the Names of the Persons voting for and against the Bill - shall be entered on the Journal of each House respectively. If any - Bill shall not be returned by the President within ten Days (Sundays - excepted) after it shall have been presented to him, the Same shall be - a Law, in like Manner as if he had signed it, unless the Congress by - their Adjournment prevent its Return, in which Case it shall not be a - Law. - - Clause 3: Every Order, Resolution, or Vote to which the Concurrence of - the Senate and House of Representatives may be necessary (except on a - question of Adjournment) shall be presented to the President of the - United States; and before the Same shall take Effect, shall be - approved by him, or being disapproved by him, shall be repassed by two - thirds of the Senate and House of Representatives, according to the - Rules and Limitations prescribed in the Case of a Bill. - - Section. 8. - - Clause 1: The Congress shall have Power To lay and collect Taxes, - Duties, Imposts and Excises, to pay the Debts and provide for the - common Defence and general Welfare of the United States; but all - Duties, Imposts and Excises shall be uniform throughout the United - States; - - Clause 2: To borrow Money on the credit of the United States; - - Clause 3: To regulate Commerce with foreign Nations, and among the - several States, and with the Indian Tribes; - - Clause 4: To establish an uniform Rule of Naturalization, and uniform - Laws on the subject of Bankruptcies throughout the United States; - - Clause 5: To coin Money, regulate the Value thereof, and of foreign - Coin, and fix the Standard of Weights and Measures; - - Clause 6: To provide for the Punishment of counterfeiting the - Securities and current Coin of the United States; - - Clause 7: To establish Post Offices and post Roads; - - Clause 8: To promote the Progress of Science and useful Arts, by - securing for limited Times to Authors and Inventors the exclusive - Right to their respective Writings and Discoveries; - - Clause 9: To constitute Tribunals inferior to the supreme Court; - - Clause 10: To define and punish Piracies and Felonies committed on the - high Seas, and Offences against the Law of Nations; - - Clause 11: To declare War, grant Letters of Marque and Reprisal, and - make Rules concerning Captures on Land and Water; - - Clause 12: To raise and support Armies, but no Appropriation of Money - to that Use shall be for a longer Term than two Years; - - Clause 13: To provide and maintain a Navy; - - Clause 14: To make Rules for the Government and Regulation of the land - and naval Forces; - - Clause 15: To provide for calling forth the Militia to execute the - Laws of the Union, suppress Insurrections and repel Invasions; - - Clause 16: To provide for organizing, arming, and disciplining, the - Militia, and for governing such Part of them as may be employed in the - Service of the United States, reserving to the States respectively, - the Appointment of the Officers, and the Authority of training the - Militia according to the discipline prescribed by Congress; - - Clause 17: To exercise exclusive Legislation in all Cases whatsoever, - over such District (not exceeding ten Miles square) as may, byCession - of particular States, and the Acceptance of Congress, become the Seat - of the Government of the United States, and to exercise like Authority - over all Places purchased by the Consent of the Legislature of the - State in which the Same shall be, for the Erection of Forts, - Magazines, Arsenals, dock-Yards, and other needful Buildings;--And - - Clause 18: To make all Laws which shall be necessary and proper for - carrying into Execution the foregoing Powers, and all other Powers - vested by this Constitution in the Government of the United States, or - in any Department or Officer thereof. - - Section. 9. - - Clause 1: The Migration or Importation of such Persons as any of the - States now existing shall think proper to admit, shall not be - prohibited by the Congress prior to the Year one thousand eight - hundred and eight, but a Tax or duty may be imposed on such - Importation, not exceeding ten dollars for each Person. - - Clause 2: The Privilege of the Writ of Habeas Corpus shall not be - suspended, unless when in Cases of Rebellion or Invasion the public - Safety may require it. - - Clause 3: No Bill of Attainder or ex post facto Law shall be passed. - - Clause 4: No Capitation, or other direct, Tax shall be laid, unless in - Proportion to the Census or Enumeration herein before directed to be - taken. (See Note 7) - - Clause 5: No Tax or Duty shall be laid on Articles exported from any - State. - - Clause 6: No Preference shall be given by any Regulation of Commerce - or Revenue to the Ports of one State over those of another: nor shall - Vessels bound to, or from, one State, be obliged to enter, clear, or - pay Duties in another. - - Clause 7: No Money shall be drawn from the Treasury, but in - Consequence of Appropriations made by Law; and a regular Statement and - Account of the Receipts and Expenditures of all public Money shall be - published from time to time. - - Clause 8: No Title of Nobility shall be granted by the United States: - And no Person holding any Office of Profit or Trust under them, shall, - without the Consent of the Congress, accept of any present, Emolument, - Office, or Title, of any kind whatever, from any King, Prince, or - foreign State. - - Section. 10. - - Clause 1: No State shall enter into any Treaty, Alliance, or - Confederation; grant Letters of Marque and Reprisal; coin Money; emit - Bills of Credit; make any Thing but gold and silver Coin a Tender in - Payment of Debts; pass any Bill of Attainder, ex post facto Law, or - Law impairing the Obligation of Contracts, or grant any Title of - Nobility. - - Clause 2: No State shall, without the Consent of the Congress, lay any - Imposts or Duties on Imports or Exports, except what may be absolutely - necessary for executing it's inspection Laws: and the net Produce of - all Duties and Imposts, laid by any State on Imports or Exports, shall - be for the Use of the Treasury of the United States; and all such Laws - shall be subject to the Revision and Controul of the Congress. - - Clause 3: No State shall, without the Consent of Congress, lay any - Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter - into any Agreement or Compact with another State, or with a foreign - Power, or engage in War, unless actually invaded, or in such imminent - Danger as will not admit of delay. - -Article. II. - - Section. 1. - - Clause 1: The executive Power shall be vested in a President of the - United States of America. He shall hold his Office during the Term of - four Years, and, together with the Vice President, chosen for the same - Term, be elected, as follows - - Clause 2: Each State shall appoint, in such Manner as the Legislature - thereof may direct, a Number of Electors, equal to the whole Number of - Senators and Representatives to which the State may be entitled in the - Congress: but no Senator or Representative, or Person holding an - Office of Trust or Profit under the United States, shall be appointed - an Elector. - - Clause 3: The Electors shall meet in their respective States, and vote - by Ballot for two Persons, of whom one at least shall not be an - Inhabitant of the same State with themselves. And they shall make a - List of all the Persons voted for, and of the Number of Votes for - each; which List they shall sign and certify, and transmit sealed to - the Seat of the Government of the United States, directed to the - President of the Senate. The President of the Senate shall, in the - Presence of the Senate and House of Representatives, open all the - Certificates, and the Votes shall then be counted. The Person having - the greatest Number of Votes shall be the President, if such Number be - a Majority of the whole Number of Electors appointed; and if there be - more than one who have such Majority, and have an equal Number of - Votes, then the House of Representatives shall immediately chuse by - Ballot one of them for President; and if no Person have a Majority, - then from the five highest on the List the said House shall in like - Manner chuse the President. But in chusing the President, the Votes - shall be taken by States, the Representation from each State having - one Vote; A quorum for this Purpose shall consist of a Member or - Members from two thirds of the States, and a Majority of all the - States shall be necessary to a Choice. In every Case, after the Choice - of the President, the Person having the greatest Number of Votes of - the Electors shall be the Vice President. But if there should remain - two or more who have equal Votes, the Senate shall chuse from them by - Ballot the Vice President. (See Note 8) - - Clause 4: The Congress may determine the Time of chusing the Electors, - and the Day on which they shall give their Votes; which Day shall be - the same throughout the United States. - - Clause 5: No Person except a natural born Citizen, or a Citizen of the - United States, at the time of the Adoption of this Constitution, shall - be eligible to the Office of President; neither shall any Person be - eligible to that Office who shall not have attained to the Age of - thirty five Years, and been fourteen Years a Resident within the - United States. - - Clause 6: In Case of the Removal of the President from Office, or of - his Death, Resignation, or Inability to discharge the Powers and - Duties of the said Office, (See Note 9) the Same shall devolve on the - VicePresident, and the Congress may by Law provide for the Case of - Removal, Death, Resignation or Inability, both of the President and - Vice President, declaring what Officer shall then act as President, - and such Officer shall act accordingly, until the Disability be - removed, or a President shall be elected. - - Clause 7: The President shall, at stated Times, receive for his - Services, a Compensation, which shall neither be encreased nor - diminished during the Period for which he shall have been elected, and - he shall not receive within that Period any other Emolument from the - United States, or any of them. - - Clause 8: Before he enter on the Execution of his Office, he shall - take the following Oath or Affirmation:--"I do solemnly swear (or - affirm) that I will faithfully execute the Office of President of the - United States, and will to the best of my Ability, preserve, protect - and defend the Constitution of the United States." - - Section. 2. - - Clause 1: The President shall be Commander in Chief of the Army and - Navy of the United States, and of the Militia of the several States, - when called into the actual Service of the United States; he may - require the Opinion, in writing, of the principal Officer in each of - the executive Departments, upon any Subject relating to the Duties of - their respective Offices, and he shall have Power to grant Reprieves - and Pardons for Offences against the United States, except in Cases of - Impeachment. - - Clause 2: He shall have Power, by and with the Advice and Consent of - the Senate, to make Treaties, provided two thirds of the Senators - present concur; and he shall nominate, and by and with the Advice and - Consent of the Senate, shall appoint Ambassadors, other public - Ministers and Consuls, Judges of the supreme Court, and all other - Officers of the United States, whose Appointments are not herein - otherwise provided for, and which shall be established by Law: but the - Congress may by Law vest the Appointment of such inferior Officers, as - they think proper, in the President alone, in the Courts of Law, or in - the Heads of Departments. - - Clause 3: The President shall have Power to fill up all Vacancies that - may happen during the Recess of the Senate, by granting Commissions - which shall expire at the End of their next Session. - - Section. 3. - - He shall from time to time give to the Congress Information of the - State of the Union, and recommend to their Consideration such Measures - as he shall judge necessary and expedient; he may, on extraordinary - Occasions, convene both Houses, or either of them, and in Case of - Disagreement between them, with Respect to the Time of Adjournment, he - may adjourn them to such Time as he shall think proper; he shall - receive Ambassadors and other public Ministers; he shall take Care - that the Laws be faithfully executed, and shall Commission all the - Officers of the United States. - - Section. 4. - - The President, Vice President and all civil Officers of the United - States, shall be removed from Office on Impeachment for, and - Conviction of, Treason, Bribery, or other high Crimes and - Misdemeanors. - -Article. III. - - Section. 1. - - The judicial Power of the United States, shall be vested in one - supreme Court, and in such inferior Courts as the Congress may from - time to time ordain and establish. The Judges, both of the supreme and - inferior Courts, shall hold their Offices during good Behaviour, and - shall, at stated Times, receive for their Services, a Compensation, - which shall not be diminished during their Continuance in Office. - - Section. 2. - - Clause 1: The judicial Power shall extend to all Cases, in Law and - Equity, arising under this Constitution, the Laws of the United - States, and Treaties made, or which shall be made, under their - Authority;--to all Cases affecting Ambassadors, other public Ministers - and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to - Controversies to which the United States shall be a Party;--to - Controversies between two or more States;--between a State and - Citizens of another State; (See Note 10)--between Citizens of - different States, --between Citizens of the same State claiming Lands - under Grants of different States, and between a State, or the Citizens - thereof, and foreign States, Citizens or Subjects. - - Clause 2: In all Cases affecting Ambassadors, other public Ministers - and Consuls, and those in which a State shall be Party, the supreme - Court shall have original Jurisdiction. In all the other Cases before - mentioned, the supreme Court shall have appellate Jurisdiction, both - as to Law and Fact, with such Exceptions, and under such Regulations - as the Congress shall make. - - Clause 3: The Trial of all Crimes, except in Cases of Impeachment, - shall be by Jury; and such Trial shall be held in the State where the - said Crimes shall have been committed; but when not committed within - any State, the Trial shall be at such Place or Places as the Congress - may by Law have directed. - - Section. 3. - - Clause 1: Treason against the United States, shall consist only in - levying War against them, or in adhering to their Enemies, giving them - Aid and Comfort. No Person shall be convicted of Treason unless on the - Testimony of two Witnesses to the same overt Act, or on Confession in - open Court. - - Clause 2: The Congress shall have Power to declare the Punishment of - Treason, but no Attainder of Treason shall work Corruption of Blood, - or Forfeiture except during the Life of the Person attainted. - -Article. IV. - - Section. 1. - - Full Faith and Credit shall be given in each State to the public Acts, - Records, and judicial Proceedings of every other State. And the - Congress may by general Laws prescribe the Manner in which such Acts, - Records and Proceedings shall be proved, and the Effect thereof. - - Section. 2. - - Clause 1: The Citizens of each State shall be entitled to all - Privileges and Immunities of Citizens in the several States. - - Clause 2: A Person charged in any State with Treason, Felony, or other - Crime, who shall flee from Justice, and be found in another State, - shall on Demand of the executive Authority of the State from which he - fled, be delivered up, to be removed to the State having Jurisdiction - of the Crime. - - Clause 3: No Person held to Service or Labour in one State, under the - Laws thereof, escaping into another, shall, in Consequence of any Law - or Regulation therein, be discharged from such Service or Labour, but - shall be delivered up on Claim of the Party to whom such Service or - Labour may be due. (See Note 11) - - Section. 3. - - Clause 1: New States may be admitted by the Congress into this Union; - but no new State shall be formed or erected within the Jurisdiction of - any other State; nor any State be formed by the Junction of two or - more States, or Parts of States, without the Consent of the - Legislatures of the States concerned as well as of the Congress. - - Clause 2: The Congress shall have Power to dispose of and make all - needful Rules and Regulations respecting the Territory or other - Property belonging to the United States; and nothing in this - Constitution shall be so construed as to Prejudice any Claims of the - United States, or of any particular State. - - Section. 4. - - The United States shall guarantee to every State in this Union a - Republican Form of Government, and shall protect each of them against - Invasion; and on Application of the Legislature, or of the Executive - (when the Legislature cannot be convened) against domestic Violence. - -Article. V. - - The Congress, whenever two thirds of both Houses shall deem it - necessary, shall propose [1]Amendments to this Constitution, or, on - the Application of the Legislatures of two thirds of the several - States, shall call a Convention for proposing Amendments, which, in - either Case, shall be valid to all Intents and Purposes, as Part of - this Constitution, when ratified by the Legislatures of three fourths - of the several States, or by Conventions in three fourths thereof, as - the one or the other Mode of Ratification may be proposed by the - Congress; Provided that no Amendment which may be made prior to the - Year One thousand eight hundred and eight shall in any Manner affect - the first and fourth Clauses in the Ninth Section of the first - Article; and that no State, without its Consent, shall be deprived of - its equal Suffrage in the Senate. - -Article. VI. - - Clause 1: All Debts contracted and Engagements entered into, before - the Adoption of this Constitution, shall be as valid against the - United States under this Constitution, as under the Confederation. - - Clause 2: This Constitution, and the Laws of the United States which - shall be made in Pursuance thereof; and all Treaties made, or which - shall be made, under the Authority of the United States, shall be the - supreme Law of the Land; and the Judges in every State shall be bound - thereby, any Thing in the Constitution or Laws of any State to the - Contrary notwithstanding. - - Clause 3: The Senators and Representatives before mentioned, and the - Members of the several State Legislatures, and all executive and - judicial Officers, both of the United States and of the several - States, shall be bound by Oath or Affirmation, to support this - Constitution; but no religious Test shall ever be required as a - Qualification to any Office or public Trust under the United States. - -Article. VII. - - The Ratification of the Conventions of nine States, shall be - sufficient for the Establishment of this Constitution between the - States so ratifying the Same. - - done in Convention by the Unanimous Consent of the States present the - Seventeenth Day of September in the Year of our Lord one thousand - seven hundred and Eighty seven and of the Independence of the United - States of America the Twelfth In witness whereof We have hereunto - subscribed our Names, - - GO WASHINGTON--Presidt. and deputy from Virginia - - [Signed also by the deputies of twelve States.] - - Delaware - - Geo: Read - Gunning Bedford jun - John Dickinson - Richard Bassett - Jaco: Broom - - Maryland - - James MCHenry - Dan of ST ThoS. Jenifer - DanL Carroll. - - Virginia - - John Blair-- - James Madison Jr. - - North Carolina - - WM Blount - RichD. Dobbs Spaight. - Hu Williamson - - South Carolina - - J. Rutledge - Charles 1ACotesworth Pinckney - Charles Pinckney - Pierce Butler. - - Georgia - - William Few - Abr Baldwin - - New Hampshire - - John Langdon - Nicholas Gilman - - Massachusetts - - Nathaniel Gorham - Rufus King - - Connecticut - WM. SamL. Johnson - Roger Sherman - - New York - - Alexander Hamilton - - New Jersey - - Wil: Livingston - David Brearley. - WM. Paterson. - Jona: Dayton - - Pennsylvania - - B Franklin - Thomas Mifflin - RobT Morris - Geo. Clymer - ThoS. FitzSimons - Jared Ingersoll - James Wilson. - Gouv Morris - - Attest William Jackson Secretary - - NOTES - - Note 1: This text of the Constitution follows the engrossed copy - signed by Gen. Washington and the deputies from 12 States. The small - superior figures preceding the paragraphs designate Clauses, and were - not in the original and have no reference to footnotes. - - The Constitution was adopted by a convention of the States on - September 17, 1787, and was subsequently ratified by the several - States, on the following dates: Delaware, December 7, 1787; - Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; - Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, - February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, - 1788; New Hampshire, June 21, 1788. - - Ratification was completed on June 21, 1788. - - The Constitution was subsequently ratified by Virginia, June 25, 1788; - New York, July 26, 1788; North Carolina, November 21, 1789; Rhode - Island, May 29, 1790; and Vermont, January 10, 1791. - - In May 1785, a committee of Congress made a report recommending an - alteration in the Articles of Confederation, but no action was taken - on it, and it was left to the State Legislatures to proceed in the - matter. In January 1786, the Legislature of Virginia passed a - resolution providing for the appointment of five commissioners, who, - or any three of them, should meet such commissioners as might be - appointed in the other States of the Union, at a time and place to be - agreed upon, to take into consideration the trade of the United - States; to consider how far a uniform system in their commercial - regulations may be necessary to their common interest and their - permanent harmony; and to report to the several States such an act, - relative to this great object, as, when ratified by them, will enable - the United States in Congress effectually to provide for the same. The - Virginia commissioners, after some correspondence, fixed the first - Monday in September as the time, and the city of Annapolis as the - place for the meeting, but only four other States were represented, - viz: Delaware, New York, New Jersey, and Pennsylvania; the - commissioners appointed by Massachusetts, New Hampshire, North - Carolina, and Rhode Island failed to attend. Under the circumstances - of so partial a representation, the commissioners present agreed upon - a report, (drawn by Mr. Hamilton, of New York,) expressing their - unanimous conviction that it might essentially tend to advance the - interests of the Union if the States by which they were respectively - delegated would concur, and use their endeavors to procure the - concurrence of the other States, in the appointment of commissioners - to meet at Philadelphia on the Second Monday of May following, to take - into consideration the situation of the United States; to devise such - further provisions as should appear to them necessary to render the - Constitution of the Federal Government adequate to the exigencies of - the Union; and to report such an act for that purpose to the United - States in Congress assembled as, when agreed to by them and afterwards - confirmed by the Legislatures of every State, would effectually - provide for the same. - - Congress, on the 21st of February, 1787, adopted a resolution in favor - of a convention, and the Legislatures of those States which had not - already done so (with the exception of Rhode Island) promptly - appointed delegates. On the 25th of May, seven States having convened, - George Washington, of Virginia, was unanimously elected President, and - the consideration of the proposed constitution was commenced. On the - 17th of September, 1787, the Constitution as engrossed and agreed upon - was signed by all the members present, except Mr. Gerry of - Massachusetts, and Messrs. Mason and Randolph, of Virginia. The - president of the convention transmitted it to Congress, with a - resolution stating how the proposed Federal Government should be put - in operation, and an explanatory letter. Congress, on the 28th of - September, 1787, directed the Constitution so framed, with the - resolutions and letter concerning the same, to "be transmitted to the - several Legislatures in order to be submitted to a convention of - delegates chosen in each State by the people thereof, in conformity to - the resolves of the convention." - - On the 4th of March, 1789, the day which had been fixed for commencing - the operations of Government under the new Constitution, it had been - ratified by the conventions chosen in each State to consider it, as - follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; - New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, - January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, - 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; - Virginia, June 25, 1788; and New York, July 26, 1788. - - The President informed Congress, on the 28th of January, 1790, that - North Carolina had ratified the Constitution November 21, 1789; and he - informed Congress on the 1st of June, 1790, that Rhode Island had - ratified the Constitution May 29, 1790. Vermont, in convention, - ratified the Constitution January 10, 1791, and was, by an act of - Congress approved February 18, 1791, "received and admitted into this - Union as a new and entire member of the United States." - - Note 2: The part of this Clause relating to the mode of apportionment - of representatives among the several States has been affected by - Section 2 of amendment XIV, and as to taxes on incomes without - apportionment by amendment XVI. - - Note 3: This Clause has been affected by Clause 1 of amendment XVII. - - Note 4: This Clause has been affected by Clause 2 of amendment XVIII. - - Note 5: This Clause has been affected by amendment XX. - - Note 6: This Clause has been affected by amendment XXVII. - - Note 7: This Clause has been affected by amendment XVI. - - Note 8: This Clause has been superseded by amendment XII. - - Note 9: This Clause has been affected by amendment XXV. - - Note 10: This Clause has been affected by amendment XI. - - Note 11: This Clause has been affected by amendment XIII. - - Note 12: The first ten amendments to the Constitution of the United - States (and two others, one of which failed of ratification and the - other which later became the 27th amendment) were proposed to the - legislatures of the several States by the First Congress on September - 25, 1789. The first ten amendments were ratified by the following - States, and the notifications of ratification by the Governors thereof - were successively communicated by the President to Congress: New - Jersey, November 20, 1789; Maryland, December 19, 1789; North - Carolina, December 22, 1789; South Carolina, January 19, 1790; New - Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, - February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, - 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. - - Ratification was completed on December 15, 1791. - - The amendments were subsequently ratified by the legislatures of - Massachusetts, March 2, 1939; Georgia, March 18, 1939; and - Connecticut, April 19, 1939. - - Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had - numbers assigned to them at the time of ratification. - - Note 14: This sentence has been superseded by section 3 of amendment - XX. - - Note 15: See amendment XIX and section 1 of amendment XXVI. - - Note 16: Repealed by section 1 of amendment XXI. - -References - - 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/alloc_extra_c99.l b/tests/alloc_extra_c99.l new file mode 100644 index 0000000..fe78939 --- /dev/null +++ b/tests/alloc_extra_c99.l @@ -0,0 +1,121 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A file to build "scanner.c". */ +/* This tests that we can use "yyextra". + We buffer all input into a growable array, then print it. + We run diff on the input and output. +*/ + +#include +#include +#include "config.h" + + +/* We'll store the entire input in this buffer, growing as necessary. */ +struct Check { + char foo; + char *bar; + char qux; +}; + +/* Save char into junk array at next position. */ +static void check_extra ( yyscan_t scanner ); + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap nodefault noinput +%option warn +%option extra-type="struct Check *" +%option reentrant +%option noyyalloc + + +%% + +.|\r|\n { check_extra (yyscanner); } + +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + struct Check check; + + check.foo = 'a'; + check.bar = NULL; + check.qux = 'z'; + + testlex_init_extra(&check, &scanner); + testset_in(stdin, scanner); + testset_out(stdout, scanner); + + /* Test to confirm that testalloc was called from + * testlex_init_extra with the testextra argument. + */ + check_extra(scanner); + + testlex(scanner); + + testlex_destroy(scanner); + return 0; +} + +void *testalloc(size_t size, yyscan_t scanner) +{ + struct Check *check; + check = testget_extra(scanner); + + if (!check->bar) + check->bar = "Hello World"; + + check_extra(scanner); + + return malloc(size); +} + +/* Save char into junk array at next position. */ +static void check_extra(yyscan_t scanner) +{ + struct Check *check; + check = testget_extra(scanner); + + if (check->foo != 'a') { + fprintf(stderr, "foo is not 'a'\n"); + exit(1); + } + if (strcmp(check->bar, "Hello World") != 0) { + fprintf(stderr, "bar is not Hello World\n"); + exit(1); + } + if (check->qux != 'z') { + fprintf(stderr, "qux is not 'z'\n"); + exit(1); + } +} diff --git a/tests/alloc_extra_c99.txt b/tests/alloc_extra_c99.txt new file mode 100644 index 0000000..243df29 --- /dev/null +++ b/tests/alloc_extra_c99.txt @@ -0,0 +1,795 @@ + + THE UNITED STATES CONSTITUTION + _________________________________________________________________ + + (See Note 1) + + We the People of the United States, in Order to form a more perfect + Union, establish Justice, insure domestic Tranquility, provide for the + common defence, promote the general Welfare, and secure the Blessings + of Liberty to ourselves and our Posterity, do ordain and establish + this Constitution for the United States of America. + +Article. I. + + Section 1. + + All legislative Powers herein granted shall be vested in a Congress of + the United States, which shall consist of a Senate and House of + Representatives. + + Section. 2. + + Clause 1: The House of Representatives shall be composed of Members + chosen every second Year by the People of the several States, and the + Electors in each State shall have the Qualifications requisite for + Electors of the most numerous Branch of the State Legislature. + + Clause 2: No Person shall be a Representative who shall not have + attained to the Age of twenty five Years, and been seven Years a + Citizen of the United States, and who shall not, when elected, be an + Inhabitant of that State in which he shall be chosen. + + Clause 3: Representatives and direct Taxes shall be apportioned among + the several States which may be included within this Union, according + to their respective Numbers, which shall be determined by adding to + the whole Number of free Persons, including those bound to Service for + a Term of Years, and excluding Indians not taxed, three fifths of all + other Persons. (See Note 2) The actual Enumeration shall be made + within three Years after the first Meeting of the Congress of the + United States, and within every subsequent Term of ten Years, in such + Manner as they shall by Law direct. The Number of Representatives + shall not exceed one for every thirty Thousand, but each State shall + have at Least one Representative; and until such enumeration shall be + made, the State of New Hampshire shall be entitled to chuse three, + Massachusetts eight, Rhode-Island and Providence Plantations one, + Connecticut five, New-York six, New Jersey four, Pennsylvania eight, + Delaware one, Maryland six, Virginia ten, North Carolina five, South + Carolina five, and Georgia three. + + Clause 4: When vacancies happen in the Representation from any State, + the Executive Authority thereof shall issue Writs of Election to fill + such Vacancies. + + Clause 5: The House of Representatives shall chuse their Speaker and + other Officers; and shall have the sole Power of Impeachment. + + Section. 3. + + Clause 1: The Senate of the United States shall be composed of two + Senators from each State, chosen by the Legislature thereof, (See Note + 3) for six Years; and each Senator shall have one Vote. + + Clause 2: Immediately after they shall be assembled in Consequence of + the first Election, they shall be divided as equally as may be into + three Classes. The Seats of the Senators of the first Class shall be + vacated at the Expiration of the second Year, of the second Class at + the Expiration of the fourth Year, and of the third Class at the + Expiration of the sixth Year, so that one third may be chosen every + second Year; and if Vacancies happen by Resignation, or otherwise, + during the Recess of the Legislature of any State, the Executive + thereof may make temporary Appointments until the next Meeting of the + Legislature, which shall then fill such Vacancies. (See Note 4) + + Clause 3: No Person shall be a Senator who shall not have attained to + the Age of thirty Years, and been nine Years a Citizen of the United + States, and who shall not, when elected, be an Inhabitant of that + State for which he shall be chosen. + + Clause 4: The Vice President of the United States shall be President + of the Senate, but shall have no Vote, unless they be equally divided. + + Clause 5: The Senate shall chuse their other Officers, and also a + President pro tempore, in the Absence of the Vice President, or when + he shall exercise the Office of President of the United States. + + Clause 6: The Senate shall have the sole Power to try all + Impeachments. When sitting for that Purpose, they shall be on Oath or + Affirmation. When the President of the United States is tried, the + Chief Justice shall preside: And no Person shall be convicted without + the Concurrence of two thirds of the Members present. + + Clause 7: Judgment in Cases of Impeachment shall not extend further + than to removal from Office, and disqualification to hold and enjoy + any Office of honor, Trust or Profit under the United States: but the + Party convicted shall nevertheless be liable and subject to + Indictment, Trial, Judgment and Punishment, according to Law. + + Section. 4. + + Clause 1: The Times, Places and Manner of holding Elections for + Senators and Representatives, shall be prescribed in each State by the + Legislature thereof; but the Congress may at any time by Law make or + alter such Regulations, except as to the Places of chusing Senators. + + Clause 2: The Congress shall assemble at least once in every Year, and + such Meeting shall be on the first Monday in December, (See Note 5) + unless they shall by Law appoint a different Day. + + Section. 5. + + Clause 1: Each House shall be the Judge of the Elections, Returns and + Qualifications of its own Members, and a Majority of each shall + constitute a Quorum to do Business; but a smaller Number may adjourn + from day to day, and may be authorized to compel the Attendance of + absent Members, in such Manner, and under such Penalties as each House + may provide. + + Clause 2: Each House may determine the Rules of its Proceedings, + punish its Members for disorderly Behaviour, and, with the Concurrence + of two thirds, expel a Member. + + Clause 3: Each House shall keep a Journal of its Proceedings, and from + time to time publish the same, excepting such Parts as may in their + Judgment require Secrecy; and the Yeas and Nays of the Members of + either House on any question shall, at the Desire of one fifth of + those Present, be entered on the Journal. + + Clause 4: Neither House, during the Session of Congress, shall, + without the Consent of the other, adjourn for more than three days, + nor to any other Place than that in which the two Houses shall be + sitting. + + Section. 6. + + Clause 1: The Senators and Representatives shall receive a + Compensation for their Services, to be ascertained by Law, and paid + out of the Treasury of the United States. (See Note 6) They shall in + all Cases, except Treason, Felony and Breach of the Peace, + beprivileged from Arrest during their Attendance at the Session of + their respective Houses, and in going to and returning from the same; + and for any Speech or Debate in either House, they shall not be + questioned in any other Place. + + Clause 2: No Senator or Representative shall, during the Time for + which he was elected, be appointed to any civil Office under the + Authority of the United States, which shall have been created, or the + Emoluments whereof shall have been encreased during such time; and no + Person holding any Office under the United States, shall be a Member + of either House during his Continuance in Office. + + Section. 7. + + Clause 1: All Bills for raising Revenue shall originate in the House + of Representatives; but the Senate may propose or concur with + Amendments as on other Bills. + + Clause 2: Every Bill which shall have passed the House of + Representatives and the Senate, shall, before it become a Law, be + presented to the President of the United States; If he approve he + shall sign it, but if not he shall return it, with his Objections to + that House in which it shall have originated, who shall enter the + Objections at large on their Journal, and proceed to reconsider it. If + after such Reconsideration two thirds of that House shall agree to + pass the Bill, it shall be sent, together with the Objections, to the + other House, by which it shall likewise be reconsidered, and if + approved by two thirds of that House, it shall become a Law. But in + all such Cases the Votes of both Houses shall be determined by yeas + and Nays, and the Names of the Persons voting for and against the Bill + shall be entered on the Journal of each House respectively. If any + Bill shall not be returned by the President within ten Days (Sundays + excepted) after it shall have been presented to him, the Same shall be + a Law, in like Manner as if he had signed it, unless the Congress by + their Adjournment prevent its Return, in which Case it shall not be a + Law. + + Clause 3: Every Order, Resolution, or Vote to which the Concurrence of + the Senate and House of Representatives may be necessary (except on a + question of Adjournment) shall be presented to the President of the + United States; and before the Same shall take Effect, shall be + approved by him, or being disapproved by him, shall be repassed by two + thirds of the Senate and House of Representatives, according to the + Rules and Limitations prescribed in the Case of a Bill. + + Section. 8. + + Clause 1: The Congress shall have Power To lay and collect Taxes, + Duties, Imposts and Excises, to pay the Debts and provide for the + common Defence and general Welfare of the United States; but all + Duties, Imposts and Excises shall be uniform throughout the United + States; + + Clause 2: To borrow Money on the credit of the United States; + + Clause 3: To regulate Commerce with foreign Nations, and among the + several States, and with the Indian Tribes; + + Clause 4: To establish an uniform Rule of Naturalization, and uniform + Laws on the subject of Bankruptcies throughout the United States; + + Clause 5: To coin Money, regulate the Value thereof, and of foreign + Coin, and fix the Standard of Weights and Measures; + + Clause 6: To provide for the Punishment of counterfeiting the + Securities and current Coin of the United States; + + Clause 7: To establish Post Offices and post Roads; + + Clause 8: To promote the Progress of Science and useful Arts, by + securing for limited Times to Authors and Inventors the exclusive + Right to their respective Writings and Discoveries; + + Clause 9: To constitute Tribunals inferior to the supreme Court; + + Clause 10: To define and punish Piracies and Felonies committed on the + high Seas, and Offences against the Law of Nations; + + Clause 11: To declare War, grant Letters of Marque and Reprisal, and + make Rules concerning Captures on Land and Water; + + Clause 12: To raise and support Armies, but no Appropriation of Money + to that Use shall be for a longer Term than two Years; + + Clause 13: To provide and maintain a Navy; + + Clause 14: To make Rules for the Government and Regulation of the land + and naval Forces; + + Clause 15: To provide for calling forth the Militia to execute the + Laws of the Union, suppress Insurrections and repel Invasions; + + Clause 16: To provide for organizing, arming, and disciplining, the + Militia, and for governing such Part of them as may be employed in the + Service of the United States, reserving to the States respectively, + the Appointment of the Officers, and the Authority of training the + Militia according to the discipline prescribed by Congress; + + Clause 17: To exercise exclusive Legislation in all Cases whatsoever, + over such District (not exceeding ten Miles square) as may, byCession + of particular States, and the Acceptance of Congress, become the Seat + of the Government of the United States, and to exercise like Authority + over all Places purchased by the Consent of the Legislature of the + State in which the Same shall be, for the Erection of Forts, + Magazines, Arsenals, dock-Yards, and other needful Buildings;--And + + Clause 18: To make all Laws which shall be necessary and proper for + carrying into Execution the foregoing Powers, and all other Powers + vested by this Constitution in the Government of the United States, or + in any Department or Officer thereof. + + Section. 9. + + Clause 1: The Migration or Importation of such Persons as any of the + States now existing shall think proper to admit, shall not be + prohibited by the Congress prior to the Year one thousand eight + hundred and eight, but a Tax or duty may be imposed on such + Importation, not exceeding ten dollars for each Person. + + Clause 2: The Privilege of the Writ of Habeas Corpus shall not be + suspended, unless when in Cases of Rebellion or Invasion the public + Safety may require it. + + Clause 3: No Bill of Attainder or ex post facto Law shall be passed. + + Clause 4: No Capitation, or other direct, Tax shall be laid, unless in + Proportion to the Census or Enumeration herein before directed to be + taken. (See Note 7) + + Clause 5: No Tax or Duty shall be laid on Articles exported from any + State. + + Clause 6: No Preference shall be given by any Regulation of Commerce + or Revenue to the Ports of one State over those of another: nor shall + Vessels bound to, or from, one State, be obliged to enter, clear, or + pay Duties in another. + + Clause 7: No Money shall be drawn from the Treasury, but in + Consequence of Appropriations made by Law; and a regular Statement and + Account of the Receipts and Expenditures of all public Money shall be + published from time to time. + + Clause 8: No Title of Nobility shall be granted by the United States: + And no Person holding any Office of Profit or Trust under them, shall, + without the Consent of the Congress, accept of any present, Emolument, + Office, or Title, of any kind whatever, from any King, Prince, or + foreign State. + + Section. 10. + + Clause 1: No State shall enter into any Treaty, Alliance, or + Confederation; grant Letters of Marque and Reprisal; coin Money; emit + Bills of Credit; make any Thing but gold and silver Coin a Tender in + Payment of Debts; pass any Bill of Attainder, ex post facto Law, or + Law impairing the Obligation of Contracts, or grant any Title of + Nobility. + + Clause 2: No State shall, without the Consent of the Congress, lay any + Imposts or Duties on Imports or Exports, except what may be absolutely + necessary for executing it's inspection Laws: and the net Produce of + all Duties and Imposts, laid by any State on Imports or Exports, shall + be for the Use of the Treasury of the United States; and all such Laws + shall be subject to the Revision and Controul of the Congress. + + Clause 3: No State shall, without the Consent of Congress, lay any + Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter + into any Agreement or Compact with another State, or with a foreign + Power, or engage in War, unless actually invaded, or in such imminent + Danger as will not admit of delay. + +Article. II. + + Section. 1. + + Clause 1: The executive Power shall be vested in a President of the + United States of America. He shall hold his Office during the Term of + four Years, and, together with the Vice President, chosen for the same + Term, be elected, as follows + + Clause 2: Each State shall appoint, in such Manner as the Legislature + thereof may direct, a Number of Electors, equal to the whole Number of + Senators and Representatives to which the State may be entitled in the + Congress: but no Senator or Representative, or Person holding an + Office of Trust or Profit under the United States, shall be appointed + an Elector. + + Clause 3: The Electors shall meet in their respective States, and vote + by Ballot for two Persons, of whom one at least shall not be an + Inhabitant of the same State with themselves. And they shall make a + List of all the Persons voted for, and of the Number of Votes for + each; which List they shall sign and certify, and transmit sealed to + the Seat of the Government of the United States, directed to the + President of the Senate. The President of the Senate shall, in the + Presence of the Senate and House of Representatives, open all the + Certificates, and the Votes shall then be counted. The Person having + the greatest Number of Votes shall be the President, if such Number be + a Majority of the whole Number of Electors appointed; and if there be + more than one who have such Majority, and have an equal Number of + Votes, then the House of Representatives shall immediately chuse by + Ballot one of them for President; and if no Person have a Majority, + then from the five highest on the List the said House shall in like + Manner chuse the President. But in chusing the President, the Votes + shall be taken by States, the Representation from each State having + one Vote; A quorum for this Purpose shall consist of a Member or + Members from two thirds of the States, and a Majority of all the + States shall be necessary to a Choice. In every Case, after the Choice + of the President, the Person having the greatest Number of Votes of + the Electors shall be the Vice President. But if there should remain + two or more who have equal Votes, the Senate shall chuse from them by + Ballot the Vice President. (See Note 8) + + Clause 4: The Congress may determine the Time of chusing the Electors, + and the Day on which they shall give their Votes; which Day shall be + the same throughout the United States. + + Clause 5: No Person except a natural born Citizen, or a Citizen of the + United States, at the time of the Adoption of this Constitution, shall + be eligible to the Office of President; neither shall any Person be + eligible to that Office who shall not have attained to the Age of + thirty five Years, and been fourteen Years a Resident within the + United States. + + Clause 6: In Case of the Removal of the President from Office, or of + his Death, Resignation, or Inability to discharge the Powers and + Duties of the said Office, (See Note 9) the Same shall devolve on the + VicePresident, and the Congress may by Law provide for the Case of + Removal, Death, Resignation or Inability, both of the President and + Vice President, declaring what Officer shall then act as President, + and such Officer shall act accordingly, until the Disability be + removed, or a President shall be elected. + + Clause 7: The President shall, at stated Times, receive for his + Services, a Compensation, which shall neither be encreased nor + diminished during the Period for which he shall have been elected, and + he shall not receive within that Period any other Emolument from the + United States, or any of them. + + Clause 8: Before he enter on the Execution of his Office, he shall + take the following Oath or Affirmation:--"I do solemnly swear (or + affirm) that I will faithfully execute the Office of President of the + United States, and will to the best of my Ability, preserve, protect + and defend the Constitution of the United States." + + Section. 2. + + Clause 1: The President shall be Commander in Chief of the Army and + Navy of the United States, and of the Militia of the several States, + when called into the actual Service of the United States; he may + require the Opinion, in writing, of the principal Officer in each of + the executive Departments, upon any Subject relating to the Duties of + their respective Offices, and he shall have Power to grant Reprieves + and Pardons for Offences against the United States, except in Cases of + Impeachment. + + Clause 2: He shall have Power, by and with the Advice and Consent of + the Senate, to make Treaties, provided two thirds of the Senators + present concur; and he shall nominate, and by and with the Advice and + Consent of the Senate, shall appoint Ambassadors, other public + Ministers and Consuls, Judges of the supreme Court, and all other + Officers of the United States, whose Appointments are not herein + otherwise provided for, and which shall be established by Law: but the + Congress may by Law vest the Appointment of such inferior Officers, as + they think proper, in the President alone, in the Courts of Law, or in + the Heads of Departments. + + Clause 3: The President shall have Power to fill up all Vacancies that + may happen during the Recess of the Senate, by granting Commissions + which shall expire at the End of their next Session. + + Section. 3. + + He shall from time to time give to the Congress Information of the + State of the Union, and recommend to their Consideration such Measures + as he shall judge necessary and expedient; he may, on extraordinary + Occasions, convene both Houses, or either of them, and in Case of + Disagreement between them, with Respect to the Time of Adjournment, he + may adjourn them to such Time as he shall think proper; he shall + receive Ambassadors and other public Ministers; he shall take Care + that the Laws be faithfully executed, and shall Commission all the + Officers of the United States. + + Section. 4. + + The President, Vice President and all civil Officers of the United + States, shall be removed from Office on Impeachment for, and + Conviction of, Treason, Bribery, or other high Crimes and + Misdemeanors. + +Article. III. + + Section. 1. + + The judicial Power of the United States, shall be vested in one + supreme Court, and in such inferior Courts as the Congress may from + time to time ordain and establish. The Judges, both of the supreme and + inferior Courts, shall hold their Offices during good Behaviour, and + shall, at stated Times, receive for their Services, a Compensation, + which shall not be diminished during their Continuance in Office. + + Section. 2. + + Clause 1: The judicial Power shall extend to all Cases, in Law and + Equity, arising under this Constitution, the Laws of the United + States, and Treaties made, or which shall be made, under their + Authority;--to all Cases affecting Ambassadors, other public Ministers + and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to + Controversies to which the United States shall be a Party;--to + Controversies between two or more States;--between a State and + Citizens of another State; (See Note 10)--between Citizens of + different States, --between Citizens of the same State claiming Lands + under Grants of different States, and between a State, or the Citizens + thereof, and foreign States, Citizens or Subjects. + + Clause 2: In all Cases affecting Ambassadors, other public Ministers + and Consuls, and those in which a State shall be Party, the supreme + Court shall have original Jurisdiction. In all the other Cases before + mentioned, the supreme Court shall have appellate Jurisdiction, both + as to Law and Fact, with such Exceptions, and under such Regulations + as the Congress shall make. + + Clause 3: The Trial of all Crimes, except in Cases of Impeachment, + shall be by Jury; and such Trial shall be held in the State where the + said Crimes shall have been committed; but when not committed within + any State, the Trial shall be at such Place or Places as the Congress + may by Law have directed. + + Section. 3. + + Clause 1: Treason against the United States, shall consist only in + levying War against them, or in adhering to their Enemies, giving them + Aid and Comfort. No Person shall be convicted of Treason unless on the + Testimony of two Witnesses to the same overt Act, or on Confession in + open Court. + + Clause 2: The Congress shall have Power to declare the Punishment of + Treason, but no Attainder of Treason shall work Corruption of Blood, + or Forfeiture except during the Life of the Person attainted. + +Article. IV. + + Section. 1. + + Full Faith and Credit shall be given in each State to the public Acts, + Records, and judicial Proceedings of every other State. And the + Congress may by general Laws prescribe the Manner in which such Acts, + Records and Proceedings shall be proved, and the Effect thereof. + + Section. 2. + + Clause 1: The Citizens of each State shall be entitled to all + Privileges and Immunities of Citizens in the several States. + + Clause 2: A Person charged in any State with Treason, Felony, or other + Crime, who shall flee from Justice, and be found in another State, + shall on Demand of the executive Authority of the State from which he + fled, be delivered up, to be removed to the State having Jurisdiction + of the Crime. + + Clause 3: No Person held to Service or Labour in one State, under the + Laws thereof, escaping into another, shall, in Consequence of any Law + or Regulation therein, be discharged from such Service or Labour, but + shall be delivered up on Claim of the Party to whom such Service or + Labour may be due. (See Note 11) + + Section. 3. + + Clause 1: New States may be admitted by the Congress into this Union; + but no new State shall be formed or erected within the Jurisdiction of + any other State; nor any State be formed by the Junction of two or + more States, or Parts of States, without the Consent of the + Legislatures of the States concerned as well as of the Congress. + + Clause 2: The Congress shall have Power to dispose of and make all + needful Rules and Regulations respecting the Territory or other + Property belonging to the United States; and nothing in this + Constitution shall be so construed as to Prejudice any Claims of the + United States, or of any particular State. + + Section. 4. + + The United States shall guarantee to every State in this Union a + Republican Form of Government, and shall protect each of them against + Invasion; and on Application of the Legislature, or of the Executive + (when the Legislature cannot be convened) against domestic Violence. + +Article. V. + + The Congress, whenever two thirds of both Houses shall deem it + necessary, shall propose [1]Amendments to this Constitution, or, on + the Application of the Legislatures of two thirds of the several + States, shall call a Convention for proposing Amendments, which, in + either Case, shall be valid to all Intents and Purposes, as Part of + this Constitution, when ratified by the Legislatures of three fourths + of the several States, or by Conventions in three fourths thereof, as + the one or the other Mode of Ratification may be proposed by the + Congress; Provided that no Amendment which may be made prior to the + Year One thousand eight hundred and eight shall in any Manner affect + the first and fourth Clauses in the Ninth Section of the first + Article; and that no State, without its Consent, shall be deprived of + its equal Suffrage in the Senate. + +Article. VI. + + Clause 1: All Debts contracted and Engagements entered into, before + the Adoption of this Constitution, shall be as valid against the + United States under this Constitution, as under the Confederation. + + Clause 2: This Constitution, and the Laws of the United States which + shall be made in Pursuance thereof; and all Treaties made, or which + shall be made, under the Authority of the United States, shall be the + supreme Law of the Land; and the Judges in every State shall be bound + thereby, any Thing in the Constitution or Laws of any State to the + Contrary notwithstanding. + + Clause 3: The Senators and Representatives before mentioned, and the + Members of the several State Legislatures, and all executive and + judicial Officers, both of the United States and of the several + States, shall be bound by Oath or Affirmation, to support this + Constitution; but no religious Test shall ever be required as a + Qualification to any Office or public Trust under the United States. + +Article. VII. + + The Ratification of the Conventions of nine States, shall be + sufficient for the Establishment of this Constitution between the + States so ratifying the Same. + + done in Convention by the Unanimous Consent of the States present the + Seventeenth Day of September in the Year of our Lord one thousand + seven hundred and Eighty seven and of the Independence of the United + States of America the Twelfth In witness whereof We have hereunto + subscribed our Names, + + GO WASHINGTON--Presidt. and deputy from Virginia + + [Signed also by the deputies of twelve States.] + + Delaware + + Geo: Read + Gunning Bedford jun + John Dickinson + Richard Bassett + Jaco: Broom + + Maryland + + James MCHenry + Dan of ST ThoS. Jenifer + DanL Carroll. + + Virginia + + John Blair-- + James Madison Jr. + + North Carolina + + WM Blount + RichD. Dobbs Spaight. + Hu Williamson + + South Carolina + + J. Rutledge + Charles 1ACotesworth Pinckney + Charles Pinckney + Pierce Butler. + + Georgia + + William Few + Abr Baldwin + + New Hampshire + + John Langdon + Nicholas Gilman + + Massachusetts + + Nathaniel Gorham + Rufus King + + Connecticut + WM. SamL. Johnson + Roger Sherman + + New York + + Alexander Hamilton + + New Jersey + + Wil: Livingston + David Brearley. + WM. Paterson. + Jona: Dayton + + Pennsylvania + + B Franklin + Thomas Mifflin + RobT Morris + Geo. Clymer + ThoS. FitzSimons + Jared Ingersoll + James Wilson. + Gouv Morris + + Attest William Jackson Secretary + + NOTES + + Note 1: This text of the Constitution follows the engrossed copy + signed by Gen. Washington and the deputies from 12 States. The small + superior figures preceding the paragraphs designate Clauses, and were + not in the original and have no reference to footnotes. + + The Constitution was adopted by a convention of the States on + September 17, 1787, and was subsequently ratified by the several + States, on the following dates: Delaware, December 7, 1787; + Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; + Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, + February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, + 1788; New Hampshire, June 21, 1788. + + Ratification was completed on June 21, 1788. + + The Constitution was subsequently ratified by Virginia, June 25, 1788; + New York, July 26, 1788; North Carolina, November 21, 1789; Rhode + Island, May 29, 1790; and Vermont, January 10, 1791. + + In May 1785, a committee of Congress made a report recommending an + alteration in the Articles of Confederation, but no action was taken + on it, and it was left to the State Legislatures to proceed in the + matter. In January 1786, the Legislature of Virginia passed a + resolution providing for the appointment of five commissioners, who, + or any three of them, should meet such commissioners as might be + appointed in the other States of the Union, at a time and place to be + agreed upon, to take into consideration the trade of the United + States; to consider how far a uniform system in their commercial + regulations may be necessary to their common interest and their + permanent harmony; and to report to the several States such an act, + relative to this great object, as, when ratified by them, will enable + the United States in Congress effectually to provide for the same. The + Virginia commissioners, after some correspondence, fixed the first + Monday in September as the time, and the city of Annapolis as the + place for the meeting, but only four other States were represented, + viz: Delaware, New York, New Jersey, and Pennsylvania; the + commissioners appointed by Massachusetts, New Hampshire, North + Carolina, and Rhode Island failed to attend. Under the circumstances + of so partial a representation, the commissioners present agreed upon + a report, (drawn by Mr. Hamilton, of New York,) expressing their + unanimous conviction that it might essentially tend to advance the + interests of the Union if the States by which they were respectively + delegated would concur, and use their endeavors to procure the + concurrence of the other States, in the appointment of commissioners + to meet at Philadelphia on the Second Monday of May following, to take + into consideration the situation of the United States; to devise such + further provisions as should appear to them necessary to render the + Constitution of the Federal Government adequate to the exigencies of + the Union; and to report such an act for that purpose to the United + States in Congress assembled as, when agreed to by them and afterwards + confirmed by the Legislatures of every State, would effectually + provide for the same. + + Congress, on the 21st of February, 1787, adopted a resolution in favor + of a convention, and the Legislatures of those States which had not + already done so (with the exception of Rhode Island) promptly + appointed delegates. On the 25th of May, seven States having convened, + George Washington, of Virginia, was unanimously elected President, and + the consideration of the proposed constitution was commenced. On the + 17th of September, 1787, the Constitution as engrossed and agreed upon + was signed by all the members present, except Mr. Gerry of + Massachusetts, and Messrs. Mason and Randolph, of Virginia. The + president of the convention transmitted it to Congress, with a + resolution stating how the proposed Federal Government should be put + in operation, and an explanatory letter. Congress, on the 28th of + September, 1787, directed the Constitution so framed, with the + resolutions and letter concerning the same, to "be transmitted to the + several Legislatures in order to be submitted to a convention of + delegates chosen in each State by the people thereof, in conformity to + the resolves of the convention." + + On the 4th of March, 1789, the day which had been fixed for commencing + the operations of Government under the new Constitution, it had been + ratified by the conventions chosen in each State to consider it, as + follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; + New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, + January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, + 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; + Virginia, June 25, 1788; and New York, July 26, 1788. + + The President informed Congress, on the 28th of January, 1790, that + North Carolina had ratified the Constitution November 21, 1789; and he + informed Congress on the 1st of June, 1790, that Rhode Island had + ratified the Constitution May 29, 1790. Vermont, in convention, + ratified the Constitution January 10, 1791, and was, by an act of + Congress approved February 18, 1791, "received and admitted into this + Union as a new and entire member of the United States." + + Note 2: The part of this Clause relating to the mode of apportionment + of representatives among the several States has been affected by + Section 2 of amendment XIV, and as to taxes on incomes without + apportionment by amendment XVI. + + Note 3: This Clause has been affected by Clause 1 of amendment XVII. + + Note 4: This Clause has been affected by Clause 2 of amendment XVIII. + + Note 5: This Clause has been affected by amendment XX. + + Note 6: This Clause has been affected by amendment XXVII. + + Note 7: This Clause has been affected by amendment XVI. + + Note 8: This Clause has been superseded by amendment XII. + + Note 9: This Clause has been affected by amendment XXV. + + Note 10: This Clause has been affected by amendment XI. + + Note 11: This Clause has been affected by amendment XIII. + + Note 12: The first ten amendments to the Constitution of the United + States (and two others, one of which failed of ratification and the + other which later became the 27th amendment) were proposed to the + legislatures of the several States by the First Congress on September + 25, 1789. The first ten amendments were ratified by the following + States, and the notifications of ratification by the Governors thereof + were successively communicated by the President to Congress: New + Jersey, November 20, 1789; Maryland, December 19, 1789; North + Carolina, December 22, 1789; South Carolina, January 19, 1790; New + Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, + February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, + 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. + + Ratification was completed on December 15, 1791. + + The amendments were subsequently ratified by the legislatures of + Massachusetts, March 2, 1939; Georgia, March 18, 1939; and + Connecticut, April 19, 1939. + + Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had + numbers assigned to them at the time of ratification. + + Note 14: This sentence has been superseded by section 3 of amendment + XX. + + Note 15: See amendment XIX and section 1 of amendment XXVI. + + Note 16: Repealed by section 1 of amendment XXI. + +References + + 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/alloc_extra_cpp.l b/tests/alloc_extra_cpp.l new file mode 100644 index 0000000..c974777 --- /dev/null +++ b/tests/alloc_extra_cpp.l @@ -0,0 +1,120 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A file to build "scanner.c". */ +/* This tests that we can use "yyextra". + We buffer all input into a growable array, then print it. + We run diff on the input and output. +*/ + +#include +#include +#include "config.h" + + +/* We'll store the entire input in this buffer, growing as necessary. */ +struct Check { + char foo; + char *bar; + char qux; +}; + +/* Save char into junk array at next position. */ +static void check_extra ( yyscan_t scanner ); + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap nodefault noinput +%option warn +%option extra-type="struct Check *" +%option reentrant +%option noyyalloc + + +%% + +.|\r|\n { check_extra (yyscanner); } + +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + struct Check check; + + check.foo = 'a'; + check.bar = NULL; + check.qux = 'z'; + + testlex_init_extra(&check, &scanner); + testset_in(stdin, scanner); + testset_out(stdout, scanner); + + /* Test to confirm that testalloc was called from + * testlex_init_extra with the testextra argument. + */ + check_extra(scanner); + + testlex(scanner); + + testlex_destroy(scanner); + return 0; +} + +void *testalloc(size_t size, yyscan_t scanner) +{ + struct Check *check; + check = testget_extra(scanner); + + if (!check->bar) + check->bar = "Hello World"; + + check_extra(scanner); + + return malloc(size); +} + +/* Save char into junk array at next position. */ +static void check_extra(yyscan_t scanner) +{ + struct Check *check; + check = testget_extra(scanner); + + if (check->foo != 'a') { + fprintf(stderr, "foo is not 'a'\n"); + exit(1); + } + if (strcmp(check->bar, "Hello World") != 0) { + fprintf(stderr, "bar is not Hello World\n"); + exit(1); + } + if (check->qux != 'z') { + fprintf(stderr, "qux is not 'z'\n"); + exit(1); + } +} diff --git a/tests/alloc_extra_cpp.txt b/tests/alloc_extra_cpp.txt new file mode 100644 index 0000000..243df29 --- /dev/null +++ b/tests/alloc_extra_cpp.txt @@ -0,0 +1,795 @@ + + THE UNITED STATES CONSTITUTION + _________________________________________________________________ + + (See Note 1) + + We the People of the United States, in Order to form a more perfect + Union, establish Justice, insure domestic Tranquility, provide for the + common defence, promote the general Welfare, and secure the Blessings + of Liberty to ourselves and our Posterity, do ordain and establish + this Constitution for the United States of America. + +Article. I. + + Section 1. + + All legislative Powers herein granted shall be vested in a Congress of + the United States, which shall consist of a Senate and House of + Representatives. + + Section. 2. + + Clause 1: The House of Representatives shall be composed of Members + chosen every second Year by the People of the several States, and the + Electors in each State shall have the Qualifications requisite for + Electors of the most numerous Branch of the State Legislature. + + Clause 2: No Person shall be a Representative who shall not have + attained to the Age of twenty five Years, and been seven Years a + Citizen of the United States, and who shall not, when elected, be an + Inhabitant of that State in which he shall be chosen. + + Clause 3: Representatives and direct Taxes shall be apportioned among + the several States which may be included within this Union, according + to their respective Numbers, which shall be determined by adding to + the whole Number of free Persons, including those bound to Service for + a Term of Years, and excluding Indians not taxed, three fifths of all + other Persons. (See Note 2) The actual Enumeration shall be made + within three Years after the first Meeting of the Congress of the + United States, and within every subsequent Term of ten Years, in such + Manner as they shall by Law direct. The Number of Representatives + shall not exceed one for every thirty Thousand, but each State shall + have at Least one Representative; and until such enumeration shall be + made, the State of New Hampshire shall be entitled to chuse three, + Massachusetts eight, Rhode-Island and Providence Plantations one, + Connecticut five, New-York six, New Jersey four, Pennsylvania eight, + Delaware one, Maryland six, Virginia ten, North Carolina five, South + Carolina five, and Georgia three. + + Clause 4: When vacancies happen in the Representation from any State, + the Executive Authority thereof shall issue Writs of Election to fill + such Vacancies. + + Clause 5: The House of Representatives shall chuse their Speaker and + other Officers; and shall have the sole Power of Impeachment. + + Section. 3. + + Clause 1: The Senate of the United States shall be composed of two + Senators from each State, chosen by the Legislature thereof, (See Note + 3) for six Years; and each Senator shall have one Vote. + + Clause 2: Immediately after they shall be assembled in Consequence of + the first Election, they shall be divided as equally as may be into + three Classes. The Seats of the Senators of the first Class shall be + vacated at the Expiration of the second Year, of the second Class at + the Expiration of the fourth Year, and of the third Class at the + Expiration of the sixth Year, so that one third may be chosen every + second Year; and if Vacancies happen by Resignation, or otherwise, + during the Recess of the Legislature of any State, the Executive + thereof may make temporary Appointments until the next Meeting of the + Legislature, which shall then fill such Vacancies. (See Note 4) + + Clause 3: No Person shall be a Senator who shall not have attained to + the Age of thirty Years, and been nine Years a Citizen of the United + States, and who shall not, when elected, be an Inhabitant of that + State for which he shall be chosen. + + Clause 4: The Vice President of the United States shall be President + of the Senate, but shall have no Vote, unless they be equally divided. + + Clause 5: The Senate shall chuse their other Officers, and also a + President pro tempore, in the Absence of the Vice President, or when + he shall exercise the Office of President of the United States. + + Clause 6: The Senate shall have the sole Power to try all + Impeachments. When sitting for that Purpose, they shall be on Oath or + Affirmation. When the President of the United States is tried, the + Chief Justice shall preside: And no Person shall be convicted without + the Concurrence of two thirds of the Members present. + + Clause 7: Judgment in Cases of Impeachment shall not extend further + than to removal from Office, and disqualification to hold and enjoy + any Office of honor, Trust or Profit under the United States: but the + Party convicted shall nevertheless be liable and subject to + Indictment, Trial, Judgment and Punishment, according to Law. + + Section. 4. + + Clause 1: The Times, Places and Manner of holding Elections for + Senators and Representatives, shall be prescribed in each State by the + Legislature thereof; but the Congress may at any time by Law make or + alter such Regulations, except as to the Places of chusing Senators. + + Clause 2: The Congress shall assemble at least once in every Year, and + such Meeting shall be on the first Monday in December, (See Note 5) + unless they shall by Law appoint a different Day. + + Section. 5. + + Clause 1: Each House shall be the Judge of the Elections, Returns and + Qualifications of its own Members, and a Majority of each shall + constitute a Quorum to do Business; but a smaller Number may adjourn + from day to day, and may be authorized to compel the Attendance of + absent Members, in such Manner, and under such Penalties as each House + may provide. + + Clause 2: Each House may determine the Rules of its Proceedings, + punish its Members for disorderly Behaviour, and, with the Concurrence + of two thirds, expel a Member. + + Clause 3: Each House shall keep a Journal of its Proceedings, and from + time to time publish the same, excepting such Parts as may in their + Judgment require Secrecy; and the Yeas and Nays of the Members of + either House on any question shall, at the Desire of one fifth of + those Present, be entered on the Journal. + + Clause 4: Neither House, during the Session of Congress, shall, + without the Consent of the other, adjourn for more than three days, + nor to any other Place than that in which the two Houses shall be + sitting. + + Section. 6. + + Clause 1: The Senators and Representatives shall receive a + Compensation for their Services, to be ascertained by Law, and paid + out of the Treasury of the United States. (See Note 6) They shall in + all Cases, except Treason, Felony and Breach of the Peace, + beprivileged from Arrest during their Attendance at the Session of + their respective Houses, and in going to and returning from the same; + and for any Speech or Debate in either House, they shall not be + questioned in any other Place. + + Clause 2: No Senator or Representative shall, during the Time for + which he was elected, be appointed to any civil Office under the + Authority of the United States, which shall have been created, or the + Emoluments whereof shall have been encreased during such time; and no + Person holding any Office under the United States, shall be a Member + of either House during his Continuance in Office. + + Section. 7. + + Clause 1: All Bills for raising Revenue shall originate in the House + of Representatives; but the Senate may propose or concur with + Amendments as on other Bills. + + Clause 2: Every Bill which shall have passed the House of + Representatives and the Senate, shall, before it become a Law, be + presented to the President of the United States; If he approve he + shall sign it, but if not he shall return it, with his Objections to + that House in which it shall have originated, who shall enter the + Objections at large on their Journal, and proceed to reconsider it. If + after such Reconsideration two thirds of that House shall agree to + pass the Bill, it shall be sent, together with the Objections, to the + other House, by which it shall likewise be reconsidered, and if + approved by two thirds of that House, it shall become a Law. But in + all such Cases the Votes of both Houses shall be determined by yeas + and Nays, and the Names of the Persons voting for and against the Bill + shall be entered on the Journal of each House respectively. If any + Bill shall not be returned by the President within ten Days (Sundays + excepted) after it shall have been presented to him, the Same shall be + a Law, in like Manner as if he had signed it, unless the Congress by + their Adjournment prevent its Return, in which Case it shall not be a + Law. + + Clause 3: Every Order, Resolution, or Vote to which the Concurrence of + the Senate and House of Representatives may be necessary (except on a + question of Adjournment) shall be presented to the President of the + United States; and before the Same shall take Effect, shall be + approved by him, or being disapproved by him, shall be repassed by two + thirds of the Senate and House of Representatives, according to the + Rules and Limitations prescribed in the Case of a Bill. + + Section. 8. + + Clause 1: The Congress shall have Power To lay and collect Taxes, + Duties, Imposts and Excises, to pay the Debts and provide for the + common Defence and general Welfare of the United States; but all + Duties, Imposts and Excises shall be uniform throughout the United + States; + + Clause 2: To borrow Money on the credit of the United States; + + Clause 3: To regulate Commerce with foreign Nations, and among the + several States, and with the Indian Tribes; + + Clause 4: To establish an uniform Rule of Naturalization, and uniform + Laws on the subject of Bankruptcies throughout the United States; + + Clause 5: To coin Money, regulate the Value thereof, and of foreign + Coin, and fix the Standard of Weights and Measures; + + Clause 6: To provide for the Punishment of counterfeiting the + Securities and current Coin of the United States; + + Clause 7: To establish Post Offices and post Roads; + + Clause 8: To promote the Progress of Science and useful Arts, by + securing for limited Times to Authors and Inventors the exclusive + Right to their respective Writings and Discoveries; + + Clause 9: To constitute Tribunals inferior to the supreme Court; + + Clause 10: To define and punish Piracies and Felonies committed on the + high Seas, and Offences against the Law of Nations; + + Clause 11: To declare War, grant Letters of Marque and Reprisal, and + make Rules concerning Captures on Land and Water; + + Clause 12: To raise and support Armies, but no Appropriation of Money + to that Use shall be for a longer Term than two Years; + + Clause 13: To provide and maintain a Navy; + + Clause 14: To make Rules for the Government and Regulation of the land + and naval Forces; + + Clause 15: To provide for calling forth the Militia to execute the + Laws of the Union, suppress Insurrections and repel Invasions; + + Clause 16: To provide for organizing, arming, and disciplining, the + Militia, and for governing such Part of them as may be employed in the + Service of the United States, reserving to the States respectively, + the Appointment of the Officers, and the Authority of training the + Militia according to the discipline prescribed by Congress; + + Clause 17: To exercise exclusive Legislation in all Cases whatsoever, + over such District (not exceeding ten Miles square) as may, byCession + of particular States, and the Acceptance of Congress, become the Seat + of the Government of the United States, and to exercise like Authority + over all Places purchased by the Consent of the Legislature of the + State in which the Same shall be, for the Erection of Forts, + Magazines, Arsenals, dock-Yards, and other needful Buildings;--And + + Clause 18: To make all Laws which shall be necessary and proper for + carrying into Execution the foregoing Powers, and all other Powers + vested by this Constitution in the Government of the United States, or + in any Department or Officer thereof. + + Section. 9. + + Clause 1: The Migration or Importation of such Persons as any of the + States now existing shall think proper to admit, shall not be + prohibited by the Congress prior to the Year one thousand eight + hundred and eight, but a Tax or duty may be imposed on such + Importation, not exceeding ten dollars for each Person. + + Clause 2: The Privilege of the Writ of Habeas Corpus shall not be + suspended, unless when in Cases of Rebellion or Invasion the public + Safety may require it. + + Clause 3: No Bill of Attainder or ex post facto Law shall be passed. + + Clause 4: No Capitation, or other direct, Tax shall be laid, unless in + Proportion to the Census or Enumeration herein before directed to be + taken. (See Note 7) + + Clause 5: No Tax or Duty shall be laid on Articles exported from any + State. + + Clause 6: No Preference shall be given by any Regulation of Commerce + or Revenue to the Ports of one State over those of another: nor shall + Vessels bound to, or from, one State, be obliged to enter, clear, or + pay Duties in another. + + Clause 7: No Money shall be drawn from the Treasury, but in + Consequence of Appropriations made by Law; and a regular Statement and + Account of the Receipts and Expenditures of all public Money shall be + published from time to time. + + Clause 8: No Title of Nobility shall be granted by the United States: + And no Person holding any Office of Profit or Trust under them, shall, + without the Consent of the Congress, accept of any present, Emolument, + Office, or Title, of any kind whatever, from any King, Prince, or + foreign State. + + Section. 10. + + Clause 1: No State shall enter into any Treaty, Alliance, or + Confederation; grant Letters of Marque and Reprisal; coin Money; emit + Bills of Credit; make any Thing but gold and silver Coin a Tender in + Payment of Debts; pass any Bill of Attainder, ex post facto Law, or + Law impairing the Obligation of Contracts, or grant any Title of + Nobility. + + Clause 2: No State shall, without the Consent of the Congress, lay any + Imposts or Duties on Imports or Exports, except what may be absolutely + necessary for executing it's inspection Laws: and the net Produce of + all Duties and Imposts, laid by any State on Imports or Exports, shall + be for the Use of the Treasury of the United States; and all such Laws + shall be subject to the Revision and Controul of the Congress. + + Clause 3: No State shall, without the Consent of Congress, lay any + Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter + into any Agreement or Compact with another State, or with a foreign + Power, or engage in War, unless actually invaded, or in such imminent + Danger as will not admit of delay. + +Article. II. + + Section. 1. + + Clause 1: The executive Power shall be vested in a President of the + United States of America. He shall hold his Office during the Term of + four Years, and, together with the Vice President, chosen for the same + Term, be elected, as follows + + Clause 2: Each State shall appoint, in such Manner as the Legislature + thereof may direct, a Number of Electors, equal to the whole Number of + Senators and Representatives to which the State may be entitled in the + Congress: but no Senator or Representative, or Person holding an + Office of Trust or Profit under the United States, shall be appointed + an Elector. + + Clause 3: The Electors shall meet in their respective States, and vote + by Ballot for two Persons, of whom one at least shall not be an + Inhabitant of the same State with themselves. And they shall make a + List of all the Persons voted for, and of the Number of Votes for + each; which List they shall sign and certify, and transmit sealed to + the Seat of the Government of the United States, directed to the + President of the Senate. The President of the Senate shall, in the + Presence of the Senate and House of Representatives, open all the + Certificates, and the Votes shall then be counted. The Person having + the greatest Number of Votes shall be the President, if such Number be + a Majority of the whole Number of Electors appointed; and if there be + more than one who have such Majority, and have an equal Number of + Votes, then the House of Representatives shall immediately chuse by + Ballot one of them for President; and if no Person have a Majority, + then from the five highest on the List the said House shall in like + Manner chuse the President. But in chusing the President, the Votes + shall be taken by States, the Representation from each State having + one Vote; A quorum for this Purpose shall consist of a Member or + Members from two thirds of the States, and a Majority of all the + States shall be necessary to a Choice. In every Case, after the Choice + of the President, the Person having the greatest Number of Votes of + the Electors shall be the Vice President. But if there should remain + two or more who have equal Votes, the Senate shall chuse from them by + Ballot the Vice President. (See Note 8) + + Clause 4: The Congress may determine the Time of chusing the Electors, + and the Day on which they shall give their Votes; which Day shall be + the same throughout the United States. + + Clause 5: No Person except a natural born Citizen, or a Citizen of the + United States, at the time of the Adoption of this Constitution, shall + be eligible to the Office of President; neither shall any Person be + eligible to that Office who shall not have attained to the Age of + thirty five Years, and been fourteen Years a Resident within the + United States. + + Clause 6: In Case of the Removal of the President from Office, or of + his Death, Resignation, or Inability to discharge the Powers and + Duties of the said Office, (See Note 9) the Same shall devolve on the + VicePresident, and the Congress may by Law provide for the Case of + Removal, Death, Resignation or Inability, both of the President and + Vice President, declaring what Officer shall then act as President, + and such Officer shall act accordingly, until the Disability be + removed, or a President shall be elected. + + Clause 7: The President shall, at stated Times, receive for his + Services, a Compensation, which shall neither be encreased nor + diminished during the Period for which he shall have been elected, and + he shall not receive within that Period any other Emolument from the + United States, or any of them. + + Clause 8: Before he enter on the Execution of his Office, he shall + take the following Oath or Affirmation:--"I do solemnly swear (or + affirm) that I will faithfully execute the Office of President of the + United States, and will to the best of my Ability, preserve, protect + and defend the Constitution of the United States." + + Section. 2. + + Clause 1: The President shall be Commander in Chief of the Army and + Navy of the United States, and of the Militia of the several States, + when called into the actual Service of the United States; he may + require the Opinion, in writing, of the principal Officer in each of + the executive Departments, upon any Subject relating to the Duties of + their respective Offices, and he shall have Power to grant Reprieves + and Pardons for Offences against the United States, except in Cases of + Impeachment. + + Clause 2: He shall have Power, by and with the Advice and Consent of + the Senate, to make Treaties, provided two thirds of the Senators + present concur; and he shall nominate, and by and with the Advice and + Consent of the Senate, shall appoint Ambassadors, other public + Ministers and Consuls, Judges of the supreme Court, and all other + Officers of the United States, whose Appointments are not herein + otherwise provided for, and which shall be established by Law: but the + Congress may by Law vest the Appointment of such inferior Officers, as + they think proper, in the President alone, in the Courts of Law, or in + the Heads of Departments. + + Clause 3: The President shall have Power to fill up all Vacancies that + may happen during the Recess of the Senate, by granting Commissions + which shall expire at the End of their next Session. + + Section. 3. + + He shall from time to time give to the Congress Information of the + State of the Union, and recommend to their Consideration such Measures + as he shall judge necessary and expedient; he may, on extraordinary + Occasions, convene both Houses, or either of them, and in Case of + Disagreement between them, with Respect to the Time of Adjournment, he + may adjourn them to such Time as he shall think proper; he shall + receive Ambassadors and other public Ministers; he shall take Care + that the Laws be faithfully executed, and shall Commission all the + Officers of the United States. + + Section. 4. + + The President, Vice President and all civil Officers of the United + States, shall be removed from Office on Impeachment for, and + Conviction of, Treason, Bribery, or other high Crimes and + Misdemeanors. + +Article. III. + + Section. 1. + + The judicial Power of the United States, shall be vested in one + supreme Court, and in such inferior Courts as the Congress may from + time to time ordain and establish. The Judges, both of the supreme and + inferior Courts, shall hold their Offices during good Behaviour, and + shall, at stated Times, receive for their Services, a Compensation, + which shall not be diminished during their Continuance in Office. + + Section. 2. + + Clause 1: The judicial Power shall extend to all Cases, in Law and + Equity, arising under this Constitution, the Laws of the United + States, and Treaties made, or which shall be made, under their + Authority;--to all Cases affecting Ambassadors, other public Ministers + and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to + Controversies to which the United States shall be a Party;--to + Controversies between two or more States;--between a State and + Citizens of another State; (See Note 10)--between Citizens of + different States, --between Citizens of the same State claiming Lands + under Grants of different States, and between a State, or the Citizens + thereof, and foreign States, Citizens or Subjects. + + Clause 2: In all Cases affecting Ambassadors, other public Ministers + and Consuls, and those in which a State shall be Party, the supreme + Court shall have original Jurisdiction. In all the other Cases before + mentioned, the supreme Court shall have appellate Jurisdiction, both + as to Law and Fact, with such Exceptions, and under such Regulations + as the Congress shall make. + + Clause 3: The Trial of all Crimes, except in Cases of Impeachment, + shall be by Jury; and such Trial shall be held in the State where the + said Crimes shall have been committed; but when not committed within + any State, the Trial shall be at such Place or Places as the Congress + may by Law have directed. + + Section. 3. + + Clause 1: Treason against the United States, shall consist only in + levying War against them, or in adhering to their Enemies, giving them + Aid and Comfort. No Person shall be convicted of Treason unless on the + Testimony of two Witnesses to the same overt Act, or on Confession in + open Court. + + Clause 2: The Congress shall have Power to declare the Punishment of + Treason, but no Attainder of Treason shall work Corruption of Blood, + or Forfeiture except during the Life of the Person attainted. + +Article. IV. + + Section. 1. + + Full Faith and Credit shall be given in each State to the public Acts, + Records, and judicial Proceedings of every other State. And the + Congress may by general Laws prescribe the Manner in which such Acts, + Records and Proceedings shall be proved, and the Effect thereof. + + Section. 2. + + Clause 1: The Citizens of each State shall be entitled to all + Privileges and Immunities of Citizens in the several States. + + Clause 2: A Person charged in any State with Treason, Felony, or other + Crime, who shall flee from Justice, and be found in another State, + shall on Demand of the executive Authority of the State from which he + fled, be delivered up, to be removed to the State having Jurisdiction + of the Crime. + + Clause 3: No Person held to Service or Labour in one State, under the + Laws thereof, escaping into another, shall, in Consequence of any Law + or Regulation therein, be discharged from such Service or Labour, but + shall be delivered up on Claim of the Party to whom such Service or + Labour may be due. (See Note 11) + + Section. 3. + + Clause 1: New States may be admitted by the Congress into this Union; + but no new State shall be formed or erected within the Jurisdiction of + any other State; nor any State be formed by the Junction of two or + more States, or Parts of States, without the Consent of the + Legislatures of the States concerned as well as of the Congress. + + Clause 2: The Congress shall have Power to dispose of and make all + needful Rules and Regulations respecting the Territory or other + Property belonging to the United States; and nothing in this + Constitution shall be so construed as to Prejudice any Claims of the + United States, or of any particular State. + + Section. 4. + + The United States shall guarantee to every State in this Union a + Republican Form of Government, and shall protect each of them against + Invasion; and on Application of the Legislature, or of the Executive + (when the Legislature cannot be convened) against domestic Violence. + +Article. V. + + The Congress, whenever two thirds of both Houses shall deem it + necessary, shall propose [1]Amendments to this Constitution, or, on + the Application of the Legislatures of two thirds of the several + States, shall call a Convention for proposing Amendments, which, in + either Case, shall be valid to all Intents and Purposes, as Part of + this Constitution, when ratified by the Legislatures of three fourths + of the several States, or by Conventions in three fourths thereof, as + the one or the other Mode of Ratification may be proposed by the + Congress; Provided that no Amendment which may be made prior to the + Year One thousand eight hundred and eight shall in any Manner affect + the first and fourth Clauses in the Ninth Section of the first + Article; and that no State, without its Consent, shall be deprived of + its equal Suffrage in the Senate. + +Article. VI. + + Clause 1: All Debts contracted and Engagements entered into, before + the Adoption of this Constitution, shall be as valid against the + United States under this Constitution, as under the Confederation. + + Clause 2: This Constitution, and the Laws of the United States which + shall be made in Pursuance thereof; and all Treaties made, or which + shall be made, under the Authority of the United States, shall be the + supreme Law of the Land; and the Judges in every State shall be bound + thereby, any Thing in the Constitution or Laws of any State to the + Contrary notwithstanding. + + Clause 3: The Senators and Representatives before mentioned, and the + Members of the several State Legislatures, and all executive and + judicial Officers, both of the United States and of the several + States, shall be bound by Oath or Affirmation, to support this + Constitution; but no religious Test shall ever be required as a + Qualification to any Office or public Trust under the United States. + +Article. VII. + + The Ratification of the Conventions of nine States, shall be + sufficient for the Establishment of this Constitution between the + States so ratifying the Same. + + done in Convention by the Unanimous Consent of the States present the + Seventeenth Day of September in the Year of our Lord one thousand + seven hundred and Eighty seven and of the Independence of the United + States of America the Twelfth In witness whereof We have hereunto + subscribed our Names, + + GO WASHINGTON--Presidt. and deputy from Virginia + + [Signed also by the deputies of twelve States.] + + Delaware + + Geo: Read + Gunning Bedford jun + John Dickinson + Richard Bassett + Jaco: Broom + + Maryland + + James MCHenry + Dan of ST ThoS. Jenifer + DanL Carroll. + + Virginia + + John Blair-- + James Madison Jr. + + North Carolina + + WM Blount + RichD. Dobbs Spaight. + Hu Williamson + + South Carolina + + J. Rutledge + Charles 1ACotesworth Pinckney + Charles Pinckney + Pierce Butler. + + Georgia + + William Few + Abr Baldwin + + New Hampshire + + John Langdon + Nicholas Gilman + + Massachusetts + + Nathaniel Gorham + Rufus King + + Connecticut + WM. SamL. Johnson + Roger Sherman + + New York + + Alexander Hamilton + + New Jersey + + Wil: Livingston + David Brearley. + WM. Paterson. + Jona: Dayton + + Pennsylvania + + B Franklin + Thomas Mifflin + RobT Morris + Geo. Clymer + ThoS. FitzSimons + Jared Ingersoll + James Wilson. + Gouv Morris + + Attest William Jackson Secretary + + NOTES + + Note 1: This text of the Constitution follows the engrossed copy + signed by Gen. Washington and the deputies from 12 States. The small + superior figures preceding the paragraphs designate Clauses, and were + not in the original and have no reference to footnotes. + + The Constitution was adopted by a convention of the States on + September 17, 1787, and was subsequently ratified by the several + States, on the following dates: Delaware, December 7, 1787; + Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; + Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, + February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, + 1788; New Hampshire, June 21, 1788. + + Ratification was completed on June 21, 1788. + + The Constitution was subsequently ratified by Virginia, June 25, 1788; + New York, July 26, 1788; North Carolina, November 21, 1789; Rhode + Island, May 29, 1790; and Vermont, January 10, 1791. + + In May 1785, a committee of Congress made a report recommending an + alteration in the Articles of Confederation, but no action was taken + on it, and it was left to the State Legislatures to proceed in the + matter. In January 1786, the Legislature of Virginia passed a + resolution providing for the appointment of five commissioners, who, + or any three of them, should meet such commissioners as might be + appointed in the other States of the Union, at a time and place to be + agreed upon, to take into consideration the trade of the United + States; to consider how far a uniform system in their commercial + regulations may be necessary to their common interest and their + permanent harmony; and to report to the several States such an act, + relative to this great object, as, when ratified by them, will enable + the United States in Congress effectually to provide for the same. The + Virginia commissioners, after some correspondence, fixed the first + Monday in September as the time, and the city of Annapolis as the + place for the meeting, but only four other States were represented, + viz: Delaware, New York, New Jersey, and Pennsylvania; the + commissioners appointed by Massachusetts, New Hampshire, North + Carolina, and Rhode Island failed to attend. Under the circumstances + of so partial a representation, the commissioners present agreed upon + a report, (drawn by Mr. Hamilton, of New York,) expressing their + unanimous conviction that it might essentially tend to advance the + interests of the Union if the States by which they were respectively + delegated would concur, and use their endeavors to procure the + concurrence of the other States, in the appointment of commissioners + to meet at Philadelphia on the Second Monday of May following, to take + into consideration the situation of the United States; to devise such + further provisions as should appear to them necessary to render the + Constitution of the Federal Government adequate to the exigencies of + the Union; and to report such an act for that purpose to the United + States in Congress assembled as, when agreed to by them and afterwards + confirmed by the Legislatures of every State, would effectually + provide for the same. + + Congress, on the 21st of February, 1787, adopted a resolution in favor + of a convention, and the Legislatures of those States which had not + already done so (with the exception of Rhode Island) promptly + appointed delegates. On the 25th of May, seven States having convened, + George Washington, of Virginia, was unanimously elected President, and + the consideration of the proposed constitution was commenced. On the + 17th of September, 1787, the Constitution as engrossed and agreed upon + was signed by all the members present, except Mr. Gerry of + Massachusetts, and Messrs. Mason and Randolph, of Virginia. The + president of the convention transmitted it to Congress, with a + resolution stating how the proposed Federal Government should be put + in operation, and an explanatory letter. Congress, on the 28th of + September, 1787, directed the Constitution so framed, with the + resolutions and letter concerning the same, to "be transmitted to the + several Legislatures in order to be submitted to a convention of + delegates chosen in each State by the people thereof, in conformity to + the resolves of the convention." + + On the 4th of March, 1789, the day which had been fixed for commencing + the operations of Government under the new Constitution, it had been + ratified by the conventions chosen in each State to consider it, as + follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; + New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, + January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, + 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; + Virginia, June 25, 1788; and New York, July 26, 1788. + + The President informed Congress, on the 28th of January, 1790, that + North Carolina had ratified the Constitution November 21, 1789; and he + informed Congress on the 1st of June, 1790, that Rhode Island had + ratified the Constitution May 29, 1790. Vermont, in convention, + ratified the Constitution January 10, 1791, and was, by an act of + Congress approved February 18, 1791, "received and admitted into this + Union as a new and entire member of the United States." + + Note 2: The part of this Clause relating to the mode of apportionment + of representatives among the several States has been affected by + Section 2 of amendment XIV, and as to taxes on incomes without + apportionment by amendment XVI. + + Note 3: This Clause has been affected by Clause 1 of amendment XVII. + + Note 4: This Clause has been affected by Clause 2 of amendment XVIII. + + Note 5: This Clause has been affected by amendment XX. + + Note 6: This Clause has been affected by amendment XXVII. + + Note 7: This Clause has been affected by amendment XVI. + + Note 8: This Clause has been superseded by amendment XII. + + Note 9: This Clause has been affected by amendment XXV. + + Note 10: This Clause has been affected by amendment XI. + + Note 11: This Clause has been affected by amendment XIII. + + Note 12: The first ten amendments to the Constitution of the United + States (and two others, one of which failed of ratification and the + other which later became the 27th amendment) were proposed to the + legislatures of the several States by the First Congress on September + 25, 1789. The first ten amendments were ratified by the following + States, and the notifications of ratification by the Governors thereof + were successively communicated by the President to Congress: New + Jersey, November 20, 1789; Maryland, December 19, 1789; North + Carolina, December 22, 1789; South Carolina, January 19, 1790; New + Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, + February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, + 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. + + Ratification was completed on December 15, 1791. + + The amendments were subsequently ratified by the legislatures of + Massachusetts, March 2, 1939; Georgia, March 18, 1939; and + Connecticut, April 19, 1939. + + Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had + numbers assigned to them at the time of ratification. + + Note 14: This sentence has been superseded by section 3 of amendment + XX. + + Note 15: See amendment XIX and section 1 of amendment XXVI. + + Note 16: Repealed by section 1 of amendment XXI. + +References + + 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/array_c99.l b/tests/array_c99.l new file mode 100644 index 0000000..99f2a02 --- /dev/null +++ b/tests/array_c99.l @@ -0,0 +1,63 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +/*#include "parser.h" */ + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn array reentrant + + +%% + +.|\n { } + + +%% + +int main(void); + +int +main (void) +{ + yyscan_t lexer; + + yylex_init(&lexer); + yyset_in(stdin, lexer); + yyset_out(stdout, lexer); + + yylex( lexer ); + + yylex_destroy( lexer); + printf("TEST RETURNING OK.\n"); + + return 0; +} diff --git a/tests/array_c99.txt b/tests/array_c99.txt new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/array_c99.txt @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/ccl.l b/tests/ccl.l deleted file mode 100644 index 9511604..0000000 --- a/tests/ccl.l +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) -#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); -^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); - -^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"check-a:"(?i:(?-i:A))@\n err_abort(); -^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); -^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); - -^"x1:"(?x: a | b )+@x1@\n a_ok(); -^"x2:"(?x: a | - (?# Comment ) - b - )+@x2@\n a_ok(); - - -.|\n { err_abort(); } -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/ccl.txt b/tests/ccl.txt deleted file mode 100644 index b318fe6..0000000 --- a/tests/ccl.txt +++ /dev/null @@ -1,27 +0,0 @@ -^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ -^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ -^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ -^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ -^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ -^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ -^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ -^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ -^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ -^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ -a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ -l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ -abcd-bc:aaaaddddaaaa@abcd-bc@ -abcde-b-c:aaaaddddeeee@abcde-b-c@ -^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ -a+d:abc0123xyz789@a+d@ -a-u+Q:abcQQQQxyz@a-u+Q@ -ia:AaAa@ia@ -iabc:ABCabcAbCaBc@iabc@ -ia-c:ABCabcAbCaBc@ia-c@ -check-a:a@ -dot-all-1:XXX junk - junk - junk - @dot-all-1@ -x1:abaabb@x1@ -x2:abaabb@x2@ diff --git a/tests/ccl_c99.l b/tests/ccl_c99.l new file mode 100644 index 0000000..9511604 --- /dev/null +++ b/tests/ccl_c99.l @@ -0,0 +1,95 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +/*#include "parser.h" */ + +#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) +#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; + +^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; + +^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); +^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); + +^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; + + /* We don't want this one to match. */ +^"check-a:"(?i:(?-i:A))@\n err_abort(); +^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; + + /* We don't want this one to match. */ +^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); +^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); + +^"x1:"(?x: a | b )+@x1@\n a_ok(); +^"x2:"(?x: a | + (?# Comment ) + b + )+@x2@\n a_ok(); + + +.|\n { err_abort(); } +%% + +int main(void); + +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/ccl_c99.txt b/tests/ccl_c99.txt new file mode 100644 index 0000000..b318fe6 --- /dev/null +++ b/tests/ccl_c99.txt @@ -0,0 +1,27 @@ +^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ +^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ +^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ +^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ +^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ +^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ +^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ +^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ +^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ +^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ +a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ +l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ +abcd-bc:aaaaddddaaaa@abcd-bc@ +abcde-b-c:aaaaddddeeee@abcde-b-c@ +^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ +a+d:abc0123xyz789@a+d@ +a-u+Q:abcQQQQxyz@a-u+Q@ +ia:AaAa@ia@ +iabc:ABCabcAbCaBc@iabc@ +ia-c:ABCabcAbCaBc@ia-c@ +check-a:a@ +dot-all-1:XXX junk + junk + junk + @dot-all-1@ +x1:abaabb@x1@ +x2:abaabb@x2@ diff --git a/tests/ccl_cpp.l b/tests/ccl_cpp.l new file mode 100644 index 0000000..1894b4c --- /dev/null +++ b/tests/ccl_cpp.l @@ -0,0 +1,96 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +/*#include "parser.h" */ + +#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) +#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; + +^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; + +^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); +^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); + +^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; + + /* We don't want this one to match. */ +^"check-a:"(?i:(?-i:A))@\n err_abort(); +^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; + + /* We don't want this one to match. */ +^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); +^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); + +^"x1:"(?x: a | b )+@x1@\n a_ok(); +^"x2:"(?x: a | + (?# Comment ) + b + )+@x2@\n a_ok(); + + +.|\n { err_abort(); } +%% + +int main(void); + +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/ccl_cpp.txt b/tests/ccl_cpp.txt new file mode 100644 index 0000000..b318fe6 --- /dev/null +++ b/tests/ccl_cpp.txt @@ -0,0 +1,27 @@ +^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ +^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ +^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ +^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ +^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ +^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ +^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ +^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ +^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ +^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ +a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ +l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ +abcd-bc:aaaaddddaaaa@abcd-bc@ +abcde-b-c:aaaaddddeeee@abcde-b-c@ +^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ +a+d:abc0123xyz789@a+d@ +a-u+Q:abcQQQQxyz@a-u+Q@ +ia:AaAa@ia@ +iabc:ABCabcAbCaBc@iabc@ +ia-c:ABCabcAbCaBc@ia-c@ +check-a:a@ +dot-all-1:XXX junk + junk + junk + @dot-all-1@ +x1:abaabb@x1@ +x2:abaabb@x2@ diff --git a/tests/debug_c99.l b/tests/debug_c99.l new file mode 100644 index 0000000..2bc01fb --- /dev/null +++ b/tests/debug_c99.l @@ -0,0 +1,60 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn debug reentrant + +%% +.+ { } +\n { } +%% + +int main(void); + +int main (void) +{ + yyscan_t lexer; + testlex_init( &lexer ); + testset_out ( stdout,lexer); + testset_in ( stdin, lexer); + + /* Just see if the next line compiles. */ + testset_debug (testget_debug(lexer), lexer); + + while( testlex(lexer) ) + { + } + testlex_destroy( lexer ); + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/debug_c99.txt b/tests/debug_c99.txt new file mode 100644 index 0000000..8d6476c --- /dev/null +++ b/tests/debug_c99.txt @@ -0,0 +1,2 @@ +Any input will do for this test. +We are only testing if it actually runs in debug mode. -- cgit v1.2.1 From e6931c9f6c896aed55ab503f316c7551bc783975 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 11:56:13 -0400 Subject: Docunent the -e/--emit backend switch and the new test convention. --- doc/flex.texi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/flex.texi b/doc/flex.texi index 2f59179..7187569 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -2696,6 +2696,20 @@ the serialized tables match the in-code tables, instead of loading them. @section Options Affecting Scanner Behavior @table @samp +@anchor{option-emit} +@opindex -e +@opindex ---emit +@opindex emit +@item -e, --emit, @code{%option emit} +instructs @code{flex} to generate code using a specific back end other +than the default. The default is called ``cpp',' generates C or C++, +supports all legacy interfaces, and generates either non-reentrant or +re-entrant scanners. There is presently one alternate back end, C99; +it drops a lot of legacy interfaces and generates only re-entrant +scanners in modern C. The C99 back end is intended to be a launch +polnt for as yet nonexistent back ends generating distinct other +languges such as Go, Rust, Java, or Python. + @anchor{option-case-insensitive} @opindex -i @opindex ---case-insensitive @@ -2708,7 +2722,6 @@ text given in @code{yytext} will have the preserved case (i.e., it will not be folded). For tricky behavior, see @ref{case and character ranges}. - @anchor{option-lex-compat} @opindex -l @opindex ---lex-compat -- cgit v1.2.1 From 3290c37223e5deb896c72578926e5d2e58b37689 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 12:07:22 -0400 Subject: Actually *commit* the documentation on test conventions. --- tests/README | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/tests/README b/tests/README index f1b9ba0..49e8e12 100644 --- a/tests/README +++ b/tests/README @@ -8,14 +8,19 @@ this directory and its contents. * STRUCTURE OF THE TEST SUITE -The testsuite consists of several tests. Each test is centered around -a scanner known to work with the most recent version of flex. In -general, after you modify your copy of the flex distribution, you -should re-run the test suite. Some of the tests may require certain -tools to be available (e.g., bison, diff). If any test returns an -error or generates an error message, then your modifications *may* -have broken a feature of flex. At a minimum, you'll want to -investigate the failure and determine if it's truly significant. +The testsuite consists of a large number of tests. Usually the test is +simply that a sanner consumes all the token fed to it firom a text +(.txt) file in a maxhing grammer, not allowing stray characters to +echo through to stdout. This is how we avoid meeding explicit check files. + +Each test is centered around a scanner known to work with the most +recent version of flex. In general, after you modify your copy of the +flex distribution, you should re-run the test suite. Some of the tests +may require certain tools to be available (e.g., bison, diff). If any +test returns an error or generates an error message, then your +modifications *may* have broken a feature of flex. At a minimum, +you'll want to investigate the failure and determine if it's truly +significant. * HOW TO RUN THE TEST SUITE @@ -39,7 +44,8 @@ To build and execute a single test: variables to group similar tests together. This also helps with handling the automake test suite requirements. Hopefully your test can be listed in SIMPLE_TESTS. You'll need to add the appropriate - automake _SOURCES variable as well. If you're unsure, then consult + automake _SOURCES variable as well, and .gitignore lines for the + binary and generated code. If you're unsure, then consult the automake manual, paying attention to the parallel test harness section. @@ -56,3 +62,26 @@ automake test suite harness. ** Once your work is done, submit a patch via the flex development mailing list, the github pull request mechanism or some other suitable means. + +* NAMING CONVENTIONS + +A test with a _nr suffix exercises a non-reentrant xanner built +with the default cpp back end. + +uA test with a _r suffix exercises a reentrant xanner built +with the default cpp back end. + +A test with a c99 suffix exercises the c99 back end. All C99 +acanners are re-entrant. + +A tesrt with a _cpp suffix exercises the default cpp back end on a +specification where the reentra=t/non-reentrant distinction is +not interesting. + +Most tests occur in groups with a common stem in the names, like +alloc_extra_ or ccl_. These are exercising the same token grammar +under different back ends. As mre target languages are added these +groups of patallel tests will grow. Tests that are not part of one of +these series are usually of features supported on the default cpp +back end only. + -- cgit v1.2.1 From 4615b6420cb941b382ab7673c8a6806cd8394632 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 12:27:07 -0400 Subject: extended -> etended_cpp. --- tests/.gitignore | 4 +-- tests/Makefile.am | 8 +++--- tests/extended.l | 73 -------------------------------------------------- tests/extended.txt | 2 -- tests/extended_cpp.l | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/extended_cpp.txt | 2 ++ 6 files changed, 81 insertions(+), 81 deletions(-) delete mode 100644 tests/extended.l delete mode 100644 tests/extended.txt create mode 100644 tests/extended_cpp.l create mode 100644 tests/extended_cpp.txt diff --git a/tests/.gitignore b/tests/.gitignore index af3cf7c..c6a2058 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -49,8 +49,8 @@ debug_r debug_r.c debug_c99 debug_c99.c -extended -extended.c +extended_cpp +extended_cpp.c header_nr header_nr_scanner.[ch] header_r diff --git a/tests/Makefile.am b/tests/Makefile.am index be9541a..4b28c3c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -82,7 +82,7 @@ simple_tests = \ debug_nr \ debug_r \ debug_c99 \ - extended \ + extended_cpp \ header_nr \ header_r \ mem_nr \ @@ -158,7 +158,7 @@ cxx_yywrap_i3_SOURCES = cxx_yywrap.ll debug_nr_SOURCES = debug_nr.l debug_r_SOURCES = debug_r.l debug_c99_SOURCES = debug_c99.l -extended_SOURCES = extended.l +extended_cpp_SOURCES = extended_cpp.l header_nr_SOURCES = header_nr_scanner.l header_nr_main.c nodist_header_nr_SOURCES = header_nr_scanner.h header_r_SOURCES = header_r_scanner.l header_r_main.c @@ -234,7 +234,7 @@ CLEANFILES = \ debug_nr.c \ debug_r.c \ debug_c99.c \ - extended.c \ + extended_cpp.c \ header_nr_scanner.c \ header_nr_scanner.h \ header_r_scanner.c \ @@ -306,7 +306,7 @@ EXTRA_DIST = \ debug_nr.txt \ debug_r.txt \ debug_c99.txt \ - extended.txt \ + extended_cpp.txt \ header_nr.txt \ header_r.txt \ include_by_buffer.direct.txt \ diff --git a/tests/extended.l b/tests/extended.l deleted file mode 100644 index 9691307..0000000 --- a/tests/extended.l +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* This test is for correctness of extended (?...) patterns. */ - -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - - /* Output should match the input. */ - -abc(?# Single Line Comment )def ECHO; -ghi(?# - multi-line - comment - )jkl ECHO; - -mno(?# - multi-line // - comment with ## - ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; - punctuation - )pqr ECHO; -(?# Start of a rule.)stu ECHO; -vwxyz(?#End of a rule.) ECHO; -A(?x: B - /* comment */ - C D) ECHO; - -\n ECHO; -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - yylex(); - //printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/extended.txt b/tests/extended.txt deleted file mode 100644 index 829e23d..0000000 --- a/tests/extended.txt +++ /dev/null @@ -1,2 +0,0 @@ -abcdefghijklmnopqrstuvwxyz -ABCD diff --git a/tests/extended_cpp.l b/tests/extended_cpp.l new file mode 100644 index 0000000..9691307 --- /dev/null +++ b/tests/extended_cpp.l @@ -0,0 +1,73 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* This test is for correctness of extended (?...) patterns. */ + +#include +#include +#include "config.h" + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + + /* Output should match the input. */ + +abc(?# Single Line Comment )def ECHO; +ghi(?# + multi-line + comment + )jkl ECHO; + +mno(?# + multi-line // + comment with ## + ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; + punctuation + )pqr ECHO; +(?# Start of a rule.)stu ECHO; +vwxyz(?#End of a rule.) ECHO; +A(?x: B + /* comment */ + C D) ECHO; + +\n ECHO; +%% + +int main(void); + +int +main (void) +{ + yyin = stdin; + yyout = stdout; + yylex(); + //printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/extended_cpp.txt b/tests/extended_cpp.txt new file mode 100644 index 0000000..829e23d --- /dev/null +++ b/tests/extended_cpp.txt @@ -0,0 +1,2 @@ +abcdefghijklmnopqrstuvwxyz +ABCD -- cgit v1.2.1 From 9a4495add564cc8784ffc616ed651da83fcd365e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 12:34:58 -0400 Subject: Added exteded_c00 test. --- tests/.gitignore | 2 ++ tests/Makefile.am | 4 +++ tests/extended_c99.l | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/extended_c99.txt | 2 ++ 4 files changed, 82 insertions(+) create mode 100644 tests/extended_c99.l create mode 100644 tests/extended_c99.txt diff --git a/tests/.gitignore b/tests/.gitignore index c6a2058..a5441c3 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -51,6 +51,8 @@ debug_c99 debug_c99.c extended_cpp extended_cpp.c +extended_c99 +extended_c99.c header_nr header_nr_scanner.[ch] header_r diff --git a/tests/Makefile.am b/tests/Makefile.am index 4b28c3c..0d01cd8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -83,6 +83,7 @@ simple_tests = \ debug_r \ debug_c99 \ extended_cpp \ + extended_c99 \ header_nr \ header_r \ mem_nr \ @@ -159,6 +160,7 @@ debug_nr_SOURCES = debug_nr.l debug_r_SOURCES = debug_r.l debug_c99_SOURCES = debug_c99.l extended_cpp_SOURCES = extended_cpp.l +extended_c99_SOURCES = extended_c99.l header_nr_SOURCES = header_nr_scanner.l header_nr_main.c nodist_header_nr_SOURCES = header_nr_scanner.h header_r_SOURCES = header_r_scanner.l header_r_main.c @@ -235,6 +237,7 @@ CLEANFILES = \ debug_r.c \ debug_c99.c \ extended_cpp.c \ + extended_c99.c \ header_nr_scanner.c \ header_nr_scanner.h \ header_r_scanner.c \ @@ -307,6 +310,7 @@ EXTRA_DIST = \ debug_r.txt \ debug_c99.txt \ extended_cpp.txt \ + extended_c99.txt \ header_nr.txt \ header_r.txt \ include_by_buffer.direct.txt \ diff --git a/tests/extended_c99.l b/tests/extended_c99.l new file mode 100644 index 0000000..5b47b5c --- /dev/null +++ b/tests/extended_c99.l @@ -0,0 +1,74 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* This test is for correctness of extended (?...) patterns. */ + +#include +#include +#include "config.h" + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + + /* Output should match the input. */ + +abc(?# Single Line Comment )def ECHO; +ghi(?# + multi-line + comment + )jkl ECHO; + +mno(?# + multi-line // + comment with ## + ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; + punctuation + )pqr ECHO; +(?# Start of a rule.)stu ECHO; +vwxyz(?#End of a rule.) ECHO; +A(?x: B + /* comment */ + C D) ECHO; + +\n ECHO; +%% + +int main(void); + +int +main (void) +{ + yyin = stdin; + yyout = stdout; + yylex(); + //printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/extended_c99.txt b/tests/extended_c99.txt new file mode 100644 index 0000000..829e23d --- /dev/null +++ b/tests/extended_c99.txt @@ -0,0 +1,2 @@ +abcdefghijklmnopqrstuvwxyz +ABCD -- cgit v1.2.1 From f07c52fdc5273edf3c8fbd0c16d780f8c9900e5e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 14:07:03 -0400 Subject: Fix a gacomment garbled by an incautuius replace. --- src/scanopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scanopt.c b/src/scanopt.c index 55e2a73..ca3f839 100644 --- a/src/scanopt.c +++ b/src/scanopt.c @@ -51,7 +51,7 @@ struct _aux { struct _scanopt_t { const optspec_t *options; /* List of ctrl. */ - struct _aux *aux; /* Auxiliary data about ctrl. */ + struct _aux *aux; /* 'Auxiliary data about options. */ int optc; /* Number of ctrl. */ int argc; /* Number of args. */ char **argv; /* Array of strings. */ -- cgit v1.2.1 From ff0f99585169a435a5638ed2c4fa3b13397ee615 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Fri, 16 Oct 2020 18:27:46 +0000 Subject: quick editing pass over recent changes to documentation and comments (#2) --- doc/flex.texi | 153 +++++++++++++++++++++++++++++-------------------------- src/cpp-flex.skl | 7 ++- src/dfa.c | 2 +- src/flexdef.h | 2 +- src/gen.c | 4 +- src/main.c | 6 +-- src/scanopt.c | 10 ++-- tests/README | 17 +++---- 8 files changed, 104 insertions(+), 97 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 7187569..c527fae 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -623,7 +623,7 @@ Posix}, for other such features). Any @emph{indented} text or text enclosed in @samp{%@{} and @samp{%@}} is copied verbatim to the output (with the %@{ and %@} symbols removed). The %@{ and %@} symbols must appear unindented on lines by -themselves. Because whiteoace is easy to mangle wuthout noticing, +themselves. Because whitespace is easy to mangle without noticing, it's good style to use the explicit %@{ and %@} delimiters. @node User Code Section, Comments in the Input, Rules Section, Format @@ -693,9 +693,9 @@ ruleD yyecho(); If the target language is something other than C/C++, you will need to use its normal comment syntax in actions and code blocks. Note that the -optional @{ and @} delimiters around actions a Flex dyntax, not C +optional @{ and @} delimiters around actions a Flex syntax, not C syntax; you will be able to use those even if, e,g., your target -language is Pascal-like and delimus blocs with begin/end. +language is Pascal-like and delimits blocs with begin/end. @node Patterns, Matching, Format, Top @chapter Patterns @@ -1195,8 +1195,8 @@ run-time error results. Also note that you cannot use @code{%array} with C++ scanner classes (@pxref{Cxx}). -In target langages with automatic memory allocation and arrays none of -this applies; you can expect @code{yytext} to dynamically resize +In target langages with automatic memory allocation and arrays, none +of this applies; you can expect @code{yytext} to dynamically resize itself, calls to the @code{yyunput()} will not destroy the present contents of @code{yytext}, and you will never get a run-time error from calls to the @code{yyunput()} function except in the extremely @@ -1505,9 +1505,9 @@ generate a default into the scanner. @chapter The Generated Scanner @cindex yylex(), in generated scanner -The output of @code{flex} is a file wity the sem name @file{lex.yy}, which contains -the scanning routine @code{yylex()}, a number of tables used by it for -matching tokens, and a number of auxiliary routines. By +The output of @code{flex} is a file with the name @file{lex.yy}, which +contains the scanning routine @code{yylex()}, a number of tables used +by it for matching tokens, and a number of auxiliary routines. By default in C, @code{yylex()} is declared as follows: @example @@ -1525,7 +1525,7 @@ For example, you could put this in among your directives: @cindex yylex, overriding the prototype of @example @verbatim -%p[tion yydecl="float lexscan(float a, float b)" +%option yydecl="float lexscan(float a, float b)" @end verbatim @end example @@ -1558,23 +1558,23 @@ one of its actions executes a @code{return} statement. @cindex end-of-file, and yyrestart() @cindex yyrestart() If the scanner reaches an end-of-file, subsequent calls are undefined -unless either @file{yyin} is pointed at a new input file (in which case -scanning continues from that file), or @code{yyrestart()} is called. -@code{yyrestart()} takes one argument, an inoput stream, and -initializes @file{yyin} for scanning from that -stream. Essentially there is no difference between just assigning -@file{yyin} to a new input stream or using @code{yyrestart()} to do so; -the latter is available for compatibility with previous versions of -@code{flex}, and because it can be used to switch input files in the -middle of scanning. It can also be used to throw away the current input -buffer, by calling it with an argument of @code{yyin}; but it would be -better to use @code{yy_flush_current_buffer()} (@pxref{Actions}). Note that +unless either @file{yyin} is pointed at a new input file (in which +case scanning continues from that file), or @code{yyrestart()} is +called. @code{yyrestart()} takes one argument, an input stream, and +initializes @file{yyin} for scanning from that stream. Essentially +there is no difference between just assigning @file{yyin} to a new +input stream or using @code{yyrestart()} to do so; the latter is +available for compatibility with previous versions of @code{flex}, and +because it can be used to switch input files in the middle of +scanning. It can also be used to throw away the current input buffer, +by calling it with an argument of @code{yyin}; but it would be better +to use @code{yy_flush_current_buffer()} (@pxref{Actions}). Note that @code{yyrestart()} does @emph{not} reset the start condition to @code{INITIAL} (@pxref{Start Conditions}). -In C, an input stream is a a @code{FILE *} pointer. This pointer -can be NULL, if you've set up a @code{%yyread()} hook to scan from a source other -than @code{yyin}. +In C, an input stream is a a @code{FILE *} pointer. This pointer can +be NULL, if you've set up a @code{%yyread()} hook to scan from a +source other than @code{yyin}. @cindex RETURN, within actions If @code{yylex()} stops scanning due to executing a @code{return} @@ -2072,8 +2072,9 @@ returns a @code{yybuffer} handle, which may then be passed to other routines (see below). In target languages other than C/C++, this prototype will look -different. The input-stream type won't be @code{FILE *}. But expect -the same semamntics wxpressed in native tytypes. +different. The input-stream type won't be @code{FILE *}, but you can +expect the same semantics expressed using the target language's native +types. @tindex yybuffer The @code{yybuffer} type is a @@ -2263,13 +2264,16 @@ new buffer using @code{yy_switch_to_buffer()}, so the next call to @deftypefun yybuffer yy_scan_string ( char *str ) scans a string. This declaration is correct for C/C++, in which -strings are simply character seqences terminated by a NUL. In target -languages with a native strbg type, the prototype will change. +strings are simply character sequences terminated by a NUL. It is +expected that each target language will use the most appropriate +native string type instead. @end deftypefun @deftypefun yybuffer yy_scan_bytes ( const char *bytes, int len ) -scans @code{len} bytes (including possibly @code{NUL}s) starting at location -@code{bytes}. +scans @code{len} bytes (including possibly @code{NUL}s) starting at +location @code{bytes}. It is expected that each target language will +use the most appropriate native type instead of char*, such as a +reference to a byte array or slice. @end deftypefun Note that both of these functions create and scan a @emph{copy} of the @@ -2281,14 +2285,17 @@ using: @deftypefun yybuffer yy_scan_buffer (char *base, yy_size_t size) which scans in place the buffer starting at @code{base}, consisting of @code{size} bytes, the last two bytes of which @emph{must} be -@code{YY_END_OF_BUFFER_CHAR} (ASCII NUL). These last two bytes are not -scanned; thus, scanning consists of @code{base[0]} through -@code{base[size-2]}, inclusive. +@code{YY_END_OF_BUFFER_CHAR} (ASCII NUL). These last two bytes are +not scanned; thus, scanning consists of @code{base[0]} through +@code{base[size-2]}, inclusive. It is expected that each target +language will use the most appropriate native type instead of char*, +such as an owned byte array. @end deftypefun -If you fail to set up @code{base} in this manner (i.e., forget the final -two @code{YY_END_OF_BUFFER_CHAR} bytes), then @code{yy_scan_buffer()} -returns a NULL pointer instead of creating a new input buffer. +If you fail to set up @code{base} in this manner (i.e., forget the +final two @code{YY_END_OF_BUFFER_CHAR} bytes), then +@code{yy_scan_buffer()} returns a NULL pointer (and/or an error) +instead of creating a new input buffer. @deftp {Data type} yy_size_t is an integral type to which you can cast an integer expression @@ -2420,7 +2427,7 @@ the current buffer will have @samp{^} rules active, false otherwise. @hkindex %option post-action In the generated scanner, the actions are all gathered in one large -switch statement and separated using a postt-action fragment, which +switch statement and separated using a post-action fragment, which may be redefined. By default, in C it is simply a @code{break}, to separate each rule's action from the following rule's. Other target languages may have different defaults for this action, often an empty @@ -2537,9 +2544,9 @@ is @code{TOK_NUMBER}, part of the scanner might look like: @end example Bison is also retargetable to langages other than C. Outside the -C/C++ back end, it is likely that your Bison module will simply -moduke-level constants that will be make visible to your scanner by -linkage. +C/C++ back end, it is likely that your Bison module will simply export +module-level constants that will be made visible to your scanner by +linkage or by explicit import statements. @node Scanner Options, Performance, Yacc, Top @chapter Scanner Options @@ -2702,13 +2709,14 @@ the serialized tables match the in-code tables, instead of loading them. @opindex emit @item -e, --emit, @code{%option emit} instructs @code{flex} to generate code using a specific back end other -than the default. The default is called ``cpp',' generates C or C++, -supports all legacy interfaces, and generates either non-reentrant or -re-entrant scanners. There is presently one alternate back end, C99; -it drops a lot of legacy interfaces and generates only re-entrant -scanners in modern C. The C99 back end is intended to be a launch -polnt for as yet nonexistent back ends generating distinct other -languges such as Go, Rust, Java, or Python. +than the default. The default is called ``cpp',' generates C or C++ +code, supports all legacy interfaces, and generates either +non-reentrant or re-entrant scanners. There is presently one +alternate back end, C99; it drops a lot of legacy interfaces, +generates only re-entrant scanners, and outputs modern C. The C99 +back end is intended to be a launching point for as yet unwritten back +ends generating scanners in other languages such as Go, Rust, Java, +Python, etc. @anchor{option-case-insensitive} @opindex -i @@ -4157,7 +4165,7 @@ probably will not emulate it. @item In the default C/C++ @code{yylex_init} and @code{yylex_destroy} must -be called before and after @code{yylex}, respectively. Other back ebds +be called before and after @code{yylex}, respectively. Other back ends may or may not require this. @item @@ -4250,7 +4258,7 @@ non-reentrant scanner. Here are the declarations of Notice that the argument @code{yyscanner} appears in the declaration of both functions. In fact, all @code{flex} functions in a reentrant -scanner have this additional argument, except fot rule hooks which +scanner have this additional argument, except for rule hooks which get it supplied implicitly. It is always the last argument @@ -4266,7 +4274,7 @@ additional argument. Rule hooks don't need to take a scanner context argument because, under the hood, the context is supplied by the call location. -The type name @code{yscan_t} follows C conventions. It mmay differ in +The type name @code{yscan_t} follows C conventions. It may differ in other target languages. @node Global Replacement, Init and Destroy Functions, Extra Reentrant Argument, Reentrant Detail @@ -4275,7 +4283,7 @@ other target languages. @cindex reentrant, accessing flex variables In the C/C++ back end global variables in traditional flex have been replaced by macro equivalents. Be aware that this will not be true in target -languages without macros, so rekying on this backward-compatibility +languages without macros, so relying on this backward-compatibility hack will hinder forward portability. Accordingly, in the above example, @code{yyout} and @code{yytext} are @@ -4352,9 +4360,10 @@ takes one argument, which is the value returned (via an argument) by @code{yylex_init}. Otherwise, it behaves the same as the non-reentrant version of @code{yylex}. -Both @code{yylex_init} and @code{yylex_init_extra} returns 0 (zero) on -success, or non-zero on failure. On error, in the C/C++ back end in -which case errno is set to one of the following values: +With the C/C++ back end, both @code{yylex_init} and +@code{yylex_init_extra} return 0 (zero) on success or non-zero on +failure. @code{errno} is also set to one of the following values on +failure: @itemize @item ENOMEM @@ -4363,7 +4372,7 @@ Memory allocation error. @xref{memory-management}. Invalid argument. @end itemize -Othert target langages may use different means of passing back an +Other target languages may use different means of passing back an error indication. The function @code{yylex_destroy} should be @@ -4476,11 +4485,11 @@ In addition, an extra form of @code{yylex_init} is provided, be accessed from within the very first yyalloc, used to allocate the scanner itself. -In the deault C/C__ back end, the extra firld in your scanner state -structure is defined as type @code{void *}; in ither target languages -no such field night ne genetated at all. You may redefine or crrate -this extra field using @code{%option extra-type="your_type"} in the -scanner: +In the default C/C++ back end, the extra field in your scanner state +structure is defined as type @code{void *}; in other target languages +it might be a generic type, or no such field might be genetated at +all. In back ends which support this extra field, you may redefine +the type using @code{%option extra-type="your_type"} in the scanner: @cindex YY_EXTRA_TYPE, defining your own type @example @@ -4521,7 +4530,7 @@ void scan_file( char* filename ) @subsection About yyscan_t @tindex yyscan_t (reentrant only) -On C/C++, @code{yyscan_t} is defined as: +In C/C++, @code{yyscan_t} is defined as: @example @verbatim @@ -4916,7 +4925,7 @@ buffer. As of version 2.5.9 Flex will clean up all memory when you call @code{yy Flex allocates dynamic memory for four purposes, listed below @footnote{The quantities given here are approximate, and may vary due to host architecture, -compiler configuration, or due to future enhancements to flex.} +compiler configuration, or due to future enhancements to flex.} @table @asis @@ -4971,7 +4980,7 @@ you call yylex_init(). It is destroyed when the user calls yylex_destroy(). @node Overriding The Default Memory Management, A Note About yytext And Memory, The Default Memory Management, Memory Management @section Overriding The Default Memory Management -Afain, this section applies onlt to languages with manual memory management. +Again, this section applies only to languages with manual memory management. @cindex yyalloc, overriding @cindex yyrealloc, overriding @@ -5483,15 +5492,15 @@ in @emph{fixed} trailing context being turned into the more expensive @end verbatim @end example -Some caveats are specific ro the In the C/C++ back end: Use of +Some caveats are specific to the C/C++ back end: Use of @code{yyunput()} invalidates yytext and yyleng, unless the @code{%array} directive or the @samp{-l} option has been used. Pattern-matching of @code{NUL}s is substantially slower than matching other characters. Dynamic resizing of the input buffer is slow, as it entails rescanning all the text matched so far by the current (generally huge) token. Due to both buffering of input and -read-ahead, you cannot intermix calls to @file{} routines, -such as, @b{getchar()}, with @code{flex} rules and expect it to work. +read-ahead, you cannot intermix calls to @file{} routines +(such as @b{getchar()}) with @code{flex} rules and expect it to work. Call @code{yyinput()} instead. The total table entries listed by the @samp{-v} flag excludes @@ -8721,12 +8730,12 @@ generation; they're for Flex to read and key on. Following those are the @code{M4_HOOK_*} macros. Rather than emit literal language syntax, Flex ships calls to these macros which are -expected to be expanded within the skeleton. The other things it -ships which appear in the output code are mostly bodies for table -initializers, with associated macros for typenames and table -dimensions. The names of all such macros have the prefix -``M4_HOOK_''; you can study them in the Flex code by grepping for that -prefix. +expected to be expanded to to the correct language syntax within the +skeleton. The other things flex ships which appear in the output code +are mostly bodies for table initializers, with associated macros for +typenames and table dimensions. The names of all such macros have the +prefix ``M4_HOOK_''; you can study them in the Flex code by grepping +for that prefix. Flex ships another fairly large set of macros that are guard conditions for conditional macroexpanion. The values of these symbols @@ -8799,7 +8808,7 @@ If your target language has an object system, you probably want your back end to generate a class named by default FlexLexer (as the C++ back end does) with all of the controls and query functions as methods. As in C++, @code{%option yyclass} should modify the -class name. If your target language has a moduke system, the +class name. If your target language has a module system, the -P option (which in C/C++ sets a common prefix on exposed entry points) can be pressed into service to set the module name. @end itemize diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index f1ee072..aec3538 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -25,7 +25,7 @@ %# prescriptive about whitespace and braces is more than usually %# important. So please set your C style to K&R, aka 1TBS with %# tabs when editing this file. Braces around single-statement -%# if/while/for/do/switch/break bodies are mandatory. +%# if/while/for/do/switch/break bodies are mandatory. %# %# Macros for preproc stage. @@ -2127,9 +2127,8 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = YY_G(yy_hold_char); - /* /\* Backing-up info for compressed tables is taken \after/ */ - /* * yy_cp has been incremented for the next state. */ - /* *\/ */ + /* Backing-up info for compressed tables is taken \after/ */ + /* yy_cp has been incremented for the next state. */ yy_cp = YY_G(yy_last_accepting_cpos); m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) diff --git a/src/dfa.c b/src/dfa.c index baa42ed..c281a7b 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -367,7 +367,7 @@ void increase_max_dfas (void) * Creates the dfa corresponding to the ndfa we've constructed. The * dfa starts out in state #1. * - * Return the amound of space, in byyes, allocated for the bxt table. + * Return the amount of space, in bytes, allocated for the next table. * In some modes this can be zero. */ diff --git a/src/flexdef.h b/src/flexdef.h index fd7d6df..8c90933 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -794,7 +794,7 @@ extern void mkechar(int, int[], int[]); extern void do_indent(void); /* indent to the current level */ -/* Set a conmditional amd make it visible in generated code */ +/* Set a conditional amd make it visible in generated code */ extern void visible_define (const char *); /* And again, with an explicit value part. */ diff --git a/src/gen.c b/src/gen.c index b42708b..62b20b6 100644 --- a/src/gen.c +++ b/src/gen.c @@ -810,8 +810,8 @@ void gentabs (void) ptype = optimize_pack(tblend + 1); - /* Note: Osed wheen !ctrl.fulltbl && !ctrl.fullspd). - * (Alternately defined wjen ctrl.fullspd + /* Note: Used when !ctrl.fulltbl && !ctrl.fullspd). + * (Alternately defined when ctrl.fullspd) */ out_str ("m4_define([[M4_HOOK_YYNXT_TYPE]], [[%s]])", ptype->name); out_dec ("m4_define([[M4_HOOK_YYNXT_SIZE]], [[%d]])", tblend + 1); diff --git a/src/main.c b/src/main.c index 5eb3d48..a0795ad 100644 --- a/src/main.c +++ b/src/main.c @@ -1223,9 +1223,9 @@ void readin (void) if (syntaxerror) flexend (1); - /* On --emit, -e, or %option emit, change backends - * This is where backed properties are collected, - * Which means they can't be set from a cudtom skelfile. + /* On --emit, -e, or %option emit, change backends + * This is where backend properties are collected, + * which means they can't be set from a custom skelfile. */ backend_by_name(ctrl.emit); diff --git a/src/scanopt.c b/src/scanopt.c index ca3f839..7a91178 100644 --- a/src/scanopt.c +++ b/src/scanopt.c @@ -50,9 +50,9 @@ struct _aux { struct _scanopt_t { - const optspec_t *options; /* List of ctrl. */ - struct _aux *aux; /* 'Auxiliary data about options. */ - int optc; /* Number of ctrl. */ + const optspec_t *options; /* List of options. */ + struct _aux *aux; /* Auxiliary data about options. */ + int optc; /* Number of options. */ int argc; /* Number of args. */ char **argv; /* Array of strings. */ int index; /* Used as: argv[index][subscript]. */ @@ -345,8 +345,8 @@ int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage) fprintf((fp), "%*s", (n), "") /* Second pass (same as above loop), this time we print. */ - /* Sloppy hack: We iterate twice. The first time we print short and long ctrl. - The second time we print those lines that have ONLY long ctrl. */ + /* Sloppy hack: We iterate twice. The first time we print short and long options. + The second time we print those lines that have ONLY long options. */ while (print_run++ < 2) { for (ue = byr_val; ue; ue = ue->next) { usg_elem *ap; diff --git a/tests/README b/tests/README index 49e8e12..8112438 100644 --- a/tests/README +++ b/tests/README @@ -9,8 +9,8 @@ this directory and its contents. * STRUCTURE OF THE TEST SUITE The testsuite consists of a large number of tests. Usually the test is -simply that a sanner consumes all the token fed to it firom a text -(.txt) file in a maxhing grammer, not allowing stray characters to +simply that a scanner consumes all the tokens fed to it from a text +(.txt) file in a maching grammar, not allowing stray characters to echo through to stdout. This is how we avoid meeding explicit check files. Each test is centered around a scanner known to work with the most @@ -65,23 +65,22 @@ automake test suite harness. * NAMING CONVENTIONS -A test with a _nr suffix exercises a non-reentrant xanner built +A test with an _nr suffix exercises a non-reentrant scanner built with the default cpp back end. -uA test with a _r suffix exercises a reentrant xanner built +uA test with an _r suffix exercises a reentrant scanner built with the default cpp back end. A test with a c99 suffix exercises the c99 back end. All C99 -acanners are re-entrant. +scanners are re-entrant. -A tesrt with a _cpp suffix exercises the default cpp back end on a -specification where the reentra=t/non-reentrant distinction is +A test with a _cpp suffix exercises the default cpp back end on a +specification where the reentrant/non-reentrant distinction is not interesting. Most tests occur in groups with a common stem in the names, like alloc_extra_ or ccl_. These are exercising the same token grammar -under different back ends. As mre target languages are added these +under different back ends. As new target languages are added these groups of patallel tests will grow. Tests that are not part of one of these series are usually of features supported on the default cpp back end only. - -- cgit v1.2.1 From 1c439cfab2912e1e8b229ae7f21b635254180d80 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 16 Oct 2020 14:23:30 -0400 Subject: Finish up the simple-test set for C99. --- doc/flex.texi | 8 + tests/.gitignore | 36 +- tests/Makefile.am | 67 +++- tests/README | 19 +- tests/mem_c99.l | 188 ++++++++++ tests/mem_c99.txt | 25 ++ tests/posix.l | 79 ---- tests/posix_c99.l | 80 +++++ tests/posix_cpp.l | 79 ++++ tests/posixly_correct.l | 79 ---- tests/posixly_correct_c99.l | 80 +++++ tests/posixly_correct_cpp.l | 79 ++++ tests/prefix_c99.l | 84 +++++ tests/prefix_c99.txt | 1 + tests/quote_in_comment.l | 16 - tests/quote_in_comment.txt | 1 - tests/quote_in_comment_c99.l | 17 + tests/quote_in_comment_c99.txt | 1 + tests/quote_in_comment_cpp.l | 16 + tests/quote_in_comment_cpp.txt | 1 + tests/quotes.l | 131 ------- tests/quotes.txt | 2 - tests/quotes_c99.l | 132 +++++++ tests/quotes_c99.txt | 2 + tests/quotes_cpp.l | 131 +++++++ tests/quotes_cpp.txt | 2 + tests/string_c99.l | 104 ++++++ tests/top.l | 3 +- tests/yyextra.l | 120 ------- tests/yyextra.txt | 795 ----------------------------------------- tests/yyextra_c99.l | 121 +++++++ tests/yyextra_c99.txt | 795 +++++++++++++++++++++++++++++++++++++++++ tests/yyextra_cpp.l | 120 +++++++ tests/yyextra_cpp.txt | 795 +++++++++++++++++++++++++++++++++++++++++ 34 files changed, 2952 insertions(+), 1257 deletions(-) create mode 100644 tests/mem_c99.l create mode 100644 tests/mem_c99.txt delete mode 100644 tests/posix.l create mode 100644 tests/posix_c99.l create mode 100644 tests/posix_cpp.l delete mode 100644 tests/posixly_correct.l create mode 100644 tests/posixly_correct_c99.l create mode 100644 tests/posixly_correct_cpp.l create mode 100644 tests/prefix_c99.l create mode 100644 tests/prefix_c99.txt delete mode 100644 tests/quote_in_comment.l delete mode 100644 tests/quote_in_comment.txt create mode 100644 tests/quote_in_comment_c99.l create mode 100644 tests/quote_in_comment_c99.txt create mode 100644 tests/quote_in_comment_cpp.l create mode 100644 tests/quote_in_comment_cpp.txt delete mode 100644 tests/quotes.l delete mode 100644 tests/quotes.txt create mode 100644 tests/quotes_c99.l create mode 100644 tests/quotes_c99.txt create mode 100644 tests/quotes_cpp.l create mode 100644 tests/quotes_cpp.txt create mode 100644 tests/string_c99.l delete mode 100644 tests/yyextra.l delete mode 100644 tests/yyextra.txt create mode 100644 tests/yyextra_c99.l create mode 100644 tests/yyextra_c99.txt create mode 100644 tests/yyextra_cpp.l create mode 100644 tests/yyextra_cpp.txt diff --git a/doc/flex.texi b/doc/flex.texi index c527fae..9453e6b 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8786,6 +8786,14 @@ targets. Almost anything generally descended from Algol shouldn't be much more difficult; this certainly includes the whole Pascal/Modula/Oberon family. +The C99 back end can be used for production, but it is really intended +as a launch point to be cloned by people writing support for +additional languages. Accordingly, it omits support for some features +that can't be practically ported out of C in order to lower the +complexity of what needs to be translated to a new target language. +These features are: the Bison bridge, header generation, and loadable +tables. + Some notes about the interesting part: @itemize diff --git a/tests/.gitignore b/tests/.gitignore index a5441c3..11bbbfb 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -73,18 +73,26 @@ mem_nr mem_nr.c mem_r mem_r.c +mem_c99 +mem_c99.c multiple_scanners_nr multiple_scanners_nr_[12].[ch] multiple_scanners_r multiple_scanners_r_[12].[ch] -posix -posix.c -posixly_correct -posixly_correct.c +posix_cpp +posix_cpp.c +posix_c99 +posix_c99.c +posixly_correct_cpp +posixly_correct_cpp.c +posixly_correct_c99 +posixly_correct_c99.c prefix_nr prefix_nr.c prefix_r prefix_r.c +prefix_c99 +prefix_c99.c pthread.pthread pthread.c reject_nr.reject @@ -99,18 +107,26 @@ rescan_nr.direct rescan_nr.direct.c rescan_r.direct rescan_r.direct.c -quote_in_comment -quote_in_comment.c -quotes -quotes.c +quote_in_comment_cpp +quote_in_comment_cpp.c +quote_in_comment_c99 +quote_in_comment_c99.c +quotes_cpp +quotes_cpp.c +quotes_c99 +quotes_c99.c string_nr string_nr.c string_r string_r.c +string_c99 +string_c99.c top top.[ch] -yyextra -yyextra.c +yyextra_cpp +yyextra_cpp.c +yyextra_c99 +yyextra_c99.c tableopts_*.c *.opt *.ser diff --git a/tests/Makefile.am b/tests/Makefile.am index 0d01cd8..a5bcac6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,18 +88,25 @@ simple_tests = \ header_r \ mem_nr \ mem_r \ + mem_c99 \ multiple_scanners_nr \ multiple_scanners_r \ - posix \ - posixly_correct \ + posix_cpp \ + posix_c99 \ + posixly_correct_cpp \ + posixly_correct_c99 \ prefix_nr \ prefix_r \ - quote_in_comment \ - quotes \ + prefix_c99 \ + quote_in_comment_cpp \ + quote_in_comment_c99 \ + quotes_cpp \ + quotes_c99 \ string_nr \ - string_r \ + string_c99 \ top \ - yyextra + yyextra_cpp \ + yyextra_c99 reject_tests = \ reject_nr.reject \ @@ -127,7 +134,8 @@ ONE_TESTS = \ lineno_r.one \ lineno_trailing.one -quote_in_comment_SOURCES = quote_in_comment.l +quote_in_comment_cpp_SOURCES = quote_in_comment_cpp.l +quote_in_comment_c99_SOURCES = quote_in_comment_c99.l alloc_extra_cpp_SOURCES = alloc_extra_cpp.l alloc_extra_c99_SOURCES = alloc_extra_c99.l array_nr_SOURCES = array_nr.l @@ -173,16 +181,21 @@ lineno_r_one_SOURCES = lineno_r.l lineno_trailing_one_SOURCES = lineno_trailing.l mem_nr_SOURCES = mem_nr.l mem_r_SOURCES = mem_r.l +mem_c99_SOURCES = mem_c99.l multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_1.l multiple_scanners_nr_2.l nodist_multiple_scanners_nr_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h -posix_SOURCES = posix.l -posixly_correct_SOURCES = posixly_correct.l +posix_cpp_SOURCES = posix_cpp.l +posix_c99_SOURCES = posix_c99.l +posixly_correct_cpp__SOURCES = posixly_correct_cp.l +posixly_correct_c99_SOURCES = posixly_correct_c99.l prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l +prefix_c99_SOURCES = prefix_c99.l pthread_pthread_SOURCES = pthread.l -quotes_SOURCES = quotes.l +quotes_cpp_SOURCES = quotes_cpp.l +quotes_c99_SOURCES = quotes_c99.l reject_nr_reject_SOURCES = reject.l4 reject_r_reject_SOURCES = reject.l4 reject_ver_table_SOURCES = reject.l4 @@ -191,9 +204,11 @@ rescan_nr_direct_SOURCES = rescan_nr.direct.l rescan_r_direct_SOURCES = rescan_r.direct.l string_nr_SOURCES = string_nr.l string_r_SOURCES = string_r.l +string_c99_SOURCES = string_c99.l top_SOURCES = top.l top_main.c nodist_top_SOURCES = top.h -yyextra_SOURCES = yyextra.l +yyextra_cpp_SOURCES = yyextra_cpp.l +yyextra_c99_SOURCES = yyextra_c99.l # Normally, automake would distribute files built by flex. Since the # point of the test suite is to test the files that flex builds, and @@ -250,6 +265,7 @@ CLEANFILES = \ lineno_trailing.c \ mem_nr.c \ mem_r.c \ + mem_c99.c \ multiple_scanners_nr_1.c \ multiple_scanners_nr_1.h \ multiple_scanners_nr_2.c \ @@ -258,13 +274,17 @@ CLEANFILES = \ multiple_scanners_r_1.h \ multiple_scanners_r_2.c \ multiple_scanners_r_2.h \ - posix.c \ - posixly_correct.c \ + posix_cpp.c \ + posix_c99.c \ + posixly_correct_cpp.c \ + posixly_correct_c99.c \ prefix_nr.c \ prefix_r.c \ + prefix_c99.c \ pthread.c \ - quote_in_comment.c \ - quotes.c \ + quote_in_comment_cpp.c \ + quote_in_comment_c99.c \ + quotes_cpp.c \ reject_nr.reject.c \ reject_r.reject.c \ reject_ser.table.c \ @@ -275,9 +295,11 @@ CLEANFILES = \ rescan_r.direct.c \ string_nr.c \ string_r.c \ + string_c99.c \ top.c \ top.h \ - yyextra.c \ + yyextra_cpp.c \ + yyextra_c99.c \ $(tableopts_c) \ $(tableopts_tables) @@ -327,8 +349,10 @@ EXTRA_DIST = \ lineno_trailing.one.txt \ mem_nr.txt \ mem_r.txt \ + mem_c99.txt \ prefix_nr.txt \ prefix_r.txt \ + prefix_c99.txt \ pthread_1.txt \ pthread_2.txt \ pthread_3.txt \ @@ -337,8 +361,10 @@ EXTRA_DIST = \ reject.txt \ rescan_nr.direct.txt \ rescan_r.direct.txt \ - quote_in_comment.txt \ - quotes.txt \ + quote_in_comment_cpp.txt \ + quote_in_comment_c99.txt \ + quotes_cpp.txt \ + quotes_c99.txt \ top.txt \ yyextra.txt \ tableopts.txt @@ -424,7 +450,10 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c @if test ! -f $@; then rm -f $<; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi -posixly_correct.c: posixly_correct.l $(FLEX) +posixly_correct_cpp.c: posixly_correct_cpp.l $(FLEX) + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< + +posixly_correct_c99.c: posixly_correct_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< reject_nr.reject.c: reject.l4 $(FLEX) diff --git a/tests/README b/tests/README index 8112438..f24b895 100644 --- a/tests/README +++ b/tests/README @@ -8,10 +8,11 @@ this directory and its contents. * STRUCTURE OF THE TEST SUITE -The testsuite consists of a large number of tests. Usually the test is -simply that a scanner consumes all the tokens fed to it from a text -(.txt) file in a maching grammar, not allowing stray characters to -echo through to stdout. This is how we avoid meeding explicit check files. +The testsuite consists of a large number of tests. In a "simple test", +the check is simply that a scanner consumes all the tokens fed to it +from a text (.txt) file in a maching grammar, not allowing stray +characters to echo through to stdout. This is how we avoid meeding +explicit check files. Each test is centered around a scanner known to work with the most recent version of flex. In general, after you modify your copy of the @@ -84,3 +85,13 @@ under different back ends. As new target languages are added these groups of patallel tests will grow. Tests that are not part of one of these series are usually of features supported on the default cpp back end only. + +WHY SOME TESTS ARE MISSING + +The "top" test is backend-independent; what it's really testing +is Flex's ability to accumulate and ship preamble code sections. + +The C99 is missing tests for the Bison bridge, header generation, and +loadable tables because it omits those features in order to be a simpler +starting point for wring new back ends. + diff --git a/tests/mem_c99.l b/tests/mem_c99.l new file mode 100644 index 0000000..a6df306 --- /dev/null +++ b/tests/mem_c99.l @@ -0,0 +1,188 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". + * The whole idea is to cause memory realloc by + * 1. pushing a lot on the condition stack, and + * 2. eating input greater than YY_BUF_SIZE + */ +#include +#include +#include "config.h" + +/* Insanely small read buffer. This pretty much guarantees at least one realloc. */ +#ifdef YY_BUF_SIZE +#undef YY_BUF_SIZE +#endif +#define YY_BUF_SIZE 8 + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput noyy_top_state +%option warn stack nodefault reentrant +%option noyyalloc noyyrealloc noyyfree + +%x parens + +%% + +{ +"(" { printf("yy_push_state(parens)\n"); yy_push_state(parens,yyscanner); } +len=[0-9]+ { printf("About read token where %s\n",yytext); } +0+ { } +.|\n { } +} + +{ +"(" { printf("yy_push_state(parens)\n"); yy_push_state(parens,yyscanner); } +")" { printf("yy_pop_state()\n");yy_pop_state(yyscanner);} +[^()\n]+ { } +.|\n { } +} + +%% +/* total memory allocated */ +static size_t total_mem=0; + +/* track the amount of memory for ptr. */ +struct memsz { + void* p; + size_t sz; +}; + +static struct memsz * ptrs=0; /* Array of pairs. */ +static int nptrs=0; /* Number of pairs in array. */ +static int arrsz=0; /* Capacity of array. */ + +static void dump_mem(FILE* fp){ + int i; + fprintf(fp,"\tptrs[%d] = {", nptrs); + for (i=0; i < arrsz; i++) + fprintf(fp," {%#lx,%ld},", (long)ptrs[i].p, (long)ptrs[i].sz); + + fprintf(fp,"}\n"); +} + +void * testalloc(yy_size_t n , void* yyscanner) +{ + (void)yyscanner; + + void * p; + int i; + + total_mem += n; + p = malloc(n); + + if( nptrs >= arrsz){ + /* increase array size by 1 */ + arrsz++; + ptrs = realloc(ptrs, (size_t) arrsz * sizeof(struct memsz)); + ptrs[nptrs].p = 0; + ptrs[nptrs].sz = 0; + } + + /* find a null slot */ + for(i=0; i < arrsz ; i++) + if (ptrs[i].p == 0) { + ptrs[i].p = p; + ptrs[i].sz = n; + } + + nptrs++; + printf("yyflex_alloc(%8ld) total=%8ld return=%#10lx\n",(long)n,(long)total_mem,(long)p); + dump_mem(stdout); + return p; +} + +void * testrealloc(void* p, yy_size_t n , void* yyscanner) +{ + (void)yyscanner; + + int i; + for (i=0; i < arrsz; i++) + if ( ptrs[i].p == p){ + total_mem -= ptrs[i].sz; + total_mem += n; + ptrs[i].p = realloc(p, n); + ptrs[i].sz = n; + + printf("yyflex_realloc(%#10lx,%8ld) total=%8ld return=%8lx\n", + (long)p,(long)n,(long)total_mem,(long)ptrs[i].p); + dump_mem(stdout); + return ptrs[i].p; + } + + fprintf(stderr,"ERROR: yyflex_realloc could not locate pointer %#lx.\n",(long)p); + dump_mem(stdout); + exit(1); +} + +void testfree(void* p , void* yyscanner) +{ + (void)yyscanner; + + int i; + for (i=0; i < arrsz; i++) + if ( ptrs[i].p == p){ + total_mem -= ptrs[i].sz; + free(p); + ptrs[i].p = 0; + ptrs[i].sz = 0; + nptrs--; + printf("yyflex_free(%#10lx) total=%8ld\n",(long)p,(long)total_mem); + dump_mem(stdout); + return; + } + + fprintf(stderr,"ERROR: yyflex_free could not locate pointer %#lx.\n",(long)p); + dump_mem(stdout); + exit(1); +} + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + arrsz = 1; + ptrs = calloc(1, sizeof(struct memsz)); + nptrs = 0; + + testlex_init(&scanner); + testset_in(stdin,scanner); + testset_out(stdout,scanner); + testlex(scanner); + testlex_destroy(scanner); + free(ptrs); + + if ( nptrs > 0 || total_mem > 0){ + fprintf(stderr,"Oops. Looks like a memory leak: nptrs=%d, unfreed memory=%ld\n",nptrs,(long)total_mem); + exit(1); + } + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/mem_c99.txt b/tests/mem_c99.txt new file mode 100644 index 0000000..79aa16a --- /dev/null +++ b/tests/mem_c99.txt @@ -0,0 +1,25 @@ +First we push a lot on the stack by nesting parenthesis: + +(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( +(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( +((((((((((((((((((((((((((((((((((((((((((( + +(should be 200 states pushed here) + +)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) +)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) +))))))))))))))))))))))))))))))))))))))))))) + +Now we match progressively bigger tokens to increase the read buffer: + +len=1 0 +len=2 00 +len=4 0000 +len=8 00000000 +len=16 0000000000000000 +len=32 00000000000000000000000000000000 +len=64 0000000000000000000000000000000000000000000000000000000000000000 +len=128 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +len=256 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +len=512 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +len=1024 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/tests/posix.l b/tests/posix.l deleted file mode 100644 index f1851d8..0000000 --- a/tests/posix.l +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn posix-compat - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posix_c99.l b/tests/posix_c99.l new file mode 100644 index 0000000..7f50492 --- /dev/null +++ b/tests/posix_c99.l @@ -0,0 +1,80 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn posix-compat + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/posix_cpp.l b/tests/posix_cpp.l new file mode 100644 index 0000000..f1851d8 --- /dev/null +++ b/tests/posix_cpp.l @@ -0,0 +1,79 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn posix-compat + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/posixly_correct.l b/tests/posixly_correct.l deleted file mode 100644 index 715bb27..0000000 --- a/tests/posixly_correct.l +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posixly_correct_c99.l b/tests/posixly_correct_c99.l new file mode 100644 index 0000000..85e5258 --- /dev/null +++ b/tests/posixly_correct_c99.l @@ -0,0 +1,80 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/posixly_correct_cpp.l b/tests/posixly_correct_cpp.l new file mode 100644 index 0000000..715bb27 --- /dev/null +++ b/tests/posixly_correct_cpp.l @@ -0,0 +1,79 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l new file mode 100644 index 0000000..4baebea --- /dev/null +++ b/tests/prefix_c99.l @@ -0,0 +1,84 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* Builds "scanner.c". */ +/* The scanner itself is a no-op. A successful compilation is all we want. */ +#include +#include +#include "config.h" + +%} +%option emit="c99" +%option reentrant +%option 8bit prefix="FOO" +%option nounput nomain noyywrap noinput +%option warn + + +%% + + +.|\n|\r { + + /* Compile, but do not execute the following code. */ + if( 0 ) { + FOO_create_buffer( (FILE*)0, 0, yyscanner); + FOO_delete_buffer( (YY_BUFFER_STATE)0, yyscanner); + FOO_flush_buffer( (YY_BUFFER_STATE)0, yyscanner); + FOO_init_buffer( (YY_BUFFER_STATE)0, (FILE*)0, yyscanner); + FOO_load_buffer_state( yyscanner); + FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner); + FOO_scan_bytes( (yyconst char*)0, 0, yyscanner); + FOO_scan_string( (yyconst char*)0, yyscanner); + FOO_switch_to_buffer( (YY_BUFFER_STATE)0, yyscanner); + FOOrestart( (FILE*)0, (yyscan_t )0); + + FOOget_extra( (yyscan_t )0 ); + FOOget_in( (yyscan_t )0 ); + FOOget_leng( (yyscan_t )0 ); + FOOget_out( (yyscan_t )0 ); + FOOget_text( (yyscan_t )0 ); + FOOlex( (yyscan_t )0 ); + FOOlex_destroy( (yyscan_t )0 ); + FOOlex_init( (yyscan_t *)0 ); + FOOset_extra( (void *)0, (yyscan_t )0 ); + FOOset_in( (FILE*)0, (yyscan_t )0 ); + FOOset_out( (FILE*)0, (yyscan_t )0 ); + } + } +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + FOOlex_init( &scanner); + FOOlex( scanner); + FOOlex_destroy( scanner); + printf( "TEST RETURNING OK.\n"); + return 0; +} + diff --git a/tests/prefix_c99.txt b/tests/prefix_c99.txt new file mode 100644 index 0000000..0e6c88f --- /dev/null +++ b/tests/prefix_c99.txt @@ -0,0 +1 @@ +Dummy input. diff --git a/tests/quote_in_comment.l b/tests/quote_in_comment.l deleted file mode 100644 index cb17e2f..0000000 --- a/tests/quote_in_comment.l +++ /dev/null @@ -1,16 +0,0 @@ -%option 8bit noyywrap -%% -.|\n { yyecho(); - //' " - } -%% -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/quote_in_comment.txt b/tests/quote_in_comment.txt deleted file mode 100644 index 9daeafb..0000000 --- a/tests/quote_in_comment.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/tests/quote_in_comment_c99.l b/tests/quote_in_comment_c99.l new file mode 100644 index 0000000..2d3db98 --- /dev/null +++ b/tests/quote_in_comment_c99.l @@ -0,0 +1,17 @@ +%option emit="c99" +%option 8bit noyywrap +%% +.|\n { yyecho(); + //' " + } +%% +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/quote_in_comment_c99.txt b/tests/quote_in_comment_c99.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/tests/quote_in_comment_c99.txt @@ -0,0 +1 @@ +test diff --git a/tests/quote_in_comment_cpp.l b/tests/quote_in_comment_cpp.l new file mode 100644 index 0000000..cb17e2f --- /dev/null +++ b/tests/quote_in_comment_cpp.l @@ -0,0 +1,16 @@ +%option 8bit noyywrap +%% +.|\n { yyecho(); + //' " + } +%% +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/quote_in_comment_cpp.txt b/tests/quote_in_comment_cpp.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/tests/quote_in_comment_cpp.txt @@ -0,0 +1 @@ +test diff --git a/tests/quotes.l b/tests/quotes.l deleted file mode 100644 index d1b97eb..0000000 --- a/tests/quotes.l +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* The point of this test is to be sure our M4 madness does not - * interfere with user code. I particular, we are looking - * for instances of M4 quotes, [[ and ]], in here to make it through the flex - * machinery unscathed. - */ - -/* sect 1 [ 1 ] TEST_XXX */ -/* sect 1 [[ 2 ]] TEST_XXX */ -/* sect 1 [[[ 3 ]]] TEST_XXX */ -/* sect 1 [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 ]] unmatched [[ TEST_XXX */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -#include -/*#include "parser.h" */ - -/* sect 1 block [ 1 ] TEST_XXX */ -/* sect 1 block [[ 2 ]] TEST_XXX */ -/* sect 1 block [[[ 3 ]]] TEST_XXX */ -/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 block ]] unmatched [[ TEST_XXX */ - -static int a[1] = {0}; -static int b[1] = {0}; -static int c[1] = {0}; - -static int foo (int i){ - return a[b[c[i]]]; /* sect 1 code TEST_XXX */ -} -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - /* indented code [ 1 ] */ - /* indented code [[ 2 ]] */ - /* indented code [[[ 3 ]]] */ - /* indented code [[[[ 4 ]]]] */ - /* indented code ]] unmatched [[ */ -%{ -// non-indented code [ 1 ] -// non-indented code [[ 2 ]] -// non-indented code [[[ 3 ]]] -// non-indented code [[[[ 4 ]]]] -%} - -a /* action comment [ 1 ] */ ; -b /* action comment [[ 2 ]] */ ; -c /* action comment [[[ 3 ]]] */ ; -d /* action comment [[[[ 4 ]]]] */ ; -e /* action comment ]] unmatched [[ */ ; -f return 1+foo(a[b[c[0]]]); -.|\n { - -#if 0 - action code [ 1 ] TEST_XXX - action code [[ 2 ]] TEST_XXX - action code [[[ 3 ]]] TEST_XXX - action code [[[[ 4 ]]]] TEST_XXX - action code ]] unmatched [[ TEST_XXX -#endif - /* action block [ 1 ] TEST_XXX */ - /* action block [[ 2 ]] TEST_XXX */ - /* action block [[[ 3 ]]] TEST_XXX */ - /* action block [[[[ 4 ]]]] TEST_XXX */ - /* action block ]] unmatched [[ TEST_XXX */ - assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); - assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); - assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); - assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); - assert(!strcmp("]]m4_define(alpha, beta)[[", - "]""]m4_""define(alpha, beta)[""[")); - return 1+foo(a[b[c[0]]]); /* TEST_XXX */ - } -%% - -/* sect 3 [ 1 ] TEST_XXX */ -/* sect 3 [[ 2 ]] TEST_XXX */ -/* sect 3 [[[ 3 ]]] TEST_XXX */ -/* sect 3 [[[[ 4 ]]]] TEST_XXX */ -/* sect 3 ]] unmatched [[ TEST_XXX */ -static int bar (int i){ - return c[b[a[i]]]; /* sect 3 code TEST_XXX */ -} -int main(void); - -#define CONCAT_IDENTS(a, b) a##b -int -main (void) -{ - /* m4_m4exit(100) */ - FILE *M4_YY_NOT_IN_HEADER = stdin; - yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); - yyout = stdout; - while (yylex()) - ; - assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); - printf("TEST RETURNING OK.\n"); - return bar(0); -} - diff --git a/tests/quotes.txt b/tests/quotes.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/quotes.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/quotes_c99.l b/tests/quotes_c99.l new file mode 100644 index 0000000..5784f2e --- /dev/null +++ b/tests/quotes_c99.l @@ -0,0 +1,132 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The point of this test is to be sure our M4 madness does not + * interfere with user code. I particular, we are looking + * for instances of M4 quotes, [[ and ]], in here to make it through the flex + * machinery unscathed. + */ + +/* sect 1 [ 1 ] TEST_XXX */ +/* sect 1 [[ 2 ]] TEST_XXX */ +/* sect 1 [[[ 3 ]]] TEST_XXX */ +/* sect 1 [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 ]] unmatched [[ TEST_XXX */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +#include +/*#include "parser.h" */ + +/* sect 1 block [ 1 ] TEST_XXX */ +/* sect 1 block [[ 2 ]] TEST_XXX */ +/* sect 1 block [[[ 3 ]]] TEST_XXX */ +/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 block ]] unmatched [[ TEST_XXX */ + +static int a[1] = {0}; +static int b[1] = {0}; +static int c[1] = {0}; + +static int foo (int i){ + return a[b[c[i]]]; /* sect 1 code TEST_XXX */ +} +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + /* indented code [ 1 ] */ + /* indented code [[ 2 ]] */ + /* indented code [[[ 3 ]]] */ + /* indented code [[[[ 4 ]]]] */ + /* indented code ]] unmatched [[ */ +%{ +// non-indented code [ 1 ] +// non-indented code [[ 2 ]] +// non-indented code [[[ 3 ]]] +// non-indented code [[[[ 4 ]]]] +%} + +a /* action comment [ 1 ] */ ; +b /* action comment [[ 2 ]] */ ; +c /* action comment [[[ 3 ]]] */ ; +d /* action comment [[[[ 4 ]]]] */ ; +e /* action comment ]] unmatched [[ */ ; +f return 1+foo(a[b[c[0]]]); +.|\n { + +#if 0 + action code [ 1 ] TEST_XXX + action code [[ 2 ]] TEST_XXX + action code [[[ 3 ]]] TEST_XXX + action code [[[[ 4 ]]]] TEST_XXX + action code ]] unmatched [[ TEST_XXX +#endif + /* action block [ 1 ] TEST_XXX */ + /* action block [[ 2 ]] TEST_XXX */ + /* action block [[[ 3 ]]] TEST_XXX */ + /* action block [[[[ 4 ]]]] TEST_XXX */ + /* action block ]] unmatched [[ TEST_XXX */ + assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); + assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); + assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); + assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); + assert(!strcmp("]]m4_define(alpha, beta)[[", + "]""]m4_""define(alpha, beta)[""[")); + return 1+foo(a[b[c[0]]]); /* TEST_XXX */ + } +%% + +/* sect 3 [ 1 ] TEST_XXX */ +/* sect 3 [[ 2 ]] TEST_XXX */ +/* sect 3 [[[ 3 ]]] TEST_XXX */ +/* sect 3 [[[[ 4 ]]]] TEST_XXX */ +/* sect 3 ]] unmatched [[ TEST_XXX */ +static int bar (int i){ + return c[b[a[i]]]; /* sect 3 code TEST_XXX */ +} +int main(void); + +#define CONCAT_IDENTS(a, b) a##b +int +main (void) +{ + /* m4_m4exit(100) */ + FILE *M4_YY_NOT_IN_HEADER = stdin; + yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); + yyout = stdout; + while (yylex()) + ; + assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); + printf("TEST RETURNING OK.\n"); + return bar(0); +} + diff --git a/tests/quotes_c99.txt b/tests/quotes_c99.txt new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/quotes_c99.txt @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/quotes_cpp.l b/tests/quotes_cpp.l new file mode 100644 index 0000000..d1b97eb --- /dev/null +++ b/tests/quotes_cpp.l @@ -0,0 +1,131 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The point of this test is to be sure our M4 madness does not + * interfere with user code. I particular, we are looking + * for instances of M4 quotes, [[ and ]], in here to make it through the flex + * machinery unscathed. + */ + +/* sect 1 [ 1 ] TEST_XXX */ +/* sect 1 [[ 2 ]] TEST_XXX */ +/* sect 1 [[[ 3 ]]] TEST_XXX */ +/* sect 1 [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 ]] unmatched [[ TEST_XXX */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +#include +/*#include "parser.h" */ + +/* sect 1 block [ 1 ] TEST_XXX */ +/* sect 1 block [[ 2 ]] TEST_XXX */ +/* sect 1 block [[[ 3 ]]] TEST_XXX */ +/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 block ]] unmatched [[ TEST_XXX */ + +static int a[1] = {0}; +static int b[1] = {0}; +static int c[1] = {0}; + +static int foo (int i){ + return a[b[c[i]]]; /* sect 1 code TEST_XXX */ +} +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + /* indented code [ 1 ] */ + /* indented code [[ 2 ]] */ + /* indented code [[[ 3 ]]] */ + /* indented code [[[[ 4 ]]]] */ + /* indented code ]] unmatched [[ */ +%{ +// non-indented code [ 1 ] +// non-indented code [[ 2 ]] +// non-indented code [[[ 3 ]]] +// non-indented code [[[[ 4 ]]]] +%} + +a /* action comment [ 1 ] */ ; +b /* action comment [[ 2 ]] */ ; +c /* action comment [[[ 3 ]]] */ ; +d /* action comment [[[[ 4 ]]]] */ ; +e /* action comment ]] unmatched [[ */ ; +f return 1+foo(a[b[c[0]]]); +.|\n { + +#if 0 + action code [ 1 ] TEST_XXX + action code [[ 2 ]] TEST_XXX + action code [[[ 3 ]]] TEST_XXX + action code [[[[ 4 ]]]] TEST_XXX + action code ]] unmatched [[ TEST_XXX +#endif + /* action block [ 1 ] TEST_XXX */ + /* action block [[ 2 ]] TEST_XXX */ + /* action block [[[ 3 ]]] TEST_XXX */ + /* action block [[[[ 4 ]]]] TEST_XXX */ + /* action block ]] unmatched [[ TEST_XXX */ + assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); + assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); + assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); + assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); + assert(!strcmp("]]m4_define(alpha, beta)[[", + "]""]m4_""define(alpha, beta)[""[")); + return 1+foo(a[b[c[0]]]); /* TEST_XXX */ + } +%% + +/* sect 3 [ 1 ] TEST_XXX */ +/* sect 3 [[ 2 ]] TEST_XXX */ +/* sect 3 [[[ 3 ]]] TEST_XXX */ +/* sect 3 [[[[ 4 ]]]] TEST_XXX */ +/* sect 3 ]] unmatched [[ TEST_XXX */ +static int bar (int i){ + return c[b[a[i]]]; /* sect 3 code TEST_XXX */ +} +int main(void); + +#define CONCAT_IDENTS(a, b) a##b +int +main (void) +{ + /* m4_m4exit(100) */ + FILE *M4_YY_NOT_IN_HEADER = stdin; + yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); + yyout = stdout; + while (yylex()) + ; + assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); + printf("TEST RETURNING OK.\n"); + return bar(0); +} + diff --git a/tests/quotes_cpp.txt b/tests/quotes_cpp.txt new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/quotes_cpp.txt @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/string_c99.l b/tests/string_c99.l new file mode 100644 index 0000000..656ea18 --- /dev/null +++ b/tests/string_c99.l @@ -0,0 +1,104 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" + +#define NUMBER 200 +#define WORD 201 + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain nodefault noyywrap noinput +%option warn reentrant + + +%% + +[[:space:]]+ { } +[[:digit:]]+ { printf("NUMBER "); fflush(stdout);} +[[:alpha:]]+ { printf("WORD "); fflush(stdout);} +. { + fprintf(stderr,"*** Error: Unrecognized character '%c' while scanning.\n", + yytext[0]); + yyterminate(); + } + +<> { printf("<>\n"); yyterminate();} + +%% + + +#define INPUT_STRING_1 "1234 foo bar" +#define INPUT_STRING_2 "1234 foo bar *@&@&###@^$#&#*" + +int main(void); + +int +main (void) +{ + char * buf; + size_t len; + YY_BUFFER_STATE state; + yyscan_t scanner=NULL; + + + /* Scan a good string. */ + printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout); + testlex_init(&scanner); + state = test_scan_string ( INPUT_STRING_1 ,scanner); + testlex(scanner); + test_delete_buffer(state, scanner); + testlex_destroy(scanner); + + /* Scan only the first 12 chars of a string. */ + printf("Testing: test_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout); + testlex_init(&scanner); + state = test_scan_bytes ( INPUT_STRING_2, 12 ,scanner); + testlex(scanner); + test_delete_buffer(state,scanner); + testlex_destroy(scanner); + + /* Scan directly from a buffer. + We make a copy, since the buffer will be modified by flex.*/ + printf("Testing: test_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout); + len = strlen(INPUT_STRING_1) + 2; + buf = malloc(len); + strcpy( buf, INPUT_STRING_1); + buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */ + buf[ len -1 ] =0; + + testlex_init(&scanner); + state = test_scan_buffer( buf, len ,scanner); + testlex(scanner); + test_delete_buffer(state,scanner); + testlex_destroy(scanner); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/top.l b/tests/top.l index 25f4773..cefb2e7 100644 --- a/tests/top.l +++ b/tests/top.l @@ -24,7 +24,8 @@ %{ /* Build "scanner.c". The scanner is not important. - This test is really about compilation. See "main.c". + This test is backend-independent; what it's really testing + is Flex's ability to accumulate and ship preamble code sections. */ #include #include diff --git a/tests/yyextra.l b/tests/yyextra.l deleted file mode 100644 index 5a5a014..0000000 --- a/tests/yyextra.l +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A file to build "scanner.c". */ -/* This tests that we can use "yyextra". - We buffer all input into a growable array, then print it. - We run diff on the input and output. -*/ - -#include -#include -#include "config.h" - - -/* We'll store the entire input in this buffer, growing as necessary. */ -struct Buffer { - int curr_len; - int max_len; - int grow_len; - char * data; -}; - -/* Save char into junk array at next position. */ -static void append_char (char c, yyscan_t scanner ); - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap nodefault noyyinput -%option warn -%option reentrant -%option extra-type="struct Buffer *" - -%% - -.|\r|\n { append_char (yytext[0],yyscanner); } - -%% - -int main(void); - -int -main (void) -{ - yyscan_t scanner; - struct Buffer * buf; - int i; - - buf = malloc(sizeof(struct Buffer)); - buf->curr_len =0; - buf->max_len = 4; - buf->grow_len = 100; - buf->data = malloc((size_t) buf->max_len); - - testlex_init(&scanner); - testset_in( stdin, scanner); - testset_out( stdout, scanner); - testset_extra( buf, scanner ); - testlex(scanner); - - buf = testget_extra(scanner); - for(i=0; i < buf->curr_len; i++) - fputc( buf->data[i], stdout ); - free( buf->data); - free( buf); - - testlex_destroy(scanner); - return 0; -} - -/* Save char into junk array at next position. */ -static void append_char (char c, yyscan_t scanner ) -{ - struct Buffer *buf, *new_buf; - buf = testget_extra(scanner); - - /* Grow buffer if necessary. */ - - if( buf->curr_len >= buf->max_len ) - { - new_buf = malloc(sizeof(struct Buffer)); - new_buf->max_len = buf->max_len + buf->grow_len; - new_buf->grow_len = buf->grow_len; - new_buf->data = malloc((size_t) new_buf->max_len); - for( new_buf->curr_len = 0; - new_buf->curr_len < buf->curr_len; - new_buf->curr_len++ ) - { - new_buf->data[ new_buf->curr_len] = buf->data [ new_buf->curr_len]; - } - free( buf->data ); - free( buf ); - buf = new_buf; - testset_extra( buf, scanner ); - } - - - buf->data[ buf->curr_len++ ] = c; -} diff --git a/tests/yyextra.txt b/tests/yyextra.txt deleted file mode 100644 index 243df29..0000000 --- a/tests/yyextra.txt +++ /dev/null @@ -1,795 +0,0 @@ - - THE UNITED STATES CONSTITUTION - _________________________________________________________________ - - (See Note 1) - - We the People of the United States, in Order to form a more perfect - Union, establish Justice, insure domestic Tranquility, provide for the - common defence, promote the general Welfare, and secure the Blessings - of Liberty to ourselves and our Posterity, do ordain and establish - this Constitution for the United States of America. - -Article. I. - - Section 1. - - All legislative Powers herein granted shall be vested in a Congress of - the United States, which shall consist of a Senate and House of - Representatives. - - Section. 2. - - Clause 1: The House of Representatives shall be composed of Members - chosen every second Year by the People of the several States, and the - Electors in each State shall have the Qualifications requisite for - Electors of the most numerous Branch of the State Legislature. - - Clause 2: No Person shall be a Representative who shall not have - attained to the Age of twenty five Years, and been seven Years a - Citizen of the United States, and who shall not, when elected, be an - Inhabitant of that State in which he shall be chosen. - - Clause 3: Representatives and direct Taxes shall be apportioned among - the several States which may be included within this Union, according - to their respective Numbers, which shall be determined by adding to - the whole Number of free Persons, including those bound to Service for - a Term of Years, and excluding Indians not taxed, three fifths of all - other Persons. (See Note 2) The actual Enumeration shall be made - within three Years after the first Meeting of the Congress of the - United States, and within every subsequent Term of ten Years, in such - Manner as they shall by Law direct. The Number of Representatives - shall not exceed one for every thirty Thousand, but each State shall - have at Least one Representative; and until such enumeration shall be - made, the State of New Hampshire shall be entitled to chuse three, - Massachusetts eight, Rhode-Island and Providence Plantations one, - Connecticut five, New-York six, New Jersey four, Pennsylvania eight, - Delaware one, Maryland six, Virginia ten, North Carolina five, South - Carolina five, and Georgia three. - - Clause 4: When vacancies happen in the Representation from any State, - the Executive Authority thereof shall issue Writs of Election to fill - such Vacancies. - - Clause 5: The House of Representatives shall chuse their Speaker and - other Officers; and shall have the sole Power of Impeachment. - - Section. 3. - - Clause 1: The Senate of the United States shall be composed of two - Senators from each State, chosen by the Legislature thereof, (See Note - 3) for six Years; and each Senator shall have one Vote. - - Clause 2: Immediately after they shall be assembled in Consequence of - the first Election, they shall be divided as equally as may be into - three Classes. The Seats of the Senators of the first Class shall be - vacated at the Expiration of the second Year, of the second Class at - the Expiration of the fourth Year, and of the third Class at the - Expiration of the sixth Year, so that one third may be chosen every - second Year; and if Vacancies happen by Resignation, or otherwise, - during the Recess of the Legislature of any State, the Executive - thereof may make temporary Appointments until the next Meeting of the - Legislature, which shall then fill such Vacancies. (See Note 4) - - Clause 3: No Person shall be a Senator who shall not have attained to - the Age of thirty Years, and been nine Years a Citizen of the United - States, and who shall not, when elected, be an Inhabitant of that - State for which he shall be chosen. - - Clause 4: The Vice President of the United States shall be President - of the Senate, but shall have no Vote, unless they be equally divided. - - Clause 5: The Senate shall chuse their other Officers, and also a - President pro tempore, in the Absence of the Vice President, or when - he shall exercise the Office of President of the United States. - - Clause 6: The Senate shall have the sole Power to try all - Impeachments. When sitting for that Purpose, they shall be on Oath or - Affirmation. When the President of the United States is tried, the - Chief Justice shall preside: And no Person shall be convicted without - the Concurrence of two thirds of the Members present. - - Clause 7: Judgment in Cases of Impeachment shall not extend further - than to removal from Office, and disqualification to hold and enjoy - any Office of honor, Trust or Profit under the United States: but the - Party convicted shall nevertheless be liable and subject to - Indictment, Trial, Judgment and Punishment, according to Law. - - Section. 4. - - Clause 1: The Times, Places and Manner of holding Elections for - Senators and Representatives, shall be prescribed in each State by the - Legislature thereof; but the Congress may at any time by Law make or - alter such Regulations, except as to the Places of chusing Senators. - - Clause 2: The Congress shall assemble at least once in every Year, and - such Meeting shall be on the first Monday in December, (See Note 5) - unless they shall by Law appoint a different Day. - - Section. 5. - - Clause 1: Each House shall be the Judge of the Elections, Returns and - Qualifications of its own Members, and a Majority of each shall - constitute a Quorum to do Business; but a smaller Number may adjourn - from day to day, and may be authorized to compel the Attendance of - absent Members, in such Manner, and under such Penalties as each House - may provide. - - Clause 2: Each House may determine the Rules of its Proceedings, - punish its Members for disorderly Behaviour, and, with the Concurrence - of two thirds, expel a Member. - - Clause 3: Each House shall keep a Journal of its Proceedings, and from - time to time publish the same, excepting such Parts as may in their - Judgment require Secrecy; and the Yeas and Nays of the Members of - either House on any question shall, at the Desire of one fifth of - those Present, be entered on the Journal. - - Clause 4: Neither House, during the Session of Congress, shall, - without the Consent of the other, adjourn for more than three days, - nor to any other Place than that in which the two Houses shall be - sitting. - - Section. 6. - - Clause 1: The Senators and Representatives shall receive a - Compensation for their Services, to be ascertained by Law, and paid - out of the Treasury of the United States. (See Note 6) They shall in - all Cases, except Treason, Felony and Breach of the Peace, - beprivileged from Arrest during their Attendance at the Session of - their respective Houses, and in going to and returning from the same; - and for any Speech or Debate in either House, they shall not be - questioned in any other Place. - - Clause 2: No Senator or Representative shall, during the Time for - which he was elected, be appointed to any civil Office under the - Authority of the United States, which shall have been created, or the - Emoluments whereof shall have been encreased during such time; and no - Person holding any Office under the United States, shall be a Member - of either House during his Continuance in Office. - - Section. 7. - - Clause 1: All Bills for raising Revenue shall originate in the House - of Representatives; but the Senate may propose or concur with - Amendments as on other Bills. - - Clause 2: Every Bill which shall have passed the House of - Representatives and the Senate, shall, before it become a Law, be - presented to the President of the United States; If he approve he - shall sign it, but if not he shall return it, with his Objections to - that House in which it shall have originated, who shall enter the - Objections at large on their Journal, and proceed to reconsider it. If - after such Reconsideration two thirds of that House shall agree to - pass the Bill, it shall be sent, together with the Objections, to the - other House, by which it shall likewise be reconsidered, and if - approved by two thirds of that House, it shall become a Law. But in - all such Cases the Votes of both Houses shall be determined by yeas - and Nays, and the Names of the Persons voting for and against the Bill - shall be entered on the Journal of each House respectively. If any - Bill shall not be returned by the President within ten Days (Sundays - excepted) after it shall have been presented to him, the Same shall be - a Law, in like Manner as if he had signed it, unless the Congress by - their Adjournment prevent its Return, in which Case it shall not be a - Law. - - Clause 3: Every Order, Resolution, or Vote to which the Concurrence of - the Senate and House of Representatives may be necessary (except on a - question of Adjournment) shall be presented to the President of the - United States; and before the Same shall take Effect, shall be - approved by him, or being disapproved by him, shall be repassed by two - thirds of the Senate and House of Representatives, according to the - Rules and Limitations prescribed in the Case of a Bill. - - Section. 8. - - Clause 1: The Congress shall have Power To lay and collect Taxes, - Duties, Imposts and Excises, to pay the Debts and provide for the - common Defence and general Welfare of the United States; but all - Duties, Imposts and Excises shall be uniform throughout the United - States; - - Clause 2: To borrow Money on the credit of the United States; - - Clause 3: To regulate Commerce with foreign Nations, and among the - several States, and with the Indian Tribes; - - Clause 4: To establish an uniform Rule of Naturalization, and uniform - Laws on the subject of Bankruptcies throughout the United States; - - Clause 5: To coin Money, regulate the Value thereof, and of foreign - Coin, and fix the Standard of Weights and Measures; - - Clause 6: To provide for the Punishment of counterfeiting the - Securities and current Coin of the United States; - - Clause 7: To establish Post Offices and post Roads; - - Clause 8: To promote the Progress of Science and useful Arts, by - securing for limited Times to Authors and Inventors the exclusive - Right to their respective Writings and Discoveries; - - Clause 9: To constitute Tribunals inferior to the supreme Court; - - Clause 10: To define and punish Piracies and Felonies committed on the - high Seas, and Offences against the Law of Nations; - - Clause 11: To declare War, grant Letters of Marque and Reprisal, and - make Rules concerning Captures on Land and Water; - - Clause 12: To raise and support Armies, but no Appropriation of Money - to that Use shall be for a longer Term than two Years; - - Clause 13: To provide and maintain a Navy; - - Clause 14: To make Rules for the Government and Regulation of the land - and naval Forces; - - Clause 15: To provide for calling forth the Militia to execute the - Laws of the Union, suppress Insurrections and repel Invasions; - - Clause 16: To provide for organizing, arming, and disciplining, the - Militia, and for governing such Part of them as may be employed in the - Service of the United States, reserving to the States respectively, - the Appointment of the Officers, and the Authority of training the - Militia according to the discipline prescribed by Congress; - - Clause 17: To exercise exclusive Legislation in all Cases whatsoever, - over such District (not exceeding ten Miles square) as may, byCession - of particular States, and the Acceptance of Congress, become the Seat - of the Government of the United States, and to exercise like Authority - over all Places purchased by the Consent of the Legislature of the - State in which the Same shall be, for the Erection of Forts, - Magazines, Arsenals, dock-Yards, and other needful Buildings;--And - - Clause 18: To make all Laws which shall be necessary and proper for - carrying into Execution the foregoing Powers, and all other Powers - vested by this Constitution in the Government of the United States, or - in any Department or Officer thereof. - - Section. 9. - - Clause 1: The Migration or Importation of such Persons as any of the - States now existing shall think proper to admit, shall not be - prohibited by the Congress prior to the Year one thousand eight - hundred and eight, but a Tax or duty may be imposed on such - Importation, not exceeding ten dollars for each Person. - - Clause 2: The Privilege of the Writ of Habeas Corpus shall not be - suspended, unless when in Cases of Rebellion or Invasion the public - Safety may require it. - - Clause 3: No Bill of Attainder or ex post facto Law shall be passed. - - Clause 4: No Capitation, or other direct, Tax shall be laid, unless in - Proportion to the Census or Enumeration herein before directed to be - taken. (See Note 7) - - Clause 5: No Tax or Duty shall be laid on Articles exported from any - State. - - Clause 6: No Preference shall be given by any Regulation of Commerce - or Revenue to the Ports of one State over those of another: nor shall - Vessels bound to, or from, one State, be obliged to enter, clear, or - pay Duties in another. - - Clause 7: No Money shall be drawn from the Treasury, but in - Consequence of Appropriations made by Law; and a regular Statement and - Account of the Receipts and Expenditures of all public Money shall be - published from time to time. - - Clause 8: No Title of Nobility shall be granted by the United States: - And no Person holding any Office of Profit or Trust under them, shall, - without the Consent of the Congress, accept of any present, Emolument, - Office, or Title, of any kind whatever, from any King, Prince, or - foreign State. - - Section. 10. - - Clause 1: No State shall enter into any Treaty, Alliance, or - Confederation; grant Letters of Marque and Reprisal; coin Money; emit - Bills of Credit; make any Thing but gold and silver Coin a Tender in - Payment of Debts; pass any Bill of Attainder, ex post facto Law, or - Law impairing the Obligation of Contracts, or grant any Title of - Nobility. - - Clause 2: No State shall, without the Consent of the Congress, lay any - Imposts or Duties on Imports or Exports, except what may be absolutely - necessary for executing it's inspection Laws: and the net Produce of - all Duties and Imposts, laid by any State on Imports or Exports, shall - be for the Use of the Treasury of the United States; and all such Laws - shall be subject to the Revision and Controul of the Congress. - - Clause 3: No State shall, without the Consent of Congress, lay any - Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter - into any Agreement or Compact with another State, or with a foreign - Power, or engage in War, unless actually invaded, or in such imminent - Danger as will not admit of delay. - -Article. II. - - Section. 1. - - Clause 1: The executive Power shall be vested in a President of the - United States of America. He shall hold his Office during the Term of - four Years, and, together with the Vice President, chosen for the same - Term, be elected, as follows - - Clause 2: Each State shall appoint, in such Manner as the Legislature - thereof may direct, a Number of Electors, equal to the whole Number of - Senators and Representatives to which the State may be entitled in the - Congress: but no Senator or Representative, or Person holding an - Office of Trust or Profit under the United States, shall be appointed - an Elector. - - Clause 3: The Electors shall meet in their respective States, and vote - by Ballot for two Persons, of whom one at least shall not be an - Inhabitant of the same State with themselves. And they shall make a - List of all the Persons voted for, and of the Number of Votes for - each; which List they shall sign and certify, and transmit sealed to - the Seat of the Government of the United States, directed to the - President of the Senate. The President of the Senate shall, in the - Presence of the Senate and House of Representatives, open all the - Certificates, and the Votes shall then be counted. The Person having - the greatest Number of Votes shall be the President, if such Number be - a Majority of the whole Number of Electors appointed; and if there be - more than one who have such Majority, and have an equal Number of - Votes, then the House of Representatives shall immediately chuse by - Ballot one of them for President; and if no Person have a Majority, - then from the five highest on the List the said House shall in like - Manner chuse the President. But in chusing the President, the Votes - shall be taken by States, the Representation from each State having - one Vote; A quorum for this Purpose shall consist of a Member or - Members from two thirds of the States, and a Majority of all the - States shall be necessary to a Choice. In every Case, after the Choice - of the President, the Person having the greatest Number of Votes of - the Electors shall be the Vice President. But if there should remain - two or more who have equal Votes, the Senate shall chuse from them by - Ballot the Vice President. (See Note 8) - - Clause 4: The Congress may determine the Time of chusing the Electors, - and the Day on which they shall give their Votes; which Day shall be - the same throughout the United States. - - Clause 5: No Person except a natural born Citizen, or a Citizen of the - United States, at the time of the Adoption of this Constitution, shall - be eligible to the Office of President; neither shall any Person be - eligible to that Office who shall not have attained to the Age of - thirty five Years, and been fourteen Years a Resident within the - United States. - - Clause 6: In Case of the Removal of the President from Office, or of - his Death, Resignation, or Inability to discharge the Powers and - Duties of the said Office, (See Note 9) the Same shall devolve on the - VicePresident, and the Congress may by Law provide for the Case of - Removal, Death, Resignation or Inability, both of the President and - Vice President, declaring what Officer shall then act as President, - and such Officer shall act accordingly, until the Disability be - removed, or a President shall be elected. - - Clause 7: The President shall, at stated Times, receive for his - Services, a Compensation, which shall neither be encreased nor - diminished during the Period for which he shall have been elected, and - he shall not receive within that Period any other Emolument from the - United States, or any of them. - - Clause 8: Before he enter on the Execution of his Office, he shall - take the following Oath or Affirmation:--"I do solemnly swear (or - affirm) that I will faithfully execute the Office of President of the - United States, and will to the best of my Ability, preserve, protect - and defend the Constitution of the United States." - - Section. 2. - - Clause 1: The President shall be Commander in Chief of the Army and - Navy of the United States, and of the Militia of the several States, - when called into the actual Service of the United States; he may - require the Opinion, in writing, of the principal Officer in each of - the executive Departments, upon any Subject relating to the Duties of - their respective Offices, and he shall have Power to grant Reprieves - and Pardons for Offences against the United States, except in Cases of - Impeachment. - - Clause 2: He shall have Power, by and with the Advice and Consent of - the Senate, to make Treaties, provided two thirds of the Senators - present concur; and he shall nominate, and by and with the Advice and - Consent of the Senate, shall appoint Ambassadors, other public - Ministers and Consuls, Judges of the supreme Court, and all other - Officers of the United States, whose Appointments are not herein - otherwise provided for, and which shall be established by Law: but the - Congress may by Law vest the Appointment of such inferior Officers, as - they think proper, in the President alone, in the Courts of Law, or in - the Heads of Departments. - - Clause 3: The President shall have Power to fill up all Vacancies that - may happen during the Recess of the Senate, by granting Commissions - which shall expire at the End of their next Session. - - Section. 3. - - He shall from time to time give to the Congress Information of the - State of the Union, and recommend to their Consideration such Measures - as he shall judge necessary and expedient; he may, on extraordinary - Occasions, convene both Houses, or either of them, and in Case of - Disagreement between them, with Respect to the Time of Adjournment, he - may adjourn them to such Time as he shall think proper; he shall - receive Ambassadors and other public Ministers; he shall take Care - that the Laws be faithfully executed, and shall Commission all the - Officers of the United States. - - Section. 4. - - The President, Vice President and all civil Officers of the United - States, shall be removed from Office on Impeachment for, and - Conviction of, Treason, Bribery, or other high Crimes and - Misdemeanors. - -Article. III. - - Section. 1. - - The judicial Power of the United States, shall be vested in one - supreme Court, and in such inferior Courts as the Congress may from - time to time ordain and establish. The Judges, both of the supreme and - inferior Courts, shall hold their Offices during good Behaviour, and - shall, at stated Times, receive for their Services, a Compensation, - which shall not be diminished during their Continuance in Office. - - Section. 2. - - Clause 1: The judicial Power shall extend to all Cases, in Law and - Equity, arising under this Constitution, the Laws of the United - States, and Treaties made, or which shall be made, under their - Authority;--to all Cases affecting Ambassadors, other public Ministers - and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to - Controversies to which the United States shall be a Party;--to - Controversies between two or more States;--between a State and - Citizens of another State; (See Note 10)--between Citizens of - different States, --between Citizens of the same State claiming Lands - under Grants of different States, and between a State, or the Citizens - thereof, and foreign States, Citizens or Subjects. - - Clause 2: In all Cases affecting Ambassadors, other public Ministers - and Consuls, and those in which a State shall be Party, the supreme - Court shall have original Jurisdiction. In all the other Cases before - mentioned, the supreme Court shall have appellate Jurisdiction, both - as to Law and Fact, with such Exceptions, and under such Regulations - as the Congress shall make. - - Clause 3: The Trial of all Crimes, except in Cases of Impeachment, - shall be by Jury; and such Trial shall be held in the State where the - said Crimes shall have been committed; but when not committed within - any State, the Trial shall be at such Place or Places as the Congress - may by Law have directed. - - Section. 3. - - Clause 1: Treason against the United States, shall consist only in - levying War against them, or in adhering to their Enemies, giving them - Aid and Comfort. No Person shall be convicted of Treason unless on the - Testimony of two Witnesses to the same overt Act, or on Confession in - open Court. - - Clause 2: The Congress shall have Power to declare the Punishment of - Treason, but no Attainder of Treason shall work Corruption of Blood, - or Forfeiture except during the Life of the Person attainted. - -Article. IV. - - Section. 1. - - Full Faith and Credit shall be given in each State to the public Acts, - Records, and judicial Proceedings of every other State. And the - Congress may by general Laws prescribe the Manner in which such Acts, - Records and Proceedings shall be proved, and the Effect thereof. - - Section. 2. - - Clause 1: The Citizens of each State shall be entitled to all - Privileges and Immunities of Citizens in the several States. - - Clause 2: A Person charged in any State with Treason, Felony, or other - Crime, who shall flee from Justice, and be found in another State, - shall on Demand of the executive Authority of the State from which he - fled, be delivered up, to be removed to the State having Jurisdiction - of the Crime. - - Clause 3: No Person held to Service or Labour in one State, under the - Laws thereof, escaping into another, shall, in Consequence of any Law - or Regulation therein, be discharged from such Service or Labour, but - shall be delivered up on Claim of the Party to whom such Service or - Labour may be due. (See Note 11) - - Section. 3. - - Clause 1: New States may be admitted by the Congress into this Union; - but no new State shall be formed or erected within the Jurisdiction of - any other State; nor any State be formed by the Junction of two or - more States, or Parts of States, without the Consent of the - Legislatures of the States concerned as well as of the Congress. - - Clause 2: The Congress shall have Power to dispose of and make all - needful Rules and Regulations respecting the Territory or other - Property belonging to the United States; and nothing in this - Constitution shall be so construed as to Prejudice any Claims of the - United States, or of any particular State. - - Section. 4. - - The United States shall guarantee to every State in this Union a - Republican Form of Government, and shall protect each of them against - Invasion; and on Application of the Legislature, or of the Executive - (when the Legislature cannot be convened) against domestic Violence. - -Article. V. - - The Congress, whenever two thirds of both Houses shall deem it - necessary, shall propose [1]Amendments to this Constitution, or, on - the Application of the Legislatures of two thirds of the several - States, shall call a Convention for proposing Amendments, which, in - either Case, shall be valid to all Intents and Purposes, as Part of - this Constitution, when ratified by the Legislatures of three fourths - of the several States, or by Conventions in three fourths thereof, as - the one or the other Mode of Ratification may be proposed by the - Congress; Provided that no Amendment which may be made prior to the - Year One thousand eight hundred and eight shall in any Manner affect - the first and fourth Clauses in the Ninth Section of the first - Article; and that no State, without its Consent, shall be deprived of - its equal Suffrage in the Senate. - -Article. VI. - - Clause 1: All Debts contracted and Engagements entered into, before - the Adoption of this Constitution, shall be as valid against the - United States under this Constitution, as under the Confederation. - - Clause 2: This Constitution, and the Laws of the United States which - shall be made in Pursuance thereof; and all Treaties made, or which - shall be made, under the Authority of the United States, shall be the - supreme Law of the Land; and the Judges in every State shall be bound - thereby, any Thing in the Constitution or Laws of any State to the - Contrary notwithstanding. - - Clause 3: The Senators and Representatives before mentioned, and the - Members of the several State Legislatures, and all executive and - judicial Officers, both of the United States and of the several - States, shall be bound by Oath or Affirmation, to support this - Constitution; but no religious Test shall ever be required as a - Qualification to any Office or public Trust under the United States. - -Article. VII. - - The Ratification of the Conventions of nine States, shall be - sufficient for the Establishment of this Constitution between the - States so ratifying the Same. - - done in Convention by the Unanimous Consent of the States present the - Seventeenth Day of September in the Year of our Lord one thousand - seven hundred and Eighty seven and of the Independence of the United - States of America the Twelfth In witness whereof We have hereunto - subscribed our Names, - - GO WASHINGTON--Presidt. and deputy from Virginia - - [Signed also by the deputies of twelve States.] - - Delaware - - Geo: Read - Gunning Bedford jun - John Dickinson - Richard Bassett - Jaco: Broom - - Maryland - - James MCHenry - Dan of ST ThoS. Jenifer - DanL Carroll. - - Virginia - - John Blair-- - James Madison Jr. - - North Carolina - - WM Blount - RichD. Dobbs Spaight. - Hu Williamson - - South Carolina - - J. Rutledge - Charles 1ACotesworth Pinckney - Charles Pinckney - Pierce Butler. - - Georgia - - William Few - Abr Baldwin - - New Hampshire - - John Langdon - Nicholas Gilman - - Massachusetts - - Nathaniel Gorham - Rufus King - - Connecticut - WM. SamL. Johnson - Roger Sherman - - New York - - Alexander Hamilton - - New Jersey - - Wil: Livingston - David Brearley. - WM. Paterson. - Jona: Dayton - - Pennsylvania - - B Franklin - Thomas Mifflin - RobT Morris - Geo. Clymer - ThoS. FitzSimons - Jared Ingersoll - James Wilson. - Gouv Morris - - Attest William Jackson Secretary - - NOTES - - Note 1: This text of the Constitution follows the engrossed copy - signed by Gen. Washington and the deputies from 12 States. The small - superior figures preceding the paragraphs designate Clauses, and were - not in the original and have no reference to footnotes. - - The Constitution was adopted by a convention of the States on - September 17, 1787, and was subsequently ratified by the several - States, on the following dates: Delaware, December 7, 1787; - Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; - Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, - February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, - 1788; New Hampshire, June 21, 1788. - - Ratification was completed on June 21, 1788. - - The Constitution was subsequently ratified by Virginia, June 25, 1788; - New York, July 26, 1788; North Carolina, November 21, 1789; Rhode - Island, May 29, 1790; and Vermont, January 10, 1791. - - In May 1785, a committee of Congress made a report recommending an - alteration in the Articles of Confederation, but no action was taken - on it, and it was left to the State Legislatures to proceed in the - matter. In January 1786, the Legislature of Virginia passed a - resolution providing for the appointment of five commissioners, who, - or any three of them, should meet such commissioners as might be - appointed in the other States of the Union, at a time and place to be - agreed upon, to take into consideration the trade of the United - States; to consider how far a uniform system in their commercial - regulations may be necessary to their common interest and their - permanent harmony; and to report to the several States such an act, - relative to this great object, as, when ratified by them, will enable - the United States in Congress effectually to provide for the same. The - Virginia commissioners, after some correspondence, fixed the first - Monday in September as the time, and the city of Annapolis as the - place for the meeting, but only four other States were represented, - viz: Delaware, New York, New Jersey, and Pennsylvania; the - commissioners appointed by Massachusetts, New Hampshire, North - Carolina, and Rhode Island failed to attend. Under the circumstances - of so partial a representation, the commissioners present agreed upon - a report, (drawn by Mr. Hamilton, of New York,) expressing their - unanimous conviction that it might essentially tend to advance the - interests of the Union if the States by which they were respectively - delegated would concur, and use their endeavors to procure the - concurrence of the other States, in the appointment of commissioners - to meet at Philadelphia on the Second Monday of May following, to take - into consideration the situation of the United States; to devise such - further provisions as should appear to them necessary to render the - Constitution of the Federal Government adequate to the exigencies of - the Union; and to report such an act for that purpose to the United - States in Congress assembled as, when agreed to by them and afterwards - confirmed by the Legislatures of every State, would effectually - provide for the same. - - Congress, on the 21st of February, 1787, adopted a resolution in favor - of a convention, and the Legislatures of those States which had not - already done so (with the exception of Rhode Island) promptly - appointed delegates. On the 25th of May, seven States having convened, - George Washington, of Virginia, was unanimously elected President, and - the consideration of the proposed constitution was commenced. On the - 17th of September, 1787, the Constitution as engrossed and agreed upon - was signed by all the members present, except Mr. Gerry of - Massachusetts, and Messrs. Mason and Randolph, of Virginia. The - president of the convention transmitted it to Congress, with a - resolution stating how the proposed Federal Government should be put - in operation, and an explanatory letter. Congress, on the 28th of - September, 1787, directed the Constitution so framed, with the - resolutions and letter concerning the same, to "be transmitted to the - several Legislatures in order to be submitted to a convention of - delegates chosen in each State by the people thereof, in conformity to - the resolves of the convention." - - On the 4th of March, 1789, the day which had been fixed for commencing - the operations of Government under the new Constitution, it had been - ratified by the conventions chosen in each State to consider it, as - follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; - New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, - January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, - 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; - Virginia, June 25, 1788; and New York, July 26, 1788. - - The President informed Congress, on the 28th of January, 1790, that - North Carolina had ratified the Constitution November 21, 1789; and he - informed Congress on the 1st of June, 1790, that Rhode Island had - ratified the Constitution May 29, 1790. Vermont, in convention, - ratified the Constitution January 10, 1791, and was, by an act of - Congress approved February 18, 1791, "received and admitted into this - Union as a new and entire member of the United States." - - Note 2: The part of this Clause relating to the mode of apportionment - of representatives among the several States has been affected by - Section 2 of amendment XIV, and as to taxes on incomes without - apportionment by amendment XVI. - - Note 3: This Clause has been affected by Clause 1 of amendment XVII. - - Note 4: This Clause has been affected by Clause 2 of amendment XVIII. - - Note 5: This Clause has been affected by amendment XX. - - Note 6: This Clause has been affected by amendment XXVII. - - Note 7: This Clause has been affected by amendment XVI. - - Note 8: This Clause has been superseded by amendment XII. - - Note 9: This Clause has been affected by amendment XXV. - - Note 10: This Clause has been affected by amendment XI. - - Note 11: This Clause has been affected by amendment XIII. - - Note 12: The first ten amendments to the Constitution of the United - States (and two others, one of which failed of ratification and the - other which later became the 27th amendment) were proposed to the - legislatures of the several States by the First Congress on September - 25, 1789. The first ten amendments were ratified by the following - States, and the notifications of ratification by the Governors thereof - were successively communicated by the President to Congress: New - Jersey, November 20, 1789; Maryland, December 19, 1789; North - Carolina, December 22, 1789; South Carolina, January 19, 1790; New - Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, - February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, - 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. - - Ratification was completed on December 15, 1791. - - The amendments were subsequently ratified by the legislatures of - Massachusetts, March 2, 1939; Georgia, March 18, 1939; and - Connecticut, April 19, 1939. - - Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had - numbers assigned to them at the time of ratification. - - Note 14: This sentence has been superseded by section 3 of amendment - XX. - - Note 15: See amendment XIX and section 1 of amendment XXVI. - - Note 16: Repealed by section 1 of amendment XXI. - -References - - 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/yyextra_c99.l b/tests/yyextra_c99.l new file mode 100644 index 0000000..66e2b4b --- /dev/null +++ b/tests/yyextra_c99.l @@ -0,0 +1,121 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A file to build "scanner.c". */ +/* This tests that we can use "yyextra". + We buffer all input into a growable array, then print it. + We run diff on the input and output. +*/ + +#include +#include +#include "config.h" + + +/* We'll store the entire input in this buffer, growing as necessary. */ +struct Buffer { + int curr_len; + int max_len; + int grow_len; + char * data; +}; + +/* Save char into junk array at next position. */ +static void append_char (char c, yyscan_t scanner ); + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap nodefault noyyinput +%option warn +%option reentrant +%option extra-type="struct Buffer *" + +%% + +.|\r|\n { append_char (yytext[0],yyscanner); } + +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + struct Buffer * buf; + int i; + + buf = malloc(sizeof(struct Buffer)); + buf->curr_len =0; + buf->max_len = 4; + buf->grow_len = 100; + buf->data = malloc((size_t) buf->max_len); + + testlex_init(&scanner); + testset_in( stdin, scanner); + testset_out( stdout, scanner); + testset_extra( buf, scanner ); + testlex(scanner); + + buf = testget_extra(scanner); + for(i=0; i < buf->curr_len; i++) + fputc( buf->data[i], stdout ); + free( buf->data); + free( buf); + + testlex_destroy(scanner); + return 0; +} + +/* Save char into junk array at next position. */ +static void append_char (char c, yyscan_t scanner ) +{ + struct Buffer *buf, *new_buf; + buf = testget_extra(scanner); + + /* Grow buffer if necessary. */ + + if( buf->curr_len >= buf->max_len ) + { + new_buf = malloc(sizeof(struct Buffer)); + new_buf->max_len = buf->max_len + buf->grow_len; + new_buf->grow_len = buf->grow_len; + new_buf->data = malloc((size_t) new_buf->max_len); + for( new_buf->curr_len = 0; + new_buf->curr_len < buf->curr_len; + new_buf->curr_len++ ) + { + new_buf->data[ new_buf->curr_len] = buf->data [ new_buf->curr_len]; + } + free( buf->data ); + free( buf ); + buf = new_buf; + testset_extra( buf, scanner ); + } + + + buf->data[ buf->curr_len++ ] = c; +} diff --git a/tests/yyextra_c99.txt b/tests/yyextra_c99.txt new file mode 100644 index 0000000..243df29 --- /dev/null +++ b/tests/yyextra_c99.txt @@ -0,0 +1,795 @@ + + THE UNITED STATES CONSTITUTION + _________________________________________________________________ + + (See Note 1) + + We the People of the United States, in Order to form a more perfect + Union, establish Justice, insure domestic Tranquility, provide for the + common defence, promote the general Welfare, and secure the Blessings + of Liberty to ourselves and our Posterity, do ordain and establish + this Constitution for the United States of America. + +Article. I. + + Section 1. + + All legislative Powers herein granted shall be vested in a Congress of + the United States, which shall consist of a Senate and House of + Representatives. + + Section. 2. + + Clause 1: The House of Representatives shall be composed of Members + chosen every second Year by the People of the several States, and the + Electors in each State shall have the Qualifications requisite for + Electors of the most numerous Branch of the State Legislature. + + Clause 2: No Person shall be a Representative who shall not have + attained to the Age of twenty five Years, and been seven Years a + Citizen of the United States, and who shall not, when elected, be an + Inhabitant of that State in which he shall be chosen. + + Clause 3: Representatives and direct Taxes shall be apportioned among + the several States which may be included within this Union, according + to their respective Numbers, which shall be determined by adding to + the whole Number of free Persons, including those bound to Service for + a Term of Years, and excluding Indians not taxed, three fifths of all + other Persons. (See Note 2) The actual Enumeration shall be made + within three Years after the first Meeting of the Congress of the + United States, and within every subsequent Term of ten Years, in such + Manner as they shall by Law direct. The Number of Representatives + shall not exceed one for every thirty Thousand, but each State shall + have at Least one Representative; and until such enumeration shall be + made, the State of New Hampshire shall be entitled to chuse three, + Massachusetts eight, Rhode-Island and Providence Plantations one, + Connecticut five, New-York six, New Jersey four, Pennsylvania eight, + Delaware one, Maryland six, Virginia ten, North Carolina five, South + Carolina five, and Georgia three. + + Clause 4: When vacancies happen in the Representation from any State, + the Executive Authority thereof shall issue Writs of Election to fill + such Vacancies. + + Clause 5: The House of Representatives shall chuse their Speaker and + other Officers; and shall have the sole Power of Impeachment. + + Section. 3. + + Clause 1: The Senate of the United States shall be composed of two + Senators from each State, chosen by the Legislature thereof, (See Note + 3) for six Years; and each Senator shall have one Vote. + + Clause 2: Immediately after they shall be assembled in Consequence of + the first Election, they shall be divided as equally as may be into + three Classes. The Seats of the Senators of the first Class shall be + vacated at the Expiration of the second Year, of the second Class at + the Expiration of the fourth Year, and of the third Class at the + Expiration of the sixth Year, so that one third may be chosen every + second Year; and if Vacancies happen by Resignation, or otherwise, + during the Recess of the Legislature of any State, the Executive + thereof may make temporary Appointments until the next Meeting of the + Legislature, which shall then fill such Vacancies. (See Note 4) + + Clause 3: No Person shall be a Senator who shall not have attained to + the Age of thirty Years, and been nine Years a Citizen of the United + States, and who shall not, when elected, be an Inhabitant of that + State for which he shall be chosen. + + Clause 4: The Vice President of the United States shall be President + of the Senate, but shall have no Vote, unless they be equally divided. + + Clause 5: The Senate shall chuse their other Officers, and also a + President pro tempore, in the Absence of the Vice President, or when + he shall exercise the Office of President of the United States. + + Clause 6: The Senate shall have the sole Power to try all + Impeachments. When sitting for that Purpose, they shall be on Oath or + Affirmation. When the President of the United States is tried, the + Chief Justice shall preside: And no Person shall be convicted without + the Concurrence of two thirds of the Members present. + + Clause 7: Judgment in Cases of Impeachment shall not extend further + than to removal from Office, and disqualification to hold and enjoy + any Office of honor, Trust or Profit under the United States: but the + Party convicted shall nevertheless be liable and subject to + Indictment, Trial, Judgment and Punishment, according to Law. + + Section. 4. + + Clause 1: The Times, Places and Manner of holding Elections for + Senators and Representatives, shall be prescribed in each State by the + Legislature thereof; but the Congress may at any time by Law make or + alter such Regulations, except as to the Places of chusing Senators. + + Clause 2: The Congress shall assemble at least once in every Year, and + such Meeting shall be on the first Monday in December, (See Note 5) + unless they shall by Law appoint a different Day. + + Section. 5. + + Clause 1: Each House shall be the Judge of the Elections, Returns and + Qualifications of its own Members, and a Majority of each shall + constitute a Quorum to do Business; but a smaller Number may adjourn + from day to day, and may be authorized to compel the Attendance of + absent Members, in such Manner, and under such Penalties as each House + may provide. + + Clause 2: Each House may determine the Rules of its Proceedings, + punish its Members for disorderly Behaviour, and, with the Concurrence + of two thirds, expel a Member. + + Clause 3: Each House shall keep a Journal of its Proceedings, and from + time to time publish the same, excepting such Parts as may in their + Judgment require Secrecy; and the Yeas and Nays of the Members of + either House on any question shall, at the Desire of one fifth of + those Present, be entered on the Journal. + + Clause 4: Neither House, during the Session of Congress, shall, + without the Consent of the other, adjourn for more than three days, + nor to any other Place than that in which the two Houses shall be + sitting. + + Section. 6. + + Clause 1: The Senators and Representatives shall receive a + Compensation for their Services, to be ascertained by Law, and paid + out of the Treasury of the United States. (See Note 6) They shall in + all Cases, except Treason, Felony and Breach of the Peace, + beprivileged from Arrest during their Attendance at the Session of + their respective Houses, and in going to and returning from the same; + and for any Speech or Debate in either House, they shall not be + questioned in any other Place. + + Clause 2: No Senator or Representative shall, during the Time for + which he was elected, be appointed to any civil Office under the + Authority of the United States, which shall have been created, or the + Emoluments whereof shall have been encreased during such time; and no + Person holding any Office under the United States, shall be a Member + of either House during his Continuance in Office. + + Section. 7. + + Clause 1: All Bills for raising Revenue shall originate in the House + of Representatives; but the Senate may propose or concur with + Amendments as on other Bills. + + Clause 2: Every Bill which shall have passed the House of + Representatives and the Senate, shall, before it become a Law, be + presented to the President of the United States; If he approve he + shall sign it, but if not he shall return it, with his Objections to + that House in which it shall have originated, who shall enter the + Objections at large on their Journal, and proceed to reconsider it. If + after such Reconsideration two thirds of that House shall agree to + pass the Bill, it shall be sent, together with the Objections, to the + other House, by which it shall likewise be reconsidered, and if + approved by two thirds of that House, it shall become a Law. But in + all such Cases the Votes of both Houses shall be determined by yeas + and Nays, and the Names of the Persons voting for and against the Bill + shall be entered on the Journal of each House respectively. If any + Bill shall not be returned by the President within ten Days (Sundays + excepted) after it shall have been presented to him, the Same shall be + a Law, in like Manner as if he had signed it, unless the Congress by + their Adjournment prevent its Return, in which Case it shall not be a + Law. + + Clause 3: Every Order, Resolution, or Vote to which the Concurrence of + the Senate and House of Representatives may be necessary (except on a + question of Adjournment) shall be presented to the President of the + United States; and before the Same shall take Effect, shall be + approved by him, or being disapproved by him, shall be repassed by two + thirds of the Senate and House of Representatives, according to the + Rules and Limitations prescribed in the Case of a Bill. + + Section. 8. + + Clause 1: The Congress shall have Power To lay and collect Taxes, + Duties, Imposts and Excises, to pay the Debts and provide for the + common Defence and general Welfare of the United States; but all + Duties, Imposts and Excises shall be uniform throughout the United + States; + + Clause 2: To borrow Money on the credit of the United States; + + Clause 3: To regulate Commerce with foreign Nations, and among the + several States, and with the Indian Tribes; + + Clause 4: To establish an uniform Rule of Naturalization, and uniform + Laws on the subject of Bankruptcies throughout the United States; + + Clause 5: To coin Money, regulate the Value thereof, and of foreign + Coin, and fix the Standard of Weights and Measures; + + Clause 6: To provide for the Punishment of counterfeiting the + Securities and current Coin of the United States; + + Clause 7: To establish Post Offices and post Roads; + + Clause 8: To promote the Progress of Science and useful Arts, by + securing for limited Times to Authors and Inventors the exclusive + Right to their respective Writings and Discoveries; + + Clause 9: To constitute Tribunals inferior to the supreme Court; + + Clause 10: To define and punish Piracies and Felonies committed on the + high Seas, and Offences against the Law of Nations; + + Clause 11: To declare War, grant Letters of Marque and Reprisal, and + make Rules concerning Captures on Land and Water; + + Clause 12: To raise and support Armies, but no Appropriation of Money + to that Use shall be for a longer Term than two Years; + + Clause 13: To provide and maintain a Navy; + + Clause 14: To make Rules for the Government and Regulation of the land + and naval Forces; + + Clause 15: To provide for calling forth the Militia to execute the + Laws of the Union, suppress Insurrections and repel Invasions; + + Clause 16: To provide for organizing, arming, and disciplining, the + Militia, and for governing such Part of them as may be employed in the + Service of the United States, reserving to the States respectively, + the Appointment of the Officers, and the Authority of training the + Militia according to the discipline prescribed by Congress; + + Clause 17: To exercise exclusive Legislation in all Cases whatsoever, + over such District (not exceeding ten Miles square) as may, byCession + of particular States, and the Acceptance of Congress, become the Seat + of the Government of the United States, and to exercise like Authority + over all Places purchased by the Consent of the Legislature of the + State in which the Same shall be, for the Erection of Forts, + Magazines, Arsenals, dock-Yards, and other needful Buildings;--And + + Clause 18: To make all Laws which shall be necessary and proper for + carrying into Execution the foregoing Powers, and all other Powers + vested by this Constitution in the Government of the United States, or + in any Department or Officer thereof. + + Section. 9. + + Clause 1: The Migration or Importation of such Persons as any of the + States now existing shall think proper to admit, shall not be + prohibited by the Congress prior to the Year one thousand eight + hundred and eight, but a Tax or duty may be imposed on such + Importation, not exceeding ten dollars for each Person. + + Clause 2: The Privilege of the Writ of Habeas Corpus shall not be + suspended, unless when in Cases of Rebellion or Invasion the public + Safety may require it. + + Clause 3: No Bill of Attainder or ex post facto Law shall be passed. + + Clause 4: No Capitation, or other direct, Tax shall be laid, unless in + Proportion to the Census or Enumeration herein before directed to be + taken. (See Note 7) + + Clause 5: No Tax or Duty shall be laid on Articles exported from any + State. + + Clause 6: No Preference shall be given by any Regulation of Commerce + or Revenue to the Ports of one State over those of another: nor shall + Vessels bound to, or from, one State, be obliged to enter, clear, or + pay Duties in another. + + Clause 7: No Money shall be drawn from the Treasury, but in + Consequence of Appropriations made by Law; and a regular Statement and + Account of the Receipts and Expenditures of all public Money shall be + published from time to time. + + Clause 8: No Title of Nobility shall be granted by the United States: + And no Person holding any Office of Profit or Trust under them, shall, + without the Consent of the Congress, accept of any present, Emolument, + Office, or Title, of any kind whatever, from any King, Prince, or + foreign State. + + Section. 10. + + Clause 1: No State shall enter into any Treaty, Alliance, or + Confederation; grant Letters of Marque and Reprisal; coin Money; emit + Bills of Credit; make any Thing but gold and silver Coin a Tender in + Payment of Debts; pass any Bill of Attainder, ex post facto Law, or + Law impairing the Obligation of Contracts, or grant any Title of + Nobility. + + Clause 2: No State shall, without the Consent of the Congress, lay any + Imposts or Duties on Imports or Exports, except what may be absolutely + necessary for executing it's inspection Laws: and the net Produce of + all Duties and Imposts, laid by any State on Imports or Exports, shall + be for the Use of the Treasury of the United States; and all such Laws + shall be subject to the Revision and Controul of the Congress. + + Clause 3: No State shall, without the Consent of Congress, lay any + Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter + into any Agreement or Compact with another State, or with a foreign + Power, or engage in War, unless actually invaded, or in such imminent + Danger as will not admit of delay. + +Article. II. + + Section. 1. + + Clause 1: The executive Power shall be vested in a President of the + United States of America. He shall hold his Office during the Term of + four Years, and, together with the Vice President, chosen for the same + Term, be elected, as follows + + Clause 2: Each State shall appoint, in such Manner as the Legislature + thereof may direct, a Number of Electors, equal to the whole Number of + Senators and Representatives to which the State may be entitled in the + Congress: but no Senator or Representative, or Person holding an + Office of Trust or Profit under the United States, shall be appointed + an Elector. + + Clause 3: The Electors shall meet in their respective States, and vote + by Ballot for two Persons, of whom one at least shall not be an + Inhabitant of the same State with themselves. And they shall make a + List of all the Persons voted for, and of the Number of Votes for + each; which List they shall sign and certify, and transmit sealed to + the Seat of the Government of the United States, directed to the + President of the Senate. The President of the Senate shall, in the + Presence of the Senate and House of Representatives, open all the + Certificates, and the Votes shall then be counted. The Person having + the greatest Number of Votes shall be the President, if such Number be + a Majority of the whole Number of Electors appointed; and if there be + more than one who have such Majority, and have an equal Number of + Votes, then the House of Representatives shall immediately chuse by + Ballot one of them for President; and if no Person have a Majority, + then from the five highest on the List the said House shall in like + Manner chuse the President. But in chusing the President, the Votes + shall be taken by States, the Representation from each State having + one Vote; A quorum for this Purpose shall consist of a Member or + Members from two thirds of the States, and a Majority of all the + States shall be necessary to a Choice. In every Case, after the Choice + of the President, the Person having the greatest Number of Votes of + the Electors shall be the Vice President. But if there should remain + two or more who have equal Votes, the Senate shall chuse from them by + Ballot the Vice President. (See Note 8) + + Clause 4: The Congress may determine the Time of chusing the Electors, + and the Day on which they shall give their Votes; which Day shall be + the same throughout the United States. + + Clause 5: No Person except a natural born Citizen, or a Citizen of the + United States, at the time of the Adoption of this Constitution, shall + be eligible to the Office of President; neither shall any Person be + eligible to that Office who shall not have attained to the Age of + thirty five Years, and been fourteen Years a Resident within the + United States. + + Clause 6: In Case of the Removal of the President from Office, or of + his Death, Resignation, or Inability to discharge the Powers and + Duties of the said Office, (See Note 9) the Same shall devolve on the + VicePresident, and the Congress may by Law provide for the Case of + Removal, Death, Resignation or Inability, both of the President and + Vice President, declaring what Officer shall then act as President, + and such Officer shall act accordingly, until the Disability be + removed, or a President shall be elected. + + Clause 7: The President shall, at stated Times, receive for his + Services, a Compensation, which shall neither be encreased nor + diminished during the Period for which he shall have been elected, and + he shall not receive within that Period any other Emolument from the + United States, or any of them. + + Clause 8: Before he enter on the Execution of his Office, he shall + take the following Oath or Affirmation:--"I do solemnly swear (or + affirm) that I will faithfully execute the Office of President of the + United States, and will to the best of my Ability, preserve, protect + and defend the Constitution of the United States." + + Section. 2. + + Clause 1: The President shall be Commander in Chief of the Army and + Navy of the United States, and of the Militia of the several States, + when called into the actual Service of the United States; he may + require the Opinion, in writing, of the principal Officer in each of + the executive Departments, upon any Subject relating to the Duties of + their respective Offices, and he shall have Power to grant Reprieves + and Pardons for Offences against the United States, except in Cases of + Impeachment. + + Clause 2: He shall have Power, by and with the Advice and Consent of + the Senate, to make Treaties, provided two thirds of the Senators + present concur; and he shall nominate, and by and with the Advice and + Consent of the Senate, shall appoint Ambassadors, other public + Ministers and Consuls, Judges of the supreme Court, and all other + Officers of the United States, whose Appointments are not herein + otherwise provided for, and which shall be established by Law: but the + Congress may by Law vest the Appointment of such inferior Officers, as + they think proper, in the President alone, in the Courts of Law, or in + the Heads of Departments. + + Clause 3: The President shall have Power to fill up all Vacancies that + may happen during the Recess of the Senate, by granting Commissions + which shall expire at the End of their next Session. + + Section. 3. + + He shall from time to time give to the Congress Information of the + State of the Union, and recommend to their Consideration such Measures + as he shall judge necessary and expedient; he may, on extraordinary + Occasions, convene both Houses, or either of them, and in Case of + Disagreement between them, with Respect to the Time of Adjournment, he + may adjourn them to such Time as he shall think proper; he shall + receive Ambassadors and other public Ministers; he shall take Care + that the Laws be faithfully executed, and shall Commission all the + Officers of the United States. + + Section. 4. + + The President, Vice President and all civil Officers of the United + States, shall be removed from Office on Impeachment for, and + Conviction of, Treason, Bribery, or other high Crimes and + Misdemeanors. + +Article. III. + + Section. 1. + + The judicial Power of the United States, shall be vested in one + supreme Court, and in such inferior Courts as the Congress may from + time to time ordain and establish. The Judges, both of the supreme and + inferior Courts, shall hold their Offices during good Behaviour, and + shall, at stated Times, receive for their Services, a Compensation, + which shall not be diminished during their Continuance in Office. + + Section. 2. + + Clause 1: The judicial Power shall extend to all Cases, in Law and + Equity, arising under this Constitution, the Laws of the United + States, and Treaties made, or which shall be made, under their + Authority;--to all Cases affecting Ambassadors, other public Ministers + and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to + Controversies to which the United States shall be a Party;--to + Controversies between two or more States;--between a State and + Citizens of another State; (See Note 10)--between Citizens of + different States, --between Citizens of the same State claiming Lands + under Grants of different States, and between a State, or the Citizens + thereof, and foreign States, Citizens or Subjects. + + Clause 2: In all Cases affecting Ambassadors, other public Ministers + and Consuls, and those in which a State shall be Party, the supreme + Court shall have original Jurisdiction. In all the other Cases before + mentioned, the supreme Court shall have appellate Jurisdiction, both + as to Law and Fact, with such Exceptions, and under such Regulations + as the Congress shall make. + + Clause 3: The Trial of all Crimes, except in Cases of Impeachment, + shall be by Jury; and such Trial shall be held in the State where the + said Crimes shall have been committed; but when not committed within + any State, the Trial shall be at such Place or Places as the Congress + may by Law have directed. + + Section. 3. + + Clause 1: Treason against the United States, shall consist only in + levying War against them, or in adhering to their Enemies, giving them + Aid and Comfort. No Person shall be convicted of Treason unless on the + Testimony of two Witnesses to the same overt Act, or on Confession in + open Court. + + Clause 2: The Congress shall have Power to declare the Punishment of + Treason, but no Attainder of Treason shall work Corruption of Blood, + or Forfeiture except during the Life of the Person attainted. + +Article. IV. + + Section. 1. + + Full Faith and Credit shall be given in each State to the public Acts, + Records, and judicial Proceedings of every other State. And the + Congress may by general Laws prescribe the Manner in which such Acts, + Records and Proceedings shall be proved, and the Effect thereof. + + Section. 2. + + Clause 1: The Citizens of each State shall be entitled to all + Privileges and Immunities of Citizens in the several States. + + Clause 2: A Person charged in any State with Treason, Felony, or other + Crime, who shall flee from Justice, and be found in another State, + shall on Demand of the executive Authority of the State from which he + fled, be delivered up, to be removed to the State having Jurisdiction + of the Crime. + + Clause 3: No Person held to Service or Labour in one State, under the + Laws thereof, escaping into another, shall, in Consequence of any Law + or Regulation therein, be discharged from such Service or Labour, but + shall be delivered up on Claim of the Party to whom such Service or + Labour may be due. (See Note 11) + + Section. 3. + + Clause 1: New States may be admitted by the Congress into this Union; + but no new State shall be formed or erected within the Jurisdiction of + any other State; nor any State be formed by the Junction of two or + more States, or Parts of States, without the Consent of the + Legislatures of the States concerned as well as of the Congress. + + Clause 2: The Congress shall have Power to dispose of and make all + needful Rules and Regulations respecting the Territory or other + Property belonging to the United States; and nothing in this + Constitution shall be so construed as to Prejudice any Claims of the + United States, or of any particular State. + + Section. 4. + + The United States shall guarantee to every State in this Union a + Republican Form of Government, and shall protect each of them against + Invasion; and on Application of the Legislature, or of the Executive + (when the Legislature cannot be convened) against domestic Violence. + +Article. V. + + The Congress, whenever two thirds of both Houses shall deem it + necessary, shall propose [1]Amendments to this Constitution, or, on + the Application of the Legislatures of two thirds of the several + States, shall call a Convention for proposing Amendments, which, in + either Case, shall be valid to all Intents and Purposes, as Part of + this Constitution, when ratified by the Legislatures of three fourths + of the several States, or by Conventions in three fourths thereof, as + the one or the other Mode of Ratification may be proposed by the + Congress; Provided that no Amendment which may be made prior to the + Year One thousand eight hundred and eight shall in any Manner affect + the first and fourth Clauses in the Ninth Section of the first + Article; and that no State, without its Consent, shall be deprived of + its equal Suffrage in the Senate. + +Article. VI. + + Clause 1: All Debts contracted and Engagements entered into, before + the Adoption of this Constitution, shall be as valid against the + United States under this Constitution, as under the Confederation. + + Clause 2: This Constitution, and the Laws of the United States which + shall be made in Pursuance thereof; and all Treaties made, or which + shall be made, under the Authority of the United States, shall be the + supreme Law of the Land; and the Judges in every State shall be bound + thereby, any Thing in the Constitution or Laws of any State to the + Contrary notwithstanding. + + Clause 3: The Senators and Representatives before mentioned, and the + Members of the several State Legislatures, and all executive and + judicial Officers, both of the United States and of the several + States, shall be bound by Oath or Affirmation, to support this + Constitution; but no religious Test shall ever be required as a + Qualification to any Office or public Trust under the United States. + +Article. VII. + + The Ratification of the Conventions of nine States, shall be + sufficient for the Establishment of this Constitution between the + States so ratifying the Same. + + done in Convention by the Unanimous Consent of the States present the + Seventeenth Day of September in the Year of our Lord one thousand + seven hundred and Eighty seven and of the Independence of the United + States of America the Twelfth In witness whereof We have hereunto + subscribed our Names, + + GO WASHINGTON--Presidt. and deputy from Virginia + + [Signed also by the deputies of twelve States.] + + Delaware + + Geo: Read + Gunning Bedford jun + John Dickinson + Richard Bassett + Jaco: Broom + + Maryland + + James MCHenry + Dan of ST ThoS. Jenifer + DanL Carroll. + + Virginia + + John Blair-- + James Madison Jr. + + North Carolina + + WM Blount + RichD. Dobbs Spaight. + Hu Williamson + + South Carolina + + J. Rutledge + Charles 1ACotesworth Pinckney + Charles Pinckney + Pierce Butler. + + Georgia + + William Few + Abr Baldwin + + New Hampshire + + John Langdon + Nicholas Gilman + + Massachusetts + + Nathaniel Gorham + Rufus King + + Connecticut + WM. SamL. Johnson + Roger Sherman + + New York + + Alexander Hamilton + + New Jersey + + Wil: Livingston + David Brearley. + WM. Paterson. + Jona: Dayton + + Pennsylvania + + B Franklin + Thomas Mifflin + RobT Morris + Geo. Clymer + ThoS. FitzSimons + Jared Ingersoll + James Wilson. + Gouv Morris + + Attest William Jackson Secretary + + NOTES + + Note 1: This text of the Constitution follows the engrossed copy + signed by Gen. Washington and the deputies from 12 States. The small + superior figures preceding the paragraphs designate Clauses, and were + not in the original and have no reference to footnotes. + + The Constitution was adopted by a convention of the States on + September 17, 1787, and was subsequently ratified by the several + States, on the following dates: Delaware, December 7, 1787; + Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; + Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, + February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, + 1788; New Hampshire, June 21, 1788. + + Ratification was completed on June 21, 1788. + + The Constitution was subsequently ratified by Virginia, June 25, 1788; + New York, July 26, 1788; North Carolina, November 21, 1789; Rhode + Island, May 29, 1790; and Vermont, January 10, 1791. + + In May 1785, a committee of Congress made a report recommending an + alteration in the Articles of Confederation, but no action was taken + on it, and it was left to the State Legislatures to proceed in the + matter. In January 1786, the Legislature of Virginia passed a + resolution providing for the appointment of five commissioners, who, + or any three of them, should meet such commissioners as might be + appointed in the other States of the Union, at a time and place to be + agreed upon, to take into consideration the trade of the United + States; to consider how far a uniform system in their commercial + regulations may be necessary to their common interest and their + permanent harmony; and to report to the several States such an act, + relative to this great object, as, when ratified by them, will enable + the United States in Congress effectually to provide for the same. The + Virginia commissioners, after some correspondence, fixed the first + Monday in September as the time, and the city of Annapolis as the + place for the meeting, but only four other States were represented, + viz: Delaware, New York, New Jersey, and Pennsylvania; the + commissioners appointed by Massachusetts, New Hampshire, North + Carolina, and Rhode Island failed to attend. Under the circumstances + of so partial a representation, the commissioners present agreed upon + a report, (drawn by Mr. Hamilton, of New York,) expressing their + unanimous conviction that it might essentially tend to advance the + interests of the Union if the States by which they were respectively + delegated would concur, and use their endeavors to procure the + concurrence of the other States, in the appointment of commissioners + to meet at Philadelphia on the Second Monday of May following, to take + into consideration the situation of the United States; to devise such + further provisions as should appear to them necessary to render the + Constitution of the Federal Government adequate to the exigencies of + the Union; and to report such an act for that purpose to the United + States in Congress assembled as, when agreed to by them and afterwards + confirmed by the Legislatures of every State, would effectually + provide for the same. + + Congress, on the 21st of February, 1787, adopted a resolution in favor + of a convention, and the Legislatures of those States which had not + already done so (with the exception of Rhode Island) promptly + appointed delegates. On the 25th of May, seven States having convened, + George Washington, of Virginia, was unanimously elected President, and + the consideration of the proposed constitution was commenced. On the + 17th of September, 1787, the Constitution as engrossed and agreed upon + was signed by all the members present, except Mr. Gerry of + Massachusetts, and Messrs. Mason and Randolph, of Virginia. The + president of the convention transmitted it to Congress, with a + resolution stating how the proposed Federal Government should be put + in operation, and an explanatory letter. Congress, on the 28th of + September, 1787, directed the Constitution so framed, with the + resolutions and letter concerning the same, to "be transmitted to the + several Legislatures in order to be submitted to a convention of + delegates chosen in each State by the people thereof, in conformity to + the resolves of the convention." + + On the 4th of March, 1789, the day which had been fixed for commencing + the operations of Government under the new Constitution, it had been + ratified by the conventions chosen in each State to consider it, as + follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; + New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, + January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, + 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; + Virginia, June 25, 1788; and New York, July 26, 1788. + + The President informed Congress, on the 28th of January, 1790, that + North Carolina had ratified the Constitution November 21, 1789; and he + informed Congress on the 1st of June, 1790, that Rhode Island had + ratified the Constitution May 29, 1790. Vermont, in convention, + ratified the Constitution January 10, 1791, and was, by an act of + Congress approved February 18, 1791, "received and admitted into this + Union as a new and entire member of the United States." + + Note 2: The part of this Clause relating to the mode of apportionment + of representatives among the several States has been affected by + Section 2 of amendment XIV, and as to taxes on incomes without + apportionment by amendment XVI. + + Note 3: This Clause has been affected by Clause 1 of amendment XVII. + + Note 4: This Clause has been affected by Clause 2 of amendment XVIII. + + Note 5: This Clause has been affected by amendment XX. + + Note 6: This Clause has been affected by amendment XXVII. + + Note 7: This Clause has been affected by amendment XVI. + + Note 8: This Clause has been superseded by amendment XII. + + Note 9: This Clause has been affected by amendment XXV. + + Note 10: This Clause has been affected by amendment XI. + + Note 11: This Clause has been affected by amendment XIII. + + Note 12: The first ten amendments to the Constitution of the United + States (and two others, one of which failed of ratification and the + other which later became the 27th amendment) were proposed to the + legislatures of the several States by the First Congress on September + 25, 1789. The first ten amendments were ratified by the following + States, and the notifications of ratification by the Governors thereof + were successively communicated by the President to Congress: New + Jersey, November 20, 1789; Maryland, December 19, 1789; North + Carolina, December 22, 1789; South Carolina, January 19, 1790; New + Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, + February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, + 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. + + Ratification was completed on December 15, 1791. + + The amendments were subsequently ratified by the legislatures of + Massachusetts, March 2, 1939; Georgia, March 18, 1939; and + Connecticut, April 19, 1939. + + Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had + numbers assigned to them at the time of ratification. + + Note 14: This sentence has been superseded by section 3 of amendment + XX. + + Note 15: See amendment XIX and section 1 of amendment XXVI. + + Note 16: Repealed by section 1 of amendment XXI. + +References + + 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/yyextra_cpp.l b/tests/yyextra_cpp.l new file mode 100644 index 0000000..5a5a014 --- /dev/null +++ b/tests/yyextra_cpp.l @@ -0,0 +1,120 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A file to build "scanner.c". */ +/* This tests that we can use "yyextra". + We buffer all input into a growable array, then print it. + We run diff on the input and output. +*/ + +#include +#include +#include "config.h" + + +/* We'll store the entire input in this buffer, growing as necessary. */ +struct Buffer { + int curr_len; + int max_len; + int grow_len; + char * data; +}; + +/* Save char into junk array at next position. */ +static void append_char (char c, yyscan_t scanner ); + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap nodefault noyyinput +%option warn +%option reentrant +%option extra-type="struct Buffer *" + +%% + +.|\r|\n { append_char (yytext[0],yyscanner); } + +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + struct Buffer * buf; + int i; + + buf = malloc(sizeof(struct Buffer)); + buf->curr_len =0; + buf->max_len = 4; + buf->grow_len = 100; + buf->data = malloc((size_t) buf->max_len); + + testlex_init(&scanner); + testset_in( stdin, scanner); + testset_out( stdout, scanner); + testset_extra( buf, scanner ); + testlex(scanner); + + buf = testget_extra(scanner); + for(i=0; i < buf->curr_len; i++) + fputc( buf->data[i], stdout ); + free( buf->data); + free( buf); + + testlex_destroy(scanner); + return 0; +} + +/* Save char into junk array at next position. */ +static void append_char (char c, yyscan_t scanner ) +{ + struct Buffer *buf, *new_buf; + buf = testget_extra(scanner); + + /* Grow buffer if necessary. */ + + if( buf->curr_len >= buf->max_len ) + { + new_buf = malloc(sizeof(struct Buffer)); + new_buf->max_len = buf->max_len + buf->grow_len; + new_buf->grow_len = buf->grow_len; + new_buf->data = malloc((size_t) new_buf->max_len); + for( new_buf->curr_len = 0; + new_buf->curr_len < buf->curr_len; + new_buf->curr_len++ ) + { + new_buf->data[ new_buf->curr_len] = buf->data [ new_buf->curr_len]; + } + free( buf->data ); + free( buf ); + buf = new_buf; + testset_extra( buf, scanner ); + } + + + buf->data[ buf->curr_len++ ] = c; +} diff --git a/tests/yyextra_cpp.txt b/tests/yyextra_cpp.txt new file mode 100644 index 0000000..243df29 --- /dev/null +++ b/tests/yyextra_cpp.txt @@ -0,0 +1,795 @@ + + THE UNITED STATES CONSTITUTION + _________________________________________________________________ + + (See Note 1) + + We the People of the United States, in Order to form a more perfect + Union, establish Justice, insure domestic Tranquility, provide for the + common defence, promote the general Welfare, and secure the Blessings + of Liberty to ourselves and our Posterity, do ordain and establish + this Constitution for the United States of America. + +Article. I. + + Section 1. + + All legislative Powers herein granted shall be vested in a Congress of + the United States, which shall consist of a Senate and House of + Representatives. + + Section. 2. + + Clause 1: The House of Representatives shall be composed of Members + chosen every second Year by the People of the several States, and the + Electors in each State shall have the Qualifications requisite for + Electors of the most numerous Branch of the State Legislature. + + Clause 2: No Person shall be a Representative who shall not have + attained to the Age of twenty five Years, and been seven Years a + Citizen of the United States, and who shall not, when elected, be an + Inhabitant of that State in which he shall be chosen. + + Clause 3: Representatives and direct Taxes shall be apportioned among + the several States which may be included within this Union, according + to their respective Numbers, which shall be determined by adding to + the whole Number of free Persons, including those bound to Service for + a Term of Years, and excluding Indians not taxed, three fifths of all + other Persons. (See Note 2) The actual Enumeration shall be made + within three Years after the first Meeting of the Congress of the + United States, and within every subsequent Term of ten Years, in such + Manner as they shall by Law direct. The Number of Representatives + shall not exceed one for every thirty Thousand, but each State shall + have at Least one Representative; and until such enumeration shall be + made, the State of New Hampshire shall be entitled to chuse three, + Massachusetts eight, Rhode-Island and Providence Plantations one, + Connecticut five, New-York six, New Jersey four, Pennsylvania eight, + Delaware one, Maryland six, Virginia ten, North Carolina five, South + Carolina five, and Georgia three. + + Clause 4: When vacancies happen in the Representation from any State, + the Executive Authority thereof shall issue Writs of Election to fill + such Vacancies. + + Clause 5: The House of Representatives shall chuse their Speaker and + other Officers; and shall have the sole Power of Impeachment. + + Section. 3. + + Clause 1: The Senate of the United States shall be composed of two + Senators from each State, chosen by the Legislature thereof, (See Note + 3) for six Years; and each Senator shall have one Vote. + + Clause 2: Immediately after they shall be assembled in Consequence of + the first Election, they shall be divided as equally as may be into + three Classes. The Seats of the Senators of the first Class shall be + vacated at the Expiration of the second Year, of the second Class at + the Expiration of the fourth Year, and of the third Class at the + Expiration of the sixth Year, so that one third may be chosen every + second Year; and if Vacancies happen by Resignation, or otherwise, + during the Recess of the Legislature of any State, the Executive + thereof may make temporary Appointments until the next Meeting of the + Legislature, which shall then fill such Vacancies. (See Note 4) + + Clause 3: No Person shall be a Senator who shall not have attained to + the Age of thirty Years, and been nine Years a Citizen of the United + States, and who shall not, when elected, be an Inhabitant of that + State for which he shall be chosen. + + Clause 4: The Vice President of the United States shall be President + of the Senate, but shall have no Vote, unless they be equally divided. + + Clause 5: The Senate shall chuse their other Officers, and also a + President pro tempore, in the Absence of the Vice President, or when + he shall exercise the Office of President of the United States. + + Clause 6: The Senate shall have the sole Power to try all + Impeachments. When sitting for that Purpose, they shall be on Oath or + Affirmation. When the President of the United States is tried, the + Chief Justice shall preside: And no Person shall be convicted without + the Concurrence of two thirds of the Members present. + + Clause 7: Judgment in Cases of Impeachment shall not extend further + than to removal from Office, and disqualification to hold and enjoy + any Office of honor, Trust or Profit under the United States: but the + Party convicted shall nevertheless be liable and subject to + Indictment, Trial, Judgment and Punishment, according to Law. + + Section. 4. + + Clause 1: The Times, Places and Manner of holding Elections for + Senators and Representatives, shall be prescribed in each State by the + Legislature thereof; but the Congress may at any time by Law make or + alter such Regulations, except as to the Places of chusing Senators. + + Clause 2: The Congress shall assemble at least once in every Year, and + such Meeting shall be on the first Monday in December, (See Note 5) + unless they shall by Law appoint a different Day. + + Section. 5. + + Clause 1: Each House shall be the Judge of the Elections, Returns and + Qualifications of its own Members, and a Majority of each shall + constitute a Quorum to do Business; but a smaller Number may adjourn + from day to day, and may be authorized to compel the Attendance of + absent Members, in such Manner, and under such Penalties as each House + may provide. + + Clause 2: Each House may determine the Rules of its Proceedings, + punish its Members for disorderly Behaviour, and, with the Concurrence + of two thirds, expel a Member. + + Clause 3: Each House shall keep a Journal of its Proceedings, and from + time to time publish the same, excepting such Parts as may in their + Judgment require Secrecy; and the Yeas and Nays of the Members of + either House on any question shall, at the Desire of one fifth of + those Present, be entered on the Journal. + + Clause 4: Neither House, during the Session of Congress, shall, + without the Consent of the other, adjourn for more than three days, + nor to any other Place than that in which the two Houses shall be + sitting. + + Section. 6. + + Clause 1: The Senators and Representatives shall receive a + Compensation for their Services, to be ascertained by Law, and paid + out of the Treasury of the United States. (See Note 6) They shall in + all Cases, except Treason, Felony and Breach of the Peace, + beprivileged from Arrest during their Attendance at the Session of + their respective Houses, and in going to and returning from the same; + and for any Speech or Debate in either House, they shall not be + questioned in any other Place. + + Clause 2: No Senator or Representative shall, during the Time for + which he was elected, be appointed to any civil Office under the + Authority of the United States, which shall have been created, or the + Emoluments whereof shall have been encreased during such time; and no + Person holding any Office under the United States, shall be a Member + of either House during his Continuance in Office. + + Section. 7. + + Clause 1: All Bills for raising Revenue shall originate in the House + of Representatives; but the Senate may propose or concur with + Amendments as on other Bills. + + Clause 2: Every Bill which shall have passed the House of + Representatives and the Senate, shall, before it become a Law, be + presented to the President of the United States; If he approve he + shall sign it, but if not he shall return it, with his Objections to + that House in which it shall have originated, who shall enter the + Objections at large on their Journal, and proceed to reconsider it. If + after such Reconsideration two thirds of that House shall agree to + pass the Bill, it shall be sent, together with the Objections, to the + other House, by which it shall likewise be reconsidered, and if + approved by two thirds of that House, it shall become a Law. But in + all such Cases the Votes of both Houses shall be determined by yeas + and Nays, and the Names of the Persons voting for and against the Bill + shall be entered on the Journal of each House respectively. If any + Bill shall not be returned by the President within ten Days (Sundays + excepted) after it shall have been presented to him, the Same shall be + a Law, in like Manner as if he had signed it, unless the Congress by + their Adjournment prevent its Return, in which Case it shall not be a + Law. + + Clause 3: Every Order, Resolution, or Vote to which the Concurrence of + the Senate and House of Representatives may be necessary (except on a + question of Adjournment) shall be presented to the President of the + United States; and before the Same shall take Effect, shall be + approved by him, or being disapproved by him, shall be repassed by two + thirds of the Senate and House of Representatives, according to the + Rules and Limitations prescribed in the Case of a Bill. + + Section. 8. + + Clause 1: The Congress shall have Power To lay and collect Taxes, + Duties, Imposts and Excises, to pay the Debts and provide for the + common Defence and general Welfare of the United States; but all + Duties, Imposts and Excises shall be uniform throughout the United + States; + + Clause 2: To borrow Money on the credit of the United States; + + Clause 3: To regulate Commerce with foreign Nations, and among the + several States, and with the Indian Tribes; + + Clause 4: To establish an uniform Rule of Naturalization, and uniform + Laws on the subject of Bankruptcies throughout the United States; + + Clause 5: To coin Money, regulate the Value thereof, and of foreign + Coin, and fix the Standard of Weights and Measures; + + Clause 6: To provide for the Punishment of counterfeiting the + Securities and current Coin of the United States; + + Clause 7: To establish Post Offices and post Roads; + + Clause 8: To promote the Progress of Science and useful Arts, by + securing for limited Times to Authors and Inventors the exclusive + Right to their respective Writings and Discoveries; + + Clause 9: To constitute Tribunals inferior to the supreme Court; + + Clause 10: To define and punish Piracies and Felonies committed on the + high Seas, and Offences against the Law of Nations; + + Clause 11: To declare War, grant Letters of Marque and Reprisal, and + make Rules concerning Captures on Land and Water; + + Clause 12: To raise and support Armies, but no Appropriation of Money + to that Use shall be for a longer Term than two Years; + + Clause 13: To provide and maintain a Navy; + + Clause 14: To make Rules for the Government and Regulation of the land + and naval Forces; + + Clause 15: To provide for calling forth the Militia to execute the + Laws of the Union, suppress Insurrections and repel Invasions; + + Clause 16: To provide for organizing, arming, and disciplining, the + Militia, and for governing such Part of them as may be employed in the + Service of the United States, reserving to the States respectively, + the Appointment of the Officers, and the Authority of training the + Militia according to the discipline prescribed by Congress; + + Clause 17: To exercise exclusive Legislation in all Cases whatsoever, + over such District (not exceeding ten Miles square) as may, byCession + of particular States, and the Acceptance of Congress, become the Seat + of the Government of the United States, and to exercise like Authority + over all Places purchased by the Consent of the Legislature of the + State in which the Same shall be, for the Erection of Forts, + Magazines, Arsenals, dock-Yards, and other needful Buildings;--And + + Clause 18: To make all Laws which shall be necessary and proper for + carrying into Execution the foregoing Powers, and all other Powers + vested by this Constitution in the Government of the United States, or + in any Department or Officer thereof. + + Section. 9. + + Clause 1: The Migration or Importation of such Persons as any of the + States now existing shall think proper to admit, shall not be + prohibited by the Congress prior to the Year one thousand eight + hundred and eight, but a Tax or duty may be imposed on such + Importation, not exceeding ten dollars for each Person. + + Clause 2: The Privilege of the Writ of Habeas Corpus shall not be + suspended, unless when in Cases of Rebellion or Invasion the public + Safety may require it. + + Clause 3: No Bill of Attainder or ex post facto Law shall be passed. + + Clause 4: No Capitation, or other direct, Tax shall be laid, unless in + Proportion to the Census or Enumeration herein before directed to be + taken. (See Note 7) + + Clause 5: No Tax or Duty shall be laid on Articles exported from any + State. + + Clause 6: No Preference shall be given by any Regulation of Commerce + or Revenue to the Ports of one State over those of another: nor shall + Vessels bound to, or from, one State, be obliged to enter, clear, or + pay Duties in another. + + Clause 7: No Money shall be drawn from the Treasury, but in + Consequence of Appropriations made by Law; and a regular Statement and + Account of the Receipts and Expenditures of all public Money shall be + published from time to time. + + Clause 8: No Title of Nobility shall be granted by the United States: + And no Person holding any Office of Profit or Trust under them, shall, + without the Consent of the Congress, accept of any present, Emolument, + Office, or Title, of any kind whatever, from any King, Prince, or + foreign State. + + Section. 10. + + Clause 1: No State shall enter into any Treaty, Alliance, or + Confederation; grant Letters of Marque and Reprisal; coin Money; emit + Bills of Credit; make any Thing but gold and silver Coin a Tender in + Payment of Debts; pass any Bill of Attainder, ex post facto Law, or + Law impairing the Obligation of Contracts, or grant any Title of + Nobility. + + Clause 2: No State shall, without the Consent of the Congress, lay any + Imposts or Duties on Imports or Exports, except what may be absolutely + necessary for executing it's inspection Laws: and the net Produce of + all Duties and Imposts, laid by any State on Imports or Exports, shall + be for the Use of the Treasury of the United States; and all such Laws + shall be subject to the Revision and Controul of the Congress. + + Clause 3: No State shall, without the Consent of Congress, lay any + Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter + into any Agreement or Compact with another State, or with a foreign + Power, or engage in War, unless actually invaded, or in such imminent + Danger as will not admit of delay. + +Article. II. + + Section. 1. + + Clause 1: The executive Power shall be vested in a President of the + United States of America. He shall hold his Office during the Term of + four Years, and, together with the Vice President, chosen for the same + Term, be elected, as follows + + Clause 2: Each State shall appoint, in such Manner as the Legislature + thereof may direct, a Number of Electors, equal to the whole Number of + Senators and Representatives to which the State may be entitled in the + Congress: but no Senator or Representative, or Person holding an + Office of Trust or Profit under the United States, shall be appointed + an Elector. + + Clause 3: The Electors shall meet in their respective States, and vote + by Ballot for two Persons, of whom one at least shall not be an + Inhabitant of the same State with themselves. And they shall make a + List of all the Persons voted for, and of the Number of Votes for + each; which List they shall sign and certify, and transmit sealed to + the Seat of the Government of the United States, directed to the + President of the Senate. The President of the Senate shall, in the + Presence of the Senate and House of Representatives, open all the + Certificates, and the Votes shall then be counted. The Person having + the greatest Number of Votes shall be the President, if such Number be + a Majority of the whole Number of Electors appointed; and if there be + more than one who have such Majority, and have an equal Number of + Votes, then the House of Representatives shall immediately chuse by + Ballot one of them for President; and if no Person have a Majority, + then from the five highest on the List the said House shall in like + Manner chuse the President. But in chusing the President, the Votes + shall be taken by States, the Representation from each State having + one Vote; A quorum for this Purpose shall consist of a Member or + Members from two thirds of the States, and a Majority of all the + States shall be necessary to a Choice. In every Case, after the Choice + of the President, the Person having the greatest Number of Votes of + the Electors shall be the Vice President. But if there should remain + two or more who have equal Votes, the Senate shall chuse from them by + Ballot the Vice President. (See Note 8) + + Clause 4: The Congress may determine the Time of chusing the Electors, + and the Day on which they shall give their Votes; which Day shall be + the same throughout the United States. + + Clause 5: No Person except a natural born Citizen, or a Citizen of the + United States, at the time of the Adoption of this Constitution, shall + be eligible to the Office of President; neither shall any Person be + eligible to that Office who shall not have attained to the Age of + thirty five Years, and been fourteen Years a Resident within the + United States. + + Clause 6: In Case of the Removal of the President from Office, or of + his Death, Resignation, or Inability to discharge the Powers and + Duties of the said Office, (See Note 9) the Same shall devolve on the + VicePresident, and the Congress may by Law provide for the Case of + Removal, Death, Resignation or Inability, both of the President and + Vice President, declaring what Officer shall then act as President, + and such Officer shall act accordingly, until the Disability be + removed, or a President shall be elected. + + Clause 7: The President shall, at stated Times, receive for his + Services, a Compensation, which shall neither be encreased nor + diminished during the Period for which he shall have been elected, and + he shall not receive within that Period any other Emolument from the + United States, or any of them. + + Clause 8: Before he enter on the Execution of his Office, he shall + take the following Oath or Affirmation:--"I do solemnly swear (or + affirm) that I will faithfully execute the Office of President of the + United States, and will to the best of my Ability, preserve, protect + and defend the Constitution of the United States." + + Section. 2. + + Clause 1: The President shall be Commander in Chief of the Army and + Navy of the United States, and of the Militia of the several States, + when called into the actual Service of the United States; he may + require the Opinion, in writing, of the principal Officer in each of + the executive Departments, upon any Subject relating to the Duties of + their respective Offices, and he shall have Power to grant Reprieves + and Pardons for Offences against the United States, except in Cases of + Impeachment. + + Clause 2: He shall have Power, by and with the Advice and Consent of + the Senate, to make Treaties, provided two thirds of the Senators + present concur; and he shall nominate, and by and with the Advice and + Consent of the Senate, shall appoint Ambassadors, other public + Ministers and Consuls, Judges of the supreme Court, and all other + Officers of the United States, whose Appointments are not herein + otherwise provided for, and which shall be established by Law: but the + Congress may by Law vest the Appointment of such inferior Officers, as + they think proper, in the President alone, in the Courts of Law, or in + the Heads of Departments. + + Clause 3: The President shall have Power to fill up all Vacancies that + may happen during the Recess of the Senate, by granting Commissions + which shall expire at the End of their next Session. + + Section. 3. + + He shall from time to time give to the Congress Information of the + State of the Union, and recommend to their Consideration such Measures + as he shall judge necessary and expedient; he may, on extraordinary + Occasions, convene both Houses, or either of them, and in Case of + Disagreement between them, with Respect to the Time of Adjournment, he + may adjourn them to such Time as he shall think proper; he shall + receive Ambassadors and other public Ministers; he shall take Care + that the Laws be faithfully executed, and shall Commission all the + Officers of the United States. + + Section. 4. + + The President, Vice President and all civil Officers of the United + States, shall be removed from Office on Impeachment for, and + Conviction of, Treason, Bribery, or other high Crimes and + Misdemeanors. + +Article. III. + + Section. 1. + + The judicial Power of the United States, shall be vested in one + supreme Court, and in such inferior Courts as the Congress may from + time to time ordain and establish. The Judges, both of the supreme and + inferior Courts, shall hold their Offices during good Behaviour, and + shall, at stated Times, receive for their Services, a Compensation, + which shall not be diminished during their Continuance in Office. + + Section. 2. + + Clause 1: The judicial Power shall extend to all Cases, in Law and + Equity, arising under this Constitution, the Laws of the United + States, and Treaties made, or which shall be made, under their + Authority;--to all Cases affecting Ambassadors, other public Ministers + and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to + Controversies to which the United States shall be a Party;--to + Controversies between two or more States;--between a State and + Citizens of another State; (See Note 10)--between Citizens of + different States, --between Citizens of the same State claiming Lands + under Grants of different States, and between a State, or the Citizens + thereof, and foreign States, Citizens or Subjects. + + Clause 2: In all Cases affecting Ambassadors, other public Ministers + and Consuls, and those in which a State shall be Party, the supreme + Court shall have original Jurisdiction. In all the other Cases before + mentioned, the supreme Court shall have appellate Jurisdiction, both + as to Law and Fact, with such Exceptions, and under such Regulations + as the Congress shall make. + + Clause 3: The Trial of all Crimes, except in Cases of Impeachment, + shall be by Jury; and such Trial shall be held in the State where the + said Crimes shall have been committed; but when not committed within + any State, the Trial shall be at such Place or Places as the Congress + may by Law have directed. + + Section. 3. + + Clause 1: Treason against the United States, shall consist only in + levying War against them, or in adhering to their Enemies, giving them + Aid and Comfort. No Person shall be convicted of Treason unless on the + Testimony of two Witnesses to the same overt Act, or on Confession in + open Court. + + Clause 2: The Congress shall have Power to declare the Punishment of + Treason, but no Attainder of Treason shall work Corruption of Blood, + or Forfeiture except during the Life of the Person attainted. + +Article. IV. + + Section. 1. + + Full Faith and Credit shall be given in each State to the public Acts, + Records, and judicial Proceedings of every other State. And the + Congress may by general Laws prescribe the Manner in which such Acts, + Records and Proceedings shall be proved, and the Effect thereof. + + Section. 2. + + Clause 1: The Citizens of each State shall be entitled to all + Privileges and Immunities of Citizens in the several States. + + Clause 2: A Person charged in any State with Treason, Felony, or other + Crime, who shall flee from Justice, and be found in another State, + shall on Demand of the executive Authority of the State from which he + fled, be delivered up, to be removed to the State having Jurisdiction + of the Crime. + + Clause 3: No Person held to Service or Labour in one State, under the + Laws thereof, escaping into another, shall, in Consequence of any Law + or Regulation therein, be discharged from such Service or Labour, but + shall be delivered up on Claim of the Party to whom such Service or + Labour may be due. (See Note 11) + + Section. 3. + + Clause 1: New States may be admitted by the Congress into this Union; + but no new State shall be formed or erected within the Jurisdiction of + any other State; nor any State be formed by the Junction of two or + more States, or Parts of States, without the Consent of the + Legislatures of the States concerned as well as of the Congress. + + Clause 2: The Congress shall have Power to dispose of and make all + needful Rules and Regulations respecting the Territory or other + Property belonging to the United States; and nothing in this + Constitution shall be so construed as to Prejudice any Claims of the + United States, or of any particular State. + + Section. 4. + + The United States shall guarantee to every State in this Union a + Republican Form of Government, and shall protect each of them against + Invasion; and on Application of the Legislature, or of the Executive + (when the Legislature cannot be convened) against domestic Violence. + +Article. V. + + The Congress, whenever two thirds of both Houses shall deem it + necessary, shall propose [1]Amendments to this Constitution, or, on + the Application of the Legislatures of two thirds of the several + States, shall call a Convention for proposing Amendments, which, in + either Case, shall be valid to all Intents and Purposes, as Part of + this Constitution, when ratified by the Legislatures of three fourths + of the several States, or by Conventions in three fourths thereof, as + the one or the other Mode of Ratification may be proposed by the + Congress; Provided that no Amendment which may be made prior to the + Year One thousand eight hundred and eight shall in any Manner affect + the first and fourth Clauses in the Ninth Section of the first + Article; and that no State, without its Consent, shall be deprived of + its equal Suffrage in the Senate. + +Article. VI. + + Clause 1: All Debts contracted and Engagements entered into, before + the Adoption of this Constitution, shall be as valid against the + United States under this Constitution, as under the Confederation. + + Clause 2: This Constitution, and the Laws of the United States which + shall be made in Pursuance thereof; and all Treaties made, or which + shall be made, under the Authority of the United States, shall be the + supreme Law of the Land; and the Judges in every State shall be bound + thereby, any Thing in the Constitution or Laws of any State to the + Contrary notwithstanding. + + Clause 3: The Senators and Representatives before mentioned, and the + Members of the several State Legislatures, and all executive and + judicial Officers, both of the United States and of the several + States, shall be bound by Oath or Affirmation, to support this + Constitution; but no religious Test shall ever be required as a + Qualification to any Office or public Trust under the United States. + +Article. VII. + + The Ratification of the Conventions of nine States, shall be + sufficient for the Establishment of this Constitution between the + States so ratifying the Same. + + done in Convention by the Unanimous Consent of the States present the + Seventeenth Day of September in the Year of our Lord one thousand + seven hundred and Eighty seven and of the Independence of the United + States of America the Twelfth In witness whereof We have hereunto + subscribed our Names, + + GO WASHINGTON--Presidt. and deputy from Virginia + + [Signed also by the deputies of twelve States.] + + Delaware + + Geo: Read + Gunning Bedford jun + John Dickinson + Richard Bassett + Jaco: Broom + + Maryland + + James MCHenry + Dan of ST ThoS. Jenifer + DanL Carroll. + + Virginia + + John Blair-- + James Madison Jr. + + North Carolina + + WM Blount + RichD. Dobbs Spaight. + Hu Williamson + + South Carolina + + J. Rutledge + Charles 1ACotesworth Pinckney + Charles Pinckney + Pierce Butler. + + Georgia + + William Few + Abr Baldwin + + New Hampshire + + John Langdon + Nicholas Gilman + + Massachusetts + + Nathaniel Gorham + Rufus King + + Connecticut + WM. SamL. Johnson + Roger Sherman + + New York + + Alexander Hamilton + + New Jersey + + Wil: Livingston + David Brearley. + WM. Paterson. + Jona: Dayton + + Pennsylvania + + B Franklin + Thomas Mifflin + RobT Morris + Geo. Clymer + ThoS. FitzSimons + Jared Ingersoll + James Wilson. + Gouv Morris + + Attest William Jackson Secretary + + NOTES + + Note 1: This text of the Constitution follows the engrossed copy + signed by Gen. Washington and the deputies from 12 States. The small + superior figures preceding the paragraphs designate Clauses, and were + not in the original and have no reference to footnotes. + + The Constitution was adopted by a convention of the States on + September 17, 1787, and was subsequently ratified by the several + States, on the following dates: Delaware, December 7, 1787; + Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; + Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, + February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, + 1788; New Hampshire, June 21, 1788. + + Ratification was completed on June 21, 1788. + + The Constitution was subsequently ratified by Virginia, June 25, 1788; + New York, July 26, 1788; North Carolina, November 21, 1789; Rhode + Island, May 29, 1790; and Vermont, January 10, 1791. + + In May 1785, a committee of Congress made a report recommending an + alteration in the Articles of Confederation, but no action was taken + on it, and it was left to the State Legislatures to proceed in the + matter. In January 1786, the Legislature of Virginia passed a + resolution providing for the appointment of five commissioners, who, + or any three of them, should meet such commissioners as might be + appointed in the other States of the Union, at a time and place to be + agreed upon, to take into consideration the trade of the United + States; to consider how far a uniform system in their commercial + regulations may be necessary to their common interest and their + permanent harmony; and to report to the several States such an act, + relative to this great object, as, when ratified by them, will enable + the United States in Congress effectually to provide for the same. The + Virginia commissioners, after some correspondence, fixed the first + Monday in September as the time, and the city of Annapolis as the + place for the meeting, but only four other States were represented, + viz: Delaware, New York, New Jersey, and Pennsylvania; the + commissioners appointed by Massachusetts, New Hampshire, North + Carolina, and Rhode Island failed to attend. Under the circumstances + of so partial a representation, the commissioners present agreed upon + a report, (drawn by Mr. Hamilton, of New York,) expressing their + unanimous conviction that it might essentially tend to advance the + interests of the Union if the States by which they were respectively + delegated would concur, and use their endeavors to procure the + concurrence of the other States, in the appointment of commissioners + to meet at Philadelphia on the Second Monday of May following, to take + into consideration the situation of the United States; to devise such + further provisions as should appear to them necessary to render the + Constitution of the Federal Government adequate to the exigencies of + the Union; and to report such an act for that purpose to the United + States in Congress assembled as, when agreed to by them and afterwards + confirmed by the Legislatures of every State, would effectually + provide for the same. + + Congress, on the 21st of February, 1787, adopted a resolution in favor + of a convention, and the Legislatures of those States which had not + already done so (with the exception of Rhode Island) promptly + appointed delegates. On the 25th of May, seven States having convened, + George Washington, of Virginia, was unanimously elected President, and + the consideration of the proposed constitution was commenced. On the + 17th of September, 1787, the Constitution as engrossed and agreed upon + was signed by all the members present, except Mr. Gerry of + Massachusetts, and Messrs. Mason and Randolph, of Virginia. The + president of the convention transmitted it to Congress, with a + resolution stating how the proposed Federal Government should be put + in operation, and an explanatory letter. Congress, on the 28th of + September, 1787, directed the Constitution so framed, with the + resolutions and letter concerning the same, to "be transmitted to the + several Legislatures in order to be submitted to a convention of + delegates chosen in each State by the people thereof, in conformity to + the resolves of the convention." + + On the 4th of March, 1789, the day which had been fixed for commencing + the operations of Government under the new Constitution, it had been + ratified by the conventions chosen in each State to consider it, as + follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; + New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, + January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, + 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; + Virginia, June 25, 1788; and New York, July 26, 1788. + + The President informed Congress, on the 28th of January, 1790, that + North Carolina had ratified the Constitution November 21, 1789; and he + informed Congress on the 1st of June, 1790, that Rhode Island had + ratified the Constitution May 29, 1790. Vermont, in convention, + ratified the Constitution January 10, 1791, and was, by an act of + Congress approved February 18, 1791, "received and admitted into this + Union as a new and entire member of the United States." + + Note 2: The part of this Clause relating to the mode of apportionment + of representatives among the several States has been affected by + Section 2 of amendment XIV, and as to taxes on incomes without + apportionment by amendment XVI. + + Note 3: This Clause has been affected by Clause 1 of amendment XVII. + + Note 4: This Clause has been affected by Clause 2 of amendment XVIII. + + Note 5: This Clause has been affected by amendment XX. + + Note 6: This Clause has been affected by amendment XXVII. + + Note 7: This Clause has been affected by amendment XVI. + + Note 8: This Clause has been superseded by amendment XII. + + Note 9: This Clause has been affected by amendment XXV. + + Note 10: This Clause has been affected by amendment XI. + + Note 11: This Clause has been affected by amendment XIII. + + Note 12: The first ten amendments to the Constitution of the United + States (and two others, one of which failed of ratification and the + other which later became the 27th amendment) were proposed to the + legislatures of the several States by the First Congress on September + 25, 1789. The first ten amendments were ratified by the following + States, and the notifications of ratification by the Governors thereof + were successively communicated by the President to Congress: New + Jersey, November 20, 1789; Maryland, December 19, 1789; North + Carolina, December 22, 1789; South Carolina, January 19, 1790; New + Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, + February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, + 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. + + Ratification was completed on December 15, 1791. + + The amendments were subsequently ratified by the legislatures of + Massachusetts, March 2, 1939; Georgia, March 18, 1939; and + Connecticut, April 19, 1939. + + Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had + numbers assigned to them at the time of ratification. + + Note 14: This sentence has been superseded by section 3 of amendment + XX. + + Note 15: See amendment XIX and section 1 of amendment XXVI. + + Note 16: Repealed by section 1 of amendment XXI. + +References + + 1. http://www.house.gov/Constitution/Amend.html -- cgit v1.2.1 From e85860015806c2684dc74b5c40f3d0dd475d4afb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 2020 10:19:36 -0400 Subject: Documentation polishing. --- doc/flex.texi | 67 +++++++++++++++++++++++++++++++++++++++++++------------- src/c99-flex.skl | 30 ------------------------- src/cpp-flex.skl | 30 ------------------------- 3 files changed, 52 insertions(+), 75 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 9453e6b..faee28c 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8688,6 +8688,16 @@ to appear in a URI, including spaces and control characters. See This appendix describes how to add support for a new target language to Flex. +@menu +* Overview:: +* Getting Started:: +* Development Steps:: +* Translation Guidelines:: +@end menu + +@node Overview, , , Retargeting Flex +@subsection Overview + The Flex code has been factored to isolate knowledge of the specifics of each target language from the logic for building the lexer state/transition tables. Code in the target language is generated via @@ -8719,9 +8729,35 @@ file named @file{cpp_backend.c} (so named because both languages use the C preprocessor), and in a skeleton file named @file{cpp-flex.skl} which is digested into a member of the method table when Flex is built. -To get started on writing a new back end, read the definition of -struct backend_t in @file{src/flexdefs.h}, and attached comments -first. Then read a skeleton file. +@node Getting Started, Development Steps, Overview, Retargeting Flex +@subsection Getting Started + +To get started on writing a new back end, browse +@code{src/skeletons,c} to get some idea of how skeleton files are +queried, then read a skeleton file. If no sketon exists of a language +that is closer to your target, the C99 back end is specifically +intended to be cloned and used as a launch pont for new back ends. + +This file you are looking at is processed through GNU m4 during the +pre-compilation stage of Flex. At this time only macros starting with +`m4preproc_' are processed, and quoting is normal. The main purpose of +this expansion phase is to set Flex version symbols. + +At Flex compilation time, the preprocessed skeleton is translated into a comma-separated +list of doublequoted strings which is stuffed into a language- +specific method block compiled into the flex binary. + +At scanner generation time, , the skeleton is generated and filtered +(again) through m4. Macros beginning with `m4_' will be processed. +The quoting is "[[" and "]]" so we don't interfere with user code. + +A line beginning with ``%# `` is comment. Thesev comments are omitted +from the generated scanner. + +A line beginning with ``%%'' us stop-point, where code is inserted by +Flex. Each stop-point is numbered here and also in the code +generator. Stop points will be inserted into the generated scanner as +a comment. This is to aid those who edit skeletons. You'll want to start by studying the @code{M4_PROPERTY_*} macros near the top of the skeleton file. They declare properties of the back end like @@ -8745,18 +8781,24 @@ generated code. The names of such macros have the prefixes grepping for these prefixes. Many of these symbols correspond to Flex command-line options. +@node Development Steps, Translation Guidelines, Getting Started, Retargeting Flex +@subsection Development Steps + To write support for a language, you'll want to do the following steps: @enumerate @item -Clone one of the existing back-end/skeleton pairs. If the language -you are supporting is named @var{foo}, you should create files named -@file{foo_backend.c} and @file{foo-flex.skl}. +Clone one of the existing skeletons. If the language you are +supporting is named @var{foo}, you should create a file named +@file{foo-flex.skl}. @item -Add @file{foo_backend.c} to COMMON_SOURCES in @file{src/Makefile.am}. Add the -name of your skeleton file to EXTRA_DIST. +Modify @code{skeleton.c} to ass the digested form of your skeleton +to the @code{backends} list. + +@item +Add the name of your skeleton file to EXTRA_DIST. @item Add a production to @file{src/Makefile.am} parallel to the one that @@ -8764,12 +8806,6 @@ produces @file{cpp-skel.h}. Your objective is to make a string list initializer from your skeleton file that can be linked with flex and is pointed at by the skel nember of your language back end. -@item -Add some logic to @file{main.c} that enables the new back end with a -new Flex option. Following this step you should be -able to run Flex on a specification and get code out in the -language of whatever back end you cloned. - @item The interesting part: mutate your new back end and skeleton so they produce code in your desired target langage. @@ -8794,7 +8830,8 @@ complexity of what needs to be translated to a new target language. These features are: the Bison bridge, header generation, and loadable tables. -Some notes about the interesting part: +@node Translation Guidelines, , Development Steps, Retargeting Flex +@subsection Translation Guidelines @itemize @item diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 5a1f119..6a4c245 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1,20 +1,4 @@ %# -*-C-*- vi: set ft=c: -%# This file is processed in several stages. -%# Here are the stages, as best as I can describe: -%# -%# 1. This is processed through GNU m4 during the -%# pre-compilation stage of flex. Only macros starting -%# with `m4preproc_' are processed, and quoting is normal. -%# -%# 2. The preprocessed skeleton is translated into a comma-separated -%# list of doublequoted strings which is stuffed into a language- -%# specific method block compiled into the flex binary. The %# comment -%# lines are removed. -%# -%# 3. At runtime, the skeleton is generated and filtered (again) -%# through m4. Macros beginning with `m4_' will be processed. -%# The quoting is "[[" and "]]" so we don't interfere with -%# user code. %# %# All generated macros for the m4 stage contain the text "m4" or "M4" %# in them. This is to distinguish them from CPP macros. @@ -36,20 +20,6 @@ m4_changecom m4_changequote m4_changequote([[, ]]) -%# -%# Lines in this skeleton starting with a "%" character are "control lines" -%# and affect the generation of the scanner. The possible control codes are -%# listed and processed in misc.c. -%# -%# %# - A comment. The current line is omitted from the generated scanner. -%# %% - A stop-point, where code is inserted by flex. -%# Each stop-point is numbered here and also in the code generator. -%# (See gen.c, etc. for details.) -%# -%# Stop points will be inserted into the generated scanner as a comment. -%# This is to aid those who edit the skeleton. -%# - %# Properties not used in the skeleton - meant to be read by the Flex code m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C99]]) m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]]) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index aec3538..6c0920a 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1,20 +1,4 @@ %# -*-C-*- vi: set ft=c: -%# This file is processed in several stages. -%# Here are the stages, as best as I can describe: -%# -%# 1. This is processed through GNU m4 during the -%# pre-compilation stage of flex. Only macros starting -%# with `m4preproc_' are processed, and quoting is normal. -%# -%# 2. The preprocessed skeleton is translated into a comma-separated -%# list of doublequoted strings which is stuffed into a language- -%# specific method block compiled into the flex binary. The %# comment -%# lines are removed. -%# -%# 3. At runtime, the skeleton is generated and filtered (again) -%# through m4. Macros beginning with `m4_' will be processed. -%# The quoting is "[[" and "]]" so we don't interfere with -%# user code. %# %# All generated macros for the m4 stage contain the text "m4" or "M4" %# in them. This is to distinguish them from CPP macros. @@ -36,20 +20,6 @@ m4_changecom m4_changequote m4_changequote([[, ]]) -%# -%# Lines in this skeleton starting with a "%" character are "control lines" -%# and affect the generation of the scanner. The possible control codes are -%# listed and processed in misc.c. -%# -%# %# - A comment. The current line is omitted from the generated scanner. -%# %% - A stop-point, where code is inserted by flex. -%# Each stop-point is numbered here and also in the code generator. -%# (See gen.c, etc. for details.) -%# -%# Stop points will be inserted into the generated scanner as a comment. -%# This is to aid those who edit the skeleton. -%# - %# Properties not used in the skeleton - meant to be read by the Flex code m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C/C++]]) %#m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[]]) -- cgit v1.2.1 From bd08ddcf8f58658887c689e60194bc93556220e7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 2020 10:29:20 -0400 Subject: Fix some minor typos recently introduced in tests/Makefile.am. --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a5bcac6..ce01b2e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -103,6 +103,7 @@ simple_tests = \ quotes_cpp \ quotes_c99 \ string_nr \ + string_r \ string_c99 \ top \ yyextra_cpp \ @@ -188,7 +189,7 @@ multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h posix_cpp_SOURCES = posix_cpp.l posix_c99_SOURCES = posix_c99.l -posixly_correct_cpp__SOURCES = posixly_correct_cp.l +posixly_correct_cpp_SOURCES = posixly_correct_cpp.l posixly_correct_c99_SOURCES = posixly_correct_c99.l prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l -- cgit v1.2.1 From 07440122ca0a68e507bb2e03c00a4abba279af7d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 2020 14:13:12 -0400 Subject: Improve explanation of m4 quoting. --- doc/flex.texi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index faee28c..8c6c487 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1,4 +1,4 @@ -\input texinfo.tex @c -*-texinfo-*- +input texinfo.tex @c -*-texinfo-*- @c %**start of header @setfilename flex.info @include version.texi @@ -8740,7 +8740,10 @@ intended to be cloned and used as a launch pont for new back ends. This file you are looking at is processed through GNU m4 during the pre-compilation stage of Flex. At this time only macros starting with -`m4preproc_' are processed, and quoting is normal. The main purpose of +`m4preproc_' are processed, and quoting is normal (that is, the quote +opener is a back-tick (ASCII 96) and the quote closer is a tick or +single quote (ASCII 39) @footnote{See chapter 3.2 of the m4 mamual, +``Quoting input to m4'', for more information.}. The main purpose of this expansion phase is to set Flex version symbols. At Flex compilation time, the preprocessed skeleton is translated into a comma-separated @@ -8749,9 +8752,9 @@ specific method block compiled into the flex binary. At scanner generation time, , the skeleton is generated and filtered (again) through m4. Macros beginning with `m4_' will be processed. -The quoting is "[[" and "]]" so we don't interfere with user code. +The quoting is ``[[`` and ``]]'' so we don't interfere with user code. -A line beginning with ``%# `` is comment. Thesev comments are omitted +A line beginning with ``%#'' is a comment. These comments are omitted from the generated scanner. A line beginning with ``%%'' us stop-point, where code is inserted by -- cgit v1.2.1 From f735bad052deedfff571e57145c5afc627e1f653 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 2020 14:52:05 -0400 Subject: Add C99 lineno test. --- tests/.gitignore | 2 + tests/Makefile.am | 4 ++ tests/lineno_c99.l | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/lineno_c99.one.txt | 19 ++++++++++ 4 files changed, 123 insertions(+) create mode 100644 tests/lineno_c99.l create mode 100644 tests/lineno_c99.one.txt diff --git a/tests/.gitignore b/tests/.gitignore index 11bbbfb..30a881e 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -67,6 +67,8 @@ lineno_nr.one lineno_nr.c lineno_r.one lineno_r.c +lineno_c99.one +lineno_c99.c lineno_trailing.one lineno_trailing.c mem_nr diff --git a/tests/Makefile.am b/tests/Makefile.am index ce01b2e..fcae87f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -133,6 +133,7 @@ PTHREAD_TESTS = \ ONE_TESTS = \ lineno_nr.one \ lineno_r.one \ + lineno_c99.one \ lineno_trailing.one quote_in_comment_cpp_SOURCES = quote_in_comment_cpp.l @@ -179,6 +180,7 @@ include_by_push_direct_SOURCES = include_by_push.direct.l include_by_reentrant_direct_SOURCES = include_by_reentrant.direct.l lineno_nr_one_SOURCES = lineno_nr.l lineno_r_one_SOURCES = lineno_r.l +lineno_r_one_SOURCES = lineno_c99.l lineno_trailing_one_SOURCES = lineno_trailing.l mem_nr_SOURCES = mem_nr.l mem_r_SOURCES = mem_r.l @@ -263,6 +265,7 @@ CLEANFILES = \ include_by_reentrant.direct.c \ lineno_nr.c \ lineno_r.c \ + lineno_c99.c \ lineno_trailing.c \ mem_nr.c \ mem_r.c \ @@ -347,6 +350,7 @@ EXTRA_DIST = \ include_by_reentrant.direct_3.txt \ lineno_nr.one.txt \ lineno_r.one.txt \ + lineno_c99.one.txt \ lineno_trailing.one.txt \ mem_nr.txt \ mem_r.txt \ diff --git a/tests/lineno_c99.l b/tests/lineno_c99.l new file mode 100644 index 0000000..ac509ec --- /dev/null +++ b/tests/lineno_c99.l @@ -0,0 +1,98 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". + Run as: + test-lineno-r # report flex's yylineno + test-lineno-r 1 # report count_newlines(stdin) +*/ + +#include +#include +#include "config.h" + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput yylineno reentrant +%option warn + +WORD [[:alpha:]]+ +DIGIT [[:digit:]] + +%% + /* The goal here is to test the yylineno processing by: + - providing some rules than CAN match newlines and + other rules that can NOT match newlines, + - matching several newlines in one rule, + - directly modifying yylineno. + */ + +"yylineno++" yylineno++; +"yylineno--" yylineno--; +[[:blank:]]+ +{WORD} +{DIGIT}+(\n{DIGIT}+)* +\n +. +<> { printf("%d\n", yylineno); + yyterminate(); + } + +%% + +/* returns number of '\n' characters in input, plus one. + This is what flex does, essentially. */ + +static int +count_newlines (FILE* in) +{ + int n=1,c; + while ((c=fgetc(in)) != EOF) + if( c == '\n') + n++; + return n; +} + +int main ( int argc, char** argv ); + +int +main (int argc, char **argv) +{ + (void)argv; + + if( argc > 1 ) + printf("%d\n", count_newlines(stdin)); + + else{ + yyscan_t s; + testlex_init(&s); + testset_in(stdin,s); + testset_out(stdout,s); + testlex(s); + testlex_destroy(s); + } + return 0; +} diff --git a/tests/lineno_c99.one.txt b/tests/lineno_c99.one.txt new file mode 100644 index 0000000..c1eb961 --- /dev/null +++ b/tests/lineno_c99.one.txt @@ -0,0 +1,19 @@ +These words +are separated +by newlines +and sometimes + spaces +too. +The next three lines are numbers with only intervening newlines +01123 +581321 +34 +And now for some blank lines.... + + +Finally, we directly modify yylineno, but then change it back afterwards +(see scanner.l): + +yylineno++ + +yylineno-- -- cgit v1.2.1 From b642977f1c6d8aab72eb4621766384c987578028 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 2020 14:59:21 -0400 Subject: MAINTAINERCLEANFILES typo fix. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2b0acd1..d969f23 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -97,7 +97,7 @@ EXTRA_DIST = \ CLEANFILES = stage1scan.c stage1flex$(EXEEXT) -MAINTAINERCLEANFILES = c9pp-skel.h +MAINTAINERCLEANFILES = cpp-skel.h c99-skel.h cpp-skel.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp -- cgit v1.2.1 From c23d0161dc2ebf374e1066e5f39f2f9fe6a19fba Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 2020 17:39:03 -0400 Subject: Cut down on input-file proliferation. With a minor tweak to testwrapper we can allow all the versions of a test for different back ends (counting _r and _nr as back ends) to share a common input file. --- tests/Makefile.am | 33 +- tests/alloc_extra.txt | 795 +++++++++++++++++++++++++++++++++++++++++ tests/alloc_extra_c99.txt | 795 ----------------------------------------- tests/alloc_extra_cpp.txt | 795 ----------------------------------------- tests/array.txt | 2 + tests/array_c99.txt | 2 - tests/array_nr.txt | 2 - tests/array_r.txt | 2 - tests/basic.txt | 5 + tests/basic_c99.txt | 4 - tests/basic_nr.txt | 5 - tests/basic_r.txt | 4 - tests/ccl.txt | 27 ++ tests/ccl_c99.txt | 27 -- tests/ccl_cpp.txt | 27 -- tests/debug.txt | 2 + tests/debug_c99.txt | 2 - tests/debug_nr.txt | 2 - tests/debug_r.txt | 2 - tests/extended.txt | 2 + tests/extended_c99.txt | 2 - tests/extended_cpp.txt | 2 - tests/mem.txt | 25 ++ tests/mem_c99.txt | 25 -- tests/mem_nr.txt | 25 -- tests/mem_r.txt | 25 -- tests/prefix.txt | 1 + tests/prefix_c99.txt | 1 - tests/prefix_nr.txt | 1 - tests/prefix_r.txt | 1 - tests/quote_in_comment.txt | 1 + tests/quote_in_comment_c99.txt | 1 - tests/quote_in_comment_cpp.txt | 1 - tests/quotes.txt | 2 + tests/quotes_c99.txt | 2 - tests/quotes_cpp.txt | 2 - tests/testwrapper.sh | 8 + tests/yyextra.txt | 795 +++++++++++++++++++++++++++++++++++++++++ tests/yyextra_c99.txt | 795 ----------------------------------------- tests/yyextra_cpp.txt | 795 ----------------------------------------- 40 files changed, 1675 insertions(+), 3370 deletions(-) create mode 100644 tests/alloc_extra.txt delete mode 100644 tests/alloc_extra_c99.txt delete mode 100644 tests/alloc_extra_cpp.txt create mode 100644 tests/array.txt delete mode 100644 tests/array_c99.txt delete mode 100644 tests/array_nr.txt delete mode 100644 tests/array_r.txt create mode 100644 tests/basic.txt delete mode 100644 tests/basic_c99.txt delete mode 100644 tests/basic_nr.txt delete mode 100644 tests/basic_r.txt create mode 100644 tests/ccl.txt delete mode 100644 tests/ccl_c99.txt delete mode 100644 tests/ccl_cpp.txt create mode 100644 tests/debug.txt delete mode 100644 tests/debug_c99.txt delete mode 100644 tests/debug_nr.txt delete mode 100644 tests/debug_r.txt create mode 100644 tests/extended.txt delete mode 100644 tests/extended_c99.txt delete mode 100644 tests/extended_cpp.txt create mode 100644 tests/mem.txt delete mode 100644 tests/mem_c99.txt delete mode 100644 tests/mem_nr.txt delete mode 100644 tests/mem_r.txt create mode 100644 tests/prefix.txt delete mode 100644 tests/prefix_c99.txt delete mode 100644 tests/prefix_nr.txt delete mode 100644 tests/prefix_r.txt create mode 100644 tests/quote_in_comment.txt delete mode 100644 tests/quote_in_comment_c99.txt delete mode 100644 tests/quote_in_comment_cpp.txt create mode 100644 tests/quotes.txt delete mode 100644 tests/quotes_c99.txt delete mode 100644 tests/quotes_cpp.txt create mode 100644 tests/yyextra.txt delete mode 100644 tests/yyextra_c99.txt delete mode 100644 tests/yyextra_cpp.txt diff --git a/tests/Makefile.am b/tests/Makefile.am index fcae87f..22d6eba 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -315,28 +315,21 @@ dist-hook: EXTRA_DIST = \ README \ - alloc_extra_cpp.txt \ - alloc_extra_c99.txt \ - array_nr.txt \ - array_r.txt \ - array_c99.txt \ - basic_nr.txt \ - basic_r.txt \ + alloc_extra.txt \ + array.txt \ + basic.txt \ bison_nr.txt \ bison_yylloc.txt \ bison_yylval.txt \ c_cxx_nr.txt \ c_cxx_r.txt \ - ccl_cpp.txt \ + ccl.txt \ cxx_basic.txt \ cxx_multiple_scanners.txt \ cxx_restart.txt \ cxx_yywrap.txt \ - debug_nr.txt \ - debug_r.txt \ - debug_c99.txt \ - extended_cpp.txt \ - extended_c99.txt \ + debug.txt \ + extended.txt \ header_nr.txt \ header_r.txt \ include_by_buffer.direct.txt \ @@ -352,12 +345,8 @@ EXTRA_DIST = \ lineno_r.one.txt \ lineno_c99.one.txt \ lineno_trailing.one.txt \ - mem_nr.txt \ - mem_r.txt \ - mem_c99.txt \ - prefix_nr.txt \ - prefix_r.txt \ - prefix_c99.txt \ + mem.txt \ + prefix.txt \ pthread_1.txt \ pthread_2.txt \ pthread_3.txt \ @@ -366,10 +355,8 @@ EXTRA_DIST = \ reject.txt \ rescan_nr.direct.txt \ rescan_r.direct.txt \ - quote_in_comment_cpp.txt \ - quote_in_comment_c99.txt \ - quotes_cpp.txt \ - quotes_c99.txt \ + quote_in_comment.txt \ + quotes.txt \ top.txt \ yyextra.txt \ tableopts.txt diff --git a/tests/alloc_extra.txt b/tests/alloc_extra.txt new file mode 100644 index 0000000..243df29 --- /dev/null +++ b/tests/alloc_extra.txt @@ -0,0 +1,795 @@ + + THE UNITED STATES CONSTITUTION + _________________________________________________________________ + + (See Note 1) + + We the People of the United States, in Order to form a more perfect + Union, establish Justice, insure domestic Tranquility, provide for the + common defence, promote the general Welfare, and secure the Blessings + of Liberty to ourselves and our Posterity, do ordain and establish + this Constitution for the United States of America. + +Article. I. + + Section 1. + + All legislative Powers herein granted shall be vested in a Congress of + the United States, which shall consist of a Senate and House of + Representatives. + + Section. 2. + + Clause 1: The House of Representatives shall be composed of Members + chosen every second Year by the People of the several States, and the + Electors in each State shall have the Qualifications requisite for + Electors of the most numerous Branch of the State Legislature. + + Clause 2: No Person shall be a Representative who shall not have + attained to the Age of twenty five Years, and been seven Years a + Citizen of the United States, and who shall not, when elected, be an + Inhabitant of that State in which he shall be chosen. + + Clause 3: Representatives and direct Taxes shall be apportioned among + the several States which may be included within this Union, according + to their respective Numbers, which shall be determined by adding to + the whole Number of free Persons, including those bound to Service for + a Term of Years, and excluding Indians not taxed, three fifths of all + other Persons. (See Note 2) The actual Enumeration shall be made + within three Years after the first Meeting of the Congress of the + United States, and within every subsequent Term of ten Years, in such + Manner as they shall by Law direct. The Number of Representatives + shall not exceed one for every thirty Thousand, but each State shall + have at Least one Representative; and until such enumeration shall be + made, the State of New Hampshire shall be entitled to chuse three, + Massachusetts eight, Rhode-Island and Providence Plantations one, + Connecticut five, New-York six, New Jersey four, Pennsylvania eight, + Delaware one, Maryland six, Virginia ten, North Carolina five, South + Carolina five, and Georgia three. + + Clause 4: When vacancies happen in the Representation from any State, + the Executive Authority thereof shall issue Writs of Election to fill + such Vacancies. + + Clause 5: The House of Representatives shall chuse their Speaker and + other Officers; and shall have the sole Power of Impeachment. + + Section. 3. + + Clause 1: The Senate of the United States shall be composed of two + Senators from each State, chosen by the Legislature thereof, (See Note + 3) for six Years; and each Senator shall have one Vote. + + Clause 2: Immediately after they shall be assembled in Consequence of + the first Election, they shall be divided as equally as may be into + three Classes. The Seats of the Senators of the first Class shall be + vacated at the Expiration of the second Year, of the second Class at + the Expiration of the fourth Year, and of the third Class at the + Expiration of the sixth Year, so that one third may be chosen every + second Year; and if Vacancies happen by Resignation, or otherwise, + during the Recess of the Legislature of any State, the Executive + thereof may make temporary Appointments until the next Meeting of the + Legislature, which shall then fill such Vacancies. (See Note 4) + + Clause 3: No Person shall be a Senator who shall not have attained to + the Age of thirty Years, and been nine Years a Citizen of the United + States, and who shall not, when elected, be an Inhabitant of that + State for which he shall be chosen. + + Clause 4: The Vice President of the United States shall be President + of the Senate, but shall have no Vote, unless they be equally divided. + + Clause 5: The Senate shall chuse their other Officers, and also a + President pro tempore, in the Absence of the Vice President, or when + he shall exercise the Office of President of the United States. + + Clause 6: The Senate shall have the sole Power to try all + Impeachments. When sitting for that Purpose, they shall be on Oath or + Affirmation. When the President of the United States is tried, the + Chief Justice shall preside: And no Person shall be convicted without + the Concurrence of two thirds of the Members present. + + Clause 7: Judgment in Cases of Impeachment shall not extend further + than to removal from Office, and disqualification to hold and enjoy + any Office of honor, Trust or Profit under the United States: but the + Party convicted shall nevertheless be liable and subject to + Indictment, Trial, Judgment and Punishment, according to Law. + + Section. 4. + + Clause 1: The Times, Places and Manner of holding Elections for + Senators and Representatives, shall be prescribed in each State by the + Legislature thereof; but the Congress may at any time by Law make or + alter such Regulations, except as to the Places of chusing Senators. + + Clause 2: The Congress shall assemble at least once in every Year, and + such Meeting shall be on the first Monday in December, (See Note 5) + unless they shall by Law appoint a different Day. + + Section. 5. + + Clause 1: Each House shall be the Judge of the Elections, Returns and + Qualifications of its own Members, and a Majority of each shall + constitute a Quorum to do Business; but a smaller Number may adjourn + from day to day, and may be authorized to compel the Attendance of + absent Members, in such Manner, and under such Penalties as each House + may provide. + + Clause 2: Each House may determine the Rules of its Proceedings, + punish its Members for disorderly Behaviour, and, with the Concurrence + of two thirds, expel a Member. + + Clause 3: Each House shall keep a Journal of its Proceedings, and from + time to time publish the same, excepting such Parts as may in their + Judgment require Secrecy; and the Yeas and Nays of the Members of + either House on any question shall, at the Desire of one fifth of + those Present, be entered on the Journal. + + Clause 4: Neither House, during the Session of Congress, shall, + without the Consent of the other, adjourn for more than three days, + nor to any other Place than that in which the two Houses shall be + sitting. + + Section. 6. + + Clause 1: The Senators and Representatives shall receive a + Compensation for their Services, to be ascertained by Law, and paid + out of the Treasury of the United States. (See Note 6) They shall in + all Cases, except Treason, Felony and Breach of the Peace, + beprivileged from Arrest during their Attendance at the Session of + their respective Houses, and in going to and returning from the same; + and for any Speech or Debate in either House, they shall not be + questioned in any other Place. + + Clause 2: No Senator or Representative shall, during the Time for + which he was elected, be appointed to any civil Office under the + Authority of the United States, which shall have been created, or the + Emoluments whereof shall have been encreased during such time; and no + Person holding any Office under the United States, shall be a Member + of either House during his Continuance in Office. + + Section. 7. + + Clause 1: All Bills for raising Revenue shall originate in the House + of Representatives; but the Senate may propose or concur with + Amendments as on other Bills. + + Clause 2: Every Bill which shall have passed the House of + Representatives and the Senate, shall, before it become a Law, be + presented to the President of the United States; If he approve he + shall sign it, but if not he shall return it, with his Objections to + that House in which it shall have originated, who shall enter the + Objections at large on their Journal, and proceed to reconsider it. If + after such Reconsideration two thirds of that House shall agree to + pass the Bill, it shall be sent, together with the Objections, to the + other House, by which it shall likewise be reconsidered, and if + approved by two thirds of that House, it shall become a Law. But in + all such Cases the Votes of both Houses shall be determined by yeas + and Nays, and the Names of the Persons voting for and against the Bill + shall be entered on the Journal of each House respectively. If any + Bill shall not be returned by the President within ten Days (Sundays + excepted) after it shall have been presented to him, the Same shall be + a Law, in like Manner as if he had signed it, unless the Congress by + their Adjournment prevent its Return, in which Case it shall not be a + Law. + + Clause 3: Every Order, Resolution, or Vote to which the Concurrence of + the Senate and House of Representatives may be necessary (except on a + question of Adjournment) shall be presented to the President of the + United States; and before the Same shall take Effect, shall be + approved by him, or being disapproved by him, shall be repassed by two + thirds of the Senate and House of Representatives, according to the + Rules and Limitations prescribed in the Case of a Bill. + + Section. 8. + + Clause 1: The Congress shall have Power To lay and collect Taxes, + Duties, Imposts and Excises, to pay the Debts and provide for the + common Defence and general Welfare of the United States; but all + Duties, Imposts and Excises shall be uniform throughout the United + States; + + Clause 2: To borrow Money on the credit of the United States; + + Clause 3: To regulate Commerce with foreign Nations, and among the + several States, and with the Indian Tribes; + + Clause 4: To establish an uniform Rule of Naturalization, and uniform + Laws on the subject of Bankruptcies throughout the United States; + + Clause 5: To coin Money, regulate the Value thereof, and of foreign + Coin, and fix the Standard of Weights and Measures; + + Clause 6: To provide for the Punishment of counterfeiting the + Securities and current Coin of the United States; + + Clause 7: To establish Post Offices and post Roads; + + Clause 8: To promote the Progress of Science and useful Arts, by + securing for limited Times to Authors and Inventors the exclusive + Right to their respective Writings and Discoveries; + + Clause 9: To constitute Tribunals inferior to the supreme Court; + + Clause 10: To define and punish Piracies and Felonies committed on the + high Seas, and Offences against the Law of Nations; + + Clause 11: To declare War, grant Letters of Marque and Reprisal, and + make Rules concerning Captures on Land and Water; + + Clause 12: To raise and support Armies, but no Appropriation of Money + to that Use shall be for a longer Term than two Years; + + Clause 13: To provide and maintain a Navy; + + Clause 14: To make Rules for the Government and Regulation of the land + and naval Forces; + + Clause 15: To provide for calling forth the Militia to execute the + Laws of the Union, suppress Insurrections and repel Invasions; + + Clause 16: To provide for organizing, arming, and disciplining, the + Militia, and for governing such Part of them as may be employed in the + Service of the United States, reserving to the States respectively, + the Appointment of the Officers, and the Authority of training the + Militia according to the discipline prescribed by Congress; + + Clause 17: To exercise exclusive Legislation in all Cases whatsoever, + over such District (not exceeding ten Miles square) as may, byCession + of particular States, and the Acceptance of Congress, become the Seat + of the Government of the United States, and to exercise like Authority + over all Places purchased by the Consent of the Legislature of the + State in which the Same shall be, for the Erection of Forts, + Magazines, Arsenals, dock-Yards, and other needful Buildings;--And + + Clause 18: To make all Laws which shall be necessary and proper for + carrying into Execution the foregoing Powers, and all other Powers + vested by this Constitution in the Government of the United States, or + in any Department or Officer thereof. + + Section. 9. + + Clause 1: The Migration or Importation of such Persons as any of the + States now existing shall think proper to admit, shall not be + prohibited by the Congress prior to the Year one thousand eight + hundred and eight, but a Tax or duty may be imposed on such + Importation, not exceeding ten dollars for each Person. + + Clause 2: The Privilege of the Writ of Habeas Corpus shall not be + suspended, unless when in Cases of Rebellion or Invasion the public + Safety may require it. + + Clause 3: No Bill of Attainder or ex post facto Law shall be passed. + + Clause 4: No Capitation, or other direct, Tax shall be laid, unless in + Proportion to the Census or Enumeration herein before directed to be + taken. (See Note 7) + + Clause 5: No Tax or Duty shall be laid on Articles exported from any + State. + + Clause 6: No Preference shall be given by any Regulation of Commerce + or Revenue to the Ports of one State over those of another: nor shall + Vessels bound to, or from, one State, be obliged to enter, clear, or + pay Duties in another. + + Clause 7: No Money shall be drawn from the Treasury, but in + Consequence of Appropriations made by Law; and a regular Statement and + Account of the Receipts and Expenditures of all public Money shall be + published from time to time. + + Clause 8: No Title of Nobility shall be granted by the United States: + And no Person holding any Office of Profit or Trust under them, shall, + without the Consent of the Congress, accept of any present, Emolument, + Office, or Title, of any kind whatever, from any King, Prince, or + foreign State. + + Section. 10. + + Clause 1: No State shall enter into any Treaty, Alliance, or + Confederation; grant Letters of Marque and Reprisal; coin Money; emit + Bills of Credit; make any Thing but gold and silver Coin a Tender in + Payment of Debts; pass any Bill of Attainder, ex post facto Law, or + Law impairing the Obligation of Contracts, or grant any Title of + Nobility. + + Clause 2: No State shall, without the Consent of the Congress, lay any + Imposts or Duties on Imports or Exports, except what may be absolutely + necessary for executing it's inspection Laws: and the net Produce of + all Duties and Imposts, laid by any State on Imports or Exports, shall + be for the Use of the Treasury of the United States; and all such Laws + shall be subject to the Revision and Controul of the Congress. + + Clause 3: No State shall, without the Consent of Congress, lay any + Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter + into any Agreement or Compact with another State, or with a foreign + Power, or engage in War, unless actually invaded, or in such imminent + Danger as will not admit of delay. + +Article. II. + + Section. 1. + + Clause 1: The executive Power shall be vested in a President of the + United States of America. He shall hold his Office during the Term of + four Years, and, together with the Vice President, chosen for the same + Term, be elected, as follows + + Clause 2: Each State shall appoint, in such Manner as the Legislature + thereof may direct, a Number of Electors, equal to the whole Number of + Senators and Representatives to which the State may be entitled in the + Congress: but no Senator or Representative, or Person holding an + Office of Trust or Profit under the United States, shall be appointed + an Elector. + + Clause 3: The Electors shall meet in their respective States, and vote + by Ballot for two Persons, of whom one at least shall not be an + Inhabitant of the same State with themselves. And they shall make a + List of all the Persons voted for, and of the Number of Votes for + each; which List they shall sign and certify, and transmit sealed to + the Seat of the Government of the United States, directed to the + President of the Senate. The President of the Senate shall, in the + Presence of the Senate and House of Representatives, open all the + Certificates, and the Votes shall then be counted. The Person having + the greatest Number of Votes shall be the President, if such Number be + a Majority of the whole Number of Electors appointed; and if there be + more than one who have such Majority, and have an equal Number of + Votes, then the House of Representatives shall immediately chuse by + Ballot one of them for President; and if no Person have a Majority, + then from the five highest on the List the said House shall in like + Manner chuse the President. But in chusing the President, the Votes + shall be taken by States, the Representation from each State having + one Vote; A quorum for this Purpose shall consist of a Member or + Members from two thirds of the States, and a Majority of all the + States shall be necessary to a Choice. In every Case, after the Choice + of the President, the Person having the greatest Number of Votes of + the Electors shall be the Vice President. But if there should remain + two or more who have equal Votes, the Senate shall chuse from them by + Ballot the Vice President. (See Note 8) + + Clause 4: The Congress may determine the Time of chusing the Electors, + and the Day on which they shall give their Votes; which Day shall be + the same throughout the United States. + + Clause 5: No Person except a natural born Citizen, or a Citizen of the + United States, at the time of the Adoption of this Constitution, shall + be eligible to the Office of President; neither shall any Person be + eligible to that Office who shall not have attained to the Age of + thirty five Years, and been fourteen Years a Resident within the + United States. + + Clause 6: In Case of the Removal of the President from Office, or of + his Death, Resignation, or Inability to discharge the Powers and + Duties of the said Office, (See Note 9) the Same shall devolve on the + VicePresident, and the Congress may by Law provide for the Case of + Removal, Death, Resignation or Inability, both of the President and + Vice President, declaring what Officer shall then act as President, + and such Officer shall act accordingly, until the Disability be + removed, or a President shall be elected. + + Clause 7: The President shall, at stated Times, receive for his + Services, a Compensation, which shall neither be encreased nor + diminished during the Period for which he shall have been elected, and + he shall not receive within that Period any other Emolument from the + United States, or any of them. + + Clause 8: Before he enter on the Execution of his Office, he shall + take the following Oath or Affirmation:--"I do solemnly swear (or + affirm) that I will faithfully execute the Office of President of the + United States, and will to the best of my Ability, preserve, protect + and defend the Constitution of the United States." + + Section. 2. + + Clause 1: The President shall be Commander in Chief of the Army and + Navy of the United States, and of the Militia of the several States, + when called into the actual Service of the United States; he may + require the Opinion, in writing, of the principal Officer in each of + the executive Departments, upon any Subject relating to the Duties of + their respective Offices, and he shall have Power to grant Reprieves + and Pardons for Offences against the United States, except in Cases of + Impeachment. + + Clause 2: He shall have Power, by and with the Advice and Consent of + the Senate, to make Treaties, provided two thirds of the Senators + present concur; and he shall nominate, and by and with the Advice and + Consent of the Senate, shall appoint Ambassadors, other public + Ministers and Consuls, Judges of the supreme Court, and all other + Officers of the United States, whose Appointments are not herein + otherwise provided for, and which shall be established by Law: but the + Congress may by Law vest the Appointment of such inferior Officers, as + they think proper, in the President alone, in the Courts of Law, or in + the Heads of Departments. + + Clause 3: The President shall have Power to fill up all Vacancies that + may happen during the Recess of the Senate, by granting Commissions + which shall expire at the End of their next Session. + + Section. 3. + + He shall from time to time give to the Congress Information of the + State of the Union, and recommend to their Consideration such Measures + as he shall judge necessary and expedient; he may, on extraordinary + Occasions, convene both Houses, or either of them, and in Case of + Disagreement between them, with Respect to the Time of Adjournment, he + may adjourn them to such Time as he shall think proper; he shall + receive Ambassadors and other public Ministers; he shall take Care + that the Laws be faithfully executed, and shall Commission all the + Officers of the United States. + + Section. 4. + + The President, Vice President and all civil Officers of the United + States, shall be removed from Office on Impeachment for, and + Conviction of, Treason, Bribery, or other high Crimes and + Misdemeanors. + +Article. III. + + Section. 1. + + The judicial Power of the United States, shall be vested in one + supreme Court, and in such inferior Courts as the Congress may from + time to time ordain and establish. The Judges, both of the supreme and + inferior Courts, shall hold their Offices during good Behaviour, and + shall, at stated Times, receive for their Services, a Compensation, + which shall not be diminished during their Continuance in Office. + + Section. 2. + + Clause 1: The judicial Power shall extend to all Cases, in Law and + Equity, arising under this Constitution, the Laws of the United + States, and Treaties made, or which shall be made, under their + Authority;--to all Cases affecting Ambassadors, other public Ministers + and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to + Controversies to which the United States shall be a Party;--to + Controversies between two or more States;--between a State and + Citizens of another State; (See Note 10)--between Citizens of + different States, --between Citizens of the same State claiming Lands + under Grants of different States, and between a State, or the Citizens + thereof, and foreign States, Citizens or Subjects. + + Clause 2: In all Cases affecting Ambassadors, other public Ministers + and Consuls, and those in which a State shall be Party, the supreme + Court shall have original Jurisdiction. In all the other Cases before + mentioned, the supreme Court shall have appellate Jurisdiction, both + as to Law and Fact, with such Exceptions, and under such Regulations + as the Congress shall make. + + Clause 3: The Trial of all Crimes, except in Cases of Impeachment, + shall be by Jury; and such Trial shall be held in the State where the + said Crimes shall have been committed; but when not committed within + any State, the Trial shall be at such Place or Places as the Congress + may by Law have directed. + + Section. 3. + + Clause 1: Treason against the United States, shall consist only in + levying War against them, or in adhering to their Enemies, giving them + Aid and Comfort. No Person shall be convicted of Treason unless on the + Testimony of two Witnesses to the same overt Act, or on Confession in + open Court. + + Clause 2: The Congress shall have Power to declare the Punishment of + Treason, but no Attainder of Treason shall work Corruption of Blood, + or Forfeiture except during the Life of the Person attainted. + +Article. IV. + + Section. 1. + + Full Faith and Credit shall be given in each State to the public Acts, + Records, and judicial Proceedings of every other State. And the + Congress may by general Laws prescribe the Manner in which such Acts, + Records and Proceedings shall be proved, and the Effect thereof. + + Section. 2. + + Clause 1: The Citizens of each State shall be entitled to all + Privileges and Immunities of Citizens in the several States. + + Clause 2: A Person charged in any State with Treason, Felony, or other + Crime, who shall flee from Justice, and be found in another State, + shall on Demand of the executive Authority of the State from which he + fled, be delivered up, to be removed to the State having Jurisdiction + of the Crime. + + Clause 3: No Person held to Service or Labour in one State, under the + Laws thereof, escaping into another, shall, in Consequence of any Law + or Regulation therein, be discharged from such Service or Labour, but + shall be delivered up on Claim of the Party to whom such Service or + Labour may be due. (See Note 11) + + Section. 3. + + Clause 1: New States may be admitted by the Congress into this Union; + but no new State shall be formed or erected within the Jurisdiction of + any other State; nor any State be formed by the Junction of two or + more States, or Parts of States, without the Consent of the + Legislatures of the States concerned as well as of the Congress. + + Clause 2: The Congress shall have Power to dispose of and make all + needful Rules and Regulations respecting the Territory or other + Property belonging to the United States; and nothing in this + Constitution shall be so construed as to Prejudice any Claims of the + United States, or of any particular State. + + Section. 4. + + The United States shall guarantee to every State in this Union a + Republican Form of Government, and shall protect each of them against + Invasion; and on Application of the Legislature, or of the Executive + (when the Legislature cannot be convened) against domestic Violence. + +Article. V. + + The Congress, whenever two thirds of both Houses shall deem it + necessary, shall propose [1]Amendments to this Constitution, or, on + the Application of the Legislatures of two thirds of the several + States, shall call a Convention for proposing Amendments, which, in + either Case, shall be valid to all Intents and Purposes, as Part of + this Constitution, when ratified by the Legislatures of three fourths + of the several States, or by Conventions in three fourths thereof, as + the one or the other Mode of Ratification may be proposed by the + Congress; Provided that no Amendment which may be made prior to the + Year One thousand eight hundred and eight shall in any Manner affect + the first and fourth Clauses in the Ninth Section of the first + Article; and that no State, without its Consent, shall be deprived of + its equal Suffrage in the Senate. + +Article. VI. + + Clause 1: All Debts contracted and Engagements entered into, before + the Adoption of this Constitution, shall be as valid against the + United States under this Constitution, as under the Confederation. + + Clause 2: This Constitution, and the Laws of the United States which + shall be made in Pursuance thereof; and all Treaties made, or which + shall be made, under the Authority of the United States, shall be the + supreme Law of the Land; and the Judges in every State shall be bound + thereby, any Thing in the Constitution or Laws of any State to the + Contrary notwithstanding. + + Clause 3: The Senators and Representatives before mentioned, and the + Members of the several State Legislatures, and all executive and + judicial Officers, both of the United States and of the several + States, shall be bound by Oath or Affirmation, to support this + Constitution; but no religious Test shall ever be required as a + Qualification to any Office or public Trust under the United States. + +Article. VII. + + The Ratification of the Conventions of nine States, shall be + sufficient for the Establishment of this Constitution between the + States so ratifying the Same. + + done in Convention by the Unanimous Consent of the States present the + Seventeenth Day of September in the Year of our Lord one thousand + seven hundred and Eighty seven and of the Independence of the United + States of America the Twelfth In witness whereof We have hereunto + subscribed our Names, + + GO WASHINGTON--Presidt. and deputy from Virginia + + [Signed also by the deputies of twelve States.] + + Delaware + + Geo: Read + Gunning Bedford jun + John Dickinson + Richard Bassett + Jaco: Broom + + Maryland + + James MCHenry + Dan of ST ThoS. Jenifer + DanL Carroll. + + Virginia + + John Blair-- + James Madison Jr. + + North Carolina + + WM Blount + RichD. Dobbs Spaight. + Hu Williamson + + South Carolina + + J. Rutledge + Charles 1ACotesworth Pinckney + Charles Pinckney + Pierce Butler. + + Georgia + + William Few + Abr Baldwin + + New Hampshire + + John Langdon + Nicholas Gilman + + Massachusetts + + Nathaniel Gorham + Rufus King + + Connecticut + WM. SamL. Johnson + Roger Sherman + + New York + + Alexander Hamilton + + New Jersey + + Wil: Livingston + David Brearley. + WM. Paterson. + Jona: Dayton + + Pennsylvania + + B Franklin + Thomas Mifflin + RobT Morris + Geo. Clymer + ThoS. FitzSimons + Jared Ingersoll + James Wilson. + Gouv Morris + + Attest William Jackson Secretary + + NOTES + + Note 1: This text of the Constitution follows the engrossed copy + signed by Gen. Washington and the deputies from 12 States. The small + superior figures preceding the paragraphs designate Clauses, and were + not in the original and have no reference to footnotes. + + The Constitution was adopted by a convention of the States on + September 17, 1787, and was subsequently ratified by the several + States, on the following dates: Delaware, December 7, 1787; + Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; + Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, + February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, + 1788; New Hampshire, June 21, 1788. + + Ratification was completed on June 21, 1788. + + The Constitution was subsequently ratified by Virginia, June 25, 1788; + New York, July 26, 1788; North Carolina, November 21, 1789; Rhode + Island, May 29, 1790; and Vermont, January 10, 1791. + + In May 1785, a committee of Congress made a report recommending an + alteration in the Articles of Confederation, but no action was taken + on it, and it was left to the State Legislatures to proceed in the + matter. In January 1786, the Legislature of Virginia passed a + resolution providing for the appointment of five commissioners, who, + or any three of them, should meet such commissioners as might be + appointed in the other States of the Union, at a time and place to be + agreed upon, to take into consideration the trade of the United + States; to consider how far a uniform system in their commercial + regulations may be necessary to their common interest and their + permanent harmony; and to report to the several States such an act, + relative to this great object, as, when ratified by them, will enable + the United States in Congress effectually to provide for the same. The + Virginia commissioners, after some correspondence, fixed the first + Monday in September as the time, and the city of Annapolis as the + place for the meeting, but only four other States were represented, + viz: Delaware, New York, New Jersey, and Pennsylvania; the + commissioners appointed by Massachusetts, New Hampshire, North + Carolina, and Rhode Island failed to attend. Under the circumstances + of so partial a representation, the commissioners present agreed upon + a report, (drawn by Mr. Hamilton, of New York,) expressing their + unanimous conviction that it might essentially tend to advance the + interests of the Union if the States by which they were respectively + delegated would concur, and use their endeavors to procure the + concurrence of the other States, in the appointment of commissioners + to meet at Philadelphia on the Second Monday of May following, to take + into consideration the situation of the United States; to devise such + further provisions as should appear to them necessary to render the + Constitution of the Federal Government adequate to the exigencies of + the Union; and to report such an act for that purpose to the United + States in Congress assembled as, when agreed to by them and afterwards + confirmed by the Legislatures of every State, would effectually + provide for the same. + + Congress, on the 21st of February, 1787, adopted a resolution in favor + of a convention, and the Legislatures of those States which had not + already done so (with the exception of Rhode Island) promptly + appointed delegates. On the 25th of May, seven States having convened, + George Washington, of Virginia, was unanimously elected President, and + the consideration of the proposed constitution was commenced. On the + 17th of September, 1787, the Constitution as engrossed and agreed upon + was signed by all the members present, except Mr. Gerry of + Massachusetts, and Messrs. Mason and Randolph, of Virginia. The + president of the convention transmitted it to Congress, with a + resolution stating how the proposed Federal Government should be put + in operation, and an explanatory letter. Congress, on the 28th of + September, 1787, directed the Constitution so framed, with the + resolutions and letter concerning the same, to "be transmitted to the + several Legislatures in order to be submitted to a convention of + delegates chosen in each State by the people thereof, in conformity to + the resolves of the convention." + + On the 4th of March, 1789, the day which had been fixed for commencing + the operations of Government under the new Constitution, it had been + ratified by the conventions chosen in each State to consider it, as + follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; + New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, + January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, + 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; + Virginia, June 25, 1788; and New York, July 26, 1788. + + The President informed Congress, on the 28th of January, 1790, that + North Carolina had ratified the Constitution November 21, 1789; and he + informed Congress on the 1st of June, 1790, that Rhode Island had + ratified the Constitution May 29, 1790. Vermont, in convention, + ratified the Constitution January 10, 1791, and was, by an act of + Congress approved February 18, 1791, "received and admitted into this + Union as a new and entire member of the United States." + + Note 2: The part of this Clause relating to the mode of apportionment + of representatives among the several States has been affected by + Section 2 of amendment XIV, and as to taxes on incomes without + apportionment by amendment XVI. + + Note 3: This Clause has been affected by Clause 1 of amendment XVII. + + Note 4: This Clause has been affected by Clause 2 of amendment XVIII. + + Note 5: This Clause has been affected by amendment XX. + + Note 6: This Clause has been affected by amendment XXVII. + + Note 7: This Clause has been affected by amendment XVI. + + Note 8: This Clause has been superseded by amendment XII. + + Note 9: This Clause has been affected by amendment XXV. + + Note 10: This Clause has been affected by amendment XI. + + Note 11: This Clause has been affected by amendment XIII. + + Note 12: The first ten amendments to the Constitution of the United + States (and two others, one of which failed of ratification and the + other which later became the 27th amendment) were proposed to the + legislatures of the several States by the First Congress on September + 25, 1789. The first ten amendments were ratified by the following + States, and the notifications of ratification by the Governors thereof + were successively communicated by the President to Congress: New + Jersey, November 20, 1789; Maryland, December 19, 1789; North + Carolina, December 22, 1789; South Carolina, January 19, 1790; New + Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, + February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, + 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. + + Ratification was completed on December 15, 1791. + + The amendments were subsequently ratified by the legislatures of + Massachusetts, March 2, 1939; Georgia, March 18, 1939; and + Connecticut, April 19, 1939. + + Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had + numbers assigned to them at the time of ratification. + + Note 14: This sentence has been superseded by section 3 of amendment + XX. + + Note 15: See amendment XIX and section 1 of amendment XXVI. + + Note 16: Repealed by section 1 of amendment XXI. + +References + + 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/alloc_extra_c99.txt b/tests/alloc_extra_c99.txt deleted file mode 100644 index 243df29..0000000 --- a/tests/alloc_extra_c99.txt +++ /dev/null @@ -1,795 +0,0 @@ - - THE UNITED STATES CONSTITUTION - _________________________________________________________________ - - (See Note 1) - - We the People of the United States, in Order to form a more perfect - Union, establish Justice, insure domestic Tranquility, provide for the - common defence, promote the general Welfare, and secure the Blessings - of Liberty to ourselves and our Posterity, do ordain and establish - this Constitution for the United States of America. - -Article. I. - - Section 1. - - All legislative Powers herein granted shall be vested in a Congress of - the United States, which shall consist of a Senate and House of - Representatives. - - Section. 2. - - Clause 1: The House of Representatives shall be composed of Members - chosen every second Year by the People of the several States, and the - Electors in each State shall have the Qualifications requisite for - Electors of the most numerous Branch of the State Legislature. - - Clause 2: No Person shall be a Representative who shall not have - attained to the Age of twenty five Years, and been seven Years a - Citizen of the United States, and who shall not, when elected, be an - Inhabitant of that State in which he shall be chosen. - - Clause 3: Representatives and direct Taxes shall be apportioned among - the several States which may be included within this Union, according - to their respective Numbers, which shall be determined by adding to - the whole Number of free Persons, including those bound to Service for - a Term of Years, and excluding Indians not taxed, three fifths of all - other Persons. (See Note 2) The actual Enumeration shall be made - within three Years after the first Meeting of the Congress of the - United States, and within every subsequent Term of ten Years, in such - Manner as they shall by Law direct. The Number of Representatives - shall not exceed one for every thirty Thousand, but each State shall - have at Least one Representative; and until such enumeration shall be - made, the State of New Hampshire shall be entitled to chuse three, - Massachusetts eight, Rhode-Island and Providence Plantations one, - Connecticut five, New-York six, New Jersey four, Pennsylvania eight, - Delaware one, Maryland six, Virginia ten, North Carolina five, South - Carolina five, and Georgia three. - - Clause 4: When vacancies happen in the Representation from any State, - the Executive Authority thereof shall issue Writs of Election to fill - such Vacancies. - - Clause 5: The House of Representatives shall chuse their Speaker and - other Officers; and shall have the sole Power of Impeachment. - - Section. 3. - - Clause 1: The Senate of the United States shall be composed of two - Senators from each State, chosen by the Legislature thereof, (See Note - 3) for six Years; and each Senator shall have one Vote. - - Clause 2: Immediately after they shall be assembled in Consequence of - the first Election, they shall be divided as equally as may be into - three Classes. The Seats of the Senators of the first Class shall be - vacated at the Expiration of the second Year, of the second Class at - the Expiration of the fourth Year, and of the third Class at the - Expiration of the sixth Year, so that one third may be chosen every - second Year; and if Vacancies happen by Resignation, or otherwise, - during the Recess of the Legislature of any State, the Executive - thereof may make temporary Appointments until the next Meeting of the - Legislature, which shall then fill such Vacancies. (See Note 4) - - Clause 3: No Person shall be a Senator who shall not have attained to - the Age of thirty Years, and been nine Years a Citizen of the United - States, and who shall not, when elected, be an Inhabitant of that - State for which he shall be chosen. - - Clause 4: The Vice President of the United States shall be President - of the Senate, but shall have no Vote, unless they be equally divided. - - Clause 5: The Senate shall chuse their other Officers, and also a - President pro tempore, in the Absence of the Vice President, or when - he shall exercise the Office of President of the United States. - - Clause 6: The Senate shall have the sole Power to try all - Impeachments. When sitting for that Purpose, they shall be on Oath or - Affirmation. When the President of the United States is tried, the - Chief Justice shall preside: And no Person shall be convicted without - the Concurrence of two thirds of the Members present. - - Clause 7: Judgment in Cases of Impeachment shall not extend further - than to removal from Office, and disqualification to hold and enjoy - any Office of honor, Trust or Profit under the United States: but the - Party convicted shall nevertheless be liable and subject to - Indictment, Trial, Judgment and Punishment, according to Law. - - Section. 4. - - Clause 1: The Times, Places and Manner of holding Elections for - Senators and Representatives, shall be prescribed in each State by the - Legislature thereof; but the Congress may at any time by Law make or - alter such Regulations, except as to the Places of chusing Senators. - - Clause 2: The Congress shall assemble at least once in every Year, and - such Meeting shall be on the first Monday in December, (See Note 5) - unless they shall by Law appoint a different Day. - - Section. 5. - - Clause 1: Each House shall be the Judge of the Elections, Returns and - Qualifications of its own Members, and a Majority of each shall - constitute a Quorum to do Business; but a smaller Number may adjourn - from day to day, and may be authorized to compel the Attendance of - absent Members, in such Manner, and under such Penalties as each House - may provide. - - Clause 2: Each House may determine the Rules of its Proceedings, - punish its Members for disorderly Behaviour, and, with the Concurrence - of two thirds, expel a Member. - - Clause 3: Each House shall keep a Journal of its Proceedings, and from - time to time publish the same, excepting such Parts as may in their - Judgment require Secrecy; and the Yeas and Nays of the Members of - either House on any question shall, at the Desire of one fifth of - those Present, be entered on the Journal. - - Clause 4: Neither House, during the Session of Congress, shall, - without the Consent of the other, adjourn for more than three days, - nor to any other Place than that in which the two Houses shall be - sitting. - - Section. 6. - - Clause 1: The Senators and Representatives shall receive a - Compensation for their Services, to be ascertained by Law, and paid - out of the Treasury of the United States. (See Note 6) They shall in - all Cases, except Treason, Felony and Breach of the Peace, - beprivileged from Arrest during their Attendance at the Session of - their respective Houses, and in going to and returning from the same; - and for any Speech or Debate in either House, they shall not be - questioned in any other Place. - - Clause 2: No Senator or Representative shall, during the Time for - which he was elected, be appointed to any civil Office under the - Authority of the United States, which shall have been created, or the - Emoluments whereof shall have been encreased during such time; and no - Person holding any Office under the United States, shall be a Member - of either House during his Continuance in Office. - - Section. 7. - - Clause 1: All Bills for raising Revenue shall originate in the House - of Representatives; but the Senate may propose or concur with - Amendments as on other Bills. - - Clause 2: Every Bill which shall have passed the House of - Representatives and the Senate, shall, before it become a Law, be - presented to the President of the United States; If he approve he - shall sign it, but if not he shall return it, with his Objections to - that House in which it shall have originated, who shall enter the - Objections at large on their Journal, and proceed to reconsider it. If - after such Reconsideration two thirds of that House shall agree to - pass the Bill, it shall be sent, together with the Objections, to the - other House, by which it shall likewise be reconsidered, and if - approved by two thirds of that House, it shall become a Law. But in - all such Cases the Votes of both Houses shall be determined by yeas - and Nays, and the Names of the Persons voting for and against the Bill - shall be entered on the Journal of each House respectively. If any - Bill shall not be returned by the President within ten Days (Sundays - excepted) after it shall have been presented to him, the Same shall be - a Law, in like Manner as if he had signed it, unless the Congress by - their Adjournment prevent its Return, in which Case it shall not be a - Law. - - Clause 3: Every Order, Resolution, or Vote to which the Concurrence of - the Senate and House of Representatives may be necessary (except on a - question of Adjournment) shall be presented to the President of the - United States; and before the Same shall take Effect, shall be - approved by him, or being disapproved by him, shall be repassed by two - thirds of the Senate and House of Representatives, according to the - Rules and Limitations prescribed in the Case of a Bill. - - Section. 8. - - Clause 1: The Congress shall have Power To lay and collect Taxes, - Duties, Imposts and Excises, to pay the Debts and provide for the - common Defence and general Welfare of the United States; but all - Duties, Imposts and Excises shall be uniform throughout the United - States; - - Clause 2: To borrow Money on the credit of the United States; - - Clause 3: To regulate Commerce with foreign Nations, and among the - several States, and with the Indian Tribes; - - Clause 4: To establish an uniform Rule of Naturalization, and uniform - Laws on the subject of Bankruptcies throughout the United States; - - Clause 5: To coin Money, regulate the Value thereof, and of foreign - Coin, and fix the Standard of Weights and Measures; - - Clause 6: To provide for the Punishment of counterfeiting the - Securities and current Coin of the United States; - - Clause 7: To establish Post Offices and post Roads; - - Clause 8: To promote the Progress of Science and useful Arts, by - securing for limited Times to Authors and Inventors the exclusive - Right to their respective Writings and Discoveries; - - Clause 9: To constitute Tribunals inferior to the supreme Court; - - Clause 10: To define and punish Piracies and Felonies committed on the - high Seas, and Offences against the Law of Nations; - - Clause 11: To declare War, grant Letters of Marque and Reprisal, and - make Rules concerning Captures on Land and Water; - - Clause 12: To raise and support Armies, but no Appropriation of Money - to that Use shall be for a longer Term than two Years; - - Clause 13: To provide and maintain a Navy; - - Clause 14: To make Rules for the Government and Regulation of the land - and naval Forces; - - Clause 15: To provide for calling forth the Militia to execute the - Laws of the Union, suppress Insurrections and repel Invasions; - - Clause 16: To provide for organizing, arming, and disciplining, the - Militia, and for governing such Part of them as may be employed in the - Service of the United States, reserving to the States respectively, - the Appointment of the Officers, and the Authority of training the - Militia according to the discipline prescribed by Congress; - - Clause 17: To exercise exclusive Legislation in all Cases whatsoever, - over such District (not exceeding ten Miles square) as may, byCession - of particular States, and the Acceptance of Congress, become the Seat - of the Government of the United States, and to exercise like Authority - over all Places purchased by the Consent of the Legislature of the - State in which the Same shall be, for the Erection of Forts, - Magazines, Arsenals, dock-Yards, and other needful Buildings;--And - - Clause 18: To make all Laws which shall be necessary and proper for - carrying into Execution the foregoing Powers, and all other Powers - vested by this Constitution in the Government of the United States, or - in any Department or Officer thereof. - - Section. 9. - - Clause 1: The Migration or Importation of such Persons as any of the - States now existing shall think proper to admit, shall not be - prohibited by the Congress prior to the Year one thousand eight - hundred and eight, but a Tax or duty may be imposed on such - Importation, not exceeding ten dollars for each Person. - - Clause 2: The Privilege of the Writ of Habeas Corpus shall not be - suspended, unless when in Cases of Rebellion or Invasion the public - Safety may require it. - - Clause 3: No Bill of Attainder or ex post facto Law shall be passed. - - Clause 4: No Capitation, or other direct, Tax shall be laid, unless in - Proportion to the Census or Enumeration herein before directed to be - taken. (See Note 7) - - Clause 5: No Tax or Duty shall be laid on Articles exported from any - State. - - Clause 6: No Preference shall be given by any Regulation of Commerce - or Revenue to the Ports of one State over those of another: nor shall - Vessels bound to, or from, one State, be obliged to enter, clear, or - pay Duties in another. - - Clause 7: No Money shall be drawn from the Treasury, but in - Consequence of Appropriations made by Law; and a regular Statement and - Account of the Receipts and Expenditures of all public Money shall be - published from time to time. - - Clause 8: No Title of Nobility shall be granted by the United States: - And no Person holding any Office of Profit or Trust under them, shall, - without the Consent of the Congress, accept of any present, Emolument, - Office, or Title, of any kind whatever, from any King, Prince, or - foreign State. - - Section. 10. - - Clause 1: No State shall enter into any Treaty, Alliance, or - Confederation; grant Letters of Marque and Reprisal; coin Money; emit - Bills of Credit; make any Thing but gold and silver Coin a Tender in - Payment of Debts; pass any Bill of Attainder, ex post facto Law, or - Law impairing the Obligation of Contracts, or grant any Title of - Nobility. - - Clause 2: No State shall, without the Consent of the Congress, lay any - Imposts or Duties on Imports or Exports, except what may be absolutely - necessary for executing it's inspection Laws: and the net Produce of - all Duties and Imposts, laid by any State on Imports or Exports, shall - be for the Use of the Treasury of the United States; and all such Laws - shall be subject to the Revision and Controul of the Congress. - - Clause 3: No State shall, without the Consent of Congress, lay any - Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter - into any Agreement or Compact with another State, or with a foreign - Power, or engage in War, unless actually invaded, or in such imminent - Danger as will not admit of delay. - -Article. II. - - Section. 1. - - Clause 1: The executive Power shall be vested in a President of the - United States of America. He shall hold his Office during the Term of - four Years, and, together with the Vice President, chosen for the same - Term, be elected, as follows - - Clause 2: Each State shall appoint, in such Manner as the Legislature - thereof may direct, a Number of Electors, equal to the whole Number of - Senators and Representatives to which the State may be entitled in the - Congress: but no Senator or Representative, or Person holding an - Office of Trust or Profit under the United States, shall be appointed - an Elector. - - Clause 3: The Electors shall meet in their respective States, and vote - by Ballot for two Persons, of whom one at least shall not be an - Inhabitant of the same State with themselves. And they shall make a - List of all the Persons voted for, and of the Number of Votes for - each; which List they shall sign and certify, and transmit sealed to - the Seat of the Government of the United States, directed to the - President of the Senate. The President of the Senate shall, in the - Presence of the Senate and House of Representatives, open all the - Certificates, and the Votes shall then be counted. The Person having - the greatest Number of Votes shall be the President, if such Number be - a Majority of the whole Number of Electors appointed; and if there be - more than one who have such Majority, and have an equal Number of - Votes, then the House of Representatives shall immediately chuse by - Ballot one of them for President; and if no Person have a Majority, - then from the five highest on the List the said House shall in like - Manner chuse the President. But in chusing the President, the Votes - shall be taken by States, the Representation from each State having - one Vote; A quorum for this Purpose shall consist of a Member or - Members from two thirds of the States, and a Majority of all the - States shall be necessary to a Choice. In every Case, after the Choice - of the President, the Person having the greatest Number of Votes of - the Electors shall be the Vice President. But if there should remain - two or more who have equal Votes, the Senate shall chuse from them by - Ballot the Vice President. (See Note 8) - - Clause 4: The Congress may determine the Time of chusing the Electors, - and the Day on which they shall give their Votes; which Day shall be - the same throughout the United States. - - Clause 5: No Person except a natural born Citizen, or a Citizen of the - United States, at the time of the Adoption of this Constitution, shall - be eligible to the Office of President; neither shall any Person be - eligible to that Office who shall not have attained to the Age of - thirty five Years, and been fourteen Years a Resident within the - United States. - - Clause 6: In Case of the Removal of the President from Office, or of - his Death, Resignation, or Inability to discharge the Powers and - Duties of the said Office, (See Note 9) the Same shall devolve on the - VicePresident, and the Congress may by Law provide for the Case of - Removal, Death, Resignation or Inability, both of the President and - Vice President, declaring what Officer shall then act as President, - and such Officer shall act accordingly, until the Disability be - removed, or a President shall be elected. - - Clause 7: The President shall, at stated Times, receive for his - Services, a Compensation, which shall neither be encreased nor - diminished during the Period for which he shall have been elected, and - he shall not receive within that Period any other Emolument from the - United States, or any of them. - - Clause 8: Before he enter on the Execution of his Office, he shall - take the following Oath or Affirmation:--"I do solemnly swear (or - affirm) that I will faithfully execute the Office of President of the - United States, and will to the best of my Ability, preserve, protect - and defend the Constitution of the United States." - - Section. 2. - - Clause 1: The President shall be Commander in Chief of the Army and - Navy of the United States, and of the Militia of the several States, - when called into the actual Service of the United States; he may - require the Opinion, in writing, of the principal Officer in each of - the executive Departments, upon any Subject relating to the Duties of - their respective Offices, and he shall have Power to grant Reprieves - and Pardons for Offences against the United States, except in Cases of - Impeachment. - - Clause 2: He shall have Power, by and with the Advice and Consent of - the Senate, to make Treaties, provided two thirds of the Senators - present concur; and he shall nominate, and by and with the Advice and - Consent of the Senate, shall appoint Ambassadors, other public - Ministers and Consuls, Judges of the supreme Court, and all other - Officers of the United States, whose Appointments are not herein - otherwise provided for, and which shall be established by Law: but the - Congress may by Law vest the Appointment of such inferior Officers, as - they think proper, in the President alone, in the Courts of Law, or in - the Heads of Departments. - - Clause 3: The President shall have Power to fill up all Vacancies that - may happen during the Recess of the Senate, by granting Commissions - which shall expire at the End of their next Session. - - Section. 3. - - He shall from time to time give to the Congress Information of the - State of the Union, and recommend to their Consideration such Measures - as he shall judge necessary and expedient; he may, on extraordinary - Occasions, convene both Houses, or either of them, and in Case of - Disagreement between them, with Respect to the Time of Adjournment, he - may adjourn them to such Time as he shall think proper; he shall - receive Ambassadors and other public Ministers; he shall take Care - that the Laws be faithfully executed, and shall Commission all the - Officers of the United States. - - Section. 4. - - The President, Vice President and all civil Officers of the United - States, shall be removed from Office on Impeachment for, and - Conviction of, Treason, Bribery, or other high Crimes and - Misdemeanors. - -Article. III. - - Section. 1. - - The judicial Power of the United States, shall be vested in one - supreme Court, and in such inferior Courts as the Congress may from - time to time ordain and establish. The Judges, both of the supreme and - inferior Courts, shall hold their Offices during good Behaviour, and - shall, at stated Times, receive for their Services, a Compensation, - which shall not be diminished during their Continuance in Office. - - Section. 2. - - Clause 1: The judicial Power shall extend to all Cases, in Law and - Equity, arising under this Constitution, the Laws of the United - States, and Treaties made, or which shall be made, under their - Authority;--to all Cases affecting Ambassadors, other public Ministers - and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to - Controversies to which the United States shall be a Party;--to - Controversies between two or more States;--between a State and - Citizens of another State; (See Note 10)--between Citizens of - different States, --between Citizens of the same State claiming Lands - under Grants of different States, and between a State, or the Citizens - thereof, and foreign States, Citizens or Subjects. - - Clause 2: In all Cases affecting Ambassadors, other public Ministers - and Consuls, and those in which a State shall be Party, the supreme - Court shall have original Jurisdiction. In all the other Cases before - mentioned, the supreme Court shall have appellate Jurisdiction, both - as to Law and Fact, with such Exceptions, and under such Regulations - as the Congress shall make. - - Clause 3: The Trial of all Crimes, except in Cases of Impeachment, - shall be by Jury; and such Trial shall be held in the State where the - said Crimes shall have been committed; but when not committed within - any State, the Trial shall be at such Place or Places as the Congress - may by Law have directed. - - Section. 3. - - Clause 1: Treason against the United States, shall consist only in - levying War against them, or in adhering to their Enemies, giving them - Aid and Comfort. No Person shall be convicted of Treason unless on the - Testimony of two Witnesses to the same overt Act, or on Confession in - open Court. - - Clause 2: The Congress shall have Power to declare the Punishment of - Treason, but no Attainder of Treason shall work Corruption of Blood, - or Forfeiture except during the Life of the Person attainted. - -Article. IV. - - Section. 1. - - Full Faith and Credit shall be given in each State to the public Acts, - Records, and judicial Proceedings of every other State. And the - Congress may by general Laws prescribe the Manner in which such Acts, - Records and Proceedings shall be proved, and the Effect thereof. - - Section. 2. - - Clause 1: The Citizens of each State shall be entitled to all - Privileges and Immunities of Citizens in the several States. - - Clause 2: A Person charged in any State with Treason, Felony, or other - Crime, who shall flee from Justice, and be found in another State, - shall on Demand of the executive Authority of the State from which he - fled, be delivered up, to be removed to the State having Jurisdiction - of the Crime. - - Clause 3: No Person held to Service or Labour in one State, under the - Laws thereof, escaping into another, shall, in Consequence of any Law - or Regulation therein, be discharged from such Service or Labour, but - shall be delivered up on Claim of the Party to whom such Service or - Labour may be due. (See Note 11) - - Section. 3. - - Clause 1: New States may be admitted by the Congress into this Union; - but no new State shall be formed or erected within the Jurisdiction of - any other State; nor any State be formed by the Junction of two or - more States, or Parts of States, without the Consent of the - Legislatures of the States concerned as well as of the Congress. - - Clause 2: The Congress shall have Power to dispose of and make all - needful Rules and Regulations respecting the Territory or other - Property belonging to the United States; and nothing in this - Constitution shall be so construed as to Prejudice any Claims of the - United States, or of any particular State. - - Section. 4. - - The United States shall guarantee to every State in this Union a - Republican Form of Government, and shall protect each of them against - Invasion; and on Application of the Legislature, or of the Executive - (when the Legislature cannot be convened) against domestic Violence. - -Article. V. - - The Congress, whenever two thirds of both Houses shall deem it - necessary, shall propose [1]Amendments to this Constitution, or, on - the Application of the Legislatures of two thirds of the several - States, shall call a Convention for proposing Amendments, which, in - either Case, shall be valid to all Intents and Purposes, as Part of - this Constitution, when ratified by the Legislatures of three fourths - of the several States, or by Conventions in three fourths thereof, as - the one or the other Mode of Ratification may be proposed by the - Congress; Provided that no Amendment which may be made prior to the - Year One thousand eight hundred and eight shall in any Manner affect - the first and fourth Clauses in the Ninth Section of the first - Article; and that no State, without its Consent, shall be deprived of - its equal Suffrage in the Senate. - -Article. VI. - - Clause 1: All Debts contracted and Engagements entered into, before - the Adoption of this Constitution, shall be as valid against the - United States under this Constitution, as under the Confederation. - - Clause 2: This Constitution, and the Laws of the United States which - shall be made in Pursuance thereof; and all Treaties made, or which - shall be made, under the Authority of the United States, shall be the - supreme Law of the Land; and the Judges in every State shall be bound - thereby, any Thing in the Constitution or Laws of any State to the - Contrary notwithstanding. - - Clause 3: The Senators and Representatives before mentioned, and the - Members of the several State Legislatures, and all executive and - judicial Officers, both of the United States and of the several - States, shall be bound by Oath or Affirmation, to support this - Constitution; but no religious Test shall ever be required as a - Qualification to any Office or public Trust under the United States. - -Article. VII. - - The Ratification of the Conventions of nine States, shall be - sufficient for the Establishment of this Constitution between the - States so ratifying the Same. - - done in Convention by the Unanimous Consent of the States present the - Seventeenth Day of September in the Year of our Lord one thousand - seven hundred and Eighty seven and of the Independence of the United - States of America the Twelfth In witness whereof We have hereunto - subscribed our Names, - - GO WASHINGTON--Presidt. and deputy from Virginia - - [Signed also by the deputies of twelve States.] - - Delaware - - Geo: Read - Gunning Bedford jun - John Dickinson - Richard Bassett - Jaco: Broom - - Maryland - - James MCHenry - Dan of ST ThoS. Jenifer - DanL Carroll. - - Virginia - - John Blair-- - James Madison Jr. - - North Carolina - - WM Blount - RichD. Dobbs Spaight. - Hu Williamson - - South Carolina - - J. Rutledge - Charles 1ACotesworth Pinckney - Charles Pinckney - Pierce Butler. - - Georgia - - William Few - Abr Baldwin - - New Hampshire - - John Langdon - Nicholas Gilman - - Massachusetts - - Nathaniel Gorham - Rufus King - - Connecticut - WM. SamL. Johnson - Roger Sherman - - New York - - Alexander Hamilton - - New Jersey - - Wil: Livingston - David Brearley. - WM. Paterson. - Jona: Dayton - - Pennsylvania - - B Franklin - Thomas Mifflin - RobT Morris - Geo. Clymer - ThoS. FitzSimons - Jared Ingersoll - James Wilson. - Gouv Morris - - Attest William Jackson Secretary - - NOTES - - Note 1: This text of the Constitution follows the engrossed copy - signed by Gen. Washington and the deputies from 12 States. The small - superior figures preceding the paragraphs designate Clauses, and were - not in the original and have no reference to footnotes. - - The Constitution was adopted by a convention of the States on - September 17, 1787, and was subsequently ratified by the several - States, on the following dates: Delaware, December 7, 1787; - Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; - Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, - February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, - 1788; New Hampshire, June 21, 1788. - - Ratification was completed on June 21, 1788. - - The Constitution was subsequently ratified by Virginia, June 25, 1788; - New York, July 26, 1788; North Carolina, November 21, 1789; Rhode - Island, May 29, 1790; and Vermont, January 10, 1791. - - In May 1785, a committee of Congress made a report recommending an - alteration in the Articles of Confederation, but no action was taken - on it, and it was left to the State Legislatures to proceed in the - matter. In January 1786, the Legislature of Virginia passed a - resolution providing for the appointment of five commissioners, who, - or any three of them, should meet such commissioners as might be - appointed in the other States of the Union, at a time and place to be - agreed upon, to take into consideration the trade of the United - States; to consider how far a uniform system in their commercial - regulations may be necessary to their common interest and their - permanent harmony; and to report to the several States such an act, - relative to this great object, as, when ratified by them, will enable - the United States in Congress effectually to provide for the same. The - Virginia commissioners, after some correspondence, fixed the first - Monday in September as the time, and the city of Annapolis as the - place for the meeting, but only four other States were represented, - viz: Delaware, New York, New Jersey, and Pennsylvania; the - commissioners appointed by Massachusetts, New Hampshire, North - Carolina, and Rhode Island failed to attend. Under the circumstances - of so partial a representation, the commissioners present agreed upon - a report, (drawn by Mr. Hamilton, of New York,) expressing their - unanimous conviction that it might essentially tend to advance the - interests of the Union if the States by which they were respectively - delegated would concur, and use their endeavors to procure the - concurrence of the other States, in the appointment of commissioners - to meet at Philadelphia on the Second Monday of May following, to take - into consideration the situation of the United States; to devise such - further provisions as should appear to them necessary to render the - Constitution of the Federal Government adequate to the exigencies of - the Union; and to report such an act for that purpose to the United - States in Congress assembled as, when agreed to by them and afterwards - confirmed by the Legislatures of every State, would effectually - provide for the same. - - Congress, on the 21st of February, 1787, adopted a resolution in favor - of a convention, and the Legislatures of those States which had not - already done so (with the exception of Rhode Island) promptly - appointed delegates. On the 25th of May, seven States having convened, - George Washington, of Virginia, was unanimously elected President, and - the consideration of the proposed constitution was commenced. On the - 17th of September, 1787, the Constitution as engrossed and agreed upon - was signed by all the members present, except Mr. Gerry of - Massachusetts, and Messrs. Mason and Randolph, of Virginia. The - president of the convention transmitted it to Congress, with a - resolution stating how the proposed Federal Government should be put - in operation, and an explanatory letter. Congress, on the 28th of - September, 1787, directed the Constitution so framed, with the - resolutions and letter concerning the same, to "be transmitted to the - several Legislatures in order to be submitted to a convention of - delegates chosen in each State by the people thereof, in conformity to - the resolves of the convention." - - On the 4th of March, 1789, the day which had been fixed for commencing - the operations of Government under the new Constitution, it had been - ratified by the conventions chosen in each State to consider it, as - follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; - New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, - January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, - 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; - Virginia, June 25, 1788; and New York, July 26, 1788. - - The President informed Congress, on the 28th of January, 1790, that - North Carolina had ratified the Constitution November 21, 1789; and he - informed Congress on the 1st of June, 1790, that Rhode Island had - ratified the Constitution May 29, 1790. Vermont, in convention, - ratified the Constitution January 10, 1791, and was, by an act of - Congress approved February 18, 1791, "received and admitted into this - Union as a new and entire member of the United States." - - Note 2: The part of this Clause relating to the mode of apportionment - of representatives among the several States has been affected by - Section 2 of amendment XIV, and as to taxes on incomes without - apportionment by amendment XVI. - - Note 3: This Clause has been affected by Clause 1 of amendment XVII. - - Note 4: This Clause has been affected by Clause 2 of amendment XVIII. - - Note 5: This Clause has been affected by amendment XX. - - Note 6: This Clause has been affected by amendment XXVII. - - Note 7: This Clause has been affected by amendment XVI. - - Note 8: This Clause has been superseded by amendment XII. - - Note 9: This Clause has been affected by amendment XXV. - - Note 10: This Clause has been affected by amendment XI. - - Note 11: This Clause has been affected by amendment XIII. - - Note 12: The first ten amendments to the Constitution of the United - States (and two others, one of which failed of ratification and the - other which later became the 27th amendment) were proposed to the - legislatures of the several States by the First Congress on September - 25, 1789. The first ten amendments were ratified by the following - States, and the notifications of ratification by the Governors thereof - were successively communicated by the President to Congress: New - Jersey, November 20, 1789; Maryland, December 19, 1789; North - Carolina, December 22, 1789; South Carolina, January 19, 1790; New - Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, - February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, - 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. - - Ratification was completed on December 15, 1791. - - The amendments were subsequently ratified by the legislatures of - Massachusetts, March 2, 1939; Georgia, March 18, 1939; and - Connecticut, April 19, 1939. - - Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had - numbers assigned to them at the time of ratification. - - Note 14: This sentence has been superseded by section 3 of amendment - XX. - - Note 15: See amendment XIX and section 1 of amendment XXVI. - - Note 16: Repealed by section 1 of amendment XXI. - -References - - 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/alloc_extra_cpp.txt b/tests/alloc_extra_cpp.txt deleted file mode 100644 index 243df29..0000000 --- a/tests/alloc_extra_cpp.txt +++ /dev/null @@ -1,795 +0,0 @@ - - THE UNITED STATES CONSTITUTION - _________________________________________________________________ - - (See Note 1) - - We the People of the United States, in Order to form a more perfect - Union, establish Justice, insure domestic Tranquility, provide for the - common defence, promote the general Welfare, and secure the Blessings - of Liberty to ourselves and our Posterity, do ordain and establish - this Constitution for the United States of America. - -Article. I. - - Section 1. - - All legislative Powers herein granted shall be vested in a Congress of - the United States, which shall consist of a Senate and House of - Representatives. - - Section. 2. - - Clause 1: The House of Representatives shall be composed of Members - chosen every second Year by the People of the several States, and the - Electors in each State shall have the Qualifications requisite for - Electors of the most numerous Branch of the State Legislature. - - Clause 2: No Person shall be a Representative who shall not have - attained to the Age of twenty five Years, and been seven Years a - Citizen of the United States, and who shall not, when elected, be an - Inhabitant of that State in which he shall be chosen. - - Clause 3: Representatives and direct Taxes shall be apportioned among - the several States which may be included within this Union, according - to their respective Numbers, which shall be determined by adding to - the whole Number of free Persons, including those bound to Service for - a Term of Years, and excluding Indians not taxed, three fifths of all - other Persons. (See Note 2) The actual Enumeration shall be made - within three Years after the first Meeting of the Congress of the - United States, and within every subsequent Term of ten Years, in such - Manner as they shall by Law direct. The Number of Representatives - shall not exceed one for every thirty Thousand, but each State shall - have at Least one Representative; and until such enumeration shall be - made, the State of New Hampshire shall be entitled to chuse three, - Massachusetts eight, Rhode-Island and Providence Plantations one, - Connecticut five, New-York six, New Jersey four, Pennsylvania eight, - Delaware one, Maryland six, Virginia ten, North Carolina five, South - Carolina five, and Georgia three. - - Clause 4: When vacancies happen in the Representation from any State, - the Executive Authority thereof shall issue Writs of Election to fill - such Vacancies. - - Clause 5: The House of Representatives shall chuse their Speaker and - other Officers; and shall have the sole Power of Impeachment. - - Section. 3. - - Clause 1: The Senate of the United States shall be composed of two - Senators from each State, chosen by the Legislature thereof, (See Note - 3) for six Years; and each Senator shall have one Vote. - - Clause 2: Immediately after they shall be assembled in Consequence of - the first Election, they shall be divided as equally as may be into - three Classes. The Seats of the Senators of the first Class shall be - vacated at the Expiration of the second Year, of the second Class at - the Expiration of the fourth Year, and of the third Class at the - Expiration of the sixth Year, so that one third may be chosen every - second Year; and if Vacancies happen by Resignation, or otherwise, - during the Recess of the Legislature of any State, the Executive - thereof may make temporary Appointments until the next Meeting of the - Legislature, which shall then fill such Vacancies. (See Note 4) - - Clause 3: No Person shall be a Senator who shall not have attained to - the Age of thirty Years, and been nine Years a Citizen of the United - States, and who shall not, when elected, be an Inhabitant of that - State for which he shall be chosen. - - Clause 4: The Vice President of the United States shall be President - of the Senate, but shall have no Vote, unless they be equally divided. - - Clause 5: The Senate shall chuse their other Officers, and also a - President pro tempore, in the Absence of the Vice President, or when - he shall exercise the Office of President of the United States. - - Clause 6: The Senate shall have the sole Power to try all - Impeachments. When sitting for that Purpose, they shall be on Oath or - Affirmation. When the President of the United States is tried, the - Chief Justice shall preside: And no Person shall be convicted without - the Concurrence of two thirds of the Members present. - - Clause 7: Judgment in Cases of Impeachment shall not extend further - than to removal from Office, and disqualification to hold and enjoy - any Office of honor, Trust or Profit under the United States: but the - Party convicted shall nevertheless be liable and subject to - Indictment, Trial, Judgment and Punishment, according to Law. - - Section. 4. - - Clause 1: The Times, Places and Manner of holding Elections for - Senators and Representatives, shall be prescribed in each State by the - Legislature thereof; but the Congress may at any time by Law make or - alter such Regulations, except as to the Places of chusing Senators. - - Clause 2: The Congress shall assemble at least once in every Year, and - such Meeting shall be on the first Monday in December, (See Note 5) - unless they shall by Law appoint a different Day. - - Section. 5. - - Clause 1: Each House shall be the Judge of the Elections, Returns and - Qualifications of its own Members, and a Majority of each shall - constitute a Quorum to do Business; but a smaller Number may adjourn - from day to day, and may be authorized to compel the Attendance of - absent Members, in such Manner, and under such Penalties as each House - may provide. - - Clause 2: Each House may determine the Rules of its Proceedings, - punish its Members for disorderly Behaviour, and, with the Concurrence - of two thirds, expel a Member. - - Clause 3: Each House shall keep a Journal of its Proceedings, and from - time to time publish the same, excepting such Parts as may in their - Judgment require Secrecy; and the Yeas and Nays of the Members of - either House on any question shall, at the Desire of one fifth of - those Present, be entered on the Journal. - - Clause 4: Neither House, during the Session of Congress, shall, - without the Consent of the other, adjourn for more than three days, - nor to any other Place than that in which the two Houses shall be - sitting. - - Section. 6. - - Clause 1: The Senators and Representatives shall receive a - Compensation for their Services, to be ascertained by Law, and paid - out of the Treasury of the United States. (See Note 6) They shall in - all Cases, except Treason, Felony and Breach of the Peace, - beprivileged from Arrest during their Attendance at the Session of - their respective Houses, and in going to and returning from the same; - and for any Speech or Debate in either House, they shall not be - questioned in any other Place. - - Clause 2: No Senator or Representative shall, during the Time for - which he was elected, be appointed to any civil Office under the - Authority of the United States, which shall have been created, or the - Emoluments whereof shall have been encreased during such time; and no - Person holding any Office under the United States, shall be a Member - of either House during his Continuance in Office. - - Section. 7. - - Clause 1: All Bills for raising Revenue shall originate in the House - of Representatives; but the Senate may propose or concur with - Amendments as on other Bills. - - Clause 2: Every Bill which shall have passed the House of - Representatives and the Senate, shall, before it become a Law, be - presented to the President of the United States; If he approve he - shall sign it, but if not he shall return it, with his Objections to - that House in which it shall have originated, who shall enter the - Objections at large on their Journal, and proceed to reconsider it. If - after such Reconsideration two thirds of that House shall agree to - pass the Bill, it shall be sent, together with the Objections, to the - other House, by which it shall likewise be reconsidered, and if - approved by two thirds of that House, it shall become a Law. But in - all such Cases the Votes of both Houses shall be determined by yeas - and Nays, and the Names of the Persons voting for and against the Bill - shall be entered on the Journal of each House respectively. If any - Bill shall not be returned by the President within ten Days (Sundays - excepted) after it shall have been presented to him, the Same shall be - a Law, in like Manner as if he had signed it, unless the Congress by - their Adjournment prevent its Return, in which Case it shall not be a - Law. - - Clause 3: Every Order, Resolution, or Vote to which the Concurrence of - the Senate and House of Representatives may be necessary (except on a - question of Adjournment) shall be presented to the President of the - United States; and before the Same shall take Effect, shall be - approved by him, or being disapproved by him, shall be repassed by two - thirds of the Senate and House of Representatives, according to the - Rules and Limitations prescribed in the Case of a Bill. - - Section. 8. - - Clause 1: The Congress shall have Power To lay and collect Taxes, - Duties, Imposts and Excises, to pay the Debts and provide for the - common Defence and general Welfare of the United States; but all - Duties, Imposts and Excises shall be uniform throughout the United - States; - - Clause 2: To borrow Money on the credit of the United States; - - Clause 3: To regulate Commerce with foreign Nations, and among the - several States, and with the Indian Tribes; - - Clause 4: To establish an uniform Rule of Naturalization, and uniform - Laws on the subject of Bankruptcies throughout the United States; - - Clause 5: To coin Money, regulate the Value thereof, and of foreign - Coin, and fix the Standard of Weights and Measures; - - Clause 6: To provide for the Punishment of counterfeiting the - Securities and current Coin of the United States; - - Clause 7: To establish Post Offices and post Roads; - - Clause 8: To promote the Progress of Science and useful Arts, by - securing for limited Times to Authors and Inventors the exclusive - Right to their respective Writings and Discoveries; - - Clause 9: To constitute Tribunals inferior to the supreme Court; - - Clause 10: To define and punish Piracies and Felonies committed on the - high Seas, and Offences against the Law of Nations; - - Clause 11: To declare War, grant Letters of Marque and Reprisal, and - make Rules concerning Captures on Land and Water; - - Clause 12: To raise and support Armies, but no Appropriation of Money - to that Use shall be for a longer Term than two Years; - - Clause 13: To provide and maintain a Navy; - - Clause 14: To make Rules for the Government and Regulation of the land - and naval Forces; - - Clause 15: To provide for calling forth the Militia to execute the - Laws of the Union, suppress Insurrections and repel Invasions; - - Clause 16: To provide for organizing, arming, and disciplining, the - Militia, and for governing such Part of them as may be employed in the - Service of the United States, reserving to the States respectively, - the Appointment of the Officers, and the Authority of training the - Militia according to the discipline prescribed by Congress; - - Clause 17: To exercise exclusive Legislation in all Cases whatsoever, - over such District (not exceeding ten Miles square) as may, byCession - of particular States, and the Acceptance of Congress, become the Seat - of the Government of the United States, and to exercise like Authority - over all Places purchased by the Consent of the Legislature of the - State in which the Same shall be, for the Erection of Forts, - Magazines, Arsenals, dock-Yards, and other needful Buildings;--And - - Clause 18: To make all Laws which shall be necessary and proper for - carrying into Execution the foregoing Powers, and all other Powers - vested by this Constitution in the Government of the United States, or - in any Department or Officer thereof. - - Section. 9. - - Clause 1: The Migration or Importation of such Persons as any of the - States now existing shall think proper to admit, shall not be - prohibited by the Congress prior to the Year one thousand eight - hundred and eight, but a Tax or duty may be imposed on such - Importation, not exceeding ten dollars for each Person. - - Clause 2: The Privilege of the Writ of Habeas Corpus shall not be - suspended, unless when in Cases of Rebellion or Invasion the public - Safety may require it. - - Clause 3: No Bill of Attainder or ex post facto Law shall be passed. - - Clause 4: No Capitation, or other direct, Tax shall be laid, unless in - Proportion to the Census or Enumeration herein before directed to be - taken. (See Note 7) - - Clause 5: No Tax or Duty shall be laid on Articles exported from any - State. - - Clause 6: No Preference shall be given by any Regulation of Commerce - or Revenue to the Ports of one State over those of another: nor shall - Vessels bound to, or from, one State, be obliged to enter, clear, or - pay Duties in another. - - Clause 7: No Money shall be drawn from the Treasury, but in - Consequence of Appropriations made by Law; and a regular Statement and - Account of the Receipts and Expenditures of all public Money shall be - published from time to time. - - Clause 8: No Title of Nobility shall be granted by the United States: - And no Person holding any Office of Profit or Trust under them, shall, - without the Consent of the Congress, accept of any present, Emolument, - Office, or Title, of any kind whatever, from any King, Prince, or - foreign State. - - Section. 10. - - Clause 1: No State shall enter into any Treaty, Alliance, or - Confederation; grant Letters of Marque and Reprisal; coin Money; emit - Bills of Credit; make any Thing but gold and silver Coin a Tender in - Payment of Debts; pass any Bill of Attainder, ex post facto Law, or - Law impairing the Obligation of Contracts, or grant any Title of - Nobility. - - Clause 2: No State shall, without the Consent of the Congress, lay any - Imposts or Duties on Imports or Exports, except what may be absolutely - necessary for executing it's inspection Laws: and the net Produce of - all Duties and Imposts, laid by any State on Imports or Exports, shall - be for the Use of the Treasury of the United States; and all such Laws - shall be subject to the Revision and Controul of the Congress. - - Clause 3: No State shall, without the Consent of Congress, lay any - Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter - into any Agreement or Compact with another State, or with a foreign - Power, or engage in War, unless actually invaded, or in such imminent - Danger as will not admit of delay. - -Article. II. - - Section. 1. - - Clause 1: The executive Power shall be vested in a President of the - United States of America. He shall hold his Office during the Term of - four Years, and, together with the Vice President, chosen for the same - Term, be elected, as follows - - Clause 2: Each State shall appoint, in such Manner as the Legislature - thereof may direct, a Number of Electors, equal to the whole Number of - Senators and Representatives to which the State may be entitled in the - Congress: but no Senator or Representative, or Person holding an - Office of Trust or Profit under the United States, shall be appointed - an Elector. - - Clause 3: The Electors shall meet in their respective States, and vote - by Ballot for two Persons, of whom one at least shall not be an - Inhabitant of the same State with themselves. And they shall make a - List of all the Persons voted for, and of the Number of Votes for - each; which List they shall sign and certify, and transmit sealed to - the Seat of the Government of the United States, directed to the - President of the Senate. The President of the Senate shall, in the - Presence of the Senate and House of Representatives, open all the - Certificates, and the Votes shall then be counted. The Person having - the greatest Number of Votes shall be the President, if such Number be - a Majority of the whole Number of Electors appointed; and if there be - more than one who have such Majority, and have an equal Number of - Votes, then the House of Representatives shall immediately chuse by - Ballot one of them for President; and if no Person have a Majority, - then from the five highest on the List the said House shall in like - Manner chuse the President. But in chusing the President, the Votes - shall be taken by States, the Representation from each State having - one Vote; A quorum for this Purpose shall consist of a Member or - Members from two thirds of the States, and a Majority of all the - States shall be necessary to a Choice. In every Case, after the Choice - of the President, the Person having the greatest Number of Votes of - the Electors shall be the Vice President. But if there should remain - two or more who have equal Votes, the Senate shall chuse from them by - Ballot the Vice President. (See Note 8) - - Clause 4: The Congress may determine the Time of chusing the Electors, - and the Day on which they shall give their Votes; which Day shall be - the same throughout the United States. - - Clause 5: No Person except a natural born Citizen, or a Citizen of the - United States, at the time of the Adoption of this Constitution, shall - be eligible to the Office of President; neither shall any Person be - eligible to that Office who shall not have attained to the Age of - thirty five Years, and been fourteen Years a Resident within the - United States. - - Clause 6: In Case of the Removal of the President from Office, or of - his Death, Resignation, or Inability to discharge the Powers and - Duties of the said Office, (See Note 9) the Same shall devolve on the - VicePresident, and the Congress may by Law provide for the Case of - Removal, Death, Resignation or Inability, both of the President and - Vice President, declaring what Officer shall then act as President, - and such Officer shall act accordingly, until the Disability be - removed, or a President shall be elected. - - Clause 7: The President shall, at stated Times, receive for his - Services, a Compensation, which shall neither be encreased nor - diminished during the Period for which he shall have been elected, and - he shall not receive within that Period any other Emolument from the - United States, or any of them. - - Clause 8: Before he enter on the Execution of his Office, he shall - take the following Oath or Affirmation:--"I do solemnly swear (or - affirm) that I will faithfully execute the Office of President of the - United States, and will to the best of my Ability, preserve, protect - and defend the Constitution of the United States." - - Section. 2. - - Clause 1: The President shall be Commander in Chief of the Army and - Navy of the United States, and of the Militia of the several States, - when called into the actual Service of the United States; he may - require the Opinion, in writing, of the principal Officer in each of - the executive Departments, upon any Subject relating to the Duties of - their respective Offices, and he shall have Power to grant Reprieves - and Pardons for Offences against the United States, except in Cases of - Impeachment. - - Clause 2: He shall have Power, by and with the Advice and Consent of - the Senate, to make Treaties, provided two thirds of the Senators - present concur; and he shall nominate, and by and with the Advice and - Consent of the Senate, shall appoint Ambassadors, other public - Ministers and Consuls, Judges of the supreme Court, and all other - Officers of the United States, whose Appointments are not herein - otherwise provided for, and which shall be established by Law: but the - Congress may by Law vest the Appointment of such inferior Officers, as - they think proper, in the President alone, in the Courts of Law, or in - the Heads of Departments. - - Clause 3: The President shall have Power to fill up all Vacancies that - may happen during the Recess of the Senate, by granting Commissions - which shall expire at the End of their next Session. - - Section. 3. - - He shall from time to time give to the Congress Information of the - State of the Union, and recommend to their Consideration such Measures - as he shall judge necessary and expedient; he may, on extraordinary - Occasions, convene both Houses, or either of them, and in Case of - Disagreement between them, with Respect to the Time of Adjournment, he - may adjourn them to such Time as he shall think proper; he shall - receive Ambassadors and other public Ministers; he shall take Care - that the Laws be faithfully executed, and shall Commission all the - Officers of the United States. - - Section. 4. - - The President, Vice President and all civil Officers of the United - States, shall be removed from Office on Impeachment for, and - Conviction of, Treason, Bribery, or other high Crimes and - Misdemeanors. - -Article. III. - - Section. 1. - - The judicial Power of the United States, shall be vested in one - supreme Court, and in such inferior Courts as the Congress may from - time to time ordain and establish. The Judges, both of the supreme and - inferior Courts, shall hold their Offices during good Behaviour, and - shall, at stated Times, receive for their Services, a Compensation, - which shall not be diminished during their Continuance in Office. - - Section. 2. - - Clause 1: The judicial Power shall extend to all Cases, in Law and - Equity, arising under this Constitution, the Laws of the United - States, and Treaties made, or which shall be made, under their - Authority;--to all Cases affecting Ambassadors, other public Ministers - and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to - Controversies to which the United States shall be a Party;--to - Controversies between two or more States;--between a State and - Citizens of another State; (See Note 10)--between Citizens of - different States, --between Citizens of the same State claiming Lands - under Grants of different States, and between a State, or the Citizens - thereof, and foreign States, Citizens or Subjects. - - Clause 2: In all Cases affecting Ambassadors, other public Ministers - and Consuls, and those in which a State shall be Party, the supreme - Court shall have original Jurisdiction. In all the other Cases before - mentioned, the supreme Court shall have appellate Jurisdiction, both - as to Law and Fact, with such Exceptions, and under such Regulations - as the Congress shall make. - - Clause 3: The Trial of all Crimes, except in Cases of Impeachment, - shall be by Jury; and such Trial shall be held in the State where the - said Crimes shall have been committed; but when not committed within - any State, the Trial shall be at such Place or Places as the Congress - may by Law have directed. - - Section. 3. - - Clause 1: Treason against the United States, shall consist only in - levying War against them, or in adhering to their Enemies, giving them - Aid and Comfort. No Person shall be convicted of Treason unless on the - Testimony of two Witnesses to the same overt Act, or on Confession in - open Court. - - Clause 2: The Congress shall have Power to declare the Punishment of - Treason, but no Attainder of Treason shall work Corruption of Blood, - or Forfeiture except during the Life of the Person attainted. - -Article. IV. - - Section. 1. - - Full Faith and Credit shall be given in each State to the public Acts, - Records, and judicial Proceedings of every other State. And the - Congress may by general Laws prescribe the Manner in which such Acts, - Records and Proceedings shall be proved, and the Effect thereof. - - Section. 2. - - Clause 1: The Citizens of each State shall be entitled to all - Privileges and Immunities of Citizens in the several States. - - Clause 2: A Person charged in any State with Treason, Felony, or other - Crime, who shall flee from Justice, and be found in another State, - shall on Demand of the executive Authority of the State from which he - fled, be delivered up, to be removed to the State having Jurisdiction - of the Crime. - - Clause 3: No Person held to Service or Labour in one State, under the - Laws thereof, escaping into another, shall, in Consequence of any Law - or Regulation therein, be discharged from such Service or Labour, but - shall be delivered up on Claim of the Party to whom such Service or - Labour may be due. (See Note 11) - - Section. 3. - - Clause 1: New States may be admitted by the Congress into this Union; - but no new State shall be formed or erected within the Jurisdiction of - any other State; nor any State be formed by the Junction of two or - more States, or Parts of States, without the Consent of the - Legislatures of the States concerned as well as of the Congress. - - Clause 2: The Congress shall have Power to dispose of and make all - needful Rules and Regulations respecting the Territory or other - Property belonging to the United States; and nothing in this - Constitution shall be so construed as to Prejudice any Claims of the - United States, or of any particular State. - - Section. 4. - - The United States shall guarantee to every State in this Union a - Republican Form of Government, and shall protect each of them against - Invasion; and on Application of the Legislature, or of the Executive - (when the Legislature cannot be convened) against domestic Violence. - -Article. V. - - The Congress, whenever two thirds of both Houses shall deem it - necessary, shall propose [1]Amendments to this Constitution, or, on - the Application of the Legislatures of two thirds of the several - States, shall call a Convention for proposing Amendments, which, in - either Case, shall be valid to all Intents and Purposes, as Part of - this Constitution, when ratified by the Legislatures of three fourths - of the several States, or by Conventions in three fourths thereof, as - the one or the other Mode of Ratification may be proposed by the - Congress; Provided that no Amendment which may be made prior to the - Year One thousand eight hundred and eight shall in any Manner affect - the first and fourth Clauses in the Ninth Section of the first - Article; and that no State, without its Consent, shall be deprived of - its equal Suffrage in the Senate. - -Article. VI. - - Clause 1: All Debts contracted and Engagements entered into, before - the Adoption of this Constitution, shall be as valid against the - United States under this Constitution, as under the Confederation. - - Clause 2: This Constitution, and the Laws of the United States which - shall be made in Pursuance thereof; and all Treaties made, or which - shall be made, under the Authority of the United States, shall be the - supreme Law of the Land; and the Judges in every State shall be bound - thereby, any Thing in the Constitution or Laws of any State to the - Contrary notwithstanding. - - Clause 3: The Senators and Representatives before mentioned, and the - Members of the several State Legislatures, and all executive and - judicial Officers, both of the United States and of the several - States, shall be bound by Oath or Affirmation, to support this - Constitution; but no religious Test shall ever be required as a - Qualification to any Office or public Trust under the United States. - -Article. VII. - - The Ratification of the Conventions of nine States, shall be - sufficient for the Establishment of this Constitution between the - States so ratifying the Same. - - done in Convention by the Unanimous Consent of the States present the - Seventeenth Day of September in the Year of our Lord one thousand - seven hundred and Eighty seven and of the Independence of the United - States of America the Twelfth In witness whereof We have hereunto - subscribed our Names, - - GO WASHINGTON--Presidt. and deputy from Virginia - - [Signed also by the deputies of twelve States.] - - Delaware - - Geo: Read - Gunning Bedford jun - John Dickinson - Richard Bassett - Jaco: Broom - - Maryland - - James MCHenry - Dan of ST ThoS. Jenifer - DanL Carroll. - - Virginia - - John Blair-- - James Madison Jr. - - North Carolina - - WM Blount - RichD. Dobbs Spaight. - Hu Williamson - - South Carolina - - J. Rutledge - Charles 1ACotesworth Pinckney - Charles Pinckney - Pierce Butler. - - Georgia - - William Few - Abr Baldwin - - New Hampshire - - John Langdon - Nicholas Gilman - - Massachusetts - - Nathaniel Gorham - Rufus King - - Connecticut - WM. SamL. Johnson - Roger Sherman - - New York - - Alexander Hamilton - - New Jersey - - Wil: Livingston - David Brearley. - WM. Paterson. - Jona: Dayton - - Pennsylvania - - B Franklin - Thomas Mifflin - RobT Morris - Geo. Clymer - ThoS. FitzSimons - Jared Ingersoll - James Wilson. - Gouv Morris - - Attest William Jackson Secretary - - NOTES - - Note 1: This text of the Constitution follows the engrossed copy - signed by Gen. Washington and the deputies from 12 States. The small - superior figures preceding the paragraphs designate Clauses, and were - not in the original and have no reference to footnotes. - - The Constitution was adopted by a convention of the States on - September 17, 1787, and was subsequently ratified by the several - States, on the following dates: Delaware, December 7, 1787; - Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; - Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, - February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, - 1788; New Hampshire, June 21, 1788. - - Ratification was completed on June 21, 1788. - - The Constitution was subsequently ratified by Virginia, June 25, 1788; - New York, July 26, 1788; North Carolina, November 21, 1789; Rhode - Island, May 29, 1790; and Vermont, January 10, 1791. - - In May 1785, a committee of Congress made a report recommending an - alteration in the Articles of Confederation, but no action was taken - on it, and it was left to the State Legislatures to proceed in the - matter. In January 1786, the Legislature of Virginia passed a - resolution providing for the appointment of five commissioners, who, - or any three of them, should meet such commissioners as might be - appointed in the other States of the Union, at a time and place to be - agreed upon, to take into consideration the trade of the United - States; to consider how far a uniform system in their commercial - regulations may be necessary to their common interest and their - permanent harmony; and to report to the several States such an act, - relative to this great object, as, when ratified by them, will enable - the United States in Congress effectually to provide for the same. The - Virginia commissioners, after some correspondence, fixed the first - Monday in September as the time, and the city of Annapolis as the - place for the meeting, but only four other States were represented, - viz: Delaware, New York, New Jersey, and Pennsylvania; the - commissioners appointed by Massachusetts, New Hampshire, North - Carolina, and Rhode Island failed to attend. Under the circumstances - of so partial a representation, the commissioners present agreed upon - a report, (drawn by Mr. Hamilton, of New York,) expressing their - unanimous conviction that it might essentially tend to advance the - interests of the Union if the States by which they were respectively - delegated would concur, and use their endeavors to procure the - concurrence of the other States, in the appointment of commissioners - to meet at Philadelphia on the Second Monday of May following, to take - into consideration the situation of the United States; to devise such - further provisions as should appear to them necessary to render the - Constitution of the Federal Government adequate to the exigencies of - the Union; and to report such an act for that purpose to the United - States in Congress assembled as, when agreed to by them and afterwards - confirmed by the Legislatures of every State, would effectually - provide for the same. - - Congress, on the 21st of February, 1787, adopted a resolution in favor - of a convention, and the Legislatures of those States which had not - already done so (with the exception of Rhode Island) promptly - appointed delegates. On the 25th of May, seven States having convened, - George Washington, of Virginia, was unanimously elected President, and - the consideration of the proposed constitution was commenced. On the - 17th of September, 1787, the Constitution as engrossed and agreed upon - was signed by all the members present, except Mr. Gerry of - Massachusetts, and Messrs. Mason and Randolph, of Virginia. The - president of the convention transmitted it to Congress, with a - resolution stating how the proposed Federal Government should be put - in operation, and an explanatory letter. Congress, on the 28th of - September, 1787, directed the Constitution so framed, with the - resolutions and letter concerning the same, to "be transmitted to the - several Legislatures in order to be submitted to a convention of - delegates chosen in each State by the people thereof, in conformity to - the resolves of the convention." - - On the 4th of March, 1789, the day which had been fixed for commencing - the operations of Government under the new Constitution, it had been - ratified by the conventions chosen in each State to consider it, as - follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; - New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, - January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, - 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; - Virginia, June 25, 1788; and New York, July 26, 1788. - - The President informed Congress, on the 28th of January, 1790, that - North Carolina had ratified the Constitution November 21, 1789; and he - informed Congress on the 1st of June, 1790, that Rhode Island had - ratified the Constitution May 29, 1790. Vermont, in convention, - ratified the Constitution January 10, 1791, and was, by an act of - Congress approved February 18, 1791, "received and admitted into this - Union as a new and entire member of the United States." - - Note 2: The part of this Clause relating to the mode of apportionment - of representatives among the several States has been affected by - Section 2 of amendment XIV, and as to taxes on incomes without - apportionment by amendment XVI. - - Note 3: This Clause has been affected by Clause 1 of amendment XVII. - - Note 4: This Clause has been affected by Clause 2 of amendment XVIII. - - Note 5: This Clause has been affected by amendment XX. - - Note 6: This Clause has been affected by amendment XXVII. - - Note 7: This Clause has been affected by amendment XVI. - - Note 8: This Clause has been superseded by amendment XII. - - Note 9: This Clause has been affected by amendment XXV. - - Note 10: This Clause has been affected by amendment XI. - - Note 11: This Clause has been affected by amendment XIII. - - Note 12: The first ten amendments to the Constitution of the United - States (and two others, one of which failed of ratification and the - other which later became the 27th amendment) were proposed to the - legislatures of the several States by the First Congress on September - 25, 1789. The first ten amendments were ratified by the following - States, and the notifications of ratification by the Governors thereof - were successively communicated by the President to Congress: New - Jersey, November 20, 1789; Maryland, December 19, 1789; North - Carolina, December 22, 1789; South Carolina, January 19, 1790; New - Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, - February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, - 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. - - Ratification was completed on December 15, 1791. - - The amendments were subsequently ratified by the legislatures of - Massachusetts, March 2, 1939; Georgia, March 18, 1939; and - Connecticut, April 19, 1939. - - Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had - numbers assigned to them at the time of ratification. - - Note 14: This sentence has been superseded by section 3 of amendment - XX. - - Note 15: See amendment XIX and section 1 of amendment XXVI. - - Note 16: Repealed by section 1 of amendment XXI. - -References - - 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/array.txt b/tests/array.txt new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/array.txt @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/array_c99.txt b/tests/array_c99.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/array_c99.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/array_nr.txt b/tests/array_nr.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/array_nr.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/array_r.txt b/tests/array_r.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/array_r.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/basic.txt b/tests/basic.txt new file mode 100644 index 0000000..642e0fb --- /dev/null +++ b/tests/basic.txt @@ -0,0 +1,5 @@ +# this is a comment +foo = "bar" +num = 43 +setting = false + diff --git a/tests/basic_c99.txt b/tests/basic_c99.txt deleted file mode 100644 index 2160628..0000000 --- a/tests/basic_c99.txt +++ /dev/null @@ -1,4 +0,0 @@ -# this is a comment -foo = "bar" -num = 43 -setting = false diff --git a/tests/basic_nr.txt b/tests/basic_nr.txt deleted file mode 100644 index 642e0fb..0000000 --- a/tests/basic_nr.txt +++ /dev/null @@ -1,5 +0,0 @@ -# this is a comment -foo = "bar" -num = 43 -setting = false - diff --git a/tests/basic_r.txt b/tests/basic_r.txt deleted file mode 100644 index 2160628..0000000 --- a/tests/basic_r.txt +++ /dev/null @@ -1,4 +0,0 @@ -# this is a comment -foo = "bar" -num = 43 -setting = false diff --git a/tests/ccl.txt b/tests/ccl.txt new file mode 100644 index 0000000..b318fe6 --- /dev/null +++ b/tests/ccl.txt @@ -0,0 +1,27 @@ +^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ +^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ +^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ +^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ +^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ +^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ +^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ +^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ +^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ +^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ +a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ +l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ +abcd-bc:aaaaddddaaaa@abcd-bc@ +abcde-b-c:aaaaddddeeee@abcde-b-c@ +^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ +a+d:abc0123xyz789@a+d@ +a-u+Q:abcQQQQxyz@a-u+Q@ +ia:AaAa@ia@ +iabc:ABCabcAbCaBc@iabc@ +ia-c:ABCabcAbCaBc@ia-c@ +check-a:a@ +dot-all-1:XXX junk + junk + junk + @dot-all-1@ +x1:abaabb@x1@ +x2:abaabb@x2@ diff --git a/tests/ccl_c99.txt b/tests/ccl_c99.txt deleted file mode 100644 index b318fe6..0000000 --- a/tests/ccl_c99.txt +++ /dev/null @@ -1,27 +0,0 @@ -^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ -^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ -^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ -^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ -^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ -^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ -^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ -^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ -^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ -^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ -a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ -l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ -abcd-bc:aaaaddddaaaa@abcd-bc@ -abcde-b-c:aaaaddddeeee@abcde-b-c@ -^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ -a+d:abc0123xyz789@a+d@ -a-u+Q:abcQQQQxyz@a-u+Q@ -ia:AaAa@ia@ -iabc:ABCabcAbCaBc@iabc@ -ia-c:ABCabcAbCaBc@ia-c@ -check-a:a@ -dot-all-1:XXX junk - junk - junk - @dot-all-1@ -x1:abaabb@x1@ -x2:abaabb@x2@ diff --git a/tests/ccl_cpp.txt b/tests/ccl_cpp.txt deleted file mode 100644 index b318fe6..0000000 --- a/tests/ccl_cpp.txt +++ /dev/null @@ -1,27 +0,0 @@ -^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ -^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ -^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ -^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ -^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ -^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ -^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ -^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ -^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ -^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ -a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ -l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ -abcd-bc:aaaaddddaaaa@abcd-bc@ -abcde-b-c:aaaaddddeeee@abcde-b-c@ -^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ -a+d:abc0123xyz789@a+d@ -a-u+Q:abcQQQQxyz@a-u+Q@ -ia:AaAa@ia@ -iabc:ABCabcAbCaBc@iabc@ -ia-c:ABCabcAbCaBc@ia-c@ -check-a:a@ -dot-all-1:XXX junk - junk - junk - @dot-all-1@ -x1:abaabb@x1@ -x2:abaabb@x2@ diff --git a/tests/debug.txt b/tests/debug.txt new file mode 100644 index 0000000..8d6476c --- /dev/null +++ b/tests/debug.txt @@ -0,0 +1,2 @@ +Any input will do for this test. +We are only testing if it actually runs in debug mode. diff --git a/tests/debug_c99.txt b/tests/debug_c99.txt deleted file mode 100644 index 8d6476c..0000000 --- a/tests/debug_c99.txt +++ /dev/null @@ -1,2 +0,0 @@ -Any input will do for this test. -We are only testing if it actually runs in debug mode. diff --git a/tests/debug_nr.txt b/tests/debug_nr.txt deleted file mode 100644 index 8d6476c..0000000 --- a/tests/debug_nr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Any input will do for this test. -We are only testing if it actually runs in debug mode. diff --git a/tests/debug_r.txt b/tests/debug_r.txt deleted file mode 100644 index 8d6476c..0000000 --- a/tests/debug_r.txt +++ /dev/null @@ -1,2 +0,0 @@ -Any input will do for this test. -We are only testing if it actually runs in debug mode. diff --git a/tests/extended.txt b/tests/extended.txt new file mode 100644 index 0000000..829e23d --- /dev/null +++ b/tests/extended.txt @@ -0,0 +1,2 @@ +abcdefghijklmnopqrstuvwxyz +ABCD diff --git a/tests/extended_c99.txt b/tests/extended_c99.txt deleted file mode 100644 index 829e23d..0000000 --- a/tests/extended_c99.txt +++ /dev/null @@ -1,2 +0,0 @@ -abcdefghijklmnopqrstuvwxyz -ABCD diff --git a/tests/extended_cpp.txt b/tests/extended_cpp.txt deleted file mode 100644 index 829e23d..0000000 --- a/tests/extended_cpp.txt +++ /dev/null @@ -1,2 +0,0 @@ -abcdefghijklmnopqrstuvwxyz -ABCD diff --git a/tests/mem.txt b/tests/mem.txt new file mode 100644 index 0000000..79aa16a --- /dev/null +++ b/tests/mem.txt @@ -0,0 +1,25 @@ +First we push a lot on the stack by nesting parenthesis: + +(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( +(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( +((((((((((((((((((((((((((((((((((((((((((( + +(should be 200 states pushed here) + +)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) +)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) +))))))))))))))))))))))))))))))))))))))))))) + +Now we match progressively bigger tokens to increase the read buffer: + +len=1 0 +len=2 00 +len=4 0000 +len=8 00000000 +len=16 0000000000000000 +len=32 00000000000000000000000000000000 +len=64 0000000000000000000000000000000000000000000000000000000000000000 +len=128 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +len=256 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +len=512 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +len=1024 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/tests/mem_c99.txt b/tests/mem_c99.txt deleted file mode 100644 index 79aa16a..0000000 --- a/tests/mem_c99.txt +++ /dev/null @@ -1,25 +0,0 @@ -First we push a lot on the stack by nesting parenthesis: - -(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( -(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( -((((((((((((((((((((((((((((((((((((((((((( - -(should be 200 states pushed here) - -)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -))))))))))))))))))))))))))))))))))))))))))) - -Now we match progressively bigger tokens to increase the read buffer: - -len=1 0 -len=2 00 -len=4 0000 -len=8 00000000 -len=16 0000000000000000 -len=32 00000000000000000000000000000000 -len=64 0000000000000000000000000000000000000000000000000000000000000000 -len=128 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=256 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=512 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=1024 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/tests/mem_nr.txt b/tests/mem_nr.txt deleted file mode 100644 index 79aa16a..0000000 --- a/tests/mem_nr.txt +++ /dev/null @@ -1,25 +0,0 @@ -First we push a lot on the stack by nesting parenthesis: - -(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( -(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( -((((((((((((((((((((((((((((((((((((((((((( - -(should be 200 states pushed here) - -)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -))))))))))))))))))))))))))))))))))))))))))) - -Now we match progressively bigger tokens to increase the read buffer: - -len=1 0 -len=2 00 -len=4 0000 -len=8 00000000 -len=16 0000000000000000 -len=32 00000000000000000000000000000000 -len=64 0000000000000000000000000000000000000000000000000000000000000000 -len=128 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=256 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=512 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=1024 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/tests/mem_r.txt b/tests/mem_r.txt deleted file mode 100644 index 79aa16a..0000000 --- a/tests/mem_r.txt +++ /dev/null @@ -1,25 +0,0 @@ -First we push a lot on the stack by nesting parenthesis: - -(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( -(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( -((((((((((((((((((((((((((((((((((((((((((( - -(should be 200 states pushed here) - -)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -))))))))))))))))))))))))))))))))))))))))))) - -Now we match progressively bigger tokens to increase the read buffer: - -len=1 0 -len=2 00 -len=4 0000 -len=8 00000000 -len=16 0000000000000000 -len=32 00000000000000000000000000000000 -len=64 0000000000000000000000000000000000000000000000000000000000000000 -len=128 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=256 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=512 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -len=1024 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/tests/prefix.txt b/tests/prefix.txt new file mode 100644 index 0000000..0e6c88f --- /dev/null +++ b/tests/prefix.txt @@ -0,0 +1 @@ +Dummy input. diff --git a/tests/prefix_c99.txt b/tests/prefix_c99.txt deleted file mode 100644 index 0e6c88f..0000000 --- a/tests/prefix_c99.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy input. diff --git a/tests/prefix_nr.txt b/tests/prefix_nr.txt deleted file mode 100644 index 0e6c88f..0000000 --- a/tests/prefix_nr.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy input. diff --git a/tests/prefix_r.txt b/tests/prefix_r.txt deleted file mode 100644 index 0e6c88f..0000000 --- a/tests/prefix_r.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy input. diff --git a/tests/quote_in_comment.txt b/tests/quote_in_comment.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/tests/quote_in_comment.txt @@ -0,0 +1 @@ +test diff --git a/tests/quote_in_comment_c99.txt b/tests/quote_in_comment_c99.txt deleted file mode 100644 index 9daeafb..0000000 --- a/tests/quote_in_comment_c99.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/tests/quote_in_comment_cpp.txt b/tests/quote_in_comment_cpp.txt deleted file mode 100644 index 9daeafb..0000000 --- a/tests/quote_in_comment_cpp.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/tests/quotes.txt b/tests/quotes.txt new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/quotes.txt @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/quotes_c99.txt b/tests/quotes_c99.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/quotes_c99.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/quotes_cpp.txt b/tests/quotes_cpp.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/quotes_cpp.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 293f8cc..33f576a 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -33,8 +33,16 @@ done shift $(($OPTIND-1)) TESTNAME=$1 +# There may be a specific input file for this test INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename "${TESTNAME%.exe}"`.txt} +# If it doesn't exist, try stripping out a backend suffix. +# There might be a generic input for all tests with this stem. +# For this purpose we consider _r and _nr to be back ends. +if [ ! -f ${INPUT_NAME} ] ; then + INPUT_NAME=`echo ${INPUT_NAME} | sed -e 's/_[a-z0-9]*.txt$/.txt/'` +fi + if [ $DO_COMPARISON = 1 ] ; then TEST_OUTPUT=`$TESTNAME < $INPUT_NAME` REF_OUTPUT=`$TESTNAME 1 < $INPUT_NAME` diff --git a/tests/yyextra.txt b/tests/yyextra.txt new file mode 100644 index 0000000..243df29 --- /dev/null +++ b/tests/yyextra.txt @@ -0,0 +1,795 @@ + + THE UNITED STATES CONSTITUTION + _________________________________________________________________ + + (See Note 1) + + We the People of the United States, in Order to form a more perfect + Union, establish Justice, insure domestic Tranquility, provide for the + common defence, promote the general Welfare, and secure the Blessings + of Liberty to ourselves and our Posterity, do ordain and establish + this Constitution for the United States of America. + +Article. I. + + Section 1. + + All legislative Powers herein granted shall be vested in a Congress of + the United States, which shall consist of a Senate and House of + Representatives. + + Section. 2. + + Clause 1: The House of Representatives shall be composed of Members + chosen every second Year by the People of the several States, and the + Electors in each State shall have the Qualifications requisite for + Electors of the most numerous Branch of the State Legislature. + + Clause 2: No Person shall be a Representative who shall not have + attained to the Age of twenty five Years, and been seven Years a + Citizen of the United States, and who shall not, when elected, be an + Inhabitant of that State in which he shall be chosen. + + Clause 3: Representatives and direct Taxes shall be apportioned among + the several States which may be included within this Union, according + to their respective Numbers, which shall be determined by adding to + the whole Number of free Persons, including those bound to Service for + a Term of Years, and excluding Indians not taxed, three fifths of all + other Persons. (See Note 2) The actual Enumeration shall be made + within three Years after the first Meeting of the Congress of the + United States, and within every subsequent Term of ten Years, in such + Manner as they shall by Law direct. The Number of Representatives + shall not exceed one for every thirty Thousand, but each State shall + have at Least one Representative; and until such enumeration shall be + made, the State of New Hampshire shall be entitled to chuse three, + Massachusetts eight, Rhode-Island and Providence Plantations one, + Connecticut five, New-York six, New Jersey four, Pennsylvania eight, + Delaware one, Maryland six, Virginia ten, North Carolina five, South + Carolina five, and Georgia three. + + Clause 4: When vacancies happen in the Representation from any State, + the Executive Authority thereof shall issue Writs of Election to fill + such Vacancies. + + Clause 5: The House of Representatives shall chuse their Speaker and + other Officers; and shall have the sole Power of Impeachment. + + Section. 3. + + Clause 1: The Senate of the United States shall be composed of two + Senators from each State, chosen by the Legislature thereof, (See Note + 3) for six Years; and each Senator shall have one Vote. + + Clause 2: Immediately after they shall be assembled in Consequence of + the first Election, they shall be divided as equally as may be into + three Classes. The Seats of the Senators of the first Class shall be + vacated at the Expiration of the second Year, of the second Class at + the Expiration of the fourth Year, and of the third Class at the + Expiration of the sixth Year, so that one third may be chosen every + second Year; and if Vacancies happen by Resignation, or otherwise, + during the Recess of the Legislature of any State, the Executive + thereof may make temporary Appointments until the next Meeting of the + Legislature, which shall then fill such Vacancies. (See Note 4) + + Clause 3: No Person shall be a Senator who shall not have attained to + the Age of thirty Years, and been nine Years a Citizen of the United + States, and who shall not, when elected, be an Inhabitant of that + State for which he shall be chosen. + + Clause 4: The Vice President of the United States shall be President + of the Senate, but shall have no Vote, unless they be equally divided. + + Clause 5: The Senate shall chuse their other Officers, and also a + President pro tempore, in the Absence of the Vice President, or when + he shall exercise the Office of President of the United States. + + Clause 6: The Senate shall have the sole Power to try all + Impeachments. When sitting for that Purpose, they shall be on Oath or + Affirmation. When the President of the United States is tried, the + Chief Justice shall preside: And no Person shall be convicted without + the Concurrence of two thirds of the Members present. + + Clause 7: Judgment in Cases of Impeachment shall not extend further + than to removal from Office, and disqualification to hold and enjoy + any Office of honor, Trust or Profit under the United States: but the + Party convicted shall nevertheless be liable and subject to + Indictment, Trial, Judgment and Punishment, according to Law. + + Section. 4. + + Clause 1: The Times, Places and Manner of holding Elections for + Senators and Representatives, shall be prescribed in each State by the + Legislature thereof; but the Congress may at any time by Law make or + alter such Regulations, except as to the Places of chusing Senators. + + Clause 2: The Congress shall assemble at least once in every Year, and + such Meeting shall be on the first Monday in December, (See Note 5) + unless they shall by Law appoint a different Day. + + Section. 5. + + Clause 1: Each House shall be the Judge of the Elections, Returns and + Qualifications of its own Members, and a Majority of each shall + constitute a Quorum to do Business; but a smaller Number may adjourn + from day to day, and may be authorized to compel the Attendance of + absent Members, in such Manner, and under such Penalties as each House + may provide. + + Clause 2: Each House may determine the Rules of its Proceedings, + punish its Members for disorderly Behaviour, and, with the Concurrence + of two thirds, expel a Member. + + Clause 3: Each House shall keep a Journal of its Proceedings, and from + time to time publish the same, excepting such Parts as may in their + Judgment require Secrecy; and the Yeas and Nays of the Members of + either House on any question shall, at the Desire of one fifth of + those Present, be entered on the Journal. + + Clause 4: Neither House, during the Session of Congress, shall, + without the Consent of the other, adjourn for more than three days, + nor to any other Place than that in which the two Houses shall be + sitting. + + Section. 6. + + Clause 1: The Senators and Representatives shall receive a + Compensation for their Services, to be ascertained by Law, and paid + out of the Treasury of the United States. (See Note 6) They shall in + all Cases, except Treason, Felony and Breach of the Peace, + beprivileged from Arrest during their Attendance at the Session of + their respective Houses, and in going to and returning from the same; + and for any Speech or Debate in either House, they shall not be + questioned in any other Place. + + Clause 2: No Senator or Representative shall, during the Time for + which he was elected, be appointed to any civil Office under the + Authority of the United States, which shall have been created, or the + Emoluments whereof shall have been encreased during such time; and no + Person holding any Office under the United States, shall be a Member + of either House during his Continuance in Office. + + Section. 7. + + Clause 1: All Bills for raising Revenue shall originate in the House + of Representatives; but the Senate may propose or concur with + Amendments as on other Bills. + + Clause 2: Every Bill which shall have passed the House of + Representatives and the Senate, shall, before it become a Law, be + presented to the President of the United States; If he approve he + shall sign it, but if not he shall return it, with his Objections to + that House in which it shall have originated, who shall enter the + Objections at large on their Journal, and proceed to reconsider it. If + after such Reconsideration two thirds of that House shall agree to + pass the Bill, it shall be sent, together with the Objections, to the + other House, by which it shall likewise be reconsidered, and if + approved by two thirds of that House, it shall become a Law. But in + all such Cases the Votes of both Houses shall be determined by yeas + and Nays, and the Names of the Persons voting for and against the Bill + shall be entered on the Journal of each House respectively. If any + Bill shall not be returned by the President within ten Days (Sundays + excepted) after it shall have been presented to him, the Same shall be + a Law, in like Manner as if he had signed it, unless the Congress by + their Adjournment prevent its Return, in which Case it shall not be a + Law. + + Clause 3: Every Order, Resolution, or Vote to which the Concurrence of + the Senate and House of Representatives may be necessary (except on a + question of Adjournment) shall be presented to the President of the + United States; and before the Same shall take Effect, shall be + approved by him, or being disapproved by him, shall be repassed by two + thirds of the Senate and House of Representatives, according to the + Rules and Limitations prescribed in the Case of a Bill. + + Section. 8. + + Clause 1: The Congress shall have Power To lay and collect Taxes, + Duties, Imposts and Excises, to pay the Debts and provide for the + common Defence and general Welfare of the United States; but all + Duties, Imposts and Excises shall be uniform throughout the United + States; + + Clause 2: To borrow Money on the credit of the United States; + + Clause 3: To regulate Commerce with foreign Nations, and among the + several States, and with the Indian Tribes; + + Clause 4: To establish an uniform Rule of Naturalization, and uniform + Laws on the subject of Bankruptcies throughout the United States; + + Clause 5: To coin Money, regulate the Value thereof, and of foreign + Coin, and fix the Standard of Weights and Measures; + + Clause 6: To provide for the Punishment of counterfeiting the + Securities and current Coin of the United States; + + Clause 7: To establish Post Offices and post Roads; + + Clause 8: To promote the Progress of Science and useful Arts, by + securing for limited Times to Authors and Inventors the exclusive + Right to their respective Writings and Discoveries; + + Clause 9: To constitute Tribunals inferior to the supreme Court; + + Clause 10: To define and punish Piracies and Felonies committed on the + high Seas, and Offences against the Law of Nations; + + Clause 11: To declare War, grant Letters of Marque and Reprisal, and + make Rules concerning Captures on Land and Water; + + Clause 12: To raise and support Armies, but no Appropriation of Money + to that Use shall be for a longer Term than two Years; + + Clause 13: To provide and maintain a Navy; + + Clause 14: To make Rules for the Government and Regulation of the land + and naval Forces; + + Clause 15: To provide for calling forth the Militia to execute the + Laws of the Union, suppress Insurrections and repel Invasions; + + Clause 16: To provide for organizing, arming, and disciplining, the + Militia, and for governing such Part of them as may be employed in the + Service of the United States, reserving to the States respectively, + the Appointment of the Officers, and the Authority of training the + Militia according to the discipline prescribed by Congress; + + Clause 17: To exercise exclusive Legislation in all Cases whatsoever, + over such District (not exceeding ten Miles square) as may, byCession + of particular States, and the Acceptance of Congress, become the Seat + of the Government of the United States, and to exercise like Authority + over all Places purchased by the Consent of the Legislature of the + State in which the Same shall be, for the Erection of Forts, + Magazines, Arsenals, dock-Yards, and other needful Buildings;--And + + Clause 18: To make all Laws which shall be necessary and proper for + carrying into Execution the foregoing Powers, and all other Powers + vested by this Constitution in the Government of the United States, or + in any Department or Officer thereof. + + Section. 9. + + Clause 1: The Migration or Importation of such Persons as any of the + States now existing shall think proper to admit, shall not be + prohibited by the Congress prior to the Year one thousand eight + hundred and eight, but a Tax or duty may be imposed on such + Importation, not exceeding ten dollars for each Person. + + Clause 2: The Privilege of the Writ of Habeas Corpus shall not be + suspended, unless when in Cases of Rebellion or Invasion the public + Safety may require it. + + Clause 3: No Bill of Attainder or ex post facto Law shall be passed. + + Clause 4: No Capitation, or other direct, Tax shall be laid, unless in + Proportion to the Census or Enumeration herein before directed to be + taken. (See Note 7) + + Clause 5: No Tax or Duty shall be laid on Articles exported from any + State. + + Clause 6: No Preference shall be given by any Regulation of Commerce + or Revenue to the Ports of one State over those of another: nor shall + Vessels bound to, or from, one State, be obliged to enter, clear, or + pay Duties in another. + + Clause 7: No Money shall be drawn from the Treasury, but in + Consequence of Appropriations made by Law; and a regular Statement and + Account of the Receipts and Expenditures of all public Money shall be + published from time to time. + + Clause 8: No Title of Nobility shall be granted by the United States: + And no Person holding any Office of Profit or Trust under them, shall, + without the Consent of the Congress, accept of any present, Emolument, + Office, or Title, of any kind whatever, from any King, Prince, or + foreign State. + + Section. 10. + + Clause 1: No State shall enter into any Treaty, Alliance, or + Confederation; grant Letters of Marque and Reprisal; coin Money; emit + Bills of Credit; make any Thing but gold and silver Coin a Tender in + Payment of Debts; pass any Bill of Attainder, ex post facto Law, or + Law impairing the Obligation of Contracts, or grant any Title of + Nobility. + + Clause 2: No State shall, without the Consent of the Congress, lay any + Imposts or Duties on Imports or Exports, except what may be absolutely + necessary for executing it's inspection Laws: and the net Produce of + all Duties and Imposts, laid by any State on Imports or Exports, shall + be for the Use of the Treasury of the United States; and all such Laws + shall be subject to the Revision and Controul of the Congress. + + Clause 3: No State shall, without the Consent of Congress, lay any + Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter + into any Agreement or Compact with another State, or with a foreign + Power, or engage in War, unless actually invaded, or in such imminent + Danger as will not admit of delay. + +Article. II. + + Section. 1. + + Clause 1: The executive Power shall be vested in a President of the + United States of America. He shall hold his Office during the Term of + four Years, and, together with the Vice President, chosen for the same + Term, be elected, as follows + + Clause 2: Each State shall appoint, in such Manner as the Legislature + thereof may direct, a Number of Electors, equal to the whole Number of + Senators and Representatives to which the State may be entitled in the + Congress: but no Senator or Representative, or Person holding an + Office of Trust or Profit under the United States, shall be appointed + an Elector. + + Clause 3: The Electors shall meet in their respective States, and vote + by Ballot for two Persons, of whom one at least shall not be an + Inhabitant of the same State with themselves. And they shall make a + List of all the Persons voted for, and of the Number of Votes for + each; which List they shall sign and certify, and transmit sealed to + the Seat of the Government of the United States, directed to the + President of the Senate. The President of the Senate shall, in the + Presence of the Senate and House of Representatives, open all the + Certificates, and the Votes shall then be counted. The Person having + the greatest Number of Votes shall be the President, if such Number be + a Majority of the whole Number of Electors appointed; and if there be + more than one who have such Majority, and have an equal Number of + Votes, then the House of Representatives shall immediately chuse by + Ballot one of them for President; and if no Person have a Majority, + then from the five highest on the List the said House shall in like + Manner chuse the President. But in chusing the President, the Votes + shall be taken by States, the Representation from each State having + one Vote; A quorum for this Purpose shall consist of a Member or + Members from two thirds of the States, and a Majority of all the + States shall be necessary to a Choice. In every Case, after the Choice + of the President, the Person having the greatest Number of Votes of + the Electors shall be the Vice President. But if there should remain + two or more who have equal Votes, the Senate shall chuse from them by + Ballot the Vice President. (See Note 8) + + Clause 4: The Congress may determine the Time of chusing the Electors, + and the Day on which they shall give their Votes; which Day shall be + the same throughout the United States. + + Clause 5: No Person except a natural born Citizen, or a Citizen of the + United States, at the time of the Adoption of this Constitution, shall + be eligible to the Office of President; neither shall any Person be + eligible to that Office who shall not have attained to the Age of + thirty five Years, and been fourteen Years a Resident within the + United States. + + Clause 6: In Case of the Removal of the President from Office, or of + his Death, Resignation, or Inability to discharge the Powers and + Duties of the said Office, (See Note 9) the Same shall devolve on the + VicePresident, and the Congress may by Law provide for the Case of + Removal, Death, Resignation or Inability, both of the President and + Vice President, declaring what Officer shall then act as President, + and such Officer shall act accordingly, until the Disability be + removed, or a President shall be elected. + + Clause 7: The President shall, at stated Times, receive for his + Services, a Compensation, which shall neither be encreased nor + diminished during the Period for which he shall have been elected, and + he shall not receive within that Period any other Emolument from the + United States, or any of them. + + Clause 8: Before he enter on the Execution of his Office, he shall + take the following Oath or Affirmation:--"I do solemnly swear (or + affirm) that I will faithfully execute the Office of President of the + United States, and will to the best of my Ability, preserve, protect + and defend the Constitution of the United States." + + Section. 2. + + Clause 1: The President shall be Commander in Chief of the Army and + Navy of the United States, and of the Militia of the several States, + when called into the actual Service of the United States; he may + require the Opinion, in writing, of the principal Officer in each of + the executive Departments, upon any Subject relating to the Duties of + their respective Offices, and he shall have Power to grant Reprieves + and Pardons for Offences against the United States, except in Cases of + Impeachment. + + Clause 2: He shall have Power, by and with the Advice and Consent of + the Senate, to make Treaties, provided two thirds of the Senators + present concur; and he shall nominate, and by and with the Advice and + Consent of the Senate, shall appoint Ambassadors, other public + Ministers and Consuls, Judges of the supreme Court, and all other + Officers of the United States, whose Appointments are not herein + otherwise provided for, and which shall be established by Law: but the + Congress may by Law vest the Appointment of such inferior Officers, as + they think proper, in the President alone, in the Courts of Law, or in + the Heads of Departments. + + Clause 3: The President shall have Power to fill up all Vacancies that + may happen during the Recess of the Senate, by granting Commissions + which shall expire at the End of their next Session. + + Section. 3. + + He shall from time to time give to the Congress Information of the + State of the Union, and recommend to their Consideration such Measures + as he shall judge necessary and expedient; he may, on extraordinary + Occasions, convene both Houses, or either of them, and in Case of + Disagreement between them, with Respect to the Time of Adjournment, he + may adjourn them to such Time as he shall think proper; he shall + receive Ambassadors and other public Ministers; he shall take Care + that the Laws be faithfully executed, and shall Commission all the + Officers of the United States. + + Section. 4. + + The President, Vice President and all civil Officers of the United + States, shall be removed from Office on Impeachment for, and + Conviction of, Treason, Bribery, or other high Crimes and + Misdemeanors. + +Article. III. + + Section. 1. + + The judicial Power of the United States, shall be vested in one + supreme Court, and in such inferior Courts as the Congress may from + time to time ordain and establish. The Judges, both of the supreme and + inferior Courts, shall hold their Offices during good Behaviour, and + shall, at stated Times, receive for their Services, a Compensation, + which shall not be diminished during their Continuance in Office. + + Section. 2. + + Clause 1: The judicial Power shall extend to all Cases, in Law and + Equity, arising under this Constitution, the Laws of the United + States, and Treaties made, or which shall be made, under their + Authority;--to all Cases affecting Ambassadors, other public Ministers + and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to + Controversies to which the United States shall be a Party;--to + Controversies between two or more States;--between a State and + Citizens of another State; (See Note 10)--between Citizens of + different States, --between Citizens of the same State claiming Lands + under Grants of different States, and between a State, or the Citizens + thereof, and foreign States, Citizens or Subjects. + + Clause 2: In all Cases affecting Ambassadors, other public Ministers + and Consuls, and those in which a State shall be Party, the supreme + Court shall have original Jurisdiction. In all the other Cases before + mentioned, the supreme Court shall have appellate Jurisdiction, both + as to Law and Fact, with such Exceptions, and under such Regulations + as the Congress shall make. + + Clause 3: The Trial of all Crimes, except in Cases of Impeachment, + shall be by Jury; and such Trial shall be held in the State where the + said Crimes shall have been committed; but when not committed within + any State, the Trial shall be at such Place or Places as the Congress + may by Law have directed. + + Section. 3. + + Clause 1: Treason against the United States, shall consist only in + levying War against them, or in adhering to their Enemies, giving them + Aid and Comfort. No Person shall be convicted of Treason unless on the + Testimony of two Witnesses to the same overt Act, or on Confession in + open Court. + + Clause 2: The Congress shall have Power to declare the Punishment of + Treason, but no Attainder of Treason shall work Corruption of Blood, + or Forfeiture except during the Life of the Person attainted. + +Article. IV. + + Section. 1. + + Full Faith and Credit shall be given in each State to the public Acts, + Records, and judicial Proceedings of every other State. And the + Congress may by general Laws prescribe the Manner in which such Acts, + Records and Proceedings shall be proved, and the Effect thereof. + + Section. 2. + + Clause 1: The Citizens of each State shall be entitled to all + Privileges and Immunities of Citizens in the several States. + + Clause 2: A Person charged in any State with Treason, Felony, or other + Crime, who shall flee from Justice, and be found in another State, + shall on Demand of the executive Authority of the State from which he + fled, be delivered up, to be removed to the State having Jurisdiction + of the Crime. + + Clause 3: No Person held to Service or Labour in one State, under the + Laws thereof, escaping into another, shall, in Consequence of any Law + or Regulation therein, be discharged from such Service or Labour, but + shall be delivered up on Claim of the Party to whom such Service or + Labour may be due. (See Note 11) + + Section. 3. + + Clause 1: New States may be admitted by the Congress into this Union; + but no new State shall be formed or erected within the Jurisdiction of + any other State; nor any State be formed by the Junction of two or + more States, or Parts of States, without the Consent of the + Legislatures of the States concerned as well as of the Congress. + + Clause 2: The Congress shall have Power to dispose of and make all + needful Rules and Regulations respecting the Territory or other + Property belonging to the United States; and nothing in this + Constitution shall be so construed as to Prejudice any Claims of the + United States, or of any particular State. + + Section. 4. + + The United States shall guarantee to every State in this Union a + Republican Form of Government, and shall protect each of them against + Invasion; and on Application of the Legislature, or of the Executive + (when the Legislature cannot be convened) against domestic Violence. + +Article. V. + + The Congress, whenever two thirds of both Houses shall deem it + necessary, shall propose [1]Amendments to this Constitution, or, on + the Application of the Legislatures of two thirds of the several + States, shall call a Convention for proposing Amendments, which, in + either Case, shall be valid to all Intents and Purposes, as Part of + this Constitution, when ratified by the Legislatures of three fourths + of the several States, or by Conventions in three fourths thereof, as + the one or the other Mode of Ratification may be proposed by the + Congress; Provided that no Amendment which may be made prior to the + Year One thousand eight hundred and eight shall in any Manner affect + the first and fourth Clauses in the Ninth Section of the first + Article; and that no State, without its Consent, shall be deprived of + its equal Suffrage in the Senate. + +Article. VI. + + Clause 1: All Debts contracted and Engagements entered into, before + the Adoption of this Constitution, shall be as valid against the + United States under this Constitution, as under the Confederation. + + Clause 2: This Constitution, and the Laws of the United States which + shall be made in Pursuance thereof; and all Treaties made, or which + shall be made, under the Authority of the United States, shall be the + supreme Law of the Land; and the Judges in every State shall be bound + thereby, any Thing in the Constitution or Laws of any State to the + Contrary notwithstanding. + + Clause 3: The Senators and Representatives before mentioned, and the + Members of the several State Legislatures, and all executive and + judicial Officers, both of the United States and of the several + States, shall be bound by Oath or Affirmation, to support this + Constitution; but no religious Test shall ever be required as a + Qualification to any Office or public Trust under the United States. + +Article. VII. + + The Ratification of the Conventions of nine States, shall be + sufficient for the Establishment of this Constitution between the + States so ratifying the Same. + + done in Convention by the Unanimous Consent of the States present the + Seventeenth Day of September in the Year of our Lord one thousand + seven hundred and Eighty seven and of the Independence of the United + States of America the Twelfth In witness whereof We have hereunto + subscribed our Names, + + GO WASHINGTON--Presidt. and deputy from Virginia + + [Signed also by the deputies of twelve States.] + + Delaware + + Geo: Read + Gunning Bedford jun + John Dickinson + Richard Bassett + Jaco: Broom + + Maryland + + James MCHenry + Dan of ST ThoS. Jenifer + DanL Carroll. + + Virginia + + John Blair-- + James Madison Jr. + + North Carolina + + WM Blount + RichD. Dobbs Spaight. + Hu Williamson + + South Carolina + + J. Rutledge + Charles 1ACotesworth Pinckney + Charles Pinckney + Pierce Butler. + + Georgia + + William Few + Abr Baldwin + + New Hampshire + + John Langdon + Nicholas Gilman + + Massachusetts + + Nathaniel Gorham + Rufus King + + Connecticut + WM. SamL. Johnson + Roger Sherman + + New York + + Alexander Hamilton + + New Jersey + + Wil: Livingston + David Brearley. + WM. Paterson. + Jona: Dayton + + Pennsylvania + + B Franklin + Thomas Mifflin + RobT Morris + Geo. Clymer + ThoS. FitzSimons + Jared Ingersoll + James Wilson. + Gouv Morris + + Attest William Jackson Secretary + + NOTES + + Note 1: This text of the Constitution follows the engrossed copy + signed by Gen. Washington and the deputies from 12 States. The small + superior figures preceding the paragraphs designate Clauses, and were + not in the original and have no reference to footnotes. + + The Constitution was adopted by a convention of the States on + September 17, 1787, and was subsequently ratified by the several + States, on the following dates: Delaware, December 7, 1787; + Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; + Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, + February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, + 1788; New Hampshire, June 21, 1788. + + Ratification was completed on June 21, 1788. + + The Constitution was subsequently ratified by Virginia, June 25, 1788; + New York, July 26, 1788; North Carolina, November 21, 1789; Rhode + Island, May 29, 1790; and Vermont, January 10, 1791. + + In May 1785, a committee of Congress made a report recommending an + alteration in the Articles of Confederation, but no action was taken + on it, and it was left to the State Legislatures to proceed in the + matter. In January 1786, the Legislature of Virginia passed a + resolution providing for the appointment of five commissioners, who, + or any three of them, should meet such commissioners as might be + appointed in the other States of the Union, at a time and place to be + agreed upon, to take into consideration the trade of the United + States; to consider how far a uniform system in their commercial + regulations may be necessary to their common interest and their + permanent harmony; and to report to the several States such an act, + relative to this great object, as, when ratified by them, will enable + the United States in Congress effectually to provide for the same. The + Virginia commissioners, after some correspondence, fixed the first + Monday in September as the time, and the city of Annapolis as the + place for the meeting, but only four other States were represented, + viz: Delaware, New York, New Jersey, and Pennsylvania; the + commissioners appointed by Massachusetts, New Hampshire, North + Carolina, and Rhode Island failed to attend. Under the circumstances + of so partial a representation, the commissioners present agreed upon + a report, (drawn by Mr. Hamilton, of New York,) expressing their + unanimous conviction that it might essentially tend to advance the + interests of the Union if the States by which they were respectively + delegated would concur, and use their endeavors to procure the + concurrence of the other States, in the appointment of commissioners + to meet at Philadelphia on the Second Monday of May following, to take + into consideration the situation of the United States; to devise such + further provisions as should appear to them necessary to render the + Constitution of the Federal Government adequate to the exigencies of + the Union; and to report such an act for that purpose to the United + States in Congress assembled as, when agreed to by them and afterwards + confirmed by the Legislatures of every State, would effectually + provide for the same. + + Congress, on the 21st of February, 1787, adopted a resolution in favor + of a convention, and the Legislatures of those States which had not + already done so (with the exception of Rhode Island) promptly + appointed delegates. On the 25th of May, seven States having convened, + George Washington, of Virginia, was unanimously elected President, and + the consideration of the proposed constitution was commenced. On the + 17th of September, 1787, the Constitution as engrossed and agreed upon + was signed by all the members present, except Mr. Gerry of + Massachusetts, and Messrs. Mason and Randolph, of Virginia. The + president of the convention transmitted it to Congress, with a + resolution stating how the proposed Federal Government should be put + in operation, and an explanatory letter. Congress, on the 28th of + September, 1787, directed the Constitution so framed, with the + resolutions and letter concerning the same, to "be transmitted to the + several Legislatures in order to be submitted to a convention of + delegates chosen in each State by the people thereof, in conformity to + the resolves of the convention." + + On the 4th of March, 1789, the day which had been fixed for commencing + the operations of Government under the new Constitution, it had been + ratified by the conventions chosen in each State to consider it, as + follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; + New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, + January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, + 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; + Virginia, June 25, 1788; and New York, July 26, 1788. + + The President informed Congress, on the 28th of January, 1790, that + North Carolina had ratified the Constitution November 21, 1789; and he + informed Congress on the 1st of June, 1790, that Rhode Island had + ratified the Constitution May 29, 1790. Vermont, in convention, + ratified the Constitution January 10, 1791, and was, by an act of + Congress approved February 18, 1791, "received and admitted into this + Union as a new and entire member of the United States." + + Note 2: The part of this Clause relating to the mode of apportionment + of representatives among the several States has been affected by + Section 2 of amendment XIV, and as to taxes on incomes without + apportionment by amendment XVI. + + Note 3: This Clause has been affected by Clause 1 of amendment XVII. + + Note 4: This Clause has been affected by Clause 2 of amendment XVIII. + + Note 5: This Clause has been affected by amendment XX. + + Note 6: This Clause has been affected by amendment XXVII. + + Note 7: This Clause has been affected by amendment XVI. + + Note 8: This Clause has been superseded by amendment XII. + + Note 9: This Clause has been affected by amendment XXV. + + Note 10: This Clause has been affected by amendment XI. + + Note 11: This Clause has been affected by amendment XIII. + + Note 12: The first ten amendments to the Constitution of the United + States (and two others, one of which failed of ratification and the + other which later became the 27th amendment) were proposed to the + legislatures of the several States by the First Congress on September + 25, 1789. The first ten amendments were ratified by the following + States, and the notifications of ratification by the Governors thereof + were successively communicated by the President to Congress: New + Jersey, November 20, 1789; Maryland, December 19, 1789; North + Carolina, December 22, 1789; South Carolina, January 19, 1790; New + Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, + February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, + 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. + + Ratification was completed on December 15, 1791. + + The amendments were subsequently ratified by the legislatures of + Massachusetts, March 2, 1939; Georgia, March 18, 1939; and + Connecticut, April 19, 1939. + + Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had + numbers assigned to them at the time of ratification. + + Note 14: This sentence has been superseded by section 3 of amendment + XX. + + Note 15: See amendment XIX and section 1 of amendment XXVI. + + Note 16: Repealed by section 1 of amendment XXI. + +References + + 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/yyextra_c99.txt b/tests/yyextra_c99.txt deleted file mode 100644 index 243df29..0000000 --- a/tests/yyextra_c99.txt +++ /dev/null @@ -1,795 +0,0 @@ - - THE UNITED STATES CONSTITUTION - _________________________________________________________________ - - (See Note 1) - - We the People of the United States, in Order to form a more perfect - Union, establish Justice, insure domestic Tranquility, provide for the - common defence, promote the general Welfare, and secure the Blessings - of Liberty to ourselves and our Posterity, do ordain and establish - this Constitution for the United States of America. - -Article. I. - - Section 1. - - All legislative Powers herein granted shall be vested in a Congress of - the United States, which shall consist of a Senate and House of - Representatives. - - Section. 2. - - Clause 1: The House of Representatives shall be composed of Members - chosen every second Year by the People of the several States, and the - Electors in each State shall have the Qualifications requisite for - Electors of the most numerous Branch of the State Legislature. - - Clause 2: No Person shall be a Representative who shall not have - attained to the Age of twenty five Years, and been seven Years a - Citizen of the United States, and who shall not, when elected, be an - Inhabitant of that State in which he shall be chosen. - - Clause 3: Representatives and direct Taxes shall be apportioned among - the several States which may be included within this Union, according - to their respective Numbers, which shall be determined by adding to - the whole Number of free Persons, including those bound to Service for - a Term of Years, and excluding Indians not taxed, three fifths of all - other Persons. (See Note 2) The actual Enumeration shall be made - within three Years after the first Meeting of the Congress of the - United States, and within every subsequent Term of ten Years, in such - Manner as they shall by Law direct. The Number of Representatives - shall not exceed one for every thirty Thousand, but each State shall - have at Least one Representative; and until such enumeration shall be - made, the State of New Hampshire shall be entitled to chuse three, - Massachusetts eight, Rhode-Island and Providence Plantations one, - Connecticut five, New-York six, New Jersey four, Pennsylvania eight, - Delaware one, Maryland six, Virginia ten, North Carolina five, South - Carolina five, and Georgia three. - - Clause 4: When vacancies happen in the Representation from any State, - the Executive Authority thereof shall issue Writs of Election to fill - such Vacancies. - - Clause 5: The House of Representatives shall chuse their Speaker and - other Officers; and shall have the sole Power of Impeachment. - - Section. 3. - - Clause 1: The Senate of the United States shall be composed of two - Senators from each State, chosen by the Legislature thereof, (See Note - 3) for six Years; and each Senator shall have one Vote. - - Clause 2: Immediately after they shall be assembled in Consequence of - the first Election, they shall be divided as equally as may be into - three Classes. The Seats of the Senators of the first Class shall be - vacated at the Expiration of the second Year, of the second Class at - the Expiration of the fourth Year, and of the third Class at the - Expiration of the sixth Year, so that one third may be chosen every - second Year; and if Vacancies happen by Resignation, or otherwise, - during the Recess of the Legislature of any State, the Executive - thereof may make temporary Appointments until the next Meeting of the - Legislature, which shall then fill such Vacancies. (See Note 4) - - Clause 3: No Person shall be a Senator who shall not have attained to - the Age of thirty Years, and been nine Years a Citizen of the United - States, and who shall not, when elected, be an Inhabitant of that - State for which he shall be chosen. - - Clause 4: The Vice President of the United States shall be President - of the Senate, but shall have no Vote, unless they be equally divided. - - Clause 5: The Senate shall chuse their other Officers, and also a - President pro tempore, in the Absence of the Vice President, or when - he shall exercise the Office of President of the United States. - - Clause 6: The Senate shall have the sole Power to try all - Impeachments. When sitting for that Purpose, they shall be on Oath or - Affirmation. When the President of the United States is tried, the - Chief Justice shall preside: And no Person shall be convicted without - the Concurrence of two thirds of the Members present. - - Clause 7: Judgment in Cases of Impeachment shall not extend further - than to removal from Office, and disqualification to hold and enjoy - any Office of honor, Trust or Profit under the United States: but the - Party convicted shall nevertheless be liable and subject to - Indictment, Trial, Judgment and Punishment, according to Law. - - Section. 4. - - Clause 1: The Times, Places and Manner of holding Elections for - Senators and Representatives, shall be prescribed in each State by the - Legislature thereof; but the Congress may at any time by Law make or - alter such Regulations, except as to the Places of chusing Senators. - - Clause 2: The Congress shall assemble at least once in every Year, and - such Meeting shall be on the first Monday in December, (See Note 5) - unless they shall by Law appoint a different Day. - - Section. 5. - - Clause 1: Each House shall be the Judge of the Elections, Returns and - Qualifications of its own Members, and a Majority of each shall - constitute a Quorum to do Business; but a smaller Number may adjourn - from day to day, and may be authorized to compel the Attendance of - absent Members, in such Manner, and under such Penalties as each House - may provide. - - Clause 2: Each House may determine the Rules of its Proceedings, - punish its Members for disorderly Behaviour, and, with the Concurrence - of two thirds, expel a Member. - - Clause 3: Each House shall keep a Journal of its Proceedings, and from - time to time publish the same, excepting such Parts as may in their - Judgment require Secrecy; and the Yeas and Nays of the Members of - either House on any question shall, at the Desire of one fifth of - those Present, be entered on the Journal. - - Clause 4: Neither House, during the Session of Congress, shall, - without the Consent of the other, adjourn for more than three days, - nor to any other Place than that in which the two Houses shall be - sitting. - - Section. 6. - - Clause 1: The Senators and Representatives shall receive a - Compensation for their Services, to be ascertained by Law, and paid - out of the Treasury of the United States. (See Note 6) They shall in - all Cases, except Treason, Felony and Breach of the Peace, - beprivileged from Arrest during their Attendance at the Session of - their respective Houses, and in going to and returning from the same; - and for any Speech or Debate in either House, they shall not be - questioned in any other Place. - - Clause 2: No Senator or Representative shall, during the Time for - which he was elected, be appointed to any civil Office under the - Authority of the United States, which shall have been created, or the - Emoluments whereof shall have been encreased during such time; and no - Person holding any Office under the United States, shall be a Member - of either House during his Continuance in Office. - - Section. 7. - - Clause 1: All Bills for raising Revenue shall originate in the House - of Representatives; but the Senate may propose or concur with - Amendments as on other Bills. - - Clause 2: Every Bill which shall have passed the House of - Representatives and the Senate, shall, before it become a Law, be - presented to the President of the United States; If he approve he - shall sign it, but if not he shall return it, with his Objections to - that House in which it shall have originated, who shall enter the - Objections at large on their Journal, and proceed to reconsider it. If - after such Reconsideration two thirds of that House shall agree to - pass the Bill, it shall be sent, together with the Objections, to the - other House, by which it shall likewise be reconsidered, and if - approved by two thirds of that House, it shall become a Law. But in - all such Cases the Votes of both Houses shall be determined by yeas - and Nays, and the Names of the Persons voting for and against the Bill - shall be entered on the Journal of each House respectively. If any - Bill shall not be returned by the President within ten Days (Sundays - excepted) after it shall have been presented to him, the Same shall be - a Law, in like Manner as if he had signed it, unless the Congress by - their Adjournment prevent its Return, in which Case it shall not be a - Law. - - Clause 3: Every Order, Resolution, or Vote to which the Concurrence of - the Senate and House of Representatives may be necessary (except on a - question of Adjournment) shall be presented to the President of the - United States; and before the Same shall take Effect, shall be - approved by him, or being disapproved by him, shall be repassed by two - thirds of the Senate and House of Representatives, according to the - Rules and Limitations prescribed in the Case of a Bill. - - Section. 8. - - Clause 1: The Congress shall have Power To lay and collect Taxes, - Duties, Imposts and Excises, to pay the Debts and provide for the - common Defence and general Welfare of the United States; but all - Duties, Imposts and Excises shall be uniform throughout the United - States; - - Clause 2: To borrow Money on the credit of the United States; - - Clause 3: To regulate Commerce with foreign Nations, and among the - several States, and with the Indian Tribes; - - Clause 4: To establish an uniform Rule of Naturalization, and uniform - Laws on the subject of Bankruptcies throughout the United States; - - Clause 5: To coin Money, regulate the Value thereof, and of foreign - Coin, and fix the Standard of Weights and Measures; - - Clause 6: To provide for the Punishment of counterfeiting the - Securities and current Coin of the United States; - - Clause 7: To establish Post Offices and post Roads; - - Clause 8: To promote the Progress of Science and useful Arts, by - securing for limited Times to Authors and Inventors the exclusive - Right to their respective Writings and Discoveries; - - Clause 9: To constitute Tribunals inferior to the supreme Court; - - Clause 10: To define and punish Piracies and Felonies committed on the - high Seas, and Offences against the Law of Nations; - - Clause 11: To declare War, grant Letters of Marque and Reprisal, and - make Rules concerning Captures on Land and Water; - - Clause 12: To raise and support Armies, but no Appropriation of Money - to that Use shall be for a longer Term than two Years; - - Clause 13: To provide and maintain a Navy; - - Clause 14: To make Rules for the Government and Regulation of the land - and naval Forces; - - Clause 15: To provide for calling forth the Militia to execute the - Laws of the Union, suppress Insurrections and repel Invasions; - - Clause 16: To provide for organizing, arming, and disciplining, the - Militia, and for governing such Part of them as may be employed in the - Service of the United States, reserving to the States respectively, - the Appointment of the Officers, and the Authority of training the - Militia according to the discipline prescribed by Congress; - - Clause 17: To exercise exclusive Legislation in all Cases whatsoever, - over such District (not exceeding ten Miles square) as may, byCession - of particular States, and the Acceptance of Congress, become the Seat - of the Government of the United States, and to exercise like Authority - over all Places purchased by the Consent of the Legislature of the - State in which the Same shall be, for the Erection of Forts, - Magazines, Arsenals, dock-Yards, and other needful Buildings;--And - - Clause 18: To make all Laws which shall be necessary and proper for - carrying into Execution the foregoing Powers, and all other Powers - vested by this Constitution in the Government of the United States, or - in any Department or Officer thereof. - - Section. 9. - - Clause 1: The Migration or Importation of such Persons as any of the - States now existing shall think proper to admit, shall not be - prohibited by the Congress prior to the Year one thousand eight - hundred and eight, but a Tax or duty may be imposed on such - Importation, not exceeding ten dollars for each Person. - - Clause 2: The Privilege of the Writ of Habeas Corpus shall not be - suspended, unless when in Cases of Rebellion or Invasion the public - Safety may require it. - - Clause 3: No Bill of Attainder or ex post facto Law shall be passed. - - Clause 4: No Capitation, or other direct, Tax shall be laid, unless in - Proportion to the Census or Enumeration herein before directed to be - taken. (See Note 7) - - Clause 5: No Tax or Duty shall be laid on Articles exported from any - State. - - Clause 6: No Preference shall be given by any Regulation of Commerce - or Revenue to the Ports of one State over those of another: nor shall - Vessels bound to, or from, one State, be obliged to enter, clear, or - pay Duties in another. - - Clause 7: No Money shall be drawn from the Treasury, but in - Consequence of Appropriations made by Law; and a regular Statement and - Account of the Receipts and Expenditures of all public Money shall be - published from time to time. - - Clause 8: No Title of Nobility shall be granted by the United States: - And no Person holding any Office of Profit or Trust under them, shall, - without the Consent of the Congress, accept of any present, Emolument, - Office, or Title, of any kind whatever, from any King, Prince, or - foreign State. - - Section. 10. - - Clause 1: No State shall enter into any Treaty, Alliance, or - Confederation; grant Letters of Marque and Reprisal; coin Money; emit - Bills of Credit; make any Thing but gold and silver Coin a Tender in - Payment of Debts; pass any Bill of Attainder, ex post facto Law, or - Law impairing the Obligation of Contracts, or grant any Title of - Nobility. - - Clause 2: No State shall, without the Consent of the Congress, lay any - Imposts or Duties on Imports or Exports, except what may be absolutely - necessary for executing it's inspection Laws: and the net Produce of - all Duties and Imposts, laid by any State on Imports or Exports, shall - be for the Use of the Treasury of the United States; and all such Laws - shall be subject to the Revision and Controul of the Congress. - - Clause 3: No State shall, without the Consent of Congress, lay any - Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter - into any Agreement or Compact with another State, or with a foreign - Power, or engage in War, unless actually invaded, or in such imminent - Danger as will not admit of delay. - -Article. II. - - Section. 1. - - Clause 1: The executive Power shall be vested in a President of the - United States of America. He shall hold his Office during the Term of - four Years, and, together with the Vice President, chosen for the same - Term, be elected, as follows - - Clause 2: Each State shall appoint, in such Manner as the Legislature - thereof may direct, a Number of Electors, equal to the whole Number of - Senators and Representatives to which the State may be entitled in the - Congress: but no Senator or Representative, or Person holding an - Office of Trust or Profit under the United States, shall be appointed - an Elector. - - Clause 3: The Electors shall meet in their respective States, and vote - by Ballot for two Persons, of whom one at least shall not be an - Inhabitant of the same State with themselves. And they shall make a - List of all the Persons voted for, and of the Number of Votes for - each; which List they shall sign and certify, and transmit sealed to - the Seat of the Government of the United States, directed to the - President of the Senate. The President of the Senate shall, in the - Presence of the Senate and House of Representatives, open all the - Certificates, and the Votes shall then be counted. The Person having - the greatest Number of Votes shall be the President, if such Number be - a Majority of the whole Number of Electors appointed; and if there be - more than one who have such Majority, and have an equal Number of - Votes, then the House of Representatives shall immediately chuse by - Ballot one of them for President; and if no Person have a Majority, - then from the five highest on the List the said House shall in like - Manner chuse the President. But in chusing the President, the Votes - shall be taken by States, the Representation from each State having - one Vote; A quorum for this Purpose shall consist of a Member or - Members from two thirds of the States, and a Majority of all the - States shall be necessary to a Choice. In every Case, after the Choice - of the President, the Person having the greatest Number of Votes of - the Electors shall be the Vice President. But if there should remain - two or more who have equal Votes, the Senate shall chuse from them by - Ballot the Vice President. (See Note 8) - - Clause 4: The Congress may determine the Time of chusing the Electors, - and the Day on which they shall give their Votes; which Day shall be - the same throughout the United States. - - Clause 5: No Person except a natural born Citizen, or a Citizen of the - United States, at the time of the Adoption of this Constitution, shall - be eligible to the Office of President; neither shall any Person be - eligible to that Office who shall not have attained to the Age of - thirty five Years, and been fourteen Years a Resident within the - United States. - - Clause 6: In Case of the Removal of the President from Office, or of - his Death, Resignation, or Inability to discharge the Powers and - Duties of the said Office, (See Note 9) the Same shall devolve on the - VicePresident, and the Congress may by Law provide for the Case of - Removal, Death, Resignation or Inability, both of the President and - Vice President, declaring what Officer shall then act as President, - and such Officer shall act accordingly, until the Disability be - removed, or a President shall be elected. - - Clause 7: The President shall, at stated Times, receive for his - Services, a Compensation, which shall neither be encreased nor - diminished during the Period for which he shall have been elected, and - he shall not receive within that Period any other Emolument from the - United States, or any of them. - - Clause 8: Before he enter on the Execution of his Office, he shall - take the following Oath or Affirmation:--"I do solemnly swear (or - affirm) that I will faithfully execute the Office of President of the - United States, and will to the best of my Ability, preserve, protect - and defend the Constitution of the United States." - - Section. 2. - - Clause 1: The President shall be Commander in Chief of the Army and - Navy of the United States, and of the Militia of the several States, - when called into the actual Service of the United States; he may - require the Opinion, in writing, of the principal Officer in each of - the executive Departments, upon any Subject relating to the Duties of - their respective Offices, and he shall have Power to grant Reprieves - and Pardons for Offences against the United States, except in Cases of - Impeachment. - - Clause 2: He shall have Power, by and with the Advice and Consent of - the Senate, to make Treaties, provided two thirds of the Senators - present concur; and he shall nominate, and by and with the Advice and - Consent of the Senate, shall appoint Ambassadors, other public - Ministers and Consuls, Judges of the supreme Court, and all other - Officers of the United States, whose Appointments are not herein - otherwise provided for, and which shall be established by Law: but the - Congress may by Law vest the Appointment of such inferior Officers, as - they think proper, in the President alone, in the Courts of Law, or in - the Heads of Departments. - - Clause 3: The President shall have Power to fill up all Vacancies that - may happen during the Recess of the Senate, by granting Commissions - which shall expire at the End of their next Session. - - Section. 3. - - He shall from time to time give to the Congress Information of the - State of the Union, and recommend to their Consideration such Measures - as he shall judge necessary and expedient; he may, on extraordinary - Occasions, convene both Houses, or either of them, and in Case of - Disagreement between them, with Respect to the Time of Adjournment, he - may adjourn them to such Time as he shall think proper; he shall - receive Ambassadors and other public Ministers; he shall take Care - that the Laws be faithfully executed, and shall Commission all the - Officers of the United States. - - Section. 4. - - The President, Vice President and all civil Officers of the United - States, shall be removed from Office on Impeachment for, and - Conviction of, Treason, Bribery, or other high Crimes and - Misdemeanors. - -Article. III. - - Section. 1. - - The judicial Power of the United States, shall be vested in one - supreme Court, and in such inferior Courts as the Congress may from - time to time ordain and establish. The Judges, both of the supreme and - inferior Courts, shall hold their Offices during good Behaviour, and - shall, at stated Times, receive for their Services, a Compensation, - which shall not be diminished during their Continuance in Office. - - Section. 2. - - Clause 1: The judicial Power shall extend to all Cases, in Law and - Equity, arising under this Constitution, the Laws of the United - States, and Treaties made, or which shall be made, under their - Authority;--to all Cases affecting Ambassadors, other public Ministers - and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to - Controversies to which the United States shall be a Party;--to - Controversies between two or more States;--between a State and - Citizens of another State; (See Note 10)--between Citizens of - different States, --between Citizens of the same State claiming Lands - under Grants of different States, and between a State, or the Citizens - thereof, and foreign States, Citizens or Subjects. - - Clause 2: In all Cases affecting Ambassadors, other public Ministers - and Consuls, and those in which a State shall be Party, the supreme - Court shall have original Jurisdiction. In all the other Cases before - mentioned, the supreme Court shall have appellate Jurisdiction, both - as to Law and Fact, with such Exceptions, and under such Regulations - as the Congress shall make. - - Clause 3: The Trial of all Crimes, except in Cases of Impeachment, - shall be by Jury; and such Trial shall be held in the State where the - said Crimes shall have been committed; but when not committed within - any State, the Trial shall be at such Place or Places as the Congress - may by Law have directed. - - Section. 3. - - Clause 1: Treason against the United States, shall consist only in - levying War against them, or in adhering to their Enemies, giving them - Aid and Comfort. No Person shall be convicted of Treason unless on the - Testimony of two Witnesses to the same overt Act, or on Confession in - open Court. - - Clause 2: The Congress shall have Power to declare the Punishment of - Treason, but no Attainder of Treason shall work Corruption of Blood, - or Forfeiture except during the Life of the Person attainted. - -Article. IV. - - Section. 1. - - Full Faith and Credit shall be given in each State to the public Acts, - Records, and judicial Proceedings of every other State. And the - Congress may by general Laws prescribe the Manner in which such Acts, - Records and Proceedings shall be proved, and the Effect thereof. - - Section. 2. - - Clause 1: The Citizens of each State shall be entitled to all - Privileges and Immunities of Citizens in the several States. - - Clause 2: A Person charged in any State with Treason, Felony, or other - Crime, who shall flee from Justice, and be found in another State, - shall on Demand of the executive Authority of the State from which he - fled, be delivered up, to be removed to the State having Jurisdiction - of the Crime. - - Clause 3: No Person held to Service or Labour in one State, under the - Laws thereof, escaping into another, shall, in Consequence of any Law - or Regulation therein, be discharged from such Service or Labour, but - shall be delivered up on Claim of the Party to whom such Service or - Labour may be due. (See Note 11) - - Section. 3. - - Clause 1: New States may be admitted by the Congress into this Union; - but no new State shall be formed or erected within the Jurisdiction of - any other State; nor any State be formed by the Junction of two or - more States, or Parts of States, without the Consent of the - Legislatures of the States concerned as well as of the Congress. - - Clause 2: The Congress shall have Power to dispose of and make all - needful Rules and Regulations respecting the Territory or other - Property belonging to the United States; and nothing in this - Constitution shall be so construed as to Prejudice any Claims of the - United States, or of any particular State. - - Section. 4. - - The United States shall guarantee to every State in this Union a - Republican Form of Government, and shall protect each of them against - Invasion; and on Application of the Legislature, or of the Executive - (when the Legislature cannot be convened) against domestic Violence. - -Article. V. - - The Congress, whenever two thirds of both Houses shall deem it - necessary, shall propose [1]Amendments to this Constitution, or, on - the Application of the Legislatures of two thirds of the several - States, shall call a Convention for proposing Amendments, which, in - either Case, shall be valid to all Intents and Purposes, as Part of - this Constitution, when ratified by the Legislatures of three fourths - of the several States, or by Conventions in three fourths thereof, as - the one or the other Mode of Ratification may be proposed by the - Congress; Provided that no Amendment which may be made prior to the - Year One thousand eight hundred and eight shall in any Manner affect - the first and fourth Clauses in the Ninth Section of the first - Article; and that no State, without its Consent, shall be deprived of - its equal Suffrage in the Senate. - -Article. VI. - - Clause 1: All Debts contracted and Engagements entered into, before - the Adoption of this Constitution, shall be as valid against the - United States under this Constitution, as under the Confederation. - - Clause 2: This Constitution, and the Laws of the United States which - shall be made in Pursuance thereof; and all Treaties made, or which - shall be made, under the Authority of the United States, shall be the - supreme Law of the Land; and the Judges in every State shall be bound - thereby, any Thing in the Constitution or Laws of any State to the - Contrary notwithstanding. - - Clause 3: The Senators and Representatives before mentioned, and the - Members of the several State Legislatures, and all executive and - judicial Officers, both of the United States and of the several - States, shall be bound by Oath or Affirmation, to support this - Constitution; but no religious Test shall ever be required as a - Qualification to any Office or public Trust under the United States. - -Article. VII. - - The Ratification of the Conventions of nine States, shall be - sufficient for the Establishment of this Constitution between the - States so ratifying the Same. - - done in Convention by the Unanimous Consent of the States present the - Seventeenth Day of September in the Year of our Lord one thousand - seven hundred and Eighty seven and of the Independence of the United - States of America the Twelfth In witness whereof We have hereunto - subscribed our Names, - - GO WASHINGTON--Presidt. and deputy from Virginia - - [Signed also by the deputies of twelve States.] - - Delaware - - Geo: Read - Gunning Bedford jun - John Dickinson - Richard Bassett - Jaco: Broom - - Maryland - - James MCHenry - Dan of ST ThoS. Jenifer - DanL Carroll. - - Virginia - - John Blair-- - James Madison Jr. - - North Carolina - - WM Blount - RichD. Dobbs Spaight. - Hu Williamson - - South Carolina - - J. Rutledge - Charles 1ACotesworth Pinckney - Charles Pinckney - Pierce Butler. - - Georgia - - William Few - Abr Baldwin - - New Hampshire - - John Langdon - Nicholas Gilman - - Massachusetts - - Nathaniel Gorham - Rufus King - - Connecticut - WM. SamL. Johnson - Roger Sherman - - New York - - Alexander Hamilton - - New Jersey - - Wil: Livingston - David Brearley. - WM. Paterson. - Jona: Dayton - - Pennsylvania - - B Franklin - Thomas Mifflin - RobT Morris - Geo. Clymer - ThoS. FitzSimons - Jared Ingersoll - James Wilson. - Gouv Morris - - Attest William Jackson Secretary - - NOTES - - Note 1: This text of the Constitution follows the engrossed copy - signed by Gen. Washington and the deputies from 12 States. The small - superior figures preceding the paragraphs designate Clauses, and were - not in the original and have no reference to footnotes. - - The Constitution was adopted by a convention of the States on - September 17, 1787, and was subsequently ratified by the several - States, on the following dates: Delaware, December 7, 1787; - Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; - Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, - February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, - 1788; New Hampshire, June 21, 1788. - - Ratification was completed on June 21, 1788. - - The Constitution was subsequently ratified by Virginia, June 25, 1788; - New York, July 26, 1788; North Carolina, November 21, 1789; Rhode - Island, May 29, 1790; and Vermont, January 10, 1791. - - In May 1785, a committee of Congress made a report recommending an - alteration in the Articles of Confederation, but no action was taken - on it, and it was left to the State Legislatures to proceed in the - matter. In January 1786, the Legislature of Virginia passed a - resolution providing for the appointment of five commissioners, who, - or any three of them, should meet such commissioners as might be - appointed in the other States of the Union, at a time and place to be - agreed upon, to take into consideration the trade of the United - States; to consider how far a uniform system in their commercial - regulations may be necessary to their common interest and their - permanent harmony; and to report to the several States such an act, - relative to this great object, as, when ratified by them, will enable - the United States in Congress effectually to provide for the same. The - Virginia commissioners, after some correspondence, fixed the first - Monday in September as the time, and the city of Annapolis as the - place for the meeting, but only four other States were represented, - viz: Delaware, New York, New Jersey, and Pennsylvania; the - commissioners appointed by Massachusetts, New Hampshire, North - Carolina, and Rhode Island failed to attend. Under the circumstances - of so partial a representation, the commissioners present agreed upon - a report, (drawn by Mr. Hamilton, of New York,) expressing their - unanimous conviction that it might essentially tend to advance the - interests of the Union if the States by which they were respectively - delegated would concur, and use their endeavors to procure the - concurrence of the other States, in the appointment of commissioners - to meet at Philadelphia on the Second Monday of May following, to take - into consideration the situation of the United States; to devise such - further provisions as should appear to them necessary to render the - Constitution of the Federal Government adequate to the exigencies of - the Union; and to report such an act for that purpose to the United - States in Congress assembled as, when agreed to by them and afterwards - confirmed by the Legislatures of every State, would effectually - provide for the same. - - Congress, on the 21st of February, 1787, adopted a resolution in favor - of a convention, and the Legislatures of those States which had not - already done so (with the exception of Rhode Island) promptly - appointed delegates. On the 25th of May, seven States having convened, - George Washington, of Virginia, was unanimously elected President, and - the consideration of the proposed constitution was commenced. On the - 17th of September, 1787, the Constitution as engrossed and agreed upon - was signed by all the members present, except Mr. Gerry of - Massachusetts, and Messrs. Mason and Randolph, of Virginia. The - president of the convention transmitted it to Congress, with a - resolution stating how the proposed Federal Government should be put - in operation, and an explanatory letter. Congress, on the 28th of - September, 1787, directed the Constitution so framed, with the - resolutions and letter concerning the same, to "be transmitted to the - several Legislatures in order to be submitted to a convention of - delegates chosen in each State by the people thereof, in conformity to - the resolves of the convention." - - On the 4th of March, 1789, the day which had been fixed for commencing - the operations of Government under the new Constitution, it had been - ratified by the conventions chosen in each State to consider it, as - follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; - New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, - January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, - 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; - Virginia, June 25, 1788; and New York, July 26, 1788. - - The President informed Congress, on the 28th of January, 1790, that - North Carolina had ratified the Constitution November 21, 1789; and he - informed Congress on the 1st of June, 1790, that Rhode Island had - ratified the Constitution May 29, 1790. Vermont, in convention, - ratified the Constitution January 10, 1791, and was, by an act of - Congress approved February 18, 1791, "received and admitted into this - Union as a new and entire member of the United States." - - Note 2: The part of this Clause relating to the mode of apportionment - of representatives among the several States has been affected by - Section 2 of amendment XIV, and as to taxes on incomes without - apportionment by amendment XVI. - - Note 3: This Clause has been affected by Clause 1 of amendment XVII. - - Note 4: This Clause has been affected by Clause 2 of amendment XVIII. - - Note 5: This Clause has been affected by amendment XX. - - Note 6: This Clause has been affected by amendment XXVII. - - Note 7: This Clause has been affected by amendment XVI. - - Note 8: This Clause has been superseded by amendment XII. - - Note 9: This Clause has been affected by amendment XXV. - - Note 10: This Clause has been affected by amendment XI. - - Note 11: This Clause has been affected by amendment XIII. - - Note 12: The first ten amendments to the Constitution of the United - States (and two others, one of which failed of ratification and the - other which later became the 27th amendment) were proposed to the - legislatures of the several States by the First Congress on September - 25, 1789. The first ten amendments were ratified by the following - States, and the notifications of ratification by the Governors thereof - were successively communicated by the President to Congress: New - Jersey, November 20, 1789; Maryland, December 19, 1789; North - Carolina, December 22, 1789; South Carolina, January 19, 1790; New - Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, - February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, - 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. - - Ratification was completed on December 15, 1791. - - The amendments were subsequently ratified by the legislatures of - Massachusetts, March 2, 1939; Georgia, March 18, 1939; and - Connecticut, April 19, 1939. - - Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had - numbers assigned to them at the time of ratification. - - Note 14: This sentence has been superseded by section 3 of amendment - XX. - - Note 15: See amendment XIX and section 1 of amendment XXVI. - - Note 16: Repealed by section 1 of amendment XXI. - -References - - 1. http://www.house.gov/Constitution/Amend.html diff --git a/tests/yyextra_cpp.txt b/tests/yyextra_cpp.txt deleted file mode 100644 index 243df29..0000000 --- a/tests/yyextra_cpp.txt +++ /dev/null @@ -1,795 +0,0 @@ - - THE UNITED STATES CONSTITUTION - _________________________________________________________________ - - (See Note 1) - - We the People of the United States, in Order to form a more perfect - Union, establish Justice, insure domestic Tranquility, provide for the - common defence, promote the general Welfare, and secure the Blessings - of Liberty to ourselves and our Posterity, do ordain and establish - this Constitution for the United States of America. - -Article. I. - - Section 1. - - All legislative Powers herein granted shall be vested in a Congress of - the United States, which shall consist of a Senate and House of - Representatives. - - Section. 2. - - Clause 1: The House of Representatives shall be composed of Members - chosen every second Year by the People of the several States, and the - Electors in each State shall have the Qualifications requisite for - Electors of the most numerous Branch of the State Legislature. - - Clause 2: No Person shall be a Representative who shall not have - attained to the Age of twenty five Years, and been seven Years a - Citizen of the United States, and who shall not, when elected, be an - Inhabitant of that State in which he shall be chosen. - - Clause 3: Representatives and direct Taxes shall be apportioned among - the several States which may be included within this Union, according - to their respective Numbers, which shall be determined by adding to - the whole Number of free Persons, including those bound to Service for - a Term of Years, and excluding Indians not taxed, three fifths of all - other Persons. (See Note 2) The actual Enumeration shall be made - within three Years after the first Meeting of the Congress of the - United States, and within every subsequent Term of ten Years, in such - Manner as they shall by Law direct. The Number of Representatives - shall not exceed one for every thirty Thousand, but each State shall - have at Least one Representative; and until such enumeration shall be - made, the State of New Hampshire shall be entitled to chuse three, - Massachusetts eight, Rhode-Island and Providence Plantations one, - Connecticut five, New-York six, New Jersey four, Pennsylvania eight, - Delaware one, Maryland six, Virginia ten, North Carolina five, South - Carolina five, and Georgia three. - - Clause 4: When vacancies happen in the Representation from any State, - the Executive Authority thereof shall issue Writs of Election to fill - such Vacancies. - - Clause 5: The House of Representatives shall chuse their Speaker and - other Officers; and shall have the sole Power of Impeachment. - - Section. 3. - - Clause 1: The Senate of the United States shall be composed of two - Senators from each State, chosen by the Legislature thereof, (See Note - 3) for six Years; and each Senator shall have one Vote. - - Clause 2: Immediately after they shall be assembled in Consequence of - the first Election, they shall be divided as equally as may be into - three Classes. The Seats of the Senators of the first Class shall be - vacated at the Expiration of the second Year, of the second Class at - the Expiration of the fourth Year, and of the third Class at the - Expiration of the sixth Year, so that one third may be chosen every - second Year; and if Vacancies happen by Resignation, or otherwise, - during the Recess of the Legislature of any State, the Executive - thereof may make temporary Appointments until the next Meeting of the - Legislature, which shall then fill such Vacancies. (See Note 4) - - Clause 3: No Person shall be a Senator who shall not have attained to - the Age of thirty Years, and been nine Years a Citizen of the United - States, and who shall not, when elected, be an Inhabitant of that - State for which he shall be chosen. - - Clause 4: The Vice President of the United States shall be President - of the Senate, but shall have no Vote, unless they be equally divided. - - Clause 5: The Senate shall chuse their other Officers, and also a - President pro tempore, in the Absence of the Vice President, or when - he shall exercise the Office of President of the United States. - - Clause 6: The Senate shall have the sole Power to try all - Impeachments. When sitting for that Purpose, they shall be on Oath or - Affirmation. When the President of the United States is tried, the - Chief Justice shall preside: And no Person shall be convicted without - the Concurrence of two thirds of the Members present. - - Clause 7: Judgment in Cases of Impeachment shall not extend further - than to removal from Office, and disqualification to hold and enjoy - any Office of honor, Trust or Profit under the United States: but the - Party convicted shall nevertheless be liable and subject to - Indictment, Trial, Judgment and Punishment, according to Law. - - Section. 4. - - Clause 1: The Times, Places and Manner of holding Elections for - Senators and Representatives, shall be prescribed in each State by the - Legislature thereof; but the Congress may at any time by Law make or - alter such Regulations, except as to the Places of chusing Senators. - - Clause 2: The Congress shall assemble at least once in every Year, and - such Meeting shall be on the first Monday in December, (See Note 5) - unless they shall by Law appoint a different Day. - - Section. 5. - - Clause 1: Each House shall be the Judge of the Elections, Returns and - Qualifications of its own Members, and a Majority of each shall - constitute a Quorum to do Business; but a smaller Number may adjourn - from day to day, and may be authorized to compel the Attendance of - absent Members, in such Manner, and under such Penalties as each House - may provide. - - Clause 2: Each House may determine the Rules of its Proceedings, - punish its Members for disorderly Behaviour, and, with the Concurrence - of two thirds, expel a Member. - - Clause 3: Each House shall keep a Journal of its Proceedings, and from - time to time publish the same, excepting such Parts as may in their - Judgment require Secrecy; and the Yeas and Nays of the Members of - either House on any question shall, at the Desire of one fifth of - those Present, be entered on the Journal. - - Clause 4: Neither House, during the Session of Congress, shall, - without the Consent of the other, adjourn for more than three days, - nor to any other Place than that in which the two Houses shall be - sitting. - - Section. 6. - - Clause 1: The Senators and Representatives shall receive a - Compensation for their Services, to be ascertained by Law, and paid - out of the Treasury of the United States. (See Note 6) They shall in - all Cases, except Treason, Felony and Breach of the Peace, - beprivileged from Arrest during their Attendance at the Session of - their respective Houses, and in going to and returning from the same; - and for any Speech or Debate in either House, they shall not be - questioned in any other Place. - - Clause 2: No Senator or Representative shall, during the Time for - which he was elected, be appointed to any civil Office under the - Authority of the United States, which shall have been created, or the - Emoluments whereof shall have been encreased during such time; and no - Person holding any Office under the United States, shall be a Member - of either House during his Continuance in Office. - - Section. 7. - - Clause 1: All Bills for raising Revenue shall originate in the House - of Representatives; but the Senate may propose or concur with - Amendments as on other Bills. - - Clause 2: Every Bill which shall have passed the House of - Representatives and the Senate, shall, before it become a Law, be - presented to the President of the United States; If he approve he - shall sign it, but if not he shall return it, with his Objections to - that House in which it shall have originated, who shall enter the - Objections at large on their Journal, and proceed to reconsider it. If - after such Reconsideration two thirds of that House shall agree to - pass the Bill, it shall be sent, together with the Objections, to the - other House, by which it shall likewise be reconsidered, and if - approved by two thirds of that House, it shall become a Law. But in - all such Cases the Votes of both Houses shall be determined by yeas - and Nays, and the Names of the Persons voting for and against the Bill - shall be entered on the Journal of each House respectively. If any - Bill shall not be returned by the President within ten Days (Sundays - excepted) after it shall have been presented to him, the Same shall be - a Law, in like Manner as if he had signed it, unless the Congress by - their Adjournment prevent its Return, in which Case it shall not be a - Law. - - Clause 3: Every Order, Resolution, or Vote to which the Concurrence of - the Senate and House of Representatives may be necessary (except on a - question of Adjournment) shall be presented to the President of the - United States; and before the Same shall take Effect, shall be - approved by him, or being disapproved by him, shall be repassed by two - thirds of the Senate and House of Representatives, according to the - Rules and Limitations prescribed in the Case of a Bill. - - Section. 8. - - Clause 1: The Congress shall have Power To lay and collect Taxes, - Duties, Imposts and Excises, to pay the Debts and provide for the - common Defence and general Welfare of the United States; but all - Duties, Imposts and Excises shall be uniform throughout the United - States; - - Clause 2: To borrow Money on the credit of the United States; - - Clause 3: To regulate Commerce with foreign Nations, and among the - several States, and with the Indian Tribes; - - Clause 4: To establish an uniform Rule of Naturalization, and uniform - Laws on the subject of Bankruptcies throughout the United States; - - Clause 5: To coin Money, regulate the Value thereof, and of foreign - Coin, and fix the Standard of Weights and Measures; - - Clause 6: To provide for the Punishment of counterfeiting the - Securities and current Coin of the United States; - - Clause 7: To establish Post Offices and post Roads; - - Clause 8: To promote the Progress of Science and useful Arts, by - securing for limited Times to Authors and Inventors the exclusive - Right to their respective Writings and Discoveries; - - Clause 9: To constitute Tribunals inferior to the supreme Court; - - Clause 10: To define and punish Piracies and Felonies committed on the - high Seas, and Offences against the Law of Nations; - - Clause 11: To declare War, grant Letters of Marque and Reprisal, and - make Rules concerning Captures on Land and Water; - - Clause 12: To raise and support Armies, but no Appropriation of Money - to that Use shall be for a longer Term than two Years; - - Clause 13: To provide and maintain a Navy; - - Clause 14: To make Rules for the Government and Regulation of the land - and naval Forces; - - Clause 15: To provide for calling forth the Militia to execute the - Laws of the Union, suppress Insurrections and repel Invasions; - - Clause 16: To provide for organizing, arming, and disciplining, the - Militia, and for governing such Part of them as may be employed in the - Service of the United States, reserving to the States respectively, - the Appointment of the Officers, and the Authority of training the - Militia according to the discipline prescribed by Congress; - - Clause 17: To exercise exclusive Legislation in all Cases whatsoever, - over such District (not exceeding ten Miles square) as may, byCession - of particular States, and the Acceptance of Congress, become the Seat - of the Government of the United States, and to exercise like Authority - over all Places purchased by the Consent of the Legislature of the - State in which the Same shall be, for the Erection of Forts, - Magazines, Arsenals, dock-Yards, and other needful Buildings;--And - - Clause 18: To make all Laws which shall be necessary and proper for - carrying into Execution the foregoing Powers, and all other Powers - vested by this Constitution in the Government of the United States, or - in any Department or Officer thereof. - - Section. 9. - - Clause 1: The Migration or Importation of such Persons as any of the - States now existing shall think proper to admit, shall not be - prohibited by the Congress prior to the Year one thousand eight - hundred and eight, but a Tax or duty may be imposed on such - Importation, not exceeding ten dollars for each Person. - - Clause 2: The Privilege of the Writ of Habeas Corpus shall not be - suspended, unless when in Cases of Rebellion or Invasion the public - Safety may require it. - - Clause 3: No Bill of Attainder or ex post facto Law shall be passed. - - Clause 4: No Capitation, or other direct, Tax shall be laid, unless in - Proportion to the Census or Enumeration herein before directed to be - taken. (See Note 7) - - Clause 5: No Tax or Duty shall be laid on Articles exported from any - State. - - Clause 6: No Preference shall be given by any Regulation of Commerce - or Revenue to the Ports of one State over those of another: nor shall - Vessels bound to, or from, one State, be obliged to enter, clear, or - pay Duties in another. - - Clause 7: No Money shall be drawn from the Treasury, but in - Consequence of Appropriations made by Law; and a regular Statement and - Account of the Receipts and Expenditures of all public Money shall be - published from time to time. - - Clause 8: No Title of Nobility shall be granted by the United States: - And no Person holding any Office of Profit or Trust under them, shall, - without the Consent of the Congress, accept of any present, Emolument, - Office, or Title, of any kind whatever, from any King, Prince, or - foreign State. - - Section. 10. - - Clause 1: No State shall enter into any Treaty, Alliance, or - Confederation; grant Letters of Marque and Reprisal; coin Money; emit - Bills of Credit; make any Thing but gold and silver Coin a Tender in - Payment of Debts; pass any Bill of Attainder, ex post facto Law, or - Law impairing the Obligation of Contracts, or grant any Title of - Nobility. - - Clause 2: No State shall, without the Consent of the Congress, lay any - Imposts or Duties on Imports or Exports, except what may be absolutely - necessary for executing it's inspection Laws: and the net Produce of - all Duties and Imposts, laid by any State on Imports or Exports, shall - be for the Use of the Treasury of the United States; and all such Laws - shall be subject to the Revision and Controul of the Congress. - - Clause 3: No State shall, without the Consent of Congress, lay any - Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter - into any Agreement or Compact with another State, or with a foreign - Power, or engage in War, unless actually invaded, or in such imminent - Danger as will not admit of delay. - -Article. II. - - Section. 1. - - Clause 1: The executive Power shall be vested in a President of the - United States of America. He shall hold his Office during the Term of - four Years, and, together with the Vice President, chosen for the same - Term, be elected, as follows - - Clause 2: Each State shall appoint, in such Manner as the Legislature - thereof may direct, a Number of Electors, equal to the whole Number of - Senators and Representatives to which the State may be entitled in the - Congress: but no Senator or Representative, or Person holding an - Office of Trust or Profit under the United States, shall be appointed - an Elector. - - Clause 3: The Electors shall meet in their respective States, and vote - by Ballot for two Persons, of whom one at least shall not be an - Inhabitant of the same State with themselves. And they shall make a - List of all the Persons voted for, and of the Number of Votes for - each; which List they shall sign and certify, and transmit sealed to - the Seat of the Government of the United States, directed to the - President of the Senate. The President of the Senate shall, in the - Presence of the Senate and House of Representatives, open all the - Certificates, and the Votes shall then be counted. The Person having - the greatest Number of Votes shall be the President, if such Number be - a Majority of the whole Number of Electors appointed; and if there be - more than one who have such Majority, and have an equal Number of - Votes, then the House of Representatives shall immediately chuse by - Ballot one of them for President; and if no Person have a Majority, - then from the five highest on the List the said House shall in like - Manner chuse the President. But in chusing the President, the Votes - shall be taken by States, the Representation from each State having - one Vote; A quorum for this Purpose shall consist of a Member or - Members from two thirds of the States, and a Majority of all the - States shall be necessary to a Choice. In every Case, after the Choice - of the President, the Person having the greatest Number of Votes of - the Electors shall be the Vice President. But if there should remain - two or more who have equal Votes, the Senate shall chuse from them by - Ballot the Vice President. (See Note 8) - - Clause 4: The Congress may determine the Time of chusing the Electors, - and the Day on which they shall give their Votes; which Day shall be - the same throughout the United States. - - Clause 5: No Person except a natural born Citizen, or a Citizen of the - United States, at the time of the Adoption of this Constitution, shall - be eligible to the Office of President; neither shall any Person be - eligible to that Office who shall not have attained to the Age of - thirty five Years, and been fourteen Years a Resident within the - United States. - - Clause 6: In Case of the Removal of the President from Office, or of - his Death, Resignation, or Inability to discharge the Powers and - Duties of the said Office, (See Note 9) the Same shall devolve on the - VicePresident, and the Congress may by Law provide for the Case of - Removal, Death, Resignation or Inability, both of the President and - Vice President, declaring what Officer shall then act as President, - and such Officer shall act accordingly, until the Disability be - removed, or a President shall be elected. - - Clause 7: The President shall, at stated Times, receive for his - Services, a Compensation, which shall neither be encreased nor - diminished during the Period for which he shall have been elected, and - he shall not receive within that Period any other Emolument from the - United States, or any of them. - - Clause 8: Before he enter on the Execution of his Office, he shall - take the following Oath or Affirmation:--"I do solemnly swear (or - affirm) that I will faithfully execute the Office of President of the - United States, and will to the best of my Ability, preserve, protect - and defend the Constitution of the United States." - - Section. 2. - - Clause 1: The President shall be Commander in Chief of the Army and - Navy of the United States, and of the Militia of the several States, - when called into the actual Service of the United States; he may - require the Opinion, in writing, of the principal Officer in each of - the executive Departments, upon any Subject relating to the Duties of - their respective Offices, and he shall have Power to grant Reprieves - and Pardons for Offences against the United States, except in Cases of - Impeachment. - - Clause 2: He shall have Power, by and with the Advice and Consent of - the Senate, to make Treaties, provided two thirds of the Senators - present concur; and he shall nominate, and by and with the Advice and - Consent of the Senate, shall appoint Ambassadors, other public - Ministers and Consuls, Judges of the supreme Court, and all other - Officers of the United States, whose Appointments are not herein - otherwise provided for, and which shall be established by Law: but the - Congress may by Law vest the Appointment of such inferior Officers, as - they think proper, in the President alone, in the Courts of Law, or in - the Heads of Departments. - - Clause 3: The President shall have Power to fill up all Vacancies that - may happen during the Recess of the Senate, by granting Commissions - which shall expire at the End of their next Session. - - Section. 3. - - He shall from time to time give to the Congress Information of the - State of the Union, and recommend to their Consideration such Measures - as he shall judge necessary and expedient; he may, on extraordinary - Occasions, convene both Houses, or either of them, and in Case of - Disagreement between them, with Respect to the Time of Adjournment, he - may adjourn them to such Time as he shall think proper; he shall - receive Ambassadors and other public Ministers; he shall take Care - that the Laws be faithfully executed, and shall Commission all the - Officers of the United States. - - Section. 4. - - The President, Vice President and all civil Officers of the United - States, shall be removed from Office on Impeachment for, and - Conviction of, Treason, Bribery, or other high Crimes and - Misdemeanors. - -Article. III. - - Section. 1. - - The judicial Power of the United States, shall be vested in one - supreme Court, and in such inferior Courts as the Congress may from - time to time ordain and establish. The Judges, both of the supreme and - inferior Courts, shall hold their Offices during good Behaviour, and - shall, at stated Times, receive for their Services, a Compensation, - which shall not be diminished during their Continuance in Office. - - Section. 2. - - Clause 1: The judicial Power shall extend to all Cases, in Law and - Equity, arising under this Constitution, the Laws of the United - States, and Treaties made, or which shall be made, under their - Authority;--to all Cases affecting Ambassadors, other public Ministers - and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to - Controversies to which the United States shall be a Party;--to - Controversies between two or more States;--between a State and - Citizens of another State; (See Note 10)--between Citizens of - different States, --between Citizens of the same State claiming Lands - under Grants of different States, and between a State, or the Citizens - thereof, and foreign States, Citizens or Subjects. - - Clause 2: In all Cases affecting Ambassadors, other public Ministers - and Consuls, and those in which a State shall be Party, the supreme - Court shall have original Jurisdiction. In all the other Cases before - mentioned, the supreme Court shall have appellate Jurisdiction, both - as to Law and Fact, with such Exceptions, and under such Regulations - as the Congress shall make. - - Clause 3: The Trial of all Crimes, except in Cases of Impeachment, - shall be by Jury; and such Trial shall be held in the State where the - said Crimes shall have been committed; but when not committed within - any State, the Trial shall be at such Place or Places as the Congress - may by Law have directed. - - Section. 3. - - Clause 1: Treason against the United States, shall consist only in - levying War against them, or in adhering to their Enemies, giving them - Aid and Comfort. No Person shall be convicted of Treason unless on the - Testimony of two Witnesses to the same overt Act, or on Confession in - open Court. - - Clause 2: The Congress shall have Power to declare the Punishment of - Treason, but no Attainder of Treason shall work Corruption of Blood, - or Forfeiture except during the Life of the Person attainted. - -Article. IV. - - Section. 1. - - Full Faith and Credit shall be given in each State to the public Acts, - Records, and judicial Proceedings of every other State. And the - Congress may by general Laws prescribe the Manner in which such Acts, - Records and Proceedings shall be proved, and the Effect thereof. - - Section. 2. - - Clause 1: The Citizens of each State shall be entitled to all - Privileges and Immunities of Citizens in the several States. - - Clause 2: A Person charged in any State with Treason, Felony, or other - Crime, who shall flee from Justice, and be found in another State, - shall on Demand of the executive Authority of the State from which he - fled, be delivered up, to be removed to the State having Jurisdiction - of the Crime. - - Clause 3: No Person held to Service or Labour in one State, under the - Laws thereof, escaping into another, shall, in Consequence of any Law - or Regulation therein, be discharged from such Service or Labour, but - shall be delivered up on Claim of the Party to whom such Service or - Labour may be due. (See Note 11) - - Section. 3. - - Clause 1: New States may be admitted by the Congress into this Union; - but no new State shall be formed or erected within the Jurisdiction of - any other State; nor any State be formed by the Junction of two or - more States, or Parts of States, without the Consent of the - Legislatures of the States concerned as well as of the Congress. - - Clause 2: The Congress shall have Power to dispose of and make all - needful Rules and Regulations respecting the Territory or other - Property belonging to the United States; and nothing in this - Constitution shall be so construed as to Prejudice any Claims of the - United States, or of any particular State. - - Section. 4. - - The United States shall guarantee to every State in this Union a - Republican Form of Government, and shall protect each of them against - Invasion; and on Application of the Legislature, or of the Executive - (when the Legislature cannot be convened) against domestic Violence. - -Article. V. - - The Congress, whenever two thirds of both Houses shall deem it - necessary, shall propose [1]Amendments to this Constitution, or, on - the Application of the Legislatures of two thirds of the several - States, shall call a Convention for proposing Amendments, which, in - either Case, shall be valid to all Intents and Purposes, as Part of - this Constitution, when ratified by the Legislatures of three fourths - of the several States, or by Conventions in three fourths thereof, as - the one or the other Mode of Ratification may be proposed by the - Congress; Provided that no Amendment which may be made prior to the - Year One thousand eight hundred and eight shall in any Manner affect - the first and fourth Clauses in the Ninth Section of the first - Article; and that no State, without its Consent, shall be deprived of - its equal Suffrage in the Senate. - -Article. VI. - - Clause 1: All Debts contracted and Engagements entered into, before - the Adoption of this Constitution, shall be as valid against the - United States under this Constitution, as under the Confederation. - - Clause 2: This Constitution, and the Laws of the United States which - shall be made in Pursuance thereof; and all Treaties made, or which - shall be made, under the Authority of the United States, shall be the - supreme Law of the Land; and the Judges in every State shall be bound - thereby, any Thing in the Constitution or Laws of any State to the - Contrary notwithstanding. - - Clause 3: The Senators and Representatives before mentioned, and the - Members of the several State Legislatures, and all executive and - judicial Officers, both of the United States and of the several - States, shall be bound by Oath or Affirmation, to support this - Constitution; but no religious Test shall ever be required as a - Qualification to any Office or public Trust under the United States. - -Article. VII. - - The Ratification of the Conventions of nine States, shall be - sufficient for the Establishment of this Constitution between the - States so ratifying the Same. - - done in Convention by the Unanimous Consent of the States present the - Seventeenth Day of September in the Year of our Lord one thousand - seven hundred and Eighty seven and of the Independence of the United - States of America the Twelfth In witness whereof We have hereunto - subscribed our Names, - - GO WASHINGTON--Presidt. and deputy from Virginia - - [Signed also by the deputies of twelve States.] - - Delaware - - Geo: Read - Gunning Bedford jun - John Dickinson - Richard Bassett - Jaco: Broom - - Maryland - - James MCHenry - Dan of ST ThoS. Jenifer - DanL Carroll. - - Virginia - - John Blair-- - James Madison Jr. - - North Carolina - - WM Blount - RichD. Dobbs Spaight. - Hu Williamson - - South Carolina - - J. Rutledge - Charles 1ACotesworth Pinckney - Charles Pinckney - Pierce Butler. - - Georgia - - William Few - Abr Baldwin - - New Hampshire - - John Langdon - Nicholas Gilman - - Massachusetts - - Nathaniel Gorham - Rufus King - - Connecticut - WM. SamL. Johnson - Roger Sherman - - New York - - Alexander Hamilton - - New Jersey - - Wil: Livingston - David Brearley. - WM. Paterson. - Jona: Dayton - - Pennsylvania - - B Franklin - Thomas Mifflin - RobT Morris - Geo. Clymer - ThoS. FitzSimons - Jared Ingersoll - James Wilson. - Gouv Morris - - Attest William Jackson Secretary - - NOTES - - Note 1: This text of the Constitution follows the engrossed copy - signed by Gen. Washington and the deputies from 12 States. The small - superior figures preceding the paragraphs designate Clauses, and were - not in the original and have no reference to footnotes. - - The Constitution was adopted by a convention of the States on - September 17, 1787, and was subsequently ratified by the several - States, on the following dates: Delaware, December 7, 1787; - Pennsylvania, December 12, 1787; New Jersey, December 18, 1787; - Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts, - February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23, - 1788; New Hampshire, June 21, 1788. - - Ratification was completed on June 21, 1788. - - The Constitution was subsequently ratified by Virginia, June 25, 1788; - New York, July 26, 1788; North Carolina, November 21, 1789; Rhode - Island, May 29, 1790; and Vermont, January 10, 1791. - - In May 1785, a committee of Congress made a report recommending an - alteration in the Articles of Confederation, but no action was taken - on it, and it was left to the State Legislatures to proceed in the - matter. In January 1786, the Legislature of Virginia passed a - resolution providing for the appointment of five commissioners, who, - or any three of them, should meet such commissioners as might be - appointed in the other States of the Union, at a time and place to be - agreed upon, to take into consideration the trade of the United - States; to consider how far a uniform system in their commercial - regulations may be necessary to their common interest and their - permanent harmony; and to report to the several States such an act, - relative to this great object, as, when ratified by them, will enable - the United States in Congress effectually to provide for the same. The - Virginia commissioners, after some correspondence, fixed the first - Monday in September as the time, and the city of Annapolis as the - place for the meeting, but only four other States were represented, - viz: Delaware, New York, New Jersey, and Pennsylvania; the - commissioners appointed by Massachusetts, New Hampshire, North - Carolina, and Rhode Island failed to attend. Under the circumstances - of so partial a representation, the commissioners present agreed upon - a report, (drawn by Mr. Hamilton, of New York,) expressing their - unanimous conviction that it might essentially tend to advance the - interests of the Union if the States by which they were respectively - delegated would concur, and use their endeavors to procure the - concurrence of the other States, in the appointment of commissioners - to meet at Philadelphia on the Second Monday of May following, to take - into consideration the situation of the United States; to devise such - further provisions as should appear to them necessary to render the - Constitution of the Federal Government adequate to the exigencies of - the Union; and to report such an act for that purpose to the United - States in Congress assembled as, when agreed to by them and afterwards - confirmed by the Legislatures of every State, would effectually - provide for the same. - - Congress, on the 21st of February, 1787, adopted a resolution in favor - of a convention, and the Legislatures of those States which had not - already done so (with the exception of Rhode Island) promptly - appointed delegates. On the 25th of May, seven States having convened, - George Washington, of Virginia, was unanimously elected President, and - the consideration of the proposed constitution was commenced. On the - 17th of September, 1787, the Constitution as engrossed and agreed upon - was signed by all the members present, except Mr. Gerry of - Massachusetts, and Messrs. Mason and Randolph, of Virginia. The - president of the convention transmitted it to Congress, with a - resolution stating how the proposed Federal Government should be put - in operation, and an explanatory letter. Congress, on the 28th of - September, 1787, directed the Constitution so framed, with the - resolutions and letter concerning the same, to "be transmitted to the - several Legislatures in order to be submitted to a convention of - delegates chosen in each State by the people thereof, in conformity to - the resolves of the convention." - - On the 4th of March, 1789, the day which had been fixed for commencing - the operations of Government under the new Constitution, it had been - ratified by the conventions chosen in each State to consider it, as - follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787; - New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut, - January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28, - 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788; - Virginia, June 25, 1788; and New York, July 26, 1788. - - The President informed Congress, on the 28th of January, 1790, that - North Carolina had ratified the Constitution November 21, 1789; and he - informed Congress on the 1st of June, 1790, that Rhode Island had - ratified the Constitution May 29, 1790. Vermont, in convention, - ratified the Constitution January 10, 1791, and was, by an act of - Congress approved February 18, 1791, "received and admitted into this - Union as a new and entire member of the United States." - - Note 2: The part of this Clause relating to the mode of apportionment - of representatives among the several States has been affected by - Section 2 of amendment XIV, and as to taxes on incomes without - apportionment by amendment XVI. - - Note 3: This Clause has been affected by Clause 1 of amendment XVII. - - Note 4: This Clause has been affected by Clause 2 of amendment XVIII. - - Note 5: This Clause has been affected by amendment XX. - - Note 6: This Clause has been affected by amendment XXVII. - - Note 7: This Clause has been affected by amendment XVI. - - Note 8: This Clause has been superseded by amendment XII. - - Note 9: This Clause has been affected by amendment XXV. - - Note 10: This Clause has been affected by amendment XI. - - Note 11: This Clause has been affected by amendment XIII. - - Note 12: The first ten amendments to the Constitution of the United - States (and two others, one of which failed of ratification and the - other which later became the 27th amendment) were proposed to the - legislatures of the several States by the First Congress on September - 25, 1789. The first ten amendments were ratified by the following - States, and the notifications of ratification by the Governors thereof - were successively communicated by the President to Congress: New - Jersey, November 20, 1789; Maryland, December 19, 1789; North - Carolina, December 22, 1789; South Carolina, January 19, 1790; New - Hampshire, January 25, 1790; Delaware, January 28, 1790; New York, - February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7, - 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791. - - Ratification was completed on December 15, 1791. - - The amendments were subsequently ratified by the legislatures of - Massachusetts, March 2, 1939; Georgia, March 18, 1939; and - Connecticut, April 19, 1939. - - Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had - numbers assigned to them at the time of ratification. - - Note 14: This sentence has been superseded by section 3 of amendment - XX. - - Note 15: See amendment XIX and section 1 of amendment XXVI. - - Note 16: Repealed by section 1 of amendment XXI. - -References - - 1. http://www.house.gov/Constitution/Amend.html -- cgit v1.2.1 From 16f19cd7ae01e0fc097f5573d18994da02e88934 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 18 Oct 2020 18:17:58 -0400 Subject: Introduce testmaker.m4 and testmaker.sh The existing method of generating multiple tests from l4 files is not flexible enough to handle multilanguage - reliance on the C preprocessor prevents that. This commit creates replacement machinery that's more flexible and will greatly reduce the complexity of adding new back ends. The idea is to generate test .l files by combining a backend-independent ruleset with backend-dependent boilerplate for test mains and preambles. This commit creates the rules files, the m4 to template them into tests, and a shell wrapper to drive the m4 expansion. The autoconf integration works OK, but requires additional rules at the end of tests/Makefile.am that probably ought to be autogenerated. There was one other change forced by this. In order for the new testmaker to work, it needs to be possible to analyze test file names into stems and option modifiers. Having underscores in the stem would make the analysis slower and bug-prone. I wanted to change them to "-" rather than deleting them, but this gives autoconf fits - it seems to not like filenames with embedded dashes in certain contexts. At this commit, only one test - array_nr.l - is generated using the new system. --- tests/.gitignore | 9 ++-- tests/Makefile.am | 20 +++++--- tests/array.rules | 37 +++++++++++++++ tests/array_nr.l | 55 ---------------------- tests/basic.rules | 50 ++++++++++++++++++++ tests/extended.rules | 52 +++++++++++++++++++++ tests/quote_in_comment.txt | 1 - tests/quote_in_comment_c99.l | 17 ------- tests/quote_in_comment_cpp.l | 16 ------- tests/quoteincomment.rules | 32 +++++++++++++ tests/quoteincomment.txt | 1 + tests/quoteincomment_c99.l | 17 +++++++ tests/quoteincomment_cpp.l | 16 +++++++ tests/reject.rules | 35 ++++++++++++++ tests/tableopts.rules | 39 ++++++++++++++++ tests/testmaker.m4 | 106 +++++++++++++++++++++++++++++++++++++++++++ tests/testmaker.sh | 64 ++++++++++++++++++++++++++ 17 files changed, 467 insertions(+), 100 deletions(-) create mode 100644 tests/array.rules delete mode 100644 tests/array_nr.l create mode 100644 tests/basic.rules create mode 100644 tests/extended.rules delete mode 100644 tests/quote_in_comment.txt delete mode 100644 tests/quote_in_comment_c99.l delete mode 100644 tests/quote_in_comment_cpp.l create mode 100644 tests/quoteincomment.rules create mode 100644 tests/quoteincomment.txt create mode 100644 tests/quoteincomment_c99.l create mode 100644 tests/quoteincomment_cpp.l create mode 100644 tests/reject.rules create mode 100644 tests/tableopts.rules create mode 100644 tests/testmaker.m4 create mode 100644 tests/testmaker.sh diff --git a/tests/.gitignore b/tests/.gitignore index 30a881e..ad3aef0 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,6 +6,7 @@ alloc_extra_cpp alloc_extra_cpp.c alloc_extra_c99 alloc_extra_c99.c +array_nr.l array_nr array_nr.c array_r @@ -109,10 +110,10 @@ rescan_nr.direct rescan_nr.direct.c rescan_r.direct rescan_r.direct.c -quote_in_comment_cpp -quote_in_comment_cpp.c -quote_in_comment_c99 -quote_in_comment_c99.c +quoteincomment_cpp +quoteincomment_cpp.c +quoteincomment_c99 +quoteincomment_c99.c quotes_cpp quotes_cpp.c quotes_c99 diff --git a/tests/Makefile.am b/tests/Makefile.am index 22d6eba..a1e1607 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,8 +98,8 @@ simple_tests = \ prefix_nr \ prefix_r \ prefix_c99 \ - quote_in_comment_cpp \ - quote_in_comment_c99 \ + quoteincomment_cpp \ + quoteincomment_c99 \ quotes_cpp \ quotes_c99 \ string_nr \ @@ -136,8 +136,8 @@ ONE_TESTS = \ lineno_c99.one \ lineno_trailing.one -quote_in_comment_cpp_SOURCES = quote_in_comment_cpp.l -quote_in_comment_c99_SOURCES = quote_in_comment_c99.l +quoteincomment_cpp_SOURCES = quoteincomment_cpp.l +quoteincomment_c99_SOURCES = quoteincomment_c99.l alloc_extra_cpp_SOURCES = alloc_extra_cpp.l alloc_extra_c99_SOURCES = alloc_extra_c99.l array_nr_SOURCES = array_nr.l @@ -225,6 +225,7 @@ yyextra_c99_SOURCES = yyextra_c99.l CLEANFILES = \ alloc_extra_cpp.c \ alloc_extra_c99.c \ + array_nr.l \ array_nr.c \ array_r.c \ array_c99.c \ @@ -286,8 +287,8 @@ CLEANFILES = \ prefix_r.c \ prefix_c99.c \ pthread.c \ - quote_in_comment_cpp.c \ - quote_in_comment_c99.c \ + quoteincomment_cpp.c \ + quoteincomment_c99.c \ quotes_cpp.c \ reject_nr.reject.c \ reject_r.reject.c \ @@ -355,7 +356,7 @@ EXTRA_DIST = \ reject.txt \ rescan_nr.direct.txt \ rescan_r.direct.txt \ - quote_in_comment.txt \ + quoteincomment.txt \ quotes.txt \ top.txt \ yyextra.txt \ @@ -550,3 +551,8 @@ tableopts_ver_r%.c: tableopts.l4 $(FLEX) tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< + +# Rules for tests generated from rulesets start here + +array_nr.l: array.rules testmaker.m4 + $(SHELL) testmaker.sh array_nr.l diff --git a/tests/array.rules b/tests/array.rules new file mode 100644 index 0000000..cd6fe91 --- /dev/null +++ b/tests/array.rules @@ -0,0 +1,37 @@ +/* This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option 8bit +%option nounput nomain noyywrap noinput +%option warn array + + +%% + +.|\n { } + + +%% +M4_TEST_POSTAMBLE`'dnl diff --git a/tests/array_nr.l b/tests/array_nr.l deleted file mode 100644 index f4f0f1b..0000000 --- a/tests/array_nr.l +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn array - - -%% - -.|\n { } - - -%% - -int main (void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - yylex(); - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/basic.rules b/tests/basic.rules new file mode 100644 index 0000000..fcddf82 --- /dev/null +++ b/tests/basic.rules @@ -0,0 +1,50 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* TEST scanner. + + Sample Input: + # this is a comment + foo = true + bar = "string value" + integer = 43 +*/ + +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option nounput noyywrap noyylineno warn nodefault noinput + +IDENT [[:alnum:]_-] +WS [[:blank:]] +%% + +^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} +^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} +^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} +^{WS}*#.*\r?\n { } +^{WS}*\r?\n { } +.|\n {M4_TEST_FAILMESSAGE} + +%% +M4_TEST_POSTAMBLE diff --git a/tests/extended.rules b/tests/extended.rules new file mode 100644 index 0000000..0dc601d --- /dev/null +++ b/tests/extended.rules @@ -0,0 +1,52 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +/* Output should match the input. */ +/* FIXME: Assumes ";" is a legal statememt terminator */ + +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option 8bit nounput nomain noyywrap noinput warn +%% + +abc(?# Single Line Comment )def yyecho(); +ghi(?# + multi-line + comment + )jkl yyecho(); + +mno(?# + multi-line // + comment with ## + ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; + punctuation + )pqr yyecho(); +(?# Start of a rule.)stu yyecho(); +vwxyz(?#End of a rule.) yyecho(); +A(?x: B + /* comment */ + C D) yyecho(); + +\n yyecho(); +%% +M4_TEST_POSTAMBLE diff --git a/tests/quote_in_comment.txt b/tests/quote_in_comment.txt deleted file mode 100644 index 9daeafb..0000000 --- a/tests/quote_in_comment.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/tests/quote_in_comment_c99.l b/tests/quote_in_comment_c99.l deleted file mode 100644 index 2d3db98..0000000 --- a/tests/quote_in_comment_c99.l +++ /dev/null @@ -1,17 +0,0 @@ -%option emit="c99" -%option 8bit noyywrap -%% -.|\n { yyecho(); - //' " - } -%% -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/quote_in_comment_cpp.l b/tests/quote_in_comment_cpp.l deleted file mode 100644 index cb17e2f..0000000 --- a/tests/quote_in_comment_cpp.l +++ /dev/null @@ -1,16 +0,0 @@ -%option 8bit noyywrap -%% -.|\n { yyecho(); - //' " - } -%% -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/quoteincomment.rules b/tests/quoteincomment.rules new file mode 100644 index 0000000..e28ee34 --- /dev/null +++ b/tests/quoteincomment.rules @@ -0,0 +1,32 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option 8bit noyywrap +%% +.|\n { yyecho(); + //' " + } +%% +M4_TEST_POSTAMBLE diff --git a/tests/quoteincomment.txt b/tests/quoteincomment.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/tests/quoteincomment.txt @@ -0,0 +1 @@ +test diff --git a/tests/quoteincomment_c99.l b/tests/quoteincomment_c99.l new file mode 100644 index 0000000..2d3db98 --- /dev/null +++ b/tests/quoteincomment_c99.l @@ -0,0 +1,17 @@ +%option emit="c99" +%option 8bit noyywrap +%% +.|\n { yyecho(); + //' " + } +%% +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/quoteincomment_cpp.l b/tests/quoteincomment_cpp.l new file mode 100644 index 0000000..cb17e2f --- /dev/null +++ b/tests/quoteincomment_cpp.l @@ -0,0 +1,16 @@ +%option 8bit noyywrap +%% +.|\n { yyecho(); + //' " + } +%% +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/reject.rules b/tests/reject.rules new file mode 100644 index 0000000..d44ade9 --- /dev/null +++ b/tests/reject.rules @@ -0,0 +1,35 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option 8bit +%option nounput nomain noyywrap noinput +%option warn reject +%% + +. { ECHO; } +.|\n ; + +%% diff --git a/tests/tableopts.rules b/tests/tableopts.rules new file mode 100644 index 0000000..65c5b7e --- /dev/null +++ b/tests/tableopts.rules @@ -0,0 +1,39 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +The simple grammar used as a test ofb table-compression options + + +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option 8bit +%option nounput nomain noyywrap noinput +%option warn yylineno +%% + +foo|bar ; +[[:digit:]]+ ; +[[:blank:]]+ ; +.|\n ; +%% +M4_TEST_POSTAMBLE diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 new file mode 100644 index 0000000..088dd3c --- /dev/null +++ b/tests/testmaker.m4 @@ -0,0 +1,106 @@ +dnl Multi-backend test template +dnl +dnl Supply per-backend boilerplate for Flex tests. +dnl See testmaker.sh for how it's used. +dnl +dnl M4_TEST_BACKEND must be set to a recognized back end name. +dnl For purposes of this file, "nr" and "r" are treated as +dnl separate back ends - non-reentrant and reentrant C through +dnl the default cpp skeleton. At time of writing this file, +dnl c99 is the only other; it is expected this will change. +dnl +dnl The purpose of this file is to properly set three macros: +dnl +dnl M4_TEST_PREAMBLE = the contyents of s top secton, if required, and +dnl the emit option required to srt the back end. +dnl +dnl M4_TEST_COMPRESSION = compression option. +dnl +dnl M4_TEST_FAILMESSAGE = A line of code required to issue dnl a +dnl failure notification to standard error and exit with a failure status. +dnl +dnl M4_TEST_POSTAMBLE = the test main. +dnl +dnl These macros are to be expanded by files with a .rules extension +dnl that contain pure flex rulesets and no backend-specific code. +dnl +define(`M4_TEST_FAILMESSAGE', `INVALID BACK END')dnl +dnl +ifelse(M4_TEST_BACKEND, `nr', `dnl +define(`M4_TEST_PREAMBLE', `dnl +%{ +#include "config.h" +#include +%} +')dnl close preamble +define(`M4_TEST_FAILMESSAGE', `dnl +fprintf(stderr,"Invalid line.\n"); exit(-1); +')dnl close failmessage +define(`M4_TEST_POSTAMBLE', `dnl +int main (void) +{ + yyin = stdin; + yyout = stdout; + while( yylex() ) + { + } + printf("TEST RETURNING OK.\n"); + return 0; +} +')dnl close postamble +')dnl close nr +dnl +ifelse(M4_TEST_BACKEND, `r', `dnl +define(`M4_TEST_PREAMBLE', `dnl +%{ +#include "config.h" +#include +%} +')dnl close preamble +define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"Invalid line.\n"); exit(-1);') +define(`M4_TEST_POSTAMBLE', `dnl +int main (void) +{ + yyscan_t lexer; + yylex_init( &lexer ); + yyset_out ( stdout,lexer); + yyset_in ( stdin, lexer); + while( yylex(lexer) ) + { + } + yylex_destroy( lexer ); + printf("TEST RETURNING OK.\n"); + return 0; +} +')dnl close postamble +')dnl close r +dnl +dnl A hypothetical example +ifelse(M4_TEST_BACKEND, `go', `dnl +define(`M4_TEST_PREAMBLE', `dnl +%top{ +package main + +import ( + "fmt" + "log" + "os" +) +%} +%option emit="go" +')dnl close preamble +define(`M4_TEST_FAILMESSAGE', `log.Fatal("Invalid line"); os.Exit(-1);') +define(`M4_TEST_POSTAMBLE', `dnl +func main(void) { + lexer := new(FlexLexer) + lexer.yysetOut(os.Stdout) + lexer.yysetIn(os.Stdin) + for lexer.yylex() { + } + fmt.Printf("TEST RETURNING OK.\n") + os.Exit(0) +} +')dnl clpse postamble +')dnl close go +dnl +dnl Additional backends go here diff --git a/tests/testmaker.sh b/tests/testmaker.sh new file mode 100644 index 0000000..70c0501 --- /dev/null +++ b/tests/testmaker.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# +# testmaker.sh - asssemble tests from backend-ndependent rulesets and +# backend-dependent boilerplate. +# +# The single argument is a testfile name to be generated. +# With the -d option, dump to stdourather than crating the file. +# +# A typical test load name: tableopts_opt_nr_Ca_opt, this breaks +# down as tableopts_{tag}_{backend}_{compression}_{tag}. +# The backend field can be nr, r, c99 and will eventually have more values. +# The compression options are the flags that woulld nprmally be passed to +# Flex; the possibilities are Ca Ce Cf C_F Cm Cem Cae Caef Cae_F Cam Caem. +# +if [ "$1" = -d ] ; then + shift + outdev=/dev/stdout +else + outdev="$1" +fi + +testfile=$1 + +trap "rm -f /tmp/testmaker$$" EXIT INT QUIT + +set `echo $testfile | tr '.' ' '` +if [ "$2" != "l" ] +then + echo "$0: Don't know how to make anything but a .l file: $parts" >&2 + exit 1 +fi + +set -- `echo $1 | tr '_' ' '` +stem=$1 +options="" +for part in $*; do + # This is the only pace in this dcript that you need to modify + # to add a new back end - just add a line on the pattern of + # the c99 one. Of course testmaker.m4 will require the + # right boilerplate code for this to work. + # + # Yes, cpp is an alias for nr. + case ${part} in + cpp|nr) backend=nr; ;; + r) backend=r; options="${options} reentrant";; + c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; + esac +done + +if [ -z "$backend" ] +then + echo "Can't identify a back end part in ${testfile}" >&2; + exit 1; +fi + +( + printf "define(\`M4_TEST_BACKEND', \`${backend}')dnl\n" + if [ -z "${options}" ] ; then + printf "define(\`M4_TEST_OPTIONS', \`')dnl\n" + else + printf "define(\`M4_TEST_OPTIONS', \`%%option${options}\n')dnl\n" + fi + cat testmaker.m4 ${stem}.rules +) | m4 >${outdev} -- cgit v1.2.1 From 5a1544256bf9515450d78cb9577e44f4cf6249d0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 20 Oct 2020 04:53:49 -0400 Subject: Greatly simplify CLEANFILES and EXTRA_DIST by using wildcarding. This reduces the amount of hand-work trquired to add a back end. --- tests/Makefile.am | 138 ++---------------------------------------------------- 1 file changed, 5 insertions(+), 133 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a1e1607..03ec228 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -223,90 +223,10 @@ yyextra_c99_SOURCES = yyextra_c99.l # it. CLEANFILES = \ - alloc_extra_cpp.c \ - alloc_extra_c99.c \ - array_nr.l \ - array_nr.c \ - array_r.c \ - array_c99.c \ - basic_nr.c \ - basic_r.c \ - basic_c99.c \ - bison_nr_parser.c \ - bison_nr_parser.h \ - bison_nr_scanner.c \ - bison_nr_scanner.h \ - bison_yylloc_parser.c \ - bison_yylloc_parser.h \ - bison_yylloc_scanner.c \ - bison_yylloc_scanner.h \ - bison_yylval_parser.c \ - bison_yylval_parser.h \ - bison_yylval_scanner.c \ - bison_yylval_scanner.h \ - c_cxx_nr.cc \ - c_cxx_r.cc \ - ccl_cpp.c \ - cxx_basic.cc \ - cxx_multiple_scanners_1.cc \ - cxx_multiple_scanners_2.cc \ - cxx_restart.cc \ - cxx_yywrap.cc \ - debug_nr.c \ - debug_r.c \ - debug_c99.c \ - extended_cpp.c \ - extended_c99.c \ - header_nr_scanner.c \ - header_nr_scanner.h \ - header_r_scanner.c \ - header_r_scanner.h \ - include_by_buffer.direct.c \ - include_by_push.direct.c \ - include_by_reentrant.direct.c \ - lineno_nr.c \ - lineno_r.c \ - lineno_c99.c \ - lineno_trailing.c \ - mem_nr.c \ - mem_r.c \ - mem_c99.c \ - multiple_scanners_nr_1.c \ - multiple_scanners_nr_1.h \ - multiple_scanners_nr_2.c \ - multiple_scanners_nr_2.h \ - multiple_scanners_r_1.c \ - multiple_scanners_r_1.h \ - multiple_scanners_r_2.c \ - multiple_scanners_r_2.h \ - posix_cpp.c \ - posix_c99.c \ - posixly_correct_cpp.c \ - posixly_correct_c99.c \ - prefix_nr.c \ - prefix_r.c \ - prefix_c99.c \ - pthread.c \ - quoteincomment_cpp.c \ - quoteincomment_c99.c \ - quotes_cpp.c \ - reject_nr.reject.c \ - reject_r.reject.c \ - reject_ser.table.c \ - reject_ser.table.tables \ - reject_ver.table.c \ - reject_ver.table.tables \ - rescan_nr.direct.c \ - rescan_r.direct.c \ - string_nr.c \ - string_r.c \ - string_c99.c \ - top.c \ - top.h \ - yyextra_cpp.c \ - yyextra_c99.c \ - $(tableopts_c) \ - $(tableopts_tables) + *.h *.tables \ + $(subst no_bison_stub.c, , $(shell ls *.c | grep -v "_main.c")) \ + $(shell ls *.cc | grep -v "_main.cc") \ + array_nr.l dist-hook: chmod u+w $(distdir) && \ @@ -314,53 +234,7 @@ dist-hook: rm -f $(distdir)/$$file \ ; done -EXTRA_DIST = \ - README \ - alloc_extra.txt \ - array.txt \ - basic.txt \ - bison_nr.txt \ - bison_yylloc.txt \ - bison_yylval.txt \ - c_cxx_nr.txt \ - c_cxx_r.txt \ - ccl.txt \ - cxx_basic.txt \ - cxx_multiple_scanners.txt \ - cxx_restart.txt \ - cxx_yywrap.txt \ - debug.txt \ - extended.txt \ - header_nr.txt \ - header_r.txt \ - include_by_buffer.direct.txt \ - include_by_buffer.direct_2.txt \ - include_by_buffer.direct_3.txt \ - include_by_push.direct.txt \ - include_by_push.direct_2.txt \ - include_by_push.direct_3.txt \ - include_by_reentrant.direct.txt \ - include_by_reentrant.direct_2.txt \ - include_by_reentrant.direct_3.txt \ - lineno_nr.one.txt \ - lineno_r.one.txt \ - lineno_c99.one.txt \ - lineno_trailing.one.txt \ - mem.txt \ - prefix.txt \ - pthread_1.txt \ - pthread_2.txt \ - pthread_3.txt \ - pthread_4.txt \ - pthread_5.txt \ - reject.txt \ - rescan_nr.direct.txt \ - rescan_r.direct.txt \ - quoteincomment.txt \ - quotes.txt \ - top.txt \ - yyextra.txt \ - tableopts.txt +EXTRA_DIST = README *.txt dist_noinst_SCRIPTS = \ tableopts.sh @@ -502,8 +376,6 @@ tableopts_sertests := $(foreach opt,$(tableopts), tableopts_ser_nr$(opt) tableo tableopts_vertests := $(foreach opt,$(tableopts), tableopts_ver_nr$(opt) tableopts_ver_r$(opt)) tableopts_tests := $(tableopts_opttests) $(tableopts_vertests) $(tableopts_sertests) -tableopts_c := $(addsuffix .c,$(tableopts_tests)) - OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r -- cgit v1.2.1 From 2034298f3d2efec1bc9b86fd2d43e89f89bd600c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 20 Oct 2020 05:39:31 -0400 Subject: Integrate all possible simple tests into the new test templating system. Still to be folded in: all the reject and tableopts tests. Note: I understand VPATH builds just well enough to suspect that this commit and my previous broke them, but not well enough to test or fix it. Mea culpa. --- tests/Makefile.am | 53 ++++++++++++++++++++++++++------- tests/array_c99.l | 63 --------------------------------------- tests/array_r.l | 62 -------------------------------------- tests/basic_c99.l | 69 ------------------------------------------ tests/basic_nr.l | 64 --------------------------------------- tests/basic_r.l | 68 ------------------------------------------ tests/extended_c99.l | 74 ---------------------------------------------- tests/extended_cpp.l | 73 --------------------------------------------- tests/quoteincomment_c99.l | 17 ----------- tests/quoteincomment_cpp.l | 16 ---------- 10 files changed, 42 insertions(+), 517 deletions(-) delete mode 100644 tests/array_c99.l delete mode 100644 tests/array_r.l delete mode 100644 tests/basic_c99.l delete mode 100644 tests/basic_nr.l delete mode 100644 tests/basic_r.l delete mode 100644 tests/extended_c99.l delete mode 100644 tests/extended_cpp.l delete mode 100644 tests/quoteincomment_c99.l delete mode 100644 tests/quoteincomment_cpp.l diff --git a/tests/Makefile.am b/tests/Makefile.am index 03ec228..85324a4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -60,15 +60,22 @@ AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src check_PROGRAMS = $(simple_tests) $(reject_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) -simple_tests = \ - alloc_extra_cpp \ - alloc_extra_c99 \ +generated = \ array_nr \ array_r \ array_c99 \ basic_nr \ basic_r \ basic_c99 \ + extended_cpp \ + extended_c99 \ + quoteincomment_cpp \ + quoteincomment_c99 + +simple_tests = \ + ${generated} \ + alloc_extra_cpp \ + alloc_extra_c99 \ bison_nr \ bison_yylloc \ bison_yylval \ @@ -82,8 +89,6 @@ simple_tests = \ debug_nr \ debug_r \ debug_c99 \ - extended_cpp \ - extended_c99 \ header_nr \ header_r \ mem_nr \ @@ -98,8 +103,6 @@ simple_tests = \ prefix_nr \ prefix_r \ prefix_c99 \ - quoteincomment_cpp \ - quoteincomment_c99 \ quotes_cpp \ quotes_c99 \ string_nr \ @@ -223,10 +226,10 @@ yyextra_c99_SOURCES = yyextra_c99.l # it. CLEANFILES = \ - *.h *.tables \ $(subst no_bison_stub.c, , $(shell ls *.c | grep -v "_main.c")) \ $(shell ls *.cc | grep -v "_main.cc") \ - array_nr.l + $(patsubst %, %.l, ${generated}) \ + *.h *.tables dist-hook: chmod u+w $(distdir) && \ @@ -425,6 +428,34 @@ tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< # Rules for tests generated from rulesets start here +# FIXME: These should be generated + +array_nr.l: array.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +array_r.l: array.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +array_c99.l: array.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +basic_nr.l: basic.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +basic_r.l: basic.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +basic_c99.l: basic.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +extended_cpp.l: extended.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +extended_c99.l: extended.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +quoteincomment_cpp.l: quoteincomment.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ -array_nr.l: array.rules testmaker.m4 - $(SHELL) testmaker.sh array_nr.l +quoteincomment_c99.l: quoteincomment.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ diff --git a/tests/array_c99.l b/tests/array_c99.l deleted file mode 100644 index 99f2a02..0000000 --- a/tests/array_c99.l +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn array reentrant - - -%% - -.|\n { } - - -%% - -int main(void); - -int -main (void) -{ - yyscan_t lexer; - - yylex_init(&lexer); - yyset_in(stdin, lexer); - yyset_out(stdout, lexer); - - yylex( lexer ); - - yylex_destroy( lexer); - printf("TEST RETURNING OK.\n"); - - return 0; -} diff --git a/tests/array_r.l b/tests/array_r.l deleted file mode 100644 index 68a6299..0000000 --- a/tests/array_r.l +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn array reentrant - - -%% - -.|\n { } - - -%% - -int main(void); - -int -main (void) -{ - yyscan_t lexer; - - yylex_init(&lexer); - yyset_in(stdin, lexer); - yyset_out(stdout, lexer); - - yylex( lexer ); - - yylex_destroy( lexer); - printf("TEST RETURNING OK.\n"); - - return 0; -} diff --git a/tests/basic_c99.l b/tests/basic_c99.l deleted file mode 100644 index 168dfd9..0000000 --- a/tests/basic_c99.l +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* A reentrant scanner. - This file will not compile under flex version <= 2.5.4. - Sample Input: - # this is a comment - foo = true - bar = "string value" - integer = 43 -*/ -%{ -#include "config.h" -%} - -%option emit="c99" -%option prefix="test" -%option nounput noyywrap noyylineno warn nodefault noinput -%option reentrant - -IDENT [[:alnum:]_-] -WS [[:blank:]] -%% - -^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} -^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} -^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} -^{WS}*#.*\r?\n { } -^{WS}*\r?\n { } -.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} - -%% - -int main(void); - -int main (void) -{ - yyscan_t lexer; - testlex_init( &lexer ); - testset_out ( stdout,lexer); - testset_in ( stdin, lexer); - while( testlex(lexer) ) - { - } - testlex_destroy( lexer ); - printf("TEST RETURNING OK.\n"); - return 0; -} - diff --git a/tests/basic_nr.l b/tests/basic_nr.l deleted file mode 100644 index bbe87c4..0000000 --- a/tests/basic_nr.l +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* TEST scanner. - Basic non-reentrant scanner. - - Sample Input: - # this is a comment - foo = true - bar = "string value" - integer = 43 -*/ -%{ -#include "config.h" -%} - -%option prefix="test" -%option nounput noyywrap noyylineno warn nodefault noinput - -IDENT [[:alnum:]_-] -WS [[:blank:]] -%% - -^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} -^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} -^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} -^{WS}*#.*\r?\n { } -^{WS}*\r?\n { } -.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} - -%% - -int main(void); - -int main (void) -{ - yyin = stdin; - yyout = stdout; - while( yylex() ) - { - } - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/basic_r.l b/tests/basic_r.l deleted file mode 100644 index 43d3a88..0000000 --- a/tests/basic_r.l +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* A reentrant scanner. - This file will not compile under flex version <= 2.5.4. - Sample Input: - # this is a comment - foo = true - bar = "string value" - integer = 43 -*/ -%{ -#include "config.h" -%} - -%option prefix="test" -%option nounput noyywrap noyylineno warn nodefault noinput -%option reentrant - -IDENT [[:alnum:]_-] -WS [[:blank:]] -%% - -^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} -^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} -^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} -^{WS}*#.*\r?\n { } -^{WS}*\r?\n { } -.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} - -%% - -int main(void); - -int main (void) -{ - yyscan_t lexer; - testlex_init( &lexer ); - testset_out ( stdout,lexer); - testset_in ( stdin, lexer); - while( testlex(lexer) ) - { - } - testlex_destroy( lexer ); - printf("TEST RETURNING OK.\n"); - return 0; -} - diff --git a/tests/extended_c99.l b/tests/extended_c99.l deleted file mode 100644 index 5b47b5c..0000000 --- a/tests/extended_c99.l +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* This test is for correctness of extended (?...) patterns. */ - -#include -#include -#include "config.h" - -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - - /* Output should match the input. */ - -abc(?# Single Line Comment )def ECHO; -ghi(?# - multi-line - comment - )jkl ECHO; - -mno(?# - multi-line // - comment with ## - ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; - punctuation - )pqr ECHO; -(?# Start of a rule.)stu ECHO; -vwxyz(?#End of a rule.) ECHO; -A(?x: B - /* comment */ - C D) ECHO; - -\n ECHO; -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - yylex(); - //printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/extended_cpp.l b/tests/extended_cpp.l deleted file mode 100644 index 9691307..0000000 --- a/tests/extended_cpp.l +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* This test is for correctness of extended (?...) patterns. */ - -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - - /* Output should match the input. */ - -abc(?# Single Line Comment )def ECHO; -ghi(?# - multi-line - comment - )jkl ECHO; - -mno(?# - multi-line // - comment with ## - ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; - punctuation - )pqr ECHO; -(?# Start of a rule.)stu ECHO; -vwxyz(?#End of a rule.) ECHO; -A(?x: B - /* comment */ - C D) ECHO; - -\n ECHO; -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - yylex(); - //printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/quoteincomment_c99.l b/tests/quoteincomment_c99.l deleted file mode 100644 index 2d3db98..0000000 --- a/tests/quoteincomment_c99.l +++ /dev/null @@ -1,17 +0,0 @@ -%option emit="c99" -%option 8bit noyywrap -%% -.|\n { yyecho(); - //' " - } -%% -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/quoteincomment_cpp.l b/tests/quoteincomment_cpp.l deleted file mode 100644 index cb17e2f..0000000 --- a/tests/quoteincomment_cpp.l +++ /dev/null @@ -1,16 +0,0 @@ -%option 8bit noyywrap -%% -.|\n { yyecho(); - //' " - } -%% -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} -- cgit v1.2.1 From 9ea7800162ac9352b36b038e61196c21e39b2a5b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 20 Oct 2020 07:12:43 -0400 Subject: Fold non-table-serialization reject tests into new test-generator system. Enables us to get rid of some spacial-purpose stuff in Makefile.am. --- tests/Makefile.am | 47 +++++++++++++++++++---------------------------- tests/reject.rules | 1 + 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 85324a4..e95401f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -34,9 +34,6 @@ TEST_EXTENSIONS = .reject .table .direct .cn .i3 .pthread .one .opt .ser .ver LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_LOG_FLAGS = -d $(srcdir) -r -REJECT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_REJECT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/reject.txt -r - TABLE_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_TABLE_LOG_FLAGS = -d $(builddir) -i $(srcdir)/reject.txt -t @@ -58,7 +55,7 @@ AM_ONE_LOG_FLAGS = -1 -d $(srcdir) AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -check_PROGRAMS = $(simple_tests) $(reject_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) +check_PROGRAMS = $(simple_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) generated = \ array_nr \ @@ -70,7 +67,10 @@ generated = \ extended_cpp \ extended_c99 \ quoteincomment_cpp \ - quoteincomment_c99 + quoteincomment_c99 \ + reject_nr \ + reject_r \ + reject_c99 simple_tests = \ ${generated} \ @@ -112,10 +112,6 @@ simple_tests = \ yyextra_cpp \ yyextra_c99 -reject_tests = \ - reject_nr.reject \ - reject_r.reject - TABLE_TESTS = \ reject_ver.table \ reject_ser.table @@ -139,8 +135,6 @@ ONE_TESTS = \ lineno_c99.one \ lineno_trailing.one -quoteincomment_cpp_SOURCES = quoteincomment_cpp.l -quoteincomment_c99_SOURCES = quoteincomment_c99.l alloc_extra_cpp_SOURCES = alloc_extra_cpp.l alloc_extra_c99_SOURCES = alloc_extra_c99.l array_nr_SOURCES = array_nr.l @@ -200,10 +194,12 @@ prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l prefix_c99_SOURCES = prefix_c99.l pthread_pthread_SOURCES = pthread.l +quoteincomment_cpp_SOURCES = quoteincomment_cpp.l +quoteincomment_c99_SOURCES = quoteincomment_c99.l quotes_cpp_SOURCES = quotes_cpp.l quotes_c99_SOURCES = quotes_c99.l -reject_nr_reject_SOURCES = reject.l4 -reject_r_reject_SOURCES = reject.l4 +reject_nr_SOURCES = reject_nr.l +reject_r_SOURCES = reject_r.l reject_ver_table_SOURCES = reject.l4 reject_ser_table_SOURCES = reject.l4 rescan_nr_direct_SOURCES = rescan_nr.direct.l @@ -326,21 +322,6 @@ posixly_correct_cpp.c: posixly_correct_cpp.l $(FLEX) posixly_correct_c99.c: posixly_correct_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< -reject_nr.reject.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ $< - -reject_nr.reject$(EXEEXT): reject_nr.reject.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $^ - -reject_r.reject.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape --reentrant -o $@ $< - -reject_r.reject.$(OBJEXT): reject_r.reject.c - $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< - -reject_r.reject$(EXEEXT): reject_r.reject.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $^ - reject_ver.table.c: reject.l4 $(FLEX) $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $< @@ -459,3 +440,13 @@ quoteincomment_cpp.l: quoteincomment.rules testmaker.m4 testmaker.sh quoteincomment_c99.l: quoteincomment.rules testmaker.m4 testmaker.sh $(SHELL) testmaker.sh $@ + +reject_nr.l: reject.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +reject_r.l: reject.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +reject_c99.l: reject.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + diff --git a/tests/reject.rules b/tests/reject.rules index d44ade9..f5f71a7 100644 --- a/tests/reject.rules +++ b/tests/reject.rules @@ -33,3 +33,4 @@ M4_TEST_OPTIONS`'dnl .|\n ; %% +M4_TEST_POSTAMBLE -- cgit v1.2.1 From 30b86fbc07f691a9d534f5d548603cdbfa5d12e1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 20 Oct 2020 10:47:05 -0400 Subject: Abolish reject.l4; all the reject tests are in the new system now. Still have the tableopts tests to do. --- tests/.gitignore | 42 +++++++++++++++++++-------- tests/Makefile.am | 40 ++++++++----------------- tests/reject.l4 | 82 ---------------------------------------------------- tests/testmaker.m4 | 46 +++++++++++++++++++++++++---- tests/testmaker.sh | 23 ++++++++++----- tests/testwrapper.sh | 7 +++++ 6 files changed, 104 insertions(+), 136 deletions(-) delete mode 100644 tests/reject.l4 diff --git a/tests/.gitignore b/tests/.gitignore index ad3aef0..18c9a82 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -11,14 +11,19 @@ array_nr array_nr.c array_r array_r.c +array_r.l array_c99 array_c99.c +array_c99.l basic_nr basic_nr.c +basic_nr.l basic_r basic_r.c +basic_r.l basic_c99 basic_c99.c +basic_c99.l bison_nr bison_nr_scanner.[ch] bison_nr_parser.[ch] @@ -52,8 +57,10 @@ debug_c99 debug_c99.c extended_cpp extended_cpp.c +extended_cpp.l extended_c99 extended_c99.c +extended_c99.l header_nr header_nr_scanner.[ch] header_r @@ -98,26 +105,37 @@ prefix_c99 prefix_c99.c pthread.pthread pthread.c -reject_nr.reject -reject_nr.reject.c -reject_r.reject -reject_r.reject.c -reject_ver.table -reject_ver.table.c -reject_ser.table -reject_ser.table.c -rescan_nr.direct -rescan_nr.direct.c -rescan_r.direct -rescan_r.direct.c quoteincomment_cpp quoteincomment_cpp.c +quoteincomment_cpp.l quoteincomment_c99 quoteincomment_c99.c +quoteincomment_c99.l quotes_cpp quotes_cpp.c quotes_c99 quotes_c99.c +reject_nr +reject_nr.c +reject_nr.l +reject_r +reject_r.c +reject_r.l +reject_c99 +reject_c99.c +reject_c99.l +reject_ser +reject_ser.c +reject_ser.l +reject_ser.table +reject_ver +reject_ver.c +reject_ver.l +reject_ver.table +rescan_nr.direct +rescan_nr.direct.c +rescan_r.direct +rescan_r.direct.c string_nr string_nr.c string_r diff --git a/tests/Makefile.am b/tests/Makefile.am index e95401f..f5f3189 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -34,9 +34,6 @@ TEST_EXTENSIONS = .reject .table .direct .cn .i3 .pthread .one .opt .ser .ver LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_LOG_FLAGS = -d $(srcdir) -r -TABLE_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_TABLE_LOG_FLAGS = -d $(builddir) -i $(srcdir)/reject.txt -t - DIRECT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper-direct.sh AM_DIRECT_LOG_FLAGS = -b $(abs_builddir) -s $(srcdir) @@ -55,7 +52,7 @@ AM_ONE_LOG_FLAGS = -1 -d $(srcdir) AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -check_PROGRAMS = $(simple_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) +check_PROGRAMS = $(simple_tests) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) generated = \ array_nr \ @@ -70,7 +67,9 @@ generated = \ quoteincomment_c99 \ reject_nr \ reject_r \ - reject_c99 + reject_c99 \ + reject_ver \ + reject_ser simple_tests = \ ${generated} \ @@ -112,9 +111,6 @@ simple_tests = \ yyextra_cpp \ yyextra_c99 -TABLE_TESTS = \ - reject_ver.table \ - reject_ser.table DIRECT_TESTS = \ include_by_buffer.direct \ @@ -200,8 +196,8 @@ quotes_cpp_SOURCES = quotes_cpp.l quotes_c99_SOURCES = quotes_c99.l reject_nr_SOURCES = reject_nr.l reject_r_SOURCES = reject_r.l -reject_ver_table_SOURCES = reject.l4 -reject_ser_table_SOURCES = reject.l4 +reject_ver_table_SOURCES = reject_ver.table.l +reject_ser_table_SOURCES = reject_ser.table.l rescan_nr_direct_SOURCES = rescan_nr.direct.l rescan_r_direct_SOURCES = rescan_r.direct.l string_nr_SOURCES = string_nr.l @@ -322,24 +318,6 @@ posixly_correct_cpp.c: posixly_correct_cpp.l $(FLEX) posixly_correct_c99.c: posixly_correct_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< -reject_ver.table.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $< - -reject_ver.table.$(OBJEXT): reject_ver.table.c - $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< - -reject_ver.table$(EXEEXT): reject_ver.table.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $^ - -reject_ser.table.c: reject.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $< - -reject_ser.table.$(OBJEXT): reject_ser.table.c - $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< - -reject_ser.table$(EXEEXT): reject_ser.table.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $^ - top_main.$(OBJEXT): top.h top.h: top.c @@ -450,3 +428,9 @@ reject_r.l: reject.rules testmaker.m4 testmaker.sh reject_c99.l: reject.rules testmaker.m4 testmaker.sh $(SHELL) testmaker.sh $@ +reject_ver.l: reject.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + +reject_ser.l: reject.rules testmaker.m4 testmaker.sh + $(SHELL) testmaker.sh $@ + diff --git a/tests/reject.l4 b/tests/reject.l4 deleted file mode 100644 index 9bcde22..0000000 --- a/tests/reject.l4 +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn reject - - -%% - -. { REJECT; } -.|\n ; - -%% - -int main ( int argc, char** argv ) -{ - FILE* fp = NULL; - void *yyscanner=0; - M4_YY_DECL_GUTS_VAR(); - -#ifdef TEST_IS_REENTRANT - testlex_init(&yyscanner); -#else - (void)yyscanner; -#endif - -#ifdef TEST_HAS_TABLES_EXTERNAL - if((fp = fopen(argv[1],"rb"))== NULL) - YY_FATAL_ERROR("could not open tables file for reading"); - - if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0) - YY_FATAL_ERROR("yytables_fload returned < 0"); - if(M4_YY_TABLES_VERIFY) - exit(0); -#endif - - if(argc > 2){ - if((fp = fopen(argv[2],"r"))== NULL) - YY_FATAL_ERROR("could not open input file for reading"); - yyin = fp; - } - while(testlex(M4_YY_CALL_ONLY_ARG) != 0) - ; - -#ifdef TEST_HAS_TABLES_EXTERNAL - testtables_destroy(M4_YY_CALL_ONLY_ARG); -#endif - testlex_destroy(M4_YY_CALL_ONLY_ARG); - - if(argc < 0) /* silence the compiler */ - yyscanner = (void*)fp; - - return 0; -} diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 088dd3c..c0bdbc3 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -6,8 +6,8 @@ dnl dnl M4_TEST_BACKEND must be set to a recognized back end name. dnl For purposes of this file, "nr" and "r" are treated as dnl separate back ends - non-reentrant and reentrant C through -dnl the default cpp skeleton. At time of writing this file, -dnl c99 is the only other; it is expected this will change. +dnl the default cpp skeleton. The c99 backend is treated here +dnl as re-eentrant C, but may have a different skeleton file. dnl dnl The purpose of this file is to properly set three macros: dnl @@ -16,11 +16,17 @@ dnl the emit option required to srt the back end. dnl dnl M4_TEST_COMPRESSION = compression option. dnl -dnl M4_TEST_FAILMESSAGE = A line of code required to issue dnl a +dnl M4_TEST_FAILMESSAGE = a line of code required to issue dnl a dnl failure notification to standard error and exit with a failure status. dnl dnl M4_TEST_POSTAMBLE = the test main. dnl +dnl M4_TEST_TABLE_SERIALIZATION = define this to exercise table +dnl serialization. +dnl +dnl M4_TEST_TABLE_VERIFICATION = define this to exercise table +dnl verification and exit. +dnl dnl These macros are to be expanded by files with a .rules extension dnl that contain pure flex rulesets and no backend-specific code. dnl @@ -37,13 +43,27 @@ define(`M4_TEST_FAILMESSAGE', `dnl fprintf(stderr,"Invalid line.\n"); exit(-1); ')dnl close failmessage define(`M4_TEST_POSTAMBLE', `dnl -int main (void) +int main (int argc, char **argv) { +ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl + FILE *fp; +')dnl table_serialization yyin = stdin; yyout = stdout; +ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl + if((fp = fopen(argv[1],"rb"))== NULL) + YY_FATAL_ERROR("could not open tables file for reading"); + + if(yytables_fload(fp) < 0) + YY_FATAL_ERROR("yytables_fload returned < 0"); + ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') +')dnl table_serialization while( yylex() ) { } +ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl + yytables_destroy(); +')dnl table_serialization printf("TEST RETURNING OK.\n"); return 0; } @@ -59,15 +79,29 @@ define(`M4_TEST_PREAMBLE', `dnl ')dnl close preamble define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"Invalid line.\n"); exit(-1);') define(`M4_TEST_POSTAMBLE', `dnl -int main (void) +int main (int argc, char **argv) { +ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl + FILE *fp; +')dnl table_serialization yyscan_t lexer; yylex_init( &lexer ); yyset_out ( stdout,lexer); yyset_in ( stdin, lexer); +ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl + if((fp = fopen(argv[1],"rb"))== NULL) + YY_FATAL_ERROR("could not open tables file for reading"); + + if(yytables_fload(fp, yyscanner) < 0) + YY_FATAL_ERROR("yytables_fload returned < 0"); + ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') +')dnl table_serialization while( yylex(lexer) ) { } +ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl + yytables_destroy(yyscanner); +')dnl table_serialization yylex_destroy( lexer ); printf("TEST RETURNING OK.\n"); return 0; @@ -95,7 +129,7 @@ func main(void) { lexer := new(FlexLexer) lexer.yysetOut(os.Stdout) lexer.yysetIn(os.Stdin) - for lexer.yylex() { + for lexer.yylex() != EOF { } fmt.Printf("TEST RETURNING OK.\n") os.Exit(0) diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 70c0501..822fa06 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -6,7 +6,7 @@ # The single argument is a testfile name to be generated. # With the -d option, dump to stdourather than crating the file. # -# A typical test load name: tableopts_opt_nr_Ca_opt, this breaks +# A typical table test load name: tableopts_opt_nr_Ca_opt, this breaks # down as tableopts_{tag}_{backend}_{compression}_{tag}. # The backend field can be nr, r, c99 and will eventually have more values. # The compression options are the flags that woulld nprmally be passed to @@ -24,7 +24,8 @@ testfile=$1 trap "rm -f /tmp/testmaker$$" EXIT INT QUIT set `echo $testfile | tr '.' ' '` -if [ "$2" != "l" ] +for last; do :; done +if [ "${last}" != "l" ] then echo "$0: Don't know how to make anything but a .l file: $parts" >&2 exit 1 @@ -33,6 +34,7 @@ fi set -- `echo $1 | tr '_' ' '` stem=$1 options="" +backend=nr for part in $*; do # This is the only pace in this dcript that you need to modify # to add a new back end - just add a line on the pattern of @@ -44,17 +46,20 @@ for part in $*; do cpp|nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; + ser) serialization=yes ;; + ver) serialization=yes; options="${options} tables-verify" ;; esac done -if [ -z "$backend" ] -then - echo "Can't identify a back end part in ${testfile}" >&2; - exit 1; -fi - ( printf "define(\`M4_TEST_BACKEND', \`${backend}')dnl\n" + if [ -n "${verification}" ] ; then + printf "define(\`M4_TEST_TABLE_VERIFICATION', \`')dnl\n" + fi + if [ -n "${serialization}" ] ; then + options="${options} tables-file=\"${testfile%.l}.tables\"" + printf "define(\`M4_TEST_TABLE_SERIALIZATION', \`')dnl\n" + fi if [ -z "${options}" ] ; then printf "define(\`M4_TEST_OPTIONS', \`')dnl\n" else @@ -62,3 +67,5 @@ fi fi cat testmaker.m4 ${stem}.rules ) | m4 >${outdev} + +# end diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 33f576a..0d15c4e 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -43,6 +43,9 @@ if [ ! -f ${INPUT_NAME} ] ; then INPUT_NAME=`echo ${INPUT_NAME} | sed -e 's/_[a-z0-9]*.txt$/.txt/'` fi +# We may want to compare the input fed to the test binary to its output. +# Equality means success, because it means ao character leaked past a +# token match to echo. if [ $DO_COMPARISON = 1 ] ; then TEST_OUTPUT=`$TESTNAME < $INPUT_NAME` REF_OUTPUT=`$TESTNAME 1 < $INPUT_NAME` @@ -50,6 +53,10 @@ if [ $DO_COMPARISON = 1 ] ; then exit $? fi +case ${TESTNAME} in + *ver|*ser) USE_TABLES=1 ;; +esac + if [ $INPUT_COUNT -gt 1 ] ; then $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} ${INPUT_NAME} exit $? -- cgit v1.2.1 From 1726f1ca2dd92daa3c845034c8375171c867b85a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 20 Oct 2020 16:28:22 -0400 Subject: Documentation polishing. --- tests/Makefile.am | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index f5f3189..c10541e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,6 +52,14 @@ AM_ONE_LOG_FLAGS = -1 -d $(srcdir) AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src +# A full cross-matrix of all back ends (nr, r, c99) and all tess that +# could potentially apply to them would push the time cost of "make check" +# uncomfortably highm and the problem will worsen as more back ends are added. +# This list tries to explout orthogonalities in the C skeleton file to test +# smaller set (hopeflly) spand the behavior space prett well. Akas, new +# langyage back ends won;'t have that slaclk to exploit, The test set for the +# c99 back end should be a model for these. + check_PROGRAMS = $(simple_tests) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) generated = \ @@ -196,8 +204,6 @@ quotes_cpp_SOURCES = quotes_cpp.l quotes_c99_SOURCES = quotes_c99.l reject_nr_SOURCES = reject_nr.l reject_r_SOURCES = reject_r.l -reject_ver_table_SOURCES = reject_ver.table.l -reject_ser_table_SOURCES = reject_ser.table.l rescan_nr_direct_SOURCES = rescan_nr.direct.l rescan_r_direct_SOURCES = rescan_r.direct.l string_nr_SOURCES = string_nr.l @@ -229,7 +235,7 @@ dist-hook: rm -f $(distdir)/$$file \ ; done -EXTRA_DIST = README *.txt +EXTRA_DIST = README *.txt testmaker.m4 dist_noinst_SCRIPTS = \ tableopts.sh @@ -237,7 +243,8 @@ dist_noinst_SCRIPTS = \ dist_check_SCRIPTS = \ options.cn \ testwrapper-direct.sh \ - testwrapper.sh + testwrapper.sh \ + testmaker.sh pthread_pthread_LDADD = @LIBPTHREAD@ -- cgit v1.2.1 From 8be9597d7d27b0db9f51922cbd9d3a87965b4445 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Wed, 21 Oct 2020 17:08:22 -0400 Subject: Use shellcheck on most of the shell scripts in the repository. And add a "lint" target that runs shellcheck on them. --- Makefile.am | 5 ++++- src/mkskel.sh | 4 +++- tests/tableopts.sh | 6 +++--- tests/testmaker.sh | 48 ++++++++++++++++++++++++++++----------------- tests/testwrapper-direct.sh | 9 ++++++--- tests/testwrapper.sh | 40 +++++++++++++++++++++++++------------ 6 files changed, 73 insertions(+), 39 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8dac6f5..409ab7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,5 +89,8 @@ install-exec-hook: cd $(DESTDIR)$(bindir) && \ $(LN_S) -f flex$(EXEEXT) flex++$(EXEEXT) +lint: + shellcheck -f gcc tests/*.sh src/*.sh *.sh + .PHONY: libfl install-libfl uninstall-libfl clean-libfl \ - ChangeLog indent + ChangeLog indent lint diff --git a/src/mkskel.sh b/src/mkskel.sh index 6eb5b60..8343722 100755 --- a/src/mkskel.sh +++ b/src/mkskel.sh @@ -33,7 +33,9 @@ case $VERSION in *[!0-9.]*) echo 'Invalid version number' >&2; exit 1;; esac IFS=. -set $VERSION +# we do want word splitting, so we won't put double quotes around it (see IFS above) +# shellcheck disable=2086 +set -- $VERSION sed 's/4_/a4_/g s/m4preproc_/m4_/g ' "$srcdir/${lang}-flex.skl" | diff --git a/tests/tableopts.sh b/tests/tableopts.sh index 60fcee8..8348aee 100755 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -19,7 +19,7 @@ for kind in opt ser ver ; do for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do bare_opt=${opt#-} # The filenames must work on case-insensitive filesystems. - bare_opt=`echo ${bare_opt}| sed 's/F$/_F/'` + bare_opt=$(echo ${bare_opt}| sed 's/F$/_F/') testname=tableopts_${kind}_${threading}-${bare_opt}.${kind} if [ "${TABLEOPTS_TESTS}" = "" ] ;then @@ -45,6 +45,6 @@ EOF done done -echo TABLEOPTS_TESTS = ${TABLEOPTS_TESTS} +echo TABLEOPTS_TESTS = "${TABLEOPTS_TESTS}" echo -echo tableopts_tables = ${tableopts_tables} +echo tableopts_tables = "${tableopts_tables}" diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 822fa06..4c81e45 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -21,21 +21,25 @@ fi testfile=$1 -trap "rm -f /tmp/testmaker$$" EXIT INT QUIT +trap 'rm -f /tmp/testmaker$$' EXIT INT QUIT -set `echo $testfile | tr '.' ' '` +# we do want word splitting, so we won't put double quotes around it +# shellcheck disable=2046 +set $(echo "${testfile}" | tr '.' ' ') for last; do :; done if [ "${last}" != "l" ] then - echo "$0: Don't know how to make anything but a .l file: $parts" >&2 + echo "$0: Don't know how to make anything but a .l file: ${last}" >&2 exit 1 fi -set -- `echo $1 | tr '_' ' '` +# ditto +# shellcheck disable=2046 +set -- $(echo "${1}" | tr '_' ' ') stem=$1 options="" backend=nr -for part in $*; do +for part in "$@"; do # This is the only pace in this dcript that you need to modify # to add a new back end - just add a line on the pattern of # the c99 one. Of course testmaker.m4 will require the @@ -43,29 +47,37 @@ for part in $*; do # # Yes, cpp is an alias for nr. case ${part} in - cpp|nr) backend=nr; ;; - r) backend=r; options="${options} reentrant";; - c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; - ser) serialization=yes ;; - ver) serialization=yes; options="${options} tables-verify" ;; + cpp|nr) backend=nr; ;; + r) backend=r; options="${options} reentrant";; + c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; + ser) serialization=yes ;; + ver) serialization=yes; options="${options} tables-verify" ;; esac done +verification= + +m4def() { + define="${1}" + value="${2}" + # we'll be careful, I promise + printf "define(\`%s', \`${value}')dnl\n" "${define}" +} ( - printf "define(\`M4_TEST_BACKEND', \`${backend}')dnl\n" + m4def M4_TEST_BACKEND "${backend}" if [ -n "${verification}" ] ; then - printf "define(\`M4_TEST_TABLE_VERIFICATION', \`')dnl\n" + m4def M4_TEST_TABLE_VERIFICATION fi if [ -n "${serialization}" ] ; then - options="${options} tables-file=\"${testfile%.l}.tables\"" - printf "define(\`M4_TEST_TABLE_SERIALIZATION', \`')dnl\n" + options="${options} tables-file=\"${testfile%.l}.tables\"" + m4def M4_TEST_TABLE_SERIALIZATION fi if [ -z "${options}" ] ; then - printf "define(\`M4_TEST_OPTIONS', \`')dnl\n" + m4def M4_TEST_OPTIONS else - printf "define(\`M4_TEST_OPTIONS', \`%%option${options}\n')dnl\n" + m4def M4_TEST_OPTIONS "%%option${options}\n" fi - cat testmaker.m4 ${stem}.rules -) | m4 >${outdev} + cat testmaker.m4 "${stem}.rules" +) | m4 >"${outdev}" # end diff --git a/tests/testwrapper-direct.sh b/tests/testwrapper-direct.sh index 9160501..53d59a0 100755 --- a/tests/testwrapper-direct.sh +++ b/tests/testwrapper-direct.sh @@ -9,12 +9,15 @@ while getopts :b:s: OPTION ; do case $OPTION in b) BINARY_DIR=$OPTARG ;; s) SOURCE_DIR=$OPTARG ;; + *) echo "Usage: ${0} [-b BINARY_DIR] [-s SOURCE_DIR] TESTNAME" + exit 1 + ;; esac done -shift $(($OPTIND-1)) +shift $((OPTIND-1)) TESTNAME=$1 -INPUT_NAME=`basename "${TESTNAME%.exe}"`.txt +INPUT_NAME=$(basename "${TESTNAME%.exe}").txt -cd ${SOURCE_DIR} && ${BINARY_DIR}/${TESTNAME} ${INPUT_NAME} +cd "${SOURCE_DIR}" && "${BINARY_DIR}/${TESTNAME}" "${INPUT_NAME}" diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 0d15c4e..46fe31c 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -22,33 +22,45 @@ while getopts :d:i:rt1 OPTION ; do else INPUT_NAME="$INPUT_NAME $OPTARG" fi - INPUT_COUNT=$(($INPUT_COUNT+1)) + INPUT_COUNT=$((INPUT_COUNT+1)) ;; r) USE_REDIRECT=1 ;; t) USE_TABLES=1 ;; 1) DO_COMPARISON=1 ;; + *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] [-t] [-1] TESTNAME" + exit 1 + ;; esac done -shift $(($OPTIND-1)) +shift $((OPTIND-1)) TESTNAME=$1 # There may be a specific input file for this test -INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename "${TESTNAME%.exe}"`.txt} +INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/$(basename "${TESTNAME%.exe}").txt} # If it doesn't exist, try stripping out a backend suffix. # There might be a generic input for all tests with this stem. # For this purpose we consider _r and _nr to be back ends. -if [ ! -f ${INPUT_NAME} ] ; then - INPUT_NAME=`echo ${INPUT_NAME} | sed -e 's/_[a-z0-9]*.txt$/.txt/'` -fi +inputs=$INPUT_NAME +INPUT_NAME= +for input in $inputs; do + if [ ! -f "${input}" ] ; then + input=$(echo "${input}" | sed -e 's/_[a-z0-9]*.txt$/.txt/') + fi + if [ "${INPUT_NAME}" = "" ] ; then + INPUT_NAME="${input}" + else + INPUT_NAME="${INPUT_NAME} ${input}" + fi +done # We may want to compare the input fed to the test binary to its output. -# Equality means success, because it means ao character leaked past a +# Equality means success, because it means no character leaked past a # token match to echo. if [ $DO_COMPARISON = 1 ] ; then - TEST_OUTPUT=`$TESTNAME < $INPUT_NAME` - REF_OUTPUT=`$TESTNAME 1 < $INPUT_NAME` + TEST_OUTPUT=$($TESTNAME < "$INPUT_NAME") + REF_OUTPUT=$($TESTNAME 1 < "$INPUT_NAME") test "$TEST_OUTPUT" -eq "$REF_OUTPUT" exit $? fi @@ -58,15 +70,17 @@ case ${TESTNAME} in esac if [ $INPUT_COUNT -gt 1 ] ; then - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} ${INPUT_NAME} + # INPUT_NAME has multiple filenames, so we do want word expansion + # shellcheck disable=SC2086 + $TESTNAME ${USE_TABLES:+"${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables"} ${INPUT_NAME} exit $? fi -if [ -f ${INPUT_NAME} ] ; then +if [ -f "${INPUT_NAME}" ] ; then if [ $USE_REDIRECT = 1 ] ; then - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < $INPUT_NAME + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < "$INPUT_NAME" else - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} $INPUT_NAME + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} "$INPUT_NAME" fi else $TESTNAME -- cgit v1.2.1 From a110b3b67db86d757b4ccf88dba306b94ebf679d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 17:13:01 -0400 Subject: Simplify testwrapper.sh by abolishing the -t option. It's easy enough to tell if a testfile wants a table by looking at its name. Getting rid of this option is a step towards putting all tableopts tests in the generated set so they are trivially portable to new back ends. --- tests/Makefile.am | 4 ++-- tests/testwrapper.sh | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index c10541e..8904d45 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -361,7 +361,7 @@ tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t +AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r tableopts_ser_nr%.c: tableopts.l4 $(FLEX) $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst _F,F,$*) -o $@ $< @@ -376,7 +376,7 @@ tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t +AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r tableopts_ver_nr%.c: tableopts.l4 $(FLEX) $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 46fe31c..0b9088f 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -13,7 +13,7 @@ INPUT_COUNT=0 USE_REDIRECT=0 DO_COMPARISON=0 -while getopts :d:i:rt1 OPTION ; do +while getopts :d:i:r1 OPTION ; do case $OPTION in d) INPUT_DIRECTORY=$OPTARG ;; i) @@ -25,7 +25,6 @@ while getopts :d:i:rt1 OPTION ; do INPUT_COUNT=$((INPUT_COUNT+1)) ;; r) USE_REDIRECT=1 ;; - t) USE_TABLES=1 ;; 1) DO_COMPARISON=1 ;; *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] [-t] [-1] TESTNAME" exit 1 @@ -65,8 +64,12 @@ if [ $DO_COMPARISON = 1 ] ; then exit $? fi +# Detect if the test wants a table argument. If it does, the test maker will have generated +# a tables=-file option do that the a table file named afte the test was created when the +# scanner was built. Thus we can assume that it will be looking for the table data at +# the matching path we're about to generate. case ${TESTNAME} in - *ver|*ser) USE_TABLES=1 ;; + *ver|*ser|*_ver_*|*_ser_*) USE_TABLES=1 ;; esac if [ $INPUT_COUNT -gt 1 ] ; then -- cgit v1.2.1 From d9826a40d92c2546f1755e9ef82b34252dffac79 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 17:18:44 -0400 Subject: Use CxF rather than C_F to prevent case ambiguity, so... ......test names can be split on _ characters in order to parse the compression options desired in the test. --- tests/Makefile.am | 12 ++++++------ tests/tableopts.am | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 8904d45..41ef3fc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -349,13 +349,13 @@ OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r tableopts_opt_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:_F=F) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:xF=F) -o $@ $< tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c $(AM_V_CC)$(COMPILE) -c -o $@ $< tableopts_opt_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst xF,F,$*) -o $@ $< tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< @@ -364,13 +364,13 @@ SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r tableopts_ser_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst xF,F,$*) -o $@ $< tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< tableopts_ser_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst xF,F,$*) -o $@ $< tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< @@ -379,7 +379,7 @@ VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r tableopts_ver_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst xF,F,$*) -o $@ $< tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< @@ -388,7 +388,7 @@ tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT) $(AM_V_CCLD)$(LINK) -o $@ $^ tableopts_ver_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $< + $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst xF,F,$*) -o $@ $< tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< diff --git a/tests/tableopts.am b/tests/tableopts.am index 8460c04..f20ca12 100644 --- a/tests/tableopts.am +++ b/tests/tableopts.am @@ -13,9 +13,9 @@ tableopts_opt_nr_Cf_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Cf.opt$(EXEEXT): tableopts_opt_nr-Cf.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_opt_nr_C_F_opt_SOURCES = tableopts.l4 +tableopts_opt_nr_CxF_opt_SOURCES = tableopts.l4 -tableopts_opt_nr-C_F.opt$(EXEEXT): tableopts_opt_nr-C_F.$(OBJEXT) +tableopts_opt_nr-CxF.opt$(EXEEXT): tableopts_opt_nr-CxF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_opt_nr_Cm_opt_SOURCES = tableopts.l4 @@ -38,9 +38,9 @@ tableopts_opt_nr_Caef_opt_SOURCES = tableopts.l4 tableopts_opt_nr-Caef.opt$(EXEEXT): tableopts_opt_nr-Caef.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_opt_nr_Cae_F_opt_SOURCES = tableopts.l4 +tableopts_opt_nr_CaexF_opt_SOURCES = tableopts.l4 -tableopts_opt_nr-Cae_F.opt$(EXEEXT): tableopts_opt_nr-Cae_F.$(OBJEXT) +tableopts_opt_nr-CaexF.opt$(EXEEXT): tableopts_opt_nr-CaexF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_opt_nr_Cam_opt_SOURCES = tableopts.l4 @@ -68,9 +68,9 @@ tableopts_opt_r_Cf_opt_SOURCES = tableopts.l4 tableopts_opt_r-Cf.opt$(EXEEXT): tableopts_opt_r-Cf.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_opt_r_C_F_opt_SOURCES = tableopts.l4 +tableopts_opt_r_CxF_opt_SOURCES = tableopts.l4 -tableopts_opt_r-C_F.opt$(EXEEXT): tableopts_opt_r-C_F.$(OBJEXT) +tableopts_opt_r-CxF.opt$(EXEEXT): tableopts_opt_r-CxF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_opt_r_Cm_opt_SOURCES = tableopts.l4 @@ -93,9 +93,9 @@ tableopts_opt_r_Caef_opt_SOURCES = tableopts.l4 tableopts_opt_r-Caef.opt$(EXEEXT): tableopts_opt_r-Caef.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_opt_r_Cae_F_opt_SOURCES = tableopts.l4 +tableopts_opt_r_CaexF_opt_SOURCES = tableopts.l4 -tableopts_opt_r-Cae_F.opt$(EXEEXT): tableopts_opt_r-Cae_F.$(OBJEXT) +tableopts_opt_r-CaexF.opt$(EXEEXT): tableopts_opt_r-CaexF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_opt_r_Cam_opt_SOURCES = tableopts.l4 @@ -123,9 +123,9 @@ tableopts_ser_nr_Cf_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Cf.ser$(EXEEXT): tableopts_ser_nr-Cf.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ser_nr_C_F_ser_SOURCES = tableopts.l4 +tableopts_ser_nr_CxF_ser_SOURCES = tableopts.l4 -tableopts_ser_nr-C_F.ser$(EXEEXT): tableopts_ser_nr-C_F.$(OBJEXT) +tableopts_ser_nr-CxF.ser$(EXEEXT): tableopts_ser_nr-CxF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ser_nr_Cm_ser_SOURCES = tableopts.l4 @@ -148,9 +148,9 @@ tableopts_ser_nr_Caef_ser_SOURCES = tableopts.l4 tableopts_ser_nr-Caef.ser$(EXEEXT): tableopts_ser_nr-Caef.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ser_nr_Cae_F_ser_SOURCES = tableopts.l4 +tableopts_ser_nr_CaexF_ser_SOURCES = tableopts.l4 -tableopts_ser_nr-Cae_F.ser$(EXEEXT): tableopts_ser_nr-Cae_F.$(OBJEXT) +tableopts_ser_nr-CaexF.ser$(EXEEXT): tableopts_ser_nr-CaexF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ser_nr_Cam_ser_SOURCES = tableopts.l4 @@ -178,9 +178,9 @@ tableopts_ser_r_Cf_ser_SOURCES = tableopts.l4 tableopts_ser_r-Cf.ser$(EXEEXT): tableopts_ser_r-Cf.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ser_r_C_F_ser_SOURCES = tableopts.l4 +tableopts_ser_r_CxF_ser_SOURCES = tableopts.l4 -tableopts_ser_r-C_F.ser$(EXEEXT): tableopts_ser_r-C_F.$(OBJEXT) +tableopts_ser_r-CxF.ser$(EXEEXT): tableopts_ser_r-CxF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ser_r_Cm_ser_SOURCES = tableopts.l4 @@ -203,9 +203,9 @@ tableopts_ser_r_Caef_ser_SOURCES = tableopts.l4 tableopts_ser_r-Caef.ser$(EXEEXT): tableopts_ser_r-Caef.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ser_r_Cae_F_ser_SOURCES = tableopts.l4 +tableopts_ser_r_CaexF_ser_SOURCES = tableopts.l4 -tableopts_ser_r-Cae_F.ser$(EXEEXT): tableopts_ser_r-Cae_F.$(OBJEXT) +tableopts_ser_r-CaexF.ser$(EXEEXT): tableopts_ser_r-CaexF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ser_r_Cam_ser_SOURCES = tableopts.l4 @@ -233,9 +233,9 @@ tableopts_ver_nr_Cf_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Cf.ver$(EXEEXT): tableopts_ver_nr-Cf.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ver_nr_C_F_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_CxF_ver_SOURCES = tableopts.l4 -tableopts_ver_nr-C_F.ver$(EXEEXT): tableopts_ver_nr-C_F.$(OBJEXT) +tableopts_ver_nr-CxF.ver$(EXEEXT): tableopts_ver_nr-CxF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ver_nr_Cm_ver_SOURCES = tableopts.l4 @@ -258,9 +258,9 @@ tableopts_ver_nr_Caef_ver_SOURCES = tableopts.l4 tableopts_ver_nr-Caef.ver$(EXEEXT): tableopts_ver_nr-Caef.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ver_nr_Cae_F_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_CaexF_ver_SOURCES = tableopts.l4 -tableopts_ver_nr-Cae_F.ver$(EXEEXT): tableopts_ver_nr-Cae_F.$(OBJEXT) +tableopts_ver_nr-CaexF.ver$(EXEEXT): tableopts_ver_nr-CaexF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ver_nr_Cam_ver_SOURCES = tableopts.l4 @@ -288,9 +288,9 @@ tableopts_ver_r_Cf_ver_SOURCES = tableopts.l4 tableopts_ver_r-Cf.ver$(EXEEXT): tableopts_ver_r-Cf.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ver_r_C_F_ver_SOURCES = tableopts.l4 +tableopts_ver_r_CxF_ver_SOURCES = tableopts.l4 -tableopts_ver_r-C_F.ver$(EXEEXT): tableopts_ver_r-C_F.$(OBJEXT) +tableopts_ver_r-CxF.ver$(EXEEXT): tableopts_ver_r-CxF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ver_r_Cm_ver_SOURCES = tableopts.l4 @@ -313,9 +313,9 @@ tableopts_ver_r_Caef_ver_SOURCES = tableopts.l4 tableopts_ver_r-Caef.ver$(EXEEXT): tableopts_ver_r-Caef.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -tableopts_ver_r_Cae_F_ver_SOURCES = tableopts.l4 +tableopts_ver_r_CaexF_ver_SOURCES = tableopts.l4 -tableopts_ver_r-Cae_F.ver$(EXEEXT): tableopts_ver_r-Cae_F.$(OBJEXT) +tableopts_ver_r-CaexF.ver$(EXEEXT): tableopts_ver_r-CaexF.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< tableopts_ver_r_Cam_ver_SOURCES = tableopts.l4 @@ -328,6 +328,6 @@ tableopts_ver_r_Caem_ver_SOURCES = tableopts.l4 tableopts_ver_r-Caem.ver$(EXEEXT): tableopts_ver_r-Caem.$(OBJEXT) $(AM_V_CCLD)$(LINK) $< -TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-C_F.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-Cae_F.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-C_F.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-Cae_F.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-C_F.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-Cae_F.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-C_F.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-Cae_F.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-C_F.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-Cae_F.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-C_F.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-Cae_F.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver +TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver -tableopts_tables = tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-C_F.ser.tables tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-Cae_F.ser.tables tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser.tables tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser.tables tableopts_ser_r-C_F.ser.tables tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser.tables tableopts_ser_r-Cae_F.ser.tables tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser.tables tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-C_F.ver.tables tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-Cae_F.ver.tables tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver.tables tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver.tables tableopts_ver_r-C_F.ver.tables tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver.tables tableopts_ver_r-Cae_F.ver.tables tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver.tables +tableopts_tables = tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser.tables tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser.tables tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver.tables tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver.tables -- cgit v1.2.1 From cd8e62a1b732eacf77757867f6adb966965231b8 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 17:25:24 -0400 Subject: Teach testwrapper.sh to parse compression options from testnames. --- tests/testmaker.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 4c81e45..aa8b47b 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -10,7 +10,7 @@ # down as tableopts_{tag}_{backend}_{compression}_{tag}. # The backend field can be nr, r, c99 and will eventually have more values. # The compression options are the flags that woulld nprmally be passed to -# Flex; the possibilities are Ca Ce Cf C_F Cm Cem Cae Caef Cae_F Cam Caem. +# Flex; the possibilities are Ca Ce Cf CxF Cm Cem Cae Caef CaexF Cam Caem. # if [ "$1" = -d ] ; then shift @@ -52,6 +52,17 @@ for part in "$@"; do c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; ser) serialization=yes ;; ver) serialization=yes; options="${options} tables-verify" ;; + Ca) options="${options} align" ;; + Ce) options="${options} ecs" ;; + Cf) options="${options} full" ;; + CxF) options="${options} fast" ;; + Cm) options="${options} meta-ecs";; + Cem) options="${options} ecs meta-ecs" ;; + Cae) options="${options} align ecs" ;; + Caef) options="${options} align ecs full" ;; + CaexF) options="${options} algin ecs fast" ;; + Cam) options="${options} align meta-ecs" ;; + Caem) options="${options} align ecs meta-ecs" ;; esac done verification= -- cgit v1.2.1 From 1200a3da64d773dd85246aaa9792e92bceafb9bf Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 07:35:53 -0400 Subject: Documentation polishing. --- tests/README | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/README b/tests/README index f24b895..be487ed 100644 --- a/tests/README +++ b/tests/README @@ -82,10 +82,19 @@ not interesting. Most tests occur in groups with a common stem in the names, like alloc_extra_ or ccl_. These are exercising the same token grammar under different back ends. As new target languages are added these -groups of patallel tests will grow. Tests that are not part of one of +groups of parallel tests will grow. Tests that are not part of one of these series are usually of features supported on the default cpp back end only. +The "generated" tests are made by wrapping boilerplate code around a +rules file. The assumption is that the test binary should consume its +test file, exercising some set of Flex features and not allowing +any ko leaxh ti strabdard output + +If you can express your test as a ruleset within in this orotocol, +please do so. Those tests are easy to port to new back ends, as that +whole job can be done by enhabcing testmaker.m4. + WHY SOME TESTS ARE MISSING The "top" test is backend-independent; what it's really testing -- cgit v1.2.1 From 2fb90cc835cdcc5ca942b9afac074850ac6ecc4f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 19:45:27 -0400 Subject: Generate some dependency relationships... ...rather than maintaining them by hand. --- tests/Makefile.am | 65 +++--------------------------------------------------- tests/tableopts.am | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/tableopts.sh | 11 ++++++++- 3 files changed, 77 insertions(+), 63 deletions(-) mode change 100755 => 100644 tests/tableopts.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 41ef3fc..f1b1094 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,7 +29,7 @@ TESTS = $(check_PROGRAMS) options.cn # automake knows how to distinguish between the various kinds of tests # we have. -TEST_EXTENSIONS = .reject .table .direct .cn .i3 .pthread .one .opt .ser .ver +TEST_EXTENSIONS = .table .direct .cn .i3 .pthread .one .opt .ser .ver LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_LOG_FLAGS = -d $(srcdir) -r @@ -141,12 +141,6 @@ ONE_TESTS = \ alloc_extra_cpp_SOURCES = alloc_extra_cpp.l alloc_extra_c99_SOURCES = alloc_extra_c99.l -array_nr_SOURCES = array_nr.l -array_r_SOURCES = array_r.l -array_c99_SOURCES = array_c99.l -basic_nr_SOURCES = basic_nr.l -basic_r_SOURCES = basic_r.l -basic_c99_SOURCES = basic_c99.l if HAVE_BISON bison_nr_SOURCES = bison_nr_scanner.l bison_nr_parser.y bison_nr_main.c nodist_bison_nr_SOURCES = bison_nr_parser.h bison_nr_scanner.h @@ -170,8 +164,6 @@ cxx_yywrap_i3_SOURCES = cxx_yywrap.ll debug_nr_SOURCES = debug_nr.l debug_r_SOURCES = debug_r.l debug_c99_SOURCES = debug_c99.l -extended_cpp_SOURCES = extended_cpp.l -extended_c99_SOURCES = extended_c99.l header_nr_SOURCES = header_nr_scanner.l header_nr_main.c nodist_header_nr_SOURCES = header_nr_scanner.h header_r_SOURCES = header_r_scanner.l header_r_main.c @@ -181,7 +173,7 @@ include_by_push_direct_SOURCES = include_by_push.direct.l include_by_reentrant_direct_SOURCES = include_by_reentrant.direct.l lineno_nr_one_SOURCES = lineno_nr.l lineno_r_one_SOURCES = lineno_r.l -lineno_r_one_SOURCES = lineno_c99.l +lineno_c99_one_SOURCES = lineno_c99.l lineno_trailing_one_SOURCES = lineno_trailing.l mem_nr_SOURCES = mem_nr.l mem_r_SOURCES = mem_r.l @@ -198,12 +190,8 @@ prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l prefix_c99_SOURCES = prefix_c99.l pthread_pthread_SOURCES = pthread.l -quoteincomment_cpp_SOURCES = quoteincomment_cpp.l -quoteincomment_c99_SOURCES = quoteincomment_c99.l quotes_cpp_SOURCES = quotes_cpp.l quotes_c99_SOURCES = quotes_c99.l -reject_nr_SOURCES = reject_nr.l -reject_r_SOURCES = reject_r.l rescan_nr_direct_SOURCES = rescan_nr.direct.l rescan_r_direct_SOURCES = rescan_r.direct.l string_nr_SOURCES = string_nr.l @@ -335,7 +323,7 @@ top.h: top.c # it can be / is generated by a shell script, tableopts.sh. $(srcdir)/tableopts.am: tableopts.sh - $(SHELL) $(srcdir)/tableopts.sh > $(srcdir)/tableopts.am + $(SHELL) $(srcdir)/tableopts.sh $(generated) > $(srcdir)/tableopts.am include $(srcdir)/tableopts.am @@ -393,51 +381,4 @@ tableopts_ver_r%.c: tableopts.l4 $(FLEX) tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< -# Rules for tests generated from rulesets start here -# FIXME: These should be generated - -array_nr.l: array.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -array_r.l: array.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -array_c99.l: array.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -basic_nr.l: basic.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -basic_r.l: basic.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -basic_c99.l: basic.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -extended_cpp.l: extended.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -extended_c99.l: extended.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -quoteincomment_cpp.l: quoteincomment.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -quoteincomment_c99.l: quoteincomment.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -reject_nr.l: reject.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -reject_r.l: reject.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -reject_c99.l: reject.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -reject_ver.l: reject.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ - -reject_ser.l: reject.rules testmaker.m4 testmaker.sh - $(SHELL) testmaker.sh $@ diff --git a/tests/tableopts.am b/tests/tableopts.am index f20ca12..8e12269 100644 --- a/tests/tableopts.am +++ b/tests/tableopts.am @@ -331,3 +331,67 @@ tableopts_ver_r-Caem.ver$(EXEEXT): tableopts_ver_r-Caem.$(OBJEXT) TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver tableopts_tables = tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser.tables tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser.tables tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver.tables tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver.tables + +# Begin simple test rules + +array_nr_SOURCES = array_nr.l +array_nr.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +array_r_SOURCES = array_r.l +array_r.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +array_c99_SOURCES = array_c99.l +array_c99.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_nr_SOURCES = basic_nr.l +basic_nr.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_r_SOURCES = basic_r.l +basic_r.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_c99_SOURCES = basic_c99.l +basic_c99.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +extended_cpp_SOURCES = extended_cpp.l +extended_cpp.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +extended_c99_SOURCES = extended_c99.l +extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +quoteincomment_cpp_SOURCES = quoteincomment_cpp.l +quoteincomment_cpp.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +quoteincomment_c99_SOURCES = quoteincomment_c99.l +quoteincomment_c99.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_nr_SOURCES = reject_nr.l +reject_nr.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_r_SOURCES = reject_r.l +reject_r.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_c99_SOURCES = reject_c99.l +reject_c99.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_ver_SOURCES = reject_ver.l +reject_ver.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_ser_SOURCES = reject_ser.l +reject_ser.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +# End simple test rules diff --git a/tests/tableopts.sh b/tests/tableopts.sh old mode 100755 new mode 100644 index 8348aee..e51c1a9 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -19,7 +19,7 @@ for kind in opt ser ver ; do for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do bare_opt=${opt#-} # The filenames must work on case-insensitive filesystems. - bare_opt=$(echo ${bare_opt}| sed 's/F$/_F/') + bare_opt=$(echo ${bare_opt}| sed 's/F$/xF/') testname=tableopts_${kind}_${threading}-${bare_opt}.${kind} if [ "${TABLEOPTS_TESTS}" = "" ] ;then @@ -48,3 +48,12 @@ done echo TABLEOPTS_TESTS = "${TABLEOPTS_TESTS}" echo echo tableopts_tables = "${tableopts_tables}" +# User can pass in a list of tesrs for which ti geneate build productions +printf "\n# Begin simple test rules\n\n" +for test in $*; do + stem=`echo ${test} | sed s/_.*//` + echo "${test}_SOURCES = ${test}.l" + echo "${test}.l: \$(srcdir)/${stem}.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" + printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' +done +printf "# End simple test rules\n" -- cgit v1.2.1 From cf0f126d13f03614de662b6f44d66d1f3eaf7abd Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 21:03:09 -0400 Subject: The new test system now covers table option tests. --- tests/.gitignore | 1 + tests/Makefile.am | 48 +----- tests/tableopts.am | 462 +++++++++++++++++++++++------------------------------ tests/tableopts.l4 | 84 ---------- tests/tableopts.sh | 7 +- 5 files changed, 207 insertions(+), 395 deletions(-) delete mode 100644 tests/tableopts.l4 diff --git a/tests/.gitignore b/tests/.gitignore index 18c9a82..a453c37 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -142,6 +142,7 @@ string_r string_r.c string_c99 string_c99.c +tableopts*.l top top.[ch] yyextra_cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index f1b1094..1e1f3e5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,12 +52,12 @@ AM_ONE_LOG_FLAGS = -1 -d $(srcdir) AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -# A full cross-matrix of all back ends (nr, r, c99) and all tess that +# A full cross-matrix of all back ends (nr, r, c99) and all tests that # could potentially apply to them would push the time cost of "make check" -# uncomfortably highm and the problem will worsen as more back ends are added. +# uncomfortably high, and the problem will worsen as more back ends are added. # This list tries to explout orthogonalities in the C skeleton file to test -# smaller set (hopeflly) spand the behavior space prett well. Akas, new -# langyage back ends won;'t have that slaclk to exploit, The test set for the +# smaller set that (hopeflly) spans the behavior space pretty well. Alas, new +# language back ends won't have that slack to exploit. The test set for the # c99 back end should be a model for these. check_PROGRAMS = $(simple_tests) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) @@ -215,6 +215,7 @@ CLEANFILES = \ $(subst no_bison_stub.c, , $(shell ls *.c | grep -v "_main.c")) \ $(shell ls *.cc | grep -v "_main.cc") \ $(patsubst %, %.l, ${generated}) \ + tableopts*.l \ *.h *.tables dist-hook: @@ -336,49 +337,10 @@ tableopts_tests := $(tableopts_opttests) $(tableopts_vertests) $(tableopts_sert OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r -tableopts_opt_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:xF=F) -o $@ $< - -tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c - $(AM_V_CC)$(COMPILE) -c -o $@ $< - -tableopts_opt_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst xF,F,$*) -o $@ $< - -tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c - $(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $< - SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -tableopts_ser_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst xF,F,$*) -o $@ $< - -tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c - $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< - -tableopts_ser_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst xF,F,$*) -o $@ $< - -tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c - $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< - VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -tableopts_ver_nr%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst xF,F,$*) -o $@ $< - -tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c - $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $< - -tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT) - $(AM_V_CCLD)$(LINK) -o $@ $^ - -tableopts_ver_r%.c: tableopts.l4 $(FLEX) - $(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst xF,F,$*) -o $@ $< - -tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c - $(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $< - diff --git a/tests/tableopts.am b/tests/tableopts.am index 8e12269..196cd0a 100644 --- a/tests/tableopts.am +++ b/tests/tableopts.am @@ -1,332 +1,266 @@ -tableopts_opt_nr_Ca_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Ca.opt$(EXEEXT): tableopts_opt_nr-Ca.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Ce_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Ce.opt$(EXEEXT): tableopts_opt_nr-Ce.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Cf_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Cf.opt$(EXEEXT): tableopts_opt_nr-Cf.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_CxF_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-CxF.opt$(EXEEXT): tableopts_opt_nr-CxF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Cm_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Cm.opt$(EXEEXT): tableopts_opt_nr-Cm.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Cem_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Cem.opt$(EXEEXT): tableopts_opt_nr-Cem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Cae_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Cae.opt$(EXEEXT): tableopts_opt_nr-Cae.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Caef_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Caef.opt$(EXEEXT): tableopts_opt_nr-Caef.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_CaexF_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-CaexF.opt$(EXEEXT): tableopts_opt_nr-CaexF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Cam_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Cam.opt$(EXEEXT): tableopts_opt_nr-Cam.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_nr_Caem_opt_SOURCES = tableopts.l4 - -tableopts_opt_nr-Caem.opt$(EXEEXT): tableopts_opt_nr-Caem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Ca_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Ca.opt$(EXEEXT): tableopts_opt_r-Ca.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Ce_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Ce.opt$(EXEEXT): tableopts_opt_r-Ce.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Cf_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Cf.opt$(EXEEXT): tableopts_opt_r-Cf.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_CxF_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-CxF.opt$(EXEEXT): tableopts_opt_r-CxF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Cm_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Cm.opt$(EXEEXT): tableopts_opt_r-Cm.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Cem_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Cem.opt$(EXEEXT): tableopts_opt_r-Cem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Cae_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Cae.opt$(EXEEXT): tableopts_opt_r-Cae.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Caef_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Caef.opt$(EXEEXT): tableopts_opt_r-Caef.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_CaexF_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-CaexF.opt$(EXEEXT): tableopts_opt_r-CaexF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Cam_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Cam.opt$(EXEEXT): tableopts_opt_r-Cam.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_opt_r_Caem_opt_SOURCES = tableopts.l4 - -tableopts_opt_r-Caem.opt$(EXEEXT): tableopts_opt_r-Caem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Ca_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Ca.ser$(EXEEXT): tableopts_ser_nr-Ca.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Ce_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Ce.ser$(EXEEXT): tableopts_ser_nr-Ce.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Cf_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Cf.ser$(EXEEXT): tableopts_ser_nr-Cf.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_CxF_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-CxF.ser$(EXEEXT): tableopts_ser_nr-CxF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Cm_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Cm.ser$(EXEEXT): tableopts_ser_nr-Cm.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Cem_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Cem.ser$(EXEEXT): tableopts_ser_nr-Cem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Cae_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Cae.ser$(EXEEXT): tableopts_ser_nr-Cae.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Caef_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Caef.ser$(EXEEXT): tableopts_ser_nr-Caef.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_CaexF_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-CaexF.ser$(EXEEXT): tableopts_ser_nr-CaexF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Cam_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Cam.ser$(EXEEXT): tableopts_ser_nr-Cam.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_nr_Caem_ser_SOURCES = tableopts.l4 - -tableopts_ser_nr-Caem.ser$(EXEEXT): tableopts_ser_nr-Caem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< - -tableopts_ser_r_Ca_ser_SOURCES = tableopts.l4 +tableopts_opt_nr_Ca_opt_SOURCES = tableopts_opt_nr-Ca.opt.l +tableopts_opt_nr-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Ca.ser$(EXEEXT): tableopts_ser_r-Ca.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_nr_Ce_opt_SOURCES = tableopts_opt_nr-Ce.opt.l +tableopts_opt_nr-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Ce_ser_SOURCES = tableopts.l4 +tableopts_opt_nr_Cf_opt_SOURCES = tableopts_opt_nr-Cf.opt.l +tableopts_opt_nr-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Ce.ser$(EXEEXT): tableopts_ser_r-Ce.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_nr_CxF_opt_SOURCES = tableopts_opt_nr-CxF.opt.l +tableopts_opt_nr-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Cf_ser_SOURCES = tableopts.l4 +tableopts_opt_nr_Cm_opt_SOURCES = tableopts_opt_nr-Cm.opt.l +tableopts_opt_nr-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Cf.ser$(EXEEXT): tableopts_ser_r-Cf.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_nr_Cem_opt_SOURCES = tableopts_opt_nr-Cem.opt.l +tableopts_opt_nr-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_CxF_ser_SOURCES = tableopts.l4 +tableopts_opt_nr_Cae_opt_SOURCES = tableopts_opt_nr-Cae.opt.l +tableopts_opt_nr-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-CxF.ser$(EXEEXT): tableopts_ser_r-CxF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_nr_Caef_opt_SOURCES = tableopts_opt_nr-Caef.opt.l +tableopts_opt_nr-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Cm_ser_SOURCES = tableopts.l4 +tableopts_opt_nr_CaexF_opt_SOURCES = tableopts_opt_nr-CaexF.opt.l +tableopts_opt_nr-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Cm.ser$(EXEEXT): tableopts_ser_r-Cm.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_nr_Cam_opt_SOURCES = tableopts_opt_nr-Cam.opt.l +tableopts_opt_nr-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Cem_ser_SOURCES = tableopts.l4 +tableopts_opt_nr_Caem_opt_SOURCES = tableopts_opt_nr-Caem.opt.l +tableopts_opt_nr-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Cem.ser$(EXEEXT): tableopts_ser_r-Cem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_r_Ca_opt_SOURCES = tableopts_opt_r-Ca.opt.l +tableopts_opt_r-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Cae_ser_SOURCES = tableopts.l4 +tableopts_opt_r_Ce_opt_SOURCES = tableopts_opt_r-Ce.opt.l +tableopts_opt_r-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Cae.ser$(EXEEXT): tableopts_ser_r-Cae.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_r_Cf_opt_SOURCES = tableopts_opt_r-Cf.opt.l +tableopts_opt_r-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Caef_ser_SOURCES = tableopts.l4 +tableopts_opt_r_CxF_opt_SOURCES = tableopts_opt_r-CxF.opt.l +tableopts_opt_r-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Caef.ser$(EXEEXT): tableopts_ser_r-Caef.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_r_Cm_opt_SOURCES = tableopts_opt_r-Cm.opt.l +tableopts_opt_r-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_CaexF_ser_SOURCES = tableopts.l4 +tableopts_opt_r_Cem_opt_SOURCES = tableopts_opt_r-Cem.opt.l +tableopts_opt_r-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-CaexF.ser$(EXEEXT): tableopts_ser_r-CaexF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_r_Cae_opt_SOURCES = tableopts_opt_r-Cae.opt.l +tableopts_opt_r-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Cam_ser_SOURCES = tableopts.l4 +tableopts_opt_r_Caef_opt_SOURCES = tableopts_opt_r-Caef.opt.l +tableopts_opt_r-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Cam.ser$(EXEEXT): tableopts_ser_r-Cam.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_r_CaexF_opt_SOURCES = tableopts_opt_r-CaexF.opt.l +tableopts_opt_r-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r_Caem_ser_SOURCES = tableopts.l4 +tableopts_opt_r_Cam_opt_SOURCES = tableopts_opt_r-Cam.opt.l +tableopts_opt_r-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ser_r-Caem.ser$(EXEEXT): tableopts_ser_r-Caem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_opt_r_Caem_opt_SOURCES = tableopts_opt_r-Caem.opt.l +tableopts_opt_r-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Ca_ver_SOURCES = tableopts.l4 +tableopts_ser_nr_Ca_ser_SOURCES = tableopts_ser_nr-Ca.ser.l +tableopts_ser_nr-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Ca.ver$(EXEEXT): tableopts_ver_nr-Ca.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_nr_Ce_ser_SOURCES = tableopts_ser_nr-Ce.ser.l +tableopts_ser_nr-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Ce_ver_SOURCES = tableopts.l4 +tableopts_ser_nr_Cf_ser_SOURCES = tableopts_ser_nr-Cf.ser.l +tableopts_ser_nr-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Ce.ver$(EXEEXT): tableopts_ver_nr-Ce.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_nr_CxF_ser_SOURCES = tableopts_ser_nr-CxF.ser.l +tableopts_ser_nr-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Cf_ver_SOURCES = tableopts.l4 +tableopts_ser_nr_Cm_ser_SOURCES = tableopts_ser_nr-Cm.ser.l +tableopts_ser_nr-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Cf.ver$(EXEEXT): tableopts_ver_nr-Cf.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_nr_Cem_ser_SOURCES = tableopts_ser_nr-Cem.ser.l +tableopts_ser_nr-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_CxF_ver_SOURCES = tableopts.l4 +tableopts_ser_nr_Cae_ser_SOURCES = tableopts_ser_nr-Cae.ser.l +tableopts_ser_nr-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-CxF.ver$(EXEEXT): tableopts_ver_nr-CxF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_nr_Caef_ser_SOURCES = tableopts_ser_nr-Caef.ser.l +tableopts_ser_nr-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Cm_ver_SOURCES = tableopts.l4 +tableopts_ser_nr_CaexF_ser_SOURCES = tableopts_ser_nr-CaexF.ser.l +tableopts_ser_nr-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Cm.ver$(EXEEXT): tableopts_ver_nr-Cm.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_nr_Cam_ser_SOURCES = tableopts_ser_nr-Cam.ser.l +tableopts_ser_nr-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Cem_ver_SOURCES = tableopts.l4 +tableopts_ser_nr_Caem_ser_SOURCES = tableopts_ser_nr-Caem.ser.l +tableopts_ser_nr-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Cem.ver$(EXEEXT): tableopts_ver_nr-Cem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_r_Ca_ser_SOURCES = tableopts_ser_r-Ca.ser.l +tableopts_ser_r-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Cae_ver_SOURCES = tableopts.l4 +tableopts_ser_r_Ce_ser_SOURCES = tableopts_ser_r-Ce.ser.l +tableopts_ser_r-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Cae.ver$(EXEEXT): tableopts_ver_nr-Cae.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_r_Cf_ser_SOURCES = tableopts_ser_r-Cf.ser.l +tableopts_ser_r-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Caef_ver_SOURCES = tableopts.l4 +tableopts_ser_r_CxF_ser_SOURCES = tableopts_ser_r-CxF.ser.l +tableopts_ser_r-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Caef.ver$(EXEEXT): tableopts_ver_nr-Caef.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_r_Cm_ser_SOURCES = tableopts_ser_r-Cm.ser.l +tableopts_ser_r-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_CaexF_ver_SOURCES = tableopts.l4 +tableopts_ser_r_Cem_ser_SOURCES = tableopts_ser_r-Cem.ser.l +tableopts_ser_r-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-CaexF.ver$(EXEEXT): tableopts_ver_nr-CaexF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_r_Cae_ser_SOURCES = tableopts_ser_r-Cae.ser.l +tableopts_ser_r-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Cam_ver_SOURCES = tableopts.l4 +tableopts_ser_r_Caef_ser_SOURCES = tableopts_ser_r-Caef.ser.l +tableopts_ser_r-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Cam.ver$(EXEEXT): tableopts_ver_nr-Cam.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_r_CaexF_ser_SOURCES = tableopts_ser_r-CaexF.ser.l +tableopts_ser_r-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr_Caem_ver_SOURCES = tableopts.l4 +tableopts_ser_r_Cam_ser_SOURCES = tableopts_ser_r-Cam.ser.l +tableopts_ser_r-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_nr-Caem.ver$(EXEEXT): tableopts_ver_nr-Caem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ser_r_Caem_ser_SOURCES = tableopts_ser_r-Caem.ser.l +tableopts_ser_r-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Ca_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_Ca_ver_SOURCES = tableopts_ver_nr-Ca.ver.l +tableopts_ver_nr-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Ca.ver$(EXEEXT): tableopts_ver_r-Ca.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_nr_Ce_ver_SOURCES = tableopts_ver_nr-Ce.ver.l +tableopts_ver_nr-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Ce_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_Cf_ver_SOURCES = tableopts_ver_nr-Cf.ver.l +tableopts_ver_nr-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Ce.ver$(EXEEXT): tableopts_ver_r-Ce.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_nr_CxF_ver_SOURCES = tableopts_ver_nr-CxF.ver.l +tableopts_ver_nr-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Cf_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_Cm_ver_SOURCES = tableopts_ver_nr-Cm.ver.l +tableopts_ver_nr-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Cf.ver$(EXEEXT): tableopts_ver_r-Cf.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_nr_Cem_ver_SOURCES = tableopts_ver_nr-Cem.ver.l +tableopts_ver_nr-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_CxF_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_Cae_ver_SOURCES = tableopts_ver_nr-Cae.ver.l +tableopts_ver_nr-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-CxF.ver$(EXEEXT): tableopts_ver_r-CxF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_nr_Caef_ver_SOURCES = tableopts_ver_nr-Caef.ver.l +tableopts_ver_nr-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Cm_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_CaexF_ver_SOURCES = tableopts_ver_nr-CaexF.ver.l +tableopts_ver_nr-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Cm.ver$(EXEEXT): tableopts_ver_r-Cm.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_nr_Cam_ver_SOURCES = tableopts_ver_nr-Cam.ver.l +tableopts_ver_nr-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Cem_ver_SOURCES = tableopts.l4 +tableopts_ver_nr_Caem_ver_SOURCES = tableopts_ver_nr-Caem.ver.l +tableopts_ver_nr-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Cem.ver$(EXEEXT): tableopts_ver_r-Cem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_r_Ca_ver_SOURCES = tableopts_ver_r-Ca.ver.l +tableopts_ver_r-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Cae_ver_SOURCES = tableopts.l4 +tableopts_ver_r_Ce_ver_SOURCES = tableopts_ver_r-Ce.ver.l +tableopts_ver_r-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Cae.ver$(EXEEXT): tableopts_ver_r-Cae.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_r_Cf_ver_SOURCES = tableopts_ver_r-Cf.ver.l +tableopts_ver_r-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Caef_ver_SOURCES = tableopts.l4 +tableopts_ver_r_CxF_ver_SOURCES = tableopts_ver_r-CxF.ver.l +tableopts_ver_r-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Caef.ver$(EXEEXT): tableopts_ver_r-Caef.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_r_Cm_ver_SOURCES = tableopts_ver_r-Cm.ver.l +tableopts_ver_r-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_CaexF_ver_SOURCES = tableopts.l4 +tableopts_ver_r_Cem_ver_SOURCES = tableopts_ver_r-Cem.ver.l +tableopts_ver_r-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-CaexF.ver$(EXEEXT): tableopts_ver_r-CaexF.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_r_Cae_ver_SOURCES = tableopts_ver_r-Cae.ver.l +tableopts_ver_r-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Cam_ver_SOURCES = tableopts.l4 +tableopts_ver_r_Caef_ver_SOURCES = tableopts_ver_r-Caef.ver.l +tableopts_ver_r-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Cam.ver$(EXEEXT): tableopts_ver_r-Cam.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_r_CaexF_ver_SOURCES = tableopts_ver_r-CaexF.ver.l +tableopts_ver_r-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r_Caem_ver_SOURCES = tableopts.l4 +tableopts_ver_r_Cam_ver_SOURCES = tableopts_ver_r-Cam.ver.l +tableopts_ver_r-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ -tableopts_ver_r-Caem.ver$(EXEEXT): tableopts_ver_r-Caem.$(OBJEXT) - $(AM_V_CCLD)$(LINK) $< +tableopts_ver_r_Caem_ver_SOURCES = tableopts_ver_r-Caem.ver.l +tableopts_ver_r-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver diff --git a/tests/tableopts.l4 b/tests/tableopts.l4 deleted file mode 100644 index ac85c29..0000000 --- a/tests/tableopts.l4 +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -%} - -%option 8bit -%option nounput nomain noyywrap noinput -%option warn yylineno - - - -%% - -foo|bar ; -[[:digit:]]+ ; -[[:blank:]]+ ; -.|\n ; -%% - -int main ( int argc, char** argv ) -{ - FILE* fp = NULL; - void *yyscanner=0; - M4_YY_DECL_GUTS_VAR(); - -#ifdef TEST_IS_REENTRANT - yylex_init(&yyscanner); -#else - (void)yyscanner; -#endif - -#ifdef TEST_HAS_TABLES_EXTERNAL - if((fp = fopen(argv[1],"rb"))== NULL) - YY_FATAL_ERROR("could not open tables file for reading"); - - if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0) - YY_FATAL_ERROR("yytables_fload returned < 0"); - if(M4_YY_TABLES_VERIFY) - exit(0); -#endif - - if(argc > 2){ - if((fp = fopen(argv[2],"r"))== NULL) - YY_FATAL_ERROR("could not open input file for reading"); - yyin = fp; - } - while(yylex(M4_YY_CALL_ONLY_ARG) != 0) - ; - -#ifdef TEST_HAS_TABLES_EXTERNAL - yytables_destroy(M4_YY_CALL_ONLY_ARG); -#endif - yylex_destroy(M4_YY_CALL_ONLY_ARG); - - if(argc < 0) /* silence the compiler */ - yyscanner = (void*)fp; - - return 0; -} diff --git a/tests/tableopts.sh b/tests/tableopts.sh index e51c1a9..1e06d3c 100644 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -35,10 +35,9 @@ for kind in opt ser ver ; do fi cat << EOF -tableopts_${kind}_${threading}_${bare_opt}_${kind}_SOURCES = tableopts.l4 - -${testname}\$(EXEEXT): tableopts_${kind}_${threading}-${bare_opt}.\$(OBJEXT) - \$(AM_V_CCLD)\$(LINK) \$< +tableopts_${kind}_${threading}_${bare_opt}_${kind}_SOURCES = ${testname}.l +${testname}.l: \$(srcdir)/tableopts.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4 + \$(SHELL) \$(srcdir)/testmaker.sh \$@ EOF done -- cgit v1.2.1 From f7cc373669e9f3a51c2bd6be53d601d48e41f06a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Oct 2020 21:58:24 -0400 Subject: This commit adds c99 to the list of back ends for tableopts testing. The overhaul of the test system is done for now, though there will be more woro to do when testing has to support compilers for non-C back ends. --- tests/tableopts.am | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++- tests/tableopts.sh | 2 +- 2 files changed, 135 insertions(+), 3 deletions(-) diff --git a/tests/tableopts.am b/tests/tableopts.am index 196cd0a..47c2d1b 100644 --- a/tests/tableopts.am +++ b/tests/tableopts.am @@ -86,6 +86,50 @@ tableopts_opt_r_Caem_opt_SOURCES = tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +tableopts_opt_c99_Ca_opt_SOURCES = tableopts_opt_c99-Ca.opt.l +tableopts_opt_c99-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Ce_opt_SOURCES = tableopts_opt_c99-Ce.opt.l +tableopts_opt_c99-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cf_opt_SOURCES = tableopts_opt_c99-Cf.opt.l +tableopts_opt_c99-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_CxF_opt_SOURCES = tableopts_opt_c99-CxF.opt.l +tableopts_opt_c99-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cm_opt_SOURCES = tableopts_opt_c99-Cm.opt.l +tableopts_opt_c99-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cem_opt_SOURCES = tableopts_opt_c99-Cem.opt.l +tableopts_opt_c99-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cae_opt_SOURCES = tableopts_opt_c99-Cae.opt.l +tableopts_opt_c99-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Caef_opt_SOURCES = tableopts_opt_c99-Caef.opt.l +tableopts_opt_c99-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_CaexF_opt_SOURCES = tableopts_opt_c99-CaexF.opt.l +tableopts_opt_c99-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cam_opt_SOURCES = tableopts_opt_c99-Cam.opt.l +tableopts_opt_c99-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Caem_opt_SOURCES = tableopts_opt_c99-Caem.opt.l +tableopts_opt_c99-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + tableopts_ser_nr_Ca_ser_SOURCES = tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -174,6 +218,50 @@ tableopts_ser_r_Caem_ser_SOURCES = tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +tableopts_ser_c99_Ca_ser_SOURCES = tableopts_ser_c99-Ca.ser.l +tableopts_ser_c99-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Ce_ser_SOURCES = tableopts_ser_c99-Ce.ser.l +tableopts_ser_c99-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cf_ser_SOURCES = tableopts_ser_c99-Cf.ser.l +tableopts_ser_c99-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_CxF_ser_SOURCES = tableopts_ser_c99-CxF.ser.l +tableopts_ser_c99-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cm_ser_SOURCES = tableopts_ser_c99-Cm.ser.l +tableopts_ser_c99-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cem_ser_SOURCES = tableopts_ser_c99-Cem.ser.l +tableopts_ser_c99-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cae_ser_SOURCES = tableopts_ser_c99-Cae.ser.l +tableopts_ser_c99-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Caef_ser_SOURCES = tableopts_ser_c99-Caef.ser.l +tableopts_ser_c99-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_CaexF_ser_SOURCES = tableopts_ser_c99-CaexF.ser.l +tableopts_ser_c99-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cam_ser_SOURCES = tableopts_ser_c99-Cam.ser.l +tableopts_ser_c99-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Caem_ser_SOURCES = tableopts_ser_c99-Caem.ser.l +tableopts_ser_c99-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + tableopts_ver_nr_Ca_ver_SOURCES = tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -262,9 +350,53 @@ tableopts_ver_r_Caem_ver_SOURCES = tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver +tableopts_ver_c99_Ca_ver_SOURCES = tableopts_ver_c99-Ca.ver.l +tableopts_ver_c99-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Ce_ver_SOURCES = tableopts_ver_c99-Ce.ver.l +tableopts_ver_c99-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cf_ver_SOURCES = tableopts_ver_c99-Cf.ver.l +tableopts_ver_c99-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_CxF_ver_SOURCES = tableopts_ver_c99-CxF.ver.l +tableopts_ver_c99-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cm_ver_SOURCES = tableopts_ver_c99-Cm.ver.l +tableopts_ver_c99-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cem_ver_SOURCES = tableopts_ver_c99-Cem.ver.l +tableopts_ver_c99-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cae_ver_SOURCES = tableopts_ver_c99-Cae.ver.l +tableopts_ver_c99-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Caef_ver_SOURCES = tableopts_ver_c99-Caef.ver.l +tableopts_ver_c99-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_CaexF_ver_SOURCES = tableopts_ver_c99-CaexF.ver.l +tableopts_ver_c99-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cam_ver_SOURCES = tableopts_ver_c99-Cam.ver.l +tableopts_ver_c99-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Caem_ver_SOURCES = tableopts_ver_c99-Caem.ver.l +tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -tableopts_tables = tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser.tables tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser.tables tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver.tables tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver.tables +tableopts_tables = tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser.tables tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser.tables tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser.tables tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver.tables tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver.tables tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver.tables # Begin simple test rules diff --git a/tests/tableopts.sh b/tests/tableopts.sh index 1e06d3c..d6b7661 100644 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -15,7 +15,7 @@ TABLEOPTS_TESTS="" tableopts_tables="" for kind in opt ser ver ; do - for threading in nr r ; do + for threading in nr r c99 ; do for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do bare_opt=${opt#-} # The filenames must work on case-insensitive filesystems. -- cgit v1.2.1 From cf6e72bb3341b083a18ecba3fa3fb38097c625ce Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Thu, 22 Oct 2020 03:02:40 +0000 Subject: fix a few shellcheck lints that have shown up (#5) --- tests/tableopts.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/tableopts.sh b/tests/tableopts.sh index d6b7661..ac30d8a 100644 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -49,10 +49,12 @@ echo echo tableopts_tables = "${tableopts_tables}" # User can pass in a list of tesrs for which ti geneate build productions printf "\n# Begin simple test rules\n\n" -for test in $*; do - stem=`echo ${test} | sed s/_.*//` +for test in "$@"; do + stem=$(echo "${test}" | sed s/_.*//) echo "${test}_SOURCES = ${test}.l" echo "${test}.l: \$(srcdir)/${stem}.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" + # we're deliberately single-quoting this because we _don't_ want those variables to be expanded yet + # shellcheck disable=2016 printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' done printf "# End simple test rules\n" -- cgit v1.2.1 From 2ff19867ca4ea1c332f4c2230444e189c1cedcf6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 07:06:23 -0400 Subject: Abolish the cpp test extension. Those things are just tessts. The distinction was intriduced when I was first feeling my way through the test machinery. It doesn't buy us anything. --- tests/.gitignore | 36 ++++++------ tests/Makefile.am | 38 +++++-------- tests/alloc_extra_cpp.l | 120 ---------------------------------------- tests/alloc_extra_nr.l | 120 ++++++++++++++++++++++++++++++++++++++++ tests/ccl_cpp.l | 96 -------------------------------- tests/ccl_nr.l | 96 ++++++++++++++++++++++++++++++++ tests/posix_cpp.l | 79 -------------------------- tests/posix_nr.l | 79 ++++++++++++++++++++++++++ tests/posixly_correct_cpp.l | 79 -------------------------- tests/posixly_correct_nr.l | 79 ++++++++++++++++++++++++++ tests/quotes_cpp.l | 131 -------------------------------------------- tests/quotes_nr.l | 131 ++++++++++++++++++++++++++++++++++++++++++++ tests/tableopts.am | 8 +-- tests/testmaker.sh | 6 +- tests/yyextra_cpp.l | 120 ---------------------------------------- tests/yyextra_nr.l | 120 ++++++++++++++++++++++++++++++++++++++++ 16 files changed, 665 insertions(+), 673 deletions(-) delete mode 100644 tests/alloc_extra_cpp.l create mode 100644 tests/alloc_extra_nr.l delete mode 100644 tests/ccl_cpp.l create mode 100644 tests/ccl_nr.l delete mode 100644 tests/posix_cpp.l create mode 100644 tests/posix_nr.l delete mode 100644 tests/posixly_correct_cpp.l create mode 100644 tests/posixly_correct_nr.l delete mode 100644 tests/quotes_cpp.l create mode 100644 tests/quotes_nr.l delete mode 100644 tests/yyextra_cpp.l create mode 100644 tests/yyextra_nr.l diff --git a/tests/.gitignore b/tests/.gitignore index a453c37..5bf7fd9 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -2,8 +2,8 @@ *.trs *.o *.tables -alloc_extra_cpp -alloc_extra_cpp.c +alloc_extra_nr +alloc_extra_nr.c alloc_extra_c99 alloc_extra_c99.c array_nr.l @@ -37,8 +37,8 @@ c_cxx_nr c_cxx_nr.cc c_cxx_r c_cxx_r.cc -ccl_cpp -ccl_cpp.c +ccl_nr +ccl_nr.c ccl_c99 ccl_c99.c cxx_basic @@ -55,9 +55,9 @@ debug_r debug_r.c debug_c99 debug_c99.c -extended_cpp -extended_cpp.c -extended_cpp.l +extended_nr +extended_nr.c +extended_nr.l extended_c99 extended_c99.c extended_c99.l @@ -89,12 +89,12 @@ multiple_scanners_nr multiple_scanners_nr_[12].[ch] multiple_scanners_r multiple_scanners_r_[12].[ch] -posix_cpp -posix_cpp.c +posix_nr +posix_nr.c posix_c99 posix_c99.c -posixly_correct_cpp -posixly_correct_cpp.c +posixly_correct_nr +posixly_correct_nr.c posixly_correct_c99 posixly_correct_c99.c prefix_nr @@ -105,14 +105,14 @@ prefix_c99 prefix_c99.c pthread.pthread pthread.c -quoteincomment_cpp -quoteincomment_cpp.c -quoteincomment_cpp.l +quoteincomment_nr +quoteincomment_nr.c +quoteincomment_nr.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l -quotes_cpp -quotes_cpp.c +quotes_nr +quotes_nr.c quotes_c99 quotes_c99.c reject_nr @@ -145,8 +145,8 @@ string_c99.c tableopts*.l top top.[ch] -yyextra_cpp -yyextra_cpp.c +yyextra_nr +yyextra_nr.c yyextra_c99 yyextra_c99.c tableopts_*.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 1e1f3e5..d0ea929 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,14 +52,6 @@ AM_ONE_LOG_FLAGS = -1 -d $(srcdir) AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -# A full cross-matrix of all back ends (nr, r, c99) and all tests that -# could potentially apply to them would push the time cost of "make check" -# uncomfortably high, and the problem will worsen as more back ends are added. -# This list tries to explout orthogonalities in the C skeleton file to test -# smaller set that (hopeflly) spans the behavior space pretty well. Alas, new -# language back ends won't have that slack to exploit. The test set for the -# c99 back end should be a model for these. - check_PROGRAMS = $(simple_tests) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) generated = \ @@ -69,9 +61,9 @@ generated = \ basic_nr \ basic_r \ basic_c99 \ - extended_cpp \ + extended_nr \ extended_c99 \ - quoteincomment_cpp \ + quoteincomment_nr \ quoteincomment_c99 \ reject_nr \ reject_r \ @@ -81,14 +73,14 @@ generated = \ simple_tests = \ ${generated} \ - alloc_extra_cpp \ + alloc_extra_nr \ alloc_extra_c99 \ bison_nr \ bison_yylloc \ bison_yylval \ c_cxx_nr \ c_cxx_r \ - ccl_cpp \ + ccl_nr \ ccl_c99 \ cxx_basic \ cxx_multiple_scanners \ @@ -103,20 +95,20 @@ simple_tests = \ mem_c99 \ multiple_scanners_nr \ multiple_scanners_r \ - posix_cpp \ + posix_nr \ posix_c99 \ - posixly_correct_cpp \ + posixly_correct_nr \ posixly_correct_c99 \ prefix_nr \ prefix_r \ prefix_c99 \ - quotes_cpp \ + quotes_nr \ quotes_c99 \ string_nr \ string_r \ string_c99 \ top \ - yyextra_cpp \ + yyextra_nr \ yyextra_c99 @@ -139,7 +131,7 @@ ONE_TESTS = \ lineno_c99.one \ lineno_trailing.one -alloc_extra_cpp_SOURCES = alloc_extra_cpp.l +alloc_extra_nr_SOURCES = alloc_extra_nr.l alloc_extra_c99_SOURCES = alloc_extra_c99.l if HAVE_BISON bison_nr_SOURCES = bison_nr_scanner.l bison_nr_parser.y bison_nr_main.c @@ -155,7 +147,7 @@ bison_yylval_SOURCES = no_bison_stub.c endif c_cxx_nr_SOURCES = c_cxx_nr.lll c_cxx_r_SOURCES = c_cxx_r.lll -ccl_cpp_SOURCES = ccl_cpp.l +ccl_nr_SOURCES = ccl_nr.l ccl_c99_SOURCES = ccl_c99.l cxx_basic_SOURCES = cxx_basic.ll cxx_restart_SOURCES = cxx_restart.ll @@ -182,15 +174,15 @@ multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_ nodist_multiple_scanners_nr_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h -posix_cpp_SOURCES = posix_cpp.l +posix_nr_SOURCES = posix_nr.l posix_c99_SOURCES = posix_c99.l -posixly_correct_cpp_SOURCES = posixly_correct_cpp.l +posixly_correct_nr_SOURCES = posixly_correct_nr.l posixly_correct_c99_SOURCES = posixly_correct_c99.l prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l prefix_c99_SOURCES = prefix_c99.l pthread_pthread_SOURCES = pthread.l -quotes_cpp_SOURCES = quotes_cpp.l +quotes_nr_SOURCES = quotes_nr.l quotes_c99_SOURCES = quotes_c99.l rescan_nr_direct_SOURCES = rescan_nr.direct.l rescan_r_direct_SOURCES = rescan_r.direct.l @@ -199,7 +191,7 @@ string_r_SOURCES = string_r.l string_c99_SOURCES = string_c99.l top_SOURCES = top.l top_main.c nodist_top_SOURCES = top.h -yyextra_cpp_SOURCES = yyextra_cpp.l +yyextra_nr_SOURCES = yyextra_nr.l yyextra_c99_SOURCES = yyextra_c99.l # Normally, automake would distribute files built by flex. Since the @@ -308,7 +300,7 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c @if test ! -f $@; then rm -f $<; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi -posixly_correct_cpp.c: posixly_correct_cpp.l $(FLEX) +posixly_correct_nr.c: posixly_correct_nr.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< posixly_correct_c99.c: posixly_correct_c99.l $(FLEX) diff --git a/tests/alloc_extra_cpp.l b/tests/alloc_extra_cpp.l deleted file mode 100644 index c974777..0000000 --- a/tests/alloc_extra_cpp.l +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A file to build "scanner.c". */ -/* This tests that we can use "yyextra". - We buffer all input into a growable array, then print it. - We run diff on the input and output. -*/ - -#include -#include -#include "config.h" - - -/* We'll store the entire input in this buffer, growing as necessary. */ -struct Check { - char foo; - char *bar; - char qux; -}; - -/* Save char into junk array at next position. */ -static void check_extra ( yyscan_t scanner ); - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap nodefault noinput -%option warn -%option extra-type="struct Check *" -%option reentrant -%option noyyalloc - - -%% - -.|\r|\n { check_extra (yyscanner); } - -%% - -int main(void); - -int -main (void) -{ - yyscan_t scanner; - struct Check check; - - check.foo = 'a'; - check.bar = NULL; - check.qux = 'z'; - - testlex_init_extra(&check, &scanner); - testset_in(stdin, scanner); - testset_out(stdout, scanner); - - /* Test to confirm that testalloc was called from - * testlex_init_extra with the testextra argument. - */ - check_extra(scanner); - - testlex(scanner); - - testlex_destroy(scanner); - return 0; -} - -void *testalloc(size_t size, yyscan_t scanner) -{ - struct Check *check; - check = testget_extra(scanner); - - if (!check->bar) - check->bar = "Hello World"; - - check_extra(scanner); - - return malloc(size); -} - -/* Save char into junk array at next position. */ -static void check_extra(yyscan_t scanner) -{ - struct Check *check; - check = testget_extra(scanner); - - if (check->foo != 'a') { - fprintf(stderr, "foo is not 'a'\n"); - exit(1); - } - if (strcmp(check->bar, "Hello World") != 0) { - fprintf(stderr, "bar is not Hello World\n"); - exit(1); - } - if (check->qux != 'z') { - fprintf(stderr, "qux is not 'z'\n"); - exit(1); - } -} diff --git a/tests/alloc_extra_nr.l b/tests/alloc_extra_nr.l new file mode 100644 index 0000000..c974777 --- /dev/null +++ b/tests/alloc_extra_nr.l @@ -0,0 +1,120 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A file to build "scanner.c". */ +/* This tests that we can use "yyextra". + We buffer all input into a growable array, then print it. + We run diff on the input and output. +*/ + +#include +#include +#include "config.h" + + +/* We'll store the entire input in this buffer, growing as necessary. */ +struct Check { + char foo; + char *bar; + char qux; +}; + +/* Save char into junk array at next position. */ +static void check_extra ( yyscan_t scanner ); + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap nodefault noinput +%option warn +%option extra-type="struct Check *" +%option reentrant +%option noyyalloc + + +%% + +.|\r|\n { check_extra (yyscanner); } + +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + struct Check check; + + check.foo = 'a'; + check.bar = NULL; + check.qux = 'z'; + + testlex_init_extra(&check, &scanner); + testset_in(stdin, scanner); + testset_out(stdout, scanner); + + /* Test to confirm that testalloc was called from + * testlex_init_extra with the testextra argument. + */ + check_extra(scanner); + + testlex(scanner); + + testlex_destroy(scanner); + return 0; +} + +void *testalloc(size_t size, yyscan_t scanner) +{ + struct Check *check; + check = testget_extra(scanner); + + if (!check->bar) + check->bar = "Hello World"; + + check_extra(scanner); + + return malloc(size); +} + +/* Save char into junk array at next position. */ +static void check_extra(yyscan_t scanner) +{ + struct Check *check; + check = testget_extra(scanner); + + if (check->foo != 'a') { + fprintf(stderr, "foo is not 'a'\n"); + exit(1); + } + if (strcmp(check->bar, "Hello World") != 0) { + fprintf(stderr, "bar is not Hello World\n"); + exit(1); + } + if (check->qux != 'z') { + fprintf(stderr, "qux is not 'z'\n"); + exit(1); + } +} diff --git a/tests/ccl_cpp.l b/tests/ccl_cpp.l deleted file mode 100644 index 1894b4c..0000000 --- a/tests/ccl_cpp.l +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) -#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); -^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); - -^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"check-a:"(?i:(?-i:A))@\n err_abort(); -^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); -^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); - -^"x1:"(?x: a | b )+@x1@\n a_ok(); -^"x2:"(?x: a | - (?# Comment ) - b - )+@x2@\n a_ok(); - - -.|\n { err_abort(); } -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/ccl_nr.l b/tests/ccl_nr.l new file mode 100644 index 0000000..1894b4c --- /dev/null +++ b/tests/ccl_nr.l @@ -0,0 +1,96 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +/*#include "parser.h" */ + +#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) +#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; + +^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; + +^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); +^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); + +^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; +^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; + + /* We don't want this one to match. */ +^"check-a:"(?i:(?-i:A))@\n err_abort(); +^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; + + /* We don't want this one to match. */ +^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); +^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); + +^"x1:"(?x: a | b )+@x1@\n a_ok(); +^"x2:"(?x: a | + (?# Comment ) + b + )+@x2@\n a_ok(); + + +.|\n { err_abort(); } +%% + +int main(void); + +int +main (void) +{ + yyin = stdin; + yyout = stdout; + while (yylex()) + ; + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/posix_cpp.l b/tests/posix_cpp.l deleted file mode 100644 index f1851d8..0000000 --- a/tests/posix_cpp.l +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn posix-compat - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posix_nr.l b/tests/posix_nr.l new file mode 100644 index 0000000..f1851d8 --- /dev/null +++ b/tests/posix_nr.l @@ -0,0 +1,79 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn posix-compat + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/posixly_correct_cpp.l b/tests/posixly_correct_cpp.l deleted file mode 100644 index 715bb27..0000000 --- a/tests/posixly_correct_cpp.l +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posixly_correct_nr.l b/tests/posixly_correct_nr.l new file mode 100644 index 0000000..715bb27 --- /dev/null +++ b/tests/posixly_correct_nr.l @@ -0,0 +1,79 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/quotes_cpp.l b/tests/quotes_cpp.l deleted file mode 100644 index d1b97eb..0000000 --- a/tests/quotes_cpp.l +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* The point of this test is to be sure our M4 madness does not - * interfere with user code. I particular, we are looking - * for instances of M4 quotes, [[ and ]], in here to make it through the flex - * machinery unscathed. - */ - -/* sect 1 [ 1 ] TEST_XXX */ -/* sect 1 [[ 2 ]] TEST_XXX */ -/* sect 1 [[[ 3 ]]] TEST_XXX */ -/* sect 1 [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 ]] unmatched [[ TEST_XXX */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -#include -/*#include "parser.h" */ - -/* sect 1 block [ 1 ] TEST_XXX */ -/* sect 1 block [[ 2 ]] TEST_XXX */ -/* sect 1 block [[[ 3 ]]] TEST_XXX */ -/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 block ]] unmatched [[ TEST_XXX */ - -static int a[1] = {0}; -static int b[1] = {0}; -static int c[1] = {0}; - -static int foo (int i){ - return a[b[c[i]]]; /* sect 1 code TEST_XXX */ -} -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - /* indented code [ 1 ] */ - /* indented code [[ 2 ]] */ - /* indented code [[[ 3 ]]] */ - /* indented code [[[[ 4 ]]]] */ - /* indented code ]] unmatched [[ */ -%{ -// non-indented code [ 1 ] -// non-indented code [[ 2 ]] -// non-indented code [[[ 3 ]]] -// non-indented code [[[[ 4 ]]]] -%} - -a /* action comment [ 1 ] */ ; -b /* action comment [[ 2 ]] */ ; -c /* action comment [[[ 3 ]]] */ ; -d /* action comment [[[[ 4 ]]]] */ ; -e /* action comment ]] unmatched [[ */ ; -f return 1+foo(a[b[c[0]]]); -.|\n { - -#if 0 - action code [ 1 ] TEST_XXX - action code [[ 2 ]] TEST_XXX - action code [[[ 3 ]]] TEST_XXX - action code [[[[ 4 ]]]] TEST_XXX - action code ]] unmatched [[ TEST_XXX -#endif - /* action block [ 1 ] TEST_XXX */ - /* action block [[ 2 ]] TEST_XXX */ - /* action block [[[ 3 ]]] TEST_XXX */ - /* action block [[[[ 4 ]]]] TEST_XXX */ - /* action block ]] unmatched [[ TEST_XXX */ - assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); - assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); - assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); - assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); - assert(!strcmp("]]m4_define(alpha, beta)[[", - "]""]m4_""define(alpha, beta)[""[")); - return 1+foo(a[b[c[0]]]); /* TEST_XXX */ - } -%% - -/* sect 3 [ 1 ] TEST_XXX */ -/* sect 3 [[ 2 ]] TEST_XXX */ -/* sect 3 [[[ 3 ]]] TEST_XXX */ -/* sect 3 [[[[ 4 ]]]] TEST_XXX */ -/* sect 3 ]] unmatched [[ TEST_XXX */ -static int bar (int i){ - return c[b[a[i]]]; /* sect 3 code TEST_XXX */ -} -int main(void); - -#define CONCAT_IDENTS(a, b) a##b -int -main (void) -{ - /* m4_m4exit(100) */ - FILE *M4_YY_NOT_IN_HEADER = stdin; - yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); - yyout = stdout; - while (yylex()) - ; - assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); - printf("TEST RETURNING OK.\n"); - return bar(0); -} - diff --git a/tests/quotes_nr.l b/tests/quotes_nr.l new file mode 100644 index 0000000..d1b97eb --- /dev/null +++ b/tests/quotes_nr.l @@ -0,0 +1,131 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The point of this test is to be sure our M4 madness does not + * interfere with user code. I particular, we are looking + * for instances of M4 quotes, [[ and ]], in here to make it through the flex + * machinery unscathed. + */ + +/* sect 1 [ 1 ] TEST_XXX */ +/* sect 1 [[ 2 ]] TEST_XXX */ +/* sect 1 [[[ 3 ]]] TEST_XXX */ +/* sect 1 [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 ]] unmatched [[ TEST_XXX */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +#include +/*#include "parser.h" */ + +/* sect 1 block [ 1 ] TEST_XXX */ +/* sect 1 block [[ 2 ]] TEST_XXX */ +/* sect 1 block [[[ 3 ]]] TEST_XXX */ +/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 block ]] unmatched [[ TEST_XXX */ + +static int a[1] = {0}; +static int b[1] = {0}; +static int c[1] = {0}; + +static int foo (int i){ + return a[b[c[i]]]; /* sect 1 code TEST_XXX */ +} +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + /* indented code [ 1 ] */ + /* indented code [[ 2 ]] */ + /* indented code [[[ 3 ]]] */ + /* indented code [[[[ 4 ]]]] */ + /* indented code ]] unmatched [[ */ +%{ +// non-indented code [ 1 ] +// non-indented code [[ 2 ]] +// non-indented code [[[ 3 ]]] +// non-indented code [[[[ 4 ]]]] +%} + +a /* action comment [ 1 ] */ ; +b /* action comment [[ 2 ]] */ ; +c /* action comment [[[ 3 ]]] */ ; +d /* action comment [[[[ 4 ]]]] */ ; +e /* action comment ]] unmatched [[ */ ; +f return 1+foo(a[b[c[0]]]); +.|\n { + +#if 0 + action code [ 1 ] TEST_XXX + action code [[ 2 ]] TEST_XXX + action code [[[ 3 ]]] TEST_XXX + action code [[[[ 4 ]]]] TEST_XXX + action code ]] unmatched [[ TEST_XXX +#endif + /* action block [ 1 ] TEST_XXX */ + /* action block [[ 2 ]] TEST_XXX */ + /* action block [[[ 3 ]]] TEST_XXX */ + /* action block [[[[ 4 ]]]] TEST_XXX */ + /* action block ]] unmatched [[ TEST_XXX */ + assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); + assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); + assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); + assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); + assert(!strcmp("]]m4_define(alpha, beta)[[", + "]""]m4_""define(alpha, beta)[""[")); + return 1+foo(a[b[c[0]]]); /* TEST_XXX */ + } +%% + +/* sect 3 [ 1 ] TEST_XXX */ +/* sect 3 [[ 2 ]] TEST_XXX */ +/* sect 3 [[[ 3 ]]] TEST_XXX */ +/* sect 3 [[[[ 4 ]]]] TEST_XXX */ +/* sect 3 ]] unmatched [[ TEST_XXX */ +static int bar (int i){ + return c[b[a[i]]]; /* sect 3 code TEST_XXX */ +} +int main(void); + +#define CONCAT_IDENTS(a, b) a##b +int +main (void) +{ + /* m4_m4exit(100) */ + FILE *M4_YY_NOT_IN_HEADER = stdin; + yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); + yyout = stdout; + while (yylex()) + ; + assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); + printf("TEST RETURNING OK.\n"); + return bar(0); +} + diff --git a/tests/tableopts.am b/tests/tableopts.am index 47c2d1b..bf0672f 100644 --- a/tests/tableopts.am +++ b/tests/tableopts.am @@ -424,16 +424,16 @@ basic_c99_SOURCES = basic_c99.l basic_c99.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -extended_cpp_SOURCES = extended_cpp.l -extended_cpp.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 +extended_nr_SOURCES = extended_nr.l +extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -quoteincomment_cpp_SOURCES = quoteincomment_cpp.l -quoteincomment_cpp.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 +quoteincomment_nr_SOURCES = quoteincomment_nr.l +quoteincomment_nr.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ quoteincomment_c99_SOURCES = quoteincomment_c99.l diff --git a/tests/testmaker.sh b/tests/testmaker.sh index aa8b47b..b03bb1f 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# testmaker.sh - asssemble tests from backend-ndependent rulesets and +# testmaker.sh - asssemble tests from backend-independent rulesets and # backend-dependent boilerplate. # # The single argument is a testfile name to be generated. @@ -40,14 +40,14 @@ stem=$1 options="" backend=nr for part in "$@"; do - # This is the only pace in this dcript that you need to modify + # This is the only pace in this script that you need to modify # to add a new back end - just add a line on the pattern of # the c99 one. Of course testmaker.m4 will require the # right boilerplate code for this to work. # # Yes, cpp is an alias for nr. case ${part} in - cpp|nr) backend=nr; ;; + nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; ser) serialization=yes ;; diff --git a/tests/yyextra_cpp.l b/tests/yyextra_cpp.l deleted file mode 100644 index 5a5a014..0000000 --- a/tests/yyextra_cpp.l +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A file to build "scanner.c". */ -/* This tests that we can use "yyextra". - We buffer all input into a growable array, then print it. - We run diff on the input and output. -*/ - -#include -#include -#include "config.h" - - -/* We'll store the entire input in this buffer, growing as necessary. */ -struct Buffer { - int curr_len; - int max_len; - int grow_len; - char * data; -}; - -/* Save char into junk array at next position. */ -static void append_char (char c, yyscan_t scanner ); - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap nodefault noyyinput -%option warn -%option reentrant -%option extra-type="struct Buffer *" - -%% - -.|\r|\n { append_char (yytext[0],yyscanner); } - -%% - -int main(void); - -int -main (void) -{ - yyscan_t scanner; - struct Buffer * buf; - int i; - - buf = malloc(sizeof(struct Buffer)); - buf->curr_len =0; - buf->max_len = 4; - buf->grow_len = 100; - buf->data = malloc((size_t) buf->max_len); - - testlex_init(&scanner); - testset_in( stdin, scanner); - testset_out( stdout, scanner); - testset_extra( buf, scanner ); - testlex(scanner); - - buf = testget_extra(scanner); - for(i=0; i < buf->curr_len; i++) - fputc( buf->data[i], stdout ); - free( buf->data); - free( buf); - - testlex_destroy(scanner); - return 0; -} - -/* Save char into junk array at next position. */ -static void append_char (char c, yyscan_t scanner ) -{ - struct Buffer *buf, *new_buf; - buf = testget_extra(scanner); - - /* Grow buffer if necessary. */ - - if( buf->curr_len >= buf->max_len ) - { - new_buf = malloc(sizeof(struct Buffer)); - new_buf->max_len = buf->max_len + buf->grow_len; - new_buf->grow_len = buf->grow_len; - new_buf->data = malloc((size_t) new_buf->max_len); - for( new_buf->curr_len = 0; - new_buf->curr_len < buf->curr_len; - new_buf->curr_len++ ) - { - new_buf->data[ new_buf->curr_len] = buf->data [ new_buf->curr_len]; - } - free( buf->data ); - free( buf ); - buf = new_buf; - testset_extra( buf, scanner ); - } - - - buf->data[ buf->curr_len++ ] = c; -} diff --git a/tests/yyextra_nr.l b/tests/yyextra_nr.l new file mode 100644 index 0000000..5a5a014 --- /dev/null +++ b/tests/yyextra_nr.l @@ -0,0 +1,120 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* A file to build "scanner.c". */ +/* This tests that we can use "yyextra". + We buffer all input into a growable array, then print it. + We run diff on the input and output. +*/ + +#include +#include +#include "config.h" + + +/* We'll store the entire input in this buffer, growing as necessary. */ +struct Buffer { + int curr_len; + int max_len; + int grow_len; + char * data; +}; + +/* Save char into junk array at next position. */ +static void append_char (char c, yyscan_t scanner ); + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap nodefault noyyinput +%option warn +%option reentrant +%option extra-type="struct Buffer *" + +%% + +.|\r|\n { append_char (yytext[0],yyscanner); } + +%% + +int main(void); + +int +main (void) +{ + yyscan_t scanner; + struct Buffer * buf; + int i; + + buf = malloc(sizeof(struct Buffer)); + buf->curr_len =0; + buf->max_len = 4; + buf->grow_len = 100; + buf->data = malloc((size_t) buf->max_len); + + testlex_init(&scanner); + testset_in( stdin, scanner); + testset_out( stdout, scanner); + testset_extra( buf, scanner ); + testlex(scanner); + + buf = testget_extra(scanner); + for(i=0; i < buf->curr_len; i++) + fputc( buf->data[i], stdout ); + free( buf->data); + free( buf); + + testlex_destroy(scanner); + return 0; +} + +/* Save char into junk array at next position. */ +static void append_char (char c, yyscan_t scanner ) +{ + struct Buffer *buf, *new_buf; + buf = testget_extra(scanner); + + /* Grow buffer if necessary. */ + + if( buf->curr_len >= buf->max_len ) + { + new_buf = malloc(sizeof(struct Buffer)); + new_buf->max_len = buf->max_len + buf->grow_len; + new_buf->grow_len = buf->grow_len; + new_buf->data = malloc((size_t) new_buf->max_len); + for( new_buf->curr_len = 0; + new_buf->curr_len < buf->curr_len; + new_buf->curr_len++ ) + { + new_buf->data[ new_buf->curr_len] = buf->data [ new_buf->curr_len]; + } + free( buf->data ); + free( buf ); + buf = new_buf; + testset_extra( buf, scanner ); + } + + + buf->data[ buf->curr_len++ ] = c; +} -- cgit v1.2.1 From cd6fdfdadf13575c3534838cdbd5925ae641ebfc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 07:15:26 -0400 Subject: Remove unused variable settings in tests/Makefile.am... ...and group the log-compiler settings together where they can be audited. --- tests/Makefile.am | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index d0ea929..7bf41bb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -320,12 +320,6 @@ $(srcdir)/tableopts.am: tableopts.sh include $(srcdir)/tableopts.am -tableopts := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem -tableopts_opt_tests := $(foreach opt,$(tableopts), tableopts_opt_nr$(opt) tableopts_opt_r$(opt)) -tableopts_sertests := $(foreach opt,$(tableopts), tableopts_ser_nr$(opt) tableopts_ser_r$(opt)) -tableopts_vertests := $(foreach opt,$(tableopts), tableopts_ver_nr$(opt) tableopts_ver_r$(opt)) -tableopts_tests := $(tableopts_opttests) $(tableopts_vertests) $(tableopts_sertests) - OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r -- cgit v1.2.1 From dddcaa7c973e17db75d31966ce8a93b82781163f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 08:29:28 -0400 Subject: Another big sinmplification of the test machinery. If you drop a file with the extension ".rules" in tests/, "make check" will now automatically make and run tests for all back ends - presently nr, r, and c99. It would be trivial to change ruleset.sh so all table-compression options are checked for all rulesets, and probably a good idea. --- tests/Makefile.am | 70 +++----- tests/ruleset.am | 474 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ruleset.sh | 48 ++++++ tests/tableopts.am | 463 --------------------------------------------------- tests/tableopts.sh | 60 ------- tests/testmaker.sh | 22 +-- 6 files changed, 555 insertions(+), 582 deletions(-) create mode 100644 tests/ruleset.am create mode 100644 tests/ruleset.sh delete mode 100644 tests/tableopts.am delete mode 100644 tests/tableopts.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 7bf41bb..285e6fa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,12 +24,12 @@ AM_CFLAGS = $(WARNINGFLAGS) TESTS = $(check_PROGRAMS) options.cn # The script testwrapper.sh will run most tests as is. A couple tests -# in the suite end in .reject, .table and the like so that we can pass +# in the suite end in .direct, .cn. and the like so that we can pass # different arguments to the test runner. We list those extensions so # automake knows how to distinguish between the various kinds of tests # we have. -TEST_EXTENSIONS = .table .direct .cn .i3 .pthread .one .opt .ser .ver +TEST_EXTENSIONS = .direct .cn .i3 .pthread .one .opt .ser .ver LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_LOG_FLAGS = -d $(srcdir) -r @@ -49,30 +49,21 @@ AM_PTHREAD_LOG_FLAGS = -i $(srcdir)/pthread_1.txt -i $(srcdir)/pthread_2.txt -i ONE_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_ONE_LOG_FLAGS = -1 -d $(srcdir) +OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh +AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r + +SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh +AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r + +VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh +AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r + AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -check_PROGRAMS = $(simple_tests) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS) - -generated = \ - array_nr \ - array_r \ - array_c99 \ - basic_nr \ - basic_r \ - basic_c99 \ - extended_nr \ - extended_c99 \ - quoteincomment_nr \ - quoteincomment_c99 \ - reject_nr \ - reject_r \ - reject_c99 \ - reject_ver \ - reject_ser - -simple_tests = \ - ${generated} \ +check_PROGRAMS = $(RULESET_TESTS) $(SPORADIC_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) + +SPORADIC_TESTS = \ alloc_extra_nr \ alloc_extra_c99 \ bison_nr \ @@ -205,9 +196,9 @@ yyextra_c99_SOURCES = yyextra_c99.l CLEANFILES = \ $(subst no_bison_stub.c, , $(shell ls *.c | grep -v "_main.c")) \ - $(shell ls *.cc | grep -v "_main.cc") \ - $(patsubst %, %.l, ${generated}) \ - tableopts*.l \ + $(shell ls *.cc | grep -v "_main.cc") + ${RULEST_TESTS} \ + $(patsubst %, %.l, ${RULESET_TESTS}) \ *.h *.tables dist-hook: @@ -219,7 +210,7 @@ dist-hook: EXTRA_DIST = README *.txt testmaker.m4 dist_noinst_SCRIPTS = \ - tableopts.sh + ruleset.sh dist_check_SCRIPTS = \ options.cn \ @@ -309,24 +300,15 @@ posixly_correct_c99.c: posixly_correct_c99.l $(FLEX) top_main.$(OBJEXT): top.h top.h: top.c -# We separate out the tableopts _SOURCES variables and the linking -# rules for those programs because automake has no way to specify such -# things with a loop in a variable (even though make can do such -# things) and the resultant list is both long an unenlightening. And -# it can be / is generated by a shell script, tableopts.sh. +# Most test priductions can be autogenerated from ruleset files, but +# automake has no way to specify such things with a loop in a variable +# (even though make can do such things) and the resultant list is both +# long an unenlightening. And it can be / is generated by a shell +# script, ruleset.sh. -$(srcdir)/tableopts.am: tableopts.sh - $(SHELL) $(srcdir)/tableopts.sh $(generated) > $(srcdir)/tableopts.am +$(srcdir)/ruleset.am: $(srcdir)/ruleset.sh + $(SHELL) $(srcdir)/ruleset.sh nr r c99 > $(srcdir)/ruleset.am -include $(srcdir)/tableopts.am - -OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r - -SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r - -VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r +include $(srcdir)/ruleset.am diff --git a/tests/ruleset.am b/tests/ruleset.am new file mode 100644 index 0000000..dc42d64 --- /dev/null +++ b/tests/ruleset.am @@ -0,0 +1,474 @@ + +# Begin generated test rules + +array_nr_SOURCES = array_nr.l +array_nr.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_nr_SOURCES = basic_nr.l +basic_nr.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +extended_nr_SOURCES = extended_nr.l +extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +quoteincomment_nr_SOURCES = quoteincomment_nr.l +quoteincomment_nr.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_nr_SOURCES = reject_nr.l +reject_nr.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_nr_SOURCES = tableopts_nr.l +tableopts_nr.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Ca_opt_SOURCES = tableopts_opt_nr-Ca.opt.l +tableopts_opt_nr-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Ce_opt_SOURCES = tableopts_opt_nr-Ce.opt.l +tableopts_opt_nr-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Cf_opt_SOURCES = tableopts_opt_nr-Cf.opt.l +tableopts_opt_nr-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_CxF_opt_SOURCES = tableopts_opt_nr-CxF.opt.l +tableopts_opt_nr-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Cm_opt_SOURCES = tableopts_opt_nr-Cm.opt.l +tableopts_opt_nr-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Cem_opt_SOURCES = tableopts_opt_nr-Cem.opt.l +tableopts_opt_nr-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Cae_opt_SOURCES = tableopts_opt_nr-Cae.opt.l +tableopts_opt_nr-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Caef_opt_SOURCES = tableopts_opt_nr-Caef.opt.l +tableopts_opt_nr-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_CaexF_opt_SOURCES = tableopts_opt_nr-CaexF.opt.l +tableopts_opt_nr-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Cam_opt_SOURCES = tableopts_opt_nr-Cam.opt.l +tableopts_opt_nr-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_nr_Caem_opt_SOURCES = tableopts_opt_nr-Caem.opt.l +tableopts_opt_nr-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Ca_ser_SOURCES = tableopts_ser_nr-Ca.ser.l +tableopts_ser_nr-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Ce_ser_SOURCES = tableopts_ser_nr-Ce.ser.l +tableopts_ser_nr-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Cf_ser_SOURCES = tableopts_ser_nr-Cf.ser.l +tableopts_ser_nr-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_CxF_ser_SOURCES = tableopts_ser_nr-CxF.ser.l +tableopts_ser_nr-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Cm_ser_SOURCES = tableopts_ser_nr-Cm.ser.l +tableopts_ser_nr-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Cem_ser_SOURCES = tableopts_ser_nr-Cem.ser.l +tableopts_ser_nr-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Cae_ser_SOURCES = tableopts_ser_nr-Cae.ser.l +tableopts_ser_nr-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Caef_ser_SOURCES = tableopts_ser_nr-Caef.ser.l +tableopts_ser_nr-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_CaexF_ser_SOURCES = tableopts_ser_nr-CaexF.ser.l +tableopts_ser_nr-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Cam_ser_SOURCES = tableopts_ser_nr-Cam.ser.l +tableopts_ser_nr-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_nr_Caem_ser_SOURCES = tableopts_ser_nr-Caem.ser.l +tableopts_ser_nr-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Ca_ver_SOURCES = tableopts_ver_nr-Ca.ver.l +tableopts_ver_nr-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Ce_ver_SOURCES = tableopts_ver_nr-Ce.ver.l +tableopts_ver_nr-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Cf_ver_SOURCES = tableopts_ver_nr-Cf.ver.l +tableopts_ver_nr-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_CxF_ver_SOURCES = tableopts_ver_nr-CxF.ver.l +tableopts_ver_nr-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Cm_ver_SOURCES = tableopts_ver_nr-Cm.ver.l +tableopts_ver_nr-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Cem_ver_SOURCES = tableopts_ver_nr-Cem.ver.l +tableopts_ver_nr-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Cae_ver_SOURCES = tableopts_ver_nr-Cae.ver.l +tableopts_ver_nr-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Caef_ver_SOURCES = tableopts_ver_nr-Caef.ver.l +tableopts_ver_nr-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_CaexF_ver_SOURCES = tableopts_ver_nr-CaexF.ver.l +tableopts_ver_nr-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Cam_ver_SOURCES = tableopts_ver_nr-Cam.ver.l +tableopts_ver_nr-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_nr_Caem_ver_SOURCES = tableopts_ver_nr-Caem.ver.l +tableopts_ver_nr-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +array_r_SOURCES = array_r.l +array_r.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_r_SOURCES = basic_r.l +basic_r.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +extended_r_SOURCES = extended_r.l +extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +quoteincomment_r_SOURCES = quoteincomment_r.l +quoteincomment_r.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_r_SOURCES = reject_r.l +reject_r.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_r_SOURCES = tableopts_r.l +tableopts_r.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Ca_opt_SOURCES = tableopts_opt_r-Ca.opt.l +tableopts_opt_r-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Ce_opt_SOURCES = tableopts_opt_r-Ce.opt.l +tableopts_opt_r-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Cf_opt_SOURCES = tableopts_opt_r-Cf.opt.l +tableopts_opt_r-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_CxF_opt_SOURCES = tableopts_opt_r-CxF.opt.l +tableopts_opt_r-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Cm_opt_SOURCES = tableopts_opt_r-Cm.opt.l +tableopts_opt_r-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Cem_opt_SOURCES = tableopts_opt_r-Cem.opt.l +tableopts_opt_r-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Cae_opt_SOURCES = tableopts_opt_r-Cae.opt.l +tableopts_opt_r-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Caef_opt_SOURCES = tableopts_opt_r-Caef.opt.l +tableopts_opt_r-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_CaexF_opt_SOURCES = tableopts_opt_r-CaexF.opt.l +tableopts_opt_r-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Cam_opt_SOURCES = tableopts_opt_r-Cam.opt.l +tableopts_opt_r-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_r_Caem_opt_SOURCES = tableopts_opt_r-Caem.opt.l +tableopts_opt_r-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Ca_ser_SOURCES = tableopts_ser_r-Ca.ser.l +tableopts_ser_r-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Ce_ser_SOURCES = tableopts_ser_r-Ce.ser.l +tableopts_ser_r-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Cf_ser_SOURCES = tableopts_ser_r-Cf.ser.l +tableopts_ser_r-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_CxF_ser_SOURCES = tableopts_ser_r-CxF.ser.l +tableopts_ser_r-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Cm_ser_SOURCES = tableopts_ser_r-Cm.ser.l +tableopts_ser_r-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Cem_ser_SOURCES = tableopts_ser_r-Cem.ser.l +tableopts_ser_r-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Cae_ser_SOURCES = tableopts_ser_r-Cae.ser.l +tableopts_ser_r-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Caef_ser_SOURCES = tableopts_ser_r-Caef.ser.l +tableopts_ser_r-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_CaexF_ser_SOURCES = tableopts_ser_r-CaexF.ser.l +tableopts_ser_r-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Cam_ser_SOURCES = tableopts_ser_r-Cam.ser.l +tableopts_ser_r-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_r_Caem_ser_SOURCES = tableopts_ser_r-Caem.ser.l +tableopts_ser_r-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Ca_ver_SOURCES = tableopts_ver_r-Ca.ver.l +tableopts_ver_r-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Ce_ver_SOURCES = tableopts_ver_r-Ce.ver.l +tableopts_ver_r-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Cf_ver_SOURCES = tableopts_ver_r-Cf.ver.l +tableopts_ver_r-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_CxF_ver_SOURCES = tableopts_ver_r-CxF.ver.l +tableopts_ver_r-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Cm_ver_SOURCES = tableopts_ver_r-Cm.ver.l +tableopts_ver_r-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Cem_ver_SOURCES = tableopts_ver_r-Cem.ver.l +tableopts_ver_r-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Cae_ver_SOURCES = tableopts_ver_r-Cae.ver.l +tableopts_ver_r-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Caef_ver_SOURCES = tableopts_ver_r-Caef.ver.l +tableopts_ver_r-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_CaexF_ver_SOURCES = tableopts_ver_r-CaexF.ver.l +tableopts_ver_r-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Cam_ver_SOURCES = tableopts_ver_r-Cam.ver.l +tableopts_ver_r-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_r_Caem_ver_SOURCES = tableopts_ver_r-Caem.ver.l +tableopts_ver_r-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +array_c99_SOURCES = array_c99.l +array_c99.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_c99_SOURCES = basic_c99.l +basic_c99.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +extended_c99_SOURCES = extended_c99.l +extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +quoteincomment_c99_SOURCES = quoteincomment_c99.l +quoteincomment_c99.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_c99_SOURCES = reject_c99.l +reject_c99.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_c99_SOURCES = tableopts_c99.l +tableopts_c99.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Ca_opt_SOURCES = tableopts_opt_c99-Ca.opt.l +tableopts_opt_c99-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Ce_opt_SOURCES = tableopts_opt_c99-Ce.opt.l +tableopts_opt_c99-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cf_opt_SOURCES = tableopts_opt_c99-Cf.opt.l +tableopts_opt_c99-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_CxF_opt_SOURCES = tableopts_opt_c99-CxF.opt.l +tableopts_opt_c99-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cm_opt_SOURCES = tableopts_opt_c99-Cm.opt.l +tableopts_opt_c99-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cem_opt_SOURCES = tableopts_opt_c99-Cem.opt.l +tableopts_opt_c99-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cae_opt_SOURCES = tableopts_opt_c99-Cae.opt.l +tableopts_opt_c99-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Caef_opt_SOURCES = tableopts_opt_c99-Caef.opt.l +tableopts_opt_c99-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_CaexF_opt_SOURCES = tableopts_opt_c99-CaexF.opt.l +tableopts_opt_c99-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Cam_opt_SOURCES = tableopts_opt_c99-Cam.opt.l +tableopts_opt_c99-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_c99_Caem_opt_SOURCES = tableopts_opt_c99-Caem.opt.l +tableopts_opt_c99-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Ca_ser_SOURCES = tableopts_ser_c99-Ca.ser.l +tableopts_ser_c99-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Ce_ser_SOURCES = tableopts_ser_c99-Ce.ser.l +tableopts_ser_c99-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cf_ser_SOURCES = tableopts_ser_c99-Cf.ser.l +tableopts_ser_c99-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_CxF_ser_SOURCES = tableopts_ser_c99-CxF.ser.l +tableopts_ser_c99-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cm_ser_SOURCES = tableopts_ser_c99-Cm.ser.l +tableopts_ser_c99-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cem_ser_SOURCES = tableopts_ser_c99-Cem.ser.l +tableopts_ser_c99-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cae_ser_SOURCES = tableopts_ser_c99-Cae.ser.l +tableopts_ser_c99-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Caef_ser_SOURCES = tableopts_ser_c99-Caef.ser.l +tableopts_ser_c99-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_CaexF_ser_SOURCES = tableopts_ser_c99-CaexF.ser.l +tableopts_ser_c99-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Cam_ser_SOURCES = tableopts_ser_c99-Cam.ser.l +tableopts_ser_c99-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_c99_Caem_ser_SOURCES = tableopts_ser_c99-Caem.ser.l +tableopts_ser_c99-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Ca_ver_SOURCES = tableopts_ver_c99-Ca.ver.l +tableopts_ver_c99-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Ce_ver_SOURCES = tableopts_ver_c99-Ce.ver.l +tableopts_ver_c99-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cf_ver_SOURCES = tableopts_ver_c99-Cf.ver.l +tableopts_ver_c99-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_CxF_ver_SOURCES = tableopts_ver_c99-CxF.ver.l +tableopts_ver_c99-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cm_ver_SOURCES = tableopts_ver_c99-Cm.ver.l +tableopts_ver_c99-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cem_ver_SOURCES = tableopts_ver_c99-Cem.ver.l +tableopts_ver_c99-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cae_ver_SOURCES = tableopts_ver_c99-Cae.ver.l +tableopts_ver_c99-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Caef_ver_SOURCES = tableopts_ver_c99-Caef.ver.l +tableopts_ver_c99-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_CaexF_ver_SOURCES = tableopts_ver_c99-CaexF.ver.l +tableopts_ver_c99-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Cam_ver_SOURCES = tableopts_ver_c99-Cam.ver.l +tableopts_ver_c99-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_c99_Caem_ver_SOURCES = tableopts_ver_c99-Caem.ver.l +tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +# End generated test rules +RULESET_TESTS = array_nr basic_nr extended_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r extended_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 extended_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver + diff --git a/tests/ruleset.sh b/tests/ruleset.sh new file mode 100644 index 0000000..a4d32ac --- /dev/null +++ b/tests/ruleset.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Generate rules to make .l for testing files from rulesets. Also set up SOURCES +# variables for link time. Pass it a list of back-end suffixes. +# +# This script exists automake isn't able to handle the pattern rules that +# would be natural to use. Output is written to standard output for +# inclusion in a Makefile.am, typically by redirecting the output and +# then an automake include directive. + +set -eu + +RULESET_TESTS="" + +printf "\n# Begin generated test rules\n\n" + +for backend in $* ; do + for ruleset in *.rules; do + testname=${ruleset%.*}_${backend} + echo "${testname}_SOURCES = ${testname}.l" + echo "${testname}.l: \$(srcdir)/${ruleset} \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" + # we're deliberately single-quoting this because we _don't_ want those variables to be expanded yet + # shellcheck disable=2016 + printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' + RULESET_TESTS="${RULESET_TESTS} ${testname}" + done + for kind in opt ser ver ; do + for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do + bare_opt=${opt#-} + # The filenames must work on case-insensitive filesystems. + bare_opt=$(echo ${bare_opt}| sed 's/F$/xF/') + testname=tableopts_${kind}_${backend}-${bare_opt}.${kind} + RULESET_TESTS="${RULESET_TESTS} ${testname}" + cat << EOF +tableopts_${kind}_${backend}_${bare_opt}_${kind}_SOURCES = ${testname}.l +${testname}.l: \$(srcdir)/tableopts.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4 + \$(SHELL) \$(srcdir)/testmaker.sh \$@ + +EOF + done + done +done + +printf "# End generated test rules\n" + +echo RULESET_TESTS = "${RULESET_TESTS}" +echo + + diff --git a/tests/tableopts.am b/tests/tableopts.am deleted file mode 100644 index bf0672f..0000000 --- a/tests/tableopts.am +++ /dev/null @@ -1,463 +0,0 @@ -tableopts_opt_nr_Ca_opt_SOURCES = tableopts_opt_nr-Ca.opt.l -tableopts_opt_nr-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Ce_opt_SOURCES = tableopts_opt_nr-Ce.opt.l -tableopts_opt_nr-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Cf_opt_SOURCES = tableopts_opt_nr-Cf.opt.l -tableopts_opt_nr-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_CxF_opt_SOURCES = tableopts_opt_nr-CxF.opt.l -tableopts_opt_nr-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Cm_opt_SOURCES = tableopts_opt_nr-Cm.opt.l -tableopts_opt_nr-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Cem_opt_SOURCES = tableopts_opt_nr-Cem.opt.l -tableopts_opt_nr-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Cae_opt_SOURCES = tableopts_opt_nr-Cae.opt.l -tableopts_opt_nr-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Caef_opt_SOURCES = tableopts_opt_nr-Caef.opt.l -tableopts_opt_nr-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_CaexF_opt_SOURCES = tableopts_opt_nr-CaexF.opt.l -tableopts_opt_nr-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Cam_opt_SOURCES = tableopts_opt_nr-Cam.opt.l -tableopts_opt_nr-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_nr_Caem_opt_SOURCES = tableopts_opt_nr-Caem.opt.l -tableopts_opt_nr-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Ca_opt_SOURCES = tableopts_opt_r-Ca.opt.l -tableopts_opt_r-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Ce_opt_SOURCES = tableopts_opt_r-Ce.opt.l -tableopts_opt_r-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Cf_opt_SOURCES = tableopts_opt_r-Cf.opt.l -tableopts_opt_r-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_CxF_opt_SOURCES = tableopts_opt_r-CxF.opt.l -tableopts_opt_r-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Cm_opt_SOURCES = tableopts_opt_r-Cm.opt.l -tableopts_opt_r-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Cem_opt_SOURCES = tableopts_opt_r-Cem.opt.l -tableopts_opt_r-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Cae_opt_SOURCES = tableopts_opt_r-Cae.opt.l -tableopts_opt_r-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Caef_opt_SOURCES = tableopts_opt_r-Caef.opt.l -tableopts_opt_r-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_CaexF_opt_SOURCES = tableopts_opt_r-CaexF.opt.l -tableopts_opt_r-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Cam_opt_SOURCES = tableopts_opt_r-Cam.opt.l -tableopts_opt_r-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_r_Caem_opt_SOURCES = tableopts_opt_r-Caem.opt.l -tableopts_opt_r-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Ca_opt_SOURCES = tableopts_opt_c99-Ca.opt.l -tableopts_opt_c99-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Ce_opt_SOURCES = tableopts_opt_c99-Ce.opt.l -tableopts_opt_c99-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Cf_opt_SOURCES = tableopts_opt_c99-Cf.opt.l -tableopts_opt_c99-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_CxF_opt_SOURCES = tableopts_opt_c99-CxF.opt.l -tableopts_opt_c99-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Cm_opt_SOURCES = tableopts_opt_c99-Cm.opt.l -tableopts_opt_c99-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Cem_opt_SOURCES = tableopts_opt_c99-Cem.opt.l -tableopts_opt_c99-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Cae_opt_SOURCES = tableopts_opt_c99-Cae.opt.l -tableopts_opt_c99-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Caef_opt_SOURCES = tableopts_opt_c99-Caef.opt.l -tableopts_opt_c99-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_CaexF_opt_SOURCES = tableopts_opt_c99-CaexF.opt.l -tableopts_opt_c99-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Cam_opt_SOURCES = tableopts_opt_c99-Cam.opt.l -tableopts_opt_c99-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_opt_c99_Caem_opt_SOURCES = tableopts_opt_c99-Caem.opt.l -tableopts_opt_c99-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Ca_ser_SOURCES = tableopts_ser_nr-Ca.ser.l -tableopts_ser_nr-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Ce_ser_SOURCES = tableopts_ser_nr-Ce.ser.l -tableopts_ser_nr-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Cf_ser_SOURCES = tableopts_ser_nr-Cf.ser.l -tableopts_ser_nr-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_CxF_ser_SOURCES = tableopts_ser_nr-CxF.ser.l -tableopts_ser_nr-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Cm_ser_SOURCES = tableopts_ser_nr-Cm.ser.l -tableopts_ser_nr-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Cem_ser_SOURCES = tableopts_ser_nr-Cem.ser.l -tableopts_ser_nr-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Cae_ser_SOURCES = tableopts_ser_nr-Cae.ser.l -tableopts_ser_nr-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Caef_ser_SOURCES = tableopts_ser_nr-Caef.ser.l -tableopts_ser_nr-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_CaexF_ser_SOURCES = tableopts_ser_nr-CaexF.ser.l -tableopts_ser_nr-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Cam_ser_SOURCES = tableopts_ser_nr-Cam.ser.l -tableopts_ser_nr-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_nr_Caem_ser_SOURCES = tableopts_ser_nr-Caem.ser.l -tableopts_ser_nr-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Ca_ser_SOURCES = tableopts_ser_r-Ca.ser.l -tableopts_ser_r-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Ce_ser_SOURCES = tableopts_ser_r-Ce.ser.l -tableopts_ser_r-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Cf_ser_SOURCES = tableopts_ser_r-Cf.ser.l -tableopts_ser_r-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_CxF_ser_SOURCES = tableopts_ser_r-CxF.ser.l -tableopts_ser_r-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Cm_ser_SOURCES = tableopts_ser_r-Cm.ser.l -tableopts_ser_r-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Cem_ser_SOURCES = tableopts_ser_r-Cem.ser.l -tableopts_ser_r-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Cae_ser_SOURCES = tableopts_ser_r-Cae.ser.l -tableopts_ser_r-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Caef_ser_SOURCES = tableopts_ser_r-Caef.ser.l -tableopts_ser_r-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_CaexF_ser_SOURCES = tableopts_ser_r-CaexF.ser.l -tableopts_ser_r-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Cam_ser_SOURCES = tableopts_ser_r-Cam.ser.l -tableopts_ser_r-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_r_Caem_ser_SOURCES = tableopts_ser_r-Caem.ser.l -tableopts_ser_r-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Ca_ser_SOURCES = tableopts_ser_c99-Ca.ser.l -tableopts_ser_c99-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Ce_ser_SOURCES = tableopts_ser_c99-Ce.ser.l -tableopts_ser_c99-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Cf_ser_SOURCES = tableopts_ser_c99-Cf.ser.l -tableopts_ser_c99-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_CxF_ser_SOURCES = tableopts_ser_c99-CxF.ser.l -tableopts_ser_c99-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Cm_ser_SOURCES = tableopts_ser_c99-Cm.ser.l -tableopts_ser_c99-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Cem_ser_SOURCES = tableopts_ser_c99-Cem.ser.l -tableopts_ser_c99-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Cae_ser_SOURCES = tableopts_ser_c99-Cae.ser.l -tableopts_ser_c99-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Caef_ser_SOURCES = tableopts_ser_c99-Caef.ser.l -tableopts_ser_c99-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_CaexF_ser_SOURCES = tableopts_ser_c99-CaexF.ser.l -tableopts_ser_c99-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Cam_ser_SOURCES = tableopts_ser_c99-Cam.ser.l -tableopts_ser_c99-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ser_c99_Caem_ser_SOURCES = tableopts_ser_c99-Caem.ser.l -tableopts_ser_c99-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Ca_ver_SOURCES = tableopts_ver_nr-Ca.ver.l -tableopts_ver_nr-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Ce_ver_SOURCES = tableopts_ver_nr-Ce.ver.l -tableopts_ver_nr-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Cf_ver_SOURCES = tableopts_ver_nr-Cf.ver.l -tableopts_ver_nr-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_CxF_ver_SOURCES = tableopts_ver_nr-CxF.ver.l -tableopts_ver_nr-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Cm_ver_SOURCES = tableopts_ver_nr-Cm.ver.l -tableopts_ver_nr-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Cem_ver_SOURCES = tableopts_ver_nr-Cem.ver.l -tableopts_ver_nr-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Cae_ver_SOURCES = tableopts_ver_nr-Cae.ver.l -tableopts_ver_nr-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Caef_ver_SOURCES = tableopts_ver_nr-Caef.ver.l -tableopts_ver_nr-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_CaexF_ver_SOURCES = tableopts_ver_nr-CaexF.ver.l -tableopts_ver_nr-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Cam_ver_SOURCES = tableopts_ver_nr-Cam.ver.l -tableopts_ver_nr-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_nr_Caem_ver_SOURCES = tableopts_ver_nr-Caem.ver.l -tableopts_ver_nr-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Ca_ver_SOURCES = tableopts_ver_r-Ca.ver.l -tableopts_ver_r-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Ce_ver_SOURCES = tableopts_ver_r-Ce.ver.l -tableopts_ver_r-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Cf_ver_SOURCES = tableopts_ver_r-Cf.ver.l -tableopts_ver_r-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_CxF_ver_SOURCES = tableopts_ver_r-CxF.ver.l -tableopts_ver_r-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Cm_ver_SOURCES = tableopts_ver_r-Cm.ver.l -tableopts_ver_r-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Cem_ver_SOURCES = tableopts_ver_r-Cem.ver.l -tableopts_ver_r-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Cae_ver_SOURCES = tableopts_ver_r-Cae.ver.l -tableopts_ver_r-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Caef_ver_SOURCES = tableopts_ver_r-Caef.ver.l -tableopts_ver_r-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_CaexF_ver_SOURCES = tableopts_ver_r-CaexF.ver.l -tableopts_ver_r-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Cam_ver_SOURCES = tableopts_ver_r-Cam.ver.l -tableopts_ver_r-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_r_Caem_ver_SOURCES = tableopts_ver_r-Caem.ver.l -tableopts_ver_r-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Ca_ver_SOURCES = tableopts_ver_c99-Ca.ver.l -tableopts_ver_c99-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Ce_ver_SOURCES = tableopts_ver_c99-Ce.ver.l -tableopts_ver_c99-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Cf_ver_SOURCES = tableopts_ver_c99-Cf.ver.l -tableopts_ver_c99-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_CxF_ver_SOURCES = tableopts_ver_c99-CxF.ver.l -tableopts_ver_c99-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Cm_ver_SOURCES = tableopts_ver_c99-Cm.ver.l -tableopts_ver_c99-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Cem_ver_SOURCES = tableopts_ver_c99-Cem.ver.l -tableopts_ver_c99-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Cae_ver_SOURCES = tableopts_ver_c99-Cae.ver.l -tableopts_ver_c99-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Caef_ver_SOURCES = tableopts_ver_c99-Caef.ver.l -tableopts_ver_c99-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_CaexF_ver_SOURCES = tableopts_ver_c99-CaexF.ver.l -tableopts_ver_c99-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Cam_ver_SOURCES = tableopts_ver_c99-Cam.ver.l -tableopts_ver_c99-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -tableopts_ver_c99_Caem_ver_SOURCES = tableopts_ver_c99-Caem.ver.l -tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -TABLEOPTS_TESTS = tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver - -tableopts_tables = tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser.tables tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser.tables tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser.tables tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver.tables tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver.tables tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver.tables - -# Begin simple test rules - -array_nr_SOURCES = array_nr.l -array_nr.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -array_r_SOURCES = array_r.l -array_r.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -array_c99_SOURCES = array_c99.l -array_c99.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -basic_nr_SOURCES = basic_nr.l -basic_nr.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -basic_r_SOURCES = basic_r.l -basic_r.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -basic_c99_SOURCES = basic_c99.l -basic_c99.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -extended_nr_SOURCES = extended_nr.l -extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -extended_c99_SOURCES = extended_c99.l -extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -quoteincomment_nr_SOURCES = quoteincomment_nr.l -quoteincomment_nr.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -quoteincomment_c99_SOURCES = quoteincomment_c99.l -quoteincomment_c99.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -reject_nr_SOURCES = reject_nr.l -reject_nr.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -reject_r_SOURCES = reject_r.l -reject_r.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -reject_c99_SOURCES = reject_c99.l -reject_c99.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -reject_ver_SOURCES = reject_ver.l -reject_ver.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -reject_ser_SOURCES = reject_ser.l -reject_ser.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - -# End simple test rules diff --git a/tests/tableopts.sh b/tests/tableopts.sh deleted file mode 100644 index ac30d8a..0000000 --- a/tests/tableopts.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -set -eu -# IFS=$'\n\t' -IFS=' -'' ' - -# This script is present to generate the automake _SOURCES variables -# for the tableopts_* tests. It also generates the linking rules for -# each test since automake isn't able to handle the pattern rules that -# would be natural to use. Output is written to standard output for -# inclusion in a Makefile.am, typically by redirecting the output and -# then an automake include directive. - -TABLEOPTS_TESTS="" -tableopts_tables="" - -for kind in opt ser ver ; do - for threading in nr r c99 ; do - for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do - bare_opt=${opt#-} - # The filenames must work on case-insensitive filesystems. - bare_opt=$(echo ${bare_opt}| sed 's/F$/xF/') - - testname=tableopts_${kind}_${threading}-${bare_opt}.${kind} - if [ "${TABLEOPTS_TESTS}" = "" ] ;then - TABLEOPTS_TESTS=${testname} - if [ "$kind" = "ser" ] || [ "$kind" = "ver" ] ; then - tableopts_tables=${testname}.tables - fi - else - TABLEOPTS_TESTS="${TABLEOPTS_TESTS} ${testname}" - if [ "$kind" = "ser" ] || [ "$kind" = "ver" ] ; then - tableopts_tables="${tableopts_tables} ${testname}.tables" - fi - fi - - cat << EOF -tableopts_${kind}_${threading}_${bare_opt}_${kind}_SOURCES = ${testname}.l -${testname}.l: \$(srcdir)/tableopts.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4 - \$(SHELL) \$(srcdir)/testmaker.sh \$@ - -EOF - done - done -done - -echo TABLEOPTS_TESTS = "${TABLEOPTS_TESTS}" -echo -echo tableopts_tables = "${tableopts_tables}" -# User can pass in a list of tesrs for which ti geneate build productions -printf "\n# Begin simple test rules\n\n" -for test in "$@"; do - stem=$(echo "${test}" | sed s/_.*//) - echo "${test}_SOURCES = ${test}.l" - echo "${test}.l: \$(srcdir)/${stem}.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" - # we're deliberately single-quoting this because we _don't_ want those variables to be expanded yet - # shellcheck disable=2016 - printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' -done -printf "# End simple test rules\n" diff --git a/tests/testmaker.sh b/tests/testmaker.sh index b03bb1f..3724aec 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -6,12 +6,10 @@ # The single argument is a testfile name to be generated. # With the -d option, dump to stdourather than crating the file. # -# A typical table test load name: tableopts_opt_nr_Ca_opt, this breaks -# down as tableopts_{tag}_{backend}_{compression}_{tag}. -# The backend field can be nr, r, c99 and will eventually have more values. -# The compression options are the flags that woulld nprmally be passed to -# Flex; the possibilities are Ca Ce Cf CxF Cm Cem Cae Caef CaexF Cam Caem. -# +# To add a new back end named "fpp", append "|foo" to the +# string literal below. +backends="c99" + if [ "$1" = -d ] ; then shift outdev=/dev/stdout @@ -40,27 +38,21 @@ stem=$1 options="" backend=nr for part in "$@"; do - # This is the only pace in this script that you need to modify - # to add a new back end - just add a line on the pattern of - # the c99 one. Of course testmaker.m4 will require the - # right boilerplate code for this to work. - # - # Yes, cpp is an alias for nr. case ${part} in nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; - c99) backend=r; options="${options} reentrant emit=\"c99\"" ;; + ${backends}) backend=r; options="${options} reentrant emit=\"${part}\"" ;; ser) serialization=yes ;; ver) serialization=yes; options="${options} tables-verify" ;; Ca) options="${options} align" ;; Ce) options="${options} ecs" ;; Cf) options="${options} full" ;; - CxF) options="${options} fast" ;; + CxF|Cxf) options="${options} fast" ;; Cm) options="${options} meta-ecs";; Cem) options="${options} ecs meta-ecs" ;; Cae) options="${options} align ecs" ;; Caef) options="${options} align ecs full" ;; - CaexF) options="${options} algin ecs fast" ;; + CaexF|Caexf) options="${options} algin ecs fast" ;; Cam) options="${options} align meta-ecs" ;; Caem) options="${options} align ecs meta-ecs" ;; esac -- cgit v1.2.1 From ee9f33ac5dfb09616987b148b55bc819dc73a71d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 09:29:26 -0400 Subject: Convert the "posix" test to be ruleset-based... ...so it will run automatically on all back ends. --- tests/.gitignore | 21 +++++++++--- tests/Makefile.am | 16 ++++----- tests/posix.rules | 44 +++++++++++++++++++++++++ tests/posix.txt | 1 + tests/posix_c99.l | 80 --------------------------------------------- tests/posix_nr.l | 79 -------------------------------------------- tests/posixly_correct_c99.l | 80 --------------------------------------------- tests/posixly_correct_nr.l | 79 -------------------------------------------- tests/posixlycorrect_c99.l | 80 +++++++++++++++++++++++++++++++++++++++++++++ tests/posixlycorrect_nr.l | 79 ++++++++++++++++++++++++++++++++++++++++++++ tests/ruleset.am | 14 +++++++- tests/testmaker.sh | 2 +- 12 files changed, 240 insertions(+), 335 deletions(-) create mode 100644 tests/posix.rules create mode 100644 tests/posix.txt delete mode 100644 tests/posix_c99.l delete mode 100644 tests/posix_nr.l delete mode 100644 tests/posixly_correct_c99.l delete mode 100644 tests/posixly_correct_nr.l create mode 100644 tests/posixlycorrect_c99.l create mode 100644 tests/posixlycorrect_nr.l diff --git a/tests/.gitignore b/tests/.gitignore index 5bf7fd9..c4dd10f 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -55,6 +55,9 @@ debug_r debug_r.c debug_c99 debug_c99.c +extended_r +extended_r.c +extended_r.l extended_nr extended_nr.c extended_nr.l @@ -91,12 +94,17 @@ multiple_scanners_r multiple_scanners_r_[12].[ch] posix_nr posix_nr.c +posix_nr.l +posix_r +posix_r.c +posix_r.l posix_c99 posix_c99.c -posixly_correct_nr -posixly_correct_nr.c -posixly_correct_c99 -posixly_correct_c99.c +posix_c99.l +posixlycorrect_nr +posixlycorrect_nr.c +posixlycorrect_c99 +posixlycorrect_c99.c prefix_nr prefix_nr.c prefix_r @@ -108,6 +116,9 @@ pthread.c quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l +quoteincomment_r +quoteincomment_r.c +quoteincomment_r.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l @@ -142,7 +153,7 @@ string_r string_r.c string_c99 string_c99.c -tableopts*.l +tableopts* top top.[ch] yyextra_nr diff --git a/tests/Makefile.am b/tests/Makefile.am index 285e6fa..7e1a331 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -86,10 +86,8 @@ SPORADIC_TESTS = \ mem_c99 \ multiple_scanners_nr \ multiple_scanners_r \ - posix_nr \ - posix_c99 \ - posixly_correct_nr \ - posixly_correct_c99 \ + posixlycorrect_nr \ + posixlycorrect_c99 \ prefix_nr \ prefix_r \ prefix_c99 \ @@ -165,10 +163,8 @@ multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_ nodist_multiple_scanners_nr_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h -posix_nr_SOURCES = posix_nr.l -posix_c99_SOURCES = posix_c99.l -posixly_correct_nr_SOURCES = posixly_correct_nr.l -posixly_correct_c99_SOURCES = posixly_correct_c99.l +posixlycorrect_nr_SOURCES = posixlycorrect_nr.l +posixlycorrect_c99_SOURCES = posixlycorrect_c99.l prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l prefix_c99_SOURCES = prefix_c99.l @@ -291,10 +287,10 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c @if test ! -f $@; then rm -f $<; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi -posixly_correct_nr.c: posixly_correct_nr.l $(FLEX) +posixlycorrect_nr.c: posixlycorrect_nr.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< -posixly_correct_c99.c: posixly_correct_c99.l $(FLEX) +posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< top_main.$(OBJEXT): top.h diff --git a/tests/posix.rules b/tests/posix.rules new file mode 100644 index 0000000..bfcee1c --- /dev/null +++ b/tests/posix.rules @@ -0,0 +1,44 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + * The input file should contain just the second string. + */ +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option nounput nomain noyywrap noinput +%option warn posix-compat + +%% + +ab{3} { } +\n { } +. {M4_TEST_FAILMESSAGE} + +%% +M4_TEST_POSTAMBLE`'dnl diff --git a/tests/posix.txt b/tests/posix.txt new file mode 100644 index 0000000..753ff4f --- /dev/null +++ b/tests/posix.txt @@ -0,0 +1 @@ +ababab diff --git a/tests/posix_c99.l b/tests/posix_c99.l deleted file mode 100644 index 7f50492..0000000 --- a/tests/posix_c99.l +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn posix-compat - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posix_nr.l b/tests/posix_nr.l deleted file mode 100644 index f1851d8..0000000 --- a/tests/posix_nr.l +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn posix-compat - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posixly_correct_c99.l b/tests/posixly_correct_c99.l deleted file mode 100644 index 85e5258..0000000 --- a/tests/posixly_correct_c99.l +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posixly_correct_nr.l b/tests/posixly_correct_nr.l deleted file mode 100644 index 715bb27..0000000 --- a/tests/posixly_correct_nr.l +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - */ -#include -#include -#include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; - -%% - - -int main (void) -{ - YY_BUFFER_STATE state; - int i; - - yyin = stdin; - yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); - } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l new file mode 100644 index 0000000..85e5258 --- /dev/null +++ b/tests/posixlycorrect_c99.l @@ -0,0 +1,80 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option emit="c99" +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/posixlycorrect_nr.l b/tests/posixlycorrect_nr.l new file mode 100644 index 0000000..715bb27 --- /dev/null +++ b/tests/posixlycorrect_nr.l @@ -0,0 +1,79 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +%{ +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + */ +#include +#include +#include "config.h" + +#define NUM_TESTS 1 +char * tests[NUM_TESTS] = { "ababab"}; +int main(void); + +int tests_ok[NUM_TESTS] = { 0 }; + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + +ab{3} tests_ok[0] = 1; return 0; +.|\n return 0; + +%% + + +int main (void) +{ + YY_BUFFER_STATE state; + int i; + + yyin = stdin; + yyout = stdout; + + /* Run the tests */ + for (i=0; i < NUM_TESTS; i++){ + printf("Testing: test_scan_string(%s): ", tests[i]); + state = test_scan_string(tests[i]); + testlex(); + yy_delete_buffer(state); + printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + } + + for (i=0; i < NUM_TESTS; i++) + if (!tests_ok[i]) + exit(1); + + printf("TEST RETURNING OK.\n"); + return 0; +} diff --git a/tests/ruleset.am b/tests/ruleset.am index dc42d64..bbf7168 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -13,6 +13,10 @@ extended_nr_SOURCES = extended_nr.l extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posix_nr_SOURCES = posix_nr.l +posix_nr.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + quoteincomment_nr_SOURCES = quoteincomment_nr.l quoteincomment_nr.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -169,6 +173,10 @@ extended_r_SOURCES = extended_r.l extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posix_r_SOURCES = posix_r.l +posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + quoteincomment_r_SOURCES = quoteincomment_r.l quoteincomment_r.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -325,6 +333,10 @@ extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posix_c99_SOURCES = posix_c99.l +posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + quoteincomment_c99_SOURCES = quoteincomment_c99.l quoteincomment_c99.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -470,5 +482,5 @@ tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $ $(SHELL) $(srcdir)/testmaker.sh $@ # End generated test rules -RULESET_TESTS = array_nr basic_nr extended_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r extended_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 extended_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_TESTS = array_nr basic_nr extended_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r extended_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 extended_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 3724aec..6618838 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -6,7 +6,7 @@ # The single argument is a testfile name to be generated. # With the -d option, dump to stdourather than crating the file. # -# To add a new back end named "fpp", append "|foo" to the +# To add a new back end named "foo", append "|foo" to the # string literal below. backends="c99" -- cgit v1.2.1 From f5017c14b09926f0b5e862dc79ea5bd7feb0d76d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 11:06:15 -0400 Subject: Fix buggy handling of lex compatiblity option introduced during the retargeting work. Not caught because we don't test that option. It's on my TODO list. --- src/scan.l | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scan.l b/src/scan.l index 67d8466..dbd0aab 100644 --- a/src/scan.l +++ b/src/scan.l @@ -386,7 +386,7 @@ M4QEND "]""]" input ctrl.no_yyinput = ! option_sense; yyinput ctrl.no_yyinput = ! option_sense; interactive ctrl.interactive = (trit)option_sense; - lex-compat ctrl.posix_compat = option_sense; + lex-compat ctrl.lex_compat = option_sense; posix-compat ctrl.posix_compat = option_sense; line ctrl.gen_line_dirs = option_sense; main { @@ -541,7 +541,7 @@ M4QEND "]""]" "\"" BEGIN(QUOTE); return '"'; "{"/[[:digit:]] { BEGIN(NUM); - if ( ctrl.posix_compat || ctrl.posix_compat ) + if ( ctrl.lex_compat || ctrl.posix_compat ) return BEGIN_REPEAT_POSIX; else return BEGIN_REPEAT_FLEX; @@ -725,7 +725,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ if (end_is_ws) unput(end_ch); - if ( ctrl.posix_compat || nmdefptr[0] == '^' || + if ( ctrl.lex_compat || nmdefptr[0] == '^' || (len > 0 && nmdefptr[len - 1] == '$') || (end_is_ws && trlcontxt && !sf_skip_ws())) { /* don't use ()'s after all */ @@ -755,7 +755,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ } "(?#" { - if (ctrl.posix_compat || ctrl.posix_compat){ + if (ctrl.lex_compat || ctrl.posix_compat){ /* Push back the "?#" and treat it like a normal parens. */ yyless(1); sf_push(); @@ -766,7 +766,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ } "(?" { sf_push(); - if (ctrl.posix_compat || ctrl.posix_compat) + if (ctrl.lex_compat || ctrl.posix_compat) /* Push back the "?" and treat it like a normal parens. */ yyless(1); else @@ -888,7 +888,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ "," return ','; "}" { BEGIN(SECT2); - if ( ctrl.posix_compat || ctrl.posix_compat ) + if ( ctrl.lex_compat || ctrl.posix_compat ) return END_REPEAT_POSIX; else return END_REPEAT_FLEX; -- cgit v1.2.1 From efb179b87d8301394d87221faf38ea488f52b75f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 12:20:29 -0400 Subject: Use wildcarding and negation toi cut the verbiage in tests/.gitignore --- tests/.gitignore | 75 ++++++++++---------------------------------------------- 1 file changed, 13 insertions(+), 62 deletions(-) diff --git a/tests/.gitignore b/tests/.gitignore index c4dd10f..4bff08e 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,24 +6,10 @@ alloc_extra_nr alloc_extra_nr.c alloc_extra_c99 alloc_extra_c99.c -array_nr.l -array_nr -array_nr.c -array_r -array_r.c -array_r.l -array_c99 -array_c99.c -array_c99.l -basic_nr -basic_nr.c -basic_nr.l -basic_r -basic_r.c -basic_r.l -basic_c99 -basic_c99.c -basic_c99.l +array_* +!array.rules +basic_* +!basic.rules bison_nr bison_nr_scanner.[ch] bison_nr_parser.[ch] @@ -55,15 +41,8 @@ debug_r debug_r.c debug_c99 debug_c99.c -extended_r -extended_r.c -extended_r.l -extended_nr -extended_nr.c -extended_nr.l -extended_c99 -extended_c99.c -extended_c99.l +extended_* +!extended.rules header_nr header_nr_scanner.[ch] header_r @@ -92,15 +71,8 @@ multiple_scanners_nr multiple_scanners_nr_[12].[ch] multiple_scanners_r multiple_scanners_r_[12].[ch] -posix_nr -posix_nr.c -posix_nr.l -posix_r -posix_r.c -posix_r.l -posix_c99 -posix_c99.c -posix_c99.l +posix_* +!posix.rules posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_c99 @@ -113,36 +85,14 @@ prefix_c99 prefix_c99.c pthread.pthread pthread.c -quoteincomment_nr -quoteincomment_nr.c -quoteincomment_nr.l -quoteincomment_r -quoteincomment_r.c -quoteincomment_r.l -quoteincomment_c99 -quoteincomment_c99.c -quoteincomment_c99.l +quoteincomment_* +quoteincomment.rules quotes_nr quotes_nr.c quotes_c99 quotes_c99.c -reject_nr -reject_nr.c -reject_nr.l -reject_r -reject_r.c -reject_r.l -reject_c99 -reject_c99.c -reject_c99.l -reject_ser -reject_ser.c -reject_ser.l -reject_ser.table -reject_ver -reject_ver.c -reject_ver.l -reject_ver.table +reject* +!reject.rules rescan_nr.direct rescan_nr.direct.c rescan_r.direct @@ -154,6 +104,7 @@ string_r.c string_c99 string_c99.c tableopts* +!tableopts.rules top top.[ch] yyextra_nr -- cgit v1.2.1 From 97b5bc730fef2f36e34ff6988252eb2d11da90e7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 13:53:48 -0400 Subject: Repair CLEANFILES and EXTRA_DIST in tests/Makefile.am/ My previous changes were based on incorrect assumptions about time of evaluation. --- tests/Makefile.am | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++--- tests/ruleset.am | 1 + tests/ruleset.sh | 4 ++ 3 files changed, 124 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 7e1a331..b39a827 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -191,11 +191,73 @@ yyextra_c99_SOURCES = yyextra_c99.l # it. CLEANFILES = \ - $(subst no_bison_stub.c, , $(shell ls *.c | grep -v "_main.c")) \ - $(shell ls *.cc | grep -v "_main.cc") - ${RULEST_TESTS} \ - $(patsubst %, %.l, ${RULESET_TESTS}) \ - *.h *.tables + alloc_extra_nr.c \ + alloc_extra_c99.c \ + bison_nr_parser.c \ + bison_nr_parser.h \ + bison_nr_scanner.c \ + bison_nr_scanner.h \ + bison_yylloc_parser.c \ + bison_yylloc_parser.h \ + bison_yylloc_scanner.c \ + bison_yylloc_scanner.h \ + bison_yylval_parser.c \ + bison_yylval_parser.h \ + bison_yylval_scanner.c \ + bison_yylval_scanner.h \ + c_cxx_nr.cc \ + c_cxx_r.cc \ + ccl_nr.c \ + ccl_c99.c \ + cxx_basic.cc \ + cxx_multiple_scanners_1.cc \ + cxx_multiple_scanners_2.cc \ + cxx_restart.cc \ + cxx_yywrap.cc \ + debug_nr.c \ + debug_r.c \ + debug_c99.c \ + header_nr_scanner.c \ + header_nr_scanner.h \ + header_r_scanner.c \ + header_r_scanner.h \ + include_by_buffer.direct.c \ + include_by_push.direct.c \ + include_by_reentrant.direct.c \ + lineno_nr.c \ + lineno_r.c \ + lineno_c99.c \ + lineno_trailing.c \ + mem_nr.c \ + mem_r.c \ + mem_99.c \ + multiple_scanners_nr_1.c \ + multiple_scanners_nr_1.h \ + multiple_scanners_nr_2.c \ + multiple_scanners_nr_2.h \ + multiple_scanners_r_1.c \ + multiple_scanners_r_1.h \ + multiple_scanners_r_2.c \ + multiple_scanners_r_2.h \ + posixly_correct_nr.c \ + posixly_correct_c99.c \ + prefix_nr.c \ + prefix_r.c \ + prefix_c99.c \ + pthread.c \ + quotes_nr.c \ + quotes_c99.c \ + rescan_nr.direct.c \ + rescan_r.direct.c \ + string_nr.c \ + string_r.c \ + string_c99.c \ + string_c99.c \ + top.c \ + top.h \ + yyextra_nr.c \ + yyextra_c99.c \ + $(RULESET_REMOVABLES) dist-hook: chmod u+w $(distdir) && \ @@ -203,7 +265,58 @@ dist-hook: rm -f $(distdir)/$$file \ ; done -EXTRA_DIST = README *.txt testmaker.m4 +EXTRA_DIST = \ + README \ + testmaker.m4 \ + alloc_extra.txt \ + array_nr.txt \ + array_r.txt \ + basic_nr.txt \ + basic_r.txt \ + bison_nr.txt \ + bison_yylloc.txt \ + bison_yylval.txt \ + c_cxx_nr.txt \ + c_cxx_r.txt \ + ccl.txt \ + cxx_basic.txt \ + cxx_multiple_scanners.txt \ + cxx_restart.txt \ + cxx_yywrap.txt \ + debug_nr.txt \ + debug_r.txt \ + extended.txt \ + header_nr.txt \ + header_r.txt \ + include_by_buffer.direct.txt \ + include_by_buffer.direct_2.txt \ + include_by_buffer.direct_3.txt \ + include_by_push.direct.txt \ + include_by_push.direct_2.txt \ + include_by_push.direct_3.txt \ + include_by_reentrant.direct.txt \ + include_by_reentrant.direct_2.txt \ + include_by_reentrant.direct_3.txt \ + lineno_nr.one.txt \ + lineno_r.one.txt \ + lineno_trailing.one.txt \ + mem_nr.txt \ + mem_r.txt \ + prefix_nr.txt \ + prefix_r.txt \ + pthread_1.txt \ + pthread_2.txt \ + pthread_3.txt \ + pthread_4.txt \ + pthread_5.txt \ + reject.txt \ + rescan_nr.direct.txt \ + rescan_r.direct.txt \ + quote_in_comment.txt \ + quotes.txt \ + top.txt \ + yyextra.txt \ + tableopts.txt dist_noinst_SCRIPTS = \ ruleset.sh diff --git a/tests/ruleset.am b/tests/ruleset.am index bbf7168..3d76adc 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -483,4 +483,5 @@ tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $ # End generated test rules RULESET_TESTS = array_nr basic_nr extended_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r extended_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 extended_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l extended_nr extended_nr.c extended_nr.l posix_nr posix_nr.c posix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l extended_r extended_r.c extended_r.l posix_r posix_r.c posix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l extended_c99 extended_c99.c extended_c99.l posix_c99 posix_c99.c posix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables diff --git a/tests/ruleset.sh b/tests/ruleset.sh index a4d32ac..c7bcd5b 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -10,6 +10,7 @@ set -eu RULESET_TESTS="" +RULESET_REMOVABLES="" printf "\n# Begin generated test rules\n\n" @@ -22,6 +23,7 @@ for backend in $* ; do # shellcheck disable=2016 printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' RULESET_TESTS="${RULESET_TESTS} ${testname}" + RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l" done for kind in opt ser ver ; do for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do @@ -30,6 +32,7 @@ for backend in $* ; do bare_opt=$(echo ${bare_opt}| sed 's/F$/xF/') testname=tableopts_${kind}_${backend}-${bare_opt}.${kind} RULESET_TESTS="${RULESET_TESTS} ${testname}" + RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l ${testname}.tables" cat << EOF tableopts_${kind}_${backend}_${bare_opt}_${kind}_SOURCES = ${testname}.l ${testname}.l: \$(srcdir)/tableopts.rules \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4 @@ -43,6 +46,7 @@ done printf "# End generated test rules\n" echo RULESET_TESTS = "${RULESET_TESTS}" +echo RULESET_REMOVABLES = "${RULESET_REMOVABLES}" echo -- cgit v1.2.1 From 683fa301a7575e019b96a1f19ed6d5ebe3226e56 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 15:10:27 -0400 Subject: Documentation cleanup - fix a wrong assumption about tests. The quotes test is backend-independent and doesn't need to be run anywhere but C. Also, remove some debris from the C99 skeleton, it injects noise into C output comparisons. --- doc/flex.texi | 4 +- src/c99-flex.skl | 7 ++- tests/.gitignore | 6 +-- tests/Makefile.am | 6 +-- tests/README | 24 +++++----- tests/quotes.l | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/quotes_c99.l | 132 ----------------------------------------------------- tests/quotes_nr.l | 131 ---------------------------------------------------- 8 files changed, 152 insertions(+), 289 deletions(-) create mode 100644 tests/quotes.l delete mode 100644 tests/quotes_c99.l delete mode 100644 tests/quotes_nr.l diff --git a/doc/flex.texi b/doc/flex.texi index 8c6c487..bcc099e 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8817,7 +8817,9 @@ produce code in your desired target langage. Add a test suite for your back end. You should be able to clone one of the existing sets of test loads to get good coverage. Note that is highly unlikely your back end will be accepted into the -flex distribution without a test suite. +flex distribution without a test suite. Fortunately, adapting +the existing tests should not be difficult. There is some guisdance +in the @file{tests/README} file of the source distrbution. @end enumerate Syntactically C-like languages such as Go, Rust, and Java should be easy diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 6a4c245..b229aea 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -9,7 +9,7 @@ %# prescriptive about whitespace and braces is more than usually %# important. So please set your C style to K&R, aka 1TBS with %# tabs when editing this file. Braces around single-statement -%# if/while/for/do/switch/break bodies are mandatory. +%# if/while/for/do/switch/break bodies are mandatory. %# %# Macros for preproc stage. @@ -2098,9 +2098,8 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = YY_G(yy_hold_char); - /* /\* Backing-up info for compressed tables is taken \after/ */ - /* * yy_cp has been incremented for the next state. */ - /* *\/ */ + /* Backing-up info for compressed tables is taken \after/ */ + /* yy_cp has been incremented for the next state. */ yy_cp = YY_G(yy_last_accepting_cpos); m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) diff --git a/tests/.gitignore b/tests/.gitignore index 4bff08e..0eed57c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -87,10 +87,8 @@ pthread.pthread pthread.c quoteincomment_* quoteincomment.rules -quotes_nr -quotes_nr.c -quotes_c99 -quotes_c99.c +quotes +quotes.c reject* !reject.rules rescan_nr.direct diff --git a/tests/Makefile.am b/tests/Makefile.am index b39a827..c53afa8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -91,8 +91,7 @@ SPORADIC_TESTS = \ prefix_nr \ prefix_r \ prefix_c99 \ - quotes_nr \ - quotes_c99 \ + quotes \ string_nr \ string_r \ string_c99 \ @@ -169,8 +168,7 @@ prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l prefix_c99_SOURCES = prefix_c99.l pthread_pthread_SOURCES = pthread.l -quotes_nr_SOURCES = quotes_nr.l -quotes_c99_SOURCES = quotes_c99.l +quotes_SOURCES = quotes.l rescan_nr_direct_SOURCES = rescan_nr.direct.l rescan_r_direct_SOURCES = rescan_r.direct.l string_nr_SOURCES = string_nr.l diff --git a/tests/README b/tests/README index be487ed..5821d15 100644 --- a/tests/README +++ b/tests/README @@ -8,12 +8,6 @@ this directory and its contents. * STRUCTURE OF THE TEST SUITE -The testsuite consists of a large number of tests. In a "simple test", -the check is simply that a scanner consumes all the tokens fed to it -from a text (.txt) file in a maching grammar, not allowing stray -characters to echo through to stdout. This is how we avoid meeding -explicit check files. - Each test is centered around a scanner known to work with the most recent version of flex. In general, after you modify your copy of the flex distribution, you should re-run the test suite. Some of the tests @@ -40,6 +34,11 @@ To build and execute a single test: * HOW TO ADD A NEW TEST TO THE TEST SUITE +** If possible, just write a *.rules file. Exit with status 1 to + indicate failure, e.g. with a "." production if nothing + prior properly consumed every input token. The test machinery + will expand a rules file into tests for all back ends. + ** List your test in the TESTS variable in Makefile.am in this directory. Note that due to the large number of tests, we use variables to group similar tests together. This also helps with @@ -69,16 +68,12 @@ automake test suite harness. A test with an _nr suffix exercises a non-reentrant scanner built with the default cpp back end. -uA test with an _r suffix exercises a reentrant scanner built +A test with an _r suffix exercises a reentrant scanner built with the default cpp back end. A test with a c99 suffix exercises the c99 back end. All C99 scanners are re-entrant. -A test with a _cpp suffix exercises the default cpp back end on a -specification where the reentrant/non-reentrant distinction is -not interesting. - Most tests occur in groups with a common stem in the names, like alloc_extra_ or ccl_. These are exercising the same token grammar under different back ends. As new target languages are added these @@ -88,8 +83,8 @@ back end only. The "generated" tests are made by wrapping boilerplate code around a rules file. The assumption is that the test binary should consume its -test file, exercising some set of Flex features and not allowing -any ko leaxh ti strabdard output +test file, exercising some set of Flex features and not returning +a nonzero status. If you can express your test as a ruleset within in this orotocol, please do so. Those tests are easy to port to new back ends, as that @@ -100,6 +95,9 @@ WHY SOME TESTS ARE MISSING The "top" test is backend-independent; what it's really testing is Flex's ability to accumulate and ship preamble code sections. +The "quotes" test is also backend-indepedent; it's testing that +m4 expansion doesn't leak through the genertated scanner. + The C99 is missing tests for the Bison bridge, header generation, and loadable tables because it omits those features in order to be a simpler starting point for wring new back ends. diff --git a/tests/quotes.l b/tests/quotes.l new file mode 100644 index 0000000..d1b97eb --- /dev/null +++ b/tests/quotes.l @@ -0,0 +1,131 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The point of this test is to be sure our M4 madness does not + * interfere with user code. I particular, we are looking + * for instances of M4 quotes, [[ and ]], in here to make it through the flex + * machinery unscathed. + */ + +/* sect 1 [ 1 ] TEST_XXX */ +/* sect 1 [[ 2 ]] TEST_XXX */ +/* sect 1 [[[ 3 ]]] TEST_XXX */ +/* sect 1 [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 ]] unmatched [[ TEST_XXX */ + +%{ +/* A template scanner file to build "scanner.c". */ +#include +#include +#include "config.h" +#include +/*#include "parser.h" */ + +/* sect 1 block [ 1 ] TEST_XXX */ +/* sect 1 block [[ 2 ]] TEST_XXX */ +/* sect 1 block [[[ 3 ]]] TEST_XXX */ +/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ +/* sect 1 block ]] unmatched [[ TEST_XXX */ + +static int a[1] = {0}; +static int b[1] = {0}; +static int c[1] = {0}; + +static int foo (int i){ + return a[b[c[i]]]; /* sect 1 code TEST_XXX */ +} +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap noinput +%option warn + + +%% + /* indented code [ 1 ] */ + /* indented code [[ 2 ]] */ + /* indented code [[[ 3 ]]] */ + /* indented code [[[[ 4 ]]]] */ + /* indented code ]] unmatched [[ */ +%{ +// non-indented code [ 1 ] +// non-indented code [[ 2 ]] +// non-indented code [[[ 3 ]]] +// non-indented code [[[[ 4 ]]]] +%} + +a /* action comment [ 1 ] */ ; +b /* action comment [[ 2 ]] */ ; +c /* action comment [[[ 3 ]]] */ ; +d /* action comment [[[[ 4 ]]]] */ ; +e /* action comment ]] unmatched [[ */ ; +f return 1+foo(a[b[c[0]]]); +.|\n { + +#if 0 + action code [ 1 ] TEST_XXX + action code [[ 2 ]] TEST_XXX + action code [[[ 3 ]]] TEST_XXX + action code [[[[ 4 ]]]] TEST_XXX + action code ]] unmatched [[ TEST_XXX +#endif + /* action block [ 1 ] TEST_XXX */ + /* action block [[ 2 ]] TEST_XXX */ + /* action block [[[ 3 ]]] TEST_XXX */ + /* action block [[[[ 4 ]]]] TEST_XXX */ + /* action block ]] unmatched [[ TEST_XXX */ + assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); + assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); + assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); + assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); + assert(!strcmp("]]m4_define(alpha, beta)[[", + "]""]m4_""define(alpha, beta)[""[")); + return 1+foo(a[b[c[0]]]); /* TEST_XXX */ + } +%% + +/* sect 3 [ 1 ] TEST_XXX */ +/* sect 3 [[ 2 ]] TEST_XXX */ +/* sect 3 [[[ 3 ]]] TEST_XXX */ +/* sect 3 [[[[ 4 ]]]] TEST_XXX */ +/* sect 3 ]] unmatched [[ TEST_XXX */ +static int bar (int i){ + return c[b[a[i]]]; /* sect 3 code TEST_XXX */ +} +int main(void); + +#define CONCAT_IDENTS(a, b) a##b +int +main (void) +{ + /* m4_m4exit(100) */ + FILE *M4_YY_NOT_IN_HEADER = stdin; + yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); + yyout = stdout; + while (yylex()) + ; + assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); + printf("TEST RETURNING OK.\n"); + return bar(0); +} + diff --git a/tests/quotes_c99.l b/tests/quotes_c99.l deleted file mode 100644 index 5784f2e..0000000 --- a/tests/quotes_c99.l +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* The point of this test is to be sure our M4 madness does not - * interfere with user code. I particular, we are looking - * for instances of M4 quotes, [[ and ]], in here to make it through the flex - * machinery unscathed. - */ - -/* sect 1 [ 1 ] TEST_XXX */ -/* sect 1 [[ 2 ]] TEST_XXX */ -/* sect 1 [[[ 3 ]]] TEST_XXX */ -/* sect 1 [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 ]] unmatched [[ TEST_XXX */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -#include -/*#include "parser.h" */ - -/* sect 1 block [ 1 ] TEST_XXX */ -/* sect 1 block [[ 2 ]] TEST_XXX */ -/* sect 1 block [[[ 3 ]]] TEST_XXX */ -/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 block ]] unmatched [[ TEST_XXX */ - -static int a[1] = {0}; -static int b[1] = {0}; -static int c[1] = {0}; - -static int foo (int i){ - return a[b[c[i]]]; /* sect 1 code TEST_XXX */ -} -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - /* indented code [ 1 ] */ - /* indented code [[ 2 ]] */ - /* indented code [[[ 3 ]]] */ - /* indented code [[[[ 4 ]]]] */ - /* indented code ]] unmatched [[ */ -%{ -// non-indented code [ 1 ] -// non-indented code [[ 2 ]] -// non-indented code [[[ 3 ]]] -// non-indented code [[[[ 4 ]]]] -%} - -a /* action comment [ 1 ] */ ; -b /* action comment [[ 2 ]] */ ; -c /* action comment [[[ 3 ]]] */ ; -d /* action comment [[[[ 4 ]]]] */ ; -e /* action comment ]] unmatched [[ */ ; -f return 1+foo(a[b[c[0]]]); -.|\n { - -#if 0 - action code [ 1 ] TEST_XXX - action code [[ 2 ]] TEST_XXX - action code [[[ 3 ]]] TEST_XXX - action code [[[[ 4 ]]]] TEST_XXX - action code ]] unmatched [[ TEST_XXX -#endif - /* action block [ 1 ] TEST_XXX */ - /* action block [[ 2 ]] TEST_XXX */ - /* action block [[[ 3 ]]] TEST_XXX */ - /* action block [[[[ 4 ]]]] TEST_XXX */ - /* action block ]] unmatched [[ TEST_XXX */ - assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); - assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); - assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); - assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); - assert(!strcmp("]]m4_define(alpha, beta)[[", - "]""]m4_""define(alpha, beta)[""[")); - return 1+foo(a[b[c[0]]]); /* TEST_XXX */ - } -%% - -/* sect 3 [ 1 ] TEST_XXX */ -/* sect 3 [[ 2 ]] TEST_XXX */ -/* sect 3 [[[ 3 ]]] TEST_XXX */ -/* sect 3 [[[[ 4 ]]]] TEST_XXX */ -/* sect 3 ]] unmatched [[ TEST_XXX */ -static int bar (int i){ - return c[b[a[i]]]; /* sect 3 code TEST_XXX */ -} -int main(void); - -#define CONCAT_IDENTS(a, b) a##b -int -main (void) -{ - /* m4_m4exit(100) */ - FILE *M4_YY_NOT_IN_HEADER = stdin; - yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); - yyout = stdout; - while (yylex()) - ; - assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); - printf("TEST RETURNING OK.\n"); - return bar(0); -} - diff --git a/tests/quotes_nr.l b/tests/quotes_nr.l deleted file mode 100644 index d1b97eb..0000000 --- a/tests/quotes_nr.l +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* The point of this test is to be sure our M4 madness does not - * interfere with user code. I particular, we are looking - * for instances of M4 quotes, [[ and ]], in here to make it through the flex - * machinery unscathed. - */ - -/* sect 1 [ 1 ] TEST_XXX */ -/* sect 1 [[ 2 ]] TEST_XXX */ -/* sect 1 [[[ 3 ]]] TEST_XXX */ -/* sect 1 [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 ]] unmatched [[ TEST_XXX */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -#include -/*#include "parser.h" */ - -/* sect 1 block [ 1 ] TEST_XXX */ -/* sect 1 block [[ 2 ]] TEST_XXX */ -/* sect 1 block [[[ 3 ]]] TEST_XXX */ -/* sect 1 block [[[[ 4 ]]]] TEST_XXX */ -/* sect 1 block ]] unmatched [[ TEST_XXX */ - -static int a[1] = {0}; -static int b[1] = {0}; -static int c[1] = {0}; - -static int foo (int i){ - return a[b[c[i]]]; /* sect 1 code TEST_XXX */ -} -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - /* indented code [ 1 ] */ - /* indented code [[ 2 ]] */ - /* indented code [[[ 3 ]]] */ - /* indented code [[[[ 4 ]]]] */ - /* indented code ]] unmatched [[ */ -%{ -// non-indented code [ 1 ] -// non-indented code [[ 2 ]] -// non-indented code [[[ 3 ]]] -// non-indented code [[[[ 4 ]]]] -%} - -a /* action comment [ 1 ] */ ; -b /* action comment [[ 2 ]] */ ; -c /* action comment [[[ 3 ]]] */ ; -d /* action comment [[[[ 4 ]]]] */ ; -e /* action comment ]] unmatched [[ */ ; -f return 1+foo(a[b[c[0]]]); -.|\n { - -#if 0 - action code [ 1 ] TEST_XXX - action code [[ 2 ]] TEST_XXX - action code [[[ 3 ]]] TEST_XXX - action code [[[[ 4 ]]]] TEST_XXX - action code ]] unmatched [[ TEST_XXX -#endif - /* action block [ 1 ] TEST_XXX */ - /* action block [[ 2 ]] TEST_XXX */ - /* action block [[[ 3 ]]] TEST_XXX */ - /* action block [[[[ 4 ]]]] TEST_XXX */ - /* action block ]] unmatched [[ TEST_XXX */ - assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]")); - assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]")); - assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]")); - assert(!strcmp("]] unmatched [[", "]""] unmatched [""[")); - assert(!strcmp("]]m4_define(alpha, beta)[[", - "]""]m4_""define(alpha, beta)[""[")); - return 1+foo(a[b[c[0]]]); /* TEST_XXX */ - } -%% - -/* sect 3 [ 1 ] TEST_XXX */ -/* sect 3 [[ 2 ]] TEST_XXX */ -/* sect 3 [[[ 3 ]]] TEST_XXX */ -/* sect 3 [[[[ 4 ]]]] TEST_XXX */ -/* sect 3 ]] unmatched [[ TEST_XXX */ -static int bar (int i){ - return c[b[a[i]]]; /* sect 3 code TEST_XXX */ -} -int main(void); - -#define CONCAT_IDENTS(a, b) a##b -int -main (void) -{ - /* m4_m4exit(100) */ - FILE *M4_YY_NOT_IN_HEADER = stdin; - yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER); - yyout = stdout; - while (yylex()) - ; - assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)")); - printf("TEST RETURNING OK.\n"); - return bar(0); -} - -- cgit v1.2.1 From c92f5df6a1f52be3e665c05776d8fb1b3af6988e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 22 Oct 2020 21:03:59 -0400 Subject: Make the ccl test ruleset-based for all back ends. --- tests/.gitignore | 6 ++-- tests/Makefile.am | 8 ++--- tests/ccl.rules | 76 ++++++++++++++++++++++++++++++++++++++++++ tests/ccl_c99.l | 95 ----------------------------------------------------- tests/ccl_nr.l | 96 ------------------------------------------------------ tests/ruleset.am | 16 +++++++-- tests/testmaker.m4 | 5 +++ 7 files changed, 99 insertions(+), 203 deletions(-) create mode 100644 tests/ccl.rules delete mode 100644 tests/ccl_c99.l delete mode 100644 tests/ccl_nr.l diff --git a/tests/.gitignore b/tests/.gitignore index 0eed57c..93d8284 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -23,10 +23,8 @@ c_cxx_nr c_cxx_nr.cc c_cxx_r c_cxx_r.cc -ccl_nr -ccl_nr.c -ccl_c99 -ccl_c99.c +ccl_* +ccl.rules cxx_basic cxx_basic.cc cxx_multiple_scanners diff --git a/tests/Makefile.am b/tests/Makefile.am index c53afa8..c2d82d9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -71,8 +71,6 @@ SPORADIC_TESTS = \ bison_yylval \ c_cxx_nr \ c_cxx_r \ - ccl_nr \ - ccl_c99 \ cxx_basic \ cxx_multiple_scanners \ cxx_restart \ @@ -135,8 +133,6 @@ bison_yylval_SOURCES = no_bison_stub.c endif c_cxx_nr_SOURCES = c_cxx_nr.lll c_cxx_r_SOURCES = c_cxx_r.lll -ccl_nr_SOURCES = ccl_nr.l -ccl_c99_SOURCES = ccl_c99.l cxx_basic_SOURCES = cxx_basic.ll cxx_restart_SOURCES = cxx_restart.ll cxx_multiple_scanners_SOURCES = cxx_multiple_scanners_main.cc cxx_multiple_scanners_1.ll cxx_multiple_scanners_2.ll @@ -205,8 +201,8 @@ CLEANFILES = \ bison_yylval_scanner.h \ c_cxx_nr.cc \ c_cxx_r.cc \ - ccl_nr.c \ - ccl_c99.c \ + ccl_* \ + !ccl.rules \ cxx_basic.cc \ cxx_multiple_scanners_1.cc \ cxx_multiple_scanners_2.cc \ diff --git a/tests/ccl.rules b/tests/ccl.rules new file mode 100644 index 0000000..ef13a2b --- /dev/null +++ b/tests/ccl.rules @@ -0,0 +1,76 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +/* + * Test character-class matching + */ + +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option 8bit +%option nounput nomain noyywrap noinput +%option warn +%% + +^"^alpha:"[[:^alpha:]]+@alpha@\n {M4_TEST_ECHO} +^"^digit:"[[:^digit:]]+@digit@\n {M4_TEST_ECHO} +^"^alnum:"[[:^alnum:]]+@alnum@\n {M4_TEST_ECHO} +^"^upper:"[[:^upper:]]+@upper@\n {M4_TEST_ECHO} +^"^lower:"[[:^lower:]]+@lower@\n {M4_TEST_ECHO} +^"^space:"[[:^space:]]+@space@\n {M4_TEST_ECHO} +^"^blank:"[[:^blank:]]+@blank@\n {M4_TEST_ECHO} +^"^punct:"[[:^punct:]]+@punct@\n {M4_TEST_ECHO} +^"^cntrl:"[[:^cntrl:]]+@cntrl@\n {M4_TEST_ECHO} +^"^xdigit:"[[:^xdigit:]]+@xdigit@\n {M4_TEST_ECHO} + +^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n {M4_TEST_ECHO} +^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n {M4_TEST_ECHO} +^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n {M4_TEST_ECHO} +^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n {M4_TEST_ECHO} +^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n {M4_TEST_ECHO} + +^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n {M4_TEST_ECHO} +^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n {M4_TEST_ECHO} + +^"ia:"(?i:a)+@ia@\n {M4_TEST_ECHO} +^"iabc:"(?i:abc)+@iabc@\n {M4_TEST_ECHO} +^"ia-c:"(?i:[a-c]+)@ia-c@\n {M4_TEST_ECHO} + + /* We don't want this one to match. */ +^"check-a:"(?i:(?-i:A))@\n {M4_TEST_FAILMESSAGE} +^"check-a:"(?i:(?-i:(?i:A)))@\n {M4_TEST_ECHO} + + /* We don't want this one to match. */ +^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n {M4_TEST_FAILMESSAGE} +^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n {M4_TEST_ECHO} + +^"x1:"(?x: a | b )+@x1@\n {M4_TEST_ECHO} +^"x2:"(?x: a | + (?# Comment ) + b + )+@x2@\n {M4_TEST_ECHO} + + +.|\n {M4_TEST_FAILMESSAGE} +%% +M4_TEST_POSTAMBLE`'dnl diff --git a/tests/ccl_c99.l b/tests/ccl_c99.l deleted file mode 100644 index 9511604..0000000 --- a/tests/ccl_c99.l +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) -#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); -^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); - -^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"check-a:"(?i:(?-i:A))@\n err_abort(); -^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); -^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); - -^"x1:"(?x: a | b )+@x1@\n a_ok(); -^"x2:"(?x: a | - (?# Comment ) - b - )+@x2@\n a_ok(); - - -.|\n { err_abort(); } -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/ccl_nr.l b/tests/ccl_nr.l deleted file mode 100644 index 1894b4c..0000000 --- a/tests/ccl_nr.l +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" -/*#include "parser.h" */ - -#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0) -#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0) -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn - - -%% - -^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1; - -^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok(); -^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok(); - -^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1; -^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"check-a:"(?i:(?-i:A))@\n err_abort(); -^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1; - - /* We don't want this one to match. */ -^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort(); -^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok(); - -^"x1:"(?x: a | b )+@x1@\n a_ok(); -^"x2:"(?x: a | - (?# Comment ) - b - )+@x2@\n a_ok(); - - -.|\n { err_abort(); } -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - while (yylex()) - ; - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/ruleset.am b/tests/ruleset.am index 3d76adc..d1daa0d 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -9,6 +9,10 @@ basic_nr_SOURCES = basic_nr.l basic_nr.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +ccl_nr_SOURCES = ccl_nr.l +ccl_nr.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + extended_nr_SOURCES = extended_nr.l extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -169,6 +173,10 @@ basic_r_SOURCES = basic_r.l basic_r.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +ccl_r_SOURCES = ccl_r.l +ccl_r.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + extended_r_SOURCES = extended_r.l extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -329,6 +337,10 @@ basic_c99_SOURCES = basic_c99.l basic_c99.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +ccl_c99_SOURCES = ccl_c99.l +ccl_c99.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -482,6 +494,6 @@ tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $ $(SHELL) $(srcdir)/testmaker.sh $@ # End generated test rules -RULESET_TESTS = array_nr basic_nr extended_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r extended_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 extended_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l extended_nr extended_nr.c extended_nr.l posix_nr posix_nr.c posix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l extended_r extended_r.c extended_r.l posix_r posix_r.c posix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l extended_c99 extended_c99.c extended_c99.l posix_c99 posix_c99.c posix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l posix_nr posix_nr.c posix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l posix_r posix_r.c posix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l posix_c99 posix_c99.c posix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index c0bdbc3..c1dc5fa 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -16,6 +16,8 @@ dnl the emit option required to srt the back end. dnl dnl M4_TEST_COMPRESSION = compression option. dnl +dnl M4_TEST_ECHO = echo the token buffer and continue. +dnl dnl M4_TEST_FAILMESSAGE = a line of code required to issue dnl a dnl failure notification to standard error and exit with a failure status. dnl @@ -39,6 +41,7 @@ define(`M4_TEST_PREAMBLE', `dnl #include %} ')dnl close preamble +define(`M4_TEST_ECHO', `yyecho();') define(`M4_TEST_FAILMESSAGE', `dnl fprintf(stderr,"Invalid line.\n"); exit(-1); ')dnl close failmessage @@ -77,6 +80,7 @@ define(`M4_TEST_PREAMBLE', `dnl #include %} ')dnl close preamble +define(`M4_TEST_ECHO', `yyecho();') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"Invalid line.\n"); exit(-1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) @@ -123,6 +127,7 @@ import ( %} %option emit="go" ')dnl close preamble +define(`M4_TEST_ECHO', `yyecho()') define(`M4_TEST_FAILMESSAGE', `log.Fatal("Invalid line"); os.Exit(-1);') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { -- cgit v1.2.1 From a5b4a2ee966300982e8a19f17afe8e7ebe99a2e3 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 23 Oct 2020 11:28:07 -0400 Subject: Force reentrancy on on the c99 back end... ...amd repair the one c99 test with a non-reentrant main. The reentrant no longer needs to be specified in an %option line for C99. --- src/c99-flex.skl | 5 +++++ src/main.c | 3 +-- tests/alloc_extra_c99.l | 1 - tests/debug_c99.l | 2 +- tests/lineno_c99.l | 2 +- tests/mem_c99.l | 2 +- tests/posixlycorrect_c99.l | 24 +++++++++++------------- tests/prefix_c99.l | 1 - tests/string_c99.l | 2 +- tests/testmaker.sh | 2 +- tests/yyextra_c99.l | 1 - 11 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index b229aea..fe49998 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -60,6 +60,11 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 %% [0.0] Make hook macros available to Flex +/* Temporary until the non-reentrant code is stripped out */ +m4_define([[M4_YY_REENTRANT]], [[]]) +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[m4_define([[M4_MODE_REENTRANT_TEXT_IS_ARRAY]])]]) +m4_undefine([[M4_YY_NOT_REENTRANT]]) + m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl #ifndef M4_MODE_PREFIX[[HEADER_H]] #define M4_MODE_PREFIX[[HEADER_H]] diff --git a/src/main.c b/src/main.c index a0795ad..e358027 100644 --- a/src/main.c +++ b/src/main.c @@ -1471,8 +1471,7 @@ void readin (void) visible_define ("M4_YY_REENTRANT"); if (ctrl.yytext_is_array) visible_define ("M4_MODE_REENTRANT_TEXT_IS_ARRAY"); - } else - visible_define ("M4_YY_NOT_REENTRANT"); + } if (ctrl.do_main == trit_true) visible_define_str ( "YY_MAIN", "1"); diff --git a/tests/alloc_extra_c99.l b/tests/alloc_extra_c99.l index fe78939..ccc035d 100644 --- a/tests/alloc_extra_c99.l +++ b/tests/alloc_extra_c99.l @@ -50,7 +50,6 @@ static void check_extra ( yyscan_t scanner ); %option nounput nomain noyywrap nodefault noinput %option warn %option extra-type="struct Check *" -%option reentrant %option noyyalloc diff --git a/tests/debug_c99.l b/tests/debug_c99.l index 2bc01fb..72d16fd 100644 --- a/tests/debug_c99.l +++ b/tests/debug_c99.l @@ -32,7 +32,7 @@ %option emit="c99" %option 8bit prefix="test" %option nounput nomain noyywrap noinput -%option warn debug reentrant +%option warn debug %% .+ { } diff --git a/tests/lineno_c99.l b/tests/lineno_c99.l index ac509ec..be46e90 100644 --- a/tests/lineno_c99.l +++ b/tests/lineno_c99.l @@ -36,7 +36,7 @@ %option emit="c99" %option 8bit prefix="test" -%option nounput nomain noyywrap noinput yylineno reentrant +%option nounput nomain noyywrap noinput yylineno %option warn WORD [[:alpha:]]+ diff --git a/tests/mem_c99.l b/tests/mem_c99.l index a6df306..b7bf835 100644 --- a/tests/mem_c99.l +++ b/tests/mem_c99.l @@ -42,7 +42,7 @@ %option emit="c99" %option 8bit prefix="test" %option nounput nomain noyywrap noinput noyy_top_state -%option warn stack nodefault reentrant +%option warn stack nodefault %option noyyalloc noyyrealloc noyyfree %x parens diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l index 85e5258..ccd992d 100644 --- a/tests/posixlycorrect_c99.l +++ b/tests/posixlycorrect_c99.l @@ -34,18 +34,15 @@ #define NUM_TESTS 1 char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - int tests_ok[NUM_TESTS] = { 0 }; %} %option emit="c99" -%option 8bit prefix="test" +%option 8bit %option nounput nomain noyywrap noinput %option warn - %% ab{3} tests_ok[0] = 1; return 0; @@ -53,28 +50,29 @@ ab{3} tests_ok[0] = 1; return 0; %% - -int main (void) +int main (int argc, char **argv) { - YY_BUFFER_STATE state; + yyscan_t lexer; int i; + YY_BUFFER_STATE state; - yyin = stdin; - yyout = stdout; + yylex_init( &lexer ); + yyset_out ( stdout,lexer); + yyset_in ( stdin, lexer); /* Run the tests */ for (i=0; i < NUM_TESTS; i++){ printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); + state = yy_scan_string(tests[i], lexer); + yylex(lexer); + yy_delete_buffer(state, lexer); printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); } - for (i=0; i < NUM_TESTS; i++) if (!tests_ok[i]) exit(1); + yylex_destroy( lexer ); printf("TEST RETURNING OK.\n"); return 0; } diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l index 4baebea..d66df29 100644 --- a/tests/prefix_c99.l +++ b/tests/prefix_c99.l @@ -30,7 +30,6 @@ %} %option emit="c99" -%option reentrant %option 8bit prefix="FOO" %option nounput nomain noyywrap noinput %option warn diff --git a/tests/string_c99.l b/tests/string_c99.l index 656ea18..2cf7eae 100644 --- a/tests/string_c99.l +++ b/tests/string_c99.l @@ -35,7 +35,7 @@ %option emit="c99" %option 8bit prefix="test" %option nounput nomain nodefault noyywrap noinput -%option warn reentrant +%option warn %% diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 6618838..2b0bbf3 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -41,7 +41,7 @@ for part in "$@"; do case ${part} in nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; - ${backends}) backend=r; options="${options} reentrant emit=\"${part}\"" ;; + ${backends}) backend=r; options="${options} emit=\"${part}\"" ;; ser) serialization=yes ;; ver) serialization=yes; options="${options} tables-verify" ;; Ca) options="${options} align" ;; diff --git a/tests/yyextra_c99.l b/tests/yyextra_c99.l index 66e2b4b..4486882 100644 --- a/tests/yyextra_c99.l +++ b/tests/yyextra_c99.l @@ -50,7 +50,6 @@ static void append_char (char c, yyscan_t scanner ); %option 8bit prefix="test" %option nounput nomain noyywrap nodefault noyyinput %option warn -%option reentrant %option extra-type="struct Buffer *" %% -- cgit v1.2.1 From 8bec427f3ea3d755dd039f2946340afb30f65a1e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 23 Oct 2020 22:29:14 -0400 Subject: Turn the posixlycorrect test into a ruleset-based one. Required generating the posixlycorrrect rules with tests/ruleset.sh so all platforms will have them. --- tests/.gitignore | 6 ++---- tests/Makefile.am | 14 +------------- tests/posixlycorrect.rules | 44 ++++++++++++++++++++++++++++++++++++++++++ tests/posixlycorrect.txt | 1 + tests/posixlycorrect_c99.l | 41 ++++++++++++--------------------------- tests/posixlycorrect_nr.l | 48 +++++++++++++--------------------------------- tests/ruleset.am | 22 +++++++++++++++++++-- tests/ruleset.sh | 9 +++++++++ 8 files changed, 102 insertions(+), 83 deletions(-) create mode 100644 tests/posixlycorrect.rules create mode 100644 tests/posixlycorrect.txt diff --git a/tests/.gitignore b/tests/.gitignore index 93d8284..e6ae36e 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -71,10 +71,8 @@ multiple_scanners_r multiple_scanners_r_[12].[ch] posix_* !posix.rules -posixlycorrect_nr -posixlycorrect_nr.c -posixlycorrect_c99 -posixlycorrect_c99.c +posixlycorrect_* +!posixlycorrect.rules prefix_nr prefix_nr.c prefix_r diff --git a/tests/Makefile.am b/tests/Makefile.am index c2d82d9..240c220 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -84,8 +84,6 @@ SPORADIC_TESTS = \ mem_c99 \ multiple_scanners_nr \ multiple_scanners_r \ - posixlycorrect_nr \ - posixlycorrect_c99 \ prefix_nr \ prefix_r \ prefix_c99 \ @@ -158,8 +156,6 @@ multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_ nodist_multiple_scanners_nr_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h -posixlycorrect_nr_SOURCES = posixlycorrect_nr.l -posixlycorrect_c99_SOURCES = posixlycorrect_c99.l prefix_nr_SOURCES = prefix_nr.l prefix_r_SOURCES = prefix_r.l prefix_c99_SOURCES = prefix_c99.l @@ -224,7 +220,7 @@ CLEANFILES = \ lineno_trailing.c \ mem_nr.c \ mem_r.c \ - mem_99.c \ + mem_c99.c \ multiple_scanners_nr_1.c \ multiple_scanners_nr_1.h \ multiple_scanners_nr_2.c \ @@ -233,8 +229,6 @@ CLEANFILES = \ multiple_scanners_r_1.h \ multiple_scanners_r_2.c \ multiple_scanners_r_2.h \ - posixly_correct_nr.c \ - posixly_correct_c99.c \ prefix_nr.c \ prefix_r.c \ prefix_c99.c \ @@ -394,12 +388,6 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c @if test ! -f $@; then rm -f $<; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi -posixlycorrect_nr.c: posixlycorrect_nr.l $(FLEX) - $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< - -posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) - $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< - top_main.$(OBJEXT): top.h top.h: top.c diff --git a/tests/posixlycorrect.rules b/tests/posixlycorrect.rules new file mode 100644 index 0000000..246ab94 --- /dev/null +++ b/tests/posixlycorrect.rules @@ -0,0 +1,44 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The goal of this test is to verify that we are getting the counter-intuitive + * posix behavior of the repeat operator `{}'. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + * The input file should contain just the second string. + */ +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option nounput nomain noyywrap noinput +%option warn + +%% + +ab{3} { } +\n { } +. {M4_TEST_FAILMESSAGE} + +%% +M4_TEST_POSTAMBLE`'dnl diff --git a/tests/posixlycorrect.txt b/tests/posixlycorrect.txt new file mode 100644 index 0000000..753ff4f --- /dev/null +++ b/tests/posixlycorrect.txt @@ -0,0 +1 @@ +ababab diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l index ccd992d..1538a04 100644 --- a/tests/posixlycorrect_c99.l +++ b/tests/posixlycorrect_c99.l @@ -1,3 +1,5 @@ + + /* * This file is part of flex. * @@ -15,63 +17,44 @@ * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED `AS IS' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ -%{ /* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. + * posix behavior of the repeat operator {}. * * ab{3} - In traditional flex, this matches "abbb". * In posix, this matches "ababab". + * The input file should contain just the second string. */ -#include -#include +%{ #include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int tests_ok[NUM_TESTS] = { 0 }; - +#include %} %option emit="c99" -%option 8bit %option nounput nomain noyywrap noinput %option warn %% -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; +ab{3} { } +\n { } +. {fprintf(stderr,"Invalid line.\n"); exit(-1);} %% - int main (int argc, char **argv) { yyscan_t lexer; - int i; - YY_BUFFER_STATE state; - yylex_init( &lexer ); yyset_out ( stdout,lexer); yyset_in ( stdin, lexer); - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = yy_scan_string(tests[i], lexer); - yylex(lexer); - yy_delete_buffer(state, lexer); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + while( yylex(lexer) ) + { } - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - yylex_destroy( lexer ); printf("TEST RETURNING OK.\n"); return 0; diff --git a/tests/posixlycorrect_nr.l b/tests/posixlycorrect_nr.l index 715bb27..262979a 100644 --- a/tests/posixlycorrect_nr.l +++ b/tests/posixlycorrect_nr.l @@ -1,3 +1,4 @@ + /* * This file is part of flex. * @@ -15,65 +16,42 @@ * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED `AS IS' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ -%{ /* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. + * posix behavior of the repeat operator {}. * * ab{3} - In traditional flex, this matches "abbb". * In posix, this matches "ababab". + * The input file should contain just the second string. */ -#include -#include +%{ #include "config.h" - -#define NUM_TESTS 1 -char * tests[NUM_TESTS] = { "ababab"}; -int main(void); - -int tests_ok[NUM_TESTS] = { 0 }; - +#include %} -%option 8bit prefix="test" %option nounput nomain noyywrap noinput %option warn - %% -ab{3} tests_ok[0] = 1; return 0; -.|\n return 0; +ab{3} { } +\n { } +. {fprintf(stderr,"Invalid line.\n"); exit(-1); +} %% - - -int main (void) +int main (int argc, char **argv) { - YY_BUFFER_STATE state; - int i; - yyin = stdin; yyout = stdout; - - /* Run the tests */ - for (i=0; i < NUM_TESTS; i++){ - printf("Testing: test_scan_string(%s): ", tests[i]); - state = test_scan_string(tests[i]); - testlex(); - yy_delete_buffer(state); - printf("... %s\n", tests_ok[i] ? "OK" : "FAILED"); + while( yylex() ) + { } - - for (i=0; i < NUM_TESTS; i++) - if (!tests_ok[i]) - exit(1); - printf("TEST RETURNING OK.\n"); return 0; } diff --git a/tests/ruleset.am b/tests/ruleset.am index d1daa0d..8afaf28 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -17,6 +17,10 @@ extended_nr_SOURCES = extended_nr.l extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posixlycorrect_nr_SOURCES = posixlycorrect_nr.l +posixlycorrect_nr.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_nr_SOURCES = posix_nr.l posix_nr.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -181,6 +185,10 @@ extended_r_SOURCES = extended_r.l extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posixlycorrect_r_SOURCES = posixlycorrect_r.l +posixlycorrect_r.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_r_SOURCES = posix_r.l posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -345,6 +353,10 @@ extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posixlycorrect_c99_SOURCES = posixlycorrect_c99.l +posixlycorrect_c99.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_c99_SOURCES = posix_c99.l posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -493,7 +505,13 @@ tableopts_ver_c99_Caem_ver_SOURCES = tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +posixlycorrect_nr.c: posixlycorrect_nr.l $(FLEX) + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< +posixlycorrect_r.c: posixlycorrect_r.l $(FLEX) + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< +posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l posix_nr posix_nr.c posix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l posix_r posix_r.c posix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l posix_c99 posix_c99.c posix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr posixlycorrect_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r posixlycorrect_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 posixlycorrect_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables diff --git a/tests/ruleset.sh b/tests/ruleset.sh index c7bcd5b..5c77dfe 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -43,6 +43,15 @@ EOF done done +for backend in $* ; do + case $backend in + nr|r|c99) ext="c" ;; + *) ext=${backend} ;; + esac + printf "posixlycorrect_${backend}.${ext}: posixlycorrect_${backend}.l \$(FLEX)\n" + printf "\t\$(AM_V_LEX)POSIXLY_CORRECT=1 \$(FLEX) \$(TESTOPTS) -o \$@ \$<\n" +done + printf "# End generated test rules\n" echo RULESET_TESTS = "${RULESET_TESTS}" -- cgit v1.2.1 From 91b3016f9dd908db3b6271c73bbd245b7d2b4680 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Oct 2020 07:46:41 -0400 Subject: Add a test for correctness of {n} behavior when posix_compat is off. Also, document what the posix and posixlycorrect rulesets are doing netter. I lost a day because the dependency on setting POSIXLY_CORRECT omn the envoronment was not obvious. --- tests/.gitignore | 13 ++++++++++++- tests/posix.rules | 2 +- tests/posixlycorrect.rules | 8 ++++++-- tests/posixlycorrect_c99.l | 8 ++++++-- tests/posixlycorrect_nr.l | 8 ++++++-- tests/preposix.rules | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/preposix.txt | 1 + tests/ruleset.am | 16 ++++++++++++++-- 8 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 tests/preposix.rules create mode 100644 tests/preposix.txt diff --git a/tests/.gitignore b/tests/.gitignore index e6ae36e..81d24c3 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -8,8 +8,10 @@ alloc_extra_c99 alloc_extra_c99.c array_* !array.rules +!array.txt basic_* !basic.rules +!basic.txt bison_nr bison_nr_scanner.[ch] bison_nr_parser.[ch] @@ -41,6 +43,7 @@ debug_c99 debug_c99.c extended_* !extended.rules +!extended.txt header_nr header_nr_scanner.[ch] header_r @@ -71,22 +74,29 @@ multiple_scanners_r multiple_scanners_r_[12].[ch] posix_* !posix.rules +!posix.txt posixlycorrect_* !posixlycorrect.rules +!posixlycorrect.txt prefix_nr prefix_nr.c prefix_r prefix_r.c prefix_c99 prefix_c99.c +preposix_* +!preposix.rules +!preposix.txt pthread.pthread pthread.c quoteincomment_* -quoteincomment.rules +!quoteincomment.rules +!quoteincomment.txt quotes quotes.c reject* !reject.rules +!reject.txt rescan_nr.direct rescan_nr.direct.c rescan_r.direct @@ -99,6 +109,7 @@ string_c99 string_c99.c tableopts* !tableopts.rules +!tableopts.txt top top.[ch] yyextra_nr diff --git a/tests/posix.rules b/tests/posix.rules index bfcee1c..1ffaca1 100644 --- a/tests/posix.rules +++ b/tests/posix.rules @@ -22,7 +22,7 @@ */ /* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. + * POSIX behavior of the repeat operator `{}' when posix-compat is on. * * ab{3} - In traditional flex, this matches "abbb". * In posix, this matches "ababab". diff --git a/tests/posixlycorrect.rules b/tests/posixlycorrect.rules index 246ab94..52e4a8e 100644 --- a/tests/posixlycorrect.rules +++ b/tests/posixlycorrect.rules @@ -21,8 +21,12 @@ * PURPOSE. */ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator `{}'. +/* + * The goal of this test is to verify that we are getting the + * counter-intuitive POSIX behavior of the repeat operator `{}' when + * posix_compat is off but POSIXLY_CORRECT=1 is set in the + * environment. Note: This depends on the test framework to actually + * set that variable! When it does not, Flex will match abbb * * ab{3} - In traditional flex, this matches "abbb". * In posix, this matches "ababab". diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l index 1538a04..e54f89d 100644 --- a/tests/posixlycorrect_c99.l +++ b/tests/posixlycorrect_c99.l @@ -23,8 +23,12 @@ * PURPOSE. */ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator {}. +/* + * The goal of this test is to verify that we are getting the + * counter-intuitive POSIX behavior of the repeat operator {} when + * posix_compat is off but POSIXLY_CORRECT=1 is set in the + * environment. Note: This depends on the test framework to actually + * set that variable! When it does not, Flex will match abbb * * ab{3} - In traditional flex, this matches "abbb". * In posix, this matches "ababab". diff --git a/tests/posixlycorrect_nr.l b/tests/posixlycorrect_nr.l index 262979a..be0cb93 100644 --- a/tests/posixlycorrect_nr.l +++ b/tests/posixlycorrect_nr.l @@ -22,8 +22,12 @@ * PURPOSE. */ -/* The goal of this test is to verify that we are getting the counter-intuitive - * posix behavior of the repeat operator {}. +/* + * The goal of this test is to verify that we are getting the + * counter-intuitive POSIX behavior of the repeat operator {} when + * posix_compat is off but POSIXLY_CORRECT=1 is set in the + * environment. Note: This depends on the test framework to actually + * set that variable! When it does not, Flex will match abbb * * ab{3} - In traditional flex, this matches "abbb". * In posix, this matches "ababab". diff --git a/tests/preposix.rules b/tests/preposix.rules new file mode 100644 index 0000000..c48a897 --- /dev/null +++ b/tests/preposix.rules @@ -0,0 +1,45 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The goal of this test is to verify that we are getting the traditional + * pre-POSIX behavior of the repeat operator `{}' when posix-compat is not on + * and POSIXLY_CORRECT is not set to 1. + * + * ab{3} - In traditional flex, this matches "abbb". + * In posix, this matches "ababab". + * The input file should contain just the first string. + */ +M4_TEST_PREAMBLE`'dnl + +M4_TEST_OPTIONS`'dnl +%option nounput nomain noyywrap noinput +%option warn + +%% + +ab{3} { } +\n { } +. {M4_TEST_FAILMESSAGE} + +%% +M4_TEST_POSTAMBLE`'dnl diff --git a/tests/preposix.txt b/tests/preposix.txt new file mode 100644 index 0000000..9abab54 --- /dev/null +++ b/tests/preposix.txt @@ -0,0 +1 @@ +abbb diff --git a/tests/ruleset.am b/tests/ruleset.am index 8afaf28..63c8e17 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -25,6 +25,10 @@ posix_nr_SOURCES = posix_nr.l posix_nr.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +preposix_nr_SOURCES = preposix_nr.l +preposix_nr.l: $(srcdir)/preposix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + quoteincomment_nr_SOURCES = quoteincomment_nr.l quoteincomment_nr.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -193,6 +197,10 @@ posix_r_SOURCES = posix_r.l posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +preposix_r_SOURCES = preposix_r.l +preposix_r.l: $(srcdir)/preposix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + quoteincomment_r_SOURCES = quoteincomment_r.l quoteincomment_r.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -361,6 +369,10 @@ posix_c99_SOURCES = posix_c99.l posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +preposix_c99_SOURCES = preposix_c99.l +preposix_c99.l: $(srcdir)/preposix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + quoteincomment_c99_SOURCES = quoteincomment_c99.l quoteincomment_c99.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -512,6 +524,6 @@ posixlycorrect_r.c: posixlycorrect_r.l $(FLEX) posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr posixlycorrect_nr posix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r posixlycorrect_r posix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 posixlycorrect_c99 posix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l preposix_nr preposix_nr.c preposix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l preposix_r preposix_r.c preposix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l preposix_c99 preposix_c99.c preposix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables -- cgit v1.2.1 From 8301e241dcbfe50e1bc987e872c0b5e0ef2cbf18 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Oct 2020 08:08:33 -0400 Subject: Move some boilerplate out of rules files. They are now pure Flex rulesets. --- tests/array.rules | 8 -------- tests/basic.rules | 4 ---- tests/ccl.rules | 4 ---- tests/extended.rules | 4 ---- tests/posix.rules | 4 ---- tests/posixlycorrect.rules | 4 ---- tests/posixlycorrect_c99.l | 11 +++++------ tests/posixlycorrect_nr.l | 9 ++++----- tests/preposix.rules | 4 ---- tests/quoteincomment.rules | 4 ---- tests/reject.rules | 6 +----- tests/tableopts.rules | 7 +------ tests/testmaker.sh | 11 ++++++++--- 13 files changed, 19 insertions(+), 61 deletions(-) diff --git a/tests/array.rules b/tests/array.rules index cd6fe91..157a48a 100644 --- a/tests/array.rules +++ b/tests/array.rules @@ -19,19 +19,11 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ - -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option 8bit %option nounput nomain noyywrap noinput %option warn array - - %% .|\n { } - %% -M4_TEST_POSTAMBLE`'dnl diff --git a/tests/basic.rules b/tests/basic.rules index fcddf82..3b18e8a 100644 --- a/tests/basic.rules +++ b/tests/basic.rules @@ -30,9 +30,6 @@ integer = 43 */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option nounput noyywrap noyylineno warn nodefault noinput IDENT [[:alnum:]_-] @@ -47,4 +44,3 @@ WS [[:blank:]] .|\n {M4_TEST_FAILMESSAGE} %% -M4_TEST_POSTAMBLE diff --git a/tests/ccl.rules b/tests/ccl.rules index ef13a2b..da547d0 100644 --- a/tests/ccl.rules +++ b/tests/ccl.rules @@ -24,9 +24,6 @@ * Test character-class matching */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option 8bit %option nounput nomain noyywrap noinput %option warn @@ -73,4 +70,3 @@ M4_TEST_OPTIONS`'dnl .|\n {M4_TEST_FAILMESSAGE} %% -M4_TEST_POSTAMBLE`'dnl diff --git a/tests/extended.rules b/tests/extended.rules index 0dc601d..0411091 100644 --- a/tests/extended.rules +++ b/tests/extended.rules @@ -23,9 +23,6 @@ /* Output should match the input. */ /* FIXME: Assumes ";" is a legal statememt terminator */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option 8bit nounput nomain noyywrap noinput warn %% @@ -49,4 +46,3 @@ A(?x: B \n yyecho(); %% -M4_TEST_POSTAMBLE diff --git a/tests/posix.rules b/tests/posix.rules index 1ffaca1..7989a9b 100644 --- a/tests/posix.rules +++ b/tests/posix.rules @@ -28,9 +28,6 @@ * In posix, this matches "ababab". * The input file should contain just the second string. */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option nounput nomain noyywrap noinput %option warn posix-compat @@ -41,4 +38,3 @@ ab{3} { } . {M4_TEST_FAILMESSAGE} %% -M4_TEST_POSTAMBLE`'dnl diff --git a/tests/posixlycorrect.rules b/tests/posixlycorrect.rules index 52e4a8e..3940fd0 100644 --- a/tests/posixlycorrect.rules +++ b/tests/posixlycorrect.rules @@ -32,9 +32,6 @@ * In posix, this matches "ababab". * The input file should contain just the second string. */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option nounput nomain noyywrap noinput %option warn @@ -45,4 +42,3 @@ ab{3} { } . {M4_TEST_FAILMESSAGE} %% -M4_TEST_POSTAMBLE`'dnl diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l index e54f89d..d073c06 100644 --- a/tests/posixlycorrect_c99.l +++ b/tests/posixlycorrect_c99.l @@ -1,5 +1,10 @@ +%{ +#include "config.h" +#include +%} +%option emit="c99" /* * This file is part of flex. * @@ -34,12 +39,6 @@ * In posix, this matches "ababab". * The input file should contain just the second string. */ -%{ -#include "config.h" -#include -%} - -%option emit="c99" %option nounput nomain noyywrap noinput %option warn diff --git a/tests/posixlycorrect_nr.l b/tests/posixlycorrect_nr.l index be0cb93..86cd1a1 100644 --- a/tests/posixlycorrect_nr.l +++ b/tests/posixlycorrect_nr.l @@ -1,4 +1,8 @@ +%{ +#include "config.h" +#include +%} /* * This file is part of flex. * @@ -33,11 +37,6 @@ * In posix, this matches "ababab". * The input file should contain just the second string. */ -%{ -#include "config.h" -#include -%} - %option nounput nomain noyywrap noinput %option warn diff --git a/tests/preposix.rules b/tests/preposix.rules index c48a897..ecabffe 100644 --- a/tests/preposix.rules +++ b/tests/preposix.rules @@ -29,9 +29,6 @@ * In posix, this matches "ababab". * The input file should contain just the first string. */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option nounput nomain noyywrap noinput %option warn @@ -42,4 +39,3 @@ ab{3} { } . {M4_TEST_FAILMESSAGE} %% -M4_TEST_POSTAMBLE`'dnl diff --git a/tests/quoteincomment.rules b/tests/quoteincomment.rules index e28ee34..342eb7a 100644 --- a/tests/quoteincomment.rules +++ b/tests/quoteincomment.rules @@ -20,13 +20,9 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option 8bit noyywrap %% .|\n { yyecho(); //' " } %% -M4_TEST_POSTAMBLE diff --git a/tests/reject.rules b/tests/reject.rules index f5f71a7..4539371 100644 --- a/tests/reject.rules +++ b/tests/reject.rules @@ -21,16 +21,12 @@ * PURPOSE. */ -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option 8bit %option nounput nomain noyywrap noinput %option warn reject %% -. { ECHO; } +. {M4_TEST_ECHO} .|\n ; %% -M4_TEST_POSTAMBLE diff --git a/tests/tableopts.rules b/tests/tableopts.rules index 65c5b7e..e4980d2 100644 --- a/tests/tableopts.rules +++ b/tests/tableopts.rules @@ -20,12 +20,8 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ -The simple grammar used as a test ofb table-compression options + /* The simple grammar used as a test of table-compression options */ - -M4_TEST_PREAMBLE`'dnl - -M4_TEST_OPTIONS`'dnl %option 8bit %option nounput nomain noyywrap noinput %option warn yylineno @@ -36,4 +32,3 @@ foo|bar ; [[:blank:]]+ ; .|\n ; %% -M4_TEST_POSTAMBLE diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 2b0bbf3..fc3dba4 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -41,7 +41,7 @@ for part in "$@"; do case ${part} in nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; - ${backends}) backend=r; options="${options} emit=\"${part}\"" ;; + ${backends}) backend=${part}; options="${options} emit=\"${part}\"" ;; ser) serialization=yes ;; ver) serialization=yes; options="${options} tables-verify" ;; Ca) options="${options} align" ;; @@ -57,7 +57,8 @@ for part in "$@"; do Caem) options="${options} align ecs meta-ecs" ;; esac done -verification= +# Special case: C99 back end uses same boilerplate as reentrant C. +case ${backend} in c99) backend=r ;; esac m4def() { define="${1}" @@ -80,7 +81,11 @@ m4def() { else m4def M4_TEST_OPTIONS "%%option${options}\n" fi - cat testmaker.m4 "${stem}.rules" + cat testmaker.m4 + echo "M4_TEST_PREAMBLE\`'dnl" + echo "M4_TEST_OPTIONS\`'dnl" + cat "${stem}.rules" + echo "M4_TEST_POSTAMBLE\`'dnl" ) | m4 >"${outdev}" # end -- cgit v1.2.1 From eaf84e669dab968dd9ea0e4b5461e13486cd2d97 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Oct 2020 12:28:19 -0400 Subject: Add tests for both senses of the Lex compatibility option... ...fulfilling a promise made in " Fix buggy handling of lex compatibility..." --- tests/.gitignore | 9 ++++++++- tests/flexname.rules | 37 +++++++++++++++++++++++++++++++++++++ tests/flexname.txt | 1 + tests/lexcompat.rules | 37 +++++++++++++++++++++++++++++++++++++ tests/lexcompat.txt | 1 + tests/ruleset.am | 20 ++++++++++++++++++-- tests/ruleset.sh | 24 ++++++++++++++++-------- 7 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 tests/flexname.rules create mode 100644 tests/flexname.txt create mode 100644 tests/lexcompat.rules create mode 100644 tests/lexcompat.txt diff --git a/tests/.gitignore b/tests/.gitignore index 81d24c3..adba2cd 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -26,7 +26,8 @@ c_cxx_nr.cc c_cxx_r c_cxx_r.cc ccl_* -ccl.rules +!ccl.rules +!ccl.txt cxx_basic cxx_basic.cc cxx_multiple_scanners @@ -44,6 +45,9 @@ debug_c99.c extended_* !extended.rules !extended.txt +flexname_* +!flexname.rules +!flexname.txt header_nr header_nr_scanner.[ch] header_r @@ -54,6 +58,9 @@ include_by_push.direct include_by_push.direct.c include_by_reentrant.direct include_by_reentrant.direct.c +lexcompat_* +!lexcompat.rules +!lexcompat.txt lineno_nr.one lineno_nr.c lineno_r.one diff --git a/tests/flexname.rules b/tests/flexname.rules new file mode 100644 index 0000000..1c5e41f --- /dev/null +++ b/tests/flexname.rules @@ -0,0 +1,37 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* + * Test Lex incompatibility. This is the compatibility exanmple from + * the documentation; with !lex-compat it *should* match the string "foo". + * For the complementery test, see lexcompat.rules. + */ +%option nounput nomain noyywrap noinput +%option warn nolex-compat + +NAME [A-Z][A-Z0-9]* +%% +foo{NAME}? {M4_TEST_ECHO} +\n {M4_TEST_ECHO} +. {M4_TEST_FAILMESSAGE} +%% diff --git a/tests/flexname.txt b/tests/flexname.txt new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/tests/flexname.txt @@ -0,0 +1 @@ +foo diff --git a/tests/lexcompat.rules b/tests/lexcompat.rules new file mode 100644 index 0000000..392c31f --- /dev/null +++ b/tests/lexcompat.rules @@ -0,0 +1,37 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* + * Test Lex compatibility. This is the compatibility example from + * the documentation; with lex-compat it should *not* match the string + * "foo". For the complementary test, see flexname.rules. + */ +%option nounput nomain noyywrap noinput +%option warn lex-compat + +NAME [A-Z][A-Z0-9]* +%% +foo{NAME}? {M4_TEST_FAILMESSAGE} +\n {M4_TEST_ECHO} +. {M4_TEST_ECHO} +%% diff --git a/tests/lexcompat.txt b/tests/lexcompat.txt new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/tests/lexcompat.txt @@ -0,0 +1 @@ +foo diff --git a/tests/ruleset.am b/tests/ruleset.am index 63c8e17..a0906f6 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -17,6 +17,14 @@ extended_nr_SOURCES = extended_nr.l extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +flexname_nr_SOURCES = flexname_nr.l +flexname_nr.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +lexcompat_nr_SOURCES = lexcompat_nr.l +lexcompat_nr.l: $(srcdir)/lexcompat.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posixlycorrect_nr_SOURCES = posixlycorrect_nr.l posixlycorrect_nr.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -189,6 +197,10 @@ extended_r_SOURCES = extended_r.l extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +flexname_r_SOURCES = flexname_r.l +flexname_r.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posixlycorrect_r_SOURCES = posixlycorrect_r.l posixlycorrect_r.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -361,6 +373,10 @@ extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +flexname_c99_SOURCES = flexname_c99.l +flexname_c99.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posixlycorrect_c99_SOURCES = posixlycorrect_c99.l posixlycorrect_c99.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -524,6 +540,6 @@ posixlycorrect_r.c: posixlycorrect_r.l $(FLEX) posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l preposix_nr preposix_nr.c preposix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l preposix_r preposix_r.c preposix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l preposix_c99 preposix_c99.c preposix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l flexname_nr flexname_nr.c flexname_nr.l lexcompat_nr lexcompat_nr.c lexcompat_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l preposix_nr preposix_nr.c preposix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l flexname_r flexname_r.c flexname_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l preposix_r preposix_r.c preposix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l flexname_c99 flexname_c99.c flexname_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l preposix_c99 preposix_c99.c preposix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 5c77dfe..16a7428 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -14,16 +14,24 @@ RULESET_REMOVABLES="" printf "\n# Begin generated test rules\n\n" +compatible() { + mybackend=$1 + myruleset=$2 + [ ${mybackend} = "nr" ] || [ ${myruleset} != "lexcompat.rules" ] +} + for backend in $* ; do for ruleset in *.rules; do - testname=${ruleset%.*}_${backend} - echo "${testname}_SOURCES = ${testname}.l" - echo "${testname}.l: \$(srcdir)/${ruleset} \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" - # we're deliberately single-quoting this because we _don't_ want those variables to be expanded yet - # shellcheck disable=2016 - printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' - RULESET_TESTS="${RULESET_TESTS} ${testname}" - RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l" + if compatible ${backend} ${ruleset} ; then + testname=${ruleset%.*}_${backend} + echo "${testname}_SOURCES = ${testname}.l" + echo "${testname}.l: \$(srcdir)/${ruleset} \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" + # we're deliberately single-quoting this because we _don't_ want those variables to be expanded yet + # shellcheck disable=2016 + printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' + RULESET_TESTS="${RULESET_TESTS} ${testname}" + RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l" + fi done for kind in opt ser ver ; do for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do -- cgit v1.2.1 From 7ec30d9fee286c619fbee457680821a43a0b610b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Oct 2020 13:37:47 -0400 Subject: Strip legacy support from the c99 back end. Gone: C++ support, M4_YY_IN_HEADER. M4_YY_REENTRANT, and their negation symbols. The strange macrology requitred to makecunction signatures conditionally compile for npn-rentrant or reentrant is gone. The default C back end is not touched by these changes. --- src/c99-flex.skl | 2492 ++++++++++++------------------------------------------ 1 file changed, 532 insertions(+), 1960 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index fe49998..916b71e 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -2,8 +2,6 @@ %# %# All generated macros for the m4 stage contain the text "m4" or "M4" %# in them. This is to distinguish them from CPP macros. -%# The exception to this rule is YY_G, which is an m4 macro, -%# but it needs to be remain short because it is used everywhere. %# %# The m4 macros complicate reading this code enough that being %# prescriptive about whitespace and braces is more than usually @@ -23,7 +21,6 @@ m4_changequote([[, ]]) %# Properties not used in the skeleton - meant to be read by the Flex code m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C99]]) m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]]) -m4_define([[M4_MODE_C_ONLY]], [[]]) m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) @@ -60,50 +57,6 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 %% [0.0] Make hook macros available to Flex -/* Temporary until the non-reentrant code is stripped out */ -m4_define([[M4_YY_REENTRANT]], [[]]) -m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[m4_define([[M4_MODE_REENTRANT_TEXT_IS_ARRAY]])]]) -m4_undefine([[M4_YY_NOT_REENTRANT]]) - -m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl -#ifndef M4_MODE_PREFIX[[HEADER_H]] -#define M4_MODE_PREFIX[[HEADER_H]] -#define M4_MODE_PREFIX[[IN_HEADER]] 1 - -]]) -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -m4_ifelse(M4_MODE_PREFIX,yy,, -#define yy_create_buffer M4_MODE_PREFIX[[_create_buffer]] -#define yy_delete_buffer M4_MODE_PREFIX[[_delete_buffer]] -#define yy_scan_buffer M4_MODE_PREFIX[[_scan_buffer]] -#define yy_scan_string M4_MODE_PREFIX[[_scan_string]] -#define yy_scan_bytes M4_MODE_PREFIX[[_scan_bytes]] -#define yy_init_buffer M4_MODE_PREFIX[[_init_buffer]] -#define yy_flush_buffer M4_MODE_PREFIX[[_flush_buffer]] -#define yy_load_buffer_state M4_MODE_PREFIX[[_load_buffer_state]] -#define yy_switch_to_buffer M4_MODE_PREFIX[[_switch_to_buffer]] -#define yypush_buffer_state M4_MODE_PREFIX[[push_buffer_state]] -#define yypop_buffer_state M4_MODE_PREFIX[[pop_buffer_state]] -#define yyensure_buffer_stack M4_MODE_PREFIX[[ensure_buffer_stack]] -#define yy_flex_debug M4_MODE_PREFIX[[_flex_debug]] -#define yyin M4_MODE_PREFIX[[in]] -#define yyleng M4_MODE_PREFIX[[leng]] -#define yylex M4_MODE_PREFIX[[lex]] -#define yylineno M4_MODE_PREFIX[[lineno]] -#define yyout M4_MODE_PREFIX[[out]] -#define yyrestart M4_MODE_PREFIX[[restart]] -#define yytext M4_MODE_PREFIX[[text]] -#define yywrap M4_MODE_PREFIX[[wrap]] -#define yyalloc M4_MODE_PREFIX[[alloc]] -#define yyrealloc M4_MODE_PREFIX[[realloc]] -#define yyfree M4_MODE_PREFIX[[free]] -#define yyread M4_MODE_PREFIX[[read]] -) -]]) -]]) -]]) #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION #define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION @@ -112,19 +65,10 @@ m4_ifelse(M4_MODE_PREFIX,yy,, #define FLEX_BETA #endif -%# Some negated symbols -m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) -m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) - -%# This is the m4 way to say "(stack_used || is_reentrant)" -m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) -m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) - %# Prefixes. %# The complexity here is necessary so that m4 preserves %# the argument lists to each C function. - - + m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) m4preproc_define(`M4_GEN_PREFIX',`` @@ -133,22 +77,8 @@ m4preproc_define(`M4_GEN_PREFIX',`` #else #define yy$1 ]]M4_MODE_PREFIX[[$1 #endif]] -'m4preproc_divert(1)` -[[#ifndef ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED -#undef yy$1 -#endif]]'m4preproc_divert(0)') - -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - /* The c++ scanner is a mess. The FlexLexer.h header file relies on the - * following macro. This is required in order to pass the c++-multiple-scanners - * test in the regression suite. We get reports that it breaks inheritance. - * We will address this in a future release of flex, or omit the C++ scanner - * altogether. - */ - #define yyFlexLexer M4_MODE_PREFIX[[FlexLexer]] -]]) +'') -m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`_create_buffer') M4_GEN_PREFIX(`_delete_buffer') @@ -179,14 +109,10 @@ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`get_text') M4_GEN_PREFIX(`get_lineno') M4_GEN_PREFIX(`set_lineno') - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - M4_GEN_PREFIX(`get_column') - M4_GEN_PREFIX(`set_column') - ]]) + M4_GEN_PREFIX(`get_column') + M4_GEN_PREFIX(`set_column') M4_GEN_PREFIX(`wrap') ) -]]) m4_ifdef( [[M4_YY_BISON_LVAL]], [[ @@ -207,32 +133,8 @@ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`free') ) -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifelse(M4_MODE_PREFIX,yy,, -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - M4_GEN_PREFIX(`text') - M4_GEN_PREFIX(`leng') - M4_GEN_PREFIX(`in') - M4_GEN_PREFIX(`out') - M4_GEN_PREFIX(`_flex_debug') - M4_GEN_PREFIX(`lineno') -]]) -) -]]) - - -m4_ifdef( [[M4_MODE_TABLESEXT]], -[[ - M4_GEN_PREFIX(`tables_fload') - M4_GEN_PREFIX(`tables_destroy') - M4_GEN_PREFIX(`TABLES_NAME') -]]) - /* First, we deal with platform-specific or compiler-specific issues. */ -/* begin standard C headers. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , [[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , [[/* Feature test macros. Flex uses functions that require a minimum set of @@ -255,23 +157,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #include #include #include -]]) - -m4_ifdef([[M4_MODE_TABLESEXT]], [[ -#include -#include -]]) -/* end standard C headers. */ - -/* begin standard C++ headers. */ -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -#include -#include -#include -#include -#include -/* end standard C++ headers. */ -]]) m4preproc_include(`flexint_shared.h') @@ -284,21 +169,13 @@ m4preproc_include(`flexint_shared.h') #define yynoreturn #endif -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /* Returned upon end-of-file. */ #define YY_NULL 0 -]]) -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /* Promotes a possibly negative, possibly signed char to an * integer in range [0..255] for use as an array index. */ #define YY_SC_TO_UI(c) ((YY_CHAR) (c)) -]]) - - - -m4_ifdef([[M4_YY_REENTRANT]], [[ /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -306,38 +183,16 @@ m4_ifdef([[M4_YY_REENTRANT]], [[ typedef void* yyscan_t; #endif -%# Declare yyguts variable -m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]]) -%# Perform a noop access on yyguts to prevent unused variable complains -m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[(void)yyg]]) -%# For use wherever a Global is accessed or assigned. -m4_define( [[YY_G]], [[yyg->$1]]) - -%# For use in function prototypes to append the additional argument. -m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]]) -m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]]) - -m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]]) -m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]]) -m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]]) - -%# For use in function calls to pass the additional argument. -m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]]) -m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]]) - -%# For use in function documentation to adjust for additional argument. -m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) - /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ -#define yyin YY_G(yyin_r) -#define yyout YY_G(yyout_r) -#define yyextra YY_G(yyextra_r) -#define yyleng YY_G(yyleng_r) -#define yytext YY_G(yytext_r) -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug YY_G(yy_flex_debug_r) +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_lineno) +#define yycolumn (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r m4_define( [[M4_YY_INCR_LINENO]], [[ @@ -346,62 +201,26 @@ m4_define( [[M4_YY_INCR_LINENO]], }while(0) ]]) -]]) - - - -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ - -m4_define( [[M4_YY_INCR_LINENO]], -[[ - yylineno++; -]]) - -%# Define these macros to be no-ops. -m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]]) -m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[m4_dnl]]) -m4_define( [[YY_G]], [[($1)]]) -m4_define( [[M4_YY_PROTO_LAST_ARG]]) -m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]]) -m4_define( [[M4_YY_DEF_LAST_ARG]]) - -m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]]) -m4_define([[M4_YY_DECL_LAST_ARG]]) -m4_define([[M4_YY_CALL_LAST_ARG]]) -m4_define([[M4_YY_CALL_ONLY_ARG]]) -m4_define( [[M4_YY_DOC_PARAM]], ) - -]]) - - -%# Generate C99 function defs. -m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]]) -m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]]) -m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ -#define yybegin(s) YY_G(yy_start) = 1 + 2 * (s) +#define yybegin(s) yyg->yy_start = 1 + 2 * (s) /* Legacy interface */ -#define BEGIN YY_G(yy_start) = 1 + 2 * +#define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define yystart() ((YY_G(yy_start) - 1) / 2) +#define yystart() ((yyg->yy_start - 1) / 2) /* Legacy interfaces */ -#define YY_START ((YY_G(yy_start) - 1) / 2) +#define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG ) +#define YY_NEW_FILE yyrestart( yyin, yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 -]]) /* Size of default input buffer. */ #ifndef YY_BUF_SIZE @@ -416,13 +235,9 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #endif /* __ia64__ */ #endif -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) -]]) - #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE @@ -436,18 +251,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -extern int yyleng; -]]) - -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -extern FILE *yyin, *yyout; -]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -490,27 +293,21 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = YY_G(yy_hold_char); \ + *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ - YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define yyunput(c) yyunput_r( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) +#define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) /* Legacy interface */ -#define unput(c) yyunput_r( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) -]]) +#define unput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { -m4_ifdef([[M4_MODE_C_ONLY]], [[ FILE *yy_input_file; -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::streambuf* yy_input_file; -]]) char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -552,8 +349,6 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ int yy_fill_buffer; int yy_buffer_status; -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process @@ -567,149 +362,83 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 -]]) }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# Standard (non-C++) definition -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static yybuffer * yy_buffer_stack = NULL; /**< Stack as an array. */ -]]) -]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ -#define yy_current_buffer() ( YY_G(yy_buffer_stack) \ - ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ +#define yy_current_buffer() ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) -/* Legacy interface */ #define YY_CURRENT_BUFFER yy_current_buffer() /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ -#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] -]]) - -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# Standard (non-C++) definition - -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; -]]) -]]) - -void yyrestart ( FILE *input_file M4_YY_PROTO_LAST_ARG ); -void yy_switch_to_buffer ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); -yybuffer yy_create_buffer ( FILE *file, int size M4_YY_PROTO_LAST_ARG ); -void yy_delete_buffer ( yybuffer b M4_YY_PROTO_LAST_ARG ); -void yy_flush_buffer ( yybuffer b M4_YY_PROTO_LAST_ARG ); -void yypush_buffer_state ( yybuffer new_buffer M4_YY_PROTO_LAST_ARG ); -void yypop_buffer_state ( M4_YY_PROTO_ONLY_ARG ); - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static void yyensure_buffer_stack ( M4_YY_PROTO_ONLY_ARG ); -static void yy_load_buffer_state ( M4_YY_PROTO_ONLY_ARG ); -static void yy_init_buffer ( yybuffer b, FILE *file M4_YY_PROTO_LAST_ARG ); -#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG) +/* Legacy interface */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file, yyscan_t yyscanner ); +void yy_switch_to_buffer ( yybuffer new_buffer, yyscan_t yyscanner ); +yybuffer yy_create_buffer ( FILE *file, int size, yyscan_t yyscanner ); +void yy_delete_buffer ( yybuffer b, yyscan_t yyscanner ); +void yy_flush_buffer ( yybuffer b, yyscan_t yyscanner ); +void yypush_buffer_state ( yybuffer new_buffer, yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( yybuffer b, FILE *file, yyscan_t yyscanner ); +#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) +/* Legacy interface */ #define YY_FLUSH_BUFFER yy_flush_current_buffer() -]]) -yybuffer yy_scan_buffer ( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); -yybuffer yy_scan_string ( const char *yy_str M4_YY_PROTO_LAST_ARG ); -yybuffer yy_scan_bytes ( const char *bytes, int len M4_YY_PROTO_LAST_ARG ); - -]]) +yybuffer yy_scan_buffer ( char *base, yy_size_t size, yyscan_t yyscanner ); +yybuffer yy_scan_string ( const char *yy_str, yyscan_t yyscanner ); +yybuffer yy_scan_bytes ( const char *bytes, int len, yyscan_t yyscanner ); -void *yyalloc ( yy_size_t M4_YY_PROTO_LAST_ARG ); -void *yyrealloc ( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); -void yyfree ( void * M4_YY_PROTO_LAST_ARG ); +void *yyalloc ( yy_size_t, yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); +void yyfree ( void *, yyscan_t yyscanner ); -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) { \ if ( yy_current_buffer() == NULL ) { \ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + yyensure_buffer_stack (yyscanner); \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ + yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); \ } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( yy_current_buffer() == NULL ) { \ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + yyensure_buffer_stack (yyscanner); \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ + yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); \ } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = at_bol; \ } -#define yy_at_bol() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +#define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) /* Legacy interface */ -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -]]) +#define YY_AT_BOL() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) /* Begin user sect3 */ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef([[M4_YY_REENTRANT]], [[ #define M4_MODE_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) -]]) -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -#define M4_MODE_PREFIX[[wrap]]() (/*CONSTCOND*/1) -]])m4_dnl -]]) #define YY_SKIP_YYWRAP ]]) m4_ifdef( [[M4_MODE_DEBUG]], [[ #define FLEX_DEBUG ]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl typedef flex_uint8_t YY_CHAR; -]])m4_dnl -m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_define([[M4_TMP_STDINIT]], [[FILE *yyin = stdin, *yyout = stdout;]]) m4_define([[M4_TMP_NO_STDINIT]], [[FILE *yyin = NULL, *yyout = NULL;]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ m4_ifdef( [[M4_MODE_DO_STDINIT]], [[m4_dnl -m4_ifdef([[M4_YY_REENTRANT]], [[ -#ifdef VMS -#ifdef __VMS_POSIX -#define YY_STDINIT -#endif -#else -#define YY_STDINIT -#endif -]]) #ifdef VMS"); #ifndef __VMS_POSIX M4_TMP_NO_STDINIT @@ -720,93 +449,30 @@ M4_TMP_STDINIT M4_TMP_STDINIT #endif ]]) -m4_ifdef( [[M4_MODE_NO_DO_STDINIT]], [[ -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -M4_TMP_NO_STDINIT -]]) -]]) -]]) m4_undefine([[M4_TMP_STDINIT]]) m4_undefine([[M4_TMP_NO_STDINIT]]) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -#define yytext_ptr yytext -m4_ifdef( [[M4_MODE_INTERACTIVE]], [[#define YY_INTERACTIVE]]) -]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[m4_dnl m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl typedef const struct yy_trans_info *yy_state_type; ]], [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ typedef int yy_state_type; ]]) -]]) -]]) m4_ifdef([[M4_MODE_LEX_COMPAT]], [[#define YY_FLEX_LEX_COMPAT]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -extern int yylineno; -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -int yylineno = 1; -]]) -]]) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - -#include -m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ -int yyFlexLexer::yywrap() { return 1;} -]]) -m4_ifdef([[M4_MODE_YYCLASS]], [[ -int yyFlexLexer::yylex() - { - LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); - return 0; - } -#define YY_DECL int M4_YY_CLASS_NAME::yylex() -]]) -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ /* Watch out: yytext_ptr is a variable when yytext is an array, * but it's a macro when yytext is a pointer. */ -m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[extern char yytext[];]]) -]]) m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -m4_ifdef([[M4_YY_REENTRANT]], [[#define yytext_ptr yytext_r]],[[ -extern char *yytext; - -#ifdef yytext_ptr -#undef yytext_ptr -#endif -#define yytext_ptr yytext -]]) -]]) +#define yytext_ptr yytext_r ]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ %% [1.5] DFA -]]) - -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# Standard (non-C++) definition - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG); -static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); -static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); -]]) -]]) +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg, yyscan_t yyscanner ); -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ -struct yy_trans_info - { +struct yy_trans_info { /* We require that yy_verify and yy_nxt must be of the same size int. */ m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ YY_OFFSET_TYPE yy_verify; @@ -829,42 +495,31 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ flex_int32_t yy_verify; flex_int32_t yy_nxt; ]]) - }; -]]) +}; -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - YY_G(yytext_ptr) = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[YY_G(yytext_ptr) -= YY_G(yy_more_len); - yyleng = (int) (yy_cp - YY_G(yytext_ptr));]])]]) \ + yyg->yytext_ptr = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; + yyleng = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ - YY_G(yy_hold_char) = *yy_cp; \ + yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyleng + yyg->yy_more_offset >= YYLMAX ) \ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyleng >= YYLMAX ) \ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyleng += YY_G(yy_more_offset);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[YY_G(yy_prev_more_offset) = YY_G(yy_more_offset);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[YY_G(yy_more_offset) = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yytext[yyg->yy_more_offset], yyg->yytext_ptr, yyleng + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyleng += yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1, yyscanner);]]) \ ]]) \ - YY_G(yy_c_buf_p) = yy_cp; - -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ -m4_ifdef( [[M4_MODE_C_ONLY]], -[[ -extern int yy_flex_debug; -int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); -]]) -]]) + yyg->yy_c_buf_p = yy_cp; %% [2.0] data tables for the DFA are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl @@ -1029,52 +684,17 @@ static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; ]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -m4_ifdef( [[M4_MODE_C_ONLY]], [[ -m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ -m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -/* Definitions for backing up. We don't need them if yyreject() - * is being used because then we use an alternative backing-up - * technique instead. - */ -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -]]) -]]) -]]) - m4_ifdef( [[M4_MODE_USES_REJECT]],[[ -m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -m4_ifdef( [[M4_MODE_C_ONLY]], [[ -/* Declare state buffer variables. */ -static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; -static char *yy_full_match; -static int yy_lp; -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ -static int yy_looking_for_trail_begin = 0; -static int yy_full_lp; -static int *yy_full_state; -%# These must match the values in the file flexdef.h -%# of the flex source code, otherwise havoc will ensue. -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 -]]) -]]) -]]) #define yyreject() \ { \ -*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \ -yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ -YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \ -YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \ -yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \ +yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ +yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ ]]) \ -++YY_G(yy_lp); \ +++yyg->yy_lp; \ goto find_rule; \ } #define REJECT yyreject() @@ -1088,33 +708,19 @@ m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ ]]) m4_ifdef([[M4_MODE_YYMORE_USED]], [[ -m4_ifdef( [[M4_MODE_C_ONLY]], [[ -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -static int yy_more_offset = 0; -static int yy_prev_more_offset = 0; -]]) -]]) -m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -static int yy_more_flag = 0; -static int yy_more_len = 0; -]]) -]]) -]]) m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext M4_YY_CALL_LAST_ARG)) +#define yymore() (yyg->yy_more_offset = yy_flex_strlen( yytext, yyscanner)) #define YY_NEED_STRLEN #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET \ { \ -YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \ -yyleng -= YY_G(yy_more_offset); \ +yyg->yy_more_offset = yyg->yy_prev_more_offset; \ +yyleng -= yyg->yy_more_offset; \ } ]]) m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yymore() (YY_G(yy_more_flag) = 1) -#define YY_MORE_ADJ YY_G(yy_more_len) +#define yymore() (yyg->yy_more_flag = 1) +#define YY_MORE_ADJ yyg->yy_more_len #define YY_RESTORE_YY_MORE_OFFSET ]]) ]]) @@ -1125,30 +731,16 @@ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ #define YY_RESTORE_YY_MORE_OFFSET ]]) -m4_ifdef( [[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #ifndef YYLMAX #define YYLMAX 8192 #endif -m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -char yytext[YYLMAX]; -char *yytext_ptr; -]]) -]]) -m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ -char *yytext; -]]) -]]) ]]) %% [3.0] static declarations conditional on mode switches go here -]]) -m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) M4_YY_SC_DEFS -m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) m4_ifdef( [[M4_YY_NO_UNISTD_H]],, [[ @@ -1157,12 +749,7 @@ m4_ifdef( [[M4_YY_NO_UNISTD_H]],, * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -#include -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #include -]]) #endif ]]) @@ -1177,12 +764,6 @@ m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], ]] ) -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# Reentrant structure and macros (non-C++). -m4_ifdef([[M4_YY_REENTRANT]], [[ - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ @@ -1221,7 +802,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ int yy_full_lp; int *yy_full_state; ]]) -m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ char yytext_r[YYLMAX]; char *yytext_ptr; int yy_more_offset; @@ -1239,143 +820,121 @@ m4_ifdef( [[]], [[ YYLTYPE * yylloc_r; ]]) }; /* end struct yyguts_t */ -]]) +static int yy_init_globals ( yyscan_t yyscanner ); -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +m4_ifdef( [[M4_YY_BISON_LVAL]], [[ -static int yy_init_globals ( M4_YY_PROTO_ONLY_ARG ); -]]) +/* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ +# define yylval yyg->yylval_r ]]) -m4_ifdef([[M4_YY_REENTRANT]], [[ - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], +m4_ifdef( [[]], [[ - m4_ifdef( [[M4_YY_BISON_LVAL]], - [[ - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval YY_G(yylval_r) - ]]) - - m4_ifdef( [[]], - [[ - # define yylloc YY_G(yylloc_r) - ]]) +# define yylloc yyg->yylloc_r ]]) int yylex_init (yyscan_t* scanner); int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); -]]) - -]]) - /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ m4_ifdef( [[M4_YY_NO_DESTROY]],, [[ -int yylex_destroy ( M4_YY_PROTO_ONLY_ARG ); +int yylex_destroy ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ -int yyget_debug ( M4_YY_PROTO_ONLY_ARG ); +int yyget_debug ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ -void yyset_debug ( int debug_flag M4_YY_PROTO_LAST_ARG ); +void yyset_debug ( int debug_flag, yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, [[ -YY_EXTRA_TYPE yyget_extra ( M4_YY_PROTO_ONLY_ARG ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, [[ -void yyset_extra ( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG ); +void yyset_extra ( YY_EXTRA_TYPE user_defined, yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_IN]],, [[ -FILE *yyget_in ( M4_YY_PROTO_ONLY_ARG ); +FILE *yyget_in ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_IN]],, [[ -void yyset_in ( FILE * _in_str M4_YY_PROTO_LAST_ARG ); +void yyset_in ( FILE * _in_str, yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_OUT]],, [[ -FILE *yyget_out ( M4_YY_PROTO_ONLY_ARG ); +FILE *yyget_out ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_OUT]],, [[ -void yyset_out ( FILE * _out_str M4_YY_PROTO_LAST_ARG ); +void yyset_out ( FILE * _out_str, yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_LENG]],, [[ - int yyget_leng ( M4_YY_PROTO_ONLY_ARG ); + int yyget_leng ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_TEXT]],, [[ -char *yyget_text ( M4_YY_PROTO_ONLY_ARG ); +char *yyget_text ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_GET_LINENO]],, [[ -int yyget_lineno ( M4_YY_PROTO_ONLY_ARG ); +int yyget_lineno ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_LINENO]],, [[ -void yyset_lineno ( int _line_number M4_YY_PROTO_LAST_ARG ); +void yyset_lineno ( int _line_number, yyscan_t yyscanner ); ]]) -m4_ifdef( [[M4_YY_REENTRANT]], -[[ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, [[ -int yyget_column ( M4_YY_PROTO_ONLY_ARG ); -]]) +int yyget_column ( yyscan_t yyscanner ); ]]) -m4_ifdef( [[M4_YY_REENTRANT]], -[[ m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, [[ -void yyset_column ( int _column_no M4_YY_PROTO_LAST_ARG ); -]]) +void yyset_column ( int _column_no, yyscan_t yyscanner ); ]]) m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_ifdef( [[M4_YY_NO_GET_LVAL]],, [[ -YYSTYPE * yyget_lval ( M4_YY_PROTO_ONLY_ARG ); +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); ]]) -void yyset_lval ( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG ); +void yyset_lval ( YYSTYPE * yylval_param, yyscan_t yyscanner ); m4_ifdef( [[]], [[ m4_ifdef( [[M4_YY_NO_GET_LLOC]],, [[ - YYLTYPE *yyget_lloc ( M4_YY_PROTO_ONLY_ARG ); + YYLTYPE *yyget_lloc ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_LLOC]],, [[ - void yyset_lloc ( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); + void yyset_lloc ( YYLTYPE * yylloc_param, yyscan_t yyscanner ); ]]) ]]) ]]) @@ -1385,83 +944,50 @@ m4_ifdef( [[]], */ #ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( M4_YY_PROTO_ONLY_ARG ); -#else -extern int yywrap ( M4_YY_PROTO_ONLY_ARG ); -#endif +extern int yywrap ( yyscan_t yyscanner ); #endif -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl #ifndef YY_NO_YYUNPUT - m4_ifdef( [[M4_YY_NO_YYUNPUT]],, - [[ - static void yyunput_r ( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); - ]]) -#endif -]]) +m4_ifdef( [[M4_YY_NO_YYUNPUT]],,[[ +static void yyunput_r ( int c, char *buf_ptr , yyscan_t yyscanner); ]]) +#endif #ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int M4_YY_PROTO_LAST_ARG); +static void yy_flex_strncpy ( char *, const char *, int, yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * M4_YY_PROTO_LAST_ARG); +static int yy_flex_strlen ( const char *, yyscan_t yyscanner); #endif -m4_ifdef([[M4_MODE_NO_YYINPUT]], [[#define YY_NO_YYINPUT 1]]) - #ifndef YY_NO_YYINPUT -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -static int yyinput ( M4_YY_PROTO_ONLY_ARG ); -#ifndef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +// Legacy interface #define input yyinput #endif -]]) -]]) -#endif -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# TODO: This is messy. m4_ifdef( [[M4_YY_STACK_USED]], -[[ - -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - m4_ifdef( [[M4_YY_NOT_IN_HEADER]], - [[ - static int yy_start_stack_ptr = 0; - static int yy_start_stack_depth = 0; - static int *yy_start_stack = NULL; - ]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ - static void yy_push_state ( int _new_state M4_YY_PROTO_LAST_ARG); + static void yy_push_state ( int _new_state, yyscan_t yyscanner); ]]) m4_ifdef( [[M4_YY_NO_POP_STATE]],, [[ - static void yy_pop_state ( M4_YY_PROTO_ONLY_ARG ); + static void yy_pop_state ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_TOP_STATE]],, [[ - static int yy_top_state ( M4_YY_PROTO_ONLY_ARG ); + static int yy_top_state ( yyscan_t yyscanner ); ]]) -]]) - ]], [[ m4_define( [[M4_YY_NO_PUSH_STATE]]) m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -]]) /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE @@ -1473,75 +999,41 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) #endif /* __ia64__ */ #endif -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Copy whatever the last rule matched to the standard output. */ -#ifndef yyecho -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# Standard (non-C++) definition -/* This used to be an fputs(), but since the string might contain NUL's, +/* This used to be an fputs(), but since the string might contain NULs, * we now use fwrite(). */ #define yyecho() do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -%# C++ definition -#define yyecho() LexerOutput( yytext, yyleng ) -]]) -#endif -/* Legacy interface */ -#define ECHO yyecho() -]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); +/* Legacy interface */ +#define ECHO yyecho() + +static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; /* forestall unused-argument warning */ fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::LexerError( const char* msg ) { - M4_YY_DECL_GUTS_VAR(); - std::cerr << msg << std::endl; - exit( YY_EXIT_FAILURE ); -} -]]) /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -m4_ifdef([[M4_MODE_C_ONLY]], [[ -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -#define YY_FATAL_ERROR(msg) LexerError( msg ) -]]) +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg, yyscanner) #endif /* Legacy interface */ #ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size M4_YY_CALL_LAST_ARG);} while (0) +#define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size, yyscanner);} while (0) -m4_ifdef( [[M4_MODE_USER_YYREAD]], , [[ +m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -int yyFlexLexer::yyread(char *buf, size_t max_size) { -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static int yyread(char *buf, size_t max_size M4_YY_PROTO_LAST_ARG) { -]]) +static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { int result; - M4_YY_DECL_GUTS_VAR(); -m4_ifdef([[M4_MODE_C_ONLY]], [[ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) { @@ -1554,7 +1046,7 @@ m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ } ]]) m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) { + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive ) { int c = '*'; int n; for ( n = 0; n < max_size && @@ -1579,23 +1071,12 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ clearerr(yyin); } } -]]) -]]) - -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -%# C++ definition - if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) { - YY_FATAL_ERROR( "input in flex scanner failed" ); - } ]]) return result; } #endif ]]) -]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. @@ -1603,75 +1084,19 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #ifndef yyterminate #define yyterminate() return YY_NULL #endif -]]) /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif -m4_ifdef([[M4_MODE_TABLESEXT]], [[ -%# structures and prototypes -m4preproc_include(`tables_shared.h') - -/* Load the DFA tables from the given stream. */ -int yytables_fload (FILE * fp M4_YY_PROTO_LAST_ARG); - -/* Unload the tables from memory. */ -int yytables_destroy (M4_YY_PROTO_ONLY_ARG); -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl - -/** Describes a mapping from a serialized table id to its deserialized state in - * this scanner. This is the bridge between our "generic" deserialization code - * and the specifics of this scanner. - */ -struct yytbl_dmap { - enum yytbl_id dm_id;/**< table identifier */ - void **dm_arr; /**< address of pointer to store the deserialized table. */ - size_t dm_sz; /**< local sizeof() each element in table. */ -}; - -/** A {0,0,0}-terminated list of structs, forming the map */ -static struct yytbl_dmap yydmap[] = { -m4_ifdef([[M4_HOOK_NXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_NXT_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_YYNXT_TYPE]], [[ {YYTD_ID_NXT, (void**)&yy_nxt, sizeof(M4_HOOK_YYNXT_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_MODE_FULLSPD]], [[ {YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(struct yy_trans_info*)},]],[[m4_dnl]]) -m4_ifdef([[M4_MODE_YYLINENO]], [[ {YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(M4_HOOK_EOLTABLE_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_MODE_USEECS]], [[ {YYTD_ID_EC, (void**)&yy_ec, sizeof(YY_CHAR)},]],[[m4_dnl]]) -m4_ifdef([[M4_MODE_USEMECS]], [[ {YYTD_ID_META, (void**)&yy_meta, sizeof(YY_CHAR)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_ACCLIST_TYPE]], [[ {YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(M4_HOOK_ACCLIST_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_MKCTBL_TYPE]], [[ {YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(M4_HOOK_MKCTBL_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_MKFTBL_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_MKFTBL_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_ACCEPT_TYPE]], [[ {YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(M4_HOOK_ACCEPT_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_BASE_TYPE]], [[ {YYTD_ID_BASE, (void**)&yy_base, sizeof(M4_HOOK_BASE_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_DEF_TYPE]], [[ {YYTD_ID_DEF, (void**)&yy_def, sizeof(M4_HOOK_DEF_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_CHK_TYPE]], [[ {YYTD_ID_CHK, (void**)&yy_chk, sizeof(M4_HOOK_CHK_TYPE)},]],[[m4_dnl]]) -m4_ifdef([[M4_HOOK_NULTRANS_TYPE]], [[ {YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(M4_HOOK_NULTRANS_TYPE)},]],[[m4_dnl]]) - {0,0,0} -}; - -/** A tables-reader object to maintain some state in the read. */ -struct yytbl_reader { - FILE * fp; /**< input stream */ - flex_uint32_t bread; /**< bytes read since beginning of current tableset */ -}; - -]]) -/* end tables serialization structures and prototypes */ - -]]) - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# Standard (non-C++) definition - - -m4_define( [[M4_YY_LEX_PROTO]], [[(M4_YY_PROTO_ONLY_ARG)]]) -m4_define( [[M4_YY_LEX_DECLARATION]], [[(M4_YY_DEF_ONLY_ARG)]]) +m4_define( [[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) +m4_define( [[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) m4_ifdef( [[M4_YY_BISON_LVAL]], [[ @@ -1679,9 +1104,9 @@ m4_ifdef( [[M4_YY_BISON_LVAL]], m4_dnl accept the lval parameter. m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]]) + [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[YYFARGS1(YYSTYPE *,yylval_param)]]) + [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) ]]) m4_ifdef( [[]], @@ -1689,47 +1114,33 @@ m4_ifdef( [[]], m4_dnl Locations are used. yylex should also accept the ylloc parameter. m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]]) + [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param, yyscan_t yyscanner)]]) m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]]) + [[(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)]]) ]]) extern int yylex M4_YY_LEX_PROTO; #define YY_DECL int yylex M4_YY_LEX_DECLARATION -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -%# C++ definition -#define YY_DECL int yyFlexLexer::yylex() -]]) #endif /* !YY_DECL */ -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif -]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK /*LINTED*/break; #endif -]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #define YY_RULE_SETUP \ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) { \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ } \ ]]) YY_USER_ACTION -]]) %# Code snippets used in various cases of code generation in the main scanner. @@ -1743,8 +1154,8 @@ m4_ifdef([[M4_MODE_FULLSPD]], [[ m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ if ( yy_accept[yy_current_state] ) { ]]) - YY_G(yy_last_accepting_state) = yy_current_state; - YY_G(yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } ]]) ]]) @@ -1791,16 +1202,16 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + yy_at_bol()];]]) -m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[YY_G(yy_start)];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[yyg->yy_start + yy_at_bol()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyg->yy_start];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - yy_current_state = YY_G(yy_start); + yy_current_state = yyg->yy_start; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yy_at_bol();]]) /* Set up for storing up states. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - YY_G(yy_state_ptr) = YY_G(yy_state_buf); - *YY_G(yy_state_ptr)++ = yy_current_state; + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; ]]) ]]) ]]) @@ -1821,39 +1232,26 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ } ]]) -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl /** The main scanner function which does all the work. */ YY_DECL { yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; - M4_YY_DECL_GUTS_VAR(); - -m4_ifdef( [[M4_YY_NOT_REENTRANT]], -[[ - m4_ifdef( [[M4_YY_BISON_LVAL]], - [[ - YYSTYPE * yylval; - ]]) - m4_ifdef( [[]], - [[ - YYLTYPE * yylloc; - ]]) -]]) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; m4_ifdef( [[M4_YY_BISON_LVAL]], [[ - yylval = yylval_param; + yylval = yylval_param; ]]) m4_ifdef( [[]], [[ - yylloc = yylloc_param; + yylloc = yylloc_param; ]]) - if ( !YY_G(yy_init) ) { - YY_G(yy_init) = 1; + if ( !yyg->yy_init ) { + yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; @@ -1862,40 +1260,30 @@ m4_ifdef( [[]], m4_ifdef( [[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! YY_G(yy_state_buf) ) { - YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); + if ( ! yyg->yy_state_buf ) { + yyg->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } - if ( ! YY_G(yy_state_buf) ) { + if ( ! yyg->yy_state_buf ) { YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); } ]]) - if ( ! YY_G(yy_start) ) { - YY_G(yy_start) = 1; /* first start state */ + if ( ! yyg->yy_start ) { + yyg->yy_start = 1; /* first start state */ } if ( ! yyin ) { -m4_ifdef([[M4_MODE_C_ONLY]], [[ yyin = stdin; -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - yyin.rdbuf(std::cin.rdbuf()); -]]) } if ( ! yyout ) { -m4_ifdef([[M4_MODE_C_ONLY]], [[ yyout = stdout; -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - yyout.rdbuf(std::cout.rdbuf()); -]]) } if ( yy_current_buffer() == NULL ) { - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + yyensure_buffer_stack (yyscanner); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = + yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); } - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + yy_load_buffer_state( yyscanner ); } /* open scope of user declarationns */ @@ -1905,17 +1293,17 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ while ( /*CONSTCOND*/1 ) { /* loops until end-of-file is reached */ m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ - YY_G(yy_more_len) = 0; - if ( YY_G(yy_more_flag) ) { - YY_G(yy_more_len) = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); - YY_G(yy_more_flag) = 0; + yyg->yy_more_len = 0; + if ( yyg->yy_more_flag ) { + yyg->yy_more_len = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + yyg->yy_more_flag = 0; } ]]) ]]) - yy_cp = YY_G(yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; /* Support of yytext. */ - *yy_cp = YY_G(yy_hold_char); + *yy_cp = yyg->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. @@ -1949,7 +1337,7 @@ m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ do { M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyg->yy_state_ptr++ = yy_current_state;]]) ++yy_cp; } @@ -1961,8 +1349,8 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure out * the match. */ - yy_cp = YY_G(yy_last_accepting_cpos); - yy_current_state = YY_G(yy_last_accepting_state); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; ]]) ]]) ]]) @@ -1972,44 +1360,44 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ - yy_current_state = *--YY_G(yy_state_ptr); - YY_G(yy_lp) = yy_accept[yy_current_state]; + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) for ( ; ; ) { /* loop until we find out what rule we matched */ - if (YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1]) { - yy_act = yy_acclist[YY_G(yy_lp)]; + if (yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1]) { + yy_act = yy_acclist[yyg->yy_lp]; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || YY_G(yy_looking_for_trail_begin)) { - if (yy_act == YY_G(yy_looking_for_trail_begin)) { - YY_G(yy_looking_for_trail_begin) = 0; + if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || yyg->yy_looking_for_trail_begin) { + if (yy_act == yyg->yy_looking_for_trail_begin) { + yyg->yy_looking_for_trail_begin = 0; yy_act &= ~YY_TRAILING_HEAD_MASK; break; } } else if (( yy_act & YY_TRAILING_MASK) != 0) { - YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; - YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; + yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; + yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; m4_ifdef([[M4_MODE_REAL_REJECT]], [[ /* Remember matched text in case we back up * due to REJECT. */ - YY_G(yy_full_match) = yy_cp; - YY_G(yy_full_state) = YY_G(yy_state_ptr); - YY_G(yy_full_lp) = YY_G(yy_lp); + yyg->yy_full_match = yy_cp; + yyg->yy_full_state = yyg->yy_state_ptr; + yyg->yy_full_lp = yyg->yy_lp; ]]) } else { - YY_G(yy_full_match) = yy_cp; - YY_G(yy_full_state) = YY_G(yy_state_ptr); - YY_G(yy_full_lp) = YY_G(yy_lp); + yyg->yy_full_match = yy_cp; + yyg->yy_full_state = yyg->yy_state_ptr; + yyg->yy_full_lp = yyg->yy_lp; break; } - ++YY_G(yy_lp); + ++yyg->yy_lp; goto find_rule; ]]) m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ /* Remember matched text in case we back up due to * trailing context plus REJECT. */ - YY_G(yy_full_match) = yy_cp; + yyg->yy_full_match = yy_cp; break; ]]) } @@ -2020,14 +1408,14 @@ m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ * the beginning, but at the cost of complaints that we're * branching inside a loop. */ - yy_current_state = *--YY_G(yy_state_ptr); - YY_G(yy_lp) = yy_accept[yy_current_state]; + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; } /* close for */ ]]) m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = YY_G(yy_last_accepting_cpos); - yy_current_state = YY_G(yy_last_accepting_state); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } ]]) @@ -2037,7 +1425,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], - [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) + [["yyg->yy_prev_more_offset"]], [["yyg->yy_more_len"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) { @@ -2054,44 +1442,17 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], m4_ifdef([[M4_MODE_DEBUG]], [[ if ( yy_flex_debug ) { if ( yy_act == 0 ) { -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::cerr << "--scanner backing up\n"; -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--scanner backing up\n" ); -]]) } else if ( yy_act < YY_NUM_RULES ) { -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << - "(\"" << yytext << "\")\n"; -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); -]]) } else if ( yy_act == YY_NUM_RULES ) { -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::cerr << "--accepting default rule (\"" << yytext << "\")\n"; -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--accepting default rule (\"%s\")\n", - yytext ); -]]) + yytext ); } else if ( yy_act == YY_NUM_RULES + 1 ) { - -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::cerr << "--(end of buffer or a NUL)\n"; -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--(end of buffer or a NUL)\n" ); -]]) } else { -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::cerr << "--EOF (start condition " << YY_START << ")\n"; -]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); -]]) } } ]]) @@ -2101,15 +1462,15 @@ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = YY_G(yy_hold_char); + *yy_cp = yyg->yy_hold_char; /* Backing-up info for compressed tables is taken \after/ */ /* yy_cp has been incremented for the next state. */ - yy_cp = YY_G(yy_last_accepting_cpos); + yy_cp = yyg->yy_last_accepting_cpos; m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) - yy_current_state = YY_G(yy_last_accepting_state); + yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; ]]) ]]) @@ -2118,13 +1479,13 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = YY_G(yy_hold_char); + *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called @@ -2134,14 +1495,9 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * this is the first action (other than possibly a * back-up) that will match for the new input source. */ - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; -m4_ifdef([[M4_MODE_C_ONLY]], [[ - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); -]]) - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + yyg->yy_n_chars = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file = yyin; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position @@ -2151,12 +1507,12 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ * end-of-buffer state). Contrast this with the test * in input(). */ - if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) { /* This was really a NUL. */ + if ( yyg->yy_c_buf_p <= &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -2167,27 +1523,27 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ * will run more slowly). */ - yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); + yy_next_state = yy_try_NUL_trans( yy_current_state, yyscanner); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++YY_G(yy_c_buf_p); + yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { %# Disguised case statement on table modes - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = YY_G(yy_c_buf_p);]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = yyg->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = yyg->yy_c_buf_p;]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure * out the match. */ - yy_cp = YY_G(yy_last_accepting_cpos); - yy_current_state = YY_G(yy_last_accepting_state); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; ]]) ]]) %# Disguised case statement on table modes ends @@ -2196,17 +1552,17 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ * yy_current_state was set up by * yy_get_previous_state(). */ - yy_cp = YY_G(yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; ]]) ]]) goto yy_find_action; } } else { /* not a NUL */ - switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) { + switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: - YY_G(yy_did_buffer_switch_on_eof) = 0; + yyg->yy_did_buffer_switch_on_eof = 0; - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) { + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up @@ -2216,34 +1572,34 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { + if ( ! yyg->yy_did_buffer_switch_on_eof ) { YY_NEW_FILE; } } break; case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = - YY_G(yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - YY_G(yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; + yyg->yy_c_buf_p = + &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars]; - yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = YY_G(yy_c_buf_p); - yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } /* end EOB inner switch */ } /* end if */ @@ -2255,137 +1611,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } /* end of scanning one token */ } /* end of user's declarations */ } /* end of yylex */ -]]) - -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -/* The contents of this function are C++ specific, so the YY_G macro is not used. - * This constructor simply maintains backward compatibility. - * DEPRECATED - */ -yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): - yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), - yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) -{ - ctor_common(); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): - yyin(arg_yyin.rdbuf()), - yyout(arg_yyout.rdbuf()) -{ - ctor_common(); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::ctor_common() { - yy_c_buf_p = 0; - yy_init = 0; - yy_start = 0; - yy_flex_debug = 0; - yylineno = 1; // this will only get updated if %option yylineno - - yy_did_buffer_switch_on_eof = 0; - - yy_looking_for_trail_begin = 0; - yy_more_flag = 0; - yy_more_len = 0; - yy_more_offset = yy_prev_more_offset = 0; - - yy_start_stack_ptr = yy_start_stack_depth = 0; - yy_start_stack = NULL; - yy_buffer_stack = NULL; - yy_buffer_stack_top = 0; - yy_buffer_stack_max = 0; - - -m4_ifdef( [[M4_MODE_USES_REJECT]], -[[ - yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; -]], -[[ - yy_state_buf = 0; -]]) -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -yyFlexLexer::~yyFlexLexer() { - delete [] yy_state_buf; - yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); - yy_delete_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG); - yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) { - // was if( new_in ) - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); - yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); - - // was if( new_out ) - yyout.rdbuf(new_out.rdbuf()); -} - -/* The contents of this function are C++ specific, so the YY_G macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) -{ - if( ! new_in ) { - new_in = &yyin; - } - - if ( ! new_out ) { - new_out = &yyout; - } - - switch_streams(*new_in, *new_out); -} - -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif -{ - if ( yyin.eof() || yyin.fail() ) { - return 0; - } -#ifdef YY_INTERACTIVE - yyin.get( buf[0] ); - - if ( yyin.eof() ) { - return 0; - } - if ( yyin.bad() ) { - return -1; - } - return 1; - -#else - (void) yyin.read( buf, max_size ); - - if ( yyin.bad() ) { - return -1; - } else { - return yyin.gcount(); - } -#endif -} - -void yyFlexLexer::LexerOutput( const char* buf, int size ) { - (void) yyout.write( buf, size ); -} -]]) -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: @@ -2393,25 +1619,20 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static int yy_get_next_buffer (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -int yyFlexLexer::yy_get_next_buffer() -]]) +static int yy_get_next_buffer (yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = YY_G(yytext_ptr); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf; + char *source = yyg->yytext_ptr; int number_to_move, i; int ret_val; - if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) { + if ( yyg->yy_c_buf_p > &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars + 1] ) { YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); } - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) { + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ @@ -2427,19 +1648,19 @@ int yyFlexLexer::yy_get_next_buffer() /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - 1); + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) { *(dest++) = *(source++); } - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars = 0; } else { int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ m4_ifdef( [[M4_MODE_USES_REJECT]], @@ -2449,10 +1670,10 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], ]], [[ /* just a shorter name for the current buffer */ - yybuffer b = YY_CURRENT_BUFFER_LVALUE; + yybuffer b = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]; int yy_c_buf_p_offset = - (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; @@ -2465,7 +1686,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); + (yy_size_t) (b->yy_buf_size + 2), yyscanner ); } else { /* Can't grow it, we don't own it. */ b->yy_ch_buf = NULL; @@ -2474,9 +1695,9 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); } - YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + num_to_read = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; ]]) } @@ -2485,62 +1706,55 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], num_to_read = YY_READ_BUF_SIZE; } /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - YY_G(yy_n_chars), num_to_read ); + YY_INPUT( (&yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars; } - if ( YY_G(yy_n_chars) == 0 ) { + if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin M4_YY_CALL_LAST_ARG); + yyrestart( yyin, yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else { ret_val = EOB_ACT_CONTINUE_SCAN; } - if ((YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yyg->yy_n_chars + number_to_move) > yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) { + int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( + (void *) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( ! yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf ) { YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); } - YY_G(yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + yyg->yy_n_chars += number_to_move; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + yyg->yytext_ptr = &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[0]; return ret_val; } -]]) /* yy_get_previous_state - get the state just before the EOB char was reached */ -m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static yy_state_type yy_get_previous_state (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -yy_state_type yyFlexLexer::yy_get_previous_state() -]]) +static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { yy_state_type yy_current_state; char *yy_cp; - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; M4_GEN_START_STATE - for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) { + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { /* Generate the code to find the next state. */ m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) @@ -2567,7 +1781,7 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*YY_G(yy_state_ptr)++ = yy_current_state;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyg->yy_state_ptr++ = yy_current_state;]]) } return yy_current_state; @@ -2579,15 +1793,10 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ * synopsis * next_state = yy_try_NUL_trans( current_state ); */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -]]) +static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner) { int yy_is_jam; - M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ /* Generate code for handling NUL's, if needed. */ /* First, deal with backing up and setting up yy_cp if the scanner @@ -2596,7 +1805,7 @@ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) * Only generate a definition for "yy_cp" if we'll generate code * that uses it. Otherwise lint and the like complain. */ - m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = YY_G(yy_c_buf_p);]]) + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyg->yy_c_buf_p;]]) %# Note that this statement block and the following three are %# not executed serially but are an if-then-else cascade @@ -2633,7 +1842,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], [[ * the state stack and yy_c_buf_p get out of sync. */ if ( ! yy_is_jam ) { - *YY_G(yy_state_ptr)++ = yy_current_state; + *yyg->yy_state_ptr++ = yy_current_state; } ]]) ]]) @@ -2651,45 +1860,39 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ } ]]) - M4_YY_NOOP_GUTS_VAR(); + (void)yyg; /* forestall unused-argument warning */ return yy_is_jam ? 0 : yy_current_state; } -m4_ifdef([[M4_MODE_CXX_ONLY]], [[m4_undefine([[M4_YY_NO_YYUNPUT]])]]) -m4_ifdef( [[M4_YY_NO_YYUNPUT]], , [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yyunput_r YYFARGS2( int,c, char *,yy_bp) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yyunput_r( int c, char* yy_bp) -]]) +m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ +static void yyunput_r( int c, char *yy_bp, yyscan_t yyscanner) { char *yy_cp; - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_cp = YY_G(yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; /* undo effects of setting up yytext */ - *yy_cp = YY_G(yy_hold_char); + *yy_cp = yyg->yy_hold_char; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { + if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = YY_G(yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + int number_to_move = yyg->yy_n_chars + 2; + char *dest = &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size + 2]; char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) { + while ( source > yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf ) { *--dest = *--source; } yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - YY_G(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = + yyg->yy_n_chars = (int) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { + if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { YY_FATAL_ERROR( "flex scanner push-back overflow" ); } } @@ -2703,39 +1906,33 @@ m4_ifdef( [[M4_MODE_YYLINENO]], } ]]) - YY_G(yytext_ptr) = yy_bp; - YY_G(yy_hold_char) = *yy_cp; - YY_G(yy_c_buf_p) = yy_cp; + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; } ]]) -m4_ifdef([[M4_MODE_C_ONLY]], [[ -#ifndef YY_NO_YYINPUT -int yyinput (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -int yyFlexLexer::yyinput() -]]) +int yyinput (yyscan_t yyscanner) { int c; - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); + *yyg->yy_c_buf_p = yyg->yy_hold_char; - if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) { + if ( yyg->yy_c_buf_p < &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ - *YY_G(yy_c_buf_p) = '\0'; + *yyg->yy_c_buf_p = '\0'; } else { /* need more input */ - int offset = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)); - ++YY_G(yy_c_buf_p); + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + ++yyg->yy_c_buf_p; - switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) { + switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a @@ -2748,34 +1945,34 @@ int yyFlexLexer::yyinput() */ /* Reset buffer status. */ - yyrestart( yyin M4_YY_CALL_LAST_ARG); + yyrestart( yyin, yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: - if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) { + if ( yywrap( yyscanner ) ) { return 0; } - if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { + if ( ! yyg->yy_did_buffer_switch_on_eof ) { YY_NEW_FILE; } - return yyinput(M4_YY_CALL_ONLY_ARG); + return yyinput(yyscanner); case EOB_ACT_CONTINUE_SCAN: - YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } - c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ - *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ - YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) { + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol ) { M4_YY_INCR_LINENO(); } ]]) @@ -2790,126 +1987,83 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ return c; } -m4_ifdef([[M4_MODE_C_ONLY]], [[ -#endif /* ifndef YY_NO_YYINPUT */ -]]) /** Immediately switch to a different input stream. * @param input_file A readable stream. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -void yyrestart YYFARGS1( FILE *,input_file) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yyrestart( std::istream& input_file ) -]]) +void yyrestart(FILE * input_file, yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( yy_current_buffer() == NULL ) { - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); + yyensure_buffer_stack (yyscanner); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = + yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); } - yy_init_buffer( yy_current_buffer(), input_file M4_YY_CALL_LAST_ARG); - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); -} - -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -/** Delegate to the new version that takes an istream reference. - * @param input_file A readable stream. - * M4_YY_DOC_PARAM - * @note This function does not reset the start condition to @c INITIAL . - */ -void yyFlexLexer::yyrestart( std::istream* input_file ) -{ - if( ! input_file ) { - input_file = &yyin; - } - yyrestart( *input_file ); + yy_init_buffer( yy_current_buffer(), input_file, yyscanner); + yy_load_buffer_state( yyscanner ); } -]]) /** Switch to a different input buffer. * @param new_buffer The new input buffer. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -void yy_switch_to_buffer YYFARGS1( yybuffer ,new_buffer) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_switch_to_buffer( yybuffer new_buffer ) -]]) +void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ - yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); + yyensure_buffer_stack (yyscanner); if ( yy_current_buffer() == new_buffer ) { return; } if ( yy_current_buffer() ) { /* Flush out information for old buffer. */ - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + *yyg->yy_c_buf_p = yyg->yy_hold_char; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos = yyg->yy_c_buf_p; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars; } - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = new_buffer; + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - YY_G(yy_did_buffer_switch_on_eof) = 1; + yyg->yy_did_buffer_switch_on_eof = 1; } -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_load_buffer_state() -]]) +static void yy_load_buffer_state (yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); - YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; -m4_ifdef([[M4_MODE_C_ONLY]], [[ - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); -]]) - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos; + yyin = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. * @return the allocated buffer state. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -yybuffer yy_create_buffer YYFARGS2( FILE *,file, int ,size) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) -]]) +yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) { yybuffer b; - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); } @@ -2918,53 +2072,35 @@ yybuffer yyFlexLexer::yy_create_buffer( std::istream& file, int size ) /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); if ( b->yy_ch_buf == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); } b->yy_is_our_buffer = 1; - yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); + yy_init_buffer( b, file, yyscanner); return b; } -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -/** Delegate creation of buffers to the new version that takes an istream reference. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * M4_YY_DOC_PARAM - * @return the allocated buffer state. - */ -yybuffer yyFlexLexer::yy_create_buffer( std::istream* file, int size ) -{ - return yy_create_buffer( *file, size ); -} -]]) - /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -void yy_delete_buffer YYFARGS1( yybuffer ,b) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_delete_buffer( yybuffer b ) -]]) +void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( b == NULL ) { return; } if ( b == yy_current_buffer() ) { /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (yybuffer) 0; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = (yybuffer) 0; } if ( b->yy_is_our_buffer ) { - yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); + yyfree( (void *) b->yy_ch_buf, yyscanner ); } - yyfree( (void *) b M4_YY_CALL_LAST_ARG ); + yyfree( (void *) b, yyscanner ); } @@ -2972,24 +2108,14 @@ void yyFlexLexer::yy_delete_buffer( yybuffer b ) * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yy_init_buffer YYFARGS2( yybuffer ,b, FILE *,file) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_init_buffer( yybuffer b, std::istream& file ) -]]) +static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) { int oerrno = errno; - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flush_buffer( b M4_YY_CALL_LAST_ARG); + yy_flush_buffer( b, yyscanner); -m4_ifdef([[M4_MODE_C_ONLY]], [[ b->yy_input_file = file; -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - b->yy_input_file = file.rdbuf(); -]]) b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ @@ -3001,7 +2127,6 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ b->yy_bs_column = 0; } -m4_ifdef([[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], [[ b->yy_is_interactive = 1; @@ -3014,26 +2139,17 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], [[ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; ]]) -]]) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - b->yy_is_interactive = 0; ]]) errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c yy_current_buffer(). - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -void yy_flush_buffer YYFARGS1( yybuffer ,b) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_flush_buffer( yybuffer b ) -]]) +void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( b == NULL ) { return; } @@ -3052,7 +2168,7 @@ void yyFlexLexer::yy_flush_buffer( yybuffer b ) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer() ) { - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); + yy_load_buffer_state( yyscanner ); } } @@ -3060,64 +2176,54 @@ void yyFlexLexer::yy_flush_buffer( yybuffer b ) * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -void yypush_buffer_state YYFARGS1(yybuffer,new_buffer) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yypush_buffer_state (yybuffer new_buffer) -]]) +void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) { return; } - yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); + yyensure_buffer_stack(yyscanner); /* This block is copied from yy_switch_to_buffer. */ if ( yy_current_buffer() != NULL ) { /* Flush out information for old buffer. */ - *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); + *yyg->yy_c_buf_p = yyg->yy_hold_char; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos = yyg->yy_c_buf_p; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (yy_current_buffer()) { - YY_G(yy_buffer_stack_top)++; + yyg->yy_buffer_stack_top++; } - YY_CURRENT_BUFFER_LVALUE = new_buffer; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - YY_G(yy_did_buffer_switch_on_eof) = 1; + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -void yypop_buffer_state (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yypop_buffer_state (void) -]]) +void yypop_buffer_state (yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (yy_current_buffer() == NULL) { return; } - yy_delete_buffer(yy_current_buffer() M4_YY_CALL_LAST_ARG); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (YY_G(yy_buffer_stack_top) > 0) { - --YY_G(yy_buffer_stack_top); + yy_delete_buffer(yy_current_buffer(), yyscanner); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = NULL; + if (yyg->yy_buffer_stack_top > 0) { + --yyg->yy_buffer_stack_top; } if (yy_current_buffer() != NULL) { - yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); - YY_G(yy_did_buffer_switch_on_eof) = 1; + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } } @@ -3125,70 +2231,60 @@ void yyFlexLexer::yypop_buffer_state (void) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yyensure_buffer_stack (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yyensure_buffer_stack(void) -]]) +static void yyensure_buffer_stack (yyscan_t yyscanner) { yy_size_t num_to_alloc; - M4_YY_DECL_GUTS_VAR(); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (YY_G(yy_buffer_stack) == NULL) { + if (yyg->yy_buffer_stack == NULL) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - M4_YY_CALL_LAST_ARG); - if ( YY_G(yy_buffer_stack == NULL) ) { + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); + if ( yyg->yy_buffer_stack == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); } - memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - YY_G(yy_buffer_stack_max) = num_to_alloc; - YY_G(yy_buffer_stack_top) = 0; + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; return; } - if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1) { + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1) { /* Increase the buffer to prepare for a possible push. */ yy_size_t grow_size = 8 /* arbitrary grow size */; - num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; - YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - (YY_G(yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - M4_YY_CALL_LAST_ARG); - if (YY_G(yy_buffer_stack) == NULL) { + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*), + yyscanner); + if (yyg->yy_buffer_stack == NULL) { YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); } /* zero only the new slots.*/ - memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - YY_G(yy_buffer_stack_max) = num_to_alloc; + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; } } - - - m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) +yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) { yybuffer b; - m4_dnl M4_YY_DECL_GUTS_VAR(); + m4_dnl struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || @@ -3196,7 +2292,7 @@ yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) /* They forgot to leave room for the EOB's. */ return NULL; } - b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); } @@ -3210,55 +2306,49 @@ yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); + yy_switch_to_buffer( b, yyscanner ); return b; } ]]) -]]) - m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -yybuffer yy_scan_string YYFARGS1( const char *, yystr) +yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) { - m4_dnl M4_YY_DECL_GUTS_VAR(); + m4_dnl struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_scan_bytes( yystr, (int) strlen(yystr) M4_YY_CALL_LAST_ARG); + return yy_scan_bytes( yystr, (int) strlen(yystr), yyscanner); } ]]) -]]) - m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { +yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { yybuffer b; char *buf; yy_size_t n; int i; - m4_dnl M4_YY_DECL_GUTS_VAR(); + m4_dnl struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); + buf = (char *) yyalloc( n, yyscanner ); if ( buf == 0 ) { YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); } @@ -3267,7 +2357,7 @@ yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { } buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); + b = yy_scan_buffer( buf, n, yyscanner); if ( b == NULL ) { YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); } @@ -3279,37 +2369,31 @@ yybuffer yy_scan_bytes YYFARGS2( const char *,yybytes, int ,_yybytes_len) { return b; } ]]) -]]) m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yy_push_state YYFARGS1( int ,_new_state) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_push_state( int _new_state ) -]]) +static void yy_push_state(int _new_state, yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); - if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) { yy_size_t new_size; - YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; - new_size = (yy_size_t) YY_G(yy_start_stack_depth) * sizeof( int ); + yyg->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = (yy_size_t) yyg->yy_start_stack_depth * sizeof( int ); - if ( ! YY_G(yy_start_stack) ) { - YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); + if ( ! yyg->yy_start_stack ) { + yyg->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); } else { - YY_G(yy_start_stack) = (int *) yyrealloc( - (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); + yyg->yy_start_stack = (int *) yyrealloc( + (void *) yyg->yy_start_stack, new_size, yyscanner ); } - if ( ! YY_G(yy_start_stack) ) { + if ( ! yyg->yy_start_stack ) { YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } } - YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; + yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; BEGIN(_new_state); } @@ -3318,33 +2402,23 @@ void yyFlexLexer::yy_push_state( int _new_state ) m4_ifdef( [[M4_YY_NO_POP_STATE]],, [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yy_pop_state (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -void yyFlexLexer::yy_pop_state() -]]) +static void yy_pop_state (yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); - if ( --YY_G(yy_start_stack_ptr) < 0 ) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( --yyg->yy_start_stack_ptr < 0 ) { YY_FATAL_ERROR( "start-condition stack underflow" ); } - BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); + BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); } ]]) m4_ifdef( [[M4_YY_NO_TOP_STATE]],, [[ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static int yy_top_state (M4_YY_DEF_ONLY_ARG) -]]) -m4_ifdef([[M4_MODE_CXX_ONLY]], [[ -int yyFlexLexer::yy_top_state() -]]) +static int yy_top_state (yyscan_t yyscanner) { - M4_YY_DECL_GUTS_VAR(); - return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyg->yy_start_stack_ptr > 0 ? yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1] : YY_START; } ]]) @@ -3356,76 +2430,62 @@ int yyFlexLexer::yy_top_state() /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = YY_G(yy_hold_char); \ - YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ - YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ - *YY_G(yy_c_buf_p) = '\0'; \ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ yyleng = yyless_macro_arg; \ } while ( 0 ) - - /* Accessor methods (get/set functions) to struct members. */ -m4_ifdef([[M4_MODE_C_ONLY]], [[ -m4_ifdef([[M4_YY_REENTRANT]], [[ -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, -[[ +m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, [[ /** Get the user-defined data for this scanner. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE yyget_extra (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; } ]]) -]]) m4_ifdef( [[M4_YY_NO_GET_LINENO]],, [[ /** Get the current line number. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -int yyget_lineno (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +int yyget_lineno (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - if (yy_current_buffer() == NULL) { - return 0; - } - ]]) + if (yy_current_buffer() == NULL) { + return 0; + } return yylineno; } ]]) -m4_ifdef( [[M4_YY_REENTRANT]], -[[ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, [[ /** Get the current column number. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -int yyget_column (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +int yyget_column (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -m4_ifdef( [[M4_YY_REENTRANT]], [[ if (yy_current_buffer() == NULL) { return 0; } -]]) return yycolumn; } ]]) -]]) m4_ifdef( [[M4_YY_NO_GET_IN]],, [[ /** Get the input stream. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -FILE *yyget_in (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +FILE *yyget_in (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; } ]]) @@ -3433,10 +2493,10 @@ FILE *yyget_in (M4_YY_DEF_ONLY_ARG) { m4_ifdef( [[M4_YY_NO_GET_OUT]],, [[ /** Get the output stream. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -FILE *yyget_out (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +FILE *yyget_out (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; } ]]) @@ -3444,100 +2504,89 @@ FILE *yyget_out (M4_YY_DEF_ONLY_ARG) { m4_ifdef( [[M4_YY_NO_GET_LENG]],, [[ /** Get the length of the current token. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -int yyget_leng (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +int yyget_leng (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; } ]]) /** Get the current token. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ m4_ifdef( [[M4_YY_NO_GET_TEXT]],, [[ -char *yyget_text (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +char *yyget_text (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; } ]]) -m4_ifdef([[M4_YY_REENTRANT]], [[ m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, [[ /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) { - M4_YY_DECL_GUTS_VAR(); +void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; } ]]) -]]) m4_ifdef( [[M4_YY_NO_SET_LINENO]],, [[ /** Set the current line number. * @param _line_number line number - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -void yyset_lineno YYFARGS1( int ,_line_number) { - M4_YY_DECL_GUTS_VAR(); - - m4_ifdef( [[M4_YY_REENTRANT]], - [[ - /* lineno is only valid if an input buffer exists. */ - if (yy_current_buffer() == NULL ) { - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - } - ]]) +void yyset_lineno(int _line_number, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (yy_current_buffer() == NULL ) { + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + } yylineno = _line_number; } ]]) -m4_ifdef( [[M4_YY_REENTRANT]], -[[ m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, [[ /** Set the current column. * @param _column_no column number - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. */ -void yyset_column YYFARGS1( int , _column_no) { - M4_YY_DECL_GUTS_VAR(); +void yyset_column(int _column_no, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -m4_ifdef( [[M4_YY_REENTRANT]], [[ /* column is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { YY_FATAL_ERROR( "yyset_column called with no buffer" ); } -]]) yycolumn = _column_no; } ]]) -]]) - m4_ifdef( [[M4_YY_NO_SET_IN]],, [[ /** Set the input stream. This does not discard the current * input buffer. * @param _in_str A readable stream. - * M4_YY_DOC_PARAM + * @param yyscanner The scanner object. * @see yy_switch_to_buffer */ -void yyset_in YYFARGS1( FILE * ,_in_str) { - M4_YY_DECL_GUTS_VAR(); +void yyset_in(FILE * _in_str, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = _in_str ; } ]]) m4_ifdef( [[M4_YY_NO_SET_OUT]],, [[ -void yyset_out YYFARGS1( FILE * ,_out_str) { - M4_YY_DECL_GUTS_VAR(); +void yyset_out( FILE * _out_str, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = _out_str ; } ]]) @@ -3545,37 +2594,33 @@ void yyset_out YYFARGS1( FILE * ,_out_str) { m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ -int yyget_debug (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +int yyget_debug (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } ]]) m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ -void yyset_debug YYFARGS1( int ,_bdebug) { - M4_YY_DECL_GUTS_VAR(); +void yyset_debug(int _bdebug, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; } ]]) -]]) - -m4_ifdef([[M4_YY_REENTRANT]], [[ -/* Accessor methods for yylval and yylloc */ m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_ifdef( [[M4_YY_NO_GET_LVAL]],, [[ -YYSTYPE * yyget_lval (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +YYSTYPE * yyget_lval (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylval; } ]]) m4_ifdef( [[M4_YY_NO_SET_LVAL]],, [[ -void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) { - M4_YY_DECL_GUTS_VAR(); +void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; } ]]) @@ -3584,16 +2629,16 @@ m4_ifdef( [[]], [[ m4_ifdef( [[M4_YY_NO_GET_LLOC]],, [[ -YYLTYPE *yyget_lloc (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +YYLTYPE *yyget_lloc (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylloc; } ]]) m4_ifdef( [[M4_YY_NO_SET_LLOC]],, [[ -void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) { - M4_YY_DECL_GUTS_VAR(); +void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylloc = yylloc_param; } ]]) @@ -3601,7 +2646,6 @@ void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) { ]]) - /* User-visible API */ /* yylex_init is special because it creates the scanner itself, so it is @@ -3627,7 +2671,6 @@ int yylex_init(yyscan_t* ptr_yy_globals) { return yy_init_globals ( *ptr_yy_globals ); } - /* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and @@ -3661,51 +2704,34 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) return yy_init_globals ( *ptr_yy_globals ); } -]]) -%# Actually, that ended an if-rentrant section - -m4_ifdef([[M4_MODE_C_ONLY]], [[ -static int yy_init_globals (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); - /* Initialization is the same as for the non-reentrant scanner. +static int yy_init_globals (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* * This function is called from yylex_destroy(), so don't allocate here. */ - -m4_ifdef( [[M4_MODE_YYLINENO]], -[[ - m4_ifdef( [[M4_YY_NOT_REENTRANT]], - [[ - /* We do not touch yylineno unless the option is enabled. */ - yylineno = 1; - ]]) -]]) - YY_G(yy_buffer_stack) = NULL; - YY_G(yy_buffer_stack_top) = 0; - YY_G(yy_buffer_stack_max) = 0; - YY_G(yy_c_buf_p) = NULL; - YY_G(yy_init) = 0; - YY_G(yy_start) = 0; - -m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], -[[ - YY_G(yy_start_stack_ptr) = 0; - YY_G(yy_start_stack_depth) = 0; - YY_G(yy_start_stack) = NULL; -]]) + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - YY_G(yy_state_buf) = 0; - YY_G(yy_state_ptr) = 0; - YY_G(yy_full_match) = 0; - YY_G(yy_lp) = 0; + yyg->yy_state_buf = 0; + yyg->yy_state_ptr = 0; + yyg->yy_full_match = 0; + yyg->yy_lp = 0; ]]) -m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ - YY_G(yytext_ptr) = 0; - YY_G(yy_more_offset) = 0; - YY_G(yy_prev_more_offset) = 0; + yyg->yytext_ptr = 0; + yyg->yy_more_offset = 0; + yyg->yy_prev_more_offset = 0; ]]) /* Defined in main.c */ @@ -3722,66 +2748,46 @@ m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], */ return 0; } -]]) - -m4_ifdef([[M4_MODE_C_ONLY]], [[ -%# SNIP! this currently causes conflicts with the c++ scanner /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (M4_YY_DEF_ONLY_ARG) { - M4_YY_DECL_GUTS_VAR(); +int yylex_destroy (yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(yy_current_buffer()) { - yy_delete_buffer( yy_current_buffer() M4_YY_CALL_LAST_ARG ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(M4_YY_CALL_ONLY_ARG); + yy_delete_buffer( yy_current_buffer(), yyscanner ); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = NULL; + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); - YY_G(yy_buffer_stack) = NULL; + yyfree(yyg->yy_buffer_stack, yyscanner); + yyg->yy_buffer_stack = NULL; -m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], -[[ /* Destroy the start condition stack. */ - yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); - YY_G(yy_start_stack) = NULL; -]]) + yyfree( yyg->yy_start_stack, yyscanner ); + yyg->yy_start_stack = NULL; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); - YY_G(yy_state_buf) = NULL; + yyfree ( yyg->yy_state_buf, yyscanner); + yyg->yy_state_buf = NULL; ]]) /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ - yy_init_globals( M4_YY_CALL_ONLY_ARG); + yy_init_globals(yyscanner); -m4_ifdef([[M4_YY_REENTRANT]], [[ /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); + yyfree ( yyscanner, yyscanner ); yyscanner = NULL; -]]) return 0; } -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* - * Internal utility routines. - */ -]]) - -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #ifndef yytext_ptr -static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); +static void yy_flex_strncpy(char *s1, const char *s2, int n, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; /* forestall unused-argument warning */ int i; for ( i = 0; i < n; ++i ) { @@ -3789,12 +2795,9 @@ static void yy_flex_strncpy YYFARGS3( char*,s1, const char *,s2, int,n) { } } #endif -]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ #ifdef YY_NEED_STRLEN -static int yy_flex_strlen YYFARGS1( const char *,s) +static int yy_flex_strlen(const char *s, yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -3803,23 +2806,30 @@ static int yy_flex_strlen YYFARGS1( const char *,s) return n; } #endif -]]) m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, [[ -void *yyalloc YYFARGS1( yy_size_t ,size) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); +void *yyalloc(yy_size_t size, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; /* forestall unused-argument warning */ return malloc(size); } ]]) m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, [[ -void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); +void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) +m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; /* forestall unused-argument warning */ /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -3827,460 +2837,22 @@ void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) { * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return realloc(ptr, size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree YYFARGS1( void *,ptr) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ + free( (char *) ptr ); } ]]) -m4_ifdef([[M4_MODE_TABLESEXT]], [[ -%# definitions -m4preproc_include(`tables_shared.c') - -static int yytbl_read8 (void *v, struct yytbl_reader * rd) { - errno = 0; - if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1) { - errno = EIO; - return -1; - } - rd->bread += (flex_uint32_t) sizeof(flex_uint8_t); - return 0; -} - -static int yytbl_read16 (void *v, struct yytbl_reader * rd) { - errno = 0; - if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1) { - errno = EIO; - return -1; - } - *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); - rd->bread += (flex_uint32_t) sizeof(flex_uint16_t); - return 0; -} - -static int yytbl_read32 (void *v, struct yytbl_reader * rd) { - errno = 0; - if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1) { - errno = EIO; - return -1; - } - *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); - rd->bread += (flex_uint32_t) sizeof(flex_uint32_t); - return 0; -} - -/** Read the header */ -static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) { - size_t bytes; - memset (th, 0, sizeof (struct yytbl_hdr)); - - if (yytbl_read32 (&(th->th_magic), rd) != 0) { - return -1; - } - if (th->th_magic != YYTBL_MAGIC) { - YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ - return -1; - } - - if (yytbl_read32 (&(th->th_hsize), rd) != 0 - || yytbl_read32 (&(th->th_ssize), rd) != 0 - || yytbl_read16 (&(th->th_flags), rd) != 0) { - return -1; - } - /* Sanity check on header size. Greater than 1k suggests some funny business. */ - if (th->th_hsize < 16 || th->th_hsize > 1024) { - YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate enough space for the version and name fields */ - bytes = th->th_hsize - 14; - th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - if ( ! th->th_version ) { - YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); - } - /* we read it all into th_version, and point th_name into that data */ - if (fread (th->th_version, 1, bytes, rd->fp) != bytes) { - errno = EIO; - yyfree(th->th_version M4_YY_CALL_LAST_ARG); - th->th_version = NULL; - return -1; - } else { - rd->bread += (flex_uint32_t) bytes; - } - th->th_name = th->th_version + strlen (th->th_version) + 1; - return 0; -} - -/** lookup id in the dmap list. - * @param dmap pointer to first element in list - * @return NULL if not found. - */ -static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, int, id) { - M4_YY_DECL_GUTS_VAR(); - M4_YY_NOOP_GUTS_VAR(); - - while (dmap->dm_id) { - if ((int)(dmap->dm_id) == id) { - return dmap; - } else { - dmap++; - } - } - return NULL; -} - -/** Read a table while mapping its contents to the local array. - * @param dmap used to performing mapping - * @return 0 on success - */ -static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) { - struct yytbl_data td; - struct yytbl_dmap *transdmap=0; - int len, i, rv, inner_loop_count; - void *p=0; - - memset (&td, 0, sizeof (struct yytbl_data)); - - if (yytbl_read16 (&td.td_id, rd) != 0 - || yytbl_read16 (&td.td_flags, rd) != 0 - || yytbl_read32 (&td.td_hilen, rd) != 0 - || yytbl_read32 (&td.td_lolen, rd) != 0) { - return -1; - } - /* Lookup the map for the transition table so we have it in case we need it - * inside the loop below. This scanner might not even have a transition - * table, which is ok. - */ - transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); - - if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL) { - YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ - return -1; - } - - /* Allocate space for table. - * The --full yy_transition table is a special case, since we - * need the dmap.dm_sz entry to tell us the sizeof the individual - * struct members. - */ - { - size_t bytes; - - if ((td.td_flags & YYTD_STRUCT)) { - bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); - } else { - bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; - } - if (M4_YY_TABLES_VERIFY) { - /* We point to the array itself */ - p = dmap->dm_arr; - } else { - /* We point to the address of a pointer. */ - *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); - } - if ( ! p ) { - YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); - } - } - - /* If it's a struct, we read 2 integers to get one element */ - if ((td.td_flags & YYTD_STRUCT) != 0) { - inner_loop_count = 2; - } else { - inner_loop_count = 1; - } - /* read and map each element. - * This loop iterates once for each element of the td_data array. - * Notice that we increment 'i' in the inner loop. - */ - len = yytbl_calc_total_len (&td); - for (i = 0; i < len; ) { - int j; - - /* This loop really executes exactly 1 or 2 times. - * The second time is to handle the second member of the - * YYTD_STRUCT for the yy_transition array. - */ - for (j = 0; j < inner_loop_count; j++, i++) { - flex_int32_t t32; - - /* read into t32 no matter what the real size is. */ - { - flex_int16_t t16; - flex_int8_t t8; - - switch (YYTDFLAGS2BYTES (td.td_flags)) { - case sizeof (flex_int32_t): - rv = yytbl_read32 (&t32, rd); - break; - case sizeof (flex_int16_t): - rv = yytbl_read16 (&t16, rd); - t32 = t16; - break; - case sizeof (flex_int8_t): - rv = yytbl_read8 (&t8, rd); - t32 = t8; - break; - default: - YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ - return -1; - } - } - if (rv != 0) { - return -1; - } - /* copy into the deserialized array... */ - - if ((td.td_flags & YYTD_STRUCT)) { - /* t32 is the j'th member of a two-element struct. */ - void *v; - - v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) - : &(((struct yy_trans_info *) p)->yy_nxt); - - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if (M4_YY_TABLES_VERIFY) { - if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); - } else { - ((flex_int32_t *) v)[0] = (flex_int32_t) t32; - } - break; - case sizeof (flex_int16_t): - if (M4_YY_TABLES_VERIFY ) { - if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); - } else { - ((flex_int16_t *) v)[0] = (flex_int16_t) t32; - } - break; - case sizeof(flex_int8_t): - if (M4_YY_TABLES_VERIFY ) { - if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) - YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); - } else { - ((flex_int8_t *) v)[0] = (flex_int8_t) t32; - } - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ - return -1; - } - - /* if we're done with j, increment p */ - if (j == 1) { - p = (struct yy_trans_info *) p + 1; - } - } - else if ((td.td_flags & YYTD_PTRANS)) { - /* t32 is an index into the transition array. */ - struct yy_trans_info *v; - - if (!transdmap) { - YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ - return -1; - } - - if( M4_YY_TABLES_VERIFY) { - v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); - } else { - v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); - } - if(M4_YY_TABLES_VERIFY ) { - if( ((struct yy_trans_info **) p)[0] != v) - YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); - } else { - ((struct yy_trans_info **) p)[0] = v; - } - /* increment p */ - p = (struct yy_trans_info **) p + 1; - } - else { - /* t32 is a plain int. copy data, then incrememnt p. */ - switch (dmap->dm_sz) { - case sizeof (flex_int32_t): - if(M4_YY_TABLES_VERIFY ) { - if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) { - YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); - } - } else { - ((flex_int32_t *) p)[0] = (flex_int32_t) t32; - } - p = ((flex_int32_t *) p) + 1; - break; - case sizeof (flex_int16_t): - if(M4_YY_TABLES_VERIFY ) { - if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) { - YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); - } - } else { - ((flex_int16_t *) p)[0] = (flex_int16_t) t32; - } - p = ((flex_int16_t *) p) + 1; - break; - case sizeof (flex_int8_t): - if(M4_YY_TABLES_VERIFY ){ - if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) { - YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); - } - } else { - ((flex_int8_t *) p)[0] = (flex_int8_t) t32; - } - p = ((flex_int8_t *) p) + 1; - break; - default: - YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ - return -1; - } - } - } - - } - - /* Now eat padding. */ - { - while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) { - flex_int8_t t8; - if(yytbl_read8(&t8,rd) != 0) - return -1; - } - } - - return 0; -} - -/* The name for this specific scanner's tables. */ -#define YYTABLES_NAME "m4_ifdef([[M4_MODE_PREFIX]], M4_MODE_PREFIX, [[yy]])tables" - -/* Find the key and load the DFA tables from the given stream. */ -static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) { - int rv=0; - struct yytbl_hdr th; - struct yytbl_reader rd; - - rd.fp = fp; - th.th_version = NULL; - - /* Keep trying until we find the right set of tables or end of file. */ - while (!feof(rd.fp)) { - rd.bread = 0; - if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0) { - rv = -1; - goto return_rv; - } - - /* A NULL key means choose the first set of tables. */ - if (key == NULL) { - break; - } - - if (strcmp(th.th_name,key) != 0) { - /* Skip ahead to next set */ - fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - else { - break; - } - } - - while (rd.bread < th.th_ssize) { - /* Load the data tables */ - if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ - rv = -1; - goto return_rv; - } - } - -return_rv: - if(th.th_version) { - yyfree(th.th_version M4_YY_CALL_LAST_ARG); - th.th_version = NULL; - } - - return rv; -} - -/** Load the DFA tables for this scanner from the given stream. */ -int yytables_fload YYFARGS1(FILE *, fp) { - if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) { - return -1; - } - return 0; -} - -/** Destroy the loaded tables, freeing memory, etc.. */ -int yytables_destroy (M4_YY_DEF_ONLY_ARG) { - struct yytbl_dmap *dmap=0; - - if(!M4_YY_TABLES_VERIFY){ - /* Walk the dmap, freeing the pointers */ - for(dmap=yydmap; dmap->dm_id; dmap++) { - void * v; - v = dmap->dm_arr; - if(v && *(char**)v){ - yyfree(*(char**)v M4_YY_CALL_LAST_ARG); - *(char**)v = NULL; - } - } - } - - return 0; -} - -/* end table serialization code definitions */ -]]) - - m4_ifdef([[M4_YY_MAIN]], [[ -int main (void); - int main () { -m4_ifdef([[M4_YY_REENTRANT]], [[ yyscan_t lexer; yylex_init(&lexer); yylex( lexer ); yylex_destroy( lexer); - -]]) -m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ yylex(); -]]) return 0; } ]]) -]]) -m4_ifdef( [[M4_YY_IN_HEADER]], -[[ -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif -m4preproc_undivert(1) -#undef M4_MODE_PREFIX[[IN_HEADER]] -#endif /* M4_MODE_PREFIX[[HEADER_H]] */ -m4_undefine([[M4_YY_IN_HEADER]])m4_dnl -]]) - %# Local Variables: %# mode:c %# c-file-style:"k&r" -- cgit v1.2.1 From 68d658f60c42ad22f93f7b982934f29becce7428 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Oct 2020 22:40:47 -0400 Subject: Sever a C99 dependency on ECHO, --- src/c99-flex.skl | 7 ++----- src/parse.y | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 916b71e..b011a0a 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -291,8 +291,8 @@ typedef size_t yy_size_t; do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ @@ -1008,9 +1008,6 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) #define YY_EXIT_FAILURE 2 #endif -/* Legacy interface */ -#define ECHO yyecho() - static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; /* forestall unused-argument warning */ diff --git a/src/parse.y b/src/parse.y index beb3b12..323689f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -139,7 +139,7 @@ goal : initlex sect1 sect1end sect2 initforrule add_action( "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); else - add_action( "ECHO" ); + add_action( "yyecho()" ); add_action( ";\n\tYY_BREAK]]\n" ); } -- cgit v1.2.1 From 393b0b573325239ca16452dd5175feed2fd465ad Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 25 Oct 2020 00:13:56 -0400 Subject: yyconst is a pre-ANSI archaism. Remove it from the test code... ...so the C99 back end doesn;'t have to carry it. It's still defined in the default C back end. --- tests/prefix_c99.l | 4 ++-- tests/prefix_nr.l | 4 ++-- tests/prefix_r.l | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l index d66df29..08120ad 100644 --- a/tests/prefix_c99.l +++ b/tests/prefix_c99.l @@ -48,8 +48,8 @@ FOO_init_buffer( (YY_BUFFER_STATE)0, (FILE*)0, yyscanner); FOO_load_buffer_state( yyscanner); FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner); - FOO_scan_bytes( (yyconst char*)0, 0, yyscanner); - FOO_scan_string( (yyconst char*)0, yyscanner); + FOO_scan_bytes( (const char*)0, 0, yyscanner); + FOO_scan_string( (const char*)0, yyscanner); FOO_switch_to_buffer( (YY_BUFFER_STATE)0, yyscanner); FOOrestart( (FILE*)0, (yyscan_t )0); diff --git a/tests/prefix_nr.l b/tests/prefix_nr.l index 2208ae0..04dff31 100644 --- a/tests/prefix_nr.l +++ b/tests/prefix_nr.l @@ -47,8 +47,8 @@ FOO_init_buffer((YY_BUFFER_STATE)0,(FILE*)0); FOO_load_buffer_state(); FOO_scan_buffer((char*)0,(yy_size_t)0); - FOO_scan_bytes((yyconst char*)0, 0); - FOO_scan_string((yyconst char*)0); + FOO_scan_bytes((const char*)0, 0); + FOO_scan_string((const char*)0); FOO_switch_to_buffer((YY_BUFFER_STATE)0); yyin = (FILE*)0; yyout = (FILE*)0; diff --git a/tests/prefix_r.l b/tests/prefix_r.l index 210a4de..384e74e 100644 --- a/tests/prefix_r.l +++ b/tests/prefix_r.l @@ -48,8 +48,8 @@ FOO_init_buffer( (YY_BUFFER_STATE)0, (FILE*)0, yyscanner); FOO_load_buffer_state( yyscanner); FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner); - FOO_scan_bytes( (yyconst char*)0, 0, yyscanner); - FOO_scan_string( (yyconst char*)0, yyscanner); + FOO_scan_bytes( (const char*)0, 0, yyscanner); + FOO_scan_string( (const char*)0, yyscanner); FOO_switch_to_buffer( (YY_BUFFER_STATE)0, yyscanner); FOOrestart( (FILE*)0, (yyscan_t )0); -- cgit v1.2.1 From 307645b7b7a21453fb8a777ddb7b0bf76df84dfd Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 25 Oct 2020 09:53:18 -0400 Subject: Narrow the interface between Flex and the skeleton file... ...and reduce C preprocessor entanglement in the C99 skeleton. --- src/c99-flex.skl | 4 ++-- src/cpp-flex.skl | 4 ++-- src/flexdef.h | 1 - src/main.c | 4 ++-- src/misc.c | 5 ----- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index b011a0a..8fcffb0 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -42,11 +42,11 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) -m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 +m4_define([[M4_HOOK_CONST_DEFINE]], [[const int $1 = $2; ]]) m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) -m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1 +m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1 ]]) m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 ]]) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 6c0920a..caf5fe1 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -46,9 +46,9 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 ]]) -m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 +m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1 ]]) -m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1 +m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 ]]) diff --git a/src/flexdef.h b/src/flexdef.h index 8c90933..098f72d 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -929,7 +929,6 @@ extern void out_dec(const char *, int); extern void out_dec2(const char *, int, int); extern void out_hex(const char *, unsigned int); extern void out_str(const char *, const char *); -extern void out_str3(const char *, const char *, const char *, const char *); extern void out_str_dec(const char *, const char *, int); extern void outc(int); extern void outn(const char *); diff --git a/src/main.c b/src/main.c index e358027..735cf80 100644 --- a/src/main.c +++ b/src/main.c @@ -205,7 +205,7 @@ int flex_main (int argc, char *argv[]) /* Need to define the transet type as a size large * enough to hold the biggest offset. */ - out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", optimize_pack(tblend + numecs + 1)->name, ""); + out_str ("M4_HOOK_SET_OFFSET_TYPE(%s)", optimize_pack(tblend + numecs + 1)->name); comment("END of Flex-generated definitions\n"); skelout (true); /* %% [2.0] - tables get dumped here */ @@ -1307,7 +1307,7 @@ void readin (void) } if (ctrl.yylmax != 0) { - out_dec ("M4_HOOK_SET_YYLMAX(%d)\n", ctrl.yylmax); + out_dec ("M4_CONST_DEFINE(YYLMAX, %d)\n", ctrl.yylmax); } /* Dump the user defined preproc directives. */ diff --git a/src/misc.c b/src/misc.c index 5c1664e..9b434c8 100644 --- a/src/misc.c +++ b/src/misc.c @@ -503,11 +503,6 @@ void out_str (const char *fmt, const char str[]) fprintf (stdout,fmt, str); } -void out_str3 (const char *fmt, const char s1[], const char s2[], const char s3[]) -{ - fprintf (stdout,fmt, s1, s2, s3); -} - void out_str_dec (const char *fmt, const char str[], int n) { fprintf (stdout,fmt, str, n); -- cgit v1.2.1 From ac97741a0b3f9d33beb2c081af2089de209290cd Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Mon, 26 Oct 2020 02:08:18 +0000 Subject: Fix Next link in the Overview of the Retargeting section of the manual (#3) --- doc/flex.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/flex.texi b/doc/flex.texi index bcc099e..c134784 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8695,7 +8695,7 @@ to Flex. * Translation Guidelines:: @end menu -@node Overview, , , Retargeting Flex +@node Overview, Getting Started, , Retargeting Flex @subsection Overview The Flex code has been factored to isolate knowledge of the specifics -- cgit v1.2.1 From e7b758041c354ca28ce441615481abdd591c24fb Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Mon, 26 Oct 2020 02:08:33 +0000 Subject: Expand M4_HOOK_CONST_DEFINE into multiple macros for different types (#6) The Rust backend needs to know the type of every constant; it can't just guess and it doesn't have text macros like C. --- src/c99-flex.skl | 10 +++++++++- src/cpp-flex.skl | 10 +++++++++- src/main.c | 18 +++++++++--------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 8fcffb0..2f2bc2c 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -42,7 +42,15 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) -m4_define([[M4_HOOK_CONST_DEFINE]], [[const int $1 = $2; +m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yy_state_type $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_BOOL]], [[const bool $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[#define $1 $2 ]]) m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index caf5fe1..6f4cf60 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -44,7 +44,15 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) -m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2 +m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[#define $1 $2 +]]) +m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[#define $1 $2 +]]) +m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[#define $1 $2 +]]) +m4_define([[M4_HOOK_CONST_DEFINE_BOOL]], [[#define $1 $2 +]]) +m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[#define $1 $2 ]]) m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1 ]]) diff --git a/src/main.c b/src/main.c index 735cf80..fb468d3 100644 --- a/src/main.c +++ b/src/main.c @@ -197,11 +197,11 @@ int flex_main (int argc, char *argv[]) out ("\n"); comment("START of Flex-generated definitions\n"); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUM_RULES", num_rules); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_END_OF_BUFFER", num_rules + 1); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMBASE", jambase); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_JAMSTATE", jamstate); - out_str_dec ("M4_HOOK_CONST_DEFINE(%s, %d)", "YY_NUL_EC", NUL_ec); + out_str_dec ("M4_HOOK_CONST_DEFINE_UINT(%s, %d)", "YY_NUM_RULES", num_rules); + out_str_dec ("M4_HOOK_CONST_DEFINE_STATE(%s, %d)", "YY_END_OF_BUFFER", num_rules + 1); + out_str_dec ("M4_HOOK_CONST_DEFINE_STATE(%s, %d)", "YY_JAMBASE", jambase); + out_str_dec ("M4_HOOK_CONST_DEFINE_STATE(%s, %d)", "YY_JAMSTATE", jamstate); + out_str_dec ("M4_HOOK_CONST_DEFINE_BYTE(%s, %d)", "YY_NUL_EC", NUL_ec); /* Need to define the transet type as a size large * enough to hold the biggest offset. */ @@ -1044,7 +1044,7 @@ void flexinit (int argc, char **argv) if (*def == '\0') def = "1"; - snprintf(buf2, sizeof(buf2), "M4_HOOK_CONST_DEFINE(%s, %s)", arg, def); + snprintf(buf2, sizeof(buf2), "M4_HOOK_CONST_DEFINE_UNKNOWN(%s, %s)", arg, def); buf_strappend (&userdef_buf, buf2); } break; @@ -1307,9 +1307,9 @@ void readin (void) } if (ctrl.yylmax != 0) { - out_dec ("M4_CONST_DEFINE(YYLMAX, %d)\n", ctrl.yylmax); + out_dec ("M4_HOOK_CONST_DEFINE_UINT(YYLMAX, %d)\n", ctrl.yylmax); } - + /* Dump the user defined preproc directives. */ if (userdef_buf.elts) outn ((char *) (userdef_buf.elts)); @@ -1439,7 +1439,7 @@ void readin (void) int i; buf_init(&tmpbuf, sizeof(char)); for (i = 1; i <= lastsc; i++) { - char *str, *fmt = "M4_HOOK_CONST_DEFINE(%s, %d)"; + char *str, *fmt = "M4_HOOK_CONST_DEFINE_STATE(%s, %d)"; size_t strsz; strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2; -- cgit v1.2.1 From 5e71dbbf5ddb9ed42819fe46ac2325ae8e03f8a5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 25 Oct 2020 21:57:17 -0400 Subject: Polish tests and test documentation. --- tests/Makefile.am | 2 +- tests/README | 6 +++--- tests/include_by_buffer.direct.l | 6 +++--- tests/include_by_push.direct.l | 2 +- tests/multiple_scanners_nr_main.c | 2 +- tests/multiple_scanners_r_main.c | 2 +- tests/prefix_c99.l | 8 ++++---- tests/prefix_nr.l | 8 ++++---- tests/prefix_r.l | 8 ++++---- tests/string_c99.l | 2 +- tests/string_nr.l | 3 +-- tests/string_r.l | 2 +- 12 files changed, 25 insertions(+), 26 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 240c220..f4c5752 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -233,7 +233,7 @@ CLEANFILES = \ prefix_r.c \ prefix_c99.c \ pthread.c \ - quotes_nr.c \ + quotes.c \ quotes_c99.c \ rescan_nr.direct.c \ rescan_r.direct.c \ diff --git a/tests/README b/tests/README index 5821d15..9518835 100644 --- a/tests/README +++ b/tests/README @@ -39,8 +39,8 @@ To build and execute a single test: prior properly consumed every input token. The test machinery will expand a rules file into tests for all back ends. -** List your test in the TESTS variable in Makefile.am in this - directory. Note that due to the large number of tests, we use +** Otherwise, list your test in the TESTS variable in Makefile.am in + this directory. Note that due to the large number of tests, we use variables to group similar tests together. This also helps with handling the automake test suite requirements. Hopefully your test can be listed in SIMPLE_TESTS. You'll need to add the appropriate @@ -90,7 +90,7 @@ If you can express your test as a ruleset within in this orotocol, please do so. Those tests are easy to port to new back ends, as that whole job can be done by enhabcing testmaker.m4. -WHY SOME TESTS ARE MISSING +* WHY SOME TESTS ARE MISSING The "top" test is backend-independent; what it's really testing is Flex's ability to accumulate and ship preamble code sections. diff --git a/tests/include_by_buffer.direct.l b/tests/include_by_buffer.direct.l index 684d34b..0be055c 100644 --- a/tests/include_by_buffer.direct.l +++ b/tests/include_by_buffer.direct.l @@ -41,7 +41,7 @@ int error = 0; %{ #define MAX_INCLUDE_DEPTH 10 -YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +yybuffer include_stack[MAX_INCLUDE_DEPTH]; int include_stack_ptr = 0; %} %% @@ -55,7 +55,7 @@ int include_stack_ptr = 0; [[:alnum:]_.-]+> { /* recurse */ yytext[yyleng-1]='\0'; - include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; + include_stack[include_stack_ptr++] = yy_current_buffer(); if((yyin=fopen(yytext,"r"))==NULL) { fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext); error = 1; @@ -77,7 +77,7 @@ int include_stack_ptr = 0; } else { fclose(yyin); - yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_delete_buffer( yy_current_buffer() ); yy_switch_to_buffer( include_stack[include_stack_ptr] ); } } diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l index 5f5fbf3..6f1b4ea 100644 --- a/tests/include_by_push.direct.l +++ b/tests/include_by_push.direct.l @@ -68,7 +68,7 @@ int error = 0; <> { fclose(yyin); testpop_buffer_state(); - if(!YY_CURRENT_BUFFER) + if(!yy_current_buffer()) yyterminate(); } diff --git a/tests/multiple_scanners_nr_main.c b/tests/multiple_scanners_nr_main.c index 497bd9f..6bb5a89 100644 --- a/tests/multiple_scanners_nr_main.c +++ b/tests/multiple_scanners_nr_main.c @@ -31,7 +31,7 @@ main ( int argc, char** argv ) (void)argv; int S1_ok=1, S2_ok=1; - YY_BUFFER_STATE buff1, buff2; + yybuffer buff1, buff2; S1_out = S2_out = stdout; buff1 = S1__scan_string("foo on bar off"); buff2 = S2__scan_string("on blah blah off foo on bar off"); diff --git a/tests/multiple_scanners_r_main.c b/tests/multiple_scanners_r_main.c index 9c3fa8d..f35ecbb 100644 --- a/tests/multiple_scanners_r_main.c +++ b/tests/multiple_scanners_r_main.c @@ -31,7 +31,7 @@ main ( int argc, char** argv ) (void)argv; int S1_ok=1, S2_ok=1; - YY_BUFFER_STATE buff1, buff2; + yybuffer buff1, buff2; yyscan_t scan1, scan2; S1_lex_init(&scan1); diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l index 08120ad..feb29b1 100644 --- a/tests/prefix_c99.l +++ b/tests/prefix_c99.l @@ -43,14 +43,14 @@ /* Compile, but do not execute the following code. */ if( 0 ) { FOO_create_buffer( (FILE*)0, 0, yyscanner); - FOO_delete_buffer( (YY_BUFFER_STATE)0, yyscanner); - FOO_flush_buffer( (YY_BUFFER_STATE)0, yyscanner); - FOO_init_buffer( (YY_BUFFER_STATE)0, (FILE*)0, yyscanner); + FOO_delete_buffer( (yybuffer)0, yyscanner); + FOO_flush_buffer( (yybuffer)0, yyscanner); + FOO_init_buffer( (yybuffer)0, (FILE*)0, yyscanner); FOO_load_buffer_state( yyscanner); FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner); FOO_scan_bytes( (const char*)0, 0, yyscanner); FOO_scan_string( (const char*)0, yyscanner); - FOO_switch_to_buffer( (YY_BUFFER_STATE)0, yyscanner); + FOO_switch_to_buffer( (yybuffer)0, yyscanner); FOOrestart( (FILE*)0, (yyscan_t )0); FOOget_extra( (yyscan_t )0 ); diff --git a/tests/prefix_nr.l b/tests/prefix_nr.l index 04dff31..e163789 100644 --- a/tests/prefix_nr.l +++ b/tests/prefix_nr.l @@ -42,14 +42,14 @@ /* Compile, but do not execute the following code. */ if( 0) { FOO_create_buffer((FILE*)0,0); - FOO_delete_buffer((YY_BUFFER_STATE)0); - FOO_flush_buffer((YY_BUFFER_STATE)0); - FOO_init_buffer((YY_BUFFER_STATE)0,(FILE*)0); + FOO_delete_buffer((yybuffer)0); + FOO_flush_buffer((yybuffer)0); + FOO_init_buffer((yybuffer)0,(FILE*)0); FOO_load_buffer_state(); FOO_scan_buffer((char*)0,(yy_size_t)0); FOO_scan_bytes((const char*)0, 0); FOO_scan_string((const char*)0); - FOO_switch_to_buffer((YY_BUFFER_STATE)0); + FOO_switch_to_buffer((yybuffer)0); yyin = (FILE*)0; yyout = (FILE*)0; yyleng = 0; diff --git a/tests/prefix_r.l b/tests/prefix_r.l index 384e74e..c7f9746 100644 --- a/tests/prefix_r.l +++ b/tests/prefix_r.l @@ -43,14 +43,14 @@ /* Compile, but do not execute the following code. */ if( 0 ) { FOO_create_buffer( (FILE*)0, 0, yyscanner); - FOO_delete_buffer( (YY_BUFFER_STATE)0, yyscanner); - FOO_flush_buffer( (YY_BUFFER_STATE)0, yyscanner); - FOO_init_buffer( (YY_BUFFER_STATE)0, (FILE*)0, yyscanner); + FOO_delete_buffer( (yybuffer)0, yyscanner); + FOO_flush_buffer( (yybuffer)0, yyscanner); + FOO_init_buffer( (yybuffer)0, (FILE*)0, yyscanner); FOO_load_buffer_state( yyscanner); FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner); FOO_scan_bytes( (const char*)0, 0, yyscanner); FOO_scan_string( (const char*)0, yyscanner); - FOO_switch_to_buffer( (YY_BUFFER_STATE)0, yyscanner); + FOO_switch_to_buffer( (yybuffer)0, yyscanner); FOOrestart( (FILE*)0, (yyscan_t )0); FOOget_extra( (yyscan_t )0 ); diff --git a/tests/string_c99.l b/tests/string_c99.l index 2cf7eae..d8eabfc 100644 --- a/tests/string_c99.l +++ b/tests/string_c99.l @@ -64,7 +64,7 @@ main (void) { char * buf; size_t len; - YY_BUFFER_STATE state; + yybuffer state; yyscan_t scanner=NULL; diff --git a/tests/string_nr.l b/tests/string_nr.l index 8352b09..fdeffbf 100644 --- a/tests/string_nr.l +++ b/tests/string_nr.l @@ -63,8 +63,7 @@ main (void) { char * buf; size_t len; - YY_BUFFER_STATE state; - + yybuffer state; /* Scan a good string. */ printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout); diff --git a/tests/string_r.l b/tests/string_r.l index 174eb6c..6770386 100644 --- a/tests/string_r.l +++ b/tests/string_r.l @@ -63,7 +63,7 @@ main (void) { char * buf; size_t len; - YY_BUFFER_STATE state; + yybuffer state; yyscan_t scanner=NULL; -- cgit v1.2.1 From 4a4cd247ca6c1b92f450cb3fe71bca6dbc69e20b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 25 Oct 2020 22:34:23 -0400 Subject: Polish documentation and fix up some uses of the old interface. --- doc/flex.texi | 5 ++++- src/c99-flex.skl | 42 +++++++++++++++++++----------------------- src/cpp-flex.skl | 14 +++++++------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index c134784..5c244a4 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8757,7 +8757,7 @@ The quoting is ``[[`` and ``]]'' so we don't interfere with user code. A line beginning with ``%#'' is a comment. These comments are omitted from the generated scanner. -A line beginning with ``%%'' us stop-point, where code is inserted by +A line beginning with ``%%'' is a stop-point, where code is inserted by Flex. Each stop-point is numbered here and also in the code generator. Stop points will be inserted into the generated scanner as a comment. This is to aid those who edit skeletons. @@ -8972,6 +8972,9 @@ YY_NEW_FILE: In previous versions of @code{flex}, when assigning call the special action @code{YY_NEW_FILE}. This is no longer necessary. +@item +FLEX_SCANNER: Not neaningful outside of the C back end, and not defined. + @end itemize @node Indices, , Appendices, Top diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 2f2bc2c..f8484ca 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1,7 +1,15 @@ %# -*-C-*- vi: set ft=c: %# -%# All generated macros for the m4 stage contain the text "m4" or "M4" -%# in them. This is to distinguish them from CPP macros. +%# This is the C99 front end. While it can be used as a production +%# skeleton for generating C tokenizers it is actually intended +%# as a porting base that can be cloned and translated into non-C +%# languages. Accordingly it cuts use of the C preprocessor to +%# the bare minimum needed to keep it working in C. +%# +%# Note that using m4 rather than C for macro definitions means they +%# will be recognized and expended in user actions but not +%# in user code sections. Anything you need to be visible there +%# needs to be declared as a function. %# %# The m4 macros complicate reading this code enough that being %# prescriptive about whitespace and braces is more than usually @@ -168,9 +176,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , m4preproc_include(`flexint_shared.h') -/* TODO: this is always defined, so inline it */ -#define yyconst const - #if defined(__GNUC__) && __GNUC__ >= 3 #define yynoreturn __attribute__((__noreturn__)) #else @@ -209,25 +214,16 @@ m4_define( [[M4_YY_INCR_LINENO]], }while(0) ]]) -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ +/* Enter a start condition. */ #define yybegin(s) yyg->yy_start = 1 + 2 * (s) -/* Legacy interface */ -#define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define yystart() ((yyg->yy_start - 1) / 2) -/* Legacy interfaces */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin, yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -1457,7 +1453,7 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ } else if ( yy_act == YY_NUM_RULES + 1 ) { fprintf( stderr, "--(end of buffer or a NUL)\n" ); } else { - fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + fprintf( stderr, "--EOF (start condition %d)\n", yystart() ); } } ]]) @@ -1579,11 +1575,11 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ */ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - yy_act = YY_STATE_EOF(YY_START); + yy_act = YY_STATE_EOF(yystart()); goto do_action; } else { if ( ! yyg->yy_did_buffer_switch_on_eof ) { - YY_NEW_FILE; + yyrestart( yyin, yyscanner ); } } break; @@ -1959,7 +1955,7 @@ int yyinput (yyscan_t yyscanner) return 0; } if ( ! yyg->yy_did_buffer_switch_on_eof ) { - YY_NEW_FILE; + yyrestart( yyin, yyscanner ); } return yyinput(yyscanner); @@ -2398,9 +2394,9 @@ static void yy_push_state(int _new_state, yyscan_t yyscanner) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } } - yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; + yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = yystart(); - BEGIN(_new_state); + yybegin(_new_state); } ]]) @@ -2413,7 +2409,7 @@ static void yy_pop_state (yyscan_t yyscanner) if ( --yyg->yy_start_stack_ptr < 0 ) { YY_FATAL_ERROR( "start-condition stack underflow" ); } - BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); + yybegin(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); } ]]) @@ -2423,7 +2419,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, static int yy_top_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yy_start_stack_ptr > 0 ? yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1] : YY_START; + return yyg->yy_start_stack_ptr > 0 ? yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1] : yystart(); } ]]) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 6f4cf60..75ff83e 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -2089,10 +2089,10 @@ m4_ifdef([[M4_MODE_C_ONLY]], [[ ]]) } else { m4_ifdef([[M4_MODE_CXX_ONLY]], [[ - std::cerr << "--EOF (start condition " << YY_START << ")\n"; + std::cerr << "--EOF (start condition " << yystart() << ")\n"; ]]) m4_ifdef([[M4_MODE_C_ONLY]], [[ - fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + fprintf( stderr, "--EOF (start condition %d)\n", yystart() ); ]]) } } @@ -2220,7 +2220,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ */ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; - yy_act = YY_STATE_EOF(YY_START); + yy_act = YY_STATE_EOF(yystart()); goto do_action; } else { if ( ! YY_G(yy_did_buffer_switch_on_eof) ) { @@ -3311,9 +3311,9 @@ void yyFlexLexer::yy_push_state( int _new_state ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } } - YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; + YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = yystart(); - BEGIN(_new_state); + yybegin(_new_state); } ]]) @@ -3331,7 +3331,7 @@ void yyFlexLexer::yy_pop_state() if ( --YY_G(yy_start_stack_ptr) < 0 ) { YY_FATAL_ERROR( "start-condition stack underflow" ); } - BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); + yybegin(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); } ]]) @@ -3346,7 +3346,7 @@ int yyFlexLexer::yy_top_state() ]]) { M4_YY_DECL_GUTS_VAR(); - return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; + return YY_G(yy_start_stack_ptr) > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : yystart(); } ]]) -- cgit v1.2.1 From 18b3523680d1e977950895a6bb7296cd3757397b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 07:59:36 -0400 Subject: Strip legacy macro definitions out of C99. This is both a step towards Go/Rust and a demonstration that all the ruleset-based tests run wtout them. --- src/c99-flex.skl | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index f8484ca..318d749 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -246,8 +246,6 @@ m4_define( [[M4_YY_INCR_LINENO]], #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *yybuffer; -/* Legacy interface */ -typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif #ifndef YY_TYPEDEF_YY_SIZE_T @@ -304,8 +302,6 @@ typedef size_t yy_size_t; } \ while ( 0 ) #define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) -/* Legacy interface */ -#define unput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE @@ -382,8 +378,6 @@ struct yy_buffer_state /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ -/* Legacy interface */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] void yyrestart ( FILE *input_file, yyscan_t yyscanner ); void yy_switch_to_buffer ( yybuffer new_buffer, yyscan_t yyscanner ); @@ -397,8 +391,6 @@ static void yyensure_buffer_stack ( yyscan_t yyscanner ); static void yy_load_buffer_state ( yyscan_t yyscanner ); static void yy_init_buffer ( yybuffer b, FILE *file, yyscan_t yyscanner ); #define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) -/* Legacy interface */ -#define YY_FLUSH_BUFFER yy_flush_current_buffer() yybuffer yy_scan_buffer ( char *base, yy_size_t size, yyscan_t yyscanner ); yybuffer yy_scan_string ( const char *yy_str, yyscan_t yyscanner ); @@ -427,8 +419,6 @@ void yyfree ( void *, yyscan_t yyscanner ); yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = at_bol; \ } #define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) -/* Legacy interface */ -#define YY_AT_BOL() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) /* Begin user sect3 */ @@ -967,8 +957,6 @@ static int yy_flex_strlen ( const char *, yyscan_t yyscanner); #ifndef YY_NO_YYINPUT static int yyinput ( yyscan_t yyscanner ); -// Legacy interface -#define input yyinput #endif -- cgit v1.2.1 From c0504115662b1d1c09add43de135689e54173a88 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 08:07:06 -0400 Subject: In C99, strip out ccp #ifndefs that can't fire if not using cpp. --- src/c99-flex.skl | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 318d749..ff3e8e0 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -191,10 +191,7 @@ m4preproc_include(`flexint_shared.h') #define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; -#endif /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ @@ -243,15 +240,9 @@ m4_define( [[M4_YY_INCR_LINENO]], */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *yybuffer; -#endif -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; -#endif #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 @@ -303,8 +294,6 @@ typedef size_t yy_size_t; while ( 0 ) #define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; @@ -363,7 +352,6 @@ struct yy_buffer_state */ #define YY_BUFFER_EOF_PENDING 2 }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -1012,8 +1000,6 @@ static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { #define YY_FATAL_ERROR(msg) yy_fatal_error( msg, yyscanner) #endif -/* Legacy interface */ -#ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size, yyscanner);} while (0) m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ @@ -1063,7 +1049,6 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ ]]) return result; } -#endif ]]) /* No semi-colon after return; correct usage is to write "yyterminate();" - -- cgit v1.2.1 From 9bfc5ce27d86f7c416aa2f9eadc7ca04d4edf868 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 09:56:18 -0400 Subject: In C99, remove most code dependencies on yyin/yyout/yyleng/yytext macros. These served a purpose when the code had to handle both reentrant and non-reentrant cases. Now, while they should still be available in user actions, the generated code is much less confusing if the yyg pointer in the references is explicit. Also, drop VMS support and consolidate platform-specific references at one spot. This is in the same commit with the macro cleanup because it included getting rid of the last stray yyin/yyout references. --- src/c99-flex.skl | 180 ++++++++++++++++++++++++++----------------------------- 1 file changed, 86 insertions(+), 94 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index ff3e8e0..e30065c 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -149,7 +149,7 @@ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`free') ) -/* First, we deal with platform-specific or compiler-specific issues. */ +/* START platform-specific and compiler-specific definitions. */ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , [[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , @@ -182,6 +182,37 @@ m4preproc_include(`flexint_shared.h') #define yynoreturn #endif +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* + * Anywhere other than C this won't be a thing, + * because strings will have an assiciated length field. + */ +#define YY_END_OF_BUFFER_CHAR 0 + +/* END platform-specific and compiler-specific definitions. */ + /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -220,21 +251,6 @@ m4_define( [[M4_YY_INCR_LINENO]], #define yystart() ((yyg->yy_start - 1) / 2) /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif /* The state buf must be large enough to hold one state per character in the main buffer. */ @@ -259,8 +275,8 @@ typedef size_t yy_size_t; #define YY_LESS_LINENO(n) \ do { \ int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl ) { \ - if ( yytext[yyl] == '\n' ) { \ + for ( yyl = n; yyl < yyg->yyleng_r; ++yyl ) { \ + if ( yyg->yytext_r[yyl] == '\n' ) { \ --yylineno;\ } \ } \ @@ -393,7 +409,7 @@ void yyfree ( void *, yyscan_t yyscanner ); if ( yy_current_buffer() == NULL ) { \ yyensure_buffer_stack (yyscanner); \ yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ - yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); \ + yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ } \ yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } @@ -402,7 +418,7 @@ void yyfree ( void *, yyscan_t yyscanner ); if ( yy_current_buffer() == NULL ) { \ yyensure_buffer_stack (yyscanner); \ yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ - yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); \ + yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ } \ yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = at_bol; \ } @@ -418,21 +434,7 @@ m4_ifdef( [[M4_MODE_DEBUG]], [[ #define FLEX_DEBUG ]]) typedef flex_uint8_t YY_CHAR; -m4_define([[M4_TMP_STDINIT]], [[FILE *yyin = stdin, *yyout = stdout;]]) -m4_define([[M4_TMP_NO_STDINIT]], [[FILE *yyin = NULL, *yyout = NULL;]]) -m4_ifdef( [[M4_MODE_DO_STDINIT]], [[m4_dnl -#ifdef VMS"); -#ifndef __VMS_POSIX -M4_TMP_NO_STDINIT -#else -M4_TMP_STDINIT -#endif -#else -M4_TMP_STDINIT -#endif -]]) -m4_undefine([[M4_TMP_STDINIT]]) -m4_undefine([[M4_TMP_NO_STDINIT]]) + m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl typedef const struct yy_trans_info *yy_state_type; ]], [[ @@ -447,7 +449,7 @@ m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ #define yytext_ptr yytext_r ]]) -%% [1.5] DFA +%% [1.0] DFA static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); @@ -485,21 +487,21 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; - yyleng = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ + yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyleng + yyg->yy_more_offset >= YYLMAX ) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyg->yyleng_r + yyg->yy_more_offset >= YYLMAX ) \ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyleng >= YYLMAX ) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyg->yyleng_r >= YYLMAX ) \ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yytext[yyg->yy_more_offset], yyg->yytext_ptr, yyleng + 1, yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyleng += yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyg->yytext_r[yyg->yy_more_offset], yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yyleng_r += yyg->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyg->yytext_r, yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ ]]) \ yyg->yy_c_buf_p = yy_cp; @@ -691,13 +693,13 @@ m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyg->yy_more_offset = yy_flex_strlen( yytext, yyscanner)) +#define yymore() (yyg->yy_more_offset = yy_flex_strlen( yyg->yytext_r, yyscanner)) #define YY_NEED_STRLEN #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET \ { \ yyg->yy_more_offset = yyg->yy_prev_more_offset; \ -yyleng -= yyg->yy_more_offset; \ +yyg->yyleng_r -= yyg->yy_more_offset; \ } ]]) m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ @@ -969,20 +971,10 @@ m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - /* This used to be an fputs(), but since the string might contain NULs, * we now use fwrite(). */ -#define yyecho() do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#define yyecho() do { if (fwrite( yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r )) {} } while (0) #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 @@ -1011,13 +1003,13 @@ static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) { + while ( (result = (int) read( fileno(yyg->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { if( errno != EINTR) { YY_FATAL_ERROR( "input in flex scanner failed" ); break; } errno=0; - clearerr(yyin); + clearerr(yyg->yyin_r); } ]]) m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ @@ -1025,25 +1017,25 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ int c = '*'; int n; for ( n = 0; n < max_size && - (c = getc( yyin )) != EOF && c != '\n'; ++n ) { + (c = getc( yyg->yyin_r )) != EOF && c != '\n'; ++n ) { buf[n] = (char) c; } if ( c == '\n' ) { buf[n++] = (char) c; } - if ( c == EOF && ferror( yyin ) ) { + if ( c == EOF && ferror( yyg->yyin_r ) ) { YY_FATAL_ERROR( "input in flex scanner failed" ); } result = n; } else { errno=0; - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) { + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyg->yyin_r)) == 0 && ferror(yyg->yyin_r)) { if( errno != EINTR) { YY_FATAL_ERROR( "input in flex scanner failed" ); break; } errno=0; - clearerr(yyin); + clearerr(yyg->yyin_r); } } ]]) @@ -1111,8 +1103,8 @@ extern int yylex M4_YY_LEX_PROTO; #endif #define YY_RULE_SETUP \ - m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) { \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ + m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyg->yyleng_r > 0 ) { \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = (yyg->yytext_r[yyg->yyleng_r - 1] == '\n'); \ } \ ]]) YY_USER_ACTION @@ -1245,16 +1237,16 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], if ( ! yyg->yy_start ) { yyg->yy_start = 1; /* first start state */ } - if ( ! yyin ) { - yyin = stdin; + if ( ! yyg->yyin_r ) { + yyg->yyin_r = stdin; } - if ( ! yyout ) { - yyout = stdout; + if ( ! yyg->yyout_r ) { + yyg->yyout_r = stdout; } if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (yyscanner); yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = - yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); + yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); } yy_load_buffer_state( yyscanner ); @@ -1402,8 +1394,8 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [["yyg->yy_prev_more_offset"]], [["yyg->yy_more_len"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; - for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) { - if ( yytext[yyl] == '\n' ) { + for ( yyl = M4_YYL_BASE; yyl < yyg->yyleng_r; ++yyl ) { + if ( yyg->yytext_r[yyl] == '\n' ) { M4_YY_INCR_LINENO(); } @@ -1419,10 +1411,10 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ fprintf( stderr, "--scanner backing up\n" ); } else if ( yy_act < YY_NUM_RULES ) { fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yytext ); + (long)yy_rule_linenum[yy_act], yyg->yytext_r ); } else if ( yy_act == YY_NUM_RULES ) { fprintf( stderr, "--accepting default rule (\"%s\")\n", - yytext ); + yyg->yytext_r ); } else if ( yy_act == YY_NUM_RULES + 1 ) { fprintf( stderr, "--(end of buffer or a NUL)\n" ); } else { @@ -1470,7 +1462,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * back-up) that will match for the new input source. */ yyg->yy_n_chars = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file = yyin; + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file = yyg->yyin_r; yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -1552,7 +1544,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ goto do_action; } else { if ( ! yyg->yy_did_buffer_switch_on_eof ) { - yyrestart( yyin, yyscanner ); + yyrestart( yyg->yyin_r, yyscanner ); } } break; @@ -1689,7 +1681,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin, yyscanner); + yyrestart( yyg->yyin_r, yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status = @@ -1919,7 +1911,7 @@ int yyinput (yyscan_t yyscanner) */ /* Reset buffer status. */ - yyrestart( yyin, yyscanner); + yyrestart( yyg->yyin_r, yyscanner); /*FALLTHROUGH*/ @@ -1928,7 +1920,7 @@ int yyinput (yyscan_t yyscanner) return 0; } if ( ! yyg->yy_did_buffer_switch_on_eof ) { - yyrestart( yyin, yyscanner ); + yyrestart( yyg->yyin_r, yyscanner ); } return yyinput(yyscanner); @@ -1974,7 +1966,7 @@ void yyrestart(FILE * input_file, yyscan_t yyscanner) if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (yyscanner); yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = - yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner); + yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); } yy_init_buffer( yy_current_buffer(), input_file, yyscanner); @@ -2022,7 +2014,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars; yyg->yytext_ptr = yyg->yy_c_buf_p = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos; - yyin = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file; + yyg->yyin_r = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file; yyg->yy_hold_char = *yyg->yy_c_buf_p; } @@ -2404,11 +2396,11 @@ static int yy_top_state (yyscan_t yyscanner) /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yytext_r[yyg->yyleng_r] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yyg->yytext_r + yyless_macro_arg; \ yyg->yy_hold_char = *yyg->yy_c_buf_p; \ *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ + yyg->yyleng_r = yyless_macro_arg; \ } while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ @@ -2460,7 +2452,7 @@ m4_ifdef( [[M4_YY_NO_GET_IN]],, */ FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; + return yyg->yyin_r; } ]]) @@ -2471,7 +2463,7 @@ m4_ifdef( [[M4_YY_NO_GET_OUT]],, */ FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; + return yyg->yyout_r; } ]]) @@ -2482,7 +2474,7 @@ m4_ifdef( [[M4_YY_NO_GET_LENG]],, */ int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; + return yyg->yyleng_r; } ]]) @@ -2493,7 +2485,7 @@ m4_ifdef( [[M4_YY_NO_GET_TEXT]],, [[ char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; + return yyg->yytext_r; } ]]) @@ -2553,7 +2545,7 @@ m4_ifdef( [[M4_YY_NO_SET_IN]],, */ void yyset_in(FILE * _in_str, yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; + yyg->yyin_r = _in_str ; } ]]) @@ -2561,7 +2553,7 @@ m4_ifdef( [[M4_YY_NO_SET_OUT]],, [[ void yyset_out( FILE * _out_str, yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; + yyg->yyout_r = _out_str ; } ]]) @@ -2710,11 +2702,11 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], /* Defined in main.c */ #ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; + yyg->yyin_r = stdin; + yyg->yyout_r = stdout; #else - yyin = NULL; - yyout = NULL; + yyg->yyin_r = NULL; + yyg->yyout_r = NULL; #endif /* For future reference: Set errno on error, since we are called by -- cgit v1.2.1 From e8de043be28e797b49ce86aead6db6dc79f5742d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 10:19:01 -0400 Subject: In C99, group macros for use in user actions... ..and move the group as late in the generated code as we can. There's no reason for those to be in scope when tables are being generated. --- src/c99-flex.skl | 368 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 185 insertions(+), 183 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index e30065c..88c4188 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -224,31 +224,6 @@ m4preproc_include(`flexint_shared.h') /* An opaque pointer. */ typedef void* yyscan_t; -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_lineno) -#define yycolumn (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -m4_define( [[M4_YY_INCR_LINENO]], -[[ - do{ yylineno++; - yycolumn=0; - }while(0) -]]) - -/* Enter a start condition. */ -#define yybegin(s) yyg->yy_start = 1 + 2 * (s) -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define yystart() ((yyg->yy_start - 1) / 2) /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) @@ -263,52 +238,6 @@ typedef size_t yy_size_t; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - m4_ifdef( [[M4_MODE_YYLINENO]], - [[ - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyg->yyleng_r; ++yyl ) { \ - if ( yyg->yytext_r[yyl] == '\n' ) { \ - --yylineno;\ - } \ - } \ - }while(0) - #define YY_LINENO_REWIND_TO(dst) \ - do {\ - const char *p;\ - for ( p = yy_cp-1; p >= (dst); --p) { \ - if ( *p == '\n' ) { \ - --yylineno;\ - } \ - } \ - }while(0) - ]], - [[ - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - ]]) -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) struct yy_buffer_state { @@ -369,20 +298,6 @@ struct yy_buffer_state #define YY_BUFFER_EOF_PENDING 2 }; -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define yy_current_buffer() ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -#define YY_CURRENT_BUFFER yy_current_buffer() -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ - void yyrestart ( FILE *input_file, yyscan_t yyscanner ); void yy_switch_to_buffer ( yybuffer new_buffer, yyscan_t yyscanner ); yybuffer yy_create_buffer ( FILE *file, int size, yyscan_t yyscanner ); @@ -394,7 +309,6 @@ void yypop_buffer_state ( yyscan_t yyscanner ); static void yyensure_buffer_stack ( yyscan_t yyscanner ); static void yy_load_buffer_state ( yyscan_t yyscanner ); static void yy_init_buffer ( yybuffer b, FILE *file, yyscan_t yyscanner ); -#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) yybuffer yy_scan_buffer ( char *base, yy_size_t size, yyscan_t yyscanner ); yybuffer yy_scan_string ( const char *yy_str, yyscan_t yyscanner ); @@ -404,26 +318,6 @@ void *yyalloc ( yy_size_t, yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); void yyfree ( void *, yyscan_t yyscanner ); -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) { \ - if ( yy_current_buffer() == NULL ) { \ - yyensure_buffer_stack (yyscanner); \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ - yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ - } \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ -} -#define yy_set_bol(at_bol) \ - { \ - if ( yy_current_buffer() == NULL ) { \ - yyensure_buffer_stack (yyscanner); \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ - yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ - } \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = at_bol; \ -} -#define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) - /* Begin user sect3 */ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ @@ -481,32 +375,9 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ ]]) }; -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; - yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ -m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyg->yyleng_r + yyg->yy_more_offset >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyg->yyleng_r >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyg->yytext_r[yyg->yy_more_offset], yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yyleng_r += yyg->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyg->yytext_r, yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ -]]) \ - yyg->yy_c_buf_p = yy_cp; - %% [2.0] data tables for the DFA are inserted here -m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl + + m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { @@ -668,53 +539,6 @@ static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; ]]) -m4_ifdef( [[M4_MODE_USES_REJECT]],[[ -#define yyreject() \ -{ \ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ -yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ -yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ -]]) \ -++yyg->yy_lp; \ -goto find_rule; \ -} -#define REJECT yyreject() -]]) -m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ -/* The intent behind this definition is that it'll catch - * any uses of yyreject() which flex missed. - */ -#define yyreject() reject_used_but_not_detected -#define REJECT reject_used_but_not_detected -]]) - -m4_ifdef([[M4_MODE_YYMORE_USED]], [[ -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyg->yy_more_offset = yy_flex_strlen( yyg->yytext_r, yyscanner)) -#define YY_NEED_STRLEN -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET \ -{ \ -yyg->yy_more_offset = yyg->yy_prev_more_offset; \ -yyg->yyleng_r -= yyg->yy_more_offset; \ -} -]]) -m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyg->yy_more_flag = 1) -#define YY_MORE_ADJ yyg->yy_more_len -#define YY_RESTORE_YY_MORE_OFFSET -]]) -]]) - -m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -]]) - m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #ifndef YYLMAX #define YYLMAX 8192 @@ -971,11 +795,6 @@ m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -/* This used to be an fputs(), but since the string might contain NULs, - * we now use fwrite(). - */ -#define yyecho() do { if (fwrite( yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r )) {} } while (0) - #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif @@ -1108,6 +927,189 @@ extern int yylex M4_YY_LEX_PROTO; } \ ]]) YY_USER_ACTION +/* START access macros for use in actions */ + +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_lineno) +#define yycolumn (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +m4_define( [[M4_YY_INCR_LINENO]], +[[ + do{ yylineno++; + yycolumn=0; + }while(0) +]]) + +/* Enter a start condition. */ +#define yybegin(s) yyg->yy_start = 1 + 2 * (s) +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define yystart() ((yyg->yy_start - 1) / 2) + +m4_ifdef( [[M4_MODE_YYLINENO]], [[ +/* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ +#define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyg->yyleng_r; ++yyl ) { \ + if ( yyg->yytext_r[yyl] == '\n' ) { \ + --yylineno;\ + } \ + } \ + }while(0) +#define YY_LINENO_REWIND_TO(dst) \ + do {\ + const char *p;\ + for ( p = yy_cp-1; p >= (dst); --p) { \ + if ( *p == '\n' ) { \ + --yylineno;\ + } \ + } \ + }while(0) +]], +[[ +#define YY_LESS_LINENO(n) +#define YY_LINENO_REWIND_TO(ptr) +]]) +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define yy_current_buffer() ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +#define YY_CURRENT_BUFFER yy_current_buffer() + +#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) { \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (yyscanner); \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ + yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ + } \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ +} +#define yy_set_bol(at_bol) \ + { \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (yyscanner); \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ + yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ + } \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = at_bol; \ +} +#define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; + yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyg->yyleng_r + yyg->yy_more_offset >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyg->yyleng_r >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyg->yytext_r[yyg->yy_more_offset], yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yyleng_r += yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyg->yytext_r, yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ +]]) \ + yyg->yy_c_buf_p = yy_cp; + +m4_ifdef( [[M4_MODE_USES_REJECT]],[[ +#define yyreject() \ +{ \ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ +yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ +yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ +]]) \ +++yyg->yy_lp; \ +goto find_rule; \ +} +#define REJECT yyreject() +]]) +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +/* The intent behind this definition is that it'll catch + * any uses of yyreject() which flex missed. + */ +#define yyreject() reject_used_but_not_detected +#define REJECT reject_used_but_not_detected +]]) + +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +#define yymore() (yyg->yy_more_offset = yy_flex_strlen( yyg->yytext_r, yyscanner)) +#define YY_NEED_STRLEN +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET \ +{ \ +yyg->yy_more_offset = yyg->yy_prev_more_offset; \ +yyg->yyleng_r -= yyg->yy_more_offset; \ +} +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +#define yymore() (yyg->yy_more_flag = 1) +#define YY_MORE_ADJ yyg->yy_more_len +#define YY_RESTORE_YY_MORE_OFFSET +]]) +]]) + +m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +]]) + +/* This used to be an fputs(), but since the string might contain NULs, + * we now use fwrite(). + */ +#define yyecho() do { if (fwrite( yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r )) {} } while (0) + +/* END access macros for use in actions */ + %# Code snippets used in various cases of code generation in the main scanner. m4_define([[M4_GEN_BACKING_UP]], [[ -- cgit v1.2.1 From ffcdee1fa2dae5d86082e199b17c85e09ab52630 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 13:11:10 -0400 Subject: In C99, use bools where it is semantically reasonable. Also, abandon the old-fashioned practice of using ! as a NULL test on pointer-valued expressions. --- src/c99-flex.skl | 60 +++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 88c4188..66095d0 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -173,6 +173,7 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #include #include #include +#include m4preproc_include(`flexint_shared.h') @@ -272,7 +273,7 @@ struct yy_buffer_state * If so, '^' rules will be active on the next match, otherwise * not. */ - int yy_at_bol; + bool yy_at_bol_flag; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ @@ -586,9 +587,9 @@ struct yyguts_t { int yy_n_chars; int yyleng_r; char *yy_c_buf_p; - int yy_init; + bool yy_init; int yy_start; - int yy_did_buffer_switch_on_eof; + bool yy_did_buffer_switch_on_eof; int yy_start_stack_ptr; int yy_start_stack_depth; int *yy_start_stack; @@ -617,7 +618,7 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ int yy_prev_more_offset; ]], [[ char *yytext_r; - int yy_more_flag; + bool yy_more_flag; int yy_more_len; ]]) m4_ifdef( [[M4_YY_BISON_LVAL]], [[ @@ -923,7 +924,7 @@ extern int yylex M4_YY_LEX_PROTO; #define YY_RULE_SETUP \ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyg->yyleng_r > 0 ) { \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = (yyg->yytext_r[yyg->yyleng_r - 1] == '\n'); \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = (yyg->yytext_r[yyg->yyleng_r - 1] == '\n'); \ } \ ]]) YY_USER_ACTION @@ -1008,11 +1009,9 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ #define yy_current_buffer() ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) -#define YY_CURRENT_BUFFER yy_current_buffer() #define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) -#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) { \ if ( yy_current_buffer() == NULL ) { \ yyensure_buffer_stack (yyscanner); \ @@ -1028,9 +1027,9 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ } \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = at_bol; \ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = at_bol; \ } -#define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol) +#define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag) /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -1076,7 +1075,6 @@ m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ * any uses of yyreject() which flex missed. */ #define yyreject() reject_used_but_not_detected -#define REJECT reject_used_but_not_detected ]]) m4_ifdef([[M4_MODE_YYMORE_USED]], [[ @@ -1091,7 +1089,7 @@ yyg->yyleng_r -= yyg->yy_more_offset; \ } ]]) m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyg->yy_more_flag = 1) +#define yymore() (yyg->yy_more_flag = true) #define YY_MORE_ADJ yyg->yy_more_len #define YY_RESTORE_YY_MORE_OFFSET ]]) @@ -1106,7 +1104,7 @@ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ /* This used to be an fputs(), but since the string might contain NULs, * we now use fwrite(). */ -#define yyecho() do { if (fwrite( yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r )) {} } while (0) +#define yyecho() fwrite(yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r) /* END access macros for use in actions */ @@ -1219,7 +1217,7 @@ m4_ifdef( [[]], ]]) if ( !yyg->yy_init ) { - yyg->yy_init = 1; + yyg->yy_init = true; #ifdef YY_USER_INIT YY_USER_INIT; @@ -1228,21 +1226,21 @@ m4_ifdef( [[]], m4_ifdef( [[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! yyg->yy_state_buf ) { + if ( yyg->yy_state_buf == NULL ) { yyg->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } - if ( ! yyg->yy_state_buf ) { + if ( yyg->yy_state_buf == NULL) { YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); } ]]) - if ( ! yyg->yy_start ) { + if ( yyg->yy_start == 0 ) { yyg->yy_start = 1; /* first start state */ } - if ( ! yyg->yyin_r ) { + if ( yyg->yyin_r == NULL ) { yyg->yyin_r = stdin; } - if ( ! yyg->yyout_r ) { + if ( yyg->yyout_r == NULL ) { yyg->yyout_r = stdout; } if ( yy_current_buffer() == NULL ) { @@ -1264,7 +1262,7 @@ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ yyg->yy_more_len = 0; if ( yyg->yy_more_flag ) { yyg->yy_more_len = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - yyg->yy_more_flag = 0; + yyg->yy_more_flag = false; } ]]) ]]) @@ -1528,7 +1526,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } else { /* not a NUL */ switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: - yyg->yy_did_buffer_switch_on_eof = 0; + yyg->yy_did_buffer_switch_on_eof = false; if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in @@ -1659,7 +1657,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], /* Can't grow it, we don't own it. */ b->yy_ch_buf = NULL; } - if ( ! b->yy_ch_buf ) { + if ( b->yy_ch_buf == NULL ) { YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); } @@ -1697,7 +1695,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( (void *) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( ! yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf ) { + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf == NULL ) { YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } /* "- 2" to take care of EOB's */ @@ -1938,7 +1936,7 @@ int yyinput (yyscan_t yyscanner) yyg->yy_hold_char = *++yyg->yy_c_buf_p; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol = (c == '\n'); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol ) { M4_YY_INCR_LINENO(); @@ -2007,7 +2005,7 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - yyg->yy_did_buffer_switch_on_eof = 1; + yyg->yy_did_buffer_switch_on_eof = true; } @@ -2132,7 +2130,7 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; + b->yy_at_bol_flag = true; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer() ) { @@ -2170,7 +2168,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; + yyg->yy_did_buffer_switch_on_eof = true; } @@ -2191,7 +2189,7 @@ void yypop_buffer_state (yyscan_t yyscanner) } if (yy_current_buffer() != NULL) { yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; + yyg->yy_did_buffer_switch_on_eof = true; } } @@ -2270,7 +2268,7 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; - b->yy_at_bol = 1; + b->yy_at_bol_flag = true; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; @@ -2350,14 +2348,14 @@ static void yy_push_state(int _new_state, yyscan_t yyscanner) yyg->yy_start_stack_depth += YY_START_STACK_INCR; new_size = (yy_size_t) yyg->yy_start_stack_depth * sizeof( int ); - if ( ! yyg->yy_start_stack ) { + if ( yyg->yy_start_stack == NULL ) { yyg->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); } else { yyg->yy_start_stack = (int *) yyrealloc( (void *) yyg->yy_start_stack, new_size, yyscanner ); } - if ( ! yyg->yy_start_stack ) { + if ( yyg->yy_start_stack == NULL ) { YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } } @@ -2681,7 +2679,7 @@ static int yy_init_globals (yyscan_t yyscanner) { yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_max = 0; yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; + yyg->yy_init = false; yyg->yy_start = 0; yyg->yy_start_stack_ptr = 0; yyg->yy_start_stack_depth = 0; -- cgit v1.2.1 From baafce5c719cabfa63cb1cdd5e94ee02de1e3edf Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 15:45:23 -0400 Subject: In C99, factor a nasty hunk of macrology into a function. --- src/c99-flex.skl | 57 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 66095d0..e7e24b4 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -928,6 +928,31 @@ extern int yylex M4_YY_LEX_PROTO; } \ ]]) YY_USER_ACTION +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ + void yy_do_before_action(struct yyguts_t *yyg, char *yy_cp, char *yy_bp) { + yyg->yytext_ptr = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; + yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyg->yyleng_r + yyg->yy_more_offset >= YYLMAX ) \ + yy_fatal_error( "token too large, exceeds YYLMAX", (yyacan_t)yyg );]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyg->yyleng_r >= YYLMAX ) \ + yy_fatal_error( "token too large, exceeds YYLMAX", (yyscan_t)yyg);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyg->yytext_r[yyg->yy_more_offset], yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yyleng_r += yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyg->yytext_r, yyg->yytext_ptr, yyg->yyleng_r + 1, (yyscan_t)yyg);]]) \ +]]) \ + yyg->yy_c_buf_p = yy_cp; +} + /* START access macros for use in actions */ #define yyin yyg->yyin_r @@ -995,7 +1020,7 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + yy_do_before_action(yyg, yy_cp, yy_bp); /* set up yytext again */ \ } \ while ( 0 ) #define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) @@ -1031,30 +1056,6 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ } #define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag) -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; - yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ -m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyg->yyleng_r + yyg->yy_more_offset >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyg->yyleng_r >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" );]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyg->yytext_r[yyg->yy_more_offset], yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yyleng_r += yyg->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyg->yytext_r, yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ -]]) \ - yyg->yy_c_buf_p = yy_cp; - m4_ifdef( [[M4_MODE_USES_REJECT]],[[ #define yyreject() \ { \ @@ -1386,7 +1387,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s } ]]) - YY_DO_BEFORE_ACTION; + yy_do_before_action(yyg, yy_cp, yy_bp); m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], @@ -1427,7 +1428,7 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ + /* undo the effects of yy_do_before_action() */ *yy_cp = yyg->yy_hold_char; /* Backing-up info for compressed tables is taken \after/ */ @@ -1447,7 +1448,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - /* Undo the effects of YY_DO_BEFORE_ACTION. */ + /* Undo the effects of yy_do_before_action(). */ *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET -- cgit v1.2.1 From f5d2d88a6d04333ac4a6655afa0613a36ce4aa2c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 16:22:27 -0400 Subject: Fix C emission lurking previously undiscovered in nfa.c. --- src/c99-flex.skl | 9 +++++++++ src/cpp-flex.skl | 9 +++++++++ src/nfa.c | 28 ++++++++++++---------------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index e7e24b4..33171fa 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -46,10 +46,17 @@ m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) m4_define([[M4_HOOK_RELATIVIZE]], [[$1]]) m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], ]]) +m4_define([[M4_HOOK_NORMAL_STATE_CASE_ARM]], [[ case $1:]]) m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) +m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyg, cp, bp); /* set up yytext */]]) +m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */]]) +m4_define([[M4_HOOK_CHAR_REWIND]], [[YY_G(yy_c_buf_p) = yy_cp -= $1;]]) +m4_define([[M4_HOOK_LINE_REWIND]], [[YY_LINENO_REWIND_TO(yy_cp - $1);]]) +m4_define([[M4_HOOK_CHAR_FORWARD]], [[YY_G(yy_c_buf_p) = yy_cp = yy_bp + $1;]]) +m4_define([[M4_HOOK_LINE_FORWARD]], [[YY_LINENO_REWIND_TO(yy_bp + $1);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; ]]) m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yy_state_type $1 = $2; @@ -66,6 +73,8 @@ m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1 ]]) m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 ]]) +m4_define([[M4_HOOK_SET_RULE_SETUP]], [[YY_RULE_SETUP +]]) m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 ]]) m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 75ff83e..0325984 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -40,10 +40,17 @@ m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) m4_define([[M4_HOOK_RELATIVIZE]], [[$1]]) m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], ]]) +m4_define([[M4_HOOK_NORMAL_STATE_CASE_ARM]], [[ case $1:]]) m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) +m4_define([[M4_HOOK_TAKE_YYTEXT]], [[YY_DO_BEFORE_ACTION; /* set up yytext */]]) +m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */]]) +m4_define([[M4_HOOK_CHAR_REWIND]], [[YY_G(yy_c_buf_p) = yy_cp -= $1;]]) +m4_define([[M4_HOOK_LINE_REWIND]], [[YY_LINENO_REWIND_TO(yy_cp - $1);]]) +m4_define([[M4_HOOK_CHAR_FORWARD]], [[YY_G(yy_c_buf_p) = yy_cp = yy_bp + $1;]]) +m4_define([[M4_HOOK_LINE_FORWARD]], [[YY_LINENO_REWIND_TO(yy_bp + $1);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[#define $1 $2 ]]) m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[#define $1 $2 @@ -60,6 +67,8 @@ m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 ]]) +m4_define([[M4_HOOK_SET_RULE_SETUP]], [[YY_RULE_SETUP +]]) m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 ]]) m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 diff --git a/src/nfa.c b/src/nfa.c index f6e8300..47faecc 100644 --- a/src/nfa.c +++ b/src/nfa.c @@ -216,10 +216,10 @@ void finish_rule (int mach, int variable_trail_rule, int headcnt, int trailcn if (pcont_act && rule_has_nl[num_rules - 1]) rule_has_nl[num_rules] = true; - snprintf (action_text, sizeof(action_text), "case %d:\n", num_rules); + snprintf (action_text, sizeof(action_text), "M4_HOOK_NORMAL_STATE_CASE_ARM(%d)\n", num_rules); add_action (action_text); if (rule_has_nl[num_rules]) { - snprintf (action_text, sizeof(action_text), "/* rule %d can match eol */\n", + snprintf (action_text, sizeof(action_text), "M4_HOOK_COMMENT_OPEN rule %d can match eol M4_HOOK_COMMENT_CLOSE\n", num_rules); add_action (action_text); } @@ -244,47 +244,43 @@ void finish_rule (int mach, int variable_trail_rule, int headcnt, int trailcn /* Do trailing context magic to not match the trailing * characters. */ - char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp"; - char *scanner_bp = "yy_bp"; - - add_action - ("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n"); + add_action ("M4_HOOK_RELEASE_YYTEXT\n"); if (headcnt > 0) { if (rule_has_nl[num_rules]) { snprintf (action_text, sizeof(action_text), - "YY_LINENO_REWIND_TO(%s + %d);\n", scanner_bp, headcnt); + "M4_HOOK_LINE_FORWARD(%d)\n", headcnt); add_action (action_text); } - snprintf (action_text, sizeof(action_text), "%s = %s + %d;\n", - scanner_cp, scanner_bp, headcnt); + snprintf (action_text, sizeof(action_text), "M4_HOOK_CHAR_FORWARD(%d)\n", + headcnt); add_action (action_text); } else { if (rule_has_nl[num_rules]) { snprintf (action_text, sizeof(action_text), - "YY_LINENO_REWIND_TO(yy_cp - %d);\n", trailcnt); + "M4_HOOK_LINE_REWIND(%d)\n", trailcnt); add_action (action_text); } - snprintf (action_text, sizeof(action_text), "%s -= %d;\n", - scanner_cp, trailcnt); + snprintf (action_text, sizeof(action_text), "M4_HOOK_CHAR_REWIND(%d)\n", + trailcnt); add_action (action_text); } add_action - ("YY_DO_BEFORE_ACTION; /* set up yytext again */\n"); + ("M4_HOOK_TAKE_YYTEXT\n"); } } /* Okay, in the action code at this point yytext and yyleng have * their proper final values for this rule, so here's the point * to do any user action. But don't do it for continued actions, - * as that'll result in multiple YY_RULE_SETUP's. + * as that'll result in multiple rule-setup calls. */ if (!continued_action) - add_action ("YY_RULE_SETUP\n"); + add_action ("M4_HOOK_SET_RULE_SETUP\n"); line_directive_out(NULL, infilename, linenum); add_action("[["); -- cgit v1.2.1 From b244d82cf0758daece2f764dd3fdc63cc9dff60f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Oct 2020 23:26:28 -0400 Subject: Remove an ugly little knor in the C99 yyunput code... ..left there from a weird compromise when the default C back end also supported C++. Add a yyunput ruleset testing it on all back ends to verify that the change is good. --- src/c99-flex.skl | 11 +++++------ tests/Makefile.am | 5 ++++- tests/posixlycorrect_c99.l | 2 +- tests/posixlycorrect_nr.l | 4 ++-- tests/ruleset.am | 16 ++++++++++++++-- tests/testmaker.m4 | 8 +++----- tests/yyunput.rules | 34 ++++++++++++++++++++++++++++++++++ tests/yyunput.txt | 1 + 8 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 tests/yyunput.rules create mode 100644 tests/yyunput.txt diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 33171fa..95bf474 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -767,7 +767,7 @@ extern int yywrap ( yyscan_t yyscanner ); #ifndef YY_NO_YYUNPUT m4_ifdef( [[M4_YY_NO_YYUNPUT]],,[[ -static void yyunput_r ( int c, char *buf_ptr , yyscan_t yyscanner); +static void yyunput_r ( int c, yyscan_t yyscanner); ]]) #endif @@ -1032,7 +1032,7 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ yy_do_before_action(yyg, yy_cp, yy_bp); /* set up yytext again */ \ } \ while ( 0 ) -#define yyunput(c) yyunput_r( c, yyg->yytext_ptr, yyscanner ) +#define yyunput(c) yyunput_r( c, yyscanner ) /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -1841,7 +1841,7 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ } m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ -static void yyunput_r( int c, char *yy_bp, yyscan_t yyscanner) +static void yyunput_r( int c, yyscan_t yyscanner) { char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1864,7 +1864,7 @@ static void yyunput_r( int c, char *yy_bp, yyscan_t yyscanner) *--dest = *--source; } yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); + yyg->yytext_ptr += (int) (dest - source); yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars = (int) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size; @@ -1878,11 +1878,10 @@ static void yyunput_r( int c, char *yy_bp, yyscan_t yyscanner) m4_ifdef( [[M4_MODE_YYLINENO]], [[ if ( c == '\n' ){ - --yylineno; + --yylineno; } ]]) - yyg->yytext_ptr = yy_bp; yyg->yy_hold_char = *yy_cp; yyg->yy_c_buf_p = yy_cp; } diff --git a/tests/Makefile.am b/tests/Makefile.am index f4c5752..0643e28 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -245,6 +245,8 @@ CLEANFILES = \ top.h \ yyextra_nr.c \ yyextra_c99.c \ + yyunput_* \ + !yyunput.rules \ $(RULESET_REMOVABLES) dist-hook: @@ -302,9 +304,10 @@ EXTRA_DIST = \ rescan_r.direct.txt \ quote_in_comment.txt \ quotes.txt \ + tableopts.txt \ top.txt \ yyextra.txt \ - tableopts.txt + yyunput.txt dist_noinst_SCRIPTS = \ ruleset.sh diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l index d073c06..4774671 100644 --- a/tests/posixlycorrect_c99.l +++ b/tests/posixlycorrect_c99.l @@ -46,7 +46,7 @@ ab{3} { } \n { } -. {fprintf(stderr,"Invalid line.\n"); exit(-1);} +. {fprintf(stderr,"TEST FAILED.\n"); exit(1);} %% int main (int argc, char **argv) diff --git a/tests/posixlycorrect_nr.l b/tests/posixlycorrect_nr.l index 86cd1a1..2a44dc7 100644 --- a/tests/posixlycorrect_nr.l +++ b/tests/posixlycorrect_nr.l @@ -1,4 +1,5 @@ + %{ #include "config.h" #include @@ -44,8 +45,7 @@ ab{3} { } \n { } -. {fprintf(stderr,"Invalid line.\n"); exit(-1); -} +. {fprintf(stderr,"TEST FAILED.\n"); exit(1);} %% int main (int argc, char **argv) diff --git a/tests/ruleset.am b/tests/ruleset.am index a0906f6..3c292ea 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -49,6 +49,10 @@ tableopts_nr_SOURCES = tableopts_nr.l tableopts_nr.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yyunput_nr_SOURCES = yyunput_nr.l +yyunput_nr.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + tableopts_opt_nr_Ca_opt_SOURCES = tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -225,6 +229,10 @@ tableopts_r_SOURCES = tableopts_r.l tableopts_r.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yyunput_r_SOURCES = yyunput_r.l +yyunput_r.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + tableopts_opt_r_Ca_opt_SOURCES = tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -401,6 +409,10 @@ tableopts_c99_SOURCES = tableopts_c99.l tableopts_c99.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yyunput_c99_SOURCES = yyunput_c99.l +yyunput_c99.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + tableopts_opt_c99_Ca_opt_SOURCES = tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -540,6 +552,6 @@ posixlycorrect_r.c: posixlycorrect_r.l $(FLEX) posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l flexname_nr flexname_nr.c flexname_nr.l lexcompat_nr lexcompat_nr.c lexcompat_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l preposix_nr preposix_nr.c preposix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l flexname_r flexname_r.c flexname_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l preposix_r preposix_r.c preposix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l flexname_c99 flexname_c99.c flexname_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l preposix_c99 preposix_c99.c preposix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l flexname_nr flexname_nr.c flexname_nr.l lexcompat_nr lexcompat_nr.c lexcompat_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l preposix_nr preposix_nr.c preposix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l yyunput_nr yyunput_nr.c yyunput_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l flexname_r flexname_r.c flexname_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l preposix_r preposix_r.c preposix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l yyunput_r yyunput_r.c yyunput_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l flexname_c99 flexname_c99.c flexname_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l preposix_c99 preposix_c99.c preposix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l yyunput_c99 yyunput_c99.c yyunput_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index c1dc5fa..35220ab 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -42,9 +42,7 @@ define(`M4_TEST_PREAMBLE', `dnl %} ')dnl close preamble define(`M4_TEST_ECHO', `yyecho();') -define(`M4_TEST_FAILMESSAGE', `dnl -fprintf(stderr,"Invalid line.\n"); exit(-1); -')dnl close failmessage +define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -81,7 +79,7 @@ define(`M4_TEST_PREAMBLE', `dnl %} ')dnl close preamble define(`M4_TEST_ECHO', `yyecho();') -define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"Invalid line.\n"); exit(-1);') +define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -128,7 +126,7 @@ import ( %option emit="go" ')dnl close preamble define(`M4_TEST_ECHO', `yyecho()') -define(`M4_TEST_FAILMESSAGE', `log.Fatal("Invalid line"); os.Exit(-1);') +define(`M4_TEST_FAILMESSAGE', `log.Fatal("TEST FAILMESSAGE"); os.Exit(1);') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { lexer := new(FlexLexer) diff --git a/tests/yyunput.rules b/tests/yyunput.rules new file mode 100644 index 0000000..97133a5 --- /dev/null +++ b/tests/yyunput.rules @@ -0,0 +1,34 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /* A test of the yyunput function */ + +%option 8bit +%option nomain noyywrap noinput +%option warn yylineno array +%% + +foo {yyunput('k');} +kick ; +\n ; +. {M4_TEST_FAILMESSAGE} +%% diff --git a/tests/yyunput.txt b/tests/yyunput.txt new file mode 100644 index 0000000..9126894 --- /dev/null +++ b/tests/yyunput.txt @@ -0,0 +1 @@ +fooick -- cgit v1.2.1 From 7af5fa13bb376dc8ee1df0d4ff2a70950997e9de Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Oct 2020 07:34:25 -0400 Subject: Outside cpp #define doesn't work, so deprecate YY_FLEX_SUBMINOR_VERSION. --- doc/flex.texi | 4 +++ src/c99-flex.skl | 9 +++---- tests/posixlycorrect_c99.l | 64 ---------------------------------------------- tests/posixlycorrect_nr.l | 60 ------------------------------------------- 4 files changed, 8 insertions(+), 129 deletions(-) delete mode 100644 tests/posixlycorrect_c99.l delete mode 100644 tests/posixlycorrect_nr.l diff --git a/doc/flex.texi b/doc/flex.texi index 5c244a4..9c452b6 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8975,6 +8975,10 @@ necessary. @item FLEX_SCANNER: Not neaningful outside of the C back end, and not defined. +@item +YY_FLEX_SUBMINOR_VERSION: Its behavior an't be replivated without the +C preprocessor. Test for YY_FLEX_SUBMINOR_VERSION instead. + @end itemize @node Indices, , Appendices, Top diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 95bf474..b853196 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -7,7 +7,7 @@ %# the bare minimum needed to keep it working in C. %# %# Note that using m4 rather than C for macro definitions means they -%# will be recognized and expended in user actions but not +%# willnot be recognized and expended in user actions nor %# in user code sections. Anything you need to be visible there %# needs to be declared as a function. %# @@ -82,10 +82,9 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 %% [0.0] Make hook macros available to Flex -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION -#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION -#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION +m4_define([[YY_FLEX_MAJOR_VERSION]], [[FLEX_MAJOR_VERSION]]) +m4_define([[YY_FLEX_MINOR_VERSION]], [[FLEX_MINOR_VERSION]]) +m4_define([[YY_FLEX_SUBMINOR_VERSION]], [[FLEX_SUBMINOR_VERSION]]) #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif diff --git a/tests/posixlycorrect_c99.l b/tests/posixlycorrect_c99.l deleted file mode 100644 index 4774671..0000000 --- a/tests/posixlycorrect_c99.l +++ /dev/null @@ -1,64 +0,0 @@ - - -%{ -#include "config.h" -#include -%} -%option emit="c99" -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED `AS IS' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* - * The goal of this test is to verify that we are getting the - * counter-intuitive POSIX behavior of the repeat operator {} when - * posix_compat is off but POSIXLY_CORRECT=1 is set in the - * environment. Note: This depends on the test framework to actually - * set that variable! When it does not, Flex will match abbb - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - * The input file should contain just the second string. - */ -%option nounput nomain noyywrap noinput -%option warn - -%% - -ab{3} { } -\n { } -. {fprintf(stderr,"TEST FAILED.\n"); exit(1);} - -%% -int main (int argc, char **argv) -{ - yyscan_t lexer; - yylex_init( &lexer ); - yyset_out ( stdout,lexer); - yyset_in ( stdin, lexer); - while( yylex(lexer) ) - { - } - yylex_destroy( lexer ); - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/posixlycorrect_nr.l b/tests/posixlycorrect_nr.l deleted file mode 100644 index 2a44dc7..0000000 --- a/tests/posixlycorrect_nr.l +++ /dev/null @@ -1,60 +0,0 @@ - - -%{ -#include "config.h" -#include -%} -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED `AS IS' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* - * The goal of this test is to verify that we are getting the - * counter-intuitive POSIX behavior of the repeat operator {} when - * posix_compat is off but POSIXLY_CORRECT=1 is set in the - * environment. Note: This depends on the test framework to actually - * set that variable! When it does not, Flex will match abbb - * - * ab{3} - In traditional flex, this matches "abbb". - * In posix, this matches "ababab". - * The input file should contain just the second string. - */ -%option nounput nomain noyywrap noinput -%option warn - -%% - -ab{3} { } -\n { } -. {fprintf(stderr,"TEST FAILED.\n"); exit(1);} - -%% -int main (int argc, char **argv) -{ - yyin = stdin; - yyout = stdout; - while( yylex() ) - { - } - printf("TEST RETURNING OK.\n"); - return 0; -} -- cgit v1.2.1 From f854b710512bb20ff41563e7ab9edfc10071fc08 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Oct 2020 09:05:37 -0400 Subject: Clean C preprocessor assumptions out of C99. Also, continue booleanizing where we can. --- src/c99-flex.skl | 92 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index b853196..631a9fb 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -82,16 +82,17 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 %% [0.0] Make hook macros available to Flex -m4_define([[YY_FLEX_MAJOR_VERSION]], [[FLEX_MAJOR_VERSION]]) -m4_define([[YY_FLEX_MINOR_VERSION]], [[FLEX_MINOR_VERSION]]) -m4_define([[YY_FLEX_SUBMINOR_VERSION]], [[FLEX_SUBMINOR_VERSION]]) -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif +const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; +const int YY_FLEX_MINOR_VERSION = FLEX_MINOR_VERSION; +const int YY_FLEX_SUBMINOR_VERSION = FLEX_SUBMINOR_VERSION; -%# Prefixes. +%# STARTS prefix machinery +%# %# The complexity here is necessary so that m4 preserves %# the argument lists to each C function. +%# +%# If your target language has OO you can generare a class definition, +%# use option yyclass to pass in the class name, and drop prefix support. m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) @@ -157,6 +158,8 @@ m4_ifelse(M4_MODE_PREFIX,yy,, M4_GEN_PREFIX(`free') ) +%# ENDS prefix machinery + /* START platform-specific and compiler-specific definitions. */ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , @@ -244,12 +247,25 @@ typedef struct yy_buffer_state *yybuffer; typedef size_t yy_size_t; -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 +%# These are not part of the exported interface and cab safewky be renamed +const int EOB_ACT_CONTINUE_SCAN = 0; +const int EOB_ACT_END_OF_FILE = 1; +const int EOB_ACT_LAST_MATCH = 2; +const int YY_BUFFER_NEW = 0; +const int YY_BUFFER_NORMAL = 1; + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +const int YY_BUFFER_EOF_PENDING = 2; -struct yy_buffer_state - { +struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -289,23 +305,10 @@ struct yy_buffer_state /* Whether to try to fill the input buffer when we reach the * end of it. */ - int yy_fill_buffer; + bool yy_fill_buffer; int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; +}; void yyrestart ( FILE *input_file, yyscan_t yyscanner ); void yy_switch_to_buffer ( yybuffer new_buffer, yyscan_t yyscanner ); @@ -386,7 +389,7 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ %% [2.0] data tables for the DFA are inserted here - m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl +m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { @@ -937,9 +940,11 @@ extern int yylex M4_YY_LEX_PROTO; ]]) YY_USER_ACTION /* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. + * corresponding action - sets up yytext. yy_cp and yy_bp are the + * end abd start pointers for the input buffer segment that is + * claimed as yytext. */ - void yy_do_before_action(struct yyguts_t *yyg, char *yy_cp, char *yy_bp) { +void yy_do_before_action(struct yyguts_t *yyg, char *yy_cp, char *yy_bp) { yyg->yytext_ptr = yy_bp; \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ @@ -1605,7 +1610,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( yyg->yy_c_buf_p > &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars + 1] ) { YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); } - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_fill_buffer == 0 ) { + if ( !yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_fill_buffer ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so @@ -2090,7 +2095,7 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) yy_flush_buffer( b, yyscanner); b->yy_input_file = file; - b->yy_fill_buffer = 1; + b->yy_fill_buffer = true; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. @@ -2277,7 +2282,7 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol_flag = true; - b->yy_fill_buffer = 0; + b->yy_fill_buffer = false; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer( b, yyscanner ); @@ -2399,17 +2404,16 @@ static int yy_top_state (yyscan_t yyscanner) /* Redefine yyless() so it works in section 3 code. */ #undef yyless -#define yyless(n) \ - do { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yyg->yytext_r[yyg->yyleng_r] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yyg->yytext_r + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyg->yyleng_r = yyless_macro_arg; \ - } while ( 0 ) +void yyless(int n, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Undo effects of setting up yytext. */ + YY_LESS_LINENO(n); + yyg->yytext_r[yyg->yyleng_r] = yyg->yy_hold_char; + yyg->yy_c_buf_p = yyg->yytext_r + n; + yyg->yy_hold_char = *yyg->yy_c_buf_p; + *yyg->yy_c_buf_p = '\0'; + yyg->yyleng_r = n; +} /* Accessor methods (get/set functions) to struct members. */ -- cgit v1.2.1 From d1dc1c0911b48e6bb4137a4aeeeead49082236eb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Oct 2020 19:35:02 -0400 Subject: Sever a number of dependencies on cpp by adding rewrite rules... ...in the flex scanner. Presently this works for yyecho(), yyinput(), yystart(), yybegin(), and yyunput(). These no longer need to be nacros. A few more remain to be done, notably yyless() and yymore(). Along the way, deprecate YY_FATAL_ERROR and add a replacement option. --- doc/flex.texi | 5 + src/c99-flex.skl | 375 +++++++++++++++++++++++++++-------------------------- src/cpp-flex.skl | 2 + src/flexdef.h | 3 + src/main.c | 10 +- src/parse.y | 4 +- src/scan.l | 32 +++++ tests/.gitignore | 3 +- tests/testmaker.m4 | 4 +- 9 files changed, 246 insertions(+), 192 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 9c452b6..01ad49c 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8966,6 +8966,11 @@ YY_CURRENT_BUFFER: replaced by yy_current_buffer(). @item YY_BUFFER_STATE: replaced by yybuffer. +@item YY_FATAL_ERROR: replaced by yy_fatal_error(). +To supply your own handler, simply use @code{%option noyy_fatal_error} +so the default handler is not generated, then write your own handler +with the same prototype. + @item YY_NEW_FILE: In previous versions of @code{flex}, when assigning @file{yyin} to a new input file, after doing the assignment you had to diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 631a9fb..e98db97 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -31,6 +31,7 @@ m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C99]]) m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]]) m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) +m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) %# Macro hooks used by Flex code generators start here m4_define([[M4_HOOK_INT32]], [[flex_int32_t]]) @@ -321,6 +322,7 @@ void yypop_buffer_state ( yyscan_t yyscanner ); static void yyensure_buffer_stack ( yyscan_t yyscanner ); static void yy_load_buffer_state ( yyscan_t yyscanner ); static void yy_init_buffer ( yybuffer b, FILE *file, yyscan_t yyscanner ); +static void yybumpline ( yyscan_t yyscanner ); yybuffer yy_scan_buffer ( char *base, yy_size_t size, yyscan_t yyscanner ); yybuffer yy_scan_string ( const char *yy_str, yyscan_t yyscanner ); @@ -759,6 +761,160 @@ m4_ifdef( [[]], ]]) ]]) +/* START special functions + * + * Flex's scanner knows these are special and inserts the yyscanner argument + * at the end of the argument list. TODO: support OO languages with a + * property that causes it to be prepended with a dot instead. + */ + +/* Enter a start condition. */ +void yybegin(int s, yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_start = 1 + 2 * (s); +} + +/* Translate the current start state into a value that can be later handed + * to yybegin() to return to the state. + */ +int yystart(yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return ((yyg->yy_start - 1) / 2); +} + +/* This used to be an fputs(), but since the string might contain NULs, + * we now use fwrite(). + */ +void yyecho(yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + fwrite(yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r); +} + +m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ +void yyunput( int c, yyscan_t yyscanner) +{ + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_cp = yyg->yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; + + if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = yyg->yy_n_chars + 2; + char *dest = &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size + 2]; + char *source = + &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; + + while ( source > yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf ) { + *--dest = *--source; + } + yy_cp += (int) (dest - source); + yyg->yytext_ptr += (int) (dest - source); + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = + yyg->yy_n_chars = (int) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size; + + if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + yy_fatal_error( "flex scanner push-back overflow", yyscanner); + } + } + + *--yy_cp = (char) c; + +m4_ifdef( [[M4_MODE_YYLINENO]], +[[ + if ( c == '\n' ){ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_lineno--; + } +]]) + + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; +} +]]) + +int yyinput (yyscan_t yyscanner) +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] ) { + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + } else { + /* need more input */ + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyg->yyin_r, yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + if ( yywrap( yyscanner ) ) { + return 0; + } + if ( ! yyg->yy_did_buffer_switch_on_eof ) { + yyrestart( yyg->yyin_r, yyscanner ); + } + return yyinput(yyscanner); + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ + yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = (c == '\n'); +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol ) { + yybumpline( yyscanner ); + } +]]) +]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( c == '\n' ) { + yybumpline( yyscanner ); + } + ]]) +]]) + + return c; +} + +/* ENDS special functions + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -767,12 +923,6 @@ m4_ifdef( [[]], extern int yywrap ( yyscan_t yyscanner ); #endif -#ifndef YY_NO_YYUNPUT -m4_ifdef( [[M4_YY_NO_YYUNPUT]],,[[ -static void yyunput_r ( int c, yyscan_t yyscanner); -]]) -#endif - #ifndef yytext_ptr static void yy_flex_strncpy ( char *, const char *, int, yyscan_t yyscanner); #endif @@ -781,11 +931,6 @@ static void yy_flex_strncpy ( char *, const char *, int, yyscan_t yyscanner); static int yy_flex_strlen ( const char *, yyscan_t yyscanner); #endif -#ifndef YY_NO_YYINPUT -static int yyinput ( yyscan_t yyscanner ); -#endif - - m4_ifdef( [[M4_YY_STACK_USED]], [[ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, @@ -811,14 +956,15 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) #define YY_EXIT_FAILURE 2 #endif +m4_ifdef( [[M4_MODE_YY_NO_FATAL_ERROR]],, [[ static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; /* forestall unused-argument warning */ fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } +]]) -/* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg, yyscanner) #endif @@ -836,7 +982,7 @@ m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; while ( (result = (int) read( fileno(yyg->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { if( errno != EINTR) { - YY_FATAL_ERROR( "input in flex scanner failed" ); + yy_fatal_error( "input in flex scanner failed", yyscanner); break; } errno=0; @@ -855,14 +1001,14 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ buf[n++] = (char) c; } if ( c == EOF && ferror( yyg->yyin_r ) ) { - YY_FATAL_ERROR( "input in flex scanner failed" ); + yy_fatal_error( "input in flex scanner failed", yyscanner); } result = n; } else { errno=0; while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyg->yyin_r)) == 0 && ferror(yyg->yyin_r)) { if( errno != EINTR) { - YY_FATAL_ERROR( "input in flex scanner failed" ); + yy_fatal_error( "input in flex scanner failed", yyscanner); break; } errno=0; @@ -977,20 +1123,11 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ #define yycolumn (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r -m4_define( [[M4_YY_INCR_LINENO]], -[[ - do{ yylineno++; +static void yybumpline( yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylineno++; yycolumn=0; - }while(0) -]]) - -/* Enter a start condition. */ -#define yybegin(s) yyg->yy_start = 1 + 2 * (s) -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define yystart() ((yyg->yy_start - 1) / 2) +} m4_ifdef( [[M4_MODE_YYLINENO]], [[ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires @@ -1036,7 +1173,6 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ yy_do_before_action(yyg, yy_cp, yy_bp); /* set up yytext again */ \ } \ while ( 0 ) -#define yyunput(c) yyunput_r( c, yyscanner ) /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -1070,6 +1206,7 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ #define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag) m4_ifdef( [[M4_MODE_USES_REJECT]],[[ +%# Can't be given the context-arg treatment due to the goto. #define yyreject() \ { \ *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ @@ -1082,7 +1219,6 @@ yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ ++yyg->yy_lp; \ goto find_rule; \ } -#define REJECT yyreject() ]]) m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ /* The intent behind this definition is that it'll catch @@ -1115,11 +1251,6 @@ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ #define YY_RESTORE_YY_MORE_OFFSET ]]) -/* This used to be an fputs(), but since the string might contain NULs, - * we now use fwrite(). - */ -#define yyecho() fwrite(yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r) - /* END access macros for use in actions */ %# Code snippets used in various cases of code generation in the main scanner. @@ -1244,7 +1375,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyg->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } if ( yyg->yy_state_buf == NULL) { - YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); + yy_fatal_error( "out of dynamic memory in yylex()", yyscanner); } ]]) @@ -1410,7 +1541,7 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], int yyl; for ( yyl = M4_YYL_BASE; yyl < yyg->yyleng_r; ++yyl ) { if ( yyg->yytext_r[yyl] == '\n' ) { - M4_YY_INCR_LINENO(); + yybumpline( yyscanner ); } } @@ -1432,7 +1563,7 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ } else if ( yy_act == YY_NUM_RULES + 1 ) { fprintf( stderr, "--(end of buffer or a NUL)\n" ); } else { - fprintf( stderr, "--EOF (start condition %d)\n", yystart() ); + fprintf( stderr, "--EOF (start condition %d)\n", yystart(yyscanner) ); } } ]]) @@ -1554,7 +1685,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ */ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - yy_act = YY_STATE_EOF(yystart()); + yy_act = YY_STATE_EOF(yystart(yyscanner)); goto do_action; } else { if ( ! yyg->yy_did_buffer_switch_on_eof ) { @@ -1586,7 +1717,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ break; } /* case YY_END_OF_BUFFER */ default: - YY_FATAL_ERROR("fatal flex scanner internal error--no action found" ); + yy_fatal_error("fatal flex scanner internal error--no action found", yyscanner); } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ @@ -1608,7 +1739,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) int ret_val; if ( yyg->yy_c_buf_p > &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars + 1] ) { - YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); + yy_fatal_error( "fatal flex scanner internal error--end of buffer missed", yyscanner); } if ( !yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_fill_buffer ) { /* Don't try to fill the buffer, so this is an EOF. */ @@ -1645,8 +1776,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses yyreject()" ); + yy_fatal_error( + "input buffer overflow, can't enlarge buffer because scanner uses yyreject()", yyscanner ); ]], [[ /* just a shorter name for the current buffer */ @@ -1672,8 +1803,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], b->yy_ch_buf = NULL; } if ( b->yy_ch_buf == NULL ) { - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); + yy_fatal_error("fatal error - scanner input buffer overflow", yyscanner); } yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; @@ -1710,7 +1840,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( (void *) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf == NULL ) { - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + yy_fatal_error( "out of dynamic memory in yy_get_next_buffer()", yyscanner); } /* "- 2" to take care of EOB's */ yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); @@ -1844,129 +1974,6 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ return yy_is_jam ? 0 : yy_current_state; } -m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ -static void yyunput_r( int c, yyscan_t yyscanner) -{ - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_cp = yyg->yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; - - if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { - /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = yyg->yy_n_chars + 2; - char *dest = &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size + 2]; - char *source = - &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; - - while ( source > yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf ) { - *--dest = *--source; - } - yy_cp += (int) (dest - source); - yyg->yytext_ptr += (int) (dest - source); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = - yyg->yy_n_chars = (int) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size; - - if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - } - - *--yy_cp = (char) c; - -m4_ifdef( [[M4_MODE_YYLINENO]], -[[ - if ( c == '\n' ){ - --yylineno; - } -]]) - - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; -} -]]) - -int yyinput (yyscan_t yyscanner) -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] ) { - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - } else { - /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyg->yyin_r, yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - if ( yywrap( yyscanner ) ) { - return 0; - } - if ( ! yyg->yy_did_buffer_switch_on_eof ) { - yyrestart( yyg->yyin_r, yyscanner ); - } - return yyinput(yyscanner); - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = (c == '\n'); -m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol ) { - M4_YY_INCR_LINENO(); - } -]]) -]]) -m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ -m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( c == '\n' ) { - M4_YY_INCR_LINENO(); - } - ]]) -]]) - - return c; -} - /** Immediately switch to a different input stream. * @param input_file A readable stream. * @param yyscanner The scanner object. @@ -2044,7 +2051,7 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + yy_fatal_error( "out of dynamic memory in yy_create_buffer()", yyscanner ); } b->yy_buf_size = size; @@ -2053,7 +2060,7 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) */ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); if ( b->yy_ch_buf == NULL ) { - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + yy_fatal_error( "out of dynamic memory in yy_create_buffer()", yyscanner ); } b->yy_is_our_buffer = 1; @@ -2224,7 +2231,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); if ( yyg->yy_buffer_stack == NULL ) { - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + yy_fatal_error( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -2244,7 +2251,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); if (yyg->yy_buffer_stack == NULL) { - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + yy_fatal_error( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2273,7 +2280,7 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) } b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + yy_fatal_error( "out of dynamic memory in yy_scan_buffer()", yyscanner ); } b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; @@ -2329,7 +2336,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann n = (yy_size_t) (_yybytes_len + 2); buf = (char *) yyalloc( n, yyscanner ); if ( buf == 0 ) { - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + yy_fatal_error( "out of dynamic memory in yy_scan_bytes()", yyscanner ); } for ( i = 0; i < _yybytes_len; ++i ) { buf[i] = yybytes[i]; @@ -2338,7 +2345,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann b = yy_scan_buffer( buf, n, yyscanner); if ( b == NULL ) { - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + yy_fatal_error( "bad buffer in yy_scan_bytes()", yyscanner ); } /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2369,12 +2376,12 @@ static void yy_push_state(int _new_state, yyscan_t yyscanner) (void *) yyg->yy_start_stack, new_size, yyscanner ); } if ( yyg->yy_start_stack == NULL ) { - YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + yy_fatal_error( "out of memory expanding start-condition stack", yyscanner); } } - yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = yystart(); + yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = yystart(yyscanner); - yybegin(_new_state); + yybegin(_new_state, yyscanner); } ]]) @@ -2385,9 +2392,9 @@ static void yy_pop_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( --yyg->yy_start_stack_ptr < 0 ) { - YY_FATAL_ERROR( "start-condition stack underflow" ); + yy_fatal_error( "start-condition stack underflow", yyscanner ); } - yybegin(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); + yybegin(yyg->yy_start_stack[yyg->yy_start_stack_ptr], yyscanner); } ]]) @@ -2397,7 +2404,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, static int yy_top_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yy_start_stack_ptr > 0 ? yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1] : yystart(); + return yyg->yy_start_stack_ptr > 0 ? yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1] : yystart(yyscanner); } ]]) @@ -2524,7 +2531,7 @@ void yyset_lineno(int _line_number, yyscan_t yyscanner) { /* lineno is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + yy_fatal_error( "yyset_lineno called with no buffer", yyscanner ); } yylineno = _line_number; } @@ -2541,7 +2548,7 @@ void yyset_column(int _column_no, yyscan_t yyscanner) { /* column is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { - YY_FATAL_ERROR( "yyset_column called with no buffer" ); + yy_fatal_error( "yyset_column called with no buffer", yyscanner ); } yycolumn = _column_no; } diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 0325984..0b0ad4b 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1510,6 +1510,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_EXIT_FAILURE 2 #endif +m4_ifdef([[M4_MODE_YY_NO_FATAL_ERROR]],,[[ m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { M4_YY_DECL_GUTS_VAR(); @@ -1525,6 +1526,7 @@ void yyFlexLexer::LexerError( const char* msg ) { exit( YY_EXIT_FAILURE ); } ]]) +]]) /* Report a fatal error. */ #ifndef YY_FATAL_ERROR diff --git a/src/flexdef.h b/src/flexdef.h index 098f72d..e5bdbc1 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -351,6 +351,7 @@ struct ctrl_bundle_t { char *postaction; // Code fragment to be inserted after each action char *emit; // Specify target language to emit. // flags corresponding to the huge mass of --no-yy options + bool no_yy_fatal_error; bool no_yy_push_state; bool no_yy_pop_state; bool no_yy_top_state; @@ -1059,6 +1060,8 @@ extern void scinstal(const char *, int); /* make a start condition */ /* Lookup the number associated with a start condition. */ extern int sclookup(const char *); +/* Supply context argument for a function if required */ +extern void context_call(char *); /* from file tblcmp.c */ diff --git a/src/main.c b/src/main.c index fb468d3..13891fe 100644 --- a/src/main.c +++ b/src/main.c @@ -1223,9 +1223,11 @@ void readin (void) if (syntaxerror) flexend (1); - /* On --emit, -e, or %option emit, change backends - * This is where backend properties are collected, - * which means they can't be set from a custom skelfile. + /* On --emit, -e, or change backends This is where backend + * properties are collected, which means they can't be set + * from a custom skelfile. Note: might have been called sooner + * when %option emit was evaluated; this catches command-line + * optiins and the default case. */ backend_by_name(ctrl.emit); @@ -1608,6 +1610,8 @@ void readin (void) if (ctrl.no_yyinput) visible_define("M4_MODE_NO_YYINPUT"); + if (ctrl.no_yy_fatal_error) + visible_define("M4_YY_NO_FATAL_ERROR"); if (ctrl.no_yy_push_state) visible_define("M4_YY_NO_PUSH_STATE"); if (ctrl.no_yy_pop_state) diff --git a/src/parse.y b/src/parse.y index 323689f..809d1ea 100644 --- a/src/parse.y +++ b/src/parse.y @@ -139,7 +139,7 @@ goal : initlex sect1 sect1end sect2 initforrule add_action( "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); else - add_action( "yyecho()" ); + context_call("yyecho()"); add_action( ";\n\tYY_BREAK]]\n" ); } @@ -216,7 +216,7 @@ option : TOK_OUTFILE '=' NAME | TOK_POSTACTION '=' NAME { ctrl.postaction = xstrdup(nmstr); } | TOK_EMIT '=' NAME - { ctrl.emit = xstrdup(nmstr); } + { ctrl.emit = xstrdup(nmstr); backend_by_name(ctrl.emit); } | TOK_USERINIT '=' NAME { ctrl.userinit = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME diff --git a/src/scan.l b/src/scan.l index dbd0aab..720034e 100644 --- a/src/scan.l +++ b/src/scan.l @@ -150,6 +150,11 @@ LEXOPT [aceknopr] M4QSTART "[""[" M4QEND "]""]" +FUNARGS [^)]* + +%{ +void context_call(char *); +%} %% static int bracelevel, didadef, indented_code; static int doing_rule_action = false; @@ -418,6 +423,8 @@ M4QEND "]""]" yywrap ctrl.do_yywrap = option_sense; yyread ctrl.noyyread = !option_sense; + yy_fatal_error ctrl.no_yy_fatal_error = !option_sense; + yy_push_state ctrl.no_yy_push_state = ! option_sense; yy_pop_state ctrl.no_yy_pop_state = ! option_sense; yy_top_state ctrl.no_yy_top_state = ! option_sense; @@ -948,6 +955,9 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ { "{" ACTION_ECHO; ++bracelevel; "}" ACTION_ECHO; --bracelevel; + yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\) { + context_call(yytext); + } [^[:alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; {NAME} ACTION_ECHO; "'"([^''\\\n]|\\.)"'" ACTION_ECHO; /* character constant */ @@ -1060,3 +1070,25 @@ void set_input_file( char *file ) linenum = 1; } + +void context_call(char *txt) { + const char *context_arg = skel_property("M4_PROPERTY_CONTEXT_ARG"); + + /* if there's no such property, simply pass through */ + if (context_arg == NULL) { + add_action(txt); + } else { + char buf[BUFSIZ]; + + /* otherwise, supply the context string as a final argument */ + assert(txt[strlen(txt)-1] == ')'); + strncpy(buf, txt, sizeof(buf)); + buf[strlen(buf)-1] = '\0'; /* remove trailing ) */ + add_action(buf); + if (txt[strlen(buf)-1] != '(') { + add_action(", "); + } + add_action(context_arg); + add_action(")"); + } +} diff --git a/tests/.gitignore b/tests/.gitignore index adba2cd..3ab460a 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -123,7 +123,8 @@ yyextra_nr yyextra_nr.c yyextra_c99 yyextra_c99.c -tableopts_*.c +yyunput_* +!yyunput.rules *.opt *.ser *.ver diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 35220ab..7fcfe5a 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -92,10 +92,10 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl yyset_in ( stdin, lexer); ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl if((fp = fopen(argv[1],"rb"))== NULL) - YY_FATAL_ERROR("could not open tables file for reading"); + yy_fatal_error("could not open tables file for reading", lexer); if(yytables_fload(fp, yyscanner) < 0) - YY_FATAL_ERROR("yytables_fload returned < 0"); + yy_fatal_error("yytables_fload returned < 0", lexer); ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') ')dnl table_serialization while( yylex(lexer) ) -- cgit v1.2.1 From 169612a929ab64036c5fd904f0794f6adb74df4f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Oct 2020 20:27:36 -0400 Subject: Remove cpp dependencies. --- src/c99-flex.skl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index e98db97..3641084 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -227,12 +227,12 @@ m4preproc_include(`flexint_shared.h') /* END platform-specific and compiler-specific definitions. */ /* Returned upon end-of-file. */ -#define YY_NULL 0 +const int YY_NULL = 0; /* Promotes a possibly negative, possibly signed char to an * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) +m4_define([[YY_SC_TO_UI]], [[((YY_CHAR)($1))]]) /* An opaque pointer. */ typedef void* yyscan_t; -- cgit v1.2.1 From af8d41eb94ca9d15c7a5c33fddfb9ce0e0c559c2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Oct 2020 21:17:36 -0400 Subject: In C99, abolish indirection through a void pointer... ...to get to the scanner internals structure. While this was a valiant effort at information hiding, it won't port out of C to any other plausible target language. That being the case, we cut the LOC. --- src/c99-flex.skl | 673 +++++++++++++++++++++++++------------------------------ tests/mem_c99.l | 6 +- 2 files changed, 314 insertions(+), 365 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 3641084..5eadf52 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -52,7 +52,7 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) -m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyg, cp, bp); /* set up yytext */]]) +m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, cp, bp); /* set up yytext */]]) m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */]]) m4_define([[M4_HOOK_CHAR_REWIND]], [[YY_G(yy_c_buf_p) = yy_cp -= $1;]]) m4_define([[M4_HOOK_LINE_REWIND]], [[YY_LINENO_REWIND_TO(yy_cp - $1);]]) @@ -234,8 +234,11 @@ const int YY_NULL = 0; */ m4_define([[YY_SC_TO_UI]], [[((YY_CHAR)($1))]]) -/* An opaque pointer. */ -typedef void* yyscan_t; +/* In the ancestal C back end this was a void pointer, meant to be + * opaque pointer. That indirection has been removed here as it + * wouldn't easily port to other langages. + */ +typedef struct yyguts_t *yyscan_t; /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) @@ -649,12 +652,12 @@ m4_ifdef( [[M4_YY_BISON_LVAL]], [[ /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ -# define yylval yyg->yylval_r +# define yylval yyscanner->yylval_r ]]) m4_ifdef( [[]], [[ -# define yylloc yyg->yylloc_r +# define yylloc yyscanner->yylloc_r ]]) int yylex_init (yyscan_t* scanner); @@ -770,55 +773,51 @@ m4_ifdef( [[]], /* Enter a start condition. */ void yybegin(int s, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_start = 1 + 2 * (s); + yyscanner->yy_start = 1 + 2 * (s); } /* Translate the current start state into a value that can be later handed * to yybegin() to return to the state. */ int yystart(yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return ((yyg->yy_start - 1) / 2); + return ((yyscanner->yy_start - 1) / 2); } /* This used to be an fputs(), but since the string might contain NULs, * we now use fwrite(). */ void yyecho(yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - fwrite(yyg->yytext_r, (size_t) yyg->yyleng_r, 1, yyg->yyout_r); + fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); } m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ void yyunput( int c, yyscan_t yyscanner) { char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_cp = yyg->yy_c_buf_p; + yy_cp = yyscanner->yy_c_buf_p; /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; + *yy_cp = yyscanner->yy_hold_char; - if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = yyg->yy_n_chars + 2; - char *dest = &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size + 2]; + int number_to_move = yyscanner->yy_n_chars + 2; + char *dest = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size + 2]; char *source = - &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; + &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; - while ( source > yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf ) { + while ( source > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf ) { *--dest = *--source; } yy_cp += (int) (dest - source); - yyg->yytext_ptr += (int) (dest - source); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = - yyg->yy_n_chars = (int) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size; + yyscanner->yytext_ptr += (int) (dest - source); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = + yyscanner->yy_n_chars = (int) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size; - if ( yy_cp < yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { yy_fatal_error( "flex scanner push-back overflow", yyscanner); } } @@ -828,34 +827,33 @@ void yyunput( int c, yyscan_t yyscanner) m4_ifdef( [[M4_MODE_YYLINENO]], [[ if ( c == '\n' ){ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_lineno--; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno--; } ]]) - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; + yyscanner->yy_hold_char = *yy_cp; + yyscanner->yy_c_buf_p = yy_cp; } ]]) int yyinput (yyscan_t yyscanner) { int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - *yyg->yy_c_buf_p = yyg->yy_hold_char; + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { + if ( *yyscanner->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( yyg->yy_c_buf_p < &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] ) { + if ( yyscanner->yy_c_buf_p < &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] ) { /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; + *yyscanner->yy_c_buf_p = '\0'; } else { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; + int offset = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr); + ++yyscanner->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: @@ -870,7 +868,7 @@ int yyinput (yyscan_t yyscanner) */ /* Reset buffer status. */ - yyrestart( yyg->yyin_r, yyscanner); + yyrestart( yyscanner->yyin_r, yyscanner); /*FALLTHROUGH*/ @@ -878,26 +876,26 @@ int yyinput (yyscan_t yyscanner) if ( yywrap( yyscanner ) ) { return 0; } - if ( ! yyg->yy_did_buffer_switch_on_eof ) { - yyrestart( yyg->yyin_r, yyscanner ); + if ( ! yyscanner->yy_did_buffer_switch_on_eof ) { + yyrestart( yyscanner->yyin_r, yyscanner ); } return yyinput(yyscanner); case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + offset; break; } } } - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; + c = *(unsigned char *) yyscanner->yy_c_buf_p; /* cast for 8-bit char's */ + *yyscanner->yy_c_buf_p = '\0'; /* preserve yytext */ + yyscanner->yy_hold_char = *++yyscanner->yy_c_buf_p; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = (c == '\n'); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol ) { + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol ) { yybumpline( yyscanner ); } ]]) @@ -958,8 +956,7 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) m4_ifdef( [[M4_MODE_YY_NO_FATAL_ERROR]],, [[ static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; /* forestall unused-argument warning */ + (void)yyscanner; /* forestall unused-argument warning */ fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -977,42 +974,41 @@ m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ */ static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { int result; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ( (result = (int) read( fileno(yyg->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { + while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { if( errno != EINTR) { yy_fatal_error( "input in flex scanner failed", yyscanner); break; } errno=0; - clearerr(yyg->yyin_r); + clearerr(yyscanner->yyin_r); } ]]) m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive ) { + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive ) { int c = '*'; int n; for ( n = 0; n < max_size && - (c = getc( yyg->yyin_r )) != EOF && c != '\n'; ++n ) { + (c = getc( yyscanner->yyin_r )) != EOF && c != '\n'; ++n ) { buf[n] = (char) c; } if ( c == '\n' ) { buf[n++] = (char) c; } - if ( c == EOF && ferror( yyg->yyin_r ) ) { + if ( c == EOF && ferror( yyscanner->yyin_r ) ) { yy_fatal_error( "input in flex scanner failed", yyscanner); } result = n; } else { errno=0; - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyg->yyin_r)) == 0 && ferror(yyg->yyin_r)) { + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { if( errno != EINTR) { yy_fatal_error( "input in flex scanner failed", yyscanner); break; } errno=0; - clearerr(yyg->yyin_r); + clearerr(yyscanner->yyin_r); } } ]]) @@ -1080,8 +1076,8 @@ extern int yylex M4_YY_LEX_PROTO; #endif #define YY_RULE_SETUP \ - m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyg->yyleng_r > 0 ) { \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = (yyg->yytext_r[yyg->yyleng_r - 1] == '\n'); \ + m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyscanner->yyleng_r > 0 ) { \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); \ } \ ]]) YY_USER_ACTION @@ -1090,41 +1086,40 @@ extern int yylex M4_YY_LEX_PROTO; * end abd start pointers for the input buffer segment that is * claimed as yytext. */ -void yy_do_before_action(struct yyguts_t *yyg, char *yy_cp, char *yy_bp) { - yyg->yytext_ptr = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyg->yytext_ptr -= yyg->yy_more_len; - yyg->yyleng_r = (int) (yy_cp - yyg->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyg->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - yyg->yy_hold_char = *yy_cp; \ +void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { + yyscanner->yytext_ptr = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; + yyscanner->yyleng_r = (int) (yy_cp - yyscanner->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + yyscanner->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyg->yyleng_r + yyg->yy_more_offset >= YYLMAX ) \ - yy_fatal_error( "token too large, exceeds YYLMAX", (yyacan_t)yyg );]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyg->yyleng_r >= YYLMAX ) \ - yy_fatal_error( "token too large, exceeds YYLMAX", (yyscan_t)yyg);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyg->yytext_r[yyg->yy_more_offset], yyg->yytext_ptr, yyg->yyleng_r + 1, yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yyleng_r += yyg->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_prev_more_offset = yyg->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyg->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyg->yytext_r, yyg->yytext_ptr, yyg->yyleng_r + 1, (yyscan_t)yyg);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ + yy_fatal_error( "token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ + yy_fatal_error( "token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1, yyscanner);]]) \ ]]) \ - yyg->yy_c_buf_p = yy_cp; + yyscanner->yy_c_buf_p = yy_cp; } /* START access macros for use in actions */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_lineno) -#define yycolumn (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r +#define yyin yyscanner->yyin_r +#define yyout yyscanner->yyout_r +#define yyextra yyscanner->yyextra_r +#define yyleng yyscanner->yyleng_r +#define yytext yyscanner->yytext_r +#define yylineno (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno) +#define yycolumn (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_column) +#define yy_flex_debug yyscanner->yy_flex_debug_r static void yybumpline( yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylineno++; yycolumn=0; } @@ -1140,8 +1135,8 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ #define YY_LESS_LINENO(n) \ do { \ int yyl;\ - for ( yyl = n; yyl < yyg->yyleng_r; ++yyl ) { \ - if ( yyg->yytext_r[yyl] == '\n' ) { \ + for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { \ + if ( yyscanner->yytext_r[yyl] == '\n' ) { \ --yylineno;\ } \ } \ @@ -1167,10 +1162,10 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ + *yy_cp = yyscanner->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - yy_do_before_action(yyg, yy_cp, yy_bp); /* set up yytext again */ \ + yyscanner->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext again */ \ } \ while ( 0 ) @@ -1180,8 +1175,8 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ * * Returns the top of the stack, or NULL. */ -#define yy_current_buffer() ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ +#define yy_current_buffer() ( yyscanner->yy_buffer_stack \ + ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ : NULL) #define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) @@ -1189,34 +1184,34 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ #define yy_set_interactive(is_interactive) { \ if ( yy_current_buffer() == NULL ) { \ yyensure_buffer_stack (yyscanner); \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ - yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = \ + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); \ } \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( yy_current_buffer() == NULL ) { \ yyensure_buffer_stack (yyscanner); \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = \ - yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = \ + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); \ } \ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag = at_bol; \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = at_bol; \ } -#define yy_at_bol() (yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_at_bol_flag) +#define yy_at_bol() (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag) m4_ifdef( [[M4_MODE_USES_REJECT]],[[ %# Can't be given the context-arg treatment due to the goto. #define yyreject() \ { \ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ +*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ \ m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ -yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ -yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ +yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ \ +yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ \ ]]) \ -++yyg->yy_lp; \ +++yyscanner->yy_lp; \ goto find_rule; \ } ]]) @@ -1229,18 +1224,18 @@ m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyg->yy_more_offset = yy_flex_strlen( yyg->yytext_r, yyscanner)) +#define yymore() (yyscanner->yy_more_offset = yy_flex_strlen( yyscanner->yytext_r, yyscanner)) #define YY_NEED_STRLEN #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET \ { \ -yyg->yy_more_offset = yyg->yy_prev_more_offset; \ -yyg->yyleng_r -= yyg->yy_more_offset; \ +yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; \ +yyscanner->yyleng_r -= yyscanner->yy_more_offset; \ } ]]) m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyg->yy_more_flag = true) -#define YY_MORE_ADJ yyg->yy_more_len +#define yymore() (yyscanner->yy_more_flag = true) +#define YY_MORE_ADJ yyscanner->yy_more_len #define YY_RESTORE_YY_MORE_OFFSET ]]) ]]) @@ -1265,8 +1260,8 @@ m4_ifdef([[M4_MODE_FULLSPD]], [[ m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ if ( yy_accept[yy_current_state] ) { ]]) - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; + yyscanner->yy_last_accepting_state = yy_current_state; + yyscanner->yy_last_accepting_cpos = yy_cp; } ]]) ]]) @@ -1313,16 +1308,16 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[yyg->yy_start + yy_at_bol()];]]) -m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyg->yy_start];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[yyscanner->yy_start + yy_at_bol()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - yy_current_state = yyg->yy_start; + yy_current_state = yyscanner->yy_start; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yy_at_bol();]]) /* Set up for storing up states. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; + yyscanner->yy_state_ptr = yyscanner->yy_state_buf; + *yyscanner->yy_state_ptr++ = yy_current_state; ]]) ]]) ]]) @@ -1349,7 +1344,6 @@ YY_DECL { yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; m4_ifdef( [[M4_YY_BISON_LVAL]], [[ @@ -1361,8 +1355,8 @@ m4_ifdef( [[]], yylloc = yylloc_param; ]]) - if ( !yyg->yy_init ) { - yyg->yy_init = true; + if ( !yyscanner->yy_init ) { + yyscanner->yy_init = true; #ifdef YY_USER_INIT YY_USER_INIT; @@ -1371,27 +1365,27 @@ m4_ifdef( [[]], m4_ifdef( [[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ - if ( yyg->yy_state_buf == NULL ) { - yyg->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); + if ( yyscanner->yy_state_buf == NULL ) { + yyscanner->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } - if ( yyg->yy_state_buf == NULL) { + if ( yyscanner->yy_state_buf == NULL) { yy_fatal_error( "out of dynamic memory in yylex()", yyscanner); } ]]) - if ( yyg->yy_start == 0 ) { - yyg->yy_start = 1; /* first start state */ + if ( yyscanner->yy_start == 0 ) { + yyscanner->yy_start = 1; /* first start state */ } - if ( yyg->yyin_r == NULL ) { - yyg->yyin_r = stdin; + if ( yyscanner->yyin_r == NULL ) { + yyscanner->yyin_r = stdin; } - if ( yyg->yyout_r == NULL ) { - yyg->yyout_r = stdout; + if ( yyscanner->yyout_r == NULL ) { + yyscanner->yyout_r = stdout; } if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (yyscanner); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = - yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } yy_load_buffer_state( yyscanner ); @@ -1404,17 +1398,17 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], while ( /*CONSTCOND*/1 ) { /* loops until end-of-file is reached */ m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ - yyg->yy_more_len = 0; - if ( yyg->yy_more_flag ) { - yyg->yy_more_len = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - yyg->yy_more_flag = false; + yyscanner->yy_more_len = 0; + if ( yyscanner->yy_more_flag ) { + yyscanner->yy_more_len = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr); + yyscanner->yy_more_flag = false; } ]]) ]]) - yy_cp = yyg->yy_c_buf_p; + yy_cp = yyscanner->yy_c_buf_p; /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; + *yy_cp = yyscanner->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. @@ -1448,7 +1442,7 @@ m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ do { M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyg->yy_state_ptr++ = yy_current_state;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) ++yy_cp; } @@ -1460,8 +1454,8 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure out * the match. */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; + yy_cp = yyscanner->yy_last_accepting_cpos; + yy_current_state = yyscanner->yy_last_accepting_state; ]]) ]]) ]]) @@ -1471,44 +1465,44 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; + yy_current_state = *--yyscanner->yy_state_ptr; + yyscanner->yy_lp = yy_accept[yy_current_state]; m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) for ( ; ; ) { /* loop until we find out what rule we matched */ - if (yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1]) { - yy_act = yy_acclist[yyg->yy_lp]; + if (yyscanner->yy_lp && yyscanner->yy_lp < yy_accept[yy_current_state + 1]) { + yy_act = yy_acclist[yyscanner->yy_lp]; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || yyg->yy_looking_for_trail_begin) { - if (yy_act == yyg->yy_looking_for_trail_begin) { - yyg->yy_looking_for_trail_begin = 0; + if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || yyscanner->yy_looking_for_trail_begin) { + if (yy_act == yyscanner->yy_looking_for_trail_begin) { + yyscanner->yy_looking_for_trail_begin = 0; yy_act &= ~YY_TRAILING_HEAD_MASK; break; } } else if (( yy_act & YY_TRAILING_MASK) != 0) { - yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; - yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; + yyscanner->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; + yyscanner->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; m4_ifdef([[M4_MODE_REAL_REJECT]], [[ /* Remember matched text in case we back up * due to REJECT. */ - yyg->yy_full_match = yy_cp; - yyg->yy_full_state = yyg->yy_state_ptr; - yyg->yy_full_lp = yyg->yy_lp; + yyscanner->yy_full_match = yy_cp; + yyscanner->yy_full_state = yyscanner->yy_state_ptr; + yyscanner->yy_full_lp = yyscanner->yy_lp; ]]) } else { - yyg->yy_full_match = yy_cp; - yyg->yy_full_state = yyg->yy_state_ptr; - yyg->yy_full_lp = yyg->yy_lp; + yyscanner->yy_full_match = yy_cp; + yyscanner->yy_full_state = yyscanner->yy_state_ptr; + yyscanner->yy_full_lp = yyscanner->yy_lp; break; } - ++yyg->yy_lp; + ++yyscanner->yy_lp; goto find_rule; ]]) m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ /* Remember matched text in case we back up due to * trailing context plus REJECT. */ - yyg->yy_full_match = yy_cp; + yyscanner->yy_full_match = yy_cp; break; ]]) } @@ -1519,28 +1513,28 @@ m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ * the beginning, but at the cost of complaints that we're * branching inside a loop. */ - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; + yy_current_state = *--yyscanner->yy_state_ptr; + yyscanner->yy_lp = yy_accept[yy_current_state]; } /* close for */ ]]) m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; + yy_cp = yyscanner->yy_last_accepting_cpos; + yy_current_state = yyscanner->yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } ]]) - yy_do_before_action(yyg, yy_cp, yy_bp); + yy_do_before_action(yyscanner, yy_cp, yy_bp); m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], - [["yyg->yy_prev_more_offset"]], [["yyg->yy_more_len"]])]], [[0]])]]) + [["yyscanner->yy_prev_more_offset"]], [["yyscanner->yy_more_len"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; - for ( yyl = M4_YYL_BASE; yyl < yyg->yyleng_r; ++yyl ) { - if ( yyg->yytext_r[yyl] == '\n' ) { + for ( yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl ) { + if ( yyscanner->yytext_r[yyl] == '\n' ) { yybumpline( yyscanner ); } @@ -1556,10 +1550,10 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ fprintf( stderr, "--scanner backing up\n" ); } else if ( yy_act < YY_NUM_RULES ) { fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yyg->yytext_r ); + (long)yy_rule_linenum[yy_act], yyscanner->yytext_r ); } else if ( yy_act == YY_NUM_RULES ) { fprintf( stderr, "--accepting default rule (\"%s\")\n", - yyg->yytext_r ); + yyscanner->yytext_r ); } else if ( yy_act == YY_NUM_RULES + 1 ) { fprintf( stderr, "--(end of buffer or a NUL)\n" ); } else { @@ -1573,15 +1567,15 @@ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case 0: /* must back up */ /* undo the effects of yy_do_before_action() */ - *yy_cp = yyg->yy_hold_char; + *yy_cp = yyscanner->yy_hold_char; /* Backing-up info for compressed tables is taken \after/ */ /* yy_cp has been incremented for the next state. */ - yy_cp = yyg->yy_last_accepting_cpos; + yy_cp = yyscanner->yy_last_accepting_cpos; m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) - yy_current_state = yyg->yy_last_accepting_state; + yy_current_state = yyscanner->yy_last_accepting_state; goto yy_find_action; ]]) ]]) @@ -1590,13 +1584,13 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yyscanner->yytext_ptr) - 1; /* Undo the effects of yy_do_before_action(). */ - *yy_cp = yyg->yy_hold_char; + *yy_cp = yyscanner->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_NEW ) { + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called @@ -1606,9 +1600,9 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * this is the first action (other than possibly a * back-up) that will match for the new input source. */ - yyg->yy_n_chars = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file = yyg->yyin_r; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_NORMAL; + yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file = yyscanner->yyin_r; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position @@ -1618,10 +1612,10 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * end-of-buffer state). Contrast this with the test * in input(). */ - if ( yyg->yy_c_buf_p <= &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ + if ( yyscanner->yy_c_buf_p <= &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); @@ -1636,25 +1630,25 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ yy_next_state = yy_try_NUL_trans( yy_current_state, yyscanner); - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; + yy_cp = ++yyscanner->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { %# Disguised case statement on table modes - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = yyg->yy_c_buf_p;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = yyg->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = yyscanner->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = yyscanner->yy_c_buf_p;]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure * out the match. */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; + yy_cp = yyscanner->yy_last_accepting_cpos; + yy_current_state = yyscanner->yy_last_accepting_state; ]]) ]]) %# Disguised case statement on table modes ends @@ -1663,7 +1657,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ * yy_current_state was set up by * yy_get_previous_state(). */ - yy_cp = yyg->yy_c_buf_p; + yy_cp = yyscanner->yy_c_buf_p; ]]) ]]) goto yy_find_action; @@ -1671,7 +1665,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } else { /* not a NUL */ switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: - yyg->yy_did_buffer_switch_on_eof = false; + yyscanner->yy_did_buffer_switch_on_eof = false; if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in @@ -1683,34 +1677,34 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(yystart(yyscanner)); goto do_action; } else { - if ( ! yyg->yy_did_buffer_switch_on_eof ) { - yyrestart( yyg->yyin_r, yyscanner ); + if ( ! yyscanner->yy_did_buffer_switch_on_eof ) { + yyrestart( yyscanner->yyin_r, yyscanner ); } } break; case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; + yyscanner->yy_c_buf_p = + yyscanner->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + yy_cp = yyscanner->yy_c_buf_p; + yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars]; + yyscanner->yy_c_buf_p = + &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars]; yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + yy_cp = yyscanner->yy_c_buf_p; + yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } /* end EOB inner switch */ } /* end if */ @@ -1732,18 +1726,17 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ */ static int yy_get_next_buffer (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf; - char *source = yyg->yytext_ptr; + char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; + char *source = yyscanner->yytext_ptr; int number_to_move, i; int ret_val; - if ( yyg->yy_c_buf_p > &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars + 1] ) { + if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { yy_fatal_error( "fatal flex scanner internal error--end of buffer missed", yyscanner); } - if ( !yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_fill_buffer ) { + if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { + if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ @@ -1759,19 +1752,19 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) { *(dest++) = *(source++); } - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars = 0; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; } else { int num_to_read = - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ m4_ifdef( [[M4_MODE_USES_REJECT]], @@ -1781,10 +1774,10 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], ]], [[ /* just a shorter name for the current buffer */ - yybuffer b = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]; + yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; @@ -1805,9 +1798,9 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], if ( b->yy_ch_buf == NULL ) { yy_fatal_error("fatal error - scanner input buffer overflow", yyscanner); } - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size - + num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; ]]) } @@ -1816,41 +1809,41 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], num_to_read = YY_READ_BUF_SIZE; } /* Read in more data. */ - YY_INPUT( (&yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); + YY_INPUT( (&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]), + yyscanner->yy_n_chars, num_to_read ); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; } - if ( yyg->yy_n_chars == 0 ) { + if ( yyscanner->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyg->yyin_r, yyscanner); + yyrestart( yyscanner->yyin_r, yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buffer_status = + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else { ret_val = EOB_ACT_CONTINUE_SCAN; } - if ((yyg->yy_n_chars + number_to_move) > yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size) { + if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( - (void *) yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf == NULL ) { + int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( + (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { yy_fatal_error( "out of dynamic memory in yy_get_next_buffer()", yyscanner); } /* "- 2" to take care of EOB's */ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); } - yyg->yy_n_chars += number_to_move; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + yyscanner->yy_n_chars += number_to_move; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - yyg->yytext_ptr = &yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_ch_buf[0]; + yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; return ret_val; } @@ -1861,10 +1854,9 @@ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { yy_state_type yy_current_state; char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; M4_GEN_START_STATE - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { + for ( yy_cp = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_cp < yyscanner->yy_c_buf_p; ++yy_cp ) { /* Generate the code to find the next state. */ m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) @@ -1891,7 +1883,7 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyg->yy_state_ptr++ = yy_current_state;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) } return yy_current_state; @@ -1905,8 +1897,7 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ */ static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + bool yy_is_jam; /* Generate code for handling NUL's, if needed. */ /* First, deal with backing up and setting up yy_cp if the scanner @@ -1915,7 +1906,7 @@ static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t y * Only generate a definition for "yy_cp" if we'll generate code * that uses it. Otherwise lint and the like complain. */ - m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyg->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyscanner->yy_c_buf_p;]]) %# Note that this statement block and the following three are %# not executed serially but are an if-then-else cascade @@ -1952,7 +1943,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], [[ * the state stack and yy_c_buf_p get out of sync. */ if ( ! yy_is_jam ) { - *yyg->yy_state_ptr++ = yy_current_state; + *yyscanner->yy_state_ptr++ = yy_current_state; } ]]) ]]) @@ -1970,7 +1961,7 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ } ]]) - (void)yyg; /* forestall unused-argument warning */ + (void)yyscanner; /* forestall unused-argument warning */ return yy_is_jam ? 0 : yy_current_state; } @@ -1981,12 +1972,11 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ */ void yyrestart(FILE * input_file, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (yyscanner); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = - yy_create_buffer( yyg->yyin_r, YY_BUF_SIZE, yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } yy_init_buffer( yy_current_buffer(), input_file, yyscanner); @@ -1999,7 +1989,6 @@ void yyrestart(FILE * input_file, yyscan_t yyscanner) */ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with @@ -2012,12 +2001,12 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) } if ( yy_current_buffer() ) { /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos = yyg->yy_c_buf_p; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars; + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; } - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = new_buffer; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during @@ -2025,17 +2014,16 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - yyg->yy_did_buffer_switch_on_eof = true; + yyscanner->yy_did_buffer_switch_on_eof = true; } static void yy_load_buffer_state (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos; - yyg->yyin_r = yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; + yyscanner->yytext_ptr = yyscanner->yy_c_buf_p = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos; + yyscanner->yyin_r = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file; + yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; } /** Allocate and initialize an input buffer state. @@ -2047,7 +2035,6 @@ static void yy_load_buffer_state (yyscan_t yyscanner) yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) { yybuffer b; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { @@ -2075,13 +2062,12 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) */ void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( b == NULL ) { return; } if ( b == yy_current_buffer() ) { /* Not sure if we should pop here. */ - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = (yybuffer) 0; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = (yybuffer) 0; } if ( b->yy_is_our_buffer ) { yyfree( (void *) b->yy_ch_buf, yyscanner ); @@ -2097,7 +2083,6 @@ void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) { int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flush_buffer( b, yyscanner); @@ -2135,7 +2120,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], */ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( b == NULL ) { return; } @@ -2166,7 +2150,6 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) */ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) { return; } @@ -2175,20 +2158,20 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) /* This block is copied from yy_switch_to_buffer. */ if ( yy_current_buffer() != NULL ) { /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_buf_pos = yyg->yy_c_buf_p; - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_n_chars = yyg->yy_n_chars; + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (yy_current_buffer()) { - yyg->yy_buffer_stack_top++; + yyscanner->yy_buffer_stack_top++; } - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = new_buffer; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = true; + yyscanner->yy_did_buffer_switch_on_eof = true; } @@ -2198,18 +2181,17 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) */ void yypop_buffer_state (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (yy_current_buffer() == NULL) { return; } yy_delete_buffer(yy_current_buffer(), yyscanner); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = NULL; - if (yyg->yy_buffer_stack_top > 0) { - --yyg->yy_buffer_stack_top; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; + if (yyscanner->yy_buffer_stack_top > 0) { + --yyscanner->yy_buffer_stack_top; } if (yy_current_buffer() != NULL) { yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = true; + yyscanner->yy_did_buffer_switch_on_eof = true; } } @@ -2220,42 +2202,41 @@ void yypop_buffer_state (yyscan_t yyscanner) static void yyensure_buffer_stack (yyscan_t yyscanner) { yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (yyg->yy_buffer_stack == NULL) { + if (yyscanner->yy_buffer_stack == NULL) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); - if ( yyg->yy_buffer_stack == NULL ) { + if ( yyscanner->yy_buffer_stack == NULL ) { yy_fatal_error( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyscanner->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; + yyscanner->yy_buffer_stack_max = num_to_alloc; + yyscanner->yy_buffer_stack_top = 0; return; } - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1) { + if (yyscanner->yy_buffer_stack_top >= (yyscanner->yy_buffer_stack_max) - 1) { /* Increase the buffer to prepare for a possible push. */ yy_size_t grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, + num_to_alloc = yyscanner->yy_buffer_stack_max + grow_size; + yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyscanner->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); - if (yyg->yy_buffer_stack == NULL) { + if (yyscanner->yy_buffer_stack == NULL) { yy_fatal_error( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + memset(yyscanner->yy_buffer_stack + yyscanner->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyscanner->yy_buffer_stack_max = num_to_alloc; } } @@ -2270,7 +2251,6 @@ m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) { yybuffer b; - m4_dnl struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || @@ -2310,8 +2290,6 @@ m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, */ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) { - m4_dnl struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_scan_bytes( yystr, (int) strlen(yystr), yyscanner); } ]]) @@ -2330,7 +2308,6 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann char *buf; yy_size_t n; int i; - m4_dnl struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -2361,25 +2338,24 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ static void yy_push_state(int _new_state, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) { + if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) { yy_size_t new_size; - yyg->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = (yy_size_t) yyg->yy_start_stack_depth * sizeof( int ); + yyscanner->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int ); - if ( yyg->yy_start_stack == NULL ) { - yyg->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); + if ( yyscanner->yy_start_stack == NULL ) { + yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); } else { - yyg->yy_start_stack = (int *) yyrealloc( - (void *) yyg->yy_start_stack, new_size, yyscanner ); + yyscanner->yy_start_stack = (int *) yyrealloc( + (void *) yyscanner->yy_start_stack, new_size, yyscanner ); } - if ( yyg->yy_start_stack == NULL ) { + if ( yyscanner->yy_start_stack == NULL ) { yy_fatal_error( "out of memory expanding start-condition stack", yyscanner); } } - yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = yystart(yyscanner); + yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner); yybegin(_new_state, yyscanner); } @@ -2390,11 +2366,10 @@ m4_ifdef( [[M4_YY_NO_POP_STATE]],, [[ static void yy_pop_state (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( --yyg->yy_start_stack_ptr < 0 ) { + if ( --yyscanner->yy_start_stack_ptr < 0 ) { yy_fatal_error( "start-condition stack underflow", yyscanner ); } - yybegin(yyg->yy_start_stack[yyg->yy_start_stack_ptr], yyscanner); + yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner); } ]]) @@ -2403,8 +2378,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, [[ static int yy_top_state (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yy_start_stack_ptr > 0 ? yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1] : yystart(yyscanner); + return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner); } ]]) @@ -2412,14 +2386,13 @@ static int yy_top_state (yyscan_t yyscanner) #undef yyless void yyless(int n, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Undo effects of setting up yytext. */ YY_LESS_LINENO(n); - yyg->yytext_r[yyg->yyleng_r] = yyg->yy_hold_char; - yyg->yy_c_buf_p = yyg->yytext_r + n; - yyg->yy_hold_char = *yyg->yy_c_buf_p; - *yyg->yy_c_buf_p = '\0'; - yyg->yyleng_r = n; + yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yy_hold_char; + yyscanner->yy_c_buf_p = yyscanner->yytext_r + n; + yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; + *yyscanner->yy_c_buf_p = '\0'; + yyscanner->yyleng_r = n; } /* Accessor methods (get/set functions) to struct members. */ @@ -2429,7 +2402,6 @@ m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, [[ * @param yyscanner The scanner object. */ YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; } ]]) @@ -2440,7 +2412,6 @@ m4_ifdef( [[M4_YY_NO_GET_LINENO]],, * @param yyscanner The scanner object. */ int yyget_lineno (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (yy_current_buffer() == NULL) { return 0; @@ -2455,7 +2426,6 @@ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, * @param yyscanner The scanner object. */ int yyget_column (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (yy_current_buffer() == NULL) { return 0; @@ -2470,8 +2440,7 @@ m4_ifdef( [[M4_YY_NO_GET_IN]],, * @param yyscanner The scanner object. */ FILE *yyget_in (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yyin_r; + return yyscanner->yyin_r; } ]]) @@ -2481,8 +2450,7 @@ m4_ifdef( [[M4_YY_NO_GET_OUT]],, * @param yyscanner The scanner object. */ FILE *yyget_out (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yyout_r; + return yyscanner->yyout_r; } ]]) @@ -2492,8 +2460,7 @@ m4_ifdef( [[M4_YY_NO_GET_LENG]],, * @param yyscanner The scanner object. */ int yyget_leng (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yyleng_r; + return yyscanner->yyleng_r; } ]]) @@ -2503,8 +2470,7 @@ int yyget_leng (yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_GET_TEXT]],, [[ char *yyget_text (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yytext_r; + return yyscanner->yytext_r; } ]]) @@ -2515,7 +2481,6 @@ m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, * @param yyscanner The scanner object. */ void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; } ]]) @@ -2527,7 +2492,6 @@ m4_ifdef( [[M4_YY_NO_SET_LINENO]],, * @param yyscanner The scanner object. */ void yyset_lineno(int _line_number, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { @@ -2544,7 +2508,6 @@ m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, * @param yyscanner The scanner object. */ void yyset_column(int _column_no, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { @@ -2563,16 +2526,14 @@ m4_ifdef( [[M4_YY_NO_SET_IN]],, * @see yy_switch_to_buffer */ void yyset_in(FILE * _in_str, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yyin_r = _in_str ; + yyscanner->yyin_r = _in_str ; } ]]) m4_ifdef( [[M4_YY_NO_SET_OUT]],, [[ void yyset_out( FILE * _out_str, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yyout_r = _out_str ; + yyscanner->yyout_r = _out_str ; } ]]) @@ -2580,7 +2541,6 @@ void yyset_out( FILE * _out_str, yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ int yyget_debug (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } ]]) @@ -2588,7 +2548,6 @@ int yyget_debug (yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ void yyset_debug(int _bdebug, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; } ]]) @@ -2597,7 +2556,6 @@ m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_ifdef( [[M4_YY_NO_GET_LVAL]],, [[ YYSTYPE * yyget_lval (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylval; } ]]) @@ -2605,7 +2563,6 @@ YYSTYPE * yyget_lval (yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_SET_LVAL]],, [[ void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; } ]]) @@ -2615,7 +2572,6 @@ m4_ifdef( [[]], m4_ifdef( [[M4_YY_NO_GET_LLOC]],, [[ YYLTYPE *yyget_lloc (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylloc; } ]]) @@ -2623,7 +2579,6 @@ YYLTYPE *yyget_lloc (yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_SET_LLOC]],, [[ void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylloc = yylloc_param; } ]]) @@ -2690,42 +2645,41 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) } static int yy_init_globals (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* * This function is called from yylex_destroy(), so don't allocate here. */ - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = false; - yyg->yy_start = 0; - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; + yyscanner->yy_buffer_stack = NULL; + yyscanner->yy_buffer_stack_top = 0; + yyscanner->yy_buffer_stack_max = 0; + yyscanner->yy_c_buf_p = NULL; + yyscanner->yy_init = false; + yyscanner->yy_start = 0; + yyscanner->yy_start_stack_ptr = 0; + yyscanner->yy_start_stack_depth = 0; + yyscanner->yy_start_stack = NULL; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyg->yy_state_buf = 0; - yyg->yy_state_ptr = 0; - yyg->yy_full_match = 0; - yyg->yy_lp = 0; + yyscanner->yy_state_buf = 0; + yyscanner->yy_state_ptr = 0; + yyscanner->yy_full_match = 0; + yyscanner->yy_lp = 0; ]]) m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ - yyg->yytext_ptr = 0; - yyg->yy_more_offset = 0; - yyg->yy_prev_more_offset = 0; + yyscanner->yytext_ptr = 0; + yyscanner->yy_more_offset = 0; + yyscanner->yy_prev_more_offset = 0; ]]) /* Defined in main.c */ #ifdef YY_STDINIT - yyg->yyin_r = stdin; - yyg->yyout_r = stdout; + yyscanner->yyin_r = stdin; + yyscanner->yyout_r = stdout; #else - yyg->yyin_r = NULL; - yyg->yyout_r = NULL; + yyscanner->yyin_r = NULL; + yyscanner->yyout_r = NULL; #endif /* For future reference: Set errno on error, since we are called by @@ -2736,27 +2690,26 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(yy_current_buffer()) { yy_delete_buffer( yy_current_buffer(), yyscanner ); - yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] = NULL; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack, yyscanner); - yyg->yy_buffer_stack = NULL; + yyfree(yyscanner->yy_buffer_stack, yyscanner); + yyscanner->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack, yyscanner ); - yyg->yy_start_stack = NULL; + yyfree( yyscanner->yy_start_stack, yyscanner ); + yyscanner->yy_start_stack = NULL; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyfree ( yyg->yy_state_buf, yyscanner); - yyg->yy_state_buf = NULL; + yyfree ( yyscanner->yy_state_buf, yyscanner); + yyscanner->yy_state_buf = NULL; ]]) /* Reset the globals. This is important in a non-reentrant scanner so the next time @@ -2771,8 +2724,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], #ifndef yytext_ptr static void yy_flex_strncpy(char *s1, const char *s2, int n, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; /* forestall unused-argument warning */ + (void)yyscanner; /* forestall unused-argument warning */ int i; for ( i = 0; i < n; ++i ) { @@ -2795,8 +2747,7 @@ static int yy_flex_strlen(const char *s, yyscan_t yyscanner) m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, [[ void *yyalloc(yy_size_t size, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; /* forestall unused-argument warning */ + (void)yyscanner; /* forestall unused-argument warning */ return malloc(size); } ]]) @@ -2804,8 +2755,7 @@ void *yyalloc(yy_size_t size, yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, [[ void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; /* forestall unused-argument warning */ + (void)yyscanner; /* forestall unused-argument warning */ return realloc(ptr, size); } ]]) @@ -2813,8 +2763,7 @@ void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, [[ void yyfree(void * ptr, yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; /* forestall unused-argument warning */ + (void)yyscanner; /* forestall unused-argument warning */ /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter diff --git a/tests/mem_c99.l b/tests/mem_c99.l index b7bf835..a33589c 100644 --- a/tests/mem_c99.l +++ b/tests/mem_c99.l @@ -86,7 +86,7 @@ static void dump_mem(FILE* fp){ fprintf(fp,"}\n"); } -void * testalloc(yy_size_t n , void* yyscanner) +void * testalloc(yy_size_t n , yyscan_t yyscanner) { (void)yyscanner; @@ -117,7 +117,7 @@ void * testalloc(yy_size_t n , void* yyscanner) return p; } -void * testrealloc(void* p, yy_size_t n , void* yyscanner) +void * testrealloc(void* p, yy_size_t n , yyscan_t yyscanner) { (void)yyscanner; @@ -140,7 +140,7 @@ void * testrealloc(void* p, yy_size_t n , void* yyscanner) exit(1); } -void testfree(void* p , void* yyscanner) +void testfree(void* p , yyscan_t yyscanner) { (void)yyscanner; -- cgit v1.2.1 From 6ba9f483bfd539d74bbb4c9152c7a80437d228e7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Oct 2020 21:50:17 -0400 Subject: Remove for cpp dependencies. --- src/c99-flex.skl | 64 +++++++++----------------------------------------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 5eadf52..a91a559 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -339,8 +339,8 @@ void yyfree ( void *, yyscan_t yyscanner ); m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ #define M4_MODE_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP ]]) + m4_ifdef( [[M4_MODE_DEBUG]], [[ #define FLEX_DEBUG ]]) @@ -917,17 +917,9 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ * section 1. */ -#ifndef YY_SKIP_YYWRAP +m4_ifdef( [[M4_MODE_NO_YYWRAP]],, [[ extern int yywrap ( yyscan_t yyscanner ); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int, yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char *, yyscan_t yyscanner); -#endif +]]) m4_ifdef( [[M4_YY_STACK_USED]], [[ @@ -950,9 +942,7 @@ m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif +const int YY_EXIT_FAILURE = 2; m4_ifdef( [[M4_MODE_YY_NO_FATAL_ERROR]],, [[ static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { @@ -966,8 +956,6 @@ static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { #define YY_FATAL_ERROR(msg) yy_fatal_error( msg, yyscanner) #endif -#define YY_INPUT(buf,result,max_size) do {result = yyread(buf, max_size, yyscanner);} while (0) - m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". @@ -1025,9 +1013,7 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ #endif /* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif +const int YY_START_STACK_INCR = 25; /* Default declaration of generated scanner - a define so the user can * easily add parameters. @@ -1099,11 +1085,11 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ yy_fatal_error( "token too large, exceeds YYLMAX", yyscanner);]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ yy_fatal_error( "token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yy_flex_strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yy_flex_strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1, yyscanner);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ ]]) \ yyscanner->yy_c_buf_p = yy_cp; } @@ -1224,8 +1210,7 @@ m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyscanner->yy_more_offset = yy_flex_strlen( yyscanner->yytext_r, yyscanner)) -#define YY_NEED_STRLEN +#define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET \ { \ @@ -1809,8 +1794,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], num_to_read = YY_READ_BUF_SIZE; } /* Read in more data. */ - YY_INPUT( (&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]), - yyscanner->yy_n_chars, num_to_read ); + yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; } @@ -2114,7 +2098,7 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], errno = oerrno; } -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. +/** Discard all buffered characters. On the next scan, yyread() will be called. * @param b the buffer state to be flushed, usually @c yy_current_buffer(). * @param yyscanner The scanner object. */ @@ -2673,14 +2657,8 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], yyscanner->yy_prev_more_offset = 0; ]]) -/* Defined in main.c */ -#ifdef YY_STDINIT - yyscanner->yyin_r = stdin; - yyscanner->yyout_r = stdout; -#else yyscanner->yyin_r = NULL; yyscanner->yyout_r = NULL; -#endif /* For future reference: Set errno on error, since we are called by * yylex_init() @@ -2722,28 +2700,6 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], return 0; } -#ifndef yytext_ptr -static void yy_flex_strncpy(char *s1, const char *s2, int n, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - - int i; - for ( i = 0; i < n; ++i ) { - s1[i] = s2[i]; - } -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen(const char *s, yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, [[ void *yyalloc(yy_size_t size, yyscan_t yyscanner) { -- cgit v1.2.1 From baaaa45b40a843cfb1fdc438bf673df23d0e9cbc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 06:54:15 -0400 Subject: A step towards getting rid of YY_FATAL_ERROR... ...because we can no longer depend on cpp to be in the pipeline. --- doc/flex.texi | 4 ++-- src/c99-flex.skl | 52 ++++++++++++++++++++++++++-------------------------- src/cpp-flex.skl | 6 +++--- src/flexdef.h | 2 +- src/main.c | 2 +- src/scan.l | 4 ++-- tests/testmaker.m4 | 8 ++++---- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 01ad49c..52edef6 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8966,8 +8966,8 @@ YY_CURRENT_BUFFER: replaced by yy_current_buffer(). @item YY_BUFFER_STATE: replaced by yybuffer. -@item YY_FATAL_ERROR: replaced by yy_fatal_error(). -To supply your own handler, simply use @code{%option noyy_fatal_error} +@item YY_FATAL_ERROR: replaced by yypanic(). +To supply your own handler, simply use @code{%option noyypanic} so the default handler is not generated, then write your own handler with the same prototype. diff --git a/src/c99-flex.skl b/src/c99-flex.skl index a91a559..2c35e4a 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -365,7 +365,7 @@ m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg, yyscan_t yyscanner ); +static void yynoreturn yypanic ( const char* msg, yyscan_t yyscanner ); struct yy_trans_info { /* We require that yy_verify and yy_nxt must be of the same size int. */ @@ -818,7 +818,7 @@ void yyunput( int c, yyscan_t yyscanner) yyscanner->yy_n_chars = (int) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size; if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { - yy_fatal_error( "flex scanner push-back overflow", yyscanner); + yypanic( "flex scanner push-back overflow", yyscanner); } } @@ -945,7 +945,7 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) const int YY_EXIT_FAILURE = 2; m4_ifdef( [[M4_MODE_YY_NO_FATAL_ERROR]],, [[ -static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { +static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -953,7 +953,7 @@ static void yynoreturn yy_fatal_error(const char* msg, yyscan_t yyscanner) { ]]) #ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg, yyscanner) +#define YY_FATAL_ERROR(msg) yypanic( msg, yyscanner) #endif m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ @@ -966,7 +966,7 @@ m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { if( errno != EINTR) { - yy_fatal_error( "input in flex scanner failed", yyscanner); + yypanic( "input in flex scanner failed", yyscanner); break; } errno=0; @@ -985,14 +985,14 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ buf[n++] = (char) c; } if ( c == EOF && ferror( yyscanner->yyin_r ) ) { - yy_fatal_error( "input in flex scanner failed", yyscanner); + yypanic( "input in flex scanner failed", yyscanner); } result = n; } else { errno=0; while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { if( errno != EINTR) { - yy_fatal_error( "input in flex scanner failed", yyscanner); + yypanic( "input in flex scanner failed", yyscanner); break; } errno=0; @@ -1082,9 +1082,9 @@ void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { *yy_cp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ - yy_fatal_error( "token too large, exceeds YYLMAX", yyscanner);]]) \ + yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ - yy_fatal_error( "token too large, exceeds YYLMAX", yyscanner);]]) \ + yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ @@ -1354,7 +1354,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyscanner->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } if ( yyscanner->yy_state_buf == NULL) { - yy_fatal_error( "out of dynamic memory in yylex()", yyscanner); + yypanic( "out of dynamic memory in yylex()", yyscanner); } ]]) @@ -1696,7 +1696,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ break; } /* case YY_END_OF_BUFFER */ default: - yy_fatal_error("fatal flex scanner internal error--no action found", yyscanner); + yypanic("fatal flex scanner internal error--no action found", yyscanner); } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ @@ -1717,7 +1717,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) int ret_val; if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { - yy_fatal_error( "fatal flex scanner internal error--end of buffer missed", yyscanner); + yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); } if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { /* Don't try to fill the buffer, so this is an EOF. */ @@ -1754,7 +1754,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yy_fatal_error( + yypanic( "input buffer overflow, can't enlarge buffer because scanner uses yyreject()", yyscanner ); ]], [[ @@ -1781,7 +1781,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], b->yy_ch_buf = NULL; } if ( b->yy_ch_buf == NULL ) { - yy_fatal_error("fatal error - scanner input buffer overflow", yyscanner); + yypanic("fatal error - scanner input buffer overflow", yyscanner); } yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; @@ -1817,7 +1817,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { - yy_fatal_error( "out of dynamic memory in yy_get_next_buffer()", yyscanner); + yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); } /* "- 2" to take care of EOB's */ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); @@ -2022,7 +2022,7 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { - yy_fatal_error( "out of dynamic memory in yy_create_buffer()", yyscanner ); + yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); } b->yy_buf_size = size; @@ -2031,7 +2031,7 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) */ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); if ( b->yy_ch_buf == NULL ) { - yy_fatal_error( "out of dynamic memory in yy_create_buffer()", yyscanner ); + yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); } b->yy_is_our_buffer = 1; @@ -2196,7 +2196,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); if ( yyscanner->yy_buffer_stack == NULL ) { - yy_fatal_error( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } memset(yyscanner->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -2216,7 +2216,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); if (yyscanner->yy_buffer_stack == NULL) { - yy_fatal_error( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } /* zero only the new slots.*/ memset(yyscanner->yy_buffer_stack + yyscanner->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2244,7 +2244,7 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) } b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); if ( b == NULL ) { - yy_fatal_error( "out of dynamic memory in yy_scan_buffer()", yyscanner ); + yypanic( "out of dynamic memory in yy_scan_buffer()", yyscanner ); } b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; @@ -2297,7 +2297,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann n = (yy_size_t) (_yybytes_len + 2); buf = (char *) yyalloc( n, yyscanner ); if ( buf == 0 ) { - yy_fatal_error( "out of dynamic memory in yy_scan_bytes()", yyscanner ); + yypanic( "out of dynamic memory in yy_scan_bytes()", yyscanner ); } for ( i = 0; i < _yybytes_len; ++i ) { buf[i] = yybytes[i]; @@ -2306,7 +2306,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann b = yy_scan_buffer( buf, n, yyscanner); if ( b == NULL ) { - yy_fatal_error( "bad buffer in yy_scan_bytes()", yyscanner ); + yypanic( "bad buffer in yy_scan_bytes()", yyscanner ); } /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2336,7 +2336,7 @@ static void yy_push_state(int _new_state, yyscan_t yyscanner) (void *) yyscanner->yy_start_stack, new_size, yyscanner ); } if ( yyscanner->yy_start_stack == NULL ) { - yy_fatal_error( "out of memory expanding start-condition stack", yyscanner); + yypanic( "out of memory expanding start-condition stack", yyscanner); } } yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner); @@ -2351,7 +2351,7 @@ m4_ifdef( [[M4_YY_NO_POP_STATE]],, static void yy_pop_state (yyscan_t yyscanner) { if ( --yyscanner->yy_start_stack_ptr < 0 ) { - yy_fatal_error( "start-condition stack underflow", yyscanner ); + yypanic( "start-condition stack underflow", yyscanner ); } yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner); } @@ -2479,7 +2479,7 @@ void yyset_lineno(int _line_number, yyscan_t yyscanner) { /* lineno is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { - yy_fatal_error( "yyset_lineno called with no buffer", yyscanner ); + yypanic( "yyset_lineno called with no buffer", yyscanner ); } yylineno = _line_number; } @@ -2495,7 +2495,7 @@ void yyset_column(int _column_no, yyscan_t yyscanner) { /* column is only valid if an input buffer exists. */ if (yy_current_buffer() == NULL ) { - yy_fatal_error( "yyset_column called with no buffer", yyscanner ); + yypanic( "yyset_column called with no buffer", yyscanner ); } yycolumn = _column_no; } diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 0b0ad4b..f01f390 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -810,7 +810,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG ); static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG); static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); -static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); +static void yynoreturn yypanic ( const char* msg M4_YY_PROTO_LAST_ARG ); ]]) ]]) @@ -1512,7 +1512,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], m4_ifdef([[M4_MODE_YY_NO_FATAL_ERROR]],,[[ m4_ifdef([[M4_MODE_C_ONLY]], [[ -static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg) { +static void yynoreturn yypanic YYFARGS1(const char*, msg) { M4_YY_DECL_GUTS_VAR(); M4_YY_NOOP_GUTS_VAR(); fprintf( stderr, "%s\n", msg ); @@ -1531,7 +1531,7 @@ void yyFlexLexer::LexerError( const char* msg ) { /* Report a fatal error. */ #ifndef YY_FATAL_ERROR m4_ifdef([[M4_MODE_C_ONLY]], [[ -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) +#define YY_FATAL_ERROR(msg) yypanic( msg M4_YY_CALL_LAST_ARG) ]]) m4_ifdef([[M4_MODE_CXX_ONLY]], [[ #define YY_FATAL_ERROR(msg) LexerError( msg ) diff --git a/src/flexdef.h b/src/flexdef.h index e5bdbc1..f4d6be8 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -351,7 +351,7 @@ struct ctrl_bundle_t { char *postaction; // Code fragment to be inserted after each action char *emit; // Specify target language to emit. // flags corresponding to the huge mass of --no-yy options - bool no_yy_fatal_error; + bool no_yypanic; bool no_yy_push_state; bool no_yy_pop_state; bool no_yy_top_state; diff --git a/src/main.c b/src/main.c index 13891fe..74cdcff 100644 --- a/src/main.c +++ b/src/main.c @@ -1610,7 +1610,7 @@ void readin (void) if (ctrl.no_yyinput) visible_define("M4_MODE_NO_YYINPUT"); - if (ctrl.no_yy_fatal_error) + if (ctrl.no_yypanic) visible_define("M4_YY_NO_FATAL_ERROR"); if (ctrl.no_yy_push_state) visible_define("M4_YY_NO_PUSH_STATE"); diff --git a/src/scan.l b/src/scan.l index 720034e..56f212c 100644 --- a/src/scan.l +++ b/src/scan.l @@ -423,7 +423,7 @@ void context_call(char *); yywrap ctrl.do_yywrap = option_sense; yyread ctrl.noyyread = !option_sense; - yy_fatal_error ctrl.no_yy_fatal_error = !option_sense; + yypanic ctrl.no_yypanic = !option_sense; yy_push_state ctrl.no_yy_push_state = ! option_sense; yy_pop_state ctrl.no_yy_pop_state = ! option_sense; @@ -955,7 +955,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ { "{" ACTION_ECHO; ++bracelevel; "}" ACTION_ECHO; --bracelevel; - yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\) { + yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { context_call(yytext); } [^[:alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 7fcfe5a..2f3ebe6 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -53,10 +53,10 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl yyout = stdout; ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl if((fp = fopen(argv[1],"rb"))== NULL) - YY_FATAL_ERROR("could not open tables file for reading"); + yypanic("could not open tables file for reading"); if(yytables_fload(fp) < 0) - YY_FATAL_ERROR("yytables_fload returned < 0"); + yypanic("yytables_fload returned < 0"); ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') ')dnl table_serialization while( yylex() ) @@ -92,10 +92,10 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl yyset_in ( stdin, lexer); ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl if((fp = fopen(argv[1],"rb"))== NULL) - yy_fatal_error("could not open tables file for reading", lexer); + yypanic("could not open tables file for reading", lexer); if(yytables_fload(fp, yyscanner) < 0) - yy_fatal_error("yytables_fload returned < 0", lexer); + yypanic("yytables_fload returned < 0", lexer); ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') ')dnl table_serialization while( yylex(lexer) ) -- cgit v1.2.1 From 079b2d1c8643174610304f90f711a485d5186f96 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 08:38:46 -0400 Subject: Eliminate YY_BREAK macro, replaced with an m4 hook. --- src/c99-flex.skl | 9 ++------- src/cpp-flex.skl | 12 ++---------- src/parse.y | 2 +- src/scan.l | 4 ++-- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 2c35e4a..bda2d1b 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -78,8 +78,8 @@ m4_define([[M4_HOOK_SET_RULE_SETUP]], [[YY_RULE_SETUP ]]) m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 ]]) -m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 -]]) +m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) +m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) %% [0.0] Make hook macros available to Flex @@ -1056,11 +1056,6 @@ extern int yylex M4_YY_LEX_PROTO; #define YY_USER_ACTION #endif -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - #define YY_RULE_SETUP \ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyscanner->yyleng_r > 0 ) { \ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); \ diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index f01f390..304ce26 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -71,8 +71,8 @@ m4_define([[M4_HOOK_SET_RULE_SETUP]], [[YY_RULE_SETUP ]]) m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 ]]) -m4_define([[M4_HOOK_SET_POSTACTION]], [[#define YY_BREAK $1 -]]) +m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) +m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) %% [0.0] Make hook macros available to Flex @@ -1727,14 +1727,6 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #endif ]]) -m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -[[ -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif -]]) - m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ #define YY_RULE_SETUP \ diff --git a/src/parse.y b/src/parse.y index 809d1ea..8eec1c7 100644 --- a/src/parse.y +++ b/src/parse.y @@ -141,7 +141,7 @@ goal : initlex sect1 sect1end sect2 initforrule else context_call("yyecho()"); - add_action( ";\n\tYY_BREAK]]\n" ); + add_action( ";\n\t]]M4_HOOK_STATE_CASE_BREAK\n" ); } ; diff --git a/src/scan.l b/src/scan.l index 56f212c..3b1a9a3 100644 --- a/src/scan.l +++ b/src/scan.l @@ -942,7 +942,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ ACTION_ECHO; if (bracelevel <= 0 || (doing_codeblock && indented_code)) { if ( doing_rule_action ) - add_action( "\tYY_BREAK]""]\n" ); + add_action( "\t]""]M4_HOOK_STATE_CASE_BREAK\n" ); doing_rule_action = doing_codeblock = false; BEGIN(SECT2); @@ -968,7 +968,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ ACTION_ECHO; if (bracelevel <= 0) { if ( doing_rule_action ) - add_action( "\tYY_BREAK]""]\n" ); + add_action( "\t]""]M4_HOOK_STATE_CASE_BREAK\n" ); doing_rule_action = false; BEGIN(SECT2); -- cgit v1.2.1 From aea2d30573d4d84e9d60ca43739d5a46efb26836 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 09:07:53 -0400 Subject: Finally ever the dependency on the YY_FATAL_ERROR macro. Still supported as a legacy interface in the default back end. --- src/c99-flex.skl | 8 +++----- src/cpp-flex.skl | 4 +++- src/main.c | 2 +- src/parse.y | 11 +++++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index bda2d1b..fa2a413 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -80,6 +80,8 @@ m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 ]]) m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) +m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) +m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) %% [0.0] Make hook macros available to Flex @@ -944,7 +946,7 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) const int YY_EXIT_FAILURE = 2; -m4_ifdef( [[M4_MODE_YY_NO_FATAL_ERROR]],, [[ +m4_ifdef( [[M4_MODE_YY_NO_YYPANIC]],, [[ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ fprintf( stderr, "%s\n", msg ); @@ -952,10 +954,6 @@ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { } ]]) -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yypanic( msg, yyscanner) -#endif - m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 304ce26..6ddead1 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -73,6 +73,8 @@ m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 ]]) m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) +m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1 M4_YY_CALL_LAST_ARG);]]) +m4_define([[M4_HOOK_ECHO]], [[yyecho();]]) %% [0.0] Make hook macros available to Flex @@ -1510,7 +1512,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_EXIT_FAILURE 2 #endif -m4_ifdef([[M4_MODE_YY_NO_FATAL_ERROR]],,[[ +m4_ifdef([[M4_MODE_YY_NO_YYPANIC]],,[[ m4_ifdef([[M4_MODE_C_ONLY]], [[ static void yynoreturn yypanic YYFARGS1(const char*, msg) { M4_YY_DECL_GUTS_VAR(); diff --git a/src/main.c b/src/main.c index 74cdcff..ad2499e 100644 --- a/src/main.c +++ b/src/main.c @@ -1611,7 +1611,7 @@ void readin (void) visible_define("M4_MODE_NO_YYINPUT"); if (ctrl.no_yypanic) - visible_define("M4_YY_NO_FATAL_ERROR"); + visible_define("M4_YY_NO_YYPANIC"); if (ctrl.no_yy_push_state) visible_define("M4_YY_NO_PUSH_STATE"); if (ctrl.no_yy_pop_state) diff --git a/src/parse.y b/src/parse.y index 8eec1c7..55f494e 100644 --- a/src/parse.y +++ b/src/parse.y @@ -135,13 +135,16 @@ goal : initlex sect1 sect1end sect2 initforrule for ( i = 1; i <= lastsc; ++i ) scset[i] = mkbranch( scset[i], def_rule ); + add_action("]]"); + if ( ctrl.spprdflt ) add_action( - "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); - else - context_call("yyecho()"); + "M4_HOOK_FATAL_ERROR(\"flex scanner jammed\")"); + else { + add_action("M4_HOOK_ECHO"); + } - add_action( ";\n\t]]M4_HOOK_STATE_CASE_BREAK\n" ); + add_action( "\n\tM4_HOOK_STATE_CASE_BREAK\n" ); } ; -- cgit v1.2.1 From 29116efd20d33cb41ac87d9fd4e81d0b840a287c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 12:26:40 -0400 Subject: Remove cpp from the way the extra type is handled, use pure m4 instead. Has the effect of making the code a bit smaller when no extra type is born. --- src/c99-flex.skl | 41 ++++++++++++++++++++--------------------- src/cpp-flex.skl | 2 +- src/main.c | 2 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index fa2a413..aa7b76e 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -580,21 +580,10 @@ m4_ifdef( [[M4_YY_NO_UNISTD_H]],, #endif ]]) -m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], -[[ -#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS -]], -[[ -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif -]] -) - /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; + m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[M4_MODE_EXTRA_TYPE yyextra_r;]]) /* The rest are the same as the globals declared in the non-reentrant scanner. */ FILE *yyin_r, *yyout_r; @@ -664,7 +653,9 @@ m4_ifdef( [[]], int yylex_init (yyscan_t* scanner); -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +int yylex_init_extra ( M4_MODE_EXTRA_TYPE user_defined, yyscan_t* scanner); +]]) /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -684,14 +675,16 @@ m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, void yyset_debug ( int debug_flag, yyscan_t yyscanner ); ]]) +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, [[ -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); +M4_MODE_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); ]]) m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, [[ -void yyset_extra ( YY_EXTRA_TYPE user_defined, yyscan_t yyscanner ); +void yyset_extra ( M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner ); +]]) ]]) m4_ifdef( [[M4_YY_NO_GET_IN]],, @@ -2374,14 +2367,16 @@ void yyless(int n, yyscan_t yyscanner) { /* Accessor methods (get/set functions) to struct members. */ -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, [[ +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { - return yyextra; +M4_MODE_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { + return yyscanner->yyextra_r; } ]]) +]]) m4_ifdef( [[M4_YY_NO_GET_LINENO]],, [[ @@ -2451,16 +2446,18 @@ char *yyget_text (yyscan_t yyscanner) { } ]]) +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, [[ /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner) { - yyextra = user_defined ; +void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { + yyscanner->yyextra_r = user_defined ; } ]]) +]]) m4_ifdef( [[M4_YY_NO_SET_LINENO]],, [[ @@ -2588,6 +2585,7 @@ int yylex_init(yyscan_t* ptr_yy_globals) { return yy_init_globals ( *ptr_yy_globals ); } +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl /* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and @@ -2595,7 +2593,7 @@ int yylex_init(yyscan_t* ptr_yy_globals) { * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { +int yylex_init_extra( M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; yyset_extra (yy_user_defined, &dummy_yyguts); @@ -2620,6 +2618,7 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) return yy_init_globals ( *ptr_yy_globals ); } +]]) static int yy_init_globals (yyscan_t yyscanner) { /* diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 6ddead1..19e8d21 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1530,7 +1530,7 @@ void yyFlexLexer::LexerError( const char* msg ) { ]]) ]]) -/* Report a fatal error. */ +/* Report a fatal error. Legacy interface. */ #ifndef YY_FATAL_ERROR m4_ifdef([[M4_MODE_C_ONLY]], [[ #define YY_FATAL_ERROR(msg) yypanic( msg M4_YY_CALL_LAST_ARG) diff --git a/src/main.c b/src/main.c index ad2499e..f662fbc 100644 --- a/src/main.c +++ b/src/main.c @@ -1464,7 +1464,7 @@ void readin (void) visible_define(""); if (extra_type != NULL) - visible_define_str ("M4_EXTRA_TYPE_DEFS", extra_type); + visible_define_str ("M4_MODE_EXTRA_TYPE", extra_type); /* always generate the tablesverify flag. */ visible_define_str ("M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0"); -- cgit v1.2.1 From 9de953f78fc011d8540cab203ae8aa761fb02cf0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 13:01:21 -0400 Subject: In C99, remove more preprocessor dependencies. --- src/c99-flex.skl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index aa7b76e..bfc83e1 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -66,7 +66,7 @@ m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; ]]) m4_define([[M4_HOOK_CONST_DEFINE_BOOL]], [[const bool $1 = $2; ]]) -m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[#define $1 $2 +m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[m4_define($1, [[$2]]) ]]) m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 ]]) -- cgit v1.2.1 From 15948a9b1405e53f7d6fc6e3fedf9ad7b5ca04e0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 15:42:27 -0400 Subject: In C99, process yylex declaration stting directly through m4... ...instead of relying on cpp to do it. This commit also adds a test for correctness of yydecl on all back ends. --- src/c99-flex.skl | 13 +++++-------- src/skeletons.c | 10 ++++++++++ tests/ruleset.am | 20 ++++++++++++++++++-- tests/ruleset.sh | 16 ++++++++++++++-- tests/test-yydecl | 14 -------------- tests/test-yydecl-gen | 29 +++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 26 deletions(-) delete mode 100755 tests/test-yydecl create mode 100755 tests/test-yydecl-gen diff --git a/src/c99-flex.skl b/src/c99-flex.skl index bfc83e1..b20a2bb 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -66,10 +66,8 @@ m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; ]]) m4_define([[M4_HOOK_CONST_DEFINE_BOOL]], [[const bool $1 = $2; ]]) -m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[m4_define($1, [[$2]]) -]]) -m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1 -]]) +m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[m4_define($1, [[$2]])]]) +m4_define([[M4_HOOK_SET_YY_DECL]], [[m4_define([[YY_DECL]], [[$1]])]]) m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1 ]]) m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 @@ -1009,8 +1007,7 @@ const int YY_START_STACK_INCR = 25; /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 +m4_ifdef([[YY_DECL]],, [[m4_dnl m4_define( [[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) m4_define( [[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) @@ -1037,8 +1034,8 @@ m4_ifdef( [[]], extern int yylex M4_YY_LEX_PROTO; -#define YY_DECL int yylex M4_YY_LEX_DECLARATION -#endif /* !YY_DECL */ +m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) +]]) /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. diff --git a/src/skeletons.c b/src/skeletons.c index 6aa3eb0..707455f 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -92,6 +92,16 @@ static bool boneseeker(const char *bone) void backend_by_name(const char *name) { if (name != NULL) { + if (strcmp(name, "nr") == 0) { + backend = &backends[0]; + ctrl.reentrant = false; + goto backend_ok; + } + if (strcmp(name, "r") == 0) { + backend = &backends[0]; + ctrl.reentrant = true; + goto backend_ok; + } for (backend = &backends[0]; backend->skel != NULL; backend++) { if (strcasecmp(skel_property("M4_PROPERTY_BACKEND_NAME"), name) == 0) goto backend_ok; diff --git a/tests/ruleset.am b/tests/ruleset.am index 3c292ea..7b70d20 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -547,11 +547,27 @@ tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $ posixlycorrect_nr.c: posixlycorrect_nr.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< + +test-yydecl-nr.sh$(EXEEXT): test-yydecl-gen + $(SHELL) test-yydecl-gen nr >test-yydecl-nr.sh$(EXEEXT) + chmod a+x test-yydecl-nr.sh$(EXEEXT) + posixlycorrect_r.c: posixlycorrect_r.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< + +test-yydecl-r.sh$(EXEEXT): test-yydecl-gen + $(SHELL) test-yydecl-gen r >test-yydecl-r.sh$(EXEEXT) + chmod a+x test-yydecl-r.sh$(EXEEXT) + posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< + +test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen + $(SHELL) test-yydecl-gen c99 >test-yydecl-c99.sh$(EXEEXT) + chmod a+x test-yydecl-c99.sh$(EXEEXT) + + # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l basic_nr basic_nr.c basic_nr.l ccl_nr ccl_nr.c ccl_nr.l extended_nr extended_nr.c extended_nr.l flexname_nr flexname_nr.c flexname_nr.l lexcompat_nr lexcompat_nr.c lexcompat_nr.l posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posix_nr posix_nr.c posix_nr.l preposix_nr preposix_nr.c preposix_nr.l quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l reject_nr reject_nr.c reject_nr.l tableopts_nr tableopts_nr.c tableopts_nr.l yyunput_nr yyunput_nr.c yyunput_nr.l tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l basic_r basic_r.c basic_r.l ccl_r ccl_r.c ccl_r.l extended_r extended_r.c extended_r.l flexname_r flexname_r.c flexname_r.l posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posix_r posix_r.c posix_r.l preposix_r preposix_r.c preposix_r.l quoteincomment_r quoteincomment_r.c quoteincomment_r.l reject_r reject_r.c reject_r.l tableopts_r tableopts_r.c tableopts_r.l yyunput_r yyunput_r.c yyunput_r.l tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l basic_c99 basic_c99.c basic_c99.l ccl_c99 ccl_c99.c ccl_c99.l extended_c99 extended_c99.c extended_c99.l flexname_c99 flexname_c99.c flexname_c99.l posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posix_c99 posix_c99.c posix_c99.l preposix_c99 preposix_c99.c preposix_c99.l quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l reject_c99 reject_c99.c reject_c99.l tableopts_c99 tableopts_c99.c tableopts_c99.l yyunput_c99 yyunput_c99.c yyunput_c99.l tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh$(EXEEXT) test-yydecl-r.sh$(EXEEXT) test-yydecl-c99.sh$(EXEEXT) +RULESET_REMOVABLES = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh$(EXEEXT) test-yydecl-r.sh$(EXEEXT) test-yydecl-c99.sh$(EXEEXT) test-yydecl-c99.sh$(EXEEXT) diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 16a7428..67fb683 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -1,8 +1,8 @@ #!/bin/sh -# Generate rules to make .l for testing files from rulesets. Also set up SOURCES +# Generate make productions for testing files from rulesets. Also set up SOURCES # variables for link time. Pass it a list of back-end suffixes. # -# This script exists automake isn't able to handle the pattern rules that +# This script exists because automake isn't able to handle the pattern rules that # would be natural to use. Output is written to standard output for # inclusion in a Makefile.am, typically by redirecting the output and # then an automake include directive. @@ -51,6 +51,8 @@ EOF done done +# posixlycorrect is a special case becaae we need to set POSIXLY_CORRECT +# in Flex's environment while these .l files are bein processed. for backend in $* ; do case $backend in nr|r|c99) ext="c" ;; @@ -58,8 +60,18 @@ for backend in $* ; do esac printf "posixlycorrect_${backend}.${ext}: posixlycorrect_${backend}.l \$(FLEX)\n" printf "\t\$(AM_V_LEX)POSIXLY_CORRECT=1 \$(FLEX) \$(TESTOPTS) -o \$@ \$<\n" + echo "" + + echo "test-yydecl-${backend}.sh\$(EXEEXT): test-yydecl-gen" + printf "\t\$(SHELL) test-yydecl-gen ${backend} >test-yydecl-${backend}.sh\$(EXEEXT)\n" + printf "\tchmod a+x test-yydecl-${backend}.sh\$(EXEEXT)\n" + echo "" + + RULESET_TESTS="${RULESET_TESTS} test-yydecl-${backend}.sh\$(EXEEXT)" + RULESET_REMOVABLES="${RULESET_TESTS} test-yydecl-${backend}.sh\$(EXEEXT)" done +echo "" printf "# End generated test rules\n" echo RULESET_TESTS = "${RULESET_TESTS}" diff --git a/tests/test-yydecl b/tests/test-yydecl deleted file mode 100755 index ffeef35..0000000 --- a/tests/test-yydecl +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/sh -# Test %yydecl option of flex in any cpp-based back end - -trap 'rm /tmp/td$$' EXIT HUP INT QUIT TERM -cat >/tmp/td$$ </dev/null ) || (echo "%yydecl test failed." >&2; exit 1) - - - diff --git a/tests/test-yydecl-gen b/tests/test-yydecl-gen new file mode 100755 index 0000000..8e1375a --- /dev/null +++ b/tests/test-yydecl-gen @@ -0,0 +1,29 @@ +#! /bin/sh +# Generate test for the %yydecl option of flex on a specified back end +backend=$1 + +cat </tmp/td\$\$ </dev/null +then + echo "%yydecl test on ${backend} SUCCEEDED" + exit 0 +else + echo "%yydecl test on ${backend} FAILED." >&2; + exit 1 +fi +EOF_OUTER -- cgit v1.2.1 From cbdc123fde857ed61fc450f887684e524e97167e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 18:25:05 -0400 Subject: In C99, de-cpp-izee processing of USER_INIT and RULE_SETUP. Also, fix a harmless compiler warning introced three commits back. --- src/c99-flex.skl | 29 ++++++++++++++--------------- tests/prefix_c99.l | 8 ++++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index b20a2bb..b429923 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -68,14 +68,13 @@ m4_define([[M4_HOOK_CONST_DEFINE_BOOL]], [[const bool $1 = $2; ]]) m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[m4_define($1, [[$2]])]]) m4_define([[M4_HOOK_SET_YY_DECL]], [[m4_define([[YY_DECL]], [[$1]])]]) -m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1 -]]) -m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1 -]]) -m4_define([[M4_HOOK_SET_RULE_SETUP]], [[YY_RULE_SETUP -]]) -m4_define([[M4_HOOK_SET_PREACTION]], [[#define YY_USER_ACTION $1 +m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[m4_define([[YY_OFFSET_TYPE]], [[$1]])]]) +m4_define([[M4_HOOK_SET_USERINIT]], [[m4_define([[YY_USER_INIT]], [[$1]])]]) +m4_define([[M4_HOOK_SET_RULE_SETUP]], [[m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ + rule_check_bol(yyscanner); +]]) YY_USER_ACTION ]]) +m4_define([[M4_HOOK_SET_PREACTION]], [[m4_defiine([[YY_USER_ACTION]], [[$1]])]]) m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) @@ -1044,11 +1043,13 @@ m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) #define YY_USER_ACTION #endif -#define YY_RULE_SETUP \ - m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyscanner->yyleng_r > 0 ) { \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); \ - } \ -]]) YY_USER_ACTION +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ +static void rule_check_bol(yyscan_t yyscanner) { + if ( yyscanner->yyleng_r > 0 ) { \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + } +} +]]) /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. yy_cp and yy_bp are the @@ -1326,9 +1327,7 @@ m4_ifdef( [[]], if ( !yyscanner->yy_init ) { yyscanner->yy_init = true; -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif + m4_ifdef([[YY_USER_INIT]], [[YY_USER_INIT]]) m4_ifdef( [[M4_MODE_USES_REJECT]], [[ diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l index feb29b1..911a105 100644 --- a/tests/prefix_c99.l +++ b/tests/prefix_c99.l @@ -53,7 +53,11 @@ FOO_switch_to_buffer( (yybuffer)0, yyscanner); FOOrestart( (FILE*)0, (yyscan_t )0); - FOOget_extra( (yyscan_t )0 ); + /* Commented out because the C99 back end is more + * careful about not compiling in things it doesn't + * need. + */ + //FOOget_extra( (yyscan_t )0 ); FOOget_in( (yyscan_t )0 ); FOOget_leng( (yyscan_t )0 ); FOOget_out( (yyscan_t )0 ); @@ -61,7 +65,7 @@ FOOlex( (yyscan_t )0 ); FOOlex_destroy( (yyscan_t )0 ); FOOlex_init( (yyscan_t *)0 ); - FOOset_extra( (void *)0, (yyscan_t )0 ); + //FOOset_extra( (void *)0, (yyscan_t )0 ); FOOset_in( (FILE*)0, (yyscan_t )0 ); FOOset_out( (FILE*)0, (yyscan_t )0 ); } -- cgit v1.2.1 From 02237b18b280bf6a7ba4ca22e3b53d8b99b7f011 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 20:49:19 -0400 Subject: Convert handling of USER_ACTION, YY_END_OF_BUFFER_CHAR, YY_STATE_BUF_SIZE... ...to use pure m4, not cpp. --- src/c99-flex.skl | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index b429923..fd96ee6 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -72,7 +72,7 @@ m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[m4_define([[YY_OFFSET_TYPE]], [[$1]])]] m4_define([[M4_HOOK_SET_USERINIT]], [[m4_define([[YY_USER_INIT]], [[$1]])]]) m4_define([[M4_HOOK_SET_RULE_SETUP]], [[m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ rule_check_bol(yyscanner); -]]) YY_USER_ACTION +]]) m4_ifdef([[YY_USER_ACTION]], YY_USER_ACTION) ]]) m4_define([[M4_HOOK_SET_PREACTION]], [[m4_defiine([[YY_USER_ACTION]], [[$1]])]]) m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) @@ -221,7 +221,7 @@ m4preproc_include(`flexint_shared.h') * Anywhere other than C this won't be a thing, * because strings will have an assiciated length field. */ -#define YY_END_OF_BUFFER_CHAR 0 +const int YY_END_OF_BUFFER_CHAR = 0; /* END platform-specific and compiler-specific definitions. */ @@ -244,7 +244,7 @@ typedef struct yyguts_t *yyscan_t; /* The state buf must be large enough to hold one state per character in the main buffer. */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) +m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yy_state_type))]]) typedef struct yy_buffer_state *yybuffer; @@ -1036,13 +1036,6 @@ extern int yylex M4_YY_LEX_PROTO; m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) ]]) -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ static void rule_check_bol(yyscan_t yyscanner) { if ( yyscanner->yyleng_r > 0 ) { \ -- cgit v1.2.1 From dc11ff302062ec7dd69d37811eac1d2be7fe97d0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Oct 2020 23:09:26 -0400 Subject: In C99, assume is available to simplify the code. --- src/c99-flex.skl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index fd96ee6..2971d24 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -34,8 +34,8 @@ m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) %# Macro hooks used by Flex code generators start here -m4_define([[M4_HOOK_INT32]], [[flex_int32_t]]) -m4_define([[M4_HOOK_INT16]], [[flex_int16_t]]) +m4_define([[M4_HOOK_INT32]], [[int32_t]]) +m4_define([[M4_HOOK_INT16]], [[int16_t]]) m4_define([[M4_HOOK_COMMENT_OPEN]], [[/*]]) m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) %# If this is not defined, no trace lines will be generated. @@ -185,8 +185,7 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #include #include #include - -m4preproc_include(`flexint_shared.h') +#include #if defined(__GNUC__) && __GNUC__ >= 3 #define yynoreturn __attribute__((__noreturn__)) @@ -343,7 +342,7 @@ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ m4_ifdef( [[M4_MODE_DEBUG]], [[ #define FLEX_DEBUG ]]) -typedef flex_uint8_t YY_CHAR; +typedef uint8_t YY_CHAR; m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl typedef const struct yy_trans_info *yy_state_type; @@ -386,8 +385,8 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ * This is so we can compile "sizeof(struct yy_trans_info)" * in any scanner. */ - flex_int32_t yy_verify; - flex_int32_t yy_nxt; + int32_t yy_verify; + int32_t yy_nxt; ]]) }; -- cgit v1.2.1 From 59c26779eb4e10130658f8067566c6813a086c54 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Oct 2020 00:18:25 -0400 Subject: In C99, make --nounistd a no-op. Explain this in the manual. --- doc/flex.texi | 11 ++++++++--- src/c99-flex.skl | 12 +----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 52edef6..908a12b 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -3127,12 +3127,17 @@ scanner, which simply calls @code{yylex()}. This option implies suppresses inclusion of the non-ANSI header file @file{unistd.h}. This option is meant to target environments in which @file{unistd.h} does not exist. Be aware that certain options may cause flex to generate code that relies on functions -normally found in @file{unistd.h}, (e.g. @code{isatty()}, @code{read()}.) +normally found in @file{unistd.h}, (e.g. @code{isatty()}.) If you wish to use these functions, you will have to inform your compiler where to find them. -@xref{option-always-interactive}. @xref{option-read}. - +This option is obsolete, as after Flex was originally written +@file{unistd.h} became part of the Single Unix Specification and is +consequently everywhere; thuas there is no reason to use this option +on modern systems. It is included so as not to break compatibility +with old build scripts, and will have no effect on backends other than +the default C one. +@xref{option-always-interactive}. @xref{option-read}. @anchor{option-yyclass} @opindex ---yyclass diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 2971d24..13a66e1 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -186,6 +186,7 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #include #include #include +#include #if defined(__GNUC__) && __GNUC__ >= 3 #define yynoreturn __attribute__((__noreturn__)) @@ -565,17 +566,6 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ M4_YY_SC_DEFS -m4_ifdef( [[M4_YY_NO_UNISTD_H]],, -[[ -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif -]]) - /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ -- cgit v1.2.1 From 8bf1889ca76d66c37d8ea01c087a693aa296b5c6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Oct 2020 08:39:56 -0400 Subject: More de-preprocessorization. --- doc/flex.texi | 4 ++++ src/c99-flex.skl | 42 +++++++++++++++++------------------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 908a12b..53d5707 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -8985,6 +8985,10 @@ necessary. @item FLEX_SCANNER: Not neaningful outside of the C back end, and not defined. +@item +FLEX_DEBUG: Outside the default C back end, this is a constant of type +bool rather rthan a preprocessor symbol. + @item YY_FLEX_SUBMINOR_VERSION: Its behavior an't be replivated without the C preprocessor. Test for YY_FLEX_SUBMINOR_VERSION instead. diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 13a66e1..ae0ed8e 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -160,7 +160,7 @@ m4_ifelse(M4_MODE_PREFIX,yy,, %# ENDS prefix machinery -/* START platform-specific and compiler-specific definitions. */ +/* STARTS platform-specific and compiler-specific definitions. */ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , [[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , @@ -180,13 +180,14 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , # define _POSIX_C_SOURCE 1 /* Required for fileno() */ # define _POSIX_SOURCE 1 #endif]])]]) + #include #include #include #include #include #include -#include +#include /* requred for isatty() */ #if defined(__GNUC__) && __GNUC__ >= 3 #define yynoreturn __attribute__((__noreturn__)) @@ -194,7 +195,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #define yynoreturn #endif -/* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ @@ -204,26 +204,19 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #endif /* __ia64__ */ #endif -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - /* * Anywhere other than C this won't be a thing, * because strings will have an assiciated length field. */ const int YY_END_OF_BUFFER_CHAR = 0; -/* END platform-specific and compiler-specific definitions. */ +/* ENDS platform-specific and compiler-specific definitions. */ + +/* Size of default input buffer. We want to be able to fit two + * OS-level reads, but efficiency gains as the buffer size + * increases fall off after that + */ +const int YY_BUF_SIZE = 2 * YY_READ_BUF_SIZE; /* Returned upon end-of-file. */ const int YY_NULL = 0; @@ -240,7 +233,7 @@ m4_define([[YY_SC_TO_UI]], [[((YY_CHAR)($1))]]) typedef struct yyguts_t *yyscan_t; /* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) /* The state buf must be large enough to hold one state per character in the main buffer. */ @@ -337,12 +330,13 @@ void yyfree ( void *, yyscan_t yyscanner ); /* Begin user sect3 */ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ -#define M4_MODE_PREFIX[[wrap]](yyscanner) (/*CONSTCOND*/1) +int M4_MODE_PREFIX[[wrap]](yyscan_t yyscanner) { + return /*CONSTCOND*/1; +} ]]) -m4_ifdef( [[M4_MODE_DEBUG]], [[ -#define FLEX_DEBUG -]]) +const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); + typedef uint8_t YY_CHAR; m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl @@ -350,7 +344,6 @@ typedef const struct yy_trans_info *yy_state_type; ]], [[ typedef int yy_state_type; ]]) -m4_ifdef([[M4_MODE_LEX_COMPAT]], [[#define YY_FLEX_LEX_COMPAT]]) /* Watch out: yytext_ptr is a variable when yytext is an array, * but it's a macro when yytext is a pointer. @@ -399,8 +392,7 @@ static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { M4_HOOK_NXT_BODY ]], [[ -#undef YY_NXT_LOLEN -#define YY_NXT_LOLEN ([[]]M4_HOOK_NXT_ROWS[[]]) +m4_ifdef([[YY_NXT_LOLEN]], [[(M4_HOOK_NXT_ROWS)]]) static const M4_HOOK_NXT_TYPE *yy_nxt =0; ]]) -- cgit v1.2.1 From 95efae546902ea23fb46aed9f26181e1b2cb2f6f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Oct 2020 17:17:47 -0400 Subject: Abolish a platform microtweak after consulting with Will Estes. --- src/c99-flex.skl | 17 ++++++++--------- src/cpp-flex.skl | 35 ++++++++++++++--------------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index ae0ed8e..9b1d721 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -195,15 +195,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , #define yynoreturn #endif -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - /* * Anywhere other than C this won't be a thing, * because strings will have an assiciated length field. @@ -212,6 +203,14 @@ const int YY_END_OF_BUFFER_CHAR = 0; /* ENDS platform-specific and compiler-specific definitions. */ +/* + * Amount of stuff to slurp up with each read. + * We assume the stdio library has already + * chosen a fit size foe whatever platform + * we're running on. + */ +#define YY_READ_BUF_SIZE BUFSIZ + /* Size of default input buffer. We want to be able to fit two * OS-level reads, but efficiency gains as the buffer size * increases fall off after that diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 19e8d21..e3c15fb 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -416,19 +416,6 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define YY_END_OF_BUFFER_CHAR 0 ]]) -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* The state buf must be large enough to hold one state per character in the main buffer. @@ -1476,14 +1463,20 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) ]]) -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ +/* + * Amount of stuff to slurp up with each read. + * We assume the stdio library has already + * chosen a fit size foe whatever platform + * we're running on. + */ +#define YY_READ_BUF_SIZE BUFSIZ + +/* Size of default input buffer. We want to be able to fit two + * OS-level reads, but efficiency gains as the buffer size + * increases fall off after that + */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE (2 * YY_READ_BUF_SIZE) #endif m4_ifdef( [[M4_YY_NOT_IN_HEADER]], -- cgit v1.2.1 From 4cc8835d3ce5924e369c4a6f542fc5e736643cac Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Oct 2020 20:34:14 -0400 Subject: Add %option bufsize, required for testing under non-C targets... ...since we can't count on the C preprocessor to do it. --- doc/flex.texi | 15 +++++++++++++-- src/c99-flex.skl | 4 ++-- src/cpp-flex.skl | 2 +- src/flexdef.h | 6 +++++- src/gen.c | 10 ++++++++++ src/main.c | 3 +++ src/parse.y | 6 ++++-- src/scan.l | 3 ++- tests/mem_c99.l | 2 +- 9 files changed, 41 insertions(+), 10 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 53d5707..5921904 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -2646,8 +2646,8 @@ is substituted with the appropriate prefix. The @samp{--header-file} option is not compatible with the @samp{--c++} option, since the C++ scanner provides its own header in @file{yyFlexLexer.h}. - -This option will generally be a no-op under other target languages. +This option will generally be a no-op under target languages other +than C. @anchor{option-outfile} @@ -3435,6 +3435,14 @@ warn about certain things. In particular, if the default rule can be matched but no default rule has been given, the flex will warn you. We recommend using this option always. +@anchor{option-bufsize} +@opindex bufsize +@item @code{%option bufsize} +Forces the input buffer size, which is normally set to a good default +for your platform based on what the standard buffered-IO library in +your traget language does. This option is mainly intended for stress-testing +memory allocation in generated scanners; you probably shouldn't set it. + @end table @node Miscellaneous Options, , Debugging Options, Scanner Options @@ -8993,6 +9001,9 @@ bool rather rthan a preprocessor symbol. YY_FLEX_SUBMINOR_VERSION: Its behavior an't be replivated without the C preprocessor. Test for YY_FLEX_SUBMINOR_VERSION instead. +@item +YY_BUF_SIZE: replaced by @code{%option bufsize}. + @end itemize @node Indices, , Appendices, Top diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 9b1d721..8d0f192 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -197,7 +197,7 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , /* * Anywhere other than C this won't be a thing, - * because strings will have an assiciated length field. + * because strings will have an associated length field. */ const int YY_END_OF_BUFFER_CHAR = 0; @@ -215,7 +215,7 @@ const int YY_END_OF_BUFFER_CHAR = 0; * OS-level reads, but efficiency gains as the buffer size * increases fall off after that */ -const int YY_BUF_SIZE = 2 * YY_READ_BUF_SIZE; +const int YY_BUF_SIZE = m4_ifdef([[M4_MODE_YY_BUFSIZE]], [[M4_MODE_YY_BUFSIZE]], [[2 * YY_READ_BUF_SIZE]]); /* Returned upon end-of-file. */ const int YY_NULL = 0; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index e3c15fb..5600886 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1476,7 +1476,7 @@ m4_define( [[M4_YY_NO_TOP_STATE]]) * increases fall off after that */ #ifndef YY_BUF_SIZE -#define YY_BUF_SIZE (2 * YY_READ_BUF_SIZE) +#define YY_BUF_SIZE (m4_ifdef([[M4_MODE_YY_BUFSIZE]], [[M4_MODE_YY_BUFSIZE]], [[2 * YY_READ_BUF_SIZE]])) #endif m4_ifdef( [[M4_YY_NOT_IN_HEADER]], diff --git a/src/flexdef.h b/src/flexdef.h index f4d6be8..db7d4e3 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -310,7 +310,8 @@ struct ctrl_bundle_t { bool always_interactive;// always use cheacter-by-character input FILE *backing_up_file; // file to summarize backing-up states to bool bison_bridge_lval; // (--bison-bridge), bison pure calling convention. - bool bison_bridge_lloc; // (--bison-locations), bison yylloc. + bool bison_bridge_lloc; // (--bison-locations), bison yylloc. + size_t bufsize; // input buffer size bool C_plus_plus; // (-+ flag) generate a C++ scanner class int csize; // size of character set for the scanner // 128 for 7-bit chars and 256 for 8-bit @@ -801,6 +802,9 @@ extern void visible_define (const char *); /* And again, with an explicit value part. */ extern void visible_define_str (const char *, const char *); +/* This time the value part is an int */ +extern void visible_define_int (const char *, const int); + /* Generate full speed compressed transition table. */ extern void genctbl(void); diff --git a/src/gen.c b/src/gen.c index 62b20b6..d6d3f9b 100644 --- a/src/gen.c +++ b/src/gen.c @@ -900,6 +900,16 @@ void visible_define_str (const char *symname, const char *val) outc ('\n'); } +void visible_define_int (const char *symname, const int val) +{ + char nbuf[24], buf[128]; + snprintf(nbuf, sizeof(nbuf), "%d", val); + out_m4_define(symname, nbuf); + snprintf(buf, sizeof(buf), "%s = %d", symname, val); + comment(buf); + outc ('\n'); +} + /* make_tables - generate transition tables */ diff --git a/src/main.c b/src/main.c index f662fbc..8abb2e6 100644 --- a/src/main.c +++ b/src/main.c @@ -1610,6 +1610,9 @@ void readin (void) if (ctrl.no_yyinput) visible_define("M4_MODE_NO_YYINPUT"); + if (ctrl.bufsize != 0) + visible_define_int("M4_MODE_YY_BUFSIZE", ctrl.bufsize); + if (ctrl.no_yypanic) visible_define("M4_YY_NO_YYPANIC"); if (ctrl.no_yy_push_state) diff --git a/src/parse.y b/src/parse.y index 55f494e..25fd697 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3,7 +3,7 @@ %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP %token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE %token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC TOK_YYDECL TOK_PREACTION TOK_POSTACTION -%token TOK_USERINIT TOK_EMIT +%token TOK_USERINIT TOK_EMIT TOK_BUFSIZE %token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH %token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT @@ -218,8 +218,10 @@ option : TOK_OUTFILE '=' NAME { ctrl.preaction = xstrdup(nmstr); } | TOK_POSTACTION '=' NAME { ctrl.postaction = xstrdup(nmstr); } + | TOK_BUFSIZE '=' TOK_NUMERIC + { ctrl.bufsize = nmval; } | TOK_EMIT '=' NAME - { ctrl.emit = xstrdup(nmstr); backend_by_name(ctrl.emit); } + { ctrl.emit = xstrdup(nmstr); backend_by_name(ctrl.emit); } | TOK_USERINIT '=' NAME { ctrl.userinit = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME diff --git a/src/scan.l b/src/scan.l index 3b1a9a3..3b82d21 100644 --- a/src/scan.l +++ b/src/scan.l @@ -373,7 +373,7 @@ void context_call(char *); bison-bridge ctrl.bison_bridge_lval = option_sense; bison-locations { if((ctrl.bison_bridge_lloc = option_sense)) ctrl.bison_bridge_lval = true; - } + } "c++" ctrl.C_plus_plus = option_sense; caseful|case-sensitive sf_set_case_ins(!option_sense); caseless|case-insensitive sf_set_case_ins(option_sense); @@ -456,6 +456,7 @@ void context_call(char *); yyget_lloc ctrl.no_yyget_lloc = ! option_sense; yyset_lloc ctrl.no_yyset_lloc = ! option_sense; + bufsize return TOK_BUFSIZE; emit return TOK_EMIT; extra-type return TOK_EXTRA_TYPE; outfile return TOK_OUTFILE; diff --git a/tests/mem_c99.l b/tests/mem_c99.l index a33589c..fefe67b 100644 --- a/tests/mem_c99.l +++ b/tests/mem_c99.l @@ -39,7 +39,7 @@ %} -%option emit="c99" +%option emit="c99" bufsize=8 %option 8bit prefix="test" %option nounput nomain noyywrap noinput noyy_top_state %option warn stack nodefault -- cgit v1.2.1 From f4de7a57a7f585f9570ddc2d9c8974f3ee01f4cc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 30 Oct 2020 19:15:16 -0400 Subject: Fix a minor bug in gathering removables. --- tests/ruleset.am | 4 ++-- tests/ruleset.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ruleset.am b/tests/ruleset.am index 7b70d20..8060816 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -568,6 +568,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh$(EXEEXT) test-yydecl-r.sh$(EXEEXT) test-yydecl-c99.sh$(EXEEXT) -RULESET_REMOVABLES = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh$(EXEEXT) test-yydecl-r.sh$(EXEEXT) test-yydecl-c99.sh$(EXEEXT) test-yydecl-c99.sh$(EXEEXT) +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh test-yydecl-c99.sh diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 67fb683..99788ad 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -67,8 +67,8 @@ for backend in $* ; do printf "\tchmod a+x test-yydecl-${backend}.sh\$(EXEEXT)\n" echo "" - RULESET_TESTS="${RULESET_TESTS} test-yydecl-${backend}.sh\$(EXEEXT)" - RULESET_REMOVABLES="${RULESET_TESTS} test-yydecl-${backend}.sh\$(EXEEXT)" + RULESET_TESTS="${RULESET_TESTS} test-yydecl-${backend}.sh" + RULESET_REMOVABLES="${RULESET_TESTS} test-yydecl-${backend}.sh" done echo "" -- cgit v1.2.1 From 48d47f6423b2596e666ab96e4eaad2a8602d9ff8 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Oct 2020 22:39:59 -0400 Subject: Convert yyreject() from a cpp macro to an m4 macro. --- src/c99-flex.skl | 35 +++++++++++++---------------------- src/scan.l | 3 +++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 8d0f192..d4e914c 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -80,6 +80,19 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) +%# This needs to be a macro hook rather than a procedure because of the goto at the end +m4_define([[M4_HOOK_YYREJECT]], [[ + *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ + yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ + yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ + yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ +]]) + ++yyscanner->yy_lp; + goto find_rule; +]]) + %% [0.0] Make hook macros available to Flex const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; @@ -1143,28 +1156,6 @@ m4_ifdef( [[M4_MODE_YYLINENO]], [[ } #define yy_at_bol() (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag) -m4_ifdef( [[M4_MODE_USES_REJECT]],[[ -%# Can't be given the context-arg treatment due to the goto. -#define yyreject() \ -{ \ -*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ \ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ -yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ \ -yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ \ -]]) \ -++yyscanner->yy_lp; \ -goto find_rule; \ -} -]]) -m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ -/* The intent behind this definition is that it'll catch - * any uses of yyreject() which flex missed. - */ -#define yyreject() reject_used_but_not_detected -]]) - m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) diff --git a/src/scan.l b/src/scan.l index 3b82d21..9bd7233 100644 --- a/src/scan.l +++ b/src/scan.l @@ -959,6 +959,9 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { context_call(yytext); } + yyreject\(\) { + add_action("]]M4_HOOK_YYREJECT[["); + } [^[:alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; {NAME} ACTION_ECHO; "'"([^''\\\n]|\\.)"'" ACTION_ECHO; /* character constant */ -- cgit v1.2.1 From 076ee33fc4a815f8a35ff88c56944cdeb5b692d6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Oct 2020 22:54:55 -0400 Subject: More small steps towards taking cpp out of the required pipeline. --- src/c99-flex.skl | 70 ++++++++++++++++++++++---------------------------------- src/cpp-flex.skl | 4 ---- src/main.c | 11 ++++++--- 3 files changed, 35 insertions(+), 50 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index d4e914c..e880bcc 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -55,9 +55,9 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, cp, bp); /* set up yytext */]]) m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */]]) m4_define([[M4_HOOK_CHAR_REWIND]], [[YY_G(yy_c_buf_p) = yy_cp -= $1;]]) -m4_define([[M4_HOOK_LINE_REWIND]], [[YY_LINENO_REWIND_TO(yy_cp - $1);]]) +m4_define([[M4_HOOK_LINE_REWIND]], [[yy_lineno_rewind_to(yy_cp, yy_cp - $1, yyscanner);]]) m4_define([[M4_HOOK_CHAR_FORWARD]], [[YY_G(yy_c_buf_p) = yy_cp = yy_bp + $1;]]) -m4_define([[M4_HOOK_LINE_FORWARD]], [[YY_LINENO_REWIND_TO(yy_bp + $1);]]) +m4_define([[M4_HOOK_LINE_FORWARD]], [[yy_lineno_rewind_to(yy_cp, yy_bp + $1, yyscanner);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; ]]) m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yy_state_type $1 = $2; @@ -222,7 +222,7 @@ const int YY_END_OF_BUFFER_CHAR = 0; * chosen a fit size foe whatever platform * we're running on. */ -#define YY_READ_BUF_SIZE BUFSIZ +const int YY_READ_BUF_SIZE = BUFSIZ; /* Size of default input buffer. We want to be able to fit two * OS-level reads, but efficiency gains as the buffer size @@ -559,13 +559,6 @@ static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; ]]) -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#ifndef YYLMAX -#define YYLMAX 8192 -#endif - -]]) - %% [3.0] static declarations conditional on mode switches go here M4_YY_SC_DEFS @@ -1064,6 +1057,28 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ yyscanner->yy_c_buf_p = yy_cp; } +m4_ifdef( [[M4_MODE_YYLINENO]], [[ +/* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro + * and we can get at yy_act */ +static void yy_less_lineno(int n, yyscan_t yyscanner) { + int yyl; + for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { + if ( yyscanner->yytext_r[yyl] == '\n' ) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno--; + } + } +} + +static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { + const char *p; + for ( p = yy_cp-1; p >= dst; --p) { + if ( *p == '\n' ) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno--; + } + } +} +]]) + /* START access macros for use in actions */ #define yyin yyscanner->yyin_r @@ -1080,44 +1095,13 @@ static void yybumpline( yyscan_t yyscanner) { yycolumn=0; } -m4_ifdef( [[M4_MODE_YYLINENO]], [[ -/* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ -#define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { \ - if ( yyscanner->yytext_r[yyl] == '\n' ) { \ - --yylineno;\ - } \ - } \ - }while(0) -#define YY_LINENO_REWIND_TO(dst) \ - do {\ - const char *p;\ - for ( p = yy_cp-1; p >= (dst); --p) { \ - if ( *p == '\n' ) { \ - --yylineno;\ - } \ - } \ - }while(0) -]], -[[ -#define YY_LESS_LINENO(n) -#define YY_LINENO_REWIND_TO(ptr) -]]) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ + m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(yyless_macro_arg, yyscanner);]]) \ *yy_cp = yyscanner->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyscanner->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ @@ -2317,7 +2301,7 @@ static int yy_top_state (yyscan_t yyscanner) #undef yyless void yyless(int n, yyscan_t yyscanner) { /* Undo effects of setting up yytext. */ - YY_LESS_LINENO(n); + m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(n, yyscanner);]]) yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yy_hold_char; yyscanner->yy_c_buf_p = yyscanner->yytext_r + n; yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 5600886..706788e 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1127,10 +1127,6 @@ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_C_ONLY]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#ifndef YYLMAX -#define YYLMAX 8192 -#endif - m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ char yytext[YYLMAX]; char *yytext_ptr; diff --git a/src/main.c b/src/main.c index 8abb2e6..9de04c8 100644 --- a/src/main.c +++ b/src/main.c @@ -729,12 +729,15 @@ void flexinit (int argc, char **argv) yymore_used = continued_action = false; in_rule = reject = false; yymore_really_used = reject_really_used = trit_unspecified; + ctrl.do_main = trit_unspecified; ctrl.interactive = ctrl.csize = trit_unspecified; ctrl.do_yywrap = ctrl.gen_line_dirs = ctrl.usemecs = ctrl.useecs = true; ctrl.reentrant = ctrl.bison_bridge_lval = ctrl.bison_bridge_lloc = false; env.performance_hint = 0; ctrl.prefix = "yy"; + ctrl.yylmax = BUFSIZ; + tablesext = tablesverify = false; gentables = true; tablesfilename = tablesname = NULL; @@ -1308,9 +1311,11 @@ void readin (void) out_str ("M4_HOOK_SET_POSTACTION(%s)\n", ctrl.postaction); } - if (ctrl.yylmax != 0) { - out_dec ("M4_HOOK_CONST_DEFINE_UINT(YYLMAX, %d)\n", ctrl.yylmax); - } + /* This has to be a stright textual substitution rather + * than a constant declaration because in C a const is + * not const enough to be a static array bound. + */ + out_dec ("m4_define([[YYLMAX]], [[%d]])\n", ctrl.yylmax); /* Dump the user defined preproc directives. */ if (userdef_buf.elts) -- cgit v1.2.1 From 3fe9c68941a7c74f461658c70c12fe886438d505 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 31 Oct 2020 04:25:15 -0400 Subject: m4ize handling of yyterminate, and translate another stray #define. --- doc/flex.texi | 17 ++++++++++++++--- src/c99-flex.skl | 16 +++++----------- src/cpp-flex.skl | 4 ++++ src/flexdef.h | 3 ++- src/main.c | 3 +++ src/parse.y | 4 +++- src/scan.l | 15 +++++++++------ 7 files changed, 40 insertions(+), 22 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 5921904..0f71421 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1497,9 +1497,8 @@ also called when an end-of-file is encountered. It may be redefined. When the target language is C/C++, @code{yyterminate()} is a macro. Redefining it using the C/C++ preprocessor in your definitions section is allowed, but not recommended as doing this makes code more -difficult to port out of C/C++. In other target languages you can define -@code{yyterminate()} as a function; Flex will notice this and not -generate a default into the scanner. +difficult to port out of C/C++. In other target languages you can +swt whatt yyterminate() explants to wih @code{%opyion yyterminate}. @node Generated Scanner, Start Conditions, Actions, Top @chapter The Generated Scanner @@ -3119,6 +3118,13 @@ scanner, which simply calls @code{yylex()}. This option implies @code{noyywrap} (see below). +@anchor{option-yyterminate} +@opindex yyterminate +@hkindex yyterminate +@item @code{%option yyterminate} +This is a sting-valuued option with which you can specify an expansion +of the yyterminate() hook. whuch normally vaauses the generated +scanner to return 0 as an end-of-infit indication. @anchor{option-nounistd} @opindex ---nounistd @@ -9004,6 +9010,11 @@ C preprocessor. Test for YY_FLEX_SUBMINOR_VERSION instead. @item YY_BUF_SIZE: replaced by @code{%option bufsize}. +@item: +yyterminate(): Backends that don't use the C preprocessor cannot +support redefinining this hook with #define. Instead, set it with +the @code{yyterminate} option. + @end itemize @node Indices, , Appendices, Top diff --git a/src/c99-flex.skl b/src/c99-flex.skl index e880bcc..5454fc4 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -80,9 +80,11 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) +m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) + %# This needs to be a macro hook rather than a procedure because of the goto at the end -m4_define([[M4_HOOK_YYREJECT]], [[ - *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ +m4_define([[yyreject()]], [[ + *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext $1 */ yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ @@ -361,7 +363,7 @@ typedef int yy_state_type; * but it's a macro when yytext is a pointer. */ m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yytext_ptr yytext_r +m4_define([[yytext_ptr]], [[yytext_r]]) ]]) %% [1.0] DFA @@ -978,14 +980,6 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ } ]]) -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - /* Number of entries by which start-condition stack grows. */ const int YY_START_STACK_INCR = 25; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 706788e..1481def 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -76,6 +76,8 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1 M4_YY_CALL_LAST_ARG);]]) m4_define([[M4_HOOK_ECHO]], [[yyecho();]]) +m4_ifdef([[M4_MODE_YYTERMINATE]], [[m4_define([[yyterminate]], [[M4_MODE_YYTERMINATE]])]]) + %% [0.0] Make hook macros available to Flex m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl @@ -1598,6 +1600,7 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ ]]) ]]) +m4_ifdef( [[M4_MODE_YYTERMINATE]], , [[ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -1608,6 +1611,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], #define yyterminate() return YY_NULL #endif ]]) +]]) /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR diff --git a/src/flexdef.h b/src/flexdef.h index db7d4e3..8555e1e 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -351,8 +351,9 @@ struct ctrl_bundle_t { char *preaction; // Code fragment to be inserted before each action char *postaction; // Code fragment to be inserted after each action char *emit; // Specify target language to emit. + char *yyterminate; // Set a non-default termination hook. + bool no_yypanic; // if true, no not generate default yypanic function // flags corresponding to the huge mass of --no-yy options - bool no_yypanic; bool no_yy_push_state; bool no_yy_pop_state; bool no_yy_top_state; diff --git a/src/main.c b/src/main.c index 9de04c8..f0f41ae 100644 --- a/src/main.c +++ b/src/main.c @@ -1618,6 +1618,9 @@ void readin (void) if (ctrl.bufsize != 0) visible_define_int("M4_MODE_YY_BUFSIZE", ctrl.bufsize); + if (ctrl.yyterminate != NULL) + visible_define_str("M4_MODE_YYTERMINATE", ctrl.yyterminate); + if (ctrl.no_yypanic) visible_define("M4_YY_NO_YYPANIC"); if (ctrl.no_yy_push_state) diff --git a/src/parse.y b/src/parse.y index 25fd697..f6d11cc 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3,7 +3,7 @@ %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP %token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE %token TOK_TABLES_FILE TOK_YYLMAX TOK_NUMERIC TOK_YYDECL TOK_PREACTION TOK_POSTACTION -%token TOK_USERINIT TOK_EMIT TOK_BUFSIZE +%token TOK_USERINIT TOK_EMIT TOK_BUFSIZE TOK_YYTERMINATE %token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH %token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT @@ -224,6 +224,8 @@ option : TOK_OUTFILE '=' NAME { ctrl.emit = xstrdup(nmstr); backend_by_name(ctrl.emit); } | TOK_USERINIT '=' NAME { ctrl.userinit = xstrdup(nmstr); } + | TOK_YYTERMINATE '=' NAME + { ctrl.yyterminate = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME { tablesext = true; tablesfilename = xstrdup(nmstr); } ; diff --git a/src/scan.l b/src/scan.l index 9bd7233..e71a364 100644 --- a/src/scan.l +++ b/src/scan.l @@ -311,7 +311,7 @@ void context_call(char *); <> { linenum = brace_start_line; synerr(_("Unmatched '{'")); - yyterminate(); + return YY_NULL; } } @@ -423,7 +423,7 @@ void context_call(char *); yywrap ctrl.do_yywrap = option_sense; yyread ctrl.noyyread = !option_sense; - yypanic ctrl.no_yypanic = !option_sense; + yypanic ctrl.no_yypanic = !option_sense; yy_push_state ctrl.no_yy_push_state = ! option_sense; yy_pop_state ctrl.no_yy_pop_state = ! option_sense; @@ -464,6 +464,7 @@ void context_call(char *); yyclass return TOK_YYCLASS; yylmax return TOK_YYLMAX; yydecl return TOK_YYDECL; + yyterminate return TOK_YYTERMINATE; pre-action return TOK_PREACTION; post-action return TOK_POSTACTION; user-init return TOK_USERINIT; @@ -525,7 +526,7 @@ void context_call(char *); <> { mark_prolog(); sectnum = 0; - yyterminate(); /* to stop the parser */ + return YY_NULL; /* to stop the parser */ } } @@ -952,15 +953,17 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ } - /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */ + /* yyreject and yymore() are checked for above, in PERCENT_BRACE_ACTION */ { "{" ACTION_ECHO; ++bracelevel; "}" ACTION_ECHO; --bracelevel; yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { context_call(yytext); } - yyreject\(\) { - add_action("]]M4_HOOK_YYREJECT[["); + yyreject\(\)|yyterminate\(\)|yyless\({FUNARGS}\) { + add_action("]""]"); + add_action(yytext); + add_action("[""["); } [^[:alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; {NAME} ACTION_ECHO; -- cgit v1.2.1 From 2b5ef23d7043366b887d2207b5d085c25acbd6c7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 31 Oct 2020 11:59:59 -0400 Subject: Modify the reject.rules ruleset so it actually tests yyreject(). This turns up the fact that m4ization of yyrehect() didn't work, so we back that change out. --- src/c99-flex.skl | 35 ++++++++++++++++++++++------------- src/scan.l | 2 +- tests/reject.rules | 6 +++++- tests/testmaker.m4 | 11 +++++++++-- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 5454fc4..7bace82 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -82,19 +82,6 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) -%# This needs to be a macro hook rather than a procedure because of the goto at the end -m4_define([[yyreject()]], [[ - *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext $1 */ - yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ - yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ - yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ -]]) - ++yyscanner->yy_lp; - goto find_rule; -]]) - %% [0.0] Make hook macros available to Flex const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; @@ -1134,6 +1121,28 @@ static void yybumpline( yyscan_t yyscanner) { } #define yy_at_bol() (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag) +m4_ifdef( [[M4_MODE_USES_REJECT]],[[ +%# Can't be given the context-arg treatment due to the goto. +#define yyreject() \ +{ \ +*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ \ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ +yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ \ +yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ \ +]]) \ +++yyscanner->yy_lp; \ +goto find_rule; \ +} +]]) +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +/* The intent behind this definition is that it'll catch + * any uses of yyreject() which flex missed. + */ +#define yyreject() reject_used_but_not_detected +]]) + m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) diff --git a/src/scan.l b/src/scan.l index e71a364..9ea52f2 100644 --- a/src/scan.l +++ b/src/scan.l @@ -960,7 +960,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { context_call(yytext); } - yyreject\(\)|yyterminate\(\)|yyless\({FUNARGS}\) { + yyterminate\(\)|yyless\({FUNARGS}\) { add_action("]""]"); add_action(yytext); add_action("[""["); diff --git a/tests/reject.rules b/tests/reject.rules index 4539371..2fab9ae 100644 --- a/tests/reject.rules +++ b/tests/reject.rules @@ -20,13 +20,17 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ +/* + * Test yyreject() by seeing if we jump out of the main rule below + * rather than reaching the abort. + */ %option 8bit %option nounput nomain noyywrap noinput %option warn reject %% -. {M4_TEST_ECHO} +. {M4_TEST_REJECT M4_TEST_FAILMESSAGE} .|\n ; %% diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 2f3ebe6..fff8962 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -9,14 +9,18 @@ dnl separate back ends - non-reentrant and reentrant C through dnl the default cpp skeleton. The c99 backend is treated here dnl as re-eentrant C, but may have a different skeleton file. dnl -dnl The purpose of this file is to properly set three macros: +dnl The purpose of this file is to properly set these macros: dnl dnl M4_TEST_PREAMBLE = the contyents of s top secton, if required, and dnl the emit option required to srt the back end. dnl dnl M4_TEST_COMPRESSION = compression option. dnl -dnl M4_TEST_ECHO = echo the token buffer and continue. +dnl M4_TEST_ECHO = echo the token buffer and continue, may add +dnl a statement terminator if target language requires it. +dnl +dnl M4_TEST_REJECT = echo the token buffer and continue, may add +dnl a statement terminator if target language requires it. dnl dnl M4_TEST_FAILMESSAGE = a line of code required to issue dnl a dnl failure notification to standard error and exit with a failure status. @@ -42,6 +46,7 @@ define(`M4_TEST_PREAMBLE', `dnl %} ')dnl close preamble define(`M4_TEST_ECHO', `yyecho();') +define(`M4_TEST_REJECT', `yyreject();') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) @@ -79,6 +84,7 @@ define(`M4_TEST_PREAMBLE', `dnl %} ')dnl close preamble define(`M4_TEST_ECHO', `yyecho();') +define(`M4_TEST_REJECT', `yyreject();') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) @@ -126,6 +132,7 @@ import ( %option emit="go" ')dnl close preamble define(`M4_TEST_ECHO', `yyecho()') +define(`M4_TEST_REJECT', `yyreject()') define(`M4_TEST_FAILMESSAGE', `log.Fatal("TEST FAILMESSAGE"); os.Exit(1);') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { -- cgit v1.2.1 From a53aec8e86c4e62fe6c0ac48abd893dec502ef19 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 31 Oct 2020 16:52:51 -0400 Subject: Rulesets now carry their test loads with them. Makes it easier to see what the tests are doing. --- tests/.gitignore | 11 +---------- tests/array.rules | 4 +++- tests/array.txt | 2 -- tests/basic.rules | 7 ++++++- tests/basic.txt | 5 ----- tests/ccl.rules | 29 ++++++++++++++++++++++++++++- tests/ccl.txt | 27 --------------------------- tests/extended.rules | 4 +++- tests/extended.txt | 2 -- tests/flexname.rules | 3 ++- tests/flexname.txt | 1 - tests/lexcompat.rules | 3 ++- tests/lexcompat.txt | 1 - tests/posix.rules | 3 ++- tests/posix.txt | 1 - tests/posixlycorrect.rules | 3 ++- tests/posixlycorrect.txt | 1 - tests/preposix.rules | 3 ++- tests/preposix.txt | 1 - tests/quoteincomment.rules | 5 +++-- tests/quoteincomment.txt | 1 - tests/reject.rules | 5 ++++- tests/reject.txt | 2 -- tests/ruleset.sh | 2 +- tests/tableopts.rules | 4 +++- tests/tableopts.txt | 2 -- tests/testmaker.sh | 8 +++++++- tests/yyunput.rules | 2 +- 28 files changed, 70 insertions(+), 72 deletions(-) delete mode 100644 tests/array.txt delete mode 100644 tests/basic.txt delete mode 100644 tests/ccl.txt delete mode 100644 tests/extended.txt delete mode 100644 tests/flexname.txt delete mode 100644 tests/lexcompat.txt delete mode 100644 tests/posix.txt delete mode 100644 tests/posixlycorrect.txt delete mode 100644 tests/preposix.txt delete mode 100644 tests/quoteincomment.txt delete mode 100644 tests/reject.txt delete mode 100644 tests/tableopts.txt diff --git a/tests/.gitignore b/tests/.gitignore index 3ab460a..8cd3fe5 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -8,10 +8,8 @@ alloc_extra_c99 alloc_extra_c99.c array_* !array.rules -!array.txt basic_* !basic.rules -!basic.txt bison_nr bison_nr_scanner.[ch] bison_nr_parser.[ch] @@ -27,7 +25,6 @@ c_cxx_r c_cxx_r.cc ccl_* !ccl.rules -!ccl.txt cxx_basic cxx_basic.cc cxx_multiple_scanners @@ -44,10 +41,8 @@ debug_c99 debug_c99.c extended_* !extended.rules -!extended.txt flexname_* !flexname.rules -!flexname.txt header_nr header_nr_scanner.[ch] header_r @@ -81,10 +76,8 @@ multiple_scanners_r multiple_scanners_r_[12].[ch] posix_* !posix.rules -!posix.txt posixlycorrect_* !posixlycorrect.rules -!posixlycorrect.txt prefix_nr prefix_nr.c prefix_r @@ -98,12 +91,10 @@ pthread.pthread pthread.c quoteincomment_* !quoteincomment.rules -!quoteincomment.txt quotes quotes.c reject* !reject.rules -!reject.txt rescan_nr.direct rescan_nr.direct.c rescan_r.direct @@ -116,7 +107,6 @@ string_c99 string_c99.c tableopts* !tableopts.rules -!tableopts.txt top top.[ch] yyextra_nr @@ -125,6 +115,7 @@ yyextra_c99 yyextra_c99.c yyunput_* !yyunput.rules +test-yydecl-* *.opt *.ser *.ver diff --git a/tests/array.rules b/tests/array.rules index 157a48a..0880805 100644 --- a/tests/array.rules +++ b/tests/array.rules @@ -26,4 +26,6 @@ .|\n { } -%% +### +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/array.txt b/tests/array.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/array.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/basic.rules b/tests/basic.rules index 3b18e8a..7ba254a 100644 --- a/tests/basic.rules +++ b/tests/basic.rules @@ -43,4 +43,9 @@ WS [[:blank:]] ^{WS}*\r?\n { } .|\n {M4_TEST_FAILMESSAGE} -%% +### +# this is a comment +foo = "bar" +num = 43 +setting = false + diff --git a/tests/basic.txt b/tests/basic.txt deleted file mode 100644 index 642e0fb..0000000 --- a/tests/basic.txt +++ /dev/null @@ -1,5 +0,0 @@ -# this is a comment -foo = "bar" -num = 43 -setting = false - diff --git a/tests/ccl.rules b/tests/ccl.rules index da547d0..64bf716 100644 --- a/tests/ccl.rules +++ b/tests/ccl.rules @@ -69,4 +69,31 @@ .|\n {M4_TEST_FAILMESSAGE} -%% +### +^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ +^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ +^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ +^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ +^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ +^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ +^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ +^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ +^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ +^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ +a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ +l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ +abcd-bc:aaaaddddaaaa@abcd-bc@ +abcde-b-c:aaaaddddeeee@abcde-b-c@ +^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ +a+d:abc0123xyz789@a+d@ +a-u+Q:abcQQQQxyz@a-u+Q@ +ia:AaAa@ia@ +iabc:ABCabcAbCaBc@iabc@ +ia-c:ABCabcAbCaBc@ia-c@ +check-a:a@ +dot-all-1:XXX junk + junk + junk + @dot-all-1@ +x1:abaabb@x1@ +x2:abaabb@x2@ diff --git a/tests/ccl.txt b/tests/ccl.txt deleted file mode 100644 index b318fe6..0000000 --- a/tests/ccl.txt +++ /dev/null @@ -1,27 +0,0 @@ -^alpha:0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alpha@ -^digit:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@digit@ -^alnum:~!@#$%^&*(){}[]':;"<>,./?\+=_-`@alnum@ -^upper:abcdefghijklmnopqrstuvwxyz0123456789 ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@upper@ -^lower:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@lower@ -^space:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@space@ -^blank:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@blank@ -^punct:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF Z@punct@ -^cntrl:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF~!@#$%^&*(){}[]':;"<>,./?\+=_-`@cntrl@ -^xdigit:ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ ~!@#$%^&*(){}[]':;"<>,./?\+=_-`@xdigit@ -a-d:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@a-d@ -l-xyz:abcdefghijklmnopqrstuvw@l-xyz@ -abcd-bc:aaaaddddaaaa@abcd-bc@ -abcde-b-c:aaaaddddeeee@abcde-b-c@ -^XY-^XYZ:ZZZZZZZZZZZ@^XY-^XYZ@ -a+d:abc0123xyz789@a+d@ -a-u+Q:abcQQQQxyz@a-u+Q@ -ia:AaAa@ia@ -iabc:ABCabcAbCaBc@iabc@ -ia-c:ABCabcAbCaBc@ia-c@ -check-a:a@ -dot-all-1:XXX junk - junk - junk - @dot-all-1@ -x1:abaabb@x1@ -x2:abaabb@x2@ diff --git a/tests/extended.rules b/tests/extended.rules index 0411091..425c2f2 100644 --- a/tests/extended.rules +++ b/tests/extended.rules @@ -45,4 +45,6 @@ A(?x: B C D) yyecho(); \n yyecho(); -%% +### +abcdefghijklmnopqrstuvwxyz +ABCD diff --git a/tests/extended.txt b/tests/extended.txt deleted file mode 100644 index 829e23d..0000000 --- a/tests/extended.txt +++ /dev/null @@ -1,2 +0,0 @@ -abcdefghijklmnopqrstuvwxyz -ABCD diff --git a/tests/flexname.rules b/tests/flexname.rules index 1c5e41f..6cda1a2 100644 --- a/tests/flexname.rules +++ b/tests/flexname.rules @@ -34,4 +34,5 @@ NAME [A-Z][A-Z0-9]* foo{NAME}? {M4_TEST_ECHO} \n {M4_TEST_ECHO} . {M4_TEST_FAILMESSAGE} -%% +### +foo diff --git a/tests/flexname.txt b/tests/flexname.txt deleted file mode 100644 index 257cc56..0000000 --- a/tests/flexname.txt +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/tests/lexcompat.rules b/tests/lexcompat.rules index 392c31f..213b59f 100644 --- a/tests/lexcompat.rules +++ b/tests/lexcompat.rules @@ -34,4 +34,5 @@ NAME [A-Z][A-Z0-9]* foo{NAME}? {M4_TEST_FAILMESSAGE} \n {M4_TEST_ECHO} . {M4_TEST_ECHO} -%% +### +foo diff --git a/tests/lexcompat.txt b/tests/lexcompat.txt deleted file mode 100644 index 257cc56..0000000 --- a/tests/lexcompat.txt +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/tests/posix.rules b/tests/posix.rules index 7989a9b..f38ea5d 100644 --- a/tests/posix.rules +++ b/tests/posix.rules @@ -37,4 +37,5 @@ ab{3} { } \n { } . {M4_TEST_FAILMESSAGE} -%% +### +ababab diff --git a/tests/posix.txt b/tests/posix.txt deleted file mode 100644 index 753ff4f..0000000 --- a/tests/posix.txt +++ /dev/null @@ -1 +0,0 @@ -ababab diff --git a/tests/posixlycorrect.rules b/tests/posixlycorrect.rules index 3940fd0..51972e3 100644 --- a/tests/posixlycorrect.rules +++ b/tests/posixlycorrect.rules @@ -41,4 +41,5 @@ ab{3} { } \n { } . {M4_TEST_FAILMESSAGE} -%% +### +ababab diff --git a/tests/posixlycorrect.txt b/tests/posixlycorrect.txt deleted file mode 100644 index 753ff4f..0000000 --- a/tests/posixlycorrect.txt +++ /dev/null @@ -1 +0,0 @@ -ababab diff --git a/tests/preposix.rules b/tests/preposix.rules index ecabffe..b43a00b 100644 --- a/tests/preposix.rules +++ b/tests/preposix.rules @@ -38,4 +38,5 @@ ab{3} { } \n { } . {M4_TEST_FAILMESSAGE} -%% +### +abbb diff --git a/tests/preposix.txt b/tests/preposix.txt deleted file mode 100644 index 9abab54..0000000 --- a/tests/preposix.txt +++ /dev/null @@ -1 +0,0 @@ -abbb diff --git a/tests/quoteincomment.rules b/tests/quoteincomment.rules index 342eb7a..d0c61bd 100644 --- a/tests/quoteincomment.rules +++ b/tests/quoteincomment.rules @@ -22,7 +22,8 @@ */ %option 8bit noyywrap %% -.|\n { yyecho(); +.|\n { M4_TEST_ECHO //' " } -%% +### +test diff --git a/tests/quoteincomment.txt b/tests/quoteincomment.txt deleted file mode 100644 index 9daeafb..0000000 --- a/tests/quoteincomment.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/tests/reject.rules b/tests/reject.rules index 2fab9ae..824f02c 100644 --- a/tests/reject.rules +++ b/tests/reject.rules @@ -33,4 +33,7 @@ . {M4_TEST_REJECT M4_TEST_FAILMESSAGE} .|\n ; -%% +### +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar + diff --git a/tests/reject.txt b/tests/reject.txt deleted file mode 100644 index 7288a40..0000000 --- a/tests/reject.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar -0000 foo 1111 foo 0000 bar diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 99788ad..87ff564 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -30,7 +30,7 @@ for backend in $* ; do # shellcheck disable=2016 printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' RULESET_TESTS="${RULESET_TESTS} ${testname}" - RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l" + RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l ${testname}.txt" fi done for kind in opt ser ver ; do diff --git a/tests/tableopts.rules b/tests/tableopts.rules index e4980d2..8787f8c 100644 --- a/tests/tableopts.rules +++ b/tests/tableopts.rules @@ -31,4 +31,6 @@ foo|bar ; [[:digit:]]+ ; [[:blank:]]+ ; .|\n ; -%% +### +0000 foo 1111 foo 0000 bar foobar +0000 foo 1111 foo 0000 bar foobar diff --git a/tests/tableopts.txt b/tests/tableopts.txt deleted file mode 100644 index aec9276..0000000 --- a/tests/tableopts.txt +++ /dev/null @@ -1,2 +0,0 @@ -0000 foo 1111 foo 0000 bar foobar -0000 foo 1111 foo 0000 bar foobar diff --git a/tests/testmaker.sh b/tests/testmaker.sh index fc3dba4..0c67e0f 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -84,8 +84,14 @@ m4def() { cat testmaker.m4 echo "M4_TEST_PREAMBLE\`'dnl" echo "M4_TEST_OPTIONS\`'dnl" - cat "${stem}.rules" + sed <"${stem}.rules" -e "/###/Q0" + echo "%%" echo "M4_TEST_POSTAMBLE\`'dnl" ) | m4 >"${outdev}" +if [ "${outdev}" != /dev/stdout ] && [ ! -f "${stem}.txt" ] +then + sed <"${stem}.rules" -e "1,/###/d" >"${stem}.txt" +fi + # end diff --git a/tests/yyunput.rules b/tests/yyunput.rules index 97133a5..1979e51 100644 --- a/tests/yyunput.rules +++ b/tests/yyunput.rules @@ -31,4 +31,4 @@ foo {yyunput('k');} kick ; \n ; . {M4_TEST_FAILMESSAGE} -%% +### -- cgit v1.2.1 From 2f449b421192edaebfdb1da0f29e69179493b00a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 1 Nov 2020 02:25:20 -0500 Subject: shellcheck cleanup on all scripts. Turned up a minor bug in testmaker.sh. --- tests/.gitignore | 25 ++++++++++++------------- tests/ruleset.am | 12 ++++++------ tests/ruleset.sh | 17 ++++++++++------- tests/test-yydecl-gen | 29 ----------------------------- tests/test-yydecl-gen.sh | 30 ++++++++++++++++++++++++++++++ tests/testmaker.sh | 2 +- 6 files changed, 59 insertions(+), 56 deletions(-) delete mode 100755 tests/test-yydecl-gen create mode 100755 tests/test-yydecl-gen.sh diff --git a/tests/.gitignore b/tests/.gitignore index 8cd3fe5..d31c939 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,9 +6,9 @@ alloc_extra_nr alloc_extra_nr.c alloc_extra_c99 alloc_extra_c99.c -array_* +array* !array.rules -basic_* +basic* !basic.rules bison_nr bison_nr_scanner.[ch] @@ -23,7 +23,7 @@ c_cxx_nr c_cxx_nr.cc c_cxx_r c_cxx_r.cc -ccl_* +ccl* !ccl.rules cxx_basic cxx_basic.cc @@ -39,9 +39,9 @@ debug_r debug_r.c debug_c99 debug_c99.c -extended_* +extended* !extended.rules -flexname_* +flexname* !flexname.rules header_nr header_nr_scanner.[ch] @@ -53,9 +53,8 @@ include_by_push.direct include_by_push.direct.c include_by_reentrant.direct include_by_reentrant.direct.c -lexcompat_* +lexcompat* !lexcompat.rules -!lexcompat.txt lineno_nr.one lineno_nr.c lineno_r.one @@ -74,9 +73,9 @@ multiple_scanners_nr multiple_scanners_nr_[12].[ch] multiple_scanners_r multiple_scanners_r_[12].[ch] -posix_* +posix* !posix.rules -posixlycorrect_* +posixlycorrect* !posixlycorrect.rules prefix_nr prefix_nr.c @@ -84,12 +83,11 @@ prefix_r prefix_r.c prefix_c99 prefix_c99.c -preposix_* +preposix* !preposix.rules -!preposix.txt pthread.pthread pthread.c -quoteincomment_* +quoteincomment* !quoteincomment.rules quotes quotes.c @@ -113,9 +111,10 @@ yyextra_nr yyextra_nr.c yyextra_c99 yyextra_c99.c -yyunput_* +yyunput* !yyunput.rules test-yydecl-* +!test-yydecl-gen.sh *.opt *.ser *.ver diff --git a/tests/ruleset.am b/tests/ruleset.am index 8060816..2fc3ea5 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -548,22 +548,22 @@ tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $ posixlycorrect_nr.c: posixlycorrect_nr.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< -test-yydecl-nr.sh$(EXEEXT): test-yydecl-gen - $(SHELL) test-yydecl-gen nr >test-yydecl-nr.sh$(EXEEXT) +test-yydecl-nr.sh$(EXEEXT): test-yydecl-gen.sh + $(SHELL) test-yydecl-gen.sh nr >test-yydecl-nr.sh$(EXEEXT) chmod a+x test-yydecl-nr.sh$(EXEEXT) posixlycorrect_r.c: posixlycorrect_r.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< -test-yydecl-r.sh$(EXEEXT): test-yydecl-gen - $(SHELL) test-yydecl-gen r >test-yydecl-r.sh$(EXEEXT) +test-yydecl-r.sh$(EXEEXT): test-yydecl-gen.sh + $(SHELL) test-yydecl-gen.sh r >test-yydecl-r.sh$(EXEEXT) chmod a+x test-yydecl-r.sh$(EXEEXT) posixlycorrect_c99.c: posixlycorrect_c99.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< -test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen - $(SHELL) test-yydecl-gen c99 >test-yydecl-c99.sh$(EXEEXT) +test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh + $(SHELL) test-yydecl-gen.sh c99 >test-yydecl-c99.sh$(EXEEXT) chmod a+x test-yydecl-c99.sh$(EXEEXT) diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 87ff564..5447052 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -17,13 +17,13 @@ printf "\n# Begin generated test rules\n\n" compatible() { mybackend=$1 myruleset=$2 - [ ${mybackend} = "nr" ] || [ ${myruleset} != "lexcompat.rules" ] + [ "${mybackend}" = "nr" ] || [ "${myruleset}" != "lexcompat.rules" ] } -for backend in $* ; do +for backend in "$@" ; do for ruleset in *.rules; do - if compatible ${backend} ${ruleset} ; then - testname=${ruleset%.*}_${backend} + if compatible "${backend}" "${ruleset}" ; then + testname="${ruleset%.*}_${backend}" echo "${testname}_SOURCES = ${testname}.l" echo "${testname}.l: \$(srcdir)/${ruleset} \$(srcdir)/testmaker.sh \$(srcdir)/testmaker.m4" # we're deliberately single-quoting this because we _don't_ want those variables to be expanded yet @@ -53,17 +53,20 @@ done # posixlycorrect is a special case becaae we need to set POSIXLY_CORRECT # in Flex's environment while these .l files are bein processed. -for backend in $* ; do +for backend in "$@" ; do case $backend in nr|r|c99) ext="c" ;; *) ext=${backend} ;; esac + # shellcheck disable=SC2059 printf "posixlycorrect_${backend}.${ext}: posixlycorrect_${backend}.l \$(FLEX)\n" printf "\t\$(AM_V_LEX)POSIXLY_CORRECT=1 \$(FLEX) \$(TESTOPTS) -o \$@ \$<\n" echo "" - echo "test-yydecl-${backend}.sh\$(EXEEXT): test-yydecl-gen" - printf "\t\$(SHELL) test-yydecl-gen ${backend} >test-yydecl-${backend}.sh\$(EXEEXT)\n" + echo "test-yydecl-${backend}.sh\$(EXEEXT): test-yydecl-gen.sh" + # shellcheck disable=SC2059 + printf "\t\$(SHELL) test-yydecl-gen.sh ${backend} >test-yydecl-${backend}.sh\$(EXEEXT)\n" + # shellcheck disable=SC2059 printf "\tchmod a+x test-yydecl-${backend}.sh\$(EXEEXT)\n" echo "" diff --git a/tests/test-yydecl-gen b/tests/test-yydecl-gen deleted file mode 100755 index 8e1375a..0000000 --- a/tests/test-yydecl-gen +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh -# Generate test for the %yydecl option of flex on a specified back end -backend=$1 - -cat </tmp/td\$\$ </dev/null -then - echo "%yydecl test on ${backend} SUCCEEDED" - exit 0 -else - echo "%yydecl test on ${backend} FAILED." >&2; - exit 1 -fi -EOF_OUTER diff --git a/tests/test-yydecl-gen.sh b/tests/test-yydecl-gen.sh new file mode 100755 index 0000000..0a70915 --- /dev/null +++ b/tests/test-yydecl-gen.sh @@ -0,0 +1,30 @@ +#! /bin/sh +# Generate test for the %yydecl option of flex on a specified back end +backend="$1" + +cat </tmp/td\$\$ </dev/null +then + echo "%yydecl test on ${backend} SUCCEEDED" + exit 0 +else + echo "%yydecl test on ${backend} FAILED." >&2; + exit 1 +fi +EOF_OUTER diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 0c67e0f..5c3df7d 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -43,7 +43,7 @@ for part in "$@"; do r) backend=r; options="${options} reentrant";; ${backends}) backend=${part}; options="${options} emit=\"${part}\"" ;; ser) serialization=yes ;; - ver) serialization=yes; options="${options} tables-verify" ;; + ver) serialization=yes; verification=yes; options="${options} tables-verify" ;; Ca) options="${options} align" ;; Ce) options="${options} ecs" ;; Cf) options="${options} full" ;; -- cgit v1.2.1 From 8b1d12f0cd72dc10b16436c17ef38dfa99b21286 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 31 Oct 2020 20:54:32 -0400 Subject: Portability improvement on the extended test. --- tests/extended.rules | 15 +++++++-------- tests/testmaker.m4 | 1 + tests/testmaker.sh | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/extended.rules b/tests/extended.rules index 425c2f2..5e332a7 100644 --- a/tests/extended.rules +++ b/tests/extended.rules @@ -21,30 +21,29 @@ * PURPOSE. */ /* Output should match the input. */ -/* FIXME: Assumes ";" is a legal statememt terminator */ %option 8bit nounput nomain noyywrap noinput warn %% -abc(?# Single Line Comment )def yyecho(); +abc(?# Single Line Comment )def {M4_TEST_ECHO} ghi(?# multi-line comment - )jkl yyecho(); + )jkl {M4_TEST_ECHO} mno(?# multi-line // comment with ## ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; punctuation - )pqr yyecho(); -(?# Start of a rule.)stu yyecho(); -vwxyz(?#End of a rule.) yyecho(); + )pqr {M4_TEST_ECHO} +(?# Start of a rule.)stu {M4_TEST_ECHO} +vwxyz(?#End of a rule.) {M4_TEST_ECHO} A(?x: B /* comment */ - C D) yyecho(); + C D) {M4_TEST_ECHO} -\n yyecho(); +\n {M4_TEST_ECHO} ### abcdefghijklmnopqrstuvwxyz ABCD diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index fff8962..be54c66 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -36,6 +36,7 @@ dnl dnl These macros are to be expanded by files with a .rules extension dnl that contain pure flex rulesets and no backend-specific code. dnl +changecom define(`M4_TEST_FAILMESSAGE', `INVALID BACK END')dnl dnl ifelse(M4_TEST_BACKEND, `nr', `dnl diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 5c3df7d..518745d 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -13,8 +13,10 @@ backends="c99" if [ "$1" = -d ] ; then shift outdev=/dev/stdout + filter=cat else outdev="$1" + filter=m4 fi testfile=$1 @@ -87,7 +89,7 @@ m4def() { sed <"${stem}.rules" -e "/###/Q0" echo "%%" echo "M4_TEST_POSTAMBLE\`'dnl" -) | m4 >"${outdev}" +) | "${filter}" >"${outdev}" if [ "${outdev}" != /dev/stdout ] && [ ! -f "${stem}.txt" ] then -- cgit v1.2.1 From b9002f8f936c91c3907945df037712f809fe65e7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 1 Nov 2020 12:55:35 -0500 Subject: Simplify and generalize the testmaker macros. --- tests/ccl.rules | 48 +++++++++++++++++++++++----------------------- tests/extended.rules | 14 +++++++------- tests/flexname.rules | 4 ++-- tests/lexcompat.rules | 4 ++-- tests/quoteincomment.rules | 2 +- tests/reject.rules | 2 +- tests/testmaker.m4 | 16 +++++----------- 7 files changed, 42 insertions(+), 48 deletions(-) diff --git a/tests/ccl.rules b/tests/ccl.rules index 64bf716..b34d8ef 100644 --- a/tests/ccl.rules +++ b/tests/ccl.rules @@ -29,43 +29,43 @@ %option warn %% -^"^alpha:"[[:^alpha:]]+@alpha@\n {M4_TEST_ECHO} -^"^digit:"[[:^digit:]]+@digit@\n {M4_TEST_ECHO} -^"^alnum:"[[:^alnum:]]+@alnum@\n {M4_TEST_ECHO} -^"^upper:"[[:^upper:]]+@upper@\n {M4_TEST_ECHO} -^"^lower:"[[:^lower:]]+@lower@\n {M4_TEST_ECHO} -^"^space:"[[:^space:]]+@space@\n {M4_TEST_ECHO} -^"^blank:"[[:^blank:]]+@blank@\n {M4_TEST_ECHO} -^"^punct:"[[:^punct:]]+@punct@\n {M4_TEST_ECHO} -^"^cntrl:"[[:^cntrl:]]+@cntrl@\n {M4_TEST_ECHO} -^"^xdigit:"[[:^xdigit:]]+@xdigit@\n {M4_TEST_ECHO} +^"^alpha:"[[:^alpha:]]+@alpha@\n {M4_TEST_DO(yyecho())} +^"^digit:"[[:^digit:]]+@digit@\n {M4_TEST_DO(yyecho())} +^"^alnum:"[[:^alnum:]]+@alnum@\n {M4_TEST_DO(yyecho())} +^"^upper:"[[:^upper:]]+@upper@\n {M4_TEST_DO(yyecho())} +^"^lower:"[[:^lower:]]+@lower@\n {M4_TEST_DO(yyecho())} +^"^space:"[[:^space:]]+@space@\n {M4_TEST_DO(yyecho())} +^"^blank:"[[:^blank:]]+@blank@\n {M4_TEST_DO(yyecho())} +^"^punct:"[[:^punct:]]+@punct@\n {M4_TEST_DO(yyecho())} +^"^cntrl:"[[:^cntrl:]]+@cntrl@\n {M4_TEST_DO(yyecho())} +^"^xdigit:"[[:^xdigit:]]+@xdigit@\n {M4_TEST_DO(yyecho())} -^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n {M4_TEST_ECHO} -^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n {M4_TEST_ECHO} -^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n {M4_TEST_ECHO} -^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n {M4_TEST_ECHO} -^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n {M4_TEST_ECHO} +^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n {M4_TEST_DO(yyecho())} +^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n {M4_TEST_DO(yyecho())} +^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n {M4_TEST_DO(yyecho())} +^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n {M4_TEST_DO(yyecho())} +^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n {M4_TEST_DO(yyecho())} -^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n {M4_TEST_ECHO} -^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n {M4_TEST_ECHO} +^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n {M4_TEST_DO(yyecho())} +^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n {M4_TEST_DO(yyecho())} -^"ia:"(?i:a)+@ia@\n {M4_TEST_ECHO} -^"iabc:"(?i:abc)+@iabc@\n {M4_TEST_ECHO} -^"ia-c:"(?i:[a-c]+)@ia-c@\n {M4_TEST_ECHO} +^"ia:"(?i:a)+@ia@\n {M4_TEST_DO(yyecho())} +^"iabc:"(?i:abc)+@iabc@\n {M4_TEST_DO(yyecho())} +^"ia-c:"(?i:[a-c]+)@ia-c@\n {M4_TEST_DO(yyecho())} /* We don't want this one to match. */ ^"check-a:"(?i:(?-i:A))@\n {M4_TEST_FAILMESSAGE} -^"check-a:"(?i:(?-i:(?i:A)))@\n {M4_TEST_ECHO} +^"check-a:"(?i:(?-i:(?i:A)))@\n {M4_TEST_DO(yyecho())} /* We don't want this one to match. */ ^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n {M4_TEST_FAILMESSAGE} -^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n {M4_TEST_ECHO} +^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n {M4_TEST_DO(yyecho())} -^"x1:"(?x: a | b )+@x1@\n {M4_TEST_ECHO} +^"x1:"(?x: a | b )+@x1@\n {M4_TEST_DO(yyecho())} ^"x2:"(?x: a | (?# Comment ) b - )+@x2@\n {M4_TEST_ECHO} + )+@x2@\n {M4_TEST_DO(yyecho())} .|\n {M4_TEST_FAILMESSAGE} diff --git a/tests/extended.rules b/tests/extended.rules index 5e332a7..6f2d03e 100644 --- a/tests/extended.rules +++ b/tests/extended.rules @@ -25,25 +25,25 @@ %option 8bit nounput nomain noyywrap noinput warn %% -abc(?# Single Line Comment )def {M4_TEST_ECHO} +abc(?# Single Line Comment )def {M4_TEST_DO(yyecho())} ghi(?# multi-line comment - )jkl {M4_TEST_ECHO} + )jkl {M4_TEST_DO(yyecho())} mno(?# multi-line // comment with ## ~~!@#$ %^&*(@-_+=\|,.<>/ ?: ; punctuation - )pqr {M4_TEST_ECHO} -(?# Start of a rule.)stu {M4_TEST_ECHO} -vwxyz(?#End of a rule.) {M4_TEST_ECHO} + )pqr {M4_TEST_DO(yyecho())} +(?# Start of a rule.)stu {M4_TEST_DO(yyecho())} +vwxyz(?#End of a rule.) {M4_TEST_DO(yyecho())} A(?x: B /* comment */ - C D) {M4_TEST_ECHO} + C D) {M4_TEST_DO(yyecho())} -\n {M4_TEST_ECHO} +\n {M4_TEST_DO(yyecho())} ### abcdefghijklmnopqrstuvwxyz ABCD diff --git a/tests/flexname.rules b/tests/flexname.rules index 6cda1a2..eb18943 100644 --- a/tests/flexname.rules +++ b/tests/flexname.rules @@ -31,8 +31,8 @@ NAME [A-Z][A-Z0-9]* %% -foo{NAME}? {M4_TEST_ECHO} -\n {M4_TEST_ECHO} +foo{NAME}? {M4_TEST_DO(yyecho())} +\n {M4_TEST_DO(yyecho())} . {M4_TEST_FAILMESSAGE} ### foo diff --git a/tests/lexcompat.rules b/tests/lexcompat.rules index 213b59f..78ba6e1 100644 --- a/tests/lexcompat.rules +++ b/tests/lexcompat.rules @@ -32,7 +32,7 @@ NAME [A-Z][A-Z0-9]* %% foo{NAME}? {M4_TEST_FAILMESSAGE} -\n {M4_TEST_ECHO} -. {M4_TEST_ECHO} +\n {M4_TEST_DO(yyecho())} +. {M4_TEST_DO(yyecho())} ### foo diff --git a/tests/quoteincomment.rules b/tests/quoteincomment.rules index d0c61bd..9aca73b 100644 --- a/tests/quoteincomment.rules +++ b/tests/quoteincomment.rules @@ -22,7 +22,7 @@ */ %option 8bit noyywrap %% -.|\n { M4_TEST_ECHO +.|\n { M4_TEST_DO(yyecho()) //' " } ### diff --git a/tests/reject.rules b/tests/reject.rules index 824f02c..b7ed30e 100644 --- a/tests/reject.rules +++ b/tests/reject.rules @@ -30,7 +30,7 @@ %option warn reject %% -. {M4_TEST_REJECT M4_TEST_FAILMESSAGE} +. {M4_TEST_DO(yyreject()) M4_TEST_FAILMESSAGE} .|\n ; ### diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index be54c66..28a4501 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -16,11 +16,8 @@ dnl the emit option required to srt the back end. dnl dnl M4_TEST_COMPRESSION = compression option. dnl -dnl M4_TEST_ECHO = echo the token buffer and continue, may add -dnl a statement terminator if target language requires it. -dnl -dnl M4_TEST_REJECT = echo the token buffer and continue, may add -dnl a statement terminator if target language requires it. +dnl M4_TEST_DO = Add a statement terminator if target language +dnl requires it. dnl dnl M4_TEST_FAILMESSAGE = a line of code required to issue dnl a dnl failure notification to standard error and exit with a failure status. @@ -46,8 +43,7 @@ define(`M4_TEST_PREAMBLE', `dnl #include %} ')dnl close preamble -define(`M4_TEST_ECHO', `yyecho();') -define(`M4_TEST_REJECT', `yyreject();') +define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) @@ -84,8 +80,7 @@ define(`M4_TEST_PREAMBLE', `dnl #include %} ')dnl close preamble -define(`M4_TEST_ECHO', `yyecho();') -define(`M4_TEST_REJECT', `yyreject();') +define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) @@ -132,8 +127,7 @@ import ( %} %option emit="go" ')dnl close preamble -define(`M4_TEST_ECHO', `yyecho()') -define(`M4_TEST_REJECT', `yyreject()') +define(`M4_TEST_DO', `$1') define(`M4_TEST_FAILMESSAGE', `log.Fatal("TEST FAILMESSAGE"); os.Exit(1);') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { -- cgit v1.2.1 From a6499117d78f332a04e784778aff25cf9a99ab82 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 1 Nov 2020 17:15:18 -0500 Subject: Add a test for yyless. --- tests/ruleset.am | 16 ++++++++++++++-- tests/testmaker.m4 | 2 +- tests/yyless.rules | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 tests/yyless.rules diff --git a/tests/ruleset.am b/tests/ruleset.am index 2fc3ea5..f9a0211 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -49,6 +49,10 @@ tableopts_nr_SOURCES = tableopts_nr.l tableopts_nr.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yyless_nr_SOURCES = yyless_nr.l +yyless_nr.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyunput_nr_SOURCES = yyunput_nr.l yyunput_nr.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -229,6 +233,10 @@ tableopts_r_SOURCES = tableopts_r.l tableopts_r.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yyless_r_SOURCES = yyless_r.l +yyless_r.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyunput_r_SOURCES = yyunput_r.l yyunput_r.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -409,6 +417,10 @@ tableopts_c99_SOURCES = tableopts_c99.l tableopts_c99.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yyless_c99_SOURCES = yyless_c99.l +yyless_c99.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyunput_c99_SOURCES = yyunput_c99.l yyunput_c99.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -568,6 +580,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh test-yydecl-c99.sh diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 28a4501..263e792 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -139,7 +139,7 @@ func main(void) { fmt.Printf("TEST RETURNING OK.\n") os.Exit(0) } -')dnl clpse postamble +')dnl close postamble ')dnl close go dnl dnl Additional backends go here diff --git a/tests/yyless.rules b/tests/yyless.rules new file mode 100644 index 0000000..8d02d16 --- /dev/null +++ b/tests/yyless.rules @@ -0,0 +1,40 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /* + * Test yyless. What should haooen is: + * 1. "foobar" is matched by the first rule. + * 2. "bar" is pushed back by yyless(3) + * 3. "bar" is matched by the second rule + * 4. Trailing \n is matched and discareded + * 5. Final rule is never reached. + */ + +%option nounput noyywrap noyylineno warn nodefault noinput +%% +foobar {M4_TEST_DO(yyless(3))} +bar ; +\n ; +. {M4_TEST_FAILMESSAGE} + +### +foobar -- cgit v1.2.1 From 22d0a5d19265bf1fbc507e39bf53d63d98817f7c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 2 Nov 2020 01:33:46 -0500 Subject: yyless is successfully m4ized. --- src/c99-flex.skl | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 7bace82..21ab4ee 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -82,6 +82,19 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) +/* Return all but the first "n" matched characters back to the input stream. */ +m4_define([[yyless]], [[ + do { + /* Undo effects of setting up yytext. */ + int yyless_macro_arg = ($1); + m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(yyless_macro_arg, yyscanner);]]) + *yy_cp = yyscanner->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + yyscanner->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; + yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext again */ + } while ( 0 ) +]]) + %% [0.0] Make hook macros available to Flex const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; @@ -1076,20 +1089,6 @@ static void yybumpline( yyscan_t yyscanner) { yycolumn=0; } -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(yyless_macro_arg, yyscanner);]]) \ - *yy_cp = yyscanner->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyscanner->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext again */ \ - } \ - while ( 0 ) - /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". @@ -2299,9 +2298,10 @@ static int yy_top_state (yyscan_t yyscanner) } ]]) +m4_undefine([[yyless]]) + /* Redefine yyless() so it works in section 3 code. */ -#undef yyless void yyless(int n, yyscan_t yyscanner) { /* Undo effects of setting up yytext. */ m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(n, yyscanner);]]) -- cgit v1.2.1 From eb6e30e9d51236f491785e7ba5537752be2c9ced Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 2 Nov 2020 05:58:28 -0500 Subject: Successful m4ization of yyreject(). --- src/c99-flex.skl | 47 ++++++++++++++++++++++++----------------------- src/scan.l | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 21ab4ee..713ae09 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -82,7 +82,7 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) -/* Return all but the first "n" matched characters back to the input stream. */ +%# Return all but the first "n" matched characters back to the input stream. m4_define([[yyless]], [[ do { /* Undo effects of setting up yytext. */ @@ -95,6 +95,29 @@ m4_define([[yyless]], [[ } while ( 0 ) ]]) +m4_ifdef([[M4_MODE_USES_REJECT]],[[ +%# Can't be given the context-arg treatment due to the goto. +m4_define([[yyreject]], [[ +{ +*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext $1 */ +yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ +yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ +yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ +yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ +]]) +++yyscanner->yy_lp; +goto find_rule; +} +]]) +]]) +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +/* The intent behind this definition is that it'll catch + * any uses of yyreject() which flex missed. + */ +m4_define([[yyreject()]], [[reject_used_but_not_detected]]) +]]) + %% [0.0] Make hook macros available to Flex const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; @@ -1120,28 +1143,6 @@ static void yybumpline( yyscan_t yyscanner) { } #define yy_at_bol() (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag) -m4_ifdef( [[M4_MODE_USES_REJECT]],[[ -%# Can't be given the context-arg treatment due to the goto. -#define yyreject() \ -{ \ -*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ \ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ -yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ \ -yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ \ -]]) \ -++yyscanner->yy_lp; \ -goto find_rule; \ -} -]]) -m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ -/* The intent behind this definition is that it'll catch - * any uses of yyreject() which flex missed. - */ -#define yyreject() reject_used_but_not_detected -]]) - m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) diff --git a/src/scan.l b/src/scan.l index 9ea52f2..b6367fd 100644 --- a/src/scan.l +++ b/src/scan.l @@ -960,7 +960,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { context_call(yytext); } - yyterminate\(\)|yyless\({FUNARGS}\) { + yyterminate\(\)|yyreject\(\)|yyless\({FUNARGS}\) { add_action("]""]"); add_action(yytext); add_action("[""["); -- cgit v1.2.1 From f2f38557eea8c18bc087d56e5afe74fe9728ded9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 2 Nov 2020 20:35:28 -0500 Subject: Pull two random flags into the ctrl structure. Also, some documentation polishing. --- doc/flex.texi | 2 +- src/flexdef.h | 3 ++- src/main.c | 23 +++++++++++------------ src/scan.l | 4 ++-- tests/.gitignore | 2 ++ tests/README | 21 +++++++++++---------- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 0f71421..4a8ec75 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1,4 +1,4 @@ -input texinfo.tex @c -*-texinfo-*- +busuinput texinfo.tex @c -*-texinfo-*- @c %**start of header @setfilename flex.info @include version.texi diff --git a/src/flexdef.h b/src/flexdef.h index 8555e1e..99c510f 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -332,6 +332,7 @@ struct ctrl_bundle_t { bool no_unistd; // suppress inclusion of unistd.h bool posix_compat; // (-X) maximize compatibility with POSIX lex char *prefix; // prefix for externally visible names, default "yy" + trit reject_really_used;// Force generation of support code for reject operation bool reentrant; // if true (-R), generate a reentrant C scanner bool stack_used; // Enable use of start-condition stacks bool no_section3_escape;// True if the undocumented option --unsafe-no-m4-sect3-escape was passed @@ -343,6 +344,7 @@ struct ctrl_bundle_t { char *yyclass; // yyFlexLexer subclass to use for YY_DECL char *yydecl; // user-specfied prototype for yylex. int yylmax; // Maximum buffer length if %array + trit yymore_really_used;// Force geberation of support code for yymore bool yytext_is_array; // if true (i.e., %array directive), then declare // yytext as array instead of a character pointer. // Nice and inefficient. @@ -441,7 +443,6 @@ extern struct env_bundle_t env; extern int syntaxerror, eofseen; extern int yymore_used, reject, real_reject, continued_action, in_rule; -extern int yymore_really_used, reject_really_used; /* Variables used in the flex input routines: * datapos - characters on current output line diff --git a/src/main.c b/src/main.c index f0f41ae..9b98873 100644 --- a/src/main.c +++ b/src/main.c @@ -49,7 +49,6 @@ void set_up_initial_allocations(void); /* these globals are all defined and commented in flexdef.h */ int syntaxerror, eofseen; int yymore_used, reject, real_reject, continued_action, in_rule; -int yymore_really_used, reject_really_used; int datapos, dataline, linenum; FILE *skelfile = NULL; int skel_ind = 0; @@ -370,7 +369,7 @@ void check_options (void) /* This makes no sense whatsoever. I'm removing it. */ if (ctrl.do_yylineno) /* This should really be "maintain_backup_tables = true" */ - reject_really_used = true; + ctrl.reject_really_used = true; #endif if (ctrl.csize == trit_unspecified) { @@ -728,7 +727,7 @@ void flexinit (int argc, char **argv) syntaxerror = false; yymore_used = continued_action = false; in_rule = reject = false; - yymore_really_used = reject_really_used = trit_unspecified; + ctrl.yymore_really_used = ctrl.reject_really_used = trit_unspecified; ctrl.do_main = trit_unspecified; ctrl.interactive = ctrl.csize = trit_unspecified; @@ -1089,19 +1088,19 @@ void flexinit (int argc, char **argv) break; case OPT_YYMORE: - yymore_really_used = true; + ctrl.yymore_really_used = true; break; case OPT_NO_YYMORE: - yymore_really_used = false; + ctrl.yymore_really_used = false; break; case OPT_REJECT: - reject_really_used = true; + ctrl.reject_really_used = true; break; case OPT_NO_REJECT: - reject_really_used = false; + ctrl.reject_really_used = false; break; case OPT_NO_YY_PUSH_STATE: @@ -1353,14 +1352,14 @@ void readin (void) else ctrl.backing_up_file = NULL; - if (yymore_really_used == true) + if (ctrl.yymore_really_used == true) yymore_used = true; - else if (yymore_really_used == false) + else if (ctrl.yymore_really_used == false) yymore_used = false; - if (reject_really_used == true) + if (ctrl.reject_really_used == true) reject = true; - else if (reject_really_used == false) + else if (ctrl.reject_really_used == false) reject = false; if (env.performance_hint > 0) { @@ -1524,7 +1523,7 @@ void readin (void) } if (real_reject) visible_define ( "M4_MODE_REAL_REJECT"); - if (reject_really_used) + if (ctrl.reject_really_used) visible_define ( "M4_MODE_FIND_ACTION_REJECT_REALLY_USED"); if (reject) visible_define ( "M4_MODE_USES_REJECT"); diff --git a/src/scan.l b/src/scan.l index b6367fd..0d3e669 100644 --- a/src/scan.l +++ b/src/scan.l @@ -409,7 +409,7 @@ void context_call(char *); pointer ctrl.yytext_is_array = ! option_sense; read ctrl.use_read = option_sense; reentrant ctrl.reentrant = option_sense; - reject reject_really_used = option_sense; + reject ctrl.reject_really_used = option_sense; stack ctrl.stack_used = option_sense; stdinit ctrl.do_stdinit = option_sense; stdout env.use_stdout = option_sense; @@ -419,7 +419,7 @@ void context_call(char *); verbose env.printstats = option_sense; warn env.nowarn = ! option_sense; yylineno ctrl.do_yylineno = option_sense; - yymore yymore_really_used = option_sense; + yymore ctrl.yymore_really_used = option_sense; yywrap ctrl.do_yywrap = option_sense; yyread ctrl.noyyread = !option_sense; diff --git a/tests/.gitignore b/tests/.gitignore index d31c939..ddc288d 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -111,6 +111,8 @@ yyextra_nr yyextra_nr.c yyextra_c99 yyextra_c99.c +yyless* +!yyless.rules yyunput* !yyunput.rules test-yydecl-* diff --git a/tests/README b/tests/README index 9518835..a33d83a 100644 --- a/tests/README +++ b/tests/README @@ -37,7 +37,8 @@ To build and execute a single test: ** If possible, just write a *.rules file. Exit with status 1 to indicate failure, e.g. with a "." production if nothing prior properly consumed every input token. The test machinery - will expand a rules file into tests for all back ends. + will expand a rules file into tests for all back ends. Note that + text following ### at the end of the ruleset will be used as input. ** Otherwise, list your test in the TESTS variable in Makefile.am in this directory. Note that due to the large number of tests, we use @@ -52,8 +53,8 @@ To build and execute a single test: ** On success, your test should return zero. ** On error, your test should return 1 (one) and print a message to -stderr, which will have been redirected to the log file created by the -automake test suite harness. + stderr, which will have been redirected to the log file created by the + automake test suite harness. ** If your test is skipped (e.g., because bison was not found), then the test should return 77 (seventy-seven). This is the exit status that @@ -75,16 +76,16 @@ A test with a c99 suffix exercises the c99 back end. All C99 scanners are re-entrant. Most tests occur in groups with a common stem in the names, like -alloc_extra_ or ccl_. These are exercising the same token grammar +alloc_extra_ or debug_. These are exercising the same token grammar under different back ends. As new target languages are added these groups of parallel tests will grow. Tests that are not part of one of these series are usually of features supported on the default cpp back end only. The "generated" tests are made by wrapping boilerplate code around a -rules file. The assumption is that the test binary should consume its -test file, exercising some set of Flex features and not returning -a nonzero status. +rules file. The assumption is that the test binary should consume the +data following ### in the rules file, exercising some set of Flex +features and not returning a nonzero status. If you can express your test as a ruleset within in this orotocol, please do so. Those tests are easy to port to new back ends, as that @@ -98,7 +99,7 @@ is Flex's ability to accumulate and ship preamble code sections. The "quotes" test is also backend-indepedent; it's testing that m4 expansion doesn't leak through the genertated scanner. -The C99 is missing tests for the Bison bridge, header generation, and -loadable tables because it omits those features in order to be a simpler -starting point for wring new back ends. +The C99 baxk end is missing tests for the Bison bridge, header +generation, and loadable tables because it omits those features in +order to be a simpler starting point for wring new back ends. -- cgit v1.2.1 From 35cdc7cabe0dc8733cfb1e8a76c868c8d7c71d26 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 3 Nov 2020 02:00:09 -0500 Subject: Implement and document the rewrite/norewrite option. --- doc/flex.texi | 12 +++++++++++- src/flexdef.h | 3 ++- src/main.c | 1 + src/scan.l | 8 ++++++-- src/skeletons.c | 1 + 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 4a8ec75..32ba29e 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -2708,7 +2708,7 @@ the serialized tables match the in-code tables, instead of loading them. @opindex emit @item -e, --emit, @code{%option emit} instructs @code{flex} to generate code using a specific back end other -than the default. The default is called ``cpp',' generates C or C++ +than the default. The default is called ``cpp'', generates C or C++ code, supports all legacy interfaces, and generates either non-reentrant or re-entrant scanners. There is presently one alternate back end, C99; it drops a lot of legacy interfaces, @@ -2717,6 +2717,16 @@ back end is intended to be a launching point for as yet unwritten back ends generating scanners in other languages such as Go, Rust, Java, Python, etc. +@anchor{option-rewrite} +@item @code{%option rewrite} +Back ends other than the default C generator can't assume they have +the C preprocessor available. Therefore, Flex recognizes the +following function calls - yyecho(), yyinput(), yystart(), yybegin(), +yyunput(), yypanic() and rewreites them adding a yyscanner final +aergument as though they were C macros. This optiion is set to false +whrn you select or default to the C back end, and to true otherwise. +You can turn it off (or on) expliciltly after your emit option. + @anchor{option-case-insensitive} @opindex -i @opindex ---case-insensitive diff --git a/src/flexdef.h b/src/flexdef.h index 99c510f..74d65b3 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -333,7 +333,8 @@ struct ctrl_bundle_t { bool posix_compat; // (-X) maximize compatibility with POSIX lex char *prefix; // prefix for externally visible names, default "yy" trit reject_really_used;// Force generation of support code for reject operation - bool reentrant; // if true (-R), generate a reentrant C scanner + bool reentrant; // if true (-R), generate a reentrant C scanner + bool rewrite; // Appl;y magic rewre rles to special fumctions bool stack_used; // Enable use of start-condition stacks bool no_section3_escape;// True if the undocumented option --unsafe-no-m4-sect3-escape was passed bool spprdflt; // (-s) suppress the default rule diff --git a/src/main.c b/src/main.c index 9b98873..434f19a 100644 --- a/src/main.c +++ b/src/main.c @@ -735,6 +735,7 @@ void flexinit (int argc, char **argv) ctrl.reentrant = ctrl.bison_bridge_lval = ctrl.bison_bridge_lloc = false; env.performance_hint = 0; ctrl.prefix = "yy"; + ctrl.rewrite = false; ctrl.yylmax = BUFSIZ; tablesext = tablesverify = false; diff --git a/src/scan.l b/src/scan.l index 0d3e669..56f85e6 100644 --- a/src/scan.l +++ b/src/scan.l @@ -410,6 +410,7 @@ void context_call(char *); read ctrl.use_read = option_sense; reentrant ctrl.reentrant = option_sense; reject ctrl.reject_really_used = option_sense; + rewrite ctrl.rewrite = option_sense; stack ctrl.stack_used = option_sense; stdinit ctrl.do_stdinit = option_sense; stdout env.use_stdout = option_sense; @@ -958,14 +959,17 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ "{" ACTION_ECHO; ++bracelevel; "}" ACTION_ECHO; --bracelevel; yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { - context_call(yytext); + if (ctrl.rewrite) + context_call(yytext); + else + ACTION_ECHO; } yyterminate\(\)|yyreject\(\)|yyless\({FUNARGS}\) { add_action("]""]"); add_action(yytext); add_action("[""["); } - [^[:alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; + [^[:Alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; {NAME} ACTION_ECHO; "'"([^''\\\n]|\\.)"'" ACTION_ECHO; /* character constant */ "'" ACTION_ECHO; BEGIN(CHARACTER_CONSTANT); diff --git a/src/skeletons.c b/src/skeletons.c index 707455f..ec65f5f 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -109,6 +109,7 @@ void backend_by_name(const char *name) flexerror(_("no such back end")); } backend_ok: + ctrl.rewrite = !is_default_backend(); ctrl.backend_name = xstrdup(skel_property("M4_PROPERTY_BACKEND_NAME")); ctrl.traceline_re = xstrdup(skel_property("M4_PROPERTY_TRACE_LINE_REGEXP")); ctrl.traceline_template = xstrdup(skel_property("M4_PROPERTY_TRACE_LINE_TEMPLATE")); -- cgit v1.2.1 From 2e6b59bb7ac98ab3eba374f6b44a6fa1e16c65ba Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 3 Nov 2020 06:18:36 -0500 Subject: Documentation polishing. --- doc/flex.texi | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 32ba29e..6d59af8 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1498,7 +1498,7 @@ When the target language is C/C++, @code{yyterminate()} is a macro. Redefining it using the C/C++ preprocessor in your definitions section is allowed, but not recommended as doing this makes code more difficult to port out of C/C++. In other target languages you can -swt whatt yyterminate() explants to wih @code{%opyion yyterminate}. +swt what yyterminate() expands to with @code{%option yyterminate}. @node Generated Scanner, Start Conditions, Actions, Top @chapter The Generated Scanner @@ -2476,12 +2476,12 @@ holds the length of the current token. @item FILE *yyin is the file which by default @code{flex} reads from. In target languages other than C/C++, expect it to have -whatever tyoe is associated with I/O streams. It may be +whatever natine type is associated with I/O streams. It may be redefined but doing so only makes sense before scanning begins or after an EOF has been encountered. Changing it in the midst of scanning will have unexpected results since @code{flex} buffers its input; use @code{yyrestart()} instead. Once scanning terminates because an -end-of-file has been seen, you can assign @file{yyin} at the new input +end-of-file has been seen, you can assign @file{yyin} to be the new input file and then call the scanner again to continue scanning. @findex yyrestart @@ -3132,9 +3132,9 @@ scanner, which simply calls @code{yylex()}. This option implies @opindex yyterminate @hkindex yyterminate @item @code{%option yyterminate} -This is a sting-valuued option with which you can specify an expansion -of the yyterminate() hook. whuch normally vaauses the generated -scanner to return 0 as an end-of-infit indication. +This is a string-valuued option with which you can specify an expansion +of the yyterminate() hook. whuch normally causes the generated +scanner to return 0 as an end-of-input indication. @anchor{option-nounistd} @opindex ---nounistd @@ -4844,7 +4844,8 @@ and @code{YY_FLEX_SUBMINOR_VERSION} indicating which version of @code{flex} generated the scanner. For example, for the 2.5.22 release, these defines would be 2, 5 and 22 respectively. If the version of @code{flex} being used is a beta -version, then the symbol @code{FLEX_BETA} is defined. +version, then the symbol @code{FLEX_BETA} is defined (on the default C +back end only). @item The symbols @samp{[[} and @samp{]]} in the code sections of the input @@ -4887,9 +4888,9 @@ yy_at_bol() @item yystart() @item -YY_USER_ACTION +%option pre-action @item -YY_USER_INIT +%option user-init @item #line directives @item @@ -4922,7 +4923,8 @@ is (rather surprisingly) truncated to @end example @code{flex} does not truncate the action. Actions that are not enclosed -in braces are simply terminated at the end of the line. +in braces are simply terminated at the end of the line. It is good +style to use the explicit braces, though. @node Memory Management, Serialized Tables, Lex and Posix, Top @chapter Memory Management @@ -4930,7 +4932,8 @@ in braces are simply terminated at the end of the line. @cindex memory management @anchor{memory-management} This chapter describes how flex handles dynamic memory, and how you can -override the default behavior. +override the default behavior. You can safely skip it if your target +language has automatic memory management. @menu * The Default Memory Management:: @@ -9014,7 +9017,7 @@ FLEX_DEBUG: Outside the default C back end, this is a constant of type bool rather rthan a preprocessor symbol. @item -YY_FLEX_SUBMINOR_VERSION: Its behavior an't be replivated without the +FLEX_BETA: Its behavior can't be replicated without the C preprocessor. Test for YY_FLEX_SUBMINOR_VERSION instead. @item -- cgit v1.2.1 From 9b27be4b2ef4fb44eda1ee0ff76a960c4d7b0819 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 3 Nov 2020 12:58:06 -0500 Subject: YY_AT_BOL() -> yyatbol(), yy_set_bol() -> yysetbol(), and make them magic. The tradeoff is a bit delicate here; yy_set_bol() did not strictly speaking need to change. On the other hand, squeezing the underscores out of YY_AT_BOL() but not yy_set_bol() would have been exactly the kind of irregularity that people trip over and curse. The underlying issue is of course languages like Go and Python with validators that get upset by all caps and embedded underscores. On the one hand, we want to not be churning the Flex API gratuitously. On the other hand it is desirable if as few entry point names as possible need to change in different target languages. The approach I'm taking to deciding this question in individual cases is this: if an entry point name is likely to appear in actions, and must be recognized as magic by Flex itself in order to have a final context argument added or an object reference prepended, then it must be multilanguage-safe - not all-caps and no underscores. Any name that does *not* need to be wired into Flex can be left alone. Users may have to change it when they port. --- doc/flex.texi | 40 +++++++++++++++++++++++++--------------- src/c99-flex.skl | 39 +++++++++++++++++++++------------------ src/cpp-flex.skl | 35 ++++++++++++++++++++++------------- src/scan.l | 2 +- 4 files changed, 69 insertions(+), 47 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 6d59af8..c9d1dd3 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -205,7 +205,7 @@ FAQ * Can I fake multi-byte character support?:: * deleteme01:: * Can you discuss some flex internals?:: -* yyunput() messes up yy_at_bol:: +* yyunput() messes up yyatbol:: * The | operator is not doing what I want:: * Why can't flex understand this variable trailing context pattern?:: * The ^ operator isn't working:: @@ -2411,8 +2411,8 @@ use of this entry point overrides @code{%option always-interactive} or the buffer that is (or is not) to be considered interactive. @cindex BOL, setting it -@findex yy_set_bol -The rule hook @code{yy_set_bol(at_bol)} can be used to control whether the +@findex yysetbol +The rule hook @code{yysetbol(at_bol)} can be used to control whether the current buffer's scanning context for the next token match is done as though at the beginning of a line. A non-zero argument makes rules anchored with @samp{^} active, while a zero argument makes @@ -2420,8 +2420,8 @@ rules anchored with @samp{^} active, while a zero argument makes @cindex BOL, checking the BOL flag @cindex rule hook -@findex yy_at_bol -The rule hook @code{yy_at_bol()} returns true if the next token scanned from +@findex yyatbol +The rule hook @code{yyatbol()} returns true if the next token scanned from the current buffer will have @samp{^} rules active, false otherwise. @hkindex %option post-action @@ -4877,9 +4877,9 @@ yyterminate() @item yy_set_interactive() @item -yy_set_bol() +yysetbol() @item -yy_at_bol() +yyatbol() <> @item <*> @@ -5622,7 +5622,7 @@ publish them here. * Can I fake multi-byte character support?:: * deleteme01:: * Can you discuss some flex internals?:: -* yyunput() messes up yy_at_bol:: +* yyunput() messes up yyatbol:: * The | operator is not doing what I want:: * Why can't flex understand this variable trailing context pattern?:: * The ^ operator isn't working:: @@ -6663,8 +6663,8 @@ See above. @end example @c TODO: Evaluate this faq. -@node yyunput() messes up yy_at_bol -@unnumberedsec yyunput() messes up yy_at_bol +@node yyunput() messes up yyatbol +@unnumberedsec yyunput() messes up yyatbol @example @verbatim To: Xinying Li @@ -6674,10 +6674,10 @@ Date: Wed, 13 Nov 1996 19:51:54 PST From: Vern Paxson > "yyunput()" them to input flow, question occurs. If I do this after I scan -> a carriage, the variable "yy_current_buffer()->yy_at_bol" is changed. That +> a carriage, the variable "yy_current_buffer()->yyatbol" is changed. That > means the carriage flag has gone. -You can control this by calling yy_set_bol(). It's described in the manual. +You can control this by calling yysetbol(). It's described in the manual. > And if in pre-reading it goes to the end of file, is anything done > to control the end of curren buffer and end of file? @@ -7757,7 +7757,7 @@ I agree that this is counter-intuitive for yyless(), given its functional description (it's less so for unput(), depending on whether you're unput()'ing new text or scanned text). But I don't plan to change it any time soon, as it's a pain to do so. Consequently, -you do indeed need to use yy_set_bol() and yy_at_bol() to tweak +you do indeed need to use yysetbol() and yyatbol() to tweak your scanner into the behavior you desire. Sorry for the less-than-completely-satisfactory answer. @@ -8961,10 +8961,13 @@ REJECT: Replaced by yyreject() #define YY_INPUT: Replaced by the @code{noyyread} option. @item -YYSTART: Replaced by yystart() +YYSTART: Replaced by yystart(). @item -YY_AT_BOL: Replaced by yy_at_bol() +YY_AT_BOL(): Replaced by yyatbol(). + +@item +yy_set_bol(): Replaced by yysetbol() @item input(): Replaced by yyinput(). This function was already yyinput() @@ -9030,6 +9033,13 @@ the @code{yyterminate} option. @end itemize +Where entry point names have been downcased and had underscores +removed, it's because some languages in the expected target set for +Flex - notably Go and Python - have validator/linter tools that would +complain about uppercase or underscores or both. It would obviously be best +if the parts of the public API that have to change to conform to +local conventions are small and not commonly used. + @node Indices, , Appendices, Top @unnumbered Indices diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 713ae09..af075f6 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -330,7 +330,7 @@ struct yy_buffer_state { * If so, '^' rules will be active on the next match, otherwise * not. */ - bool yy_at_bol_flag; + bool yyatbol_flag; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ @@ -896,9 +896,9 @@ int yyinput (yyscan_t yyscanner) yyscanner->yy_hold_char = *++yyscanner->yy_c_buf_p; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (c == '\n'); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol ) { + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag ) { yybumpline( yyscanner ); } ]]) @@ -1042,7 +1042,7 @@ m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ static void rule_check_bol(yyscan_t yyscanner) { if ( yyscanner->yyleng_r > 0 ) { \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); } } ]]) @@ -1132,16 +1132,6 @@ static void yybumpline( yyscan_t yyscanner) { } \ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } -#define yy_set_bol(at_bol) \ - { \ - if ( yy_current_buffer() == NULL ) { \ - yyensure_buffer_stack (yyscanner); \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = \ - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); \ - } \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag = at_bol; \ -} -#define yy_at_bol() (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_at_bol_flag) m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ @@ -1168,6 +1158,19 @@ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ /* END access macros for use in actions */ +void yysetbol(bool at_bol, yyscan_t yyscanner) { + if ( yy_current_buffer() == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = at_bol; +} + +bool yyatbol(yyscan_t yyscanner) { + return (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag); +} + %# Code snippets used in various cases of code generation in the main scanner. m4_define([[M4_GEN_BACKING_UP]], [[ @@ -1228,12 +1231,12 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[yyscanner->yy_start + yy_at_bol()];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[yyscanner->yy_start + yyatbol()];]]) m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ yy_current_state = yyscanner->yy_start; -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yy_at_bol();]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yyatbol(yyscanner);]]) /* Set up for storing up states. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yyscanner->yy_state_ptr = yyscanner->yy_state_buf; @@ -2051,7 +2054,7 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol_flag = true; + b->yyatbol_flag = true; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer() ) { @@ -2185,7 +2188,7 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; - b->yy_at_bol_flag = true; + b->yyatbol_flag = true; b->yy_fill_buffer = false; b->yy_buffer_status = YY_BUFFER_NEW; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 1481def..f7b32af 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -543,7 +543,7 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[ * If so, '^' rules will be active on the next match, otherwise * not. */ - int yy_at_bol; + int yyatbol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ @@ -665,18 +665,27 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } -#define yy_set_bol(at_bol) \ +#define yysetbol(at_bol) \ { \ if ( yy_current_buffer() == NULL ) { \ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + YY_CURRENT_BUFFER_LVALUE->yyatbol = at_bol; \ } -#define yy_at_bol() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +#define yyatbol() (YY_CURRENT_BUFFER_LVALUE->yyatbol) /* Legacy interface */ -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yyatbol) +#define yy_set_bol(at_bol) \ + { \ + if ( yy_current_buffer() == NULL ) { \ + yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yyatbol = at_bol; \ +} ]]) /* Begin user sect3 */ @@ -1726,7 +1735,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], [[ #define YY_RULE_SETUP \ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ if ( yyleng > 0 ) { \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (yytext[yyleng - 1] == '\n'); \ + YY_CURRENT_BUFFER_LVALUE->yyatbol = (yytext[yyleng - 1] == '\n'); \ } \ ]]) YY_USER_ACTION ]]) @@ -1791,12 +1800,12 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + yy_at_bol()];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[YY_G(yy_start) + yyatbol()];]]) m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[YY_G(yy_start)];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ yy_current_state = YY_G(yy_start); -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yy_at_bol();]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yyatbol();]]) /* Set up for storing up states. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ YY_G(yy_state_ptr) = YY_G(yy_state_buf); @@ -2773,9 +2782,9 @@ int yyFlexLexer::yyinput() YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + YY_CURRENT_BUFFER_LVALUE->yyatbol = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) { + if ( YY_CURRENT_BUFFER_LVALUE->yyatbol ) { M4_YY_INCR_LINENO(); } ]]) @@ -3048,7 +3057,7 @@ void yyFlexLexer::yy_flush_buffer( yybuffer b ) b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; + b->yyatbol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer() ) { @@ -3206,7 +3215,7 @@ yybuffer yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; - b->yy_at_bol = 1; + b->yyatbol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; @@ -4266,7 +4275,7 @@ m4_ifdef( [[M4_YY_IN_HEADER]], [[ #undef YY_NEW_FILE #undef YY_FLUSH_BUFFER -#undef yy_set_bol +#undef yysetbol #undef yy_new_buffer #undef yy_set_interactive #undef YY_DO_BEFORE_ACTION diff --git a/src/scan.l b/src/scan.l index 56f85e6..6767463 100644 --- a/src/scan.l +++ b/src/scan.l @@ -958,7 +958,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ { "{" ACTION_ECHO; ++bracelevel; "}" ACTION_ECHO; --bracelevel; - yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\) { + yyecho\(\)|yyinput\(\)|yystart\({FUNARGS}\)|yybegin\({FUNARGS}\)|yyunput\({FUNARGS}\)|yypanic\({FUNARGS}\)|yyatbol\(\)|yysetbol\({FUNARGS}\) { if (ctrl.rewrite) context_call(yytext); else -- cgit v1.2.1 From b9414d653c78baf0c795584aeb6404a863494994 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 4 Nov 2020 02:40:37 -0500 Subject: Revert "Successful m4ization of yyreject()." There seems to be something in the build recipe or test system that makes the yyreject test unreliable. Reverting until I figure out what. --- src/c99-flex.skl | 47 +++++++++++++++++++++++------------------------ src/scan.l | 2 +- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index af075f6..2a700d7 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -82,7 +82,7 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) -%# Return all but the first "n" matched characters back to the input stream. +/* Return all but the first "n" matched characters back to the input stream. */ m4_define([[yyless]], [[ do { /* Undo effects of setting up yytext. */ @@ -95,29 +95,6 @@ m4_define([[yyless]], [[ } while ( 0 ) ]]) -m4_ifdef([[M4_MODE_USES_REJECT]],[[ -%# Can't be given the context-arg treatment due to the goto. -m4_define([[yyreject]], [[ -{ -*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext $1 */ -yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ -yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ -yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ -yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ -]]) -++yyscanner->yy_lp; -goto find_rule; -} -]]) -]]) -m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ -/* The intent behind this definition is that it'll catch - * any uses of yyreject() which flex missed. - */ -m4_define([[yyreject()]], [[reject_used_but_not_detected]]) -]]) - %% [0.0] Make hook macros available to Flex const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; @@ -1133,6 +1110,28 @@ static void yybumpline( yyscan_t yyscanner) { yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } +m4_ifdef( [[M4_MODE_USES_REJECT]],[[ +%# Can't be given the context-arg treatment due to the goto. +#define yyreject() \ +{ \ +*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ \ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ +yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ \ +yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ \ +]]) \ +++yyscanner->yy_lp; \ +goto find_rule; \ +} +]]) +m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ +/* The intent behind this definition is that it'll catch + * any uses of yyreject() which flex missed. + */ +#define yyreject() reject_used_but_not_detected +]]) + m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) diff --git a/src/scan.l b/src/scan.l index 6767463..88b38b8 100644 --- a/src/scan.l +++ b/src/scan.l @@ -964,7 +964,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ else ACTION_ECHO; } - yyterminate\(\)|yyreject\(\)|yyless\({FUNARGS}\) { + yyterminate\(\)|yyless\({FUNARGS}\) { add_action("]""]"); add_action(yytext); add_action("[""["); -- cgit v1.2.1 From d056db08e660c7513b5d57985e09c5a7e3e3e4b4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 4 Nov 2020 05:28:19 -0500 Subject: Fix errors that were masking problems with yyreject(). Ensure that derived skel.h includes are removed on every clean. Fix a bad shell line that prevented proper cleaming of derived *.c files from tests. --- src/Makefile.am | 3 ++- tests/ruleset.am | 2 +- tests/ruleset.sh | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d969f23..52d8aa5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -97,7 +97,8 @@ EXTRA_DIST = \ CLEANFILES = stage1scan.c stage1flex$(EXEEXT) -MAINTAINERCLEANFILES = cpp-skel.h c99-skel.h +clean-local: + rm -f *-skel.h cpp-skel.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp diff --git a/tests/ruleset.am b/tests/ruleset.am index f9a0211..a9f5036 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -581,5 +581,5 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posixlycorrect_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posixlycorrect_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 5447052..0520177 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -71,7 +71,7 @@ for backend in "$@" ; do echo "" RULESET_TESTS="${RULESET_TESTS} test-yydecl-${backend}.sh" - RULESET_REMOVABLES="${RULESET_TESTS} test-yydecl-${backend}.sh" + RULESET_REMOVABLES="${RULESET_REMOVABLES} test-yydecl-${backend}.sh" done echo "" -- cgit v1.2.1 From ec140e6477c4bcd09ae6e92b24c351e8f006e0cd Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 4 Nov 2020 12:47:16 -0500 Subject: m4ize yyreject() handling. --- src/c99-flex.skl | 46 +++++++++++++++++++--------------------------- src/cpp-flex.skl | 2 ++ src/scan.l | 3 ++- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 2a700d7..22ac95d 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -53,10 +53,10 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, cp, bp); /* set up yytext */]]) -m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */]]) -m4_define([[M4_HOOK_CHAR_REWIND]], [[YY_G(yy_c_buf_p) = yy_cp -= $1;]]) +m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */]]) +m4_define([[M4_HOOK_CHAR_REWIND]], [[yyscanner->yy_c_buf_p = yy_cp -= $1;]]) m4_define([[M4_HOOK_LINE_REWIND]], [[yy_lineno_rewind_to(yy_cp, yy_cp - $1, yyscanner);]]) -m4_define([[M4_HOOK_CHAR_FORWARD]], [[YY_G(yy_c_buf_p) = yy_cp = yy_bp + $1;]]) +m4_define([[M4_HOOK_CHAR_FORWARD]], [[yyscanner->yy_c_buf_p = yy_cp = yy_bp + $1;]]) m4_define([[M4_HOOK_LINE_FORWARD]], [[yy_lineno_rewind_to(yy_cp, yy_bp + $1, yyscanner);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; ]]) @@ -74,7 +74,7 @@ m4_define([[M4_HOOK_SET_RULE_SETUP]], [[m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ rule_check_bol(yyscanner); ]]) m4_ifdef([[YY_USER_ACTION]], YY_USER_ACTION) ]]) -m4_define([[M4_HOOK_SET_PREACTION]], [[m4_defiine([[YY_USER_ACTION]], [[$1]])]]) +m4_define([[M4_HOOK_SET_PREACTION]], [[m4_define([[YY_USER_ACTION]], [[$1]])]]) m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) @@ -95,6 +95,20 @@ m4_define([[yyless]], [[ } while ( 0 ) ]]) +%# Can't be a function given the context-arg treatment due to the goto. +m4_define([[M4_HOOK_REJECT]], [[{ + *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ + yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ + yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ + yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ +]]) + ++yyscanner->yy_lp; + goto find_rule; +} +]]) + %% [0.0] Make hook macros available to Flex const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; @@ -1110,28 +1124,6 @@ static void yybumpline( yyscan_t yyscanner) { yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } -m4_ifdef( [[M4_MODE_USES_REJECT]],[[ -%# Can't be given the context-arg treatment due to the goto. -#define yyreject() \ -{ \ -*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ \ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ \ -yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ \ -yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ \ -]]) \ -++yyscanner->yy_lp; \ -goto find_rule; \ -} -]]) -m4_ifdef( [[M4_MODE_NO_USES_REJECT]],[[ -/* The intent behind this definition is that it'll catch - * any uses of yyreject() which flex missed. - */ -#define yyreject() reject_used_but_not_detected -]]) - m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ #define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) @@ -1690,7 +1682,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yypanic( - "input buffer overflow, can't enlarge buffer because scanner uses yyreject()", yyscanner ); + "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); ]], [[ /* just a shorter name for the current buffer */ diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index f7b32af..04c6255 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -78,6 +78,8 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho();]]) m4_ifdef([[M4_MODE_YYTERMINATE]], [[m4_define([[yyterminate]], [[M4_MODE_YYTERMINATE]])]]) +m4_define([[M4_HOOK_REJECT]], [[yyreject()]]) + %% [0.0] Make hook macros available to Flex m4_ifdef( [[M4_YY_IN_HEADER]], [[m4_dnl diff --git a/src/scan.l b/src/scan.l index 88b38b8..f9fcd36 100644 --- a/src/scan.l +++ b/src/scan.l @@ -154,6 +154,7 @@ FUNARGS [^)]* %{ void context_call(char *); +#undef yyreject %} %% static int bracelevel, didadef, indented_code; @@ -930,7 +931,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ CHECK_REJECT(yytext); } "yyreject()" { - ACTION_ECHO; + add_action("]""]M4_HOOK_REJECT[""["); CHECK_YYREJECT(yytext); } "yymore" { -- cgit v1.2.1 From 8aabc897cd0729b9961b8b919a6ed7331cc32aca Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 6 Nov 2020 14:59:54 -0500 Subject: Add a test for yymore, and fix a bug it turned up. --- src/c99-flex.skl | 2 +- src/cpp-flex.skl | 2 +- tests/.gitignore | 2 ++ tests/ruleset.am | 16 ++++++++++++++-- tests/testmaker.m4 | 3 +++ tests/yymore.rules | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 tests/yymore.rules diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 22ac95d..6bc60f5 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1045,7 +1045,7 @@ static void rule_check_bol(yyscan_t yyscanner) { */ void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { yyscanner->yytext_ptr = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; \ yyscanner->yyleng_r = (int) (yy_cp - yyscanner->yytext_ptr);]])]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 04c6255..c28d671 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -852,7 +852,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], */ #define YY_DO_BEFORE_ACTION \ YY_G(yytext_ptr) = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[YY_G(yytext_ptr) -= YY_G(yy_more_len); + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[YY_G(yytext_ptr) -= YY_G(yy_more_len); \ yyleng = (int) (yy_cp - YY_G(yytext_ptr));]])]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyleng = (int) (yy_cp - yy_bp);]]) \ diff --git a/tests/.gitignore b/tests/.gitignore index ddc288d..105ff43 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -113,6 +113,8 @@ yyextra_c99 yyextra_c99.c yyless* !yyless.rules +yymore* +!yymore.rules yyunput* !yyunput.rules test-yydecl-* diff --git a/tests/ruleset.am b/tests/ruleset.am index a9f5036..ddbafc2 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -53,6 +53,10 @@ yyless_nr_SOURCES = yyless_nr.l yyless_nr.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yymore_nr_SOURCES = yymore_nr.l +yymore_nr.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyunput_nr_SOURCES = yyunput_nr.l yyunput_nr.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -237,6 +241,10 @@ yyless_r_SOURCES = yyless_r.l yyless_r.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yymore_r_SOURCES = yymore_r.l +yymore_r.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyunput_r_SOURCES = yyunput_r.l yyunput_r.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -421,6 +429,10 @@ yyless_c99_SOURCES = yyless_c99.l yyless_c99.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yymore_c99_SOURCES = yymore_c99.l +yymore_c99.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyunput_c99_SOURCES = yyunput_c99.l yyunput_c99.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -580,6 +592,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posixlycorrect_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posixlycorrect_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posixlycorrect_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posixlycorrect_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 263e792..dd0d97a 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -45,6 +45,7 @@ define(`M4_TEST_PREAMBLE', `dnl ')dnl close preamble define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') +define(`M4_TEST_ASSERT', `if (!($1)) {fprintf(stderr,"ASSERT FAILED.\n"); exit(1);}') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -82,6 +83,7 @@ define(`M4_TEST_PREAMBLE', `dnl ')dnl close preamble define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') +define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED.\n"); exit(1);}') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -129,6 +131,7 @@ import ( ')dnl close preamble define(`M4_TEST_DO', `$1') define(`M4_TEST_FAILMESSAGE', `log.Fatal("TEST FAILMESSAGE"); os.Exit(1);') +define(`M4_TEST_ASSERT', `if !$1 {Fprintf(os.Stderr,"ASSERT FAILED.\n"); os.Exit(1);}') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { lexer := new(FlexLexer) diff --git a/tests/yymore.rules b/tests/yymore.rules new file mode 100644 index 0000000..17600e5 --- /dev/null +++ b/tests/yymore.rules @@ -0,0 +1,34 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /* + * Test yymore. What should haooen is: + * 1. "foo" is matched by the first rule but not consumed. + * 2. "bar" is matched, but the token length is 6 rather than 3. + */ + +%option nounput noyywrap noyylineno warn noinput +%% +foo {M4_TEST_DO(yymore())} +bar {M4_TEST_ASSERT(yyleng == 6)} +### +foobar -- cgit v1.2.1 From 191d7068c3045e3a966800428d64881590cf61a5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 6 Nov 2020 13:19:17 -0500 Subject: Fully m4ize yymore() --- doc/flex.texi | 11 ++++++----- src/c99-flex.skl | 27 +++++++++++++-------------- src/scan.l | 21 ++++++++++----------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index c9d1dd3..7a52029 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -2721,11 +2721,12 @@ Python, etc. @item @code{%option rewrite} Back ends other than the default C generator can't assume they have the C preprocessor available. Therefore, Flex recognizes the -following function calls - yyecho(), yyinput(), yystart(), yybegin(), -yyunput(), yypanic() and rewreites them adding a yyscanner final -aergument as though they were C macros. This optiion is set to false -whrn you select or default to the C back end, and to true otherwise. -You can turn it off (or on) expliciltly after your emit option. +following function calls - yyecho(), yyless(), yymore(), yyinput(), +yystart(), yybegin(), yyunput(), yypanic() - and rewreites them adding a +yyscanner final argument as though they were C macros. This optiion +is set to false whrn you select or default to the C back end, and to +true otherwise. You can turn it off (or on) explicitly after your +emit option. @anchor{option-case-insensitive} @opindex -i diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 6bc60f5..017d2cb 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1124,31 +1124,30 @@ static void yybumpline( yyscan_t yyscanner) { yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ } +/* END access macros for use in actions */ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyscanner->yy_more_offset = strlen(yyscanner->yytext_r)) -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET \ -{ \ -yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; \ -yyscanner->yyleng_r -= yyscanner->yy_more_offset; \ +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ +yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; +yyscanner->yyleng_r -= yyscanner->yy_more_offset; } ]]) +]]) m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -#define yymore() (yyscanner->yy_more_flag = true) -#define YY_MORE_ADJ yyscanner->yy_more_len -#define YY_RESTORE_YY_MORE_OFFSET +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} +m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) ]]) m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) -/* END access macros for use in actions */ - void yysetbol(bool at_bol, yyscan_t yyscanner) { if ( yy_current_buffer() == NULL ) { yyensure_buffer_stack (yyscanner); diff --git a/src/scan.l b/src/scan.l index f9fcd36..02220e2 100644 --- a/src/scan.l +++ b/src/scan.l @@ -88,10 +88,6 @@ extern const char *escaped_qstart, *escaped_qend; if ( all_lower( str ) ) \ reject = true; -#define CHECK_YYMORE(str) \ - if ( all_lower( str ) ) \ - yymore_used = true; - #define YY_USER_INIT \ if ( getenv("POSIXLY_CORRECT") ) \ ctrl.posix_compat = true; @@ -927,16 +923,19 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ { "reject" { - ACTION_ECHO; - CHECK_REJECT(yytext); + ACTION_ECHO; + CHECK_REJECT(yytext); } "yyreject()" { - add_action("]""]M4_HOOK_REJECT[""["); - CHECK_YYREJECT(yytext); + add_action("]""]M4_HOOK_REJECT[""["); + CHECK_YYREJECT(yytext); } - "yymore" { - ACTION_ECHO; - CHECK_YYMORE(yytext); + "yymore()" { + yymore_used = true; + if (ctrl.rewrite) + context_call(yytext); + else + ACTION_ECHO; } } -- cgit v1.2.1 From db1dca76c1fd042516661218ba588a0aae682587 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 8 Nov 2020 06:23:29 -0500 Subject: Make the rewrite flag visible. --- src/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.c b/src/main.c index 434f19a..e86d86b 100644 --- a/src/main.c +++ b/src/main.c @@ -1690,6 +1690,11 @@ void readin (void) if (ctrl.stack_used) visible_define("M4_YY_STACK_USED"); + if (ctrl.rewrite) + visible_define ( "M4_MODE_REWRITE"); + else + visible_define ( "M4_MODE_NO_REWRITE"); + comment("END of m4 controls\n"); out ("\n"); } -- cgit v1.2.1 From 2995af0eeb3792506f2b9975788443f67ac4b389 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 8 Nov 2020 13:30:49 -0500 Subject: yy_flex_debug -> yyflexdebug. --- src/FlexLexer.h | 6 +++--- src/c99-flex.skl | 10 +++++----- src/cpp-flex.skl | 24 ++++++++++++++---------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/FlexLexer.h b/src/FlexLexer.h index 5a1a72f..ccd9eeb 100644 --- a/src/FlexLexer.h +++ b/src/FlexLexer.h @@ -95,14 +95,14 @@ public: int lineno() const { return yylineno; } - int debug() const { return yy_flex_debug; } - void set_debug( int flag ) { yy_flex_debug = flag; } + int debug() const { return yyflexdebug; } + void set_debug( int flag ) { yyflexdebug = flag; } protected: char* yytext; int yyleng; int yylineno; // only maintained if you use %option yylineno - int yy_flex_debug; // only has effect with -d or "%option debug" + int yyflexdebug; // only has effect with -d or "%option debug" }; } diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 017d2cb..3dbdc8d 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -603,7 +603,7 @@ struct yyguts_t { char* yy_last_accepting_cpos; int yylineno_r; - int yy_flex_debug_r; + int yyflexdebug_r; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yy_state_type *yy_state_buf; @@ -1096,7 +1096,7 @@ static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { #define yytext yyscanner->yytext_r #define yylineno (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno) #define yycolumn (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_column) -#define yy_flex_debug yyscanner->yy_flex_debug_r +#define yyflexdebug yyscanner->yyflexdebug_r static void yybumpline( yyscan_t yyscanner) { yylineno++; @@ -1456,7 +1456,7 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], do_action: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ - if ( yy_flex_debug ) { + if ( yyflexdebug ) { if ( yy_act == 0 ) { fprintf( stderr, "--scanner backing up\n" ); } else if ( yy_act < YY_NUM_RULES ) { @@ -2456,14 +2456,14 @@ void yyset_out( FILE * _out_str, yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ int yyget_debug (yyscan_t yyscanner) { - return yy_flex_debug; + return yyflexdebug; } ]]) m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ void yyset_debug(int _bdebug, yyscan_t yyscanner) { - yy_flex_debug = _bdebug ; + yyflexdebug = _bdebug ; } ]]) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index c28d671..200bfaa 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -104,7 +104,7 @@ m4_ifelse(M4_MODE_PREFIX,yy,, #define yypush_buffer_state M4_MODE_PREFIX[[push_buffer_state]] #define yypop_buffer_state M4_MODE_PREFIX[[pop_buffer_state]] #define yyensure_buffer_stack M4_MODE_PREFIX[[ensure_buffer_stack]] -#define yy_flex_debug M4_MODE_PREFIX[[_flex_debug]] +#define yyflexdebug M4_MODE_PREFIX[[flexdebug]] #define yyin M4_MODE_PREFIX[[in]] #define yyleng M4_MODE_PREFIX[[leng]] #define yylex M4_MODE_PREFIX[[lex]] @@ -232,7 +232,7 @@ m4_ifdef( [[M4_YY_NOT_REENTRANT]], M4_GEN_PREFIX(`leng') M4_GEN_PREFIX(`in') M4_GEN_PREFIX(`out') - M4_GEN_PREFIX(`_flex_debug') + M4_GEN_PREFIX(`flexdebug') M4_GEN_PREFIX(`lineno') ]]) ) @@ -354,7 +354,7 @@ m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) #define yytext YY_G(yytext_r) #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug YY_G(yy_flex_debug_r) +#define yyflexdebug YY_G(yyflexdebug_r) m4_define( [[M4_YY_INCR_LINENO]], [[ @@ -874,8 +874,12 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef([[M4_YY_NOT_REENTRANT]], [[ m4_ifdef( [[M4_MODE_C_ONLY]], [[ -extern int yy_flex_debug; -int yy_flex_debug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); +extern int yyflexdebug; +int yyflexdebug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); +/* Legacy interface */ +#ifndef yy_flex_debug +#define yy_flex_debug yyflexdebug +#endif ]]) ]]) @@ -1216,7 +1220,7 @@ struct yyguts_t { char* yy_last_accepting_cpos; int yylineno_r; - int yy_flex_debug_r; + int yyflexdebug_r; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ yy_state_type *yy_state_buf; @@ -2063,7 +2067,7 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], do_action: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ - if ( yy_flex_debug ) { + if ( yyflexdebug ) { if ( yy_act == 0 ) { m4_ifdef([[M4_MODE_CXX_ONLY]], [[ std::cerr << "--scanner backing up\n"; @@ -2296,7 +2300,7 @@ void yyFlexLexer::ctor_common() { yy_c_buf_p = 0; yy_init = 0; yy_start = 0; - yy_flex_debug = 0; + yyflexdebug = 0; yylineno = 1; // this will only get updated if %option yylineno yy_did_buffer_switch_on_eof = 0; @@ -3558,7 +3562,7 @@ m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ int yyget_debug (M4_YY_DEF_ONLY_ARG) { M4_YY_DECL_GUTS_VAR(); - return yy_flex_debug; + return yyflexdebug; } ]]) @@ -3566,7 +3570,7 @@ m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ void yyset_debug YYFARGS1( int ,_bdebug) { M4_YY_DECL_GUTS_VAR(); - yy_flex_debug = _bdebug ; + yyflexdebug = _bdebug ; } ]]) ]]) -- cgit v1.2.1 From aa782b6233e0914591b0e967d1662449744e9497 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 9 Nov 2020 04:26:56 -0500 Subject: Explain why 3 API functions don't have magic rewrite rules. The functions are: yy_current_buffer(), yy_flush_current_buffer(), and yy_set_interactive(). --- doc/flex.texi | 9 ++++++ src/c99-flex.skl | 96 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 57 insertions(+), 48 deletions(-) diff --git a/doc/flex.texi b/doc/flex.texi index 7a52029..0457279 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -9041,6 +9041,15 @@ complain about uppercase or underscores or both. It would obviously be best if the parts of the public API that have to change to conform to local conventions are small and not commonly used. +This is also why the functions @code{yy_current_buffer()}, +@code{yy_flush_current_buffer()}, and @code{yy_set_interactive()} +do not have rewrite rules (see @xref{option-rewrite}); simply +removing the underscores would have produced names that are +unncomfortably long and hard on the eyeballs. We leave +it to the API binding for each individual target language to +choose whether they should be left as is, camel-cased, or +otherwise adapted to local conventions. + @node Indices, , Appendices, Top @unnumbered Indices diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 3dbdc8d..c2caad1 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1087,6 +1087,32 @@ static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { } ]]) +/* Returns the top of the stack, or NULL. */ +yybuffer yy_current_buffer(yyscan_t yyscanner) { + return ( yyscanner->yy_buffer_stack \ + ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ + : NULL); +} + +void yy_flush_current_buffer(yyscan_t yyscanner) { + yy_flush_buffer( yy_current_buffer(yyscanner), yyscanner); +} + +void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { + if ( yy_current_buffer(yyscanner) == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; +} + + +static void yybumpline( yyscan_t yyscanner) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno++; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_column=0; +} + /* START access macros for use in actions */ #define yyin yyscanner->yyin_r @@ -1098,32 +1124,6 @@ static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { #define yycolumn (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_column) #define yyflexdebug yyscanner->yyflexdebug_r -static void yybumpline( yyscan_t yyscanner) { - yylineno++; - yycolumn=0; -} - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define yy_current_buffer() ( yyscanner->yy_buffer_stack \ - ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ - : NULL) - -#define yy_flush_current_buffer() yy_flush_buffer( yy_current_buffer(), yyscanner) - -#define yy_set_interactive(is_interactive) { \ - if ( yy_current_buffer() == NULL ) { \ - yyensure_buffer_stack (yyscanner); \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = \ - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); \ - } \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; \ -} - /* END access macros for use in actions */ m4_ifdef([[M4_MODE_YYMORE_USED]], [[ @@ -1149,7 +1149,7 @@ m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) void yysetbol(bool at_bol, yyscan_t yyscanner) { - if ( yy_current_buffer() == NULL ) { + if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); @@ -1293,7 +1293,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], if ( yyscanner->yyout_r == NULL ) { yyscanner->yyout_r = stdout; } - if ( yy_current_buffer() == NULL ) { + if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); @@ -1506,7 +1506,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure - * consistency between yy_current_buffer() and our + * consistency between yy_current_buffer(yyscanner) and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. @@ -1883,13 +1883,13 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ void yyrestart(FILE * input_file, yyscan_t yyscanner) { - if ( yy_current_buffer() == NULL ) { + if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yy_init_buffer( yy_current_buffer(), input_file, yyscanner); + yy_init_buffer( yy_current_buffer(yyscanner), input_file, yyscanner); yy_load_buffer_state( yyscanner ); } @@ -1906,10 +1906,10 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (yyscanner); - if ( yy_current_buffer() == new_buffer ) { + if ( yy_current_buffer(yyscanner) == new_buffer ) { return; } - if ( yy_current_buffer() ) { + if ( yy_current_buffer(yyscanner) ) { /* Flush out information for old buffer. */ *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; @@ -1976,7 +1976,7 @@ void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) if ( b == NULL ) { return; } - if ( b == yy_current_buffer() ) { /* Not sure if we should pop here. */ + if ( b == yy_current_buffer(yyscanner) ) { /* Not sure if we should pop here. */ yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = (yybuffer) 0; } if ( b->yy_is_our_buffer ) { @@ -2003,7 +2003,7 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ - if (b != yy_current_buffer()) { + if (b != yy_current_buffer(yyscanner)) { b->yy_bs_lineno = 1; b->yy_bs_column = 0; } @@ -2025,7 +2025,7 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], } /** Discard all buffered characters. On the next scan, yyread() will be called. - * @param b the buffer state to be flushed, usually @c yy_current_buffer(). + * @param b the buffer state to be flushed, usually @c yy_current_buffer(yyscanner). * @param yyscanner The scanner object. */ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) @@ -2047,7 +2047,7 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) b->yyatbol_flag = true; b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == yy_current_buffer() ) { + if ( b == yy_current_buffer(yyscanner) ) { yy_load_buffer_state( yyscanner ); } } @@ -2066,7 +2066,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) yyensure_buffer_stack(yyscanner); /* This block is copied from yy_switch_to_buffer. */ - if ( yy_current_buffer() != NULL ) { + if ( yy_current_buffer(yyscanner) != NULL ) { /* Flush out information for old buffer. */ *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; @@ -2074,7 +2074,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) } /* Only push if top exists. Otherwise, replace top. */ - if (yy_current_buffer()) { + if (yy_current_buffer(yyscanner)) { yyscanner->yy_buffer_stack_top++; } yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; @@ -2091,15 +2091,15 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) */ void yypop_buffer_state (yyscan_t yyscanner) { - if (yy_current_buffer() == NULL) { + if (yy_current_buffer(yyscanner) == NULL) { return; } - yy_delete_buffer(yy_current_buffer(), yyscanner); + yy_delete_buffer(yy_current_buffer(yyscanner), yyscanner); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; if (yyscanner->yy_buffer_stack_top > 0) { --yyscanner->yy_buffer_stack_top; } - if (yy_current_buffer() != NULL) { + if (yy_current_buffer(yyscanner) != NULL) { yy_load_buffer_state( yyscanner ); yyscanner->yy_did_buffer_switch_on_eof = true; } @@ -2326,7 +2326,7 @@ m4_ifdef( [[M4_YY_NO_GET_LINENO]],, */ int yyget_lineno (yyscan_t yyscanner) { - if (yy_current_buffer() == NULL) { + if (yy_current_buffer(yyscanner) == NULL) { return 0; } return yylineno; @@ -2340,7 +2340,7 @@ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, */ int yyget_column (yyscan_t yyscanner) { - if (yy_current_buffer() == NULL) { + if (yy_current_buffer(yyscanner) == NULL) { return 0; } return yycolumn; @@ -2409,7 +2409,7 @@ m4_ifdef( [[M4_YY_NO_SET_LINENO]],, void yyset_lineno(int _line_number, yyscan_t yyscanner) { /* lineno is only valid if an input buffer exists. */ - if (yy_current_buffer() == NULL ) { + if (yy_current_buffer(yyscanner) == NULL ) { yypanic( "yyset_lineno called with no buffer", yyscanner ); } yylineno = _line_number; @@ -2425,7 +2425,7 @@ m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, void yyset_column(int _column_no, yyscan_t yyscanner) { /* column is only valid if an input buffer exists. */ - if (yy_current_buffer() == NULL ) { + if (yy_current_buffer(yyscanner) == NULL ) { yypanic( "yyset_column called with no buffer", yyscanner ); } yycolumn = _column_no; @@ -2603,8 +2603,8 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], int yylex_destroy (yyscan_t yyscanner) { /* Pop the buffer stack, destroying each element. */ - while(yy_current_buffer()) { - yy_delete_buffer( yy_current_buffer(), yyscanner ); + while(yy_current_buffer(yyscanner)) { + yy_delete_buffer( yy_current_buffer(yyscanner), yyscanner ); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; yypop_buffer_state(yyscanner); } -- cgit v1.2.1 From 9b68eb3634f1b9edc9e7d35f932661d0ba2a7e7c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 9 Nov 2020 15:39:49 -0500 Subject: Change two member names to make rewite rules easier. --- src/c99-flex.skl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index c2caad1..88947fe 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -323,8 +323,8 @@ struct yy_buffer_state { */ bool yyatbol_flag; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ + int bs_yylineno; /**< The line count. */ + int bs_yycolumn; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. @@ -821,7 +821,7 @@ void yyunput( int c, yyscan_t yyscanner) m4_ifdef( [[M4_MODE_YYLINENO]], [[ if ( c == '\n' ){ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno--; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; } ]]) @@ -1072,7 +1072,7 @@ static void yy_less_lineno(int n, yyscan_t yyscanner) { int yyl; for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { if ( yyscanner->yytext_r[yyl] == '\n' ) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno--; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; } } } @@ -1081,7 +1081,7 @@ static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { const char *p; for ( p = yy_cp-1; p >= dst; --p) { if ( *p == '\n' ) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno--; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; } } } @@ -1109,8 +1109,8 @@ void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { static void yybumpline( yyscan_t yyscanner) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno++; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_column=0; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno++; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn=0; } /* START access macros for use in actions */ @@ -1120,8 +1120,8 @@ static void yybumpline( yyscan_t yyscanner) { #define yyextra yyscanner->yyextra_r #define yyleng yyscanner->yyleng_r #define yytext yyscanner->yytext_r -#define yylineno (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_lineno) -#define yycolumn (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_bs_column) +#define yylineno (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno) +#define yycolumn (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn) #define yyflexdebug yyscanner->yyflexdebug_r /* END access macros for use in actions */ @@ -2004,8 +2004,8 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) * In that case, we don't want to reset the lineno or column. */ if (b != yy_current_buffer(yyscanner)) { - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + b->bs_yylineno = 1; + b->bs_yycolumn = 0; } m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], -- cgit v1.2.1 From 87686ff2fbb94978f8c8bf9dc79284bfcd8343a1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 10 Nov 2020 06:55:22 -0500 Subject: Successful elimination of preprocessor dependencies fromm C99 skeleton. There's only one left. in the prefix code. We leave that in place because ity will be needed if we ever want to replace the default C back end with C99. --- src/c99-flex.skl | 41 +++++++++++++++++------------------------ src/scan.l | 26 ++++++++++++++++++++++++++ tests/lineno_c99.l | 4 ++-- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 88947fe..83dcabd 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -32,6 +32,8 @@ m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]]) m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) +m4_define([[M4_PROPERTY_CONTEXT_FORMAT]], [[yyscanner->%s_r]]) +m4_define([[M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT]], [[yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_%s]]) %# Macro hooks used by Flex code generators start here m4_define([[M4_HOOK_INT32]], [[int32_t]]) @@ -1113,19 +1115,6 @@ static void yybumpline( yyscan_t yyscanner) { yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn=0; } -/* START access macros for use in actions */ - -#define yyin yyscanner->yyin_r -#define yyout yyscanner->yyout_r -#define yyextra yyscanner->yyextra_r -#define yyleng yyscanner->yyleng_r -#define yytext yyscanner->yytext_r -#define yylineno (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno) -#define yycolumn (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn) -#define yyflexdebug yyscanner->yyflexdebug_r - -/* END access macros for use in actions */ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} @@ -1456,7 +1445,7 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], do_action: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ - if ( yyflexdebug ) { + if ( yyscanner->yyflexdebug_r ) { if ( yy_act == 0 ) { fprintf( stderr, "--scanner backing up\n" ); } else if ( yy_act < YY_NUM_RULES ) { @@ -2325,11 +2314,12 @@ m4_ifdef( [[M4_YY_NO_GET_LINENO]],, * @param yyscanner The scanner object. */ int yyget_lineno (yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); - if (yy_current_buffer(yyscanner) == NULL) { + if (cb == NULL) { return 0; } - return yylineno; + return cb->bs_yylineno; } ]]) @@ -2339,11 +2329,12 @@ m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, * @param yyscanner The scanner object. */ int yyget_column (yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); - if (yy_current_buffer(yyscanner) == NULL) { + if (cb == NULL) { return 0; } - return yycolumn; + return cb->bs_yycolumn; } ]]) @@ -2407,12 +2398,13 @@ m4_ifdef( [[M4_YY_NO_SET_LINENO]],, * @param yyscanner The scanner object. */ void yyset_lineno(int _line_number, yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); /* lineno is only valid if an input buffer exists. */ - if (yy_current_buffer(yyscanner) == NULL ) { + if (cb == NULL ) { yypanic( "yyset_lineno called with no buffer", yyscanner ); } - yylineno = _line_number; + cb->bs_yylineno = _line_number; } ]]) @@ -2423,12 +2415,13 @@ m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, * @param yyscanner The scanner object. */ void yyset_column(int _column_no, yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); /* column is only valid if an input buffer exists. */ - if (yy_current_buffer(yyscanner) == NULL ) { + if (cb == NULL ) { yypanic( "yyset_column called with no buffer", yyscanner ); } - yycolumn = _column_no; + cb->bs_yycolumn = _column_no; } ]]) @@ -2456,14 +2449,14 @@ void yyset_out( FILE * _out_str, yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, [[ int yyget_debug (yyscan_t yyscanner) { - return yyflexdebug; + return yyscanner->yyflexdebug_r; } ]]) m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, [[ void yyset_debug(int _bdebug, yyscan_t yyscanner) { - yyflexdebug = _bdebug ; + yyscanner->yyflexdebug_r = _bdebug ; } ]]) diff --git a/src/scan.l b/src/scan.l index 02220e2..87c0d47 100644 --- a/src/scan.l +++ b/src/scan.l @@ -150,6 +150,7 @@ FUNARGS [^)]* %{ void context_call(char *); +void context_member(char *, const char *); #undef yyreject %} %% @@ -969,6 +970,18 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ add_action(yytext); add_action("[""["); } + yyin|yyout|yyextra|yyleng|yytext|yyflexdebug { + if (ctrl.rewrite) + context_member(yytext, "M4_PROPERTY_CONTEXT_FORMAT"); + else + ACTION_ECHO; + } + yylineno|yycolumn { + if (ctrl.rewrite) + context_member(yytext, "M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT"); + else + ACTION_ECHO; + } [^[:Alpha:]_{}""''/\n\[\]]+ ACTION_ECHO; {NAME} ACTION_ECHO; "'"([^''\\\n]|\\.)"'" ACTION_ECHO; /* character constant */ @@ -1103,3 +1116,16 @@ void context_call(char *txt) { add_action(")"); } } + +void context_member(char *txt, const char *prop) { + const char *context_format = skel_property(prop); + + /* if there's no such property, simply pass through */ + if (context_format == NULL) { + add_action(txt); + } else { + char buf[128]; + snprintf(buf, sizeof(buf), context_format, txt); + add_action(buf); + } +} diff --git a/tests/lineno_c99.l b/tests/lineno_c99.l index be46e90..11d402c 100644 --- a/tests/lineno_c99.l +++ b/tests/lineno_c99.l @@ -50,8 +50,8 @@ DIGIT [[:digit:]] - directly modifying yylineno. */ -"yylineno++" yylineno++; -"yylineno--" yylineno--; +"yylineno--" --yylineno; +"yylineno++" ++yylineno; [[:blank:]]+ {WORD} {DIGIT}+(\n{DIGIT}+)* -- cgit v1.2.1 From 2056b2184d018c919b63abd26f1784ebf47077ac Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 10 Nov 2020 07:33:10 -0500 Subject: Add a trailing guard to the magic-rewrite recignizer. --- src/scan.l | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scan.l b/src/scan.l index 87c0d47..871130c 100644 --- a/src/scan.l +++ b/src/scan.l @@ -970,13 +970,13 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ add_action(yytext); add_action("[""["); } - yyin|yyout|yyextra|yyleng|yytext|yyflexdebug { + (yyin|yyout|yyextra|yyleng|yytext|yyflexdebug)/[^[:alnum:]_] { if (ctrl.rewrite) context_member(yytext, "M4_PROPERTY_CONTEXT_FORMAT"); else ACTION_ECHO; } - yylineno|yycolumn { + (yylineno|yycolumn)/[^[:alnum:]_] { if (ctrl.rewrite) context_member(yytext, "M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT"); else -- cgit v1.2.1 From ab32ad65bb13eff5c1210c56d564af2c71516262 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 10 Nov 2020 19:56:39 -0500 Subject: Repair some markup damage in the manual. --- doc/flex.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/flex.texi b/doc/flex.texi index 0457279..30d98dd 100644 --- a/doc/flex.texi +++ b/doc/flex.texi @@ -1,4 +1,4 @@ -busuinput texinfo.tex @c -*-texinfo-*- +\input texinfo.tex @c -*-texinfo-*- @c %**start of header @setfilename flex.info @include version.texi -- cgit v1.2.1 From 3854cd2c67e31ddfacfe5a6b3aba1347e63be420 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Nov 2020 06:16:18 -0500 Subject: Add a test for trailing conyext rules. Fix the bug it turned up. Also, roperly condition some variables related to trailing contexts. Makes generated parsers ever so slightly smaller in this case. --- src/c99-flex.skl | 7 ++++--- src/cpp-flex.skl | 5 +++-- tests/.gitignore | 2 ++ tests/ruleset.am | 16 ++++++++++++++-- tests/trailing.rules | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 tests/trailing.rules diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 83dcabd..8e55384 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -54,7 +54,7 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) -m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, cp, bp); /* set up yytext */]]) +m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext */]]) m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */]]) m4_define([[M4_HOOK_CHAR_REWIND]], [[yyscanner->yy_c_buf_p = yy_cp -= $1;]]) m4_define([[M4_HOOK_LINE_REWIND]], [[yy_lineno_rewind_to(yy_cp, yy_cp - $1, yyscanner);]]) @@ -613,12 +613,13 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ char *yy_full_match; int yy_lp; - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[dnl + /* These are only needed for trailing context rules */ int yy_looking_for_trail_begin; int yy_full_lp; int *yy_full_state; ]]) +]]) m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ char yytext_r[YYLMAX]; char *yytext_ptr; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 200bfaa..4432126 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1228,12 +1228,13 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ char *yy_full_match; int yy_lp; - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[dnl + /* These are only needed for trailing context rules */ int yy_looking_for_trail_begin; int yy_full_lp; int *yy_full_state; ]]) +]]) m4_ifdef( [[M4_MODE_REENTRANT_TEXT_IS_ARRAY]], [[ char yytext_r[YYLMAX]; char *yytext_ptr; diff --git a/tests/.gitignore b/tests/.gitignore index 105ff43..b449a38 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -107,6 +107,8 @@ tableopts* !tableopts.rules top top.[ch] +trailing* +!trailing.rules yyextra_nr yyextra_nr.c yyextra_c99 diff --git a/tests/ruleset.am b/tests/ruleset.am index ddbafc2..983e529 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -49,6 +49,10 @@ tableopts_nr_SOURCES = tableopts_nr.l tableopts_nr.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +trailing_nr_SOURCES = trailing_nr.l +trailing_nr.l: $(srcdir)/trailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyless_nr_SOURCES = yyless_nr.l yyless_nr.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -237,6 +241,10 @@ tableopts_r_SOURCES = tableopts_r.l tableopts_r.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +trailing_r_SOURCES = trailing_r.l +trailing_r.l: $(srcdir)/trailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyless_r_SOURCES = yyless_r.l yyless_r.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -425,6 +433,10 @@ tableopts_c99_SOURCES = tableopts_c99.l tableopts_c99.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +trailing_c99_SOURCES = trailing_c99.l +trailing_c99.l: $(srcdir)/trailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yyless_c99_SOURCES = yyless_c99.l yyless_c99.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -592,6 +604,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr yyless_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r yyless_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 yyless_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posixlycorrect_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posixlycorrect_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posixlycorrect_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posixlycorrect_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/trailing.rules b/tests/trailing.rules new file mode 100644 index 0000000..9389688 --- /dev/null +++ b/tests/trailing.rules @@ -0,0 +1,42 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* + * Test rules with variable trailing context. + * Input should match first rule, but only + * consume the "foo". Therefore the second + * rule should not match, but the third should. + */ + +%option nounput noyywrap noyylineno warn nodefault noinput + +%% + +foo/a+ {M4_TEST_ASSERT(yyleng== 3)} +foo {M4_TEST_FAILMESSAGE} +aa { } +\n { } +. {M4_TEST_FAILMESSAGE} + +### +fooaa -- cgit v1.2.1 From 01850d3ba1f1d0bbfe45a24331fba2192da1f321 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Nov 2020 07:29:05 -0500 Subject: Eliminate almost all forward declarations from C99. One less C-ism to deal wit h when porting to a new target languages. --- src/c99-flex.skl | 1834 ++++++++++++++++++++++------------------------- tests/alloc_extra_c99.l | 19 +- 2 files changed, 871 insertions(+), 982 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 8e55384..ed605a3 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -336,23 +336,9 @@ struct yy_buffer_state { int yy_buffer_status; }; -void yyrestart ( FILE *input_file, yyscan_t yyscanner ); -void yy_switch_to_buffer ( yybuffer new_buffer, yyscan_t yyscanner ); -yybuffer yy_create_buffer ( FILE *file, int size, yyscan_t yyscanner ); -void yy_delete_buffer ( yybuffer b, yyscan_t yyscanner ); -void yy_flush_buffer ( yybuffer b, yyscan_t yyscanner ); -void yypush_buffer_state ( yybuffer new_buffer, yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( yybuffer b, FILE *file, yyscan_t yyscanner ); -static void yybumpline ( yyscan_t yyscanner ); - -yybuffer yy_scan_buffer ( char *base, yy_size_t size, yyscan_t yyscanner ); -yybuffer yy_scan_string ( const char *yy_str, yyscan_t yyscanner ); -yybuffer yy_scan_bytes ( const char *bytes, int len, yyscan_t yyscanner ); - +/* These forwards can simply deleted when poerting to a target language + * with two-pass name resoltion. + */ void *yyalloc ( yy_size_t, yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); void yyfree ( void *, yyscan_t yyscanner ); @@ -384,10 +370,7 @@ m4_define([[yytext_ptr]], [[yytext_r]]) %% [1.0] DFA -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yypanic ( const char* msg, yyscan_t yyscanner ); struct yy_trans_info { /* We require that yy_verify and yy_nxt must be of the same size int. */ @@ -659,152 +642,319 @@ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl int yylex_init_extra ( M4_MODE_EXTRA_TYPE user_defined, yyscan_t* scanner); ]]) -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ +/* Helpers for special functions, also part of public API */ -m4_ifdef( [[M4_YY_NO_DESTROY]],, -[[ -int yylex_destroy ( yyscan_t yyscanner ); -]]) +/* Returns the top of the stack, or NULL. */ +yybuffer yy_current_buffer(yyscan_t yyscanner) { + return ( yyscanner->yy_buffer_stack \ + ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ + : NULL); +} -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, -[[ -int yyget_debug ( yyscan_t yyscanner ); -]]) +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; + yyscanner->yytext_ptr = yyscanner->yy_c_buf_p = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos; + yyscanner->yyin_r = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file; + yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; +} -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, -[[ -void yyset_debug ( int debug_flag, yyscan_t yyscanner ); -]]) +/** Discard all buffered characters. On the next scan, yyread() will be called. + * @param b the buffer state to be flushed, usually @c yy_current_buffer(yyscanner). + * @param yyscanner The scanner object. + */ +void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) +{ + if ( b == NULL ) { + return; + } + b->yy_n_chars = 0; -m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl -m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, -[[ -M4_MODE_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -]]) + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, -[[ -void yyset_extra ( M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner ); -]]) -]]) + b->yy_buf_pos = &b->yy_ch_buf[0]; -m4_ifdef( [[M4_YY_NO_GET_IN]],, -[[ -FILE *yyget_in ( yyscan_t yyscanner ); -]]) + b->yyatbol_flag = true; + b->yy_buffer_status = YY_BUFFER_NEW; -m4_ifdef( [[M4_YY_NO_SET_IN]],, -[[ -void yyset_in ( FILE * _in_str, yyscan_t yyscanner ); -]]) + if ( b == yy_current_buffer(yyscanner) ) { + yy_load_buffer_state( yyscanner ); + } +} -m4_ifdef( [[M4_YY_NO_GET_OUT]],, -[[ -FILE *yyget_out ( yyscan_t yyscanner ); -]]) +void yy_flush_current_buffer(yyscan_t yyscanner) { + yy_flush_buffer( yy_current_buffer(yyscanner), yyscanner); +} -m4_ifdef( [[M4_YY_NO_SET_OUT]],, -[[ -void yyset_out ( FILE * _out_str, yyscan_t yyscanner ); -]]) +const int YY_EXIT_FAILURE = 2; -m4_ifdef( [[M4_YY_NO_GET_LENG]],, -[[ - int yyget_leng ( yyscan_t yyscanner ); +m4_ifdef( [[M4_MODE_YY_NO_YYPANIC]],, [[ +/* This gfunction has a magic rewrite rule */ +static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} ]]) -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, -[[ -char *yyget_text ( yyscan_t yyscanner ); -]]) +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, -[[ -int yyget_lineno ( yyscan_t yyscanner ); -]]) + if (yyscanner->yy_buffer_stack == NULL) { + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); + if ( yyscanner->yy_buffer_stack == NULL ) { + yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + } -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, -[[ -void yyset_lineno ( int _line_number, yyscan_t yyscanner ); -]]) + memset(yyscanner->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, -[[ -int yyget_column ( yyscan_t yyscanner ); -]]) + yyscanner->yy_buffer_stack_max = num_to_alloc; + yyscanner->yy_buffer_stack_top = 0; + return; + } -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, -[[ -void yyset_column ( int _column_no, yyscan_t yyscanner ); -]]) + if (yyscanner->yy_buffer_stack_top >= (yyscanner->yy_buffer_stack_max) - 1) { + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; -m4_ifdef([[M4_YY_BISON_LVAL]], [[ -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE * yyget_lval ( yyscan_t yyscanner ); -]]) + num_to_alloc = yyscanner->yy_buffer_stack_max + grow_size; + yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyscanner->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*), + yyscanner); + if (yyscanner->yy_buffer_stack == NULL) { + yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + } + /* zero only the new slots.*/ + memset(yyscanner->yy_buffer_stack + yyscanner->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyscanner->yy_buffer_stack_max = num_to_alloc; + } +} -void yyset_lval ( YYSTYPE * yylval_param, yyscan_t yyscanner ); +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ +static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) +{ + int oerrno = errno; -m4_ifdef( [[]], + yy_flush_buffer( b, yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = true; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != yy_current_buffer(yyscanner)) { + b->bs_yylineno = 1; + b->bs_yycolumn = 0; + } + +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], +[[ + b->yy_is_interactive = 1; +]], [[ - m4_ifdef( [[M4_YY_NO_GET_LLOC]],, + m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], [[ - YYLTYPE *yyget_lloc ( yyscan_t yyscanner ); - ]]) - - m4_ifdef( [[M4_YY_NO_SET_LLOC]],, + b->yy_is_interactive = 0; + ]], [[ - void yyset_lloc ( YYLTYPE * yylloc_param, yyscan_t yyscanner ); + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; ]]) ]]) -]]) + errno = oerrno; +} -/* START special functions - * - * Flex's scanner knows these are special and inserts the yyscanner argument - * at the end of the argument list. TODO: support OO languages with a - * property that causes it to be prepended with a dot instead. +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. */ +yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) +{ + yybuffer b; -/* Enter a start condition. */ -void yybegin(int s, yyscan_t yyscanner) { - yyscanner->yy_start = 1 + 2 * (s); -} + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); + if ( b == NULL ) { + yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); + } + b->yy_buf_size = size; -/* Translate the current start state into a value that can be later handed - * to yybegin() to return to the state. - */ -int yystart(yyscan_t yyscanner) { - return ((yyscanner->yy_start - 1) / 2); -} + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + if ( b->yy_ch_buf == NULL ) { + yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); + } + b->yy_is_our_buffer = 1; -/* This used to be an fputs(), but since the string might contain NULs, - * we now use fwrite(). - */ -void yyecho(yyscan_t yyscanner) { - fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); + yy_init_buffer( b, file, yyscanner); + + return b; } -m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ -void yyunput( int c, yyscan_t yyscanner) +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ +void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) { - char *yy_cp; - yy_cp = yyscanner->yy_c_buf_p; + if ( b == NULL ) { + return; + } + if ( b == yy_current_buffer(yyscanner) ) { /* Not sure if we should pop here. */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = (yybuffer) 0; + } + if ( b->yy_is_our_buffer ) { + yyfree( (void *) b->yy_ch_buf, yyscanner ); + } + yyfree( (void *) b, yyscanner ); +} - /* undo effects of setting up yytext */ - *yy_cp = yyscanner->yy_hold_char; - if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { - /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = yyscanner->yy_n_chars + 2; - char *dest = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size + 2]; - char *source = - &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) +{ + if (new_buffer == NULL) { + return; + } + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( yy_current_buffer(yyscanner) != NULL ) { + /* Flush out information for old buffer. */ + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (yy_current_buffer(yyscanner)) { + yyscanner->yy_buffer_stack_top++; + } + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyscanner->yy_did_buffer_switch_on_eof = true; +} + + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + if (yy_current_buffer(yyscanner) == NULL) { + return; + } + yy_delete_buffer(yy_current_buffer(yyscanner), yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; + if (yyscanner->yy_buffer_stack_top > 0) { + --yyscanner->yy_buffer_stack_top; + } + if (yy_current_buffer(yyscanner) != NULL) { + yy_load_buffer_state( yyscanner ); + yyscanner->yy_did_buffer_switch_on_eof = true; + } +} + + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ +void yyrestart(FILE * input_file, yyscan_t yyscanner) +{ + + if ( yy_current_buffer(yyscanner) == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + + yy_init_buffer( yy_current_buffer(yyscanner), input_file, yyscanner); + yy_load_buffer_state( yyscanner ); +} + +static void yybumpline( yyscan_t yyscanner) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno++; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn=0; +} + +/* START special functions + * + * Flex's scanner knows these are special and inserts the yyscanner argument + * at the end of the argument list. TODO: support OO languages with a + * property that causes it to be prepended with a dot instead. + */ + +/* Enter a start condition. */ +void yybegin(int s, yyscan_t yyscanner) { + yyscanner->yy_start = 1 + 2 * (s); +} + +/* Translate the current start state into a value that can be later handed + * to yybegin() to return to the state. + */ +int yystart(yyscan_t yyscanner) { + return ((yyscanner->yy_start - 1) / 2); +} + +/* This used to be an fputs(), but since the string might contain NULs, + * we now use fwrite(). + */ +void yyecho(yyscan_t yyscanner) { + fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); +} + +m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ +void yyunput( int c, yyscan_t yyscanner) +{ + char *yy_cp; + + yy_cp = yyscanner->yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yyscanner->yy_hold_char; + + if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = yyscanner->yy_n_chars + 2; + char *dest = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size + 2]; + char *source = + &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; while ( source > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf ) { *--dest = *--source; @@ -939,16 +1089,6 @@ m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -const int YY_EXIT_FAILURE = 2; - -m4_ifdef( [[M4_MODE_YY_NO_YYPANIC]],, [[ -static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} -]]) - m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". @@ -997,109 +1137,300 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ } ]]) -/* Number of entries by which start-condition stack grows. */ -const int YY_START_STACK_INCR = 25; +/* STARTS Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. */ -m4_ifdef([[YY_DECL]],, [[m4_dnl -m4_define( [[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) -m4_define( [[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - m4_dnl The bison pure parser is used. Redefine yylex to - m4_dnl accept the lval parameter. - - m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) +M4_MODE_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { + return yyscanner->yyextra_r; +} +]]) ]]) -m4_ifdef( [[]], +m4_ifdef( [[M4_YY_NO_GET_LINENO]],, [[ - m4_dnl Locations are used. yylex should also accept the ylloc parameter. +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); - m4_define( [[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param, yyscan_t yyscanner)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] - [[(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)]]) + if (cb == NULL) { + return 0; + } + return cb->bs_yylineno; +} ]]) -extern int yylex M4_YY_LEX_PROTO; - -m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) -]]) +m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +[[ +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ -static void rule_check_bol(yyscan_t yyscanner) { - if ( yyscanner->yyleng_r > 0 ) { \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + if (cb == NULL) { + return 0; } + return cb->bs_yycolumn; } ]]) -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. yy_cp and yy_bp are the - * end abd start pointers for the input buffer segment that is - * claimed as yytext. +m4_ifdef( [[M4_YY_NO_GET_IN]],, +[[ +/** Get the input stream. + * @param yyscanner The scanner object. */ -void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { - yyscanner->yytext_ptr = yy_bp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; \ - yyscanner->yyleng_r = (int) (yy_cp - yyscanner->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - yyscanner->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ -m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ - yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ - yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ -]]) \ - yyscanner->yy_c_buf_p = yy_cp; +FILE *yyget_in (yyscan_t yyscanner) { + return yyscanner->yyin_r; } +]]) -m4_ifdef( [[M4_MODE_YYLINENO]], [[ -/* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro - * and we can get at yy_act */ -static void yy_less_lineno(int n, yyscan_t yyscanner) { - int yyl; - for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { - if ( yyscanner->yytext_r[yyl] == '\n' ) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; - } - } +m4_ifdef( [[M4_YY_NO_GET_OUT]],, +[[ +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) { + return yyscanner->yyout_r; } +]]) -static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { - const char *p; - for ( p = yy_cp-1; p >= dst; --p) { - if ( *p == '\n' ) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; - } - } +m4_ifdef( [[M4_YY_NO_GET_LENG]],, +[[ +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int yyget_leng (yyscan_t yyscanner) { + return yyscanner->yyleng_r; } ]]) -/* Returns the top of the stack, or NULL. */ -yybuffer yy_current_buffer(yyscan_t yyscanner) { - return ( yyscanner->yy_buffer_stack \ - ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ - : NULL); +/** Get the current token. + * @param yyscanner The scanner object. + */ +m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +[[ +char *yyget_text (yyscan_t yyscanner) { + return yyscanner->yytext_r; } +]]) -void yy_flush_current_buffer(yyscan_t yyscanner) { - yy_flush_buffer( yy_current_buffer(yyscanner), yyscanner); +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +[[ +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { + yyscanner->yyextra_r = user_defined ; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +[[ +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno(int _line_number, yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); + + /* lineno is only valid if an input buffer exists. */ + if (cb == NULL ) { + yypanic( "yyset_lineno called with no buffer", yyscanner ); + } + cb->bs_yylineno = _line_number; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +[[ +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column(int _column_no, yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); + + /* column is only valid if an input buffer exists. */ + if (cb == NULL ) { + yypanic( "yyset_column called with no buffer", yyscanner ); + } + cb->bs_yycolumn = _column_no; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_IN]],, +[[ +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in(FILE * _in_str, yyscan_t yyscanner) { + yyscanner->yyin_r = _in_str ; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_OUT]],, +[[ +void yyset_out( FILE * _out_str, yyscan_t yyscanner) { + yyscanner->yyout_r = _out_str ; +} +]]) + + +m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +[[ +int yyget_debug (yyscan_t yyscanner) { + return yyscanner->yyflexdebug_r; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +[[ +void yyset_debug(int _bdebug, yyscan_t yyscanner) { + yyscanner->yyflexdebug_r = _bdebug ; +} +]]) + +m4_ifdef([[M4_YY_BISON_LVAL]], [[ +m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +[[ +YYSTYPE * yyget_lval (yyscan_t yyscanner) { + return yylval; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LVAL]],, +[[ +void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { + yylval = yylval_param; +} +]]) + +m4_ifdef( [[]], +[[ +m4_ifdef( [[M4_YY_NO_GET_LLOC]],, +[[ +YYLTYPE *yyget_lloc (yyscan_t yyscanner) { + return yylloc; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LLOC]],, +[[ +void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { + yylloc = yylloc_param; +} +]]) +]]) + +]]) + +/* ENDS public accessor functions */ + +/* Number of entries by which start-condition stack grows. */ +const int YY_START_STACK_INCR = 25; + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +m4_ifdef([[YY_DECL]],, [[m4_dnl +m4_define( [[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) +m4_define( [[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + m4_dnl The bison pure parser is used. Redefine yylex to + m4_dnl accept the lval parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) +]]) + +m4_ifdef( [[]], +[[ + m4_dnl Locations are used. yylex should also accept the ylloc parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param, yyscan_t yyscanner)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)]]) +]]) + +extern int yylex M4_YY_LEX_PROTO; + +m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) +]]) + +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ +static void rule_check_bol(yyscan_t yyscanner) { + if ( yyscanner->yyleng_r > 0 ) { \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + } +} +]]) + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. yy_cp and yy_bp are the + * end abd start pointers for the input buffer segment that is + * claimed as yytext. + */ +void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { + yyscanner->yytext_ptr = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; \ + yyscanner->yyleng_r = (int) (yy_cp - yyscanner->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + yyscanner->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ + yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ + yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ +]]) \ + yyscanner->yy_c_buf_p = yy_cp; +} + +m4_ifdef( [[M4_MODE_YYLINENO]], [[ +/* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro + * and we can get at yy_act */ +static void yy_less_lineno(int n, yyscan_t yyscanner) { + int yyl; + for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { + if ( yyscanner->yytext_r[yyl] == '\n' ) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + } + } +} + +static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { + const char *p; + for ( p = yy_cp-1; p >= dst; --p) { + if ( *p == '\n' ) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + } + } } +]]) void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { if ( yy_current_buffer(yyscanner) == NULL ) { @@ -1111,11 +1442,6 @@ void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { } -static void yybumpline( yyscan_t yyscanner) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno++; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn=0; -} - m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} @@ -1151,28 +1477,156 @@ bool yyatbol(yyscan_t yyscanner) { return (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag); } -%# Code snippets used in various cases of code generation in the main scanner. +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ +void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) +{ -m4_define([[M4_GEN_BACKING_UP]], [[ -m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ -m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ - /* Generate code to keep backing-up information. */ -m4_ifdef([[M4_MODE_FULLSPD]], [[ - if ( yy_current_state[-1].yy_nxt ) { -]]) -m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - if ( yy_accept[yy_current_state] ) { -]]) - yyscanner->yy_last_accepting_state = yy_current_state; - yyscanner->yy_last_accepting_cpos = yy_cp; - } -]]) -]]) -]]) + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( yy_current_buffer(yyscanner) == new_buffer ) { + return; + } + if ( yy_current_buffer(yyscanner) ) { + /* Flush out information for old buffer. */ + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } -%# yy_c was formerly YY_CHAR, changed to int because table can now -%# have up to 0x101 entries, since we no longer generate a separate -%# NUL table. + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyscanner->yy_did_buffer_switch_on_eof = true; +} + + +m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, +[[ +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) +{ + yybuffer b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) { + /* They forgot to leave room for the EOB's. */ + return NULL; + } + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); + if ( b == NULL ) { + yypanic( "out of dynamic memory in yy_scan_buffer()", yyscanner ); + } + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yyatbol_flag = true; + b->yy_fill_buffer = false; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b, yyscanner ); + + return b; +} +]]) + +m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, +[[ +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { + yybuffer b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n, yyscanner ); + if ( buf == 0 ) { + yypanic( "out of dynamic memory in yy_scan_bytes()", yyscanner ); + } + for ( i = 0; i < _yybytes_len; ++i ) { + buf[i] = yybytes[i]; + } + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n, yyscanner); + if ( b == NULL ) { + yypanic( "bad buffer in yy_scan_bytes()", yyscanner ); + } + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} +]]) + +m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, +[[ +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) +{ + return yy_scan_bytes( yystr, (int) strlen(yystr), yyscanner); +} +]]) + +%# Code snippets used in various cases of code generation in the main scanner. + +m4_define([[M4_GEN_BACKING_UP]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + /* Generate code to keep backing-up information. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ + if ( yy_current_state[-1].yy_nxt ) { +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + if ( yy_accept[yy_current_state] ) { +]]) + yyscanner->yy_last_accepting_state = yy_current_state; + yyscanner->yy_last_accepting_cpos = yy_cp; + } +]]) +]]) +]]) + +%# yy_c was formerly YY_CHAR, changed to int because table can now +%# have up to 0x101 entries, since we no longer generate a separate +%# NUL table. %# %# Note: on x86-64 architecture with gcc -O2, we save an instruction %# in the main loop, since the character can now be zero-extended in @@ -1241,6 +1695,129 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ } ]]) +/* + * Helpers for yylex() + */ + +%# Conditional indirection through an equivalence map +m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) +m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { + yy_state_type yy_current_state; + char *yy_cp; + + M4_GEN_START_STATE + for ( yy_cp = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_cp < yyscanner->yy_c_buf_p; ++yy_cp ) { + /* Generate the code to find the next state. */ + m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) + m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) + + m4_ifdef([[M4_MODE_NULTRANS]], [[ + /* Compressed tables back up *before* they match. */ + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) + if ( *yy_cp ) { + ]]) + + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ + m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) + ]]) + + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) + +m4_ifdef([[M4_MODE_NULTRANS]], [[ + } else { + yy_current_state = yy_NUL_trans[yy_current_state]; + } +]]) + + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ +static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner) +{ + bool yy_is_jam; + /* Generate code for handling NUL's, if needed. */ + + /* First, deal with backing up and setting up yy_cp if the scanner + * finds that it should JAM on the NUL. + * + * Only generate a definition for "yy_cp" if we'll generate code + * that uses it. Otherwise lint and the like complain. + */ + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyscanner->yy_c_buf_p;]]) + +%# Note that this statement block and the following three are +%# not executed serially but are an if-then-else cascade +%# for different table modes. +m4_ifdef([[M4_MODE_NULTRANS]], [[ + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) + yy_is_jam = (yy_current_state <= 0); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ + int yy_c = YY_NUL_EC; + + const struct yy_trans_info *yy_trans_info; + + yy_trans_info = &yy_current_state[(unsigned int) yy_c]; + yy_current_state += yy_trans_info->yy_nxt; + yy_is_jam = (yy_trans_info->yy_verify != yy_c); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ +M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) +yy_is_jam = (yy_current_state == YY_JAMSTATE); +m4_ifdef([[M4_MODE_USES_REJECT]], [[ + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + if ( ! yy_is_jam ) { + *yyscanner->yy_state_ptr++ = yy_current_state; + } + ]]) +]]) +]]) +]]) +%# End of if-else cascade + +m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ + /* If we've entered an accepting state, back up; note that + * compressed tables have *already* done such backing up, so + * we needn't bother with it again. + */ + if ( ! yy_is_jam ) { + M4_GEN_BACKING_UP + } +]]) + + (void)yyscanner; /* forestall unused-argument warning */ + return yy_is_jam ? 0 : yy_current_state; +} + /** The main scanner function which does all the work. */ YY_DECL { @@ -1320,10 +1897,6 @@ M4_GEN_START_STATE yy_match: /* Generate the code to find the next match. */ -%# Conditional indirection through an equivalence map -m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) -m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { @@ -1702,537 +2275,51 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - - number_to_move - 1; -]]) - } - - if ( num_to_read > YY_READ_BUF_SIZE ) { - num_to_read = YY_READ_BUF_SIZE; - } - /* Read in more data. */ - yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); - - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; - } - - if ( yyscanner->yy_n_chars == 0 ) { - if ( number_to_move == YY_MORE_ADJ ) { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyscanner->yyin_r, yyscanner); - } else { - ret_val = EOB_ACT_LAST_MATCH; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } else { - ret_val = EOB_ACT_CONTINUE_SCAN; - } - if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( - (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { - yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); - } - /* "- 2" to take care of EOB's */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); - } - - yyscanner->yy_n_chars += number_to_move; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - yy_state_type yy_current_state; - char *yy_cp; - - M4_GEN_START_STATE - for ( yy_cp = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_cp < yyscanner->yy_c_buf_p; ++yy_cp ) { - /* Generate the code to find the next state. */ - m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) - m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) - - m4_ifdef([[M4_MODE_NULTRANS]], [[ - /* Compressed tables back up *before* they match. */ - m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) - if ( *yy_cp ) { - ]]) - - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ - m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) - m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) - ]]) - - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) - m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) - -m4_ifdef([[M4_MODE_NULTRANS]], [[ - } else { - yy_current_state = yy_NUL_trans[yy_current_state]; - } -]]) - - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) - m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) - } - - return yy_current_state; -} - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ -static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner) -{ - bool yy_is_jam; - /* Generate code for handling NUL's, if needed. */ - - /* First, deal with backing up and setting up yy_cp if the scanner - * finds that it should JAM on the NUL. - * - * Only generate a definition for "yy_cp" if we'll generate code - * that uses it. Otherwise lint and the like complain. - */ - m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyscanner->yy_c_buf_p;]]) - -%# Note that this statement block and the following three are -%# not executed serially but are an if-then-else cascade -%# for different table modes. -m4_ifdef([[M4_MODE_NULTRANS]], [[ - yy_current_state = yy_NUL_trans[yy_current_state]; - yy_is_jam = (yy_current_state == 0); -]]) - -m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ -m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ -m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) -m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) - yy_is_jam = (yy_current_state <= 0); -]]) - -m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ -m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ - int yy_c = YY_NUL_EC; - - const struct yy_trans_info *yy_trans_info; - - yy_trans_info = &yy_current_state[(unsigned int) yy_c]; - yy_current_state += yy_trans_info->yy_nxt; - yy_is_jam = (yy_trans_info->yy_verify != yy_c); -]]) - -m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ -M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) -yy_is_jam = (yy_current_state == YY_JAMSTATE); -m4_ifdef([[M4_MODE_USES_REJECT]], [[ - /* Only stack this state if it's a transition we - * actually make. If we stack it on a jam, then - * the state stack and yy_c_buf_p get out of sync. - */ - if ( ! yy_is_jam ) { - *yyscanner->yy_state_ptr++ = yy_current_state; - } - ]]) -]]) -]]) -]]) -%# End of if-else cascade - -m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ - /* If we've entered an accepting state, back up; note that - * compressed tables have *already* done such backing up, so - * we needn't bother with it again. - */ - if ( ! yy_is_jam ) { - M4_GEN_BACKING_UP - } -]]) - - (void)yyscanner; /* forestall unused-argument warning */ - return yy_is_jam ? 0 : yy_current_state; -} - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ -void yyrestart(FILE * input_file, yyscan_t yyscanner) -{ - - if ( yy_current_buffer(yyscanner) == NULL ) { - yyensure_buffer_stack (yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); - } - - yy_init_buffer( yy_current_buffer(yyscanner), input_file, yyscanner); - yy_load_buffer_state( yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ -void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( yy_current_buffer(yyscanner) == new_buffer ) { - return; - } - if ( yy_current_buffer(yyscanner) ) { - /* Flush out information for old buffer. */ - *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; - } - - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyscanner->yy_did_buffer_switch_on_eof = true; -} - - -static void yy_load_buffer_state (yyscan_t yyscanner) -{ - yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; - yyscanner->yytext_ptr = yyscanner->yy_c_buf_p = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos; - yyscanner->yyin_r = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file; - yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ -yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) -{ - yybuffer b; - - b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); - if ( b == NULL ) { - yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); - } - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); - if ( b->yy_ch_buf == NULL ) { - yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); - } - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file, yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ -void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) -{ - - if ( b == NULL ) { - return; - } - if ( b == yy_current_buffer(yyscanner) ) { /* Not sure if we should pop here. */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = (yybuffer) 0; - } - if ( b->yy_is_our_buffer ) { - yyfree( (void *) b->yy_ch_buf, yyscanner ); - } - yyfree( (void *) b, yyscanner ); -} - - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) -{ - int oerrno = errno; - - yy_flush_buffer( b, yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = true; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != yy_current_buffer(yyscanner)) { - b->bs_yylineno = 1; - b->bs_yycolumn = 0; - } - -m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], -[[ - b->yy_is_interactive = 1; -]], -[[ - m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], - [[ - b->yy_is_interactive = 0; - ]], - [[ - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - ]]) -]]) - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, yyread() will be called. - * @param b the buffer state to be flushed, usually @c yy_current_buffer(yyscanner). - * @param yyscanner The scanner object. - */ -void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) -{ - if ( b == NULL ) { - return; - } - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yyatbol_flag = true; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer(yyscanner) ) { - yy_load_buffer_state( yyscanner ); - } -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) -{ - if (new_buffer == NULL) { - return; - } - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( yy_current_buffer(yyscanner) != NULL ) { - /* Flush out information for old buffer. */ - *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (yy_current_buffer(yyscanner)) { - yyscanner->yy_buffer_stack_top++; - } - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyscanner->yy_did_buffer_switch_on_eof = true; -} - - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - if (yy_current_buffer(yyscanner) == NULL) { - return; - } - yy_delete_buffer(yy_current_buffer(yyscanner), yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; - if (yyscanner->yy_buffer_stack_top > 0) { - --yyscanner->yy_buffer_stack_top; - } - if (yy_current_buffer(yyscanner) != NULL) { - yy_load_buffer_state( yyscanner ); - yyscanner->yy_did_buffer_switch_on_eof = true; - } -} - - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - - if (yyscanner->yy_buffer_stack == NULL) { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); - if ( yyscanner->yy_buffer_stack == NULL ) { - yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); - } - - memset(yyscanner->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyscanner->yy_buffer_stack_max = num_to_alloc; - yyscanner->yy_buffer_stack_top = 0; - return; - } - - if (yyscanner->yy_buffer_stack_top >= (yyscanner->yy_buffer_stack_max) - 1) { - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyscanner->yy_buffer_stack_max + grow_size; - yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyscanner->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*), - yyscanner); - if (yyscanner->yy_buffer_stack == NULL) { - yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); - } - /* zero only the new slots.*/ - memset(yyscanner->yy_buffer_stack + yyscanner->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyscanner->yy_buffer_stack_max = num_to_alloc; - } -} - -m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, -[[ -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) -{ - yybuffer b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) { - /* They forgot to leave room for the EOB's. */ - return NULL; - } - b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); - if ( b == NULL ) { - yypanic( "out of dynamic memory in yy_scan_buffer()", yyscanner ); - } - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yyatbol_flag = true; - b->yy_fill_buffer = false; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b, yyscanner ); - - return b; -} -]]) - -m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, -[[ -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) -{ - return yy_scan_bytes( yystr, (int) strlen(yystr), yyscanner); -} -]]) - -m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, -[[ -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { - yybuffer b; - char *buf; - yy_size_t n; - int i; + number_to_move - 1; +]]) + } - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n, yyscanner ); - if ( buf == 0 ) { - yypanic( "out of dynamic memory in yy_scan_bytes()", yyscanner ); - } - for ( i = 0; i < _yybytes_len; ++i ) { - buf[i] = yybytes[i]; + if ( num_to_read > YY_READ_BUF_SIZE ) { + num_to_read = YY_READ_BUF_SIZE; + } + /* Read in more data. */ + yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); + + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; } - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n, yyscanner); - if ( b == NULL ) { - yypanic( "bad buffer in yy_scan_bytes()", yyscanner ); + if ( yyscanner->yy_n_chars == 0 ) { + if ( number_to_move == YY_MORE_ADJ ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyscanner->yyin_r, yyscanner); + } else { + ret_val = EOB_ACT_LAST_MATCH; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } else { + ret_val = EOB_ACT_CONTINUE_SCAN; + } + if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( + (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { + yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); + } + /* "- 2" to take care of EOB's */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); } - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - return b; -} -]]) + yyscanner->yy_n_chars += number_to_move; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; + return ret_val; +} m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ @@ -2296,205 +2383,6 @@ void yyless(int n, yyscan_t yyscanner) { yyscanner->yyleng_r = n; } -/* Accessor methods (get/set functions) to struct members. */ - -m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl -m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -M4_MODE_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { - return yyscanner->yyextra_r; -} -]]) -]]) - -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, -[[ -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) { - yybuffer cb = yy_current_buffer(yyscanner); - - if (cb == NULL) { - return 0; - } - return cb->bs_yylineno; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, -[[ -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) { - yybuffer cb = yy_current_buffer(yyscanner); - - if (cb == NULL) { - return 0; - } - return cb->bs_yycolumn; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_IN]],, -[[ -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) { - return yyscanner->yyin_r; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_OUT]],, -[[ -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) { - return yyscanner->yyout_r; -} -]]) - -m4_ifdef( [[M4_YY_NO_GET_LENG]],, -[[ -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) { - return yyscanner->yyleng_r; -} -]]) - -/** Get the current token. - * @param yyscanner The scanner object. - */ -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, -[[ -char *yyget_text (yyscan_t yyscanner) { - return yyscanner->yytext_r; -} -]]) - -m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, -[[ -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { - yyscanner->yyextra_r = user_defined ; -} -]]) -]]) - -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, -[[ -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno(int _line_number, yyscan_t yyscanner) { - yybuffer cb = yy_current_buffer(yyscanner); - - /* lineno is only valid if an input buffer exists. */ - if (cb == NULL ) { - yypanic( "yyset_lineno called with no buffer", yyscanner ); - } - cb->bs_yylineno = _line_number; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, -[[ -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column(int _column_no, yyscan_t yyscanner) { - yybuffer cb = yy_current_buffer(yyscanner); - - /* column is only valid if an input buffer exists. */ - if (cb == NULL ) { - yypanic( "yyset_column called with no buffer", yyscanner ); - } - cb->bs_yycolumn = _column_no; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_IN]],, -[[ -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in(FILE * _in_str, yyscan_t yyscanner) { - yyscanner->yyin_r = _in_str ; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_OUT]],, -[[ -void yyset_out( FILE * _out_str, yyscan_t yyscanner) { - yyscanner->yyout_r = _out_str ; -} -]]) - - -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, -[[ -int yyget_debug (yyscan_t yyscanner) { - return yyscanner->yyflexdebug_r; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, -[[ -void yyset_debug(int _bdebug, yyscan_t yyscanner) { - yyscanner->yyflexdebug_r = _bdebug ; -} -]]) - -m4_ifdef([[M4_YY_BISON_LVAL]], [[ -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE * yyget_lval (yyscan_t yyscanner) { - return yylval; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_LVAL]],, -[[ -void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { - yylval = yylval_param; -} -]]) - -m4_ifdef( [[]], -[[ -m4_ifdef( [[M4_YY_NO_GET_LLOC]],, -[[ -YYLTYPE *yyget_lloc (yyscan_t yyscanner) { - return yylloc; -} -]]) - -m4_ifdef( [[M4_YY_NO_SET_LLOC]],, -[[ -void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { - yylloc = yylloc_param; -} -]]) -]]) - -]]) - /* User-visible API */ /* yylex_init is special because it creates the scanner itself, so it is diff --git a/tests/alloc_extra_c99.l b/tests/alloc_extra_c99.l index ccc035d..67c3526 100644 --- a/tests/alloc_extra_c99.l +++ b/tests/alloc_extra_c99.l @@ -46,7 +46,7 @@ static void check_extra ( yyscan_t scanner ); %} %option emit="c99" -%option 8bit prefix="test" +%option 8bit %option nounput nomain noyywrap nodefault noinput %option warn %option extra-type="struct Check *" @@ -71,25 +71,26 @@ main (void) check.bar = NULL; check.qux = 'z'; - testlex_init_extra(&check, &scanner); - testset_in(stdin, scanner); - testset_out(stdout, scanner); + yylex_init_extra(&check, &scanner); + yyset_in(stdin, scanner); + yyset_out(stdout, scanner); /* Test to confirm that testalloc was called from * testlex_init_extra with the testextra argument. */ check_extra(scanner); - testlex(scanner); + yylex(scanner); - testlex_destroy(scanner); + yylex_destroy(scanner); return 0; } -void *testalloc(size_t size, yyscan_t scanner) +/* Replaces the stock yyalloc */ +void *yyalloc(size_t size, yyscan_t scanner) { struct Check *check; - check = testget_extra(scanner); + check = yyget_extra(scanner); if (!check->bar) check->bar = "Hello World"; @@ -103,7 +104,7 @@ void *testalloc(size_t size, yyscan_t scanner) static void check_extra(yyscan_t scanner) { struct Check *check; - check = testget_extra(scanner); + check = yyget_extra(scanner); if (check->foo != 'a') { fprintf(stderr, "foo is not 'a'\n"); -- cgit v1.2.1 From 1b27cb2366bab475d56b9ec530c7ea63ef9f98bb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Nov 2020 18:37:31 -0500 Subject: Fix two minor m4 errors found by Daniel Brooks. --- src/c99-flex.skl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index ed605a3..1668b64 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -405,7 +405,7 @@ static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { M4_HOOK_NXT_BODY ]], [[ -m4_ifdef([[YY_NXT_LOLEN]], [[(M4_HOOK_NXT_ROWS)]]) +m4_define([[YY_NXT_LOLEN]], [[(M4_HOOK_NXT_ROWS)]]) static const M4_HOOK_NXT_TYPE *yy_nxt =0; ]]) @@ -693,7 +693,7 @@ void yy_flush_current_buffer(yyscan_t yyscanner) { const int YY_EXIT_FAILURE = 2; -m4_ifdef( [[M4_MODE_YY_NO_YYPANIC]],, [[ +m4_ifdef( [[M4_M4_YY_NO_YYPANIC]],, [[ /* This gfunction has a magic rewrite rule */ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ -- cgit v1.2.1 From 43aed9f0c9d9ee82646a1985fdee2e1bb213b352 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Nov 2020 20:57:39 -0500 Subject: Typo fix. --- src/c99-flex.skl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 1668b64..af642d4 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -693,7 +693,7 @@ void yy_flush_current_buffer(yyscan_t yyscanner) { const int YY_EXIT_FAILURE = 2; -m4_ifdef( [[M4_M4_YY_NO_YYPANIC]],, [[ +m4_ifdef( [[M4_YY_NO_YYPANIC]],, [[ /* This gfunction has a magic rewrite rule */ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ -- cgit v1.2.1 From 8a973b0efd8b1860244323e4af34fceb6d1eacef Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Nov 2020 22:52:47 -0500 Subject: Booleanization. --- src/c99-flex.skl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index af642d4..6207002 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -310,14 +310,14 @@ struct yy_buffer_state { * and can realloc() it to grow it, and should free() it to * delete it. */ - int yy_is_our_buffer; + bool yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after + * if we're using stdio for input, then we want to use char-by-char + * rather than a buffered read, to make sure we stop fetching input after * each newline. */ - int yy_is_interactive; + bool yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise @@ -770,18 +770,18 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], [[ - b->yy_is_interactive = 1; + b->yy_is_interactive = true; ]], [[ m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], [[ - b->yy_is_interactive = 0; + b->yy_is_interactive = false; ]], [[ - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + b->yy_is_interactive = (file != NULL) && (isatty( fileno(file) ) > 0); ]]) ]]) - errno = oerrno; + errno = oerrno; } /** Allocate and initialize an input buffer state. @@ -807,7 +807,7 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) if ( b->yy_ch_buf == NULL ) { yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); } - b->yy_is_our_buffer = 1; + b->yy_is_our_buffer = true; yy_init_buffer( b, file, yyscanner); @@ -1536,10 +1536,10 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) } b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; + b->yy_is_our_buffer = false; b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; + b->yy_is_interactive = false; b->yyatbol_flag = true; b->yy_fill_buffer = false; b->yy_buffer_status = YY_BUFFER_NEW; @@ -1583,7 +1583,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ - b->yy_is_our_buffer = 1; + b->yy_is_our_buffer = true; return b; } -- cgit v1.2.1 From 6c8b6c1c1fb714ced0b43d945116f960bbe4136a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Nov 2020 23:15:55 -0500 Subject: Clean out some small C dependencies. --- src/c99-flex.skl | 82 +++++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 6207002..77268cf 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -622,18 +622,16 @@ m4_ifdef( [[]], [[ ]]) }; /* end struct yyguts_t */ -static int yy_init_globals ( yyscan_t yyscanner ); - m4_ifdef( [[M4_YY_BISON_LVAL]], [[ /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ -# define yylval yyscanner->yylval_r +m4_define([[yylval]], [[yyscanner->yylval_r]]) ]]) m4_ifdef( [[]], [[ -# define yylloc yyscanner->yylloc_r +m4_define([[yylloc]], [[yyscanner->yylloc_r]]) ]]) int yylex_init (yyscan_t* scanner); @@ -2383,6 +2381,44 @@ void yyless(int n, yyscan_t yyscanner) { yyscanner->yyleng_r = n; } +static int yy_init_globals (yyscan_t yyscanner) { + /* + * This function is called from yylex_destroy(), so don't allocate here. + */ + yyscanner->yy_buffer_stack = NULL; + yyscanner->yy_buffer_stack_top = 0; + yyscanner->yy_buffer_stack_max = 0; + yyscanner->yy_c_buf_p = NULL; + yyscanner->yy_init = false; + yyscanner->yy_start = 0; + yyscanner->yy_start_stack_ptr = 0; + yyscanner->yy_start_stack_depth = 0; + yyscanner->yy_start_stack = NULL; + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yyscanner->yy_state_buf = 0; + yyscanner->yy_state_ptr = 0; + yyscanner->yy_full_match = 0; + yyscanner->yy_lp = 0; +]]) + +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], +[[ + yyscanner->yytext_ptr = 0; + yyscanner->yy_more_offset = 0; + yyscanner->yy_prev_more_offset = 0; +]]) + + yyscanner->yyin_r = NULL; + yyscanner->yyout_r = NULL; + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + /* User-visible API */ /* yylex_init is special because it creates the scanner itself, so it is @@ -2443,44 +2479,6 @@ int yylex_init_extra( M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globa } ]]) -static int yy_init_globals (yyscan_t yyscanner) { - /* - * This function is called from yylex_destroy(), so don't allocate here. - */ - yyscanner->yy_buffer_stack = NULL; - yyscanner->yy_buffer_stack_top = 0; - yyscanner->yy_buffer_stack_max = 0; - yyscanner->yy_c_buf_p = NULL; - yyscanner->yy_init = false; - yyscanner->yy_start = 0; - yyscanner->yy_start_stack_ptr = 0; - yyscanner->yy_start_stack_depth = 0; - yyscanner->yy_start_stack = NULL; - -m4_ifdef( [[M4_MODE_USES_REJECT]], -[[ - yyscanner->yy_state_buf = 0; - yyscanner->yy_state_ptr = 0; - yyscanner->yy_full_match = 0; - yyscanner->yy_lp = 0; -]]) - -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], -[[ - yyscanner->yytext_ptr = 0; - yyscanner->yy_more_offset = 0; - yyscanner->yy_prev_more_offset = 0; -]]) - - yyscanner->yyin_r = NULL; - yyscanner->yyout_r = NULL; - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (yyscan_t yyscanner) { -- cgit v1.2.1 From 1991ad515f102d2eeb858180d7aa2f6b9344da5e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 12 Nov 2020 07:53:29 -0500 Subject: Fix another carnivorous typo. --- src/c99-flex.skl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 77268cf..361bf9c 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -1663,7 +1663,7 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state", "yy_start_state_list[yyscanner->yy_start + yyatbol()];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start + yyatbol()];]]) m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ -- cgit v1.2.1 From fa6a0fc6665b5315fb72903f8b3d27cbde61901d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 12 Nov 2020 08:37:50 -0500 Subject: Declare that rulset.am depends on *.rules files... ...for automatic remake when a new one is added. --- tests/Makefile.am | 6 +++--- tests/README | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0643e28..6c7f95a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -394,13 +394,13 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c top_main.$(OBJEXT): top.h top.h: top.c -# Most test priductions can be autogenerated from ruleset files, but +# Most test productions can be autogenerated from ruleset files, but # automake has no way to specify such things with a loop in a variable # (even though make can do such things) and the resultant list is both -# long an unenlightening. And it can be / is generated by a shell +# long and unenlightening. And it can be / is generated by a shell # script, ruleset.sh. -$(srcdir)/ruleset.am: $(srcdir)/ruleset.sh +$(srcdir)/ruleset.am: $(srcdir)/ruleset.sh $(srcdir)/*.rules $(SHELL) $(srcdir)/ruleset.sh nr r c99 > $(srcdir)/ruleset.am include $(srcdir)/ruleset.am diff --git a/tests/README b/tests/README index a33d83a..f837261 100644 --- a/tests/README +++ b/tests/README @@ -99,7 +99,7 @@ is Flex's ability to accumulate and ship preamble code sections. The "quotes" test is also backend-indepedent; it's testing that m4 expansion doesn't leak through the genertated scanner. -The C99 baxk end is missing tests for the Bison bridge, header +The C99 backend is missing tests for the Bison bridge, header generation, and loadable tables because it omits those features in order to be a simpler starting point for wring new back ends. -- cgit v1.2.1 From 110899d69e54c206d599fae07480ddb6720d7ce2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 12 Nov 2020 09:53:26 -0500 Subject: Clean up test/Makefile,am's EXTRA_DIST. --- tests/Makefile.am | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6c7f95a..4c8f42f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -261,21 +261,17 @@ EXTRA_DIST = \ alloc_extra.txt \ array_nr.txt \ array_r.txt \ - basic_nr.txt \ - basic_r.txt \ bison_nr.txt \ bison_yylloc.txt \ bison_yylval.txt \ c_cxx_nr.txt \ c_cxx_r.txt \ - ccl.txt \ cxx_basic.txt \ cxx_multiple_scanners.txt \ cxx_restart.txt \ cxx_yywrap.txt \ debug_nr.txt \ debug_r.txt \ - extended.txt \ header_nr.txt \ header_r.txt \ include_by_buffer.direct.txt \ @@ -299,15 +295,12 @@ EXTRA_DIST = \ pthread_3.txt \ pthread_4.txt \ pthread_5.txt \ - reject.txt \ rescan_nr.direct.txt \ rescan_r.direct.txt \ - quote_in_comment.txt \ quotes.txt \ tableopts.txt \ top.txt \ - yyextra.txt \ - yyunput.txt + yyextra.txt dist_noinst_SCRIPTS = \ ruleset.sh -- cgit v1.2.1 From e3e0d791eaca3485dadfcb84530f23c360f61ec9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 12 Nov 2020 10:49:10 -0500 Subject: Documentation polishing. --- src/c99-flex.skl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 361bf9c..37f0c96 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -7,9 +7,10 @@ %# the bare minimum needed to keep it working in C. %# %# Note that using m4 rather than C for macro definitions means they -%# willnot be recognized and expended in user actions nor +%# will not automatically be recognized and expended in user actions nor %# in user code sections. Anything you need to be visible there -%# needs to be declared as a function. +%# needs to be declared as a function or have a rewrite rule +%# that dequotes the macro. %# %# The m4 macros complicate reading this code enough that being %# prescriptive about whitespace and braces is more than usually -- cgit v1.2.1 From 1a48798ca94c0afd8ff5b5e2e26948948352a2ad Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 12 Nov 2020 18:45:54 -0500 Subject: In C99, more rearrangement to make public API calls visible in actions... ..,without resorting to forward declarations. Last C99 cleanup before the Go port begins. --- src/c99-flex.skl | 358 +++++++++++++++++++++++++++---------------------------- 1 file changed, 179 insertions(+), 179 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 37f0c96..408761a 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -29,7 +29,7 @@ m4_changequote([[, ]]) %# Properties not used in the skeleton - meant to be read by the Flex code m4_define([[M4_PROPERTY_BACKEND_NAME]], [[C99]]) -m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[.c]]) +m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[c]]) m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) @@ -1604,6 +1604,184 @@ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) } ]]) +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; + char *source = yyscanner->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { + yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); + } + if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) { + *(dest++) = *(source++); + } + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; + } else { + int num_to_read = + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yypanic( + "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); +]], +[[ + /* just a shorter name for the current buffer */ + yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; + + int yy_c_buf_p_offset = + (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) { + b->yy_buf_size += b->yy_buf_size / 8; + } else { + b->yy_buf_size *= 2; + } + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + } else { + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + } + if ( b->yy_ch_buf == NULL ) { + yypanic("fatal error - scanner input buffer overflow", yyscanner); + } + yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - + number_to_move - 1; +]]) + } + + if ( num_to_read > YY_READ_BUF_SIZE ) { + num_to_read = YY_READ_BUF_SIZE; + } + /* Read in more data. */ + yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); + + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } + + if ( yyscanner->yy_n_chars == 0 ) { + if ( number_to_move == YY_MORE_ADJ ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyscanner->yyin_r, yyscanner); + } else { + ret_val = EOB_ACT_LAST_MATCH; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } else { + ret_val = EOB_ACT_CONTINUE_SCAN; + } + if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( + (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { + yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); + } + /* "- 2" to take care of EOB's */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); + } + + yyscanner->yy_n_chars += number_to_move; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; + + return ret_val; +} + +m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, +[[ +static void yy_push_state(int _new_state, yyscan_t yyscanner) +{ + if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) { + yy_size_t new_size; + + yyscanner->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int ); + + if ( yyscanner->yy_start_stack == NULL ) { + yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); + + } else { + yyscanner->yy_start_stack = (int *) yyrealloc( + (void *) yyscanner->yy_start_stack, new_size, yyscanner ); + } + if ( yyscanner->yy_start_stack == NULL ) { + yypanic( "out of memory expanding start-condition stack", yyscanner); + } + } + yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner); + + yybegin(_new_state, yyscanner); +} +]]) + + +m4_ifdef( [[M4_YY_NO_POP_STATE]],, +[[ +static void yy_pop_state (yyscan_t yyscanner) +{ + if ( --yyscanner->yy_start_stack_ptr < 0 ) { + yypanic( "start-condition stack underflow", yyscanner ); + } + yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner); +} +]]) + + +m4_ifdef( [[M4_YY_NO_TOP_STATE]],, +[[ +static int yy_top_state (yyscan_t yyscanner) +{ + return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner); +} +]]) + %# Code snippets used in various cases of code generation in the main scanner. m4_define([[M4_GEN_BACKING_UP]], [[ @@ -2190,184 +2368,6 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } /* end of user's declarations */ } /* end of yylex */ -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; - char *source = yyscanner->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { - yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); - } - if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { - /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } else { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) { - *(dest++) = *(source++); - } - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; - } else { - int num_to_read = - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ -m4_ifdef( [[M4_MODE_USES_REJECT]], -[[ - yypanic( - "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); -]], -[[ - /* just a shorter name for the current buffer */ - yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; - - int yy_c_buf_p_offset = - (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) { - b->yy_buf_size += b->yy_buf_size / 8; - } else { - b->yy_buf_size *= 2; - } - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2), yyscanner ); - } else { - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - } - if ( b->yy_ch_buf == NULL ) { - yypanic("fatal error - scanner input buffer overflow", yyscanner); - } - yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - - number_to_move - 1; -]]) - } - - if ( num_to_read > YY_READ_BUF_SIZE ) { - num_to_read = YY_READ_BUF_SIZE; - } - /* Read in more data. */ - yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); - - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; - } - - if ( yyscanner->yy_n_chars == 0 ) { - if ( number_to_move == YY_MORE_ADJ ) { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyscanner->yyin_r, yyscanner); - } else { - ret_val = EOB_ACT_LAST_MATCH; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } else { - ret_val = EOB_ACT_CONTINUE_SCAN; - } - if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( - (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { - yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); - } - /* "- 2" to take care of EOB's */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); - } - - yyscanner->yy_n_chars += number_to_move; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; - - return ret_val; -} - -m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, -[[ -static void yy_push_state(int _new_state, yyscan_t yyscanner) -{ - if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) { - yy_size_t new_size; - - yyscanner->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int ); - - if ( yyscanner->yy_start_stack == NULL ) { - yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); - - } else { - yyscanner->yy_start_stack = (int *) yyrealloc( - (void *) yyscanner->yy_start_stack, new_size, yyscanner ); - } - if ( yyscanner->yy_start_stack == NULL ) { - yypanic( "out of memory expanding start-condition stack", yyscanner); - } - } - yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner); - - yybegin(_new_state, yyscanner); -} -]]) - - -m4_ifdef( [[M4_YY_NO_POP_STATE]],, -[[ -static void yy_pop_state (yyscan_t yyscanner) -{ - if ( --yyscanner->yy_start_stack_ptr < 0 ) { - yypanic( "start-condition stack underflow", yyscanner ); - } - yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner); -} -]]) - - -m4_ifdef( [[M4_YY_NO_TOP_STATE]],, -[[ -static int yy_top_state (yyscan_t yyscanner) -{ - return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner); -} -]]) - m4_undefine([[yyless]]) /* Redefine yyless() so it works in section 3 code. */ -- cgit v1.2.1 From 3603f033509d5a214b603f60ce4dd6ed7819843e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 12 Nov 2020 20:54:12 -0500 Subject: Minor build system fixes before starting the Go port. Remove two dependencies that the C99 back end no longer has. Repair to force in-time building of skel.h files. This way of doing it reduces where a new skel dependency has to be declared in the vuilld recipe to the one spot where the flex.h file is made from the flex.skl file. The posixly correct test only needs to be done once, since it only affects how the tables are genetated rather than setting code conditionals in the back end. Also, some comment typo fixes. --- src/.gitignore | 3 +-- src/Makefile.am | 29 ++++++++++++++--------------- src/skeletons.c | 10 +++++----- tests/ruleset.am | 12 ++---------- tests/ruleset.sh | 7 +++++-- tests/testmaker.m4 | 4 ++-- 6 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 7cf38a7..fadd6f3 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,6 +1,7 @@ *.la *.lo *.o +*-flex.h config.h config.h.in flex @@ -8,7 +9,5 @@ libfl.pc parse.c parse.h scan.c -cpp-skel.h -c99-skel.h stage1scan.[cl] stage1flex diff --git a/src/Makefile.am b/src/Makefile.am index 52d8aa5..2df8cc9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,9 +53,6 @@ flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS) COMMON_SOURCES = \ buf.c \ ccl.c \ - skeletons.c \ - cpp-skel.h \ - c99-skel.h \ dfa.c \ ecs.c \ filter.c \ @@ -73,6 +70,7 @@ COMMON_SOURCES = \ scanflags.c \ scanopt.c \ scanopt.h \ + skeletons.c \ sym.c \ tables.c \ tables.h \ @@ -90,21 +88,20 @@ include_HEADERS = \ FlexLexer.h EXTRA_DIST = \ - cpp-flex.skl \ - c99-flex.skl \ + *-flex.skl \ mkskel.sh \ gettext.h CLEANFILES = stage1scan.c stage1flex$(EXEEXT) clean-local: - rm -f *-skel.h + rm -f *-flex.h -cpp-skel.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c +cpp-flex.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp mv -f $@.tmp $@ -c99-skel.h: c99-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c +c99-flex.h: c99-flex.skl mkskel.sh $(SHELL) $(srcdir)/mkskel.sh c99 $(srcdir) $(m4) $(VERSION) > $@.tmp mv -f $@.tmp $@ @@ -121,17 +118,19 @@ dist-hook: scan.l flex$(EXEEXT) ./flex$(EXEEXT) -o scan.c $< && \ mv -f scan.c $(distdir) -# make needs to be told to make parse.h so that parallelized runs will +# make needs to be told to make inclusions so that parallelized runs will # not fail. -stage1flex-main.$(OBJEXT): parse.h -flex-main.$(OBJEXT): parse.h +SKELINCLUDES := $(subst skl,h,$(wildcard *.skl)) + +stage1flex-main.$(OBJEXT): parse.h $(SKELINCLUDES) +flex-main.$(OBJEXT): parse.h $(SKELINCLUDES) -stage1flex-yylex.$(OBJEXT): parse.h -flex-yylex.$(OBJEXT): parse.h +stage1flex-yylex.$(OBJEXT): parse.h $(SKELINCLUDES) +flex-yylex.$(OBJEXT): parse.h $(SKELINCLUDES) -stage1flex-scan.$(OBJEXT): parse.h -flex-stage1scan.$(OBJEXT): parse.h +stage1flex-scan.$(OBJEXT): parse.h $(SKELINCLUDES) +flex-stage1scan.$(OBJEXT): parse.h $(SKELINCLUDES) # Run GNU indent on sources. Don't run this unless all the sources compile cleanly. # diff --git a/src/skeletons.c b/src/skeletons.c index ec65f5f..b55cb27 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -38,21 +38,21 @@ /* START digested skeletons */ const char *cpp_skel[] = { -#include "cpp-skel.h" +#include "cpp-flex.h" 0, }; const char *c99_skel[] = { -#include "c99-skel.h" +#include "c99-flex.h" 0, }; /* END digested skeletons */ /* Method table describing a language-specific back end. - * Even if this never gets a member other than the skell - * array, it prevents us from geting lost in a maze of - * twity array referebce levels, all different. + * Even if this never gets a member other than the skel + * array, it prevents us from getting lost in a maze of + * twisty array reference levels, all different. */ struct flex_backend_t { const char **skel; // Digested skeleton file diff --git a/tests/ruleset.am b/tests/ruleset.am index 983e529..13968f5 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -217,10 +217,6 @@ flexname_r_SOURCES = flexname_r.l flexname_r.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -posixlycorrect_r_SOURCES = posixlycorrect_r.l -posixlycorrect_r.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - posix_r_SOURCES = posix_r.l posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -409,10 +405,6 @@ flexname_c99_SOURCES = flexname_c99.l flexname_c99.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -posixlycorrect_c99_SOURCES = posixlycorrect_c99.l -posixlycorrect_c99.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - posix_c99_SOURCES = posix_c99.l posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -604,6 +596,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posixlycorrect_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posixlycorrect_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posixlycorrect_r posixlycorrect_r.c posixlycorrect_r.l posixlycorrect_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posixlycorrect_c99 posixlycorrect_c99.c posixlycorrect_c99.l posixlycorrect_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/ruleset.sh b/tests/ruleset.sh index 0520177..a2c000f 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -17,7 +17,10 @@ printf "\n# Begin generated test rules\n\n" compatible() { mybackend=$1 myruleset=$2 - [ "${mybackend}" = "nr" ] || [ "${myruleset}" != "lexcompat.rules" ] + # Some options are both a pain to test outside the default back end and really don't need to be + # tested in more than one back end anyway. An option is in this category if it doesn't affect + # any conditionals in the code generation, just the way the Flex scanner generates its NDFSA tables. + [ "${mybackend}" = "nr" ] || [ "${myruleset}" != "lexcompat.rules" -a "${myruleset}" != "posixlycorrect.rules" ] } for backend in "$@" ; do @@ -52,7 +55,7 @@ EOF done # posixlycorrect is a special case becaae we need to set POSIXLY_CORRECT -# in Flex's environment while these .l files are bein processed. +# in Flex's environment while these .l files are being processed. for backend in "$@" ; do case $backend in nr|r|c99) ext="c" ;; diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index dd0d97a..ad80615 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -7,7 +7,7 @@ dnl M4_TEST_BACKEND must be set to a recognized back end name. dnl For purposes of this file, "nr" and "r" are treated as dnl separate back ends - non-reentrant and reentrant C through dnl the default cpp skeleton. The c99 backend is treated here -dnl as re-eentrant C, but may have a different skeleton file. +dnl as re-entrant C, but may have a different skeleton file. dnl dnl The purpose of this file is to properly set these macros: dnl @@ -116,7 +116,7 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl ')dnl close r dnl dnl A hypothetical example -ifelse(M4_TEST_BACKEND, `go', `dnl +ifelse(M4_TEST_BACKEND, `hypothetical-go', `dnl define(`M4_TEST_PREAMBLE', `dnl %top{ package main -- cgit v1.2.1 From df632cf2eb1e1def8f63d08d54055862ac6d8978 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 15 Nov 2020 11:55:50 -0500 Subject: Fix typo revealed by Go porting work, and improve test coverage to match. We a ruleset test for BOL matching and a test for the array case of yymore. Improve yymore testing by adding tests that require a BOL match in both array and pointer cases. Also, convert lineno sporadic test to be ruleset-based so it's applied on all back ends. No cide changes. --- src/c99-flex.skl | 2 +- src/cpp-flex.skl | 2 +- tests/.gitignore | 15 +++++-- tests/Makefile.am | 3 -- tests/bol.rules | 35 +++++++++++++++++ tests/lineno.rules | 71 +++++++++++++++++++++++++++++++++ tests/lineno_c99.l | 98 ---------------------------------------------- tests/lineno_nr.l | 94 -------------------------------------------- tests/lineno_r.l | 97 --------------------------------------------- tests/ruleset.am | 52 +++++++++++++++++++++++- tests/yymore.rules | 5 ++- tests/yymorearray.rules | 36 +++++++++++++++++ tests/yymorearraybol.rules | 39 ++++++++++++++++++ 13 files changed, 248 insertions(+), 301 deletions(-) create mode 100644 tests/bol.rules create mode 100644 tests/lineno.rules delete mode 100644 tests/lineno_c99.l delete mode 100644 tests/lineno_nr.l delete mode 100644 tests/lineno_r.l create mode 100644 tests/yymorearray.rules create mode 100644 tests/yymorearraybol.rules diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 408761a..fe63912 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -2180,7 +2180,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], - [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], + [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [["yyscanner->yy_prev_more_offset"]], [["yyscanner->yy_more_len"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 4432126..e31f448 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -2052,7 +2052,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], - [[m4_ifdef([[M4_MODE_YYTECT_IS_ARRAY]], + [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; diff --git a/tests/.gitignore b/tests/.gitignore index b449a38..52efe99 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -19,6 +19,8 @@ bison_yylloc_scanner.[ch] bison_yylval bison_yylval_parser.[ch] bison_yylval_scanner.[ch] +bol* +!bol.rules c_cxx_nr c_cxx_nr.cc c_cxx_r @@ -56,13 +58,18 @@ include_by_reentrant.direct.c lexcompat* !lexcompat.rules lineno_nr.one -lineno_nr.c lineno_r.one -lineno_r.c lineno_c99.one -lineno_c99.c lineno_trailing.one lineno_trailing.c +lineno*.c +lineno*.l +lineno_nr +lineno_r +lineno_c99 +lineno_go +lineno.txt +!lineno.rules mem_nr mem_nr.c mem_r @@ -117,6 +124,8 @@ yyless* !yyless.rules yymore* !yymore.rules +!yymorearray.rules +!yymorearraybol.rules yyunput* !yyunput.rules test-yydecl-* diff --git a/tests/Makefile.am b/tests/Makefile.am index 4c8f42f..9d4677a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -214,9 +214,6 @@ CLEANFILES = \ include_by_buffer.direct.c \ include_by_push.direct.c \ include_by_reentrant.direct.c \ - lineno_nr.c \ - lineno_r.c \ - lineno_c99.c \ lineno_trailing.c \ mem_nr.c \ mem_r.c \ diff --git a/tests/bol.rules b/tests/bol.rules new file mode 100644 index 0000000..f9031ae --- /dev/null +++ b/tests/bol.rules @@ -0,0 +1,35 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* Test BOL matching, + * If the ^ operator does not constrain pattern patching, these rules + * will false-match on after :bar: the line of input and fail. + */ + +%option nounput noyywrap noyylineno warn nodefault noinput +%% +^foo {M4_TEST_FAILMESSAGE} +.|\n {} + +### +barfoo diff --git a/tests/lineno.rules b/tests/lineno.rules new file mode 100644 index 0000000..7fc9c31 --- /dev/null +++ b/tests/lineno.rules @@ -0,0 +1,71 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The goal here is to test the yylineno processing by: + * - providing some rules than CAN match newlines and + * other rules that can NOT match newlines, + * - matching several newlines in one rule, + * - directly modifying yylineno. + * FIXME: Exposes a bug, probably in the Flex scanner. + * If "--yylineno" in the action is "yylineno--", the pattern + * is not recognized and the magic rewrite rule for yylineo + * does not fire. Only an issue for non-default back ends that + * do magic rewrites rather than rtelying on the C preprocessor. + */ +%option 8bit +%option nounput nomain noyywrap noinput yylineno +%option warn + +WORD [[:alpha:]]+ +DIGIT [[:digit:]] + +%% +"yylineno++" ++yylineno; +"yylineno--" --yylineno; +[[:blank:]]+ +{WORD} +{DIGIT}+(\n{DIGIT}+)* +\n +. +<> {M4_TEST_ASSERT(yylineno == 20) M4_TEST_DO(yyterminate())} + +### +These words +are separated +by newlines +and sometimes + spaces +too. +The next three lines are numbers with only intervening newlines +01123 +581321 +34 +And now for some blank lines.... + + +Finally, we directly modify yylineno, but then change it back afterwards +(see scanner.l): + +yylineno++ + +yylineno-- diff --git a/tests/lineno_c99.l b/tests/lineno_c99.l deleted file mode 100644 index 11d402c..0000000 --- a/tests/lineno_c99.l +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". - Run as: - test-lineno-r # report flex's yylineno - test-lineno-r 1 # report count_newlines(stdin) -*/ - -#include -#include -#include "config.h" - -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput yylineno -%option warn - -WORD [[:alpha:]]+ -DIGIT [[:digit:]] - -%% - /* The goal here is to test the yylineno processing by: - - providing some rules than CAN match newlines and - other rules that can NOT match newlines, - - matching several newlines in one rule, - - directly modifying yylineno. - */ - -"yylineno--" --yylineno; -"yylineno++" ++yylineno; -[[:blank:]]+ -{WORD} -{DIGIT}+(\n{DIGIT}+)* -\n -. -<> { printf("%d\n", yylineno); - yyterminate(); - } - -%% - -/* returns number of '\n' characters in input, plus one. - This is what flex does, essentially. */ - -static int -count_newlines (FILE* in) -{ - int n=1,c; - while ((c=fgetc(in)) != EOF) - if( c == '\n') - n++; - return n; -} - -int main ( int argc, char** argv ); - -int -main (int argc, char **argv) -{ - (void)argv; - - if( argc > 1 ) - printf("%d\n", count_newlines(stdin)); - - else{ - yyscan_t s; - testlex_init(&s); - testset_in(stdin,s); - testset_out(stdout,s); - testlex(s); - testlex_destroy(s); - } - return 0; -} diff --git a/tests/lineno_nr.l b/tests/lineno_nr.l deleted file mode 100644 index dbe6b2d..0000000 --- a/tests/lineno_nr.l +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". - Run as: - test-lineno-nr # report flex's yylineno - test-lineno-nr 1 # report count_newlines(stdin) -*/ - -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput yylineno -%option warn - -WORD [[:alpha:]]+ -DIGIT [[:digit:]] - -%% - /* The goal here is to test the yylineno processing by: - - providing some rules than CAN match newlines and - other rules that can NOT match newlines, - - matching several newlines in one rule, - - directly modifying yylineno. - */ - -"yylineno++" yylineno++; -"yylineno--" yylineno--; -[[:blank:]]+ -{WORD} -{DIGIT}+(\n{DIGIT}+)* -\n -. -<> { printf("%d\n", yylineno); - yyterminate(); - } - -%% - -/* returns number of '\n' characters in input, plus one. - This is what flex does, essentially. */ - -static int -count_newlines (FILE* in) -{ - int n=1,c; - while ((c=fgetc(in)) != EOF) - if( c == '\n') - n++; - return n; -} - -int main ( int, char**); - -int -main ( int argc, char **argv ) -{ - (void)argv; - - if( argc > 1 ) - printf("%d\n", count_newlines(stdin)); - - else{ - yyin = stdin; - yyout = stdout; - yylex(); - } - return 0; -} diff --git a/tests/lineno_r.l b/tests/lineno_r.l deleted file mode 100644 index d7230d7..0000000 --- a/tests/lineno_r.l +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". - Run as: - test-lineno-r # report flex's yylineno - test-lineno-r 1 # report count_newlines(stdin) -*/ - -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput yylineno reentrant -%option warn - -WORD [[:alpha:]]+ -DIGIT [[:digit:]] - -%% - /* The goal here is to test the yylineno processing by: - - providing some rules than CAN match newlines and - other rules that can NOT match newlines, - - matching several newlines in one rule, - - directly modifying yylineno. - */ - -"yylineno++" yylineno++; -"yylineno--" yylineno--; -[[:blank:]]+ -{WORD} -{DIGIT}+(\n{DIGIT}+)* -\n -. -<> { printf("%d\n", yylineno); - yyterminate(); - } - -%% - -/* returns number of '\n' characters in input, plus one. - This is what flex does, essentially. */ - -static int -count_newlines (FILE* in) -{ - int n=1,c; - while ((c=fgetc(in)) != EOF) - if( c == '\n') - n++; - return n; -} - -int main ( int argc, char** argv ); - -int -main (int argc, char **argv) -{ - (void)argv; - - if( argc > 1 ) - printf("%d\n", count_newlines(stdin)); - - else{ - yyscan_t s; - testlex_init(&s); - testset_in(stdin,s); - testset_out(stdout,s); - testlex(s); - testlex_destroy(s); - } - return 0; -} diff --git a/tests/ruleset.am b/tests/ruleset.am index 13968f5..1f4fd6d 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -9,6 +9,10 @@ basic_nr_SOURCES = basic_nr.l basic_nr.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +bol_nr_SOURCES = bol_nr.l +bol_nr.l: $(srcdir)/bol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + ccl_nr_SOURCES = ccl_nr.l ccl_nr.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -25,6 +29,10 @@ lexcompat_nr_SOURCES = lexcompat_nr.l lexcompat_nr.l: $(srcdir)/lexcompat.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +lineno_nr_SOURCES = lineno_nr.l +lineno_nr.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posixlycorrect_nr_SOURCES = posixlycorrect_nr.l posixlycorrect_nr.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -57,6 +65,14 @@ yyless_nr_SOURCES = yyless_nr.l yyless_nr.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yymorearraybol_nr_SOURCES = yymorearraybol_nr.l +yymorearraybol_nr.l: $(srcdir)/yymorearraybol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yymorearray_nr_SOURCES = yymorearray_nr.l +yymorearray_nr.l: $(srcdir)/yymorearray.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yymore_nr_SOURCES = yymore_nr.l yymore_nr.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -205,6 +221,10 @@ basic_r_SOURCES = basic_r.l basic_r.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +bol_r_SOURCES = bol_r.l +bol_r.l: $(srcdir)/bol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + ccl_r_SOURCES = ccl_r.l ccl_r.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -217,6 +237,10 @@ flexname_r_SOURCES = flexname_r.l flexname_r.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +lineno_r_SOURCES = lineno_r.l +lineno_r.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_r_SOURCES = posix_r.l posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -245,6 +269,14 @@ yyless_r_SOURCES = yyless_r.l yyless_r.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yymorearraybol_r_SOURCES = yymorearraybol_r.l +yymorearraybol_r.l: $(srcdir)/yymorearraybol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yymorearray_r_SOURCES = yymorearray_r.l +yymorearray_r.l: $(srcdir)/yymorearray.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yymore_r_SOURCES = yymore_r.l yymore_r.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -393,6 +425,10 @@ basic_c99_SOURCES = basic_c99.l basic_c99.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +bol_c99_SOURCES = bol_c99.l +bol_c99.l: $(srcdir)/bol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + ccl_c99_SOURCES = ccl_c99.l ccl_c99.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -405,6 +441,10 @@ flexname_c99_SOURCES = flexname_c99.l flexname_c99.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +lineno_c99_SOURCES = lineno_c99.l +lineno_c99.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_c99_SOURCES = posix_c99.l posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -433,6 +473,14 @@ yyless_c99_SOURCES = yyless_c99.l yyless_c99.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +yymorearraybol_c99_SOURCES = yymorearraybol_c99.l +yymorearraybol_c99.l: $(srcdir)/yymorearraybol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yymorearray_c99_SOURCES = yymorearray_c99.l +yymorearray_c99.l: $(srcdir)/yymorearray.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + yymore_c99_SOURCES = yymore_c99.l yymore_c99.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -596,6 +644,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr ccl_nr extended_nr flexname_nr lexcompat_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r ccl_r extended_r flexname_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 ccl_c99 extended_c99 flexname_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr extended_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r extended_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 extended_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/yymore.rules b/tests/yymore.rules index 17600e5..50c0b87 100644 --- a/tests/yymore.rules +++ b/tests/yymore.rules @@ -21,9 +21,10 @@ * PURPOSE. */ /* - * Test yymore. What should haooen is: + * Test yymore with default pointer buffer. What should happen is: * 1. "foo" is matched by the first rule but not consumed. * 2. "bar" is matched, but the token length is 6 rather than 3. + * We use a ^ to force the extra code for BOL checking. */ %option nounput noyywrap noyylineno warn noinput @@ -31,4 +32,4 @@ foo {M4_TEST_DO(yymore())} bar {M4_TEST_ASSERT(yyleng == 6)} ### -foobar +^foobar diff --git a/tests/yymorearray.rules b/tests/yymorearray.rules new file mode 100644 index 0000000..270ff33 --- /dev/null +++ b/tests/yymorearray.rules @@ -0,0 +1,36 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /* + * Test yymore with array buffer representation. What should happen is: + * 1. "foo" is matched by the first rule but not consumed. + * 2. "bar" is matched, but the token length is 6 rather than 3. + * Also see the yymorearraybol ruleset. + */ + +%array +%option nounput noyywrap noyylineno warn noinput +%% +foo {M4_TEST_DO(yymore())} +bar {M4_TEST_ASSERT(yyleng == 6)} +### +foobar diff --git a/tests/yymorearraybol.rules b/tests/yymorearraybol.rules new file mode 100644 index 0000000..80f6b8e --- /dev/null +++ b/tests/yymorearraybol.rules @@ -0,0 +1,39 @@ +%{ +#include +%} +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /* + * Test yymore with array buffer representation. What should happen is: + * 1. "foo" is matched by the first rule but not consumed. + * 2. "bar" is matched, but the token length is 6 rather than 3. + * We use a ^ to force the extra code for BOL checking. + */ + +%array +%option nounput noyywrap noyylineno warn noinput +%% +^foo {yymore();} +bar {if (!(yyleng == 6)) {fprintf(stderr,"ASSERT FAILED.\n"); exit(1);}} +### +foobar -- cgit v1.2.1 From 709c1724ed74bee614c9e35b99d630396822f8c3 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 15 Nov 2020 12:36:00 -0500 Subject: Repair some bitrotted variable-trailing-context code. It decayed because the test for this feature only exercised the nr back end. We add a ruleset--based test to verify on all back ends. --- src/c99-flex.skl | 8 ++++++- src/cpp-flex.skl | 12 ++++++---- tests/.gitignore | 2 ++ tests/lineno_trailing.l | 8 +++---- tests/linenotrailing.rules | 57 ++++++++++++++++++++++++++++++++++++++++++++++ tests/ruleset.am | 16 +++++++++++-- 6 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 tests/linenotrailing.rules diff --git a/src/c99-flex.skl b/src/c99-flex.skl index fe63912..e4af687 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -565,6 +565,12 @@ static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; M4_YY_SC_DEFS +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl +%# These must match the values in the file flexdef.h +%# of the flex source code, otherwise havoc will ensue. +const int YY_TRAILING_MASK = 0x2000; +const int YY_TRAILING_HEAD_MASK = 0x4000; +]]) /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ @@ -597,7 +603,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ char *yy_full_match; int yy_lp; -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[dnl +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl /* These are only needed for trailing context rules */ int yy_looking_for_trail_begin; int yy_full_lp; diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index e31f448..3e3b247 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -1064,6 +1064,12 @@ static char *yy_last_accepting_cpos; ]]) ]]) +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl +%# These must match the values in the file flexdef.h +%# of the flex source code, otherwise havoc will ensue. +#define YY_TRAILING_MASK 0x2000 +#define YY_TRAILING_HEAD_MASK 0x4000 +]]) m4_ifdef( [[M4_MODE_USES_REJECT]],[[ m4_ifdef( [[M4_YY_NOT_REENTRANT]], [[ m4_ifdef( [[M4_MODE_C_ONLY]], [[ @@ -1075,10 +1081,6 @@ m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ static int yy_looking_for_trail_begin = 0; static int yy_full_lp; static int *yy_full_state; -%# These must match the values in the file flexdef.h -%# of the flex source code, otherwise havoc will ensue. -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 ]]) ]]) ]]) @@ -1228,7 +1230,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ char *yy_full_match; int yy_lp; -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[dnl +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl /* These are only needed for trailing context rules */ int yy_looking_for_trail_begin; int yy_full_lp; diff --git a/tests/.gitignore b/tests/.gitignore index 52efe99..e9a3405 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -70,6 +70,8 @@ lineno_c99 lineno_go lineno.txt !lineno.rules +linenotrailing* +!linenotrailing.rules mem_nr mem_nr.c mem_r diff --git a/tests/lineno_trailing.l b/tests/lineno_trailing.l index cceaa23..a165734 100644 --- a/tests/lineno_trailing.l +++ b/tests/lineno_trailing.l @@ -28,22 +28,22 @@ test-lineno-trailing 1 # report count_newlines(stdin) */ +/* The goal here is to test the yylineno in the context of trailing-contexts. + * Using rules that have newlines in look-ahead. + */ #include #include #include "config.h" %} -%option 8bit prefix="test" +%option 8bit %option nounput nomain noyywrap noinput yylineno %option warn WORD [[:alpha:]]+ %% - /* The goal here is to test the yylineno in the context of trailing-contexts. - Using rules that have newlines in look-ahead. - */ "Fixed_trailing:"/[\n]"test"[\n] {} "Var_trailing:"{WORD}/[\n] {} "Var_prefix_and_trailing:"{WORD}":"/(\n{WORD})* {} diff --git a/tests/linenotrailing.rules b/tests/linenotrailing.rules new file mode 100644 index 0000000..4d4a37f --- /dev/null +++ b/tests/linenotrailing.rules @@ -0,0 +1,57 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The goal here is to test the yylineno in the context of trailing-contexts. + * Using rules that have newlines in look-ahead. + */ + +%option 8bit +%option nounput nomain noyywrap noinput yylineno +%option warn + +WORD [[:alpha:]]+ + +%% +"Fixed_trailing:"/[\n]"test"[\n] {} +"Var_trailing:"{WORD}/[\n] {} +"Var_prefix_and_trailing:"{WORD}":"/(\n{WORD})* {} +\n {} +. {} +<> {M4_TEST_ASSERT(yylineno==16) M4_TEST_DO(yyterminate())} + +### +We are testing rules with trailing contexts containing newlines (see scanner.l): + +Fixed_trailing: +test + +Var_trailing:word +test + +Var_prefix_and_trailing:word: +more +text +comes +here + + diff --git a/tests/ruleset.am b/tests/ruleset.am index 1f4fd6d..1d6cf81 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -33,6 +33,10 @@ lineno_nr_SOURCES = lineno_nr.l lineno_nr.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +linenotrailing_nr_SOURCES = linenotrailing_nr.l +linenotrailing_nr.l: $(srcdir)/linenotrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posixlycorrect_nr_SOURCES = posixlycorrect_nr.l posixlycorrect_nr.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -241,6 +245,10 @@ lineno_r_SOURCES = lineno_r.l lineno_r.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +linenotrailing_r_SOURCES = linenotrailing_r.l +linenotrailing_r.l: $(srcdir)/linenotrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_r_SOURCES = posix_r.l posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -445,6 +453,10 @@ lineno_c99_SOURCES = lineno_c99.l lineno_c99.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +linenotrailing_c99_SOURCES = linenotrailing_c99.l +linenotrailing_c99.l: $(srcdir)/linenotrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posix_c99_SOURCES = posix_c99.l posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -644,6 +656,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr extended_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r extended_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 extended_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr extended_nr flexname_nr lexcompat_nr lineno_nr linenotrailing_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r extended_r flexname_r lineno_r linenotrailing_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 extended_c99 flexname_c99 lineno_c99 linenotrailing_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt linenotrailing_nr linenotrailing_nr.c linenotrailing_nr.l linenotrailing_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt linenotrailing_r linenotrailing_r.c linenotrailing_r.l linenotrailing_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt linenotrailing_c99 linenotrailing_c99.c linenotrailing_c99.l linenotrailing_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -- cgit v1.2.1 From eacb312e5b9868dba734996d6c72fc60e0d75036 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 01:18:36 -0500 Subject: Improve instrumentation of test failures. Also, yyinpt.txt is generated and does not need to be checked in. --- tests/testmaker.m4 | 12 ++++++------ tests/yyunput.txt | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 tests/yyunput.txt diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index ad80615..2560a79 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -44,8 +44,8 @@ define(`M4_TEST_PREAMBLE', `dnl %} ')dnl close preamble define(`M4_TEST_DO', `$1;') -define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') -define(`M4_TEST_ASSERT', `if (!($1)) {fprintf(stderr,"ASSERT FAILED.\n"); exit(1);}') +define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') +define(`M4_TEST_ASSERT', `if (!($1)) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -82,8 +82,8 @@ define(`M4_TEST_PREAMBLE', `dnl %} ')dnl close preamble define(`M4_TEST_DO', `$1;') -define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED.\n"); exit(1);') -define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED.\n"); exit(1);}') +define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') +define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -130,8 +130,8 @@ import ( %option emit="go" ')dnl close preamble define(`M4_TEST_DO', `$1') -define(`M4_TEST_FAILMESSAGE', `log.Fatal("TEST FAILMESSAGE"); os.Exit(1);') -define(`M4_TEST_ASSERT', `if !$1 {Fprintf(os.Stderr,"ASSERT FAILED.\n"); os.Exit(1);}') +define(`M4_TEST_FAILMESSAGE', `fmt.Fprintf(os.Stderr, "TEST FAILMESSAGE: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);') +define(`M4_TEST_ASSERT', `if !$1 {fmt.Fprintf(os.Stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);}') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { lexer := new(FlexLexer) diff --git a/tests/yyunput.txt b/tests/yyunput.txt deleted file mode 100644 index 9126894..0000000 --- a/tests/yyunput.txt +++ /dev/null @@ -1 +0,0 @@ -fooick -- cgit v1.2.1 From f0f53f6930bb3d8fc8878e3fc9996b95d59a6b4f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 05:32:38 -0500 Subject: Remove now-unused SOURCES declarations. --- tests/Makefile.am | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 9d4677a..7187f03 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -145,9 +145,6 @@ nodist_header_r_SOURCES = header_r_scanner.h include_by_buffer_direct_SOURCES = include_by_buffer.direct.l include_by_push_direct_SOURCES = include_by_push.direct.l include_by_reentrant_direct_SOURCES = include_by_reentrant.direct.l -lineno_nr_one_SOURCES = lineno_nr.l -lineno_r_one_SOURCES = lineno_r.l -lineno_c99_one_SOURCES = lineno_c99.l lineno_trailing_one_SOURCES = lineno_trailing.l mem_nr_SOURCES = mem_nr.l mem_r_SOURCES = mem_r.l -- cgit v1.2.1 From 22b9ea63bdc0a7ac1f9b8593cf19887cbe1d22fc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 05:46:28 -0500 Subject: Remove the ".one" category of tests; they've been replaced by rulesets. This reduces the complexitry of the test machinery as well as making tests less backend-specific. --- tests/.gitignore | 5 --- tests/Makefile.am | 15 +------- tests/lineno_c99.one.txt | 19 ---------- tests/lineno_nr.one.txt | 19 ---------- tests/lineno_r.one.txt | 19 ---------- tests/lineno_trailing.l | 87 ------------------------------------------- tests/lineno_trailing.one.txt | 13 ------- tests/testwrapper.sh | 15 +------- 8 files changed, 4 insertions(+), 188 deletions(-) delete mode 100644 tests/lineno_c99.one.txt delete mode 100644 tests/lineno_nr.one.txt delete mode 100644 tests/lineno_r.one.txt delete mode 100644 tests/lineno_trailing.l delete mode 100644 tests/lineno_trailing.one.txt diff --git a/tests/.gitignore b/tests/.gitignore index e9a3405..28bc046 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -57,11 +57,6 @@ include_by_reentrant.direct include_by_reentrant.direct.c lexcompat* !lexcompat.rules -lineno_nr.one -lineno_r.one -lineno_c99.one -lineno_trailing.one -lineno_trailing.c lineno*.c lineno*.l lineno_nr diff --git a/tests/Makefile.am b/tests/Makefile.am index 7187f03..3a907a3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,7 +29,7 @@ TESTS = $(check_PROGRAMS) options.cn # automake knows how to distinguish between the various kinds of tests # we have. -TEST_EXTENSIONS = .direct .cn .i3 .pthread .one .opt .ser .ver +TEST_EXTENSIONS = .direct .cn .i3 .pthread .opt .ser .ver LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_LOG_FLAGS = -d $(srcdir) -r @@ -46,9 +46,6 @@ AM_I3_LOG_FLAGS = -i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt -i $(s PTHREAD_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_PTHREAD_LOG_FLAGS = -i $(srcdir)/pthread_1.txt -i $(srcdir)/pthread_2.txt -i $(srcdir)/pthread_3.txt -i $(srcdir)/pthread_4.txt -i $(srcdir)/pthread_5.txt -ONE_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh -AM_ONE_LOG_FLAGS = -1 -d $(srcdir) - OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r @@ -61,7 +58,7 @@ AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r AM_YFLAGS = -d -p test AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -check_PROGRAMS = $(RULESET_TESTS) $(SPORADIC_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) +check_PROGRAMS = $(RULESET_TESTS) $(SPORADIC_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) SPORADIC_TESTS = \ alloc_extra_nr \ @@ -109,12 +106,6 @@ I3_TESTS = \ PTHREAD_TESTS = \ pthread.pthread -ONE_TESTS = \ - lineno_nr.one \ - lineno_r.one \ - lineno_c99.one \ - lineno_trailing.one - alloc_extra_nr_SOURCES = alloc_extra_nr.l alloc_extra_c99_SOURCES = alloc_extra_c99.l if HAVE_BISON @@ -145,7 +136,6 @@ nodist_header_r_SOURCES = header_r_scanner.h include_by_buffer_direct_SOURCES = include_by_buffer.direct.l include_by_push_direct_SOURCES = include_by_push.direct.l include_by_reentrant_direct_SOURCES = include_by_reentrant.direct.l -lineno_trailing_one_SOURCES = lineno_trailing.l mem_nr_SOURCES = mem_nr.l mem_r_SOURCES = mem_r.l mem_c99_SOURCES = mem_c99.l @@ -211,7 +201,6 @@ CLEANFILES = \ include_by_buffer.direct.c \ include_by_push.direct.c \ include_by_reentrant.direct.c \ - lineno_trailing.c \ mem_nr.c \ mem_r.c \ mem_c99.c \ diff --git a/tests/lineno_c99.one.txt b/tests/lineno_c99.one.txt deleted file mode 100644 index c1eb961..0000000 --- a/tests/lineno_c99.one.txt +++ /dev/null @@ -1,19 +0,0 @@ -These words -are separated -by newlines -and sometimes - spaces -too. -The next three lines are numbers with only intervening newlines -01123 -581321 -34 -And now for some blank lines.... - - -Finally, we directly modify yylineno, but then change it back afterwards -(see scanner.l): - -yylineno++ - -yylineno-- diff --git a/tests/lineno_nr.one.txt b/tests/lineno_nr.one.txt deleted file mode 100644 index c1eb961..0000000 --- a/tests/lineno_nr.one.txt +++ /dev/null @@ -1,19 +0,0 @@ -These words -are separated -by newlines -and sometimes - spaces -too. -The next three lines are numbers with only intervening newlines -01123 -581321 -34 -And now for some blank lines.... - - -Finally, we directly modify yylineno, but then change it back afterwards -(see scanner.l): - -yylineno++ - -yylineno-- diff --git a/tests/lineno_r.one.txt b/tests/lineno_r.one.txt deleted file mode 100644 index c1eb961..0000000 --- a/tests/lineno_r.one.txt +++ /dev/null @@ -1,19 +0,0 @@ -These words -are separated -by newlines -and sometimes - spaces -too. -The next three lines are numbers with only intervening newlines -01123 -581321 -34 -And now for some blank lines.... - - -Finally, we directly modify yylineno, but then change it back afterwards -(see scanner.l): - -yylineno++ - -yylineno-- diff --git a/tests/lineno_trailing.l b/tests/lineno_trailing.l deleted file mode 100644 index a165734..0000000 --- a/tests/lineno_trailing.l +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". - Run as: - test-lineno-trailing # report flex's yylineno - test-lineno-trailing 1 # report count_newlines(stdin) -*/ - -/* The goal here is to test the yylineno in the context of trailing-contexts. - * Using rules that have newlines in look-ahead. - */ -#include -#include -#include "config.h" - -%} - -%option 8bit -%option nounput nomain noyywrap noinput yylineno -%option warn - -WORD [[:alpha:]]+ - -%% -"Fixed_trailing:"/[\n]"test"[\n] {} -"Var_trailing:"{WORD}/[\n] {} -"Var_prefix_and_trailing:"{WORD}":"/(\n{WORD})* {} -\n {} -. {} -<> { printf("%d\n", yylineno); - yyterminate(); - } - -%% - -/* returns number of '\n' characters in input, plus one. - This is what flex does, essentially. */ - -static int -count_newlines (FILE* in) -{ - int n=1,c; - while ((c=fgetc(in)) != EOF) - if( c == '\n') - n++; - return n; -} - -int main ( int, char**); - -int -main ( int argc, char **argv ) -{ - (void)argv; - - if( argc > 1 ) - printf("%d\n", count_newlines(stdin)); - - else{ - yyin = stdin; - yyout = stdout; - yylex(); - } - return 0; -} diff --git a/tests/lineno_trailing.one.txt b/tests/lineno_trailing.one.txt deleted file mode 100644 index 201164d..0000000 --- a/tests/lineno_trailing.one.txt +++ /dev/null @@ -1,13 +0,0 @@ -We are testing rules with trailing contexts containing newlines (see scanner.l): - -Fixed_trailing: -test - -Var_trailing:word -test - -Var_prefix_and_trailing:word: -more -text -comes -here diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 0b9088f..d20fba4 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -13,7 +13,7 @@ INPUT_COUNT=0 USE_REDIRECT=0 DO_COMPARISON=0 -while getopts :d:i:r1 OPTION ; do +while getopts :d:i:r OPTION ; do case $OPTION in d) INPUT_DIRECTORY=$OPTARG ;; i) @@ -25,8 +25,7 @@ while getopts :d:i:r1 OPTION ; do INPUT_COUNT=$((INPUT_COUNT+1)) ;; r) USE_REDIRECT=1 ;; - 1) DO_COMPARISON=1 ;; - *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] [-t] [-1] TESTNAME" + *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] [-t] TESTNAME" exit 1 ;; esac @@ -54,16 +53,6 @@ for input in $inputs; do fi done -# We may want to compare the input fed to the test binary to its output. -# Equality means success, because it means no character leaked past a -# token match to echo. -if [ $DO_COMPARISON = 1 ] ; then - TEST_OUTPUT=$($TESTNAME < "$INPUT_NAME") - REF_OUTPUT=$($TESTNAME 1 < "$INPUT_NAME") - test "$TEST_OUTPUT" -eq "$REF_OUTPUT" - exit $? -fi - # Detect if the test wants a table argument. If it does, the test maker will have generated # a tables=-file option do that the a table file named afte the test was created when the # scanner was built. Thus we can assume that it will be looking for the table data at -- cgit v1.2.1 From a67532dd5799676b9e1629b8fd2dc9f526383e09 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 06:10:47 -0500 Subject: Remove now-unused parts of test/testwrapper.sh. --- tests/testwrapper.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index d20fba4..f07f798 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -13,7 +13,7 @@ INPUT_COUNT=0 USE_REDIRECT=0 DO_COMPARISON=0 -while getopts :d:i:r OPTION ; do +while getopts d:i:r OPTION ; do case $OPTION in d) INPUT_DIRECTORY=$OPTARG ;; i) @@ -25,7 +25,7 @@ while getopts :d:i:r OPTION ; do INPUT_COUNT=$((INPUT_COUNT+1)) ;; r) USE_REDIRECT=1 ;; - *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] [-t] TESTNAME" + *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] TESTNAME" exit 1 ;; esac @@ -68,6 +68,7 @@ if [ $INPUT_COUNT -gt 1 ] ; then exit $? fi +# Set up input redirection as required if [ -f "${INPUT_NAME}" ] ; then if [ $USE_REDIRECT = 1 ] ; then $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < "$INPUT_NAME" -- cgit v1.2.1 From 654ab2012f9345798ef3a214ccb6ebd1f1b4d12d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 17:32:40 -0500 Subject: Up-gun a test to use the lineno code in the array+BOL case... ...and fix the bug that turned up. --- src/c99-flex.skl | 2 +- src/cpp-flex.skl | 2 +- tests/yymorearraybol.rules | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index e4af687..75228e2 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -2187,7 +2187,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], - [["yyscanner->yy_prev_more_offset"]], [["yyscanner->yy_more_len"]])]], [[0]])]]) + [[yyscanner->yy_prev_more_offset]], [[yyscanner->yy_more_len]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl ) { diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 3e3b247..2d7abe1 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -2055,7 +2055,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_s m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], - [["YY_G(yy_prev_more_offset)"]], [["YY_G(yy_more_len)"]])]], [[0]])]]) + [[YY_G(yy_prev_more_offset)]], [[YY_G(yy_more_len)]])]], [[0]])]]) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = M4_YYL_BASE; yyl < yyleng; ++yyl ) { diff --git a/tests/yymorearraybol.rules b/tests/yymorearraybol.rules index 80f6b8e..8683ac2 100644 --- a/tests/yymorearraybol.rules +++ b/tests/yymorearraybol.rules @@ -31,7 +31,7 @@ */ %array -%option nounput noyywrap noyylineno warn noinput +%option nounput noyywrap yylineno warn noinput %% ^foo {yymore();} bar {if (!(yyleng == 6)) {fprintf(stderr,"ASSERT FAILED.\n"); exit(1);}} -- cgit v1.2.1 From ad9f2d493ebd3ae9eabdb9bd62043909394af484 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 17:55:59 -0500 Subject: In C99, remove unneeded forward declarations. --- src/c99-flex.skl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 75228e2..fdfa3e2 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -641,12 +641,6 @@ m4_ifdef( [[]], m4_define([[yylloc]], [[yyscanner->yylloc_r]]) ]]) -int yylex_init (yyscan_t* scanner); - -m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl -int yylex_init_extra ( M4_MODE_EXTRA_TYPE user_defined, yyscan_t* scanner); -]]) - /* Helpers for special functions, also part of public API */ /* Returns the top of the stack, or NULL. */ -- cgit v1.2.1 From 52e6bb3e84d5ab23c692cc7636c01b486ca1bb71 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Nov 2020 23:24:30 -0500 Subject: Fix error in testnmaker: shell case alternations evaluate easrky. --- tests/testmaker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 518745d..52dfdec 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -1,14 +1,14 @@ #!/bin/sh # # testmaker.sh - asssemble tests from backend-independent rulesets and -# backend-dependent boilerplate. +# backend-dependent boilerplate. Generates both a Flex source file +# and an input text for it. # # The single argument is a testfile name to be generated. # With the -d option, dump to stdourather than crating the file. # # To add a new back end named "foo", append "|foo" to the -# string literal below. -backends="c99" +# third case arm marked "# Add new back ends on this line". if [ "$1" = -d ] ; then shift @@ -43,7 +43,7 @@ for part in "$@"; do case ${part} in nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; - ${backends}) backend=${part}; options="${options} emit=\"${part}\"" ;; + c99) backend=${part}; options="${options} emit=\"${part}\"" ;; # Add new back ends on this line ser) serialization=yes ;; ver) serialization=yes; verification=yes; options="${options} tables-verify" ;; Ca) options="${options} align" ;; -- cgit v1.2.1 From e2a64fa1746c3a7d515a2bb1ab7bda9462bec10c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 17 Nov 2020 00:00:49 -0500 Subject: Rename some rules files to make maintaining .gitignore simpler. Due to some limitayions in git ignore wildcarding. --- tests/.gitignore | 16 ++++--------- tests/fixedtrailing.rules | 42 ++++++++++++++++++++++++++++++++++ tests/linenotrailing.rules | 57 ---------------------------------------------- tests/ruleset.am | 40 ++++++++++++++++---------------- tests/trailing.rules | 42 ---------------------------------- tests/vartrailing.rules | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 124 insertions(+), 130 deletions(-) create mode 100644 tests/fixedtrailing.rules delete mode 100644 tests/linenotrailing.rules delete mode 100644 tests/trailing.rules create mode 100644 tests/vartrailing.rules diff --git a/tests/.gitignore b/tests/.gitignore index 28bc046..628064b 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -43,6 +43,8 @@ debug_c99 debug_c99.c extended* !extended.rules +fixedtrailing* +!fixedtrailing.rules flexname* !flexname.rules header_nr @@ -57,16 +59,8 @@ include_by_reentrant.direct include_by_reentrant.direct.c lexcompat* !lexcompat.rules -lineno*.c -lineno*.l -lineno_nr -lineno_r -lineno_c99 -lineno_go -lineno.txt +lineno* !lineno.rules -linenotrailing* -!linenotrailing.rules mem_nr mem_nr.c mem_r @@ -111,8 +105,8 @@ tableopts* !tableopts.rules top top.[ch] -trailing* -!trailing.rules +vartrailing* +!vartrailing.rules yyextra_nr yyextra_nr.c yyextra_c99 diff --git a/tests/fixedtrailing.rules b/tests/fixedtrailing.rules new file mode 100644 index 0000000..9389688 --- /dev/null +++ b/tests/fixedtrailing.rules @@ -0,0 +1,42 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* + * Test rules with variable trailing context. + * Input should match first rule, but only + * consume the "foo". Therefore the second + * rule should not match, but the third should. + */ + +%option nounput noyywrap noyylineno warn nodefault noinput + +%% + +foo/a+ {M4_TEST_ASSERT(yyleng== 3)} +foo {M4_TEST_FAILMESSAGE} +aa { } +\n { } +. {M4_TEST_FAILMESSAGE} + +### +fooaa diff --git a/tests/linenotrailing.rules b/tests/linenotrailing.rules deleted file mode 100644 index 4d4a37f..0000000 --- a/tests/linenotrailing.rules +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* The goal here is to test the yylineno in the context of trailing-contexts. - * Using rules that have newlines in look-ahead. - */ - -%option 8bit -%option nounput nomain noyywrap noinput yylineno -%option warn - -WORD [[:alpha:]]+ - -%% -"Fixed_trailing:"/[\n]"test"[\n] {} -"Var_trailing:"{WORD}/[\n] {} -"Var_prefix_and_trailing:"{WORD}":"/(\n{WORD})* {} -\n {} -. {} -<> {M4_TEST_ASSERT(yylineno==16) M4_TEST_DO(yyterminate())} - -### -We are testing rules with trailing contexts containing newlines (see scanner.l): - -Fixed_trailing: -test - -Var_trailing:word -test - -Var_prefix_and_trailing:word: -more -text -comes -here - - diff --git a/tests/ruleset.am b/tests/ruleset.am index 1d6cf81..508f702 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -21,6 +21,10 @@ extended_nr_SOURCES = extended_nr.l extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +fixedtrailing_nr_SOURCES = fixedtrailing_nr.l +fixedtrailing_nr.l: $(srcdir)/fixedtrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + flexname_nr_SOURCES = flexname_nr.l flexname_nr.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -33,10 +37,6 @@ lineno_nr_SOURCES = lineno_nr.l lineno_nr.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -linenotrailing_nr_SOURCES = linenotrailing_nr.l -linenotrailing_nr.l: $(srcdir)/linenotrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - posixlycorrect_nr_SOURCES = posixlycorrect_nr.l posixlycorrect_nr.l: $(srcdir)/posixlycorrect.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -61,8 +61,8 @@ tableopts_nr_SOURCES = tableopts_nr.l tableopts_nr.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -trailing_nr_SOURCES = trailing_nr.l -trailing_nr.l: $(srcdir)/trailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 +vartrailing_nr_SOURCES = vartrailing_nr.l +vartrailing_nr.l: $(srcdir)/vartrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ yyless_nr_SOURCES = yyless_nr.l @@ -237,6 +237,10 @@ extended_r_SOURCES = extended_r.l extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +fixedtrailing_r_SOURCES = fixedtrailing_r.l +fixedtrailing_r.l: $(srcdir)/fixedtrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + flexname_r_SOURCES = flexname_r.l flexname_r.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -245,10 +249,6 @@ lineno_r_SOURCES = lineno_r.l lineno_r.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -linenotrailing_r_SOURCES = linenotrailing_r.l -linenotrailing_r.l: $(srcdir)/linenotrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - posix_r_SOURCES = posix_r.l posix_r.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -269,8 +269,8 @@ tableopts_r_SOURCES = tableopts_r.l tableopts_r.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -trailing_r_SOURCES = trailing_r.l -trailing_r.l: $(srcdir)/trailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 +vartrailing_r_SOURCES = vartrailing_r.l +vartrailing_r.l: $(srcdir)/vartrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ yyless_r_SOURCES = yyless_r.l @@ -445,6 +445,10 @@ extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +fixedtrailing_c99_SOURCES = fixedtrailing_c99.l +fixedtrailing_c99.l: $(srcdir)/fixedtrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + flexname_c99_SOURCES = flexname_c99.l flexname_c99.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -453,10 +457,6 @@ lineno_c99_SOURCES = lineno_c99.l lineno_c99.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -linenotrailing_c99_SOURCES = linenotrailing_c99.l -linenotrailing_c99.l: $(srcdir)/linenotrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 - $(SHELL) $(srcdir)/testmaker.sh $@ - posix_c99_SOURCES = posix_c99.l posix_c99.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -477,8 +477,8 @@ tableopts_c99_SOURCES = tableopts_c99.l tableopts_c99.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ -trailing_c99_SOURCES = trailing_c99.l -trailing_c99.l: $(srcdir)/trailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 +vartrailing_c99_SOURCES = vartrailing_c99.l +vartrailing_c99.l: $(srcdir)/vartrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ yyless_c99_SOURCES = yyless_c99.l @@ -656,6 +656,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr extended_nr flexname_nr lexcompat_nr lineno_nr linenotrailing_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr trailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r extended_r flexname_r lineno_r linenotrailing_r posix_r preposix_r quoteincomment_r reject_r tableopts_r trailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 extended_c99 flexname_c99 lineno_c99 linenotrailing_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 trailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt linenotrailing_nr linenotrailing_nr.c linenotrailing_nr.l linenotrailing_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt trailing_nr trailing_nr.c trailing_nr.l trailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt linenotrailing_r linenotrailing_r.c linenotrailing_r.l linenotrailing_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt trailing_r trailing_r.c trailing_r.l trailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt linenotrailing_c99 linenotrailing_c99.c linenotrailing_c99.l linenotrailing_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt trailing_c99 trailing_c99.c trailing_c99.l trailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr extended_nr fixedtrailing_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr vartrailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r extended_r fixedtrailing_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r vartrailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 extended_c99 fixedtrailing_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 vartrailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/trailing.rules b/tests/trailing.rules deleted file mode 100644 index 9389688..0000000 --- a/tests/trailing.rules +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/* - * Test rules with variable trailing context. - * Input should match first rule, but only - * consume the "foo". Therefore the second - * rule should not match, but the third should. - */ - -%option nounput noyywrap noyylineno warn nodefault noinput - -%% - -foo/a+ {M4_TEST_ASSERT(yyleng== 3)} -foo {M4_TEST_FAILMESSAGE} -aa { } -\n { } -. {M4_TEST_FAILMESSAGE} - -### -fooaa diff --git a/tests/vartrailing.rules b/tests/vartrailing.rules new file mode 100644 index 0000000..4d4a37f --- /dev/null +++ b/tests/vartrailing.rules @@ -0,0 +1,57 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/* The goal here is to test the yylineno in the context of trailing-contexts. + * Using rules that have newlines in look-ahead. + */ + +%option 8bit +%option nounput nomain noyywrap noinput yylineno +%option warn + +WORD [[:alpha:]]+ + +%% +"Fixed_trailing:"/[\n]"test"[\n] {} +"Var_trailing:"{WORD}/[\n] {} +"Var_prefix_and_trailing:"{WORD}":"/(\n{WORD})* {} +\n {} +. {} +<> {M4_TEST_ASSERT(yylineno==16) M4_TEST_DO(yyterminate())} + +### +We are testing rules with trailing contexts containing newlines (see scanner.l): + +Fixed_trailing: +test + +Var_trailing:word +test + +Var_prefix_and_trailing:word: +more +text +comes +here + + -- cgit v1.2.1 From eaf12696afcf66668618ad3f2bdba854d919f3a4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 17 Nov 2020 04:36:56 -0500 Subject: Convert the debug test to be ruleset-based, --- tests/.gitignore | 8 ++------ tests/Makefile.am | 11 ---------- tests/debug.rules | 34 +++++++++++++++++++++++++++++++ tests/debug.txt | 2 -- tests/debug_c99.l | 60 ------------------------------------------------------ tests/debug_nr.l | 52 ---------------------------------------------- tests/debug_r.l | 59 ----------------------------------------------------- tests/ruleset.am | 16 +++++++++++++-- tests/testmaker.m4 | 18 ++++++++++++---- 9 files changed, 64 insertions(+), 196 deletions(-) create mode 100644 tests/debug.rules delete mode 100644 tests/debug.txt delete mode 100644 tests/debug_c99.l delete mode 100644 tests/debug_nr.l delete mode 100644 tests/debug_r.l diff --git a/tests/.gitignore b/tests/.gitignore index 628064b..4aa70a6 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -35,12 +35,8 @@ cxx_restart cxx_restart.cc cxx_yywrap.i3 cxx_yywrap.cc -debug_nr -debug_nr.c -debug_r -debug_r.c -debug_c99 -debug_c99.c +debug* +!debug.rules extended* !extended.rules fixedtrailing* diff --git a/tests/Makefile.am b/tests/Makefile.am index 3a907a3..efc3a84 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -71,9 +71,6 @@ SPORADIC_TESTS = \ cxx_basic \ cxx_multiple_scanners \ cxx_restart \ - debug_nr \ - debug_r \ - debug_c99 \ header_nr \ header_r \ mem_nr \ @@ -126,9 +123,6 @@ cxx_basic_SOURCES = cxx_basic.ll cxx_restart_SOURCES = cxx_restart.ll cxx_multiple_scanners_SOURCES = cxx_multiple_scanners_main.cc cxx_multiple_scanners_1.ll cxx_multiple_scanners_2.ll cxx_yywrap_i3_SOURCES = cxx_yywrap.ll -debug_nr_SOURCES = debug_nr.l -debug_r_SOURCES = debug_r.l -debug_c99_SOURCES = debug_c99.l header_nr_SOURCES = header_nr_scanner.l header_nr_main.c nodist_header_nr_SOURCES = header_nr_scanner.h header_r_SOURCES = header_r_scanner.l header_r_main.c @@ -191,9 +185,6 @@ CLEANFILES = \ cxx_multiple_scanners_2.cc \ cxx_restart.cc \ cxx_yywrap.cc \ - debug_nr.c \ - debug_r.c \ - debug_c99.c \ header_nr_scanner.c \ header_nr_scanner.h \ header_r_scanner.c \ @@ -253,8 +244,6 @@ EXTRA_DIST = \ cxx_multiple_scanners.txt \ cxx_restart.txt \ cxx_yywrap.txt \ - debug_nr.txt \ - debug_r.txt \ header_nr.txt \ header_r.txt \ include_by_buffer.direct.txt \ diff --git a/tests/debug.rules b/tests/debug.rules new file mode 100644 index 0000000..5c5813d --- /dev/null +++ b/tests/debug.rules @@ -0,0 +1,34 @@ +/* + * This file is part of flex. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +define(`M4_TEST_ENABLEDEBUG', `') + +%option 8bit +%option nounput nomain noyywrap noinput +%option warn debug + +%% +.+ { } +\n { } +### +Any input will do for this test. +We are only testing if it actually runs in debug mode. diff --git a/tests/debug.txt b/tests/debug.txt deleted file mode 100644 index 8d6476c..0000000 --- a/tests/debug.txt +++ /dev/null @@ -1,2 +0,0 @@ -Any input will do for this test. -We are only testing if it actually runs in debug mode. diff --git a/tests/debug_c99.l b/tests/debug_c99.l deleted file mode 100644 index 72d16fd..0000000 --- a/tests/debug_c99.l +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" - -%} - -%option emit="c99" -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn debug - -%% -.+ { } -\n { } -%% - -int main(void); - -int main (void) -{ - yyscan_t lexer; - testlex_init( &lexer ); - testset_out ( stdout,lexer); - testset_in ( stdin, lexer); - - /* Just see if the next line compiles. */ - testset_debug (testget_debug(lexer), lexer); - - while( testlex(lexer) ) - { - } - testlex_destroy( lexer ); - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/debug_nr.l b/tests/debug_nr.l deleted file mode 100644 index 8110ab4..0000000 --- a/tests/debug_nr.l +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn debug - -%% -.+ { } -\n { } -%% - -int main(void); - -int -main (void) -{ - yyin = stdin; - yyout = stdout; - yy_flex_debug = 1; - yylex(); - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/debug_r.l b/tests/debug_r.l deleted file mode 100644 index 8c2d7a5..0000000 --- a/tests/debug_r.l +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of flex. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -%{ -/* A template scanner file to build "scanner.c". */ -#include -#include -#include "config.h" - -%} - -%option 8bit prefix="test" -%option nounput nomain noyywrap noinput -%option warn debug reentrant - -%% -.+ { } -\n { } -%% - -int main(void); - -int main (void) -{ - yyscan_t lexer; - testlex_init( &lexer ); - testset_out ( stdout,lexer); - testset_in ( stdin, lexer); - - /* Just see if the next line compiles. */ - testset_debug (testget_debug(lexer), lexer); - - while( testlex(lexer) ) - { - } - testlex_destroy( lexer ); - printf("TEST RETURNING OK.\n"); - return 0; -} diff --git a/tests/ruleset.am b/tests/ruleset.am index 508f702..927edad 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -17,6 +17,10 @@ ccl_nr_SOURCES = ccl_nr.l ccl_nr.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +debug_nr_SOURCES = debug_nr.l +debug_nr.l: $(srcdir)/debug.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + extended_nr_SOURCES = extended_nr.l extended_nr.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -233,6 +237,10 @@ ccl_r_SOURCES = ccl_r.l ccl_r.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +debug_r_SOURCES = debug_r.l +debug_r.l: $(srcdir)/debug.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + extended_r_SOURCES = extended_r.l extended_r.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -441,6 +449,10 @@ ccl_c99_SOURCES = ccl_c99.l ccl_c99.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +debug_c99_SOURCES = debug_c99.l +debug_c99.l: $(srcdir)/debug.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + extended_c99_SOURCES = extended_c99.l extended_c99.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ @@ -656,6 +668,6 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules -RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr extended_nr fixedtrailing_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr vartrailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r extended_r fixedtrailing_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r vartrailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 extended_c99 fixedtrailing_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 vartrailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt extended_r extended_r.c extended_r.l extended_r.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr debug_nr extended_nr fixedtrailing_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr vartrailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r debug_r extended_r fixedtrailing_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r vartrailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 debug_c99 extended_c99 fixedtrailing_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 vartrailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt debug_nr debug_nr.c debug_nr.l debug_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt debug_r debug_r.c debug_r.l debug_r.txt extended_r extended_r.c extended_r.l extended_r.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt debug_c99 debug_c99.c debug_c99.l debug_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 2560a79..573dc71 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -30,11 +30,15 @@ dnl dnl M4_TEST_TABLE_VERIFICATION = define this to exercise table dnl verification and exit. dnl +dnl M4_TEST_INITHOOK = define this in a rules file to splice code into +dnl the test main as a compilation test. +dnl dnl These macros are to be expanded by files with a .rules extension dnl that contain pure flex rulesets and no backend-specific code. dnl changecom define(`M4_TEST_FAILMESSAGE', `INVALID BACK END')dnl +define(`M4_TEST_INITHOOK', `')dnl dnl ifelse(M4_TEST_BACKEND, `nr', `dnl define(`M4_TEST_PREAMBLE', `dnl @@ -46,6 +50,7 @@ define(`M4_TEST_PREAMBLE', `dnl define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') define(`M4_TEST_ASSERT', `if (!($1)) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') +m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `flex_debug = 1;')') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -61,8 +66,9 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl if(yytables_fload(fp) < 0) yypanic("yytables_fload returned < 0"); ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') + M4_TEST_INITHOOK ')dnl table_serialization - while( yylex() ) + while( yylex() != YY_NULL ) { } ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl @@ -84,6 +90,7 @@ define(`M4_TEST_PREAMBLE', `dnl define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') +m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_debug(lexer), lexer);')') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -102,7 +109,8 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl yypanic("yytables_fload returned < 0", lexer); ifdef(`M4_TEST_TABLE_VERIFICATION', `exit(0);') ')dnl table_serialization - while( yylex(lexer) ) + M4_TEST_INITHOOK + while( yylex(lexer) != YY_NULL ) { } ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl @@ -127,17 +135,19 @@ import ( "os" ) %} -%option emit="go" +%option emit="hypothetical-go" ')dnl close preamble define(`M4_TEST_DO', `$1') define(`M4_TEST_FAILMESSAGE', `fmt.Fprintf(os.Stderr, "TEST FAILMESSAGE: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);') define(`M4_TEST_ASSERT', `if !$1 {fmt.Fprintf(os.Stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);}') +m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `lexer.yysetDebug(lexer.yygetDebug())')') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { lexer := new(FlexLexer) lexer.yysetOut(os.Stdout) lexer.yysetIn(os.Stdin) - for lexer.yylex() != EOF { + M4_TEST_INITHOOK + for lexer.yylex() != YY_NULL { } fmt.Printf("TEST RETURNING OK.\n") os.Exit(0) -- cgit v1.2.1 From be50e74b5c58c786592948b22f389c95139ed5a4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 17 Nov 2020 05:52:08 -0500 Subject: Improve cleanup of generated .txt after tests. --- tests/ruleset.am | 2 +- tests/ruleset.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ruleset.am b/tests/ruleset.am index 927edad..90af507 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -669,5 +669,5 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh # End generated test rules RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr debug_nr extended_nr fixedtrailing_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr vartrailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r debug_r extended_r fixedtrailing_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r vartrailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 debug_c99 extended_c99 fixedtrailing_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 vartrailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array_nr.txt basic_nr basic_nr.c basic_nr.l basic_nr.txt bol_nr bol_nr.c bol_nr.l bol_nr.txt ccl_nr ccl_nr.c ccl_nr.l ccl_nr.txt debug_nr debug_nr.c debug_nr.l debug_nr.txt extended_nr extended_nr.c extended_nr.l extended_nr.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing_nr.txt flexname_nr flexname_nr.c flexname_nr.l flexname_nr.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat_nr.txt lineno_nr lineno_nr.c lineno_nr.l lineno_nr.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect_nr.txt posix_nr posix_nr.c posix_nr.l posix_nr.txt preposix_nr preposix_nr.c preposix_nr.l preposix_nr.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment_nr.txt reject_nr reject_nr.c reject_nr.l reject_nr.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts_nr.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing_nr.txt yyless_nr yyless_nr.c yyless_nr.l yyless_nr.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol_nr.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray_nr.txt yymore_nr yymore_nr.c yymore_nr.l yymore_nr.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput_nr.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array_r.txt basic_r basic_r.c basic_r.l basic_r.txt bol_r bol_r.c bol_r.l bol_r.txt ccl_r ccl_r.c ccl_r.l ccl_r.txt debug_r debug_r.c debug_r.l debug_r.txt extended_r extended_r.c extended_r.l extended_r.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing_r.txt flexname_r flexname_r.c flexname_r.l flexname_r.txt lineno_r lineno_r.c lineno_r.l lineno_r.txt posix_r posix_r.c posix_r.l posix_r.txt preposix_r preposix_r.c preposix_r.l preposix_r.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment_r.txt reject_r reject_r.c reject_r.l reject_r.txt tableopts_r tableopts_r.c tableopts_r.l tableopts_r.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing_r.txt yyless_r yyless_r.c yyless_r.l yyless_r.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol_r.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray_r.txt yymore_r yymore_r.c yymore_r.l yymore_r.txt yyunput_r yyunput_r.c yyunput_r.l yyunput_r.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array_c99.txt basic_c99 basic_c99.c basic_c99.l basic_c99.txt bol_c99 bol_c99.c bol_c99.l bol_c99.txt ccl_c99 ccl_c99.c ccl_c99.l ccl_c99.txt debug_c99 debug_c99.c debug_c99.l debug_c99.txt extended_c99 extended_c99.c extended_c99.l extended_c99.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing_c99.txt flexname_c99 flexname_c99.c flexname_c99.l flexname_c99.txt lineno_c99 lineno_c99.c lineno_c99.l lineno_c99.txt posix_c99 posix_c99.c posix_c99.l posix_c99.txt preposix_c99 preposix_c99.c preposix_c99.l preposix_c99.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment_c99.txt reject_c99 reject_c99.c reject_c99.l reject_c99.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts_c99.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing_c99.txt yyless_c99 yyless_c99.c yyless_c99.l yyless_c99.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol_c99.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray_c99.txt yymore_c99 yymore_c99.c yymore_c99.l yymore_c99.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput_c99.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array.txt basic_nr basic_nr.c basic_nr.l basic.txt bol_nr bol_nr.c bol_nr.l bol.txt ccl_nr ccl_nr.c ccl_nr.l ccl.txt debug_nr debug_nr.c debug_nr.l debug.txt extended_nr extended_nr.c extended_nr.l extended.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing.txt flexname_nr flexname_nr.c flexname_nr.l flexname.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat.txt lineno_nr lineno_nr.c lineno_nr.l lineno.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect.txt posix_nr posix_nr.c posix_nr.l posix.txt preposix_nr preposix_nr.c preposix_nr.l preposix.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment.txt reject_nr reject_nr.c reject_nr.l reject.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing.txt yyless_nr yyless_nr.c yyless_nr.l yyless.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray.txt yymore_nr yymore_nr.c yymore_nr.l yymore.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array.txt basic_r basic_r.c basic_r.l basic.txt bol_r bol_r.c bol_r.l bol.txt ccl_r ccl_r.c ccl_r.l ccl.txt debug_r debug_r.c debug_r.l debug.txt extended_r extended_r.c extended_r.l extended.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing.txt flexname_r flexname_r.c flexname_r.l flexname.txt lineno_r lineno_r.c lineno_r.l lineno.txt posix_r posix_r.c posix_r.l posix.txt preposix_r preposix_r.c preposix_r.l preposix.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment.txt reject_r reject_r.c reject_r.l reject.txt tableopts_r tableopts_r.c tableopts_r.l tableopts.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing.txt yyless_r yyless_r.c yyless_r.l yyless.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray.txt yymore_r yymore_r.c yymore_r.l yymore.txt yyunput_r yyunput_r.c yyunput_r.l yyunput.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array.txt basic_c99 basic_c99.c basic_c99.l basic.txt bol_c99 bol_c99.c bol_c99.l bol.txt ccl_c99 ccl_c99.c ccl_c99.l ccl.txt debug_c99 debug_c99.c debug_c99.l debug.txt extended_c99 extended_c99.c extended_c99.l extended.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing.txt flexname_c99 flexname_c99.c flexname_c99.l flexname.txt lineno_c99 lineno_c99.c lineno_c99.l lineno.txt posix_c99 posix_c99.c posix_c99.l posix.txt preposix_c99 preposix_c99.c preposix_c99.l preposix.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment.txt reject_c99 reject_c99.c reject_c99.l reject.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing.txt yyless_c99 yyless_c99.c yyless_c99.l yyless.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray.txt yymore_c99 yymore_c99.c yymore_c99.l yymore.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh diff --git a/tests/ruleset.sh b/tests/ruleset.sh index a2c000f..8832a57 100644 --- a/tests/ruleset.sh +++ b/tests/ruleset.sh @@ -33,7 +33,7 @@ for backend in "$@" ; do # shellcheck disable=2016 printf '\t$(SHELL) $(srcdir)/testmaker.sh $@\n\n' RULESET_TESTS="${RULESET_TESTS} ${testname}" - RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l ${testname}.txt" + RULESET_REMOVABLES="${RULESET_REMOVABLES} ${testname} ${testname}.c ${testname}.l ${ruleset%.*}.txt" fi done for kind in opt ser ver ; do -- cgit v1.2.1 From 30d15dfae9cf386c9871dda39838fcef7827c4d2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 17 Nov 2020 07:07:20 -0500 Subject: TYhis commit is a model for how to add a new back end. Begin the Go back end. Right now it's a fake that generates C... ...but this commit puts all the build and testnmachinery in place for when it's not. All tests pass. --- src/Makefile.am | 4 + src/go-flex.skl | 2550 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/skeletons.c | 6 + tests/Makefile.am | 12 +- tests/ruleset.am | 223 ++++- tests/testmaker.m4 | 32 + tests/testmaker.sh | 2 +- 7 files changed, 2825 insertions(+), 4 deletions(-) create mode 100644 src/go-flex.skl diff --git a/src/Makefile.am b/src/Makefile.am index 2df8cc9..029d06a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,6 +105,10 @@ c99-flex.h: c99-flex.skl mkskel.sh $(SHELL) $(srcdir)/mkskel.sh c99 $(srcdir) $(m4) $(VERSION) > $@.tmp mv -f $@.tmp $@ +go-flex.h: go-flex.skl mkskel.sh + $(SHELL) $(srcdir)/mkskel.sh go $(srcdir) $(m4) $(VERSION) > $@.tmp + mv -f $@.tmp $@ + if ENABLE_BOOTSTRAP stage1scan.c: scan.l stage1flex$(EXEEXT) ./stage1flex$(EXEEXT) $(AM_LFLAGS) $(LFLAGS) -o $@ $(srcdir)/scan.l diff --git a/src/go-flex.skl b/src/go-flex.skl new file mode 100644 index 0000000..3ef0229 --- /dev/null +++ b/src/go-flex.skl @@ -0,0 +1,2550 @@ +%# -*-C-*- vi: set ft=c: +%# +%# This is a fake Go back end. It clones C99, giving output files +%# a .go extension but generating C code. Its purpose is to verify build and test be +%# before actually trying to generate Go. +%# + +%# Macros for preproc stage. +m4preproc_changecom + +%# Macros for runtime processing stage. +m4_changecom +m4_changequote +m4_changequote([[, ]]) + +%# Properties not used in the skeleton - meant to be read by the Flex code +m4_define([[M4_PROPERTY_BACKEND_NAME]], [[Go]]) +m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[go]]) +m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) +m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) +m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) +m4_define([[M4_PROPERTY_CONTEXT_FORMAT]], [[yyscanner->%s_r]]) +m4_define([[M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT]], [[yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_%s]]) + +%# Macro hooks used by Flex code generators start here +m4_define([[M4_HOOK_INT32]], [[int32_t]]) +m4_define([[M4_HOOK_INT16]], [[int16_t]]) +m4_define([[M4_HOOK_COMMENT_OPEN]], [[/*]]) +m4_define([[M4_HOOK_COMMENT_CLOSE]], [[*/]]) +%# If this is not defined, no trace lines will be generated. +m4_define([[M4_HOOK_TRACE_LINE_FORMAT]], [[#line $1 "$2" +]]) +m4_define([[M4_HOOK_TABLE_OPENER]], [[{]]) +m4_define([[M4_HOOK_TABLE_CONTINUE]], [[},]]) +m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) +m4_define([[M4_HOOK_RELATIVIZE]], [[$1]]) +m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], +]]) +m4_define([[M4_HOOK_NORMAL_STATE_CASE_ARM]], [[ case $1:]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) +m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); +]]) +m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext */]]) +m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */]]) +m4_define([[M4_HOOK_CHAR_REWIND]], [[yyscanner->yy_c_buf_p = yy_cp -= $1;]]) +m4_define([[M4_HOOK_LINE_REWIND]], [[yy_lineno_rewind_to(yy_cp, yy_cp - $1, yyscanner);]]) +m4_define([[M4_HOOK_CHAR_FORWARD]], [[yyscanner->yy_c_buf_p = yy_cp = yy_bp + $1;]]) +m4_define([[M4_HOOK_LINE_FORWARD]], [[yy_lineno_rewind_to(yy_cp, yy_bp + $1, yyscanner);]]) +m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yy_state_type $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_BOOL]], [[const bool $1 = $2; +]]) +m4_define([[M4_HOOK_CONST_DEFINE_UNKNOWN]], [[m4_define($1, [[$2]])]]) +m4_define([[M4_HOOK_SET_YY_DECL]], [[m4_define([[YY_DECL]], [[$1]])]]) +m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[m4_define([[YY_OFFSET_TYPE]], [[$1]])]]) +m4_define([[M4_HOOK_SET_USERINIT]], [[m4_define([[YY_USER_INIT]], [[$1]])]]) +m4_define([[M4_HOOK_SET_RULE_SETUP]], [[m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ + rule_check_bol(yyscanner); +]]) m4_ifdef([[YY_USER_ACTION]], YY_USER_ACTION) +]]) +m4_define([[M4_HOOK_SET_PREACTION]], [[m4_define([[YY_USER_ACTION]], [[$1]])]]) +m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[/*LINTED*/break;]]) +m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], [[$1]])]]) +m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) +m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) + +m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) + +/* Return all but the first "n" matched characters back to the input stream. */ +m4_define([[yyless]], [[ + do { + /* Undo effects of setting up yytext. */ + int yyless_macro_arg = ($1); + m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(yyless_macro_arg, yyscanner);]]) + *yy_cp = yyscanner->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + yyscanner->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; + yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext again */ + } while ( 0 ) +]]) + +%# Can't be a function given the context-arg treatment due to the goto. +m4_define([[M4_HOOK_REJECT]], [[{ + *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ + yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ + yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ + yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ +]]) + ++yyscanner->yy_lp; + goto find_rule; +} +]]) + +%% [0.0] Make hook macros available to Flex + +const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; +const int YY_FLEX_MINOR_VERSION = FLEX_MINOR_VERSION; +const int YY_FLEX_SUBMINOR_VERSION = FLEX_SUBMINOR_VERSION; + +%# STARTS prefix machinery +%# +%# The complexity here is necessary so that m4 preserves +%# the argument lists to each C function. +%# +%# If your target language has OO you can generare a class definition, +%# use option yyclass to pass in the class name, and drop prefix support. + +m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) + +m4preproc_define(`M4_GEN_PREFIX',`` +[[#ifdef yy$1 +#define ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED +#else +#define yy$1 ]]M4_MODE_PREFIX[[$1 +#endif]] +'') + +m4_ifelse(M4_MODE_PREFIX,yy,, + M4_GEN_PREFIX(`_create_buffer') + M4_GEN_PREFIX(`_delete_buffer') + M4_GEN_PREFIX(`_scan_buffer') + M4_GEN_PREFIX(`_scan_string') + M4_GEN_PREFIX(`_scan_bytes') + M4_GEN_PREFIX(`_init_buffer') + M4_GEN_PREFIX(`_flush_buffer') + M4_GEN_PREFIX(`_load_buffer_state') + M4_GEN_PREFIX(`_switch_to_buffer') + M4_GEN_PREFIX(`push_buffer_state') + M4_GEN_PREFIX(`pop_buffer_state') + M4_GEN_PREFIX(`ensure_buffer_stack') + M4_GEN_PREFIX(`lex') + M4_GEN_PREFIX(`restart') + M4_GEN_PREFIX(`lex_init') + M4_GEN_PREFIX(`lex_init_extra') + M4_GEN_PREFIX(`lex_destroy') + M4_GEN_PREFIX(`get_debug') + M4_GEN_PREFIX(`set_debug') + M4_GEN_PREFIX(`get_extra') + M4_GEN_PREFIX(`set_extra') + M4_GEN_PREFIX(`get_in') + M4_GEN_PREFIX(`set_in') + M4_GEN_PREFIX(`get_out') + M4_GEN_PREFIX(`set_out') + M4_GEN_PREFIX(`get_leng') + M4_GEN_PREFIX(`get_text') + M4_GEN_PREFIX(`get_lineno') + M4_GEN_PREFIX(`set_lineno') + M4_GEN_PREFIX(`get_column') + M4_GEN_PREFIX(`set_column') + M4_GEN_PREFIX(`wrap') +) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + M4_GEN_PREFIX(`get_lval') + M4_GEN_PREFIX(`set_lval') +]]) + +m4_ifdef( [[]], +[[ + M4_GEN_PREFIX(`get_lloc') + M4_GEN_PREFIX(`set_lloc') +]]) + + +m4_ifelse(M4_MODE_PREFIX,yy,, + M4_GEN_PREFIX(`alloc') + M4_GEN_PREFIX(`realloc') + M4_GEN_PREFIX(`free') +) + +%# ENDS prefix machinery + +/* STARTS platform-specific and compiler-specific definitions. */ + +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , +[[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , +[[/* Feature test macros. Flex uses functions that require a minimum set of + * macros defined. As defining some macros may hide function declarations that + * user code might use, be conservative and respect user's definitions as much + * as possible. In glibc, feature test macros may not be all set up until one + * of the libc header (that includes ) is included. This creates + * a circular dependency when we check the macros. is the safest + * header we can include and does not declare too many functions we don't need. + */ +#if !defined(__GNU_LIBRARY__) && defined(__STDC__) +#include +#endif +#if !(defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_POSIX_SOURCE)) +# define _POSIX_C_SOURCE 1 /* Required for fileno() */ +# define _POSIX_SOURCE 1 +#endif]])]]) + +#include +#include +#include +#include +#include +#include +#include /* requred for isatty() */ + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* + * Anywhere other than C this won't be a thing, + * because strings will have an associated length field. + */ +const int YY_END_OF_BUFFER_CHAR = 0; + +/* ENDS platform-specific and compiler-specific definitions. */ + +/* + * Amount of stuff to slurp up with each read. + * We assume the stdio library has already + * chosen a fit size foe whatever platform + * we're running on. + */ +const int YY_READ_BUF_SIZE = BUFSIZ; + +/* Size of default input buffer. We want to be able to fit two + * OS-level reads, but efficiency gains as the buffer size + * increases fall off after that + */ +const int YY_BUF_SIZE = m4_ifdef([[M4_MODE_YY_BUFSIZE]], [[M4_MODE_YY_BUFSIZE]], [[2 * YY_READ_BUF_SIZE]]); + +/* Returned upon end-of-file. */ +const int YY_NULL = 0; + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +m4_define([[YY_SC_TO_UI]], [[((YY_CHAR)($1))]]) + +/* In the ancestal C back end this was a void pointer, meant to be + * opaque pointer. That indirection has been removed here as it + * wouldn't easily port to other langages. + */ +typedef struct yyguts_t *yyscan_t; + +/* Action number for EOF rule of a given start state. */ +m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yy_state_type))]]) + +typedef struct yy_buffer_state *yybuffer; + +typedef size_t yy_size_t; + +%# These are not part of the exported interface and cab safewky be renamed +const int EOB_ACT_CONTINUE_SCAN = 0; +const int EOB_ACT_END_OF_FILE = 1; +const int EOB_ACT_LAST_MATCH = 2; +const int YY_BUFFER_NEW = 0; +const int YY_BUFFER_NORMAL = 1; + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +const int YY_BUFFER_EOF_PENDING = 2; + +struct yy_buffer_state { + FILE *yy_input_file; + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + bool yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use char-by-char + * rather than a buffered read, to make sure we stop fetching input after + * each newline. + */ + bool yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + bool yyatbol_flag; + + int bs_yylineno; /**< The line count. */ + int bs_yycolumn; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + bool yy_fill_buffer; + + int yy_buffer_status; +}; + +/* These forwards can simply deleted when poerting to a target language + * with two-pass name resoltion. + */ +void *yyalloc ( yy_size_t, yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); +void yyfree ( void *, yyscan_t yyscanner ); + +/* Begin user sect3 */ + +m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ +int M4_MODE_PREFIX[[wrap]](yyscan_t yyscanner) { + return /*CONSTCOND*/1; +} +]]) + +const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); + +typedef uint8_t YY_CHAR; + +m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl +typedef const struct yy_trans_info *yy_state_type; +]], [[ +typedef int yy_state_type; +]]) + +/* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_define([[yytext_ptr]], [[yytext_r]]) +]]) + +%% [1.0] DFA + +static int yy_get_next_buffer ( yyscan_t yyscanner ); + +struct yy_trans_info { + /* We require that yy_verify and yy_nxt must be of the same size int. */ +m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ + YY_OFFSET_TYPE yy_verify; + + /* In cases where its sister yy_verify *is* a "yes, there is + * a transition", yy_nxt is the offset (in records) to the + * next state. In most cases where there is no transition, + * the value of yy_nxt is irrelevant. If yy_nxt is the -1th + * record of a state, though, then yy_nxt is the action number + * for that state. + */ + YY_OFFSET_TYPE yy_nxt; +]]) +m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ + /* We generate a bogus 'struct yy_trans_info' data type + * so we can guarantee that it is always declared in the skel. + * This is so we can compile "sizeof(struct yy_trans_info)" + * in any scanner. + */ + int32_t yy_verify; + int32_t yy_nxt; +]]) +}; + +%% [2.0] data tables for the DFA are inserted here + +m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = + { +M4_HOOK_NXT_BODY +]], [[ +m4_define([[YY_NXT_LOLEN]], [[(M4_HOOK_NXT_ROWS)]]) +static const M4_HOOK_NXT_TYPE *yy_nxt =0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl +/* Table of booleans, true if rule could match eol. */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, +M4_HOOK_EOLTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_NEED_ACCEPT]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, +M4_HOOK_ACCEPT_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_ACCEPT_TYPE * yy_accept = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl +/* Character equivalence-class mapping */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, +M4_HOOK_ECSTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const YY_CHAR * yy_ec = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl +/* Character meta-equivalence-class mappings */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, +M4_HOOK_MECSTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const YY_CHAR * yy_meta = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl +/* The transition table */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = { +M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const struct yy_trans_info *yy_transition = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl +/* Table of pointers to start states. */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { +M4_HOOK_STARTTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const struct yy_trans_info **yy_start_state_list =0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, +M4_HOOK_ACCLIST_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_ACCLIST_TYPE * yy_acclist = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_BASE_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, +M4_HOOK_BASE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_BASE_TYPE * yy_base = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_DEF_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, +M4_HOOK_DEF_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_DEF_TYPE * yy_def = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_YYNXT_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, +M4_HOOK_YYNXT_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_YYNXT_TYPE * yy_nxt = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_CHK_TYPE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, +M4_HOOK_CHK_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_CHK_TYPE * yy_chk = 0; +]]) + +]]) + +m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const yy_state_type yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, +M4_HOOK_NULTRANS_BODY[[]]m4_dnl +}; +]], [[ +static const yy_state_type * yy_NUL_trans = 0; +]]) + +]]) + +m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl +/* Rule to line-number mapping */ +m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl +static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, +M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl +}; +]], [[ +static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; +]]) + +]]) + +%% [3.0] static declarations conditional on mode switches go here + +M4_YY_SC_DEFS + +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl +%# These must match the values in the file flexdef.h +%# of the flex source code, otherwise havoc will ensue. +const int YY_TRAILING_MASK = 0x2000; +const int YY_TRAILING_HEAD_MASK = 0x4000; +]]) +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t { + /* User-defined. Not touched by flex. */ + m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[M4_MODE_EXTRA_TYPE yyextra_r;]]) + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + yybuffer * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + bool yy_init; + int yy_start; + bool yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yyflexdebug_r; + +m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; + +m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl + /* These are only needed for trailing context rules */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; +]]) +]]) +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ + char yytext_r[YYLMAX]; + char *yytext_ptr; + int yy_more_offset; + int yy_prev_more_offset; +]], [[ + char *yytext_r; + bool yy_more_flag; + int yy_more_len; +]]) +m4_ifdef( [[M4_YY_BISON_LVAL]], [[ + YYSTYPE * yylval_r; +]]) + +m4_ifdef( [[]], [[ + YYLTYPE * yylloc_r; +]]) +}; /* end struct yyguts_t */ + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ +/* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ +m4_define([[yylval]], [[yyscanner->yylval_r]]) +]]) + +m4_ifdef( [[]], +[[ +m4_define([[yylloc]], [[yyscanner->yylloc_r]]) +]]) + +/* Helpers for special functions, also part of public API */ + +/* Returns the top of the stack, or NULL. */ +yybuffer yy_current_buffer(yyscan_t yyscanner) { + return ( yyscanner->yy_buffer_stack \ + ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ + : NULL); +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; + yyscanner->yytext_ptr = yyscanner->yy_c_buf_p = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos; + yyscanner->yyin_r = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file; + yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; +} + +/** Discard all buffered characters. On the next scan, yyread() will be called. + * @param b the buffer state to be flushed, usually @c yy_current_buffer(yyscanner). + * @param yyscanner The scanner object. + */ +void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) +{ + if ( b == NULL ) { + return; + } + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yyatbol_flag = true; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer(yyscanner) ) { + yy_load_buffer_state( yyscanner ); + } +} + +void yy_flush_current_buffer(yyscan_t yyscanner) { + yy_flush_buffer( yy_current_buffer(yyscanner), yyscanner); +} + +const int YY_EXIT_FAILURE = 2; + +m4_ifdef( [[M4_YY_NO_YYPANIC]],, [[ +/* This gfunction has a magic rewrite rule */ +static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} +]]) + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + + if (yyscanner->yy_buffer_stack == NULL) { + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); + if ( yyscanner->yy_buffer_stack == NULL ) { + yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + } + + memset(yyscanner->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyscanner->yy_buffer_stack_max = num_to_alloc; + yyscanner->yy_buffer_stack_top = 0; + return; + } + + if (yyscanner->yy_buffer_stack_top >= (yyscanner->yy_buffer_stack_max) - 1) { + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyscanner->yy_buffer_stack_max + grow_size; + yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyscanner->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*), + yyscanner); + if (yyscanner->yy_buffer_stack == NULL) { + yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + } + /* zero only the new slots.*/ + memset(yyscanner->yy_buffer_stack + yyscanner->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyscanner->yy_buffer_stack_max = num_to_alloc; + } +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ +static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) +{ + int oerrno = errno; + + yy_flush_buffer( b, yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = true; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != yy_current_buffer(yyscanner)) { + b->bs_yylineno = 1; + b->bs_yycolumn = 0; + } + +m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], +[[ + b->yy_is_interactive = true; +]], +[[ + m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], + [[ + b->yy_is_interactive = false; + ]], + [[ + b->yy_is_interactive = (file != NULL) && (isatty( fileno(file) ) > 0); + ]]) +]]) + errno = oerrno; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ +yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) +{ + yybuffer b; + + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); + if ( b == NULL ) { + yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); + } + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + if ( b->yy_ch_buf == NULL ) { + yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); + } + b->yy_is_our_buffer = true; + + yy_init_buffer( b, file, yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ +void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) +{ + + if ( b == NULL ) { + return; + } + if ( b == yy_current_buffer(yyscanner) ) { /* Not sure if we should pop here. */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = (yybuffer) 0; + } + if ( b->yy_is_our_buffer ) { + yyfree( (void *) b->yy_ch_buf, yyscanner ); + } + yyfree( (void *) b, yyscanner ); +} + + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) +{ + if (new_buffer == NULL) { + return; + } + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( yy_current_buffer(yyscanner) != NULL ) { + /* Flush out information for old buffer. */ + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (yy_current_buffer(yyscanner)) { + yyscanner->yy_buffer_stack_top++; + } + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyscanner->yy_did_buffer_switch_on_eof = true; +} + + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + if (yy_current_buffer(yyscanner) == NULL) { + return; + } + yy_delete_buffer(yy_current_buffer(yyscanner), yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; + if (yyscanner->yy_buffer_stack_top > 0) { + --yyscanner->yy_buffer_stack_top; + } + if (yy_current_buffer(yyscanner) != NULL) { + yy_load_buffer_state( yyscanner ); + yyscanner->yy_did_buffer_switch_on_eof = true; + } +} + + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ +void yyrestart(FILE * input_file, yyscan_t yyscanner) +{ + + if ( yy_current_buffer(yyscanner) == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + + yy_init_buffer( yy_current_buffer(yyscanner), input_file, yyscanner); + yy_load_buffer_state( yyscanner ); +} + +static void yybumpline( yyscan_t yyscanner) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno++; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn=0; +} + +/* START special functions + * + * Flex's scanner knows these are special and inserts the yyscanner argument + * at the end of the argument list. TODO: support OO languages with a + * property that causes it to be prepended with a dot instead. + */ + +/* Enter a start condition. */ +void yybegin(int s, yyscan_t yyscanner) { + yyscanner->yy_start = 1 + 2 * (s); +} + +/* Translate the current start state into a value that can be later handed + * to yybegin() to return to the state. + */ +int yystart(yyscan_t yyscanner) { + return ((yyscanner->yy_start - 1) / 2); +} + +/* This used to be an fputs(), but since the string might contain NULs, + * we now use fwrite(). + */ +void yyecho(yyscan_t yyscanner) { + fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); +} + +m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ +void yyunput( int c, yyscan_t yyscanner) +{ + char *yy_cp; + + yy_cp = yyscanner->yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yyscanner->yy_hold_char; + + if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = yyscanner->yy_n_chars + 2; + char *dest = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size + 2]; + char *source = + &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; + + while ( source > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf ) { + *--dest = *--source; + } + yy_cp += (int) (dest - source); + yyscanner->yytext_ptr += (int) (dest - source); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = + yyscanner->yy_n_chars = (int) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size; + + if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + yypanic( "flex scanner push-back overflow", yyscanner); + } + } + + *--yy_cp = (char) c; + +m4_ifdef( [[M4_MODE_YYLINENO]], +[[ + if ( c == '\n' ){ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + } +]]) + + yyscanner->yy_hold_char = *yy_cp; + yyscanner->yy_c_buf_p = yy_cp; +} +]]) + +int yyinput (yyscan_t yyscanner) +{ + int c; + + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + + if ( *yyscanner->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyscanner->yy_c_buf_p < &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] ) { + /* This was really a NUL. */ + *yyscanner->yy_c_buf_p = '\0'; + } else { + /* need more input */ + int offset = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr); + ++yyscanner->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyscanner->yyin_r, yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + if ( yywrap( yyscanner ) ) { + return 0; + } + if ( ! yyscanner->yy_did_buffer_switch_on_eof ) { + yyrestart( yyscanner->yyin_r, yyscanner ); + } + return yyinput(yyscanner); + + case EOB_ACT_CONTINUE_SCAN: + yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyscanner->yy_c_buf_p; /* cast for 8-bit char's */ + *yyscanner->yy_c_buf_p = '\0'; /* preserve yytext */ + yyscanner->yy_hold_char = *++yyscanner->yy_c_buf_p; + +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (c == '\n'); +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag ) { + yybumpline( yyscanner ); + } +]]) +]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ +m4_ifdef([[M4_MODE_YYLINENO]], [[ + if ( c == '\n' ) { + yybumpline( yyscanner ); + } + ]]) +]]) + + return c; +} + +/* ENDS special functions + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +m4_ifdef( [[M4_MODE_NO_YYWRAP]],, [[ +extern int yywrap ( yyscan_t yyscanner ); +]]) + +m4_ifdef( [[M4_YY_STACK_USED]], +[[ + m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, + [[ + static void yy_push_state ( int _new_state, yyscan_t yyscanner); + ]]) + m4_ifdef( [[M4_YY_NO_POP_STATE]],, + [[ + static void yy_pop_state ( yyscan_t yyscanner ); + ]]) + m4_ifdef( [[M4_YY_NO_TOP_STATE]],, + [[ + static int yy_top_state ( yyscan_t yyscanner ); + ]]) +]], +[[ +m4_define( [[M4_YY_NO_PUSH_STATE]]) +m4_define( [[M4_YY_NO_POP_STATE]]) +m4_define( [[M4_YY_NO_TOP_STATE]]) +]]) + +m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { + int result; +m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ + errno=0; + while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { + if( errno != EINTR) { + yypanic( "input in flex scanner failed", yyscanner); + break; + } + errno=0; + clearerr(yyscanner->yyin_r); + } +]]) +m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive ) { + int c = '*'; + int n; + for ( n = 0; n < max_size && + (c = getc( yyscanner->yyin_r )) != EOF && c != '\n'; ++n ) { + buf[n] = (char) c; + } + if ( c == '\n' ) { + buf[n++] = (char) c; + } + if ( c == EOF && ferror( yyscanner->yyin_r ) ) { + yypanic( "input in flex scanner failed", yyscanner); + } + result = n; + } else { + errno=0; + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + if( errno != EINTR) { + yypanic( "input in flex scanner failed", yyscanner); + break; + } + errno=0; + clearerr(yyscanner->yyin_r); + } + } +]]) + return result; +} +]]) + +/* STARTS Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +M4_MODE_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { + return yyscanner->yyextra_r; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_GET_LINENO]],, +[[ +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); + + if (cb == NULL) { + return 0; + } + return cb->bs_yylineno; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +[[ +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); + + if (cb == NULL) { + return 0; + } + return cb->bs_yycolumn; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_IN]],, +[[ +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) { + return yyscanner->yyin_r; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_OUT]],, +[[ +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) { + return yyscanner->yyout_r; +} +]]) + +m4_ifdef( [[M4_YY_NO_GET_LENG]],, +[[ +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int yyget_leng (yyscan_t yyscanner) { + return yyscanner->yyleng_r; +} +]]) + +/** Get the current token. + * @param yyscanner The scanner object. + */ +m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +[[ +char *yyget_text (yyscan_t yyscanner) { + return yyscanner->yytext_r; +} +]]) + +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +[[ +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { + yyscanner->yyextra_r = user_defined ; +} +]]) +]]) + +m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +[[ +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno(int _line_number, yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); + + /* lineno is only valid if an input buffer exists. */ + if (cb == NULL ) { + yypanic( "yyset_lineno called with no buffer", yyscanner ); + } + cb->bs_yylineno = _line_number; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +[[ +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column(int _column_no, yyscan_t yyscanner) { + yybuffer cb = yy_current_buffer(yyscanner); + + /* column is only valid if an input buffer exists. */ + if (cb == NULL ) { + yypanic( "yyset_column called with no buffer", yyscanner ); + } + cb->bs_yycolumn = _column_no; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_IN]],, +[[ +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in(FILE * _in_str, yyscan_t yyscanner) { + yyscanner->yyin_r = _in_str ; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_OUT]],, +[[ +void yyset_out( FILE * _out_str, yyscan_t yyscanner) { + yyscanner->yyout_r = _out_str ; +} +]]) + + +m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +[[ +int yyget_debug (yyscan_t yyscanner) { + return yyscanner->yyflexdebug_r; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +[[ +void yyset_debug(int _bdebug, yyscan_t yyscanner) { + yyscanner->yyflexdebug_r = _bdebug ; +} +]]) + +m4_ifdef([[M4_YY_BISON_LVAL]], [[ +m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +[[ +YYSTYPE * yyget_lval (yyscan_t yyscanner) { + return yylval; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LVAL]],, +[[ +void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { + yylval = yylval_param; +} +]]) + +m4_ifdef( [[]], +[[ +m4_ifdef( [[M4_YY_NO_GET_LLOC]],, +[[ +YYLTYPE *yyget_lloc (yyscan_t yyscanner) { + return yylloc; +} +]]) + +m4_ifdef( [[M4_YY_NO_SET_LLOC]],, +[[ +void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { + yylloc = yylloc_param; +} +]]) +]]) + +]]) + +/* ENDS public accessor functions */ + +/* Number of entries by which start-condition stack grows. */ +const int YY_START_STACK_INCR = 25; + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +m4_ifdef([[YY_DECL]],, [[m4_dnl +m4_define( [[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) +m4_define( [[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + m4_dnl The bison pure parser is used. Redefine yylex to + m4_dnl accept the lval parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) +]]) + +m4_ifdef( [[]], +[[ + m4_dnl Locations are used. yylex should also accept the ylloc parameter. + + m4_define( [[M4_YY_LEX_PROTO]], [[\]] + [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param, yyscan_t yyscanner)]]) + m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + [[(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)]]) +]]) + +extern int yylex M4_YY_LEX_PROTO; + +m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) +]]) + +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ +static void rule_check_bol(yyscan_t yyscanner) { + if ( yyscanner->yyleng_r > 0 ) { \ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + } +} +]]) + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. yy_cp and yy_bp are the + * end abd start pointers for the input buffer segment that is + * claimed as yytext. + */ +void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { + yyscanner->yytext_ptr = yy_bp; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; \ + yyscanner->yyleng_r = (int) (yy_cp - yyscanner->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ + yyscanner->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ + yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ + yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ +]]) \ + yyscanner->yy_c_buf_p = yy_cp; +} + +m4_ifdef( [[M4_MODE_YYLINENO]], [[ +/* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro + * and we can get at yy_act */ +static void yy_less_lineno(int n, yyscan_t yyscanner) { + int yyl; + for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { + if ( yyscanner->yytext_r[yyl] == '\n' ) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + } + } +} + +static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { + const char *p; + for ( p = yy_cp-1; p >= dst; --p) { + if ( *p == '\n' ) { + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + } + } +} +]]) + +void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { + if ( yy_current_buffer(yyscanner) == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; +} + + +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ +yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; +yyscanner->yyleng_r -= yyscanner->yy_more_offset; +} +]]) +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} +m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) +]]) +]]) + +m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) +]]) + +void yysetbol(bool at_bol, yyscan_t yyscanner) { + if ( yy_current_buffer(yyscanner) == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = at_bol; +} + +bool yyatbol(yyscan_t yyscanner) { + return (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ +void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( yy_current_buffer(yyscanner) == new_buffer ) { + return; + } + if ( yy_current_buffer(yyscanner) ) { + /* Flush out information for old buffer. */ + *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } + + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyscanner->yy_did_buffer_switch_on_eof = true; +} + + +m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, +[[ +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) +{ + yybuffer b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) { + /* They forgot to leave room for the EOB's. */ + return NULL; + } + b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); + if ( b == NULL ) { + yypanic( "out of dynamic memory in yy_scan_buffer()", yyscanner ); + } + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = false; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = false; + b->yyatbol_flag = true; + b->yy_fill_buffer = false; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b, yyscanner ); + + return b; +} +]]) + +m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, +[[ +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { + yybuffer b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n, yyscanner ); + if ( buf == 0 ) { + yypanic( "out of dynamic memory in yy_scan_bytes()", yyscanner ); + } + for ( i = 0; i < _yybytes_len; ++i ) { + buf[i] = yybytes[i]; + } + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n, yyscanner); + if ( b == NULL ) { + yypanic( "bad buffer in yy_scan_bytes()", yyscanner ); + } + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = true; + + return b; +} +]]) + +m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, +[[ +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) +{ + return yy_scan_bytes( yystr, (int) strlen(yystr), yyscanner); +} +]]) + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; + char *source = yyscanner->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { + yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); + } + if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) { + *(dest++) = *(source++); + } + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; + } else { + int num_to_read = + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yypanic( + "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); +]], +[[ + /* just a shorter name for the current buffer */ + yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; + + int yy_c_buf_p_offset = + (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) { + b->yy_buf_size += b->yy_buf_size / 8; + } else { + b->yy_buf_size *= 2; + } + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + } else { + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + } + if ( b->yy_ch_buf == NULL ) { + yypanic("fatal error - scanner input buffer overflow", yyscanner); + } + yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - + number_to_move - 1; +]]) + } + + if ( num_to_read > YY_READ_BUF_SIZE ) { + num_to_read = YY_READ_BUF_SIZE; + } + /* Read in more data. */ + yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); + + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } + + if ( yyscanner->yy_n_chars == 0 ) { + if ( number_to_move == YY_MORE_ADJ ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyscanner->yyin_r, yyscanner); + } else { + ret_val = EOB_ACT_LAST_MATCH; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } else { + ret_val = EOB_ACT_CONTINUE_SCAN; + } + if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( + (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { + yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); + } + /* "- 2" to take care of EOB's */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); + } + + yyscanner->yy_n_chars += number_to_move; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; + + return ret_val; +} + +m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, +[[ +static void yy_push_state(int _new_state, yyscan_t yyscanner) +{ + if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) { + yy_size_t new_size; + + yyscanner->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int ); + + if ( yyscanner->yy_start_stack == NULL ) { + yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); + + } else { + yyscanner->yy_start_stack = (int *) yyrealloc( + (void *) yyscanner->yy_start_stack, new_size, yyscanner ); + } + if ( yyscanner->yy_start_stack == NULL ) { + yypanic( "out of memory expanding start-condition stack", yyscanner); + } + } + yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner); + + yybegin(_new_state, yyscanner); +} +]]) + + +m4_ifdef( [[M4_YY_NO_POP_STATE]],, +[[ +static void yy_pop_state (yyscan_t yyscanner) +{ + if ( --yyscanner->yy_start_stack_ptr < 0 ) { + yypanic( "start-condition stack underflow", yyscanner ); + } + yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner); +} +]]) + + +m4_ifdef( [[M4_YY_NO_TOP_STATE]],, +[[ +static int yy_top_state (yyscan_t yyscanner) +{ + return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner); +} +]]) + +%# Code snippets used in various cases of code generation in the main scanner. + +m4_define([[M4_GEN_BACKING_UP]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + /* Generate code to keep backing-up information. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ + if ( yy_current_state[-1].yy_nxt ) { +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + if ( yy_accept[yy_current_state] ) { +]]) + yyscanner->yy_last_accepting_state = yy_current_state; + yyscanner->yy_last_accepting_cpos = yy_cp; + } +]]) +]]) +]]) + +%# yy_c was formerly YY_CHAR, changed to int because table can now +%# have up to 0x101 entries, since we no longer generate a separate +%# NUL table. +%# +%# Note: on x86-64 architecture with gcc -O2, we save an instruction +%# in the main loop, since the character can now be zero-extended in +%# the process of retrieving it from the input stream or the yy_ec[] +%# or yy_meta[] arrays, whereas previously it was zero-extended by a +%# register-to-register move just prior to the yy_chk[] table lookup +m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ + int yy_c = $1; + /* Save the backing-up info \before/ computing the next state + * because we always compute one more state than needed - we + * always proceed until we reach a jam state + */ + M4_GEN_BACKING_UP + + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { + yy_current_state = (int) yy_def[yy_current_state]; + +m4_ifdef([[M4_MODE_USEMECS]], [[ + /* We've arranged it so that templates are never chained + * to one another. This means we can afford to make a + * very simple test to see if we need to convert to + * yy_c's meta-equivalence class without worrying + * about erroneously looking up the meta-equivalence + * class twice + */ + + /* lastdfa + 2 == YY_JAMSTATE + 1 is the beginning of the templates */ + if (yy_current_state >= YY_JAMSTATE + 1) { + yy_c = yy_meta[yy_c]; + } +]]) + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; +]]) + +m4_define([[M4_GEN_START_STATE]], [[ + /* Generate the code to find the start state. */ +m4_ifdef([[M4_MODE_FULLSPD]], [[ +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start + yyatbol()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start];]]) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ + yy_current_state = yyscanner->yy_start; +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yyatbol(yyscanner);]]) + /* Set up for storing up states. */ + m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + yyscanner->yy_state_ptr = yyscanner->yy_state_buf; + *yyscanner->yy_state_ptr++ = yy_current_state; +]]) +]]) +]]) + +m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ + { + const struct yy_trans_info *yy_trans_info; + YY_CHAR yy_c; + + for ( yy_c = $1; + (yy_trans_info = &yy_current_state[yy_c])->yy_verify == yy_c; + yy_c = $2 ) + { + yy_current_state += yy_trans_info->yy_nxt; + + M4_GEN_BACKING_UP + } + } +]]) + +/* + * Helpers for yylex() + */ + +%# Conditional indirection through an equivalence map +m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) +m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { + yy_state_type yy_current_state; + char *yy_cp; + + M4_GEN_START_STATE + for ( yy_cp = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_cp < yyscanner->yy_c_buf_p; ++yy_cp ) { + /* Generate the code to find the next state. */ + m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) + m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) + + m4_ifdef([[M4_MODE_NULTRANS]], [[ + /* Compressed tables back up *before* they match. */ + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) + if ( *yy_cp ) { + ]]) + + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ + m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) + ]]) + + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) + m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) + +m4_ifdef([[M4_MODE_NULTRANS]], [[ + } else { + yy_current_state = yy_NUL_trans[yy_current_state]; + } +]]) + + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ +static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner) +{ + bool yy_is_jam; + /* Generate code for handling NUL's, if needed. */ + + /* First, deal with backing up and setting up yy_cp if the scanner + * finds that it should JAM on the NUL. + * + * Only generate a definition for "yy_cp" if we'll generate code + * that uses it. Otherwise lint and the like complain. + */ + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyscanner->yy_c_buf_p;]]) + +%# Note that this statement block and the following three are +%# not executed serially but are an if-then-else cascade +%# for different table modes. +m4_ifdef([[M4_MODE_NULTRANS]], [[ + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) + yy_is_jam = (yy_current_state <= 0); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ + int yy_c = YY_NUL_EC; + + const struct yy_trans_info *yy_trans_info; + + yy_trans_info = &yy_current_state[(unsigned int) yy_c]; + yy_current_state += yy_trans_info->yy_nxt; + yy_is_jam = (yy_trans_info->yy_verify != yy_c); +]]) + +m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ +M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) +yy_is_jam = (yy_current_state == YY_JAMSTATE); +m4_ifdef([[M4_MODE_USES_REJECT]], [[ + /* Only stack this state if it's a transition we + * actually make. If we stack it on a jam, then + * the state stack and yy_c_buf_p get out of sync. + */ + if ( ! yy_is_jam ) { + *yyscanner->yy_state_ptr++ = yy_current_state; + } + ]]) +]]) +]]) +]]) +%# End of if-else cascade + +m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ + /* If we've entered an accepting state, back up; note that + * compressed tables have *already* done such backing up, so + * we needn't bother with it again. + */ + if ( ! yy_is_jam ) { + M4_GEN_BACKING_UP + } +]]) + + (void)yyscanner; /* forestall unused-argument warning */ + return yy_is_jam ? 0 : yy_current_state; +} + +/** The main scanner function which does all the work. + */ +YY_DECL { + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + +m4_ifdef( [[M4_YY_BISON_LVAL]], +[[ + yylval = yylval_param; +]]) + +m4_ifdef( [[]], +[[ + yylloc = yylloc_param; +]]) + + if ( !yyscanner->yy_init ) { + yyscanner->yy_init = true; + + m4_ifdef([[YY_USER_INIT]], [[YY_USER_INIT]]) + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + /* Create the reject buffer large enough to save one state per allowed character. */ + if ( yyscanner->yy_state_buf == NULL ) { + yyscanner->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); + } + if ( yyscanner->yy_state_buf == NULL) { + yypanic( "out of dynamic memory in yylex()", yyscanner); + } +]]) + + if ( yyscanner->yy_start == 0 ) { + yyscanner->yy_start = 1; /* first start state */ + } + if ( yyscanner->yyin_r == NULL ) { + yyscanner->yyin_r = stdin; + } + if ( yyscanner->yyout_r == NULL ) { + yyscanner->yyout_r = stdout; + } + if ( yy_current_buffer(yyscanner) == NULL ) { + yyensure_buffer_stack (yyscanner); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + /* open scope of user declarationns */ + { +%% [4.0] user's declarations go here + + while ( /*CONSTCOND*/1 ) { /* loops until end-of-file is reached */ +m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ + yyscanner->yy_more_len = 0; + if ( yyscanner->yy_more_flag ) { + yyscanner->yy_more_len = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr); + yyscanner->yy_more_flag = false; + } +]]) +]]) + yy_cp = yyscanner->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyscanner->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + +M4_GEN_START_STATE + + yy_match: + /* Generate the code to find the next match. */ +m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl +m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl + while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { +]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ + while ((yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { +]]) +M4_GEN_BACKING_UP + yy_cp++; + } + yy_current_state = -yy_current_state; +]]) +m4_ifdef([[M4_MODE_FULLSPD]], [[ + M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yy_cp)), M4_EC(YY_SC_TO_UI(*++yy_cp))) +]]) +m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ + do { + M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) + + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) + ++yy_cp; + + } + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yy_current_state] != YY_JAMBASE );]]) + m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yy_current_state != YY_JAMSTATE );]]) + +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ + /* Do the guaranteed-needed backing up to figure out + * the match. + */ + yy_cp = yyscanner->yy_last_accepting_cpos; + yy_current_state = yyscanner->yy_last_accepting_state; +]]) +]]) +]]) + + yy_find_action: + /* code to find the action number goes here */ + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ + yy_current_state = *--yyscanner->yy_state_ptr; + yyscanner->yy_lp = yy_accept[yy_current_state]; +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) + for ( ; ; ) { /* loop until we find out what rule we matched */ + if (yyscanner->yy_lp && yyscanner->yy_lp < yy_accept[yy_current_state + 1]) { + yy_act = yy_acclist[yyscanner->yy_lp]; +m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || yyscanner->yy_looking_for_trail_begin) { + if (yy_act == yyscanner->yy_looking_for_trail_begin) { + yyscanner->yy_looking_for_trail_begin = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } else if (( yy_act & YY_TRAILING_MASK) != 0) { + yyscanner->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; + yyscanner->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; +m4_ifdef([[M4_MODE_REAL_REJECT]], [[ + /* Remember matched text in case we back up + * due to REJECT. + */ + yyscanner->yy_full_match = yy_cp; + yyscanner->yy_full_state = yyscanner->yy_state_ptr; + yyscanner->yy_full_lp = yyscanner->yy_lp; +]]) + } else { + yyscanner->yy_full_match = yy_cp; + yyscanner->yy_full_state = yyscanner->yy_state_ptr; + yyscanner->yy_full_lp = yyscanner->yy_lp; + break; + } + ++yyscanner->yy_lp; + goto find_rule; +]]) +m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ + /* Remember matched text in case we back up due to + * trailing context plus REJECT. + */ + yyscanner->yy_full_match = yy_cp; + break; +]]) + } + + --yy_cp; + + /* We could consolidate the following two lines with those at + * the beginning, but at the cost of complaints that we're + * branching inside a loop. + */ + yy_current_state = *--yyscanner->yy_state_ptr; + yyscanner->yy_lp = yy_accept[yy_current_state]; + } /* close for */ +]]) +m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) { /* have to back up */ + yy_cp = yyscanner->yy_last_accepting_cpos; + yy_current_state = yyscanner->yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } +]]) + + yy_do_before_action(yyscanner, yy_cp, yy_bp); + +m4_ifdef( [[M4_MODE_YYLINENO]],[[ +m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], + [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], + [[yyscanner->yy_prev_more_offset]], [[yyscanner->yy_more_len]])]], [[0]])]]) + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { + int yyl; + for ( yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl ) { + if ( yyscanner->yytext_r[yyl] == '\n' ) { + yybumpline( yyscanner ); + + } + } + } +]]) + + do_action: /* This label is used only to access EOF actions. */ + +m4_ifdef([[M4_MODE_DEBUG]], [[ + if ( yyscanner->yyflexdebug_r ) { + if ( yy_act == 0 ) { + fprintf( stderr, "--scanner backing up\n" ); + } else if ( yy_act < YY_NUM_RULES ) { + fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", + (long)yy_rule_linenum[yy_act], yyscanner->yytext_r ); + } else if ( yy_act == YY_NUM_RULES ) { + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yyscanner->yytext_r ); + } else if ( yy_act == YY_NUM_RULES + 1 ) { + fprintf( stderr, "--(end of buffer or a NUL)\n" ); + } else { + fprintf( stderr, "--EOF (start condition %d)\n", yystart(yyscanner) ); + } + } +]]) + + switch ( yy_act ) { /* beginning of action switch */ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ + case 0: /* must back up */ + /* undo the effects of yy_do_before_action() */ + *yy_cp = yyscanner->yy_hold_char; + + /* Backing-up info for compressed tables is taken \after/ */ + /* yy_cp has been incremented for the next state. */ + yy_cp = yyscanner->yy_last_accepting_cpos; + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) + + yy_current_state = yyscanner->yy_last_accepting_state; + goto yy_find_action; +]]) +]]) +%% [5.0] user actions get inserted here + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyscanner->yytext_ptr) - 1; + + /* Undo the effects of yy_do_before_action(). */ + *yy_cp = yyscanner->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_NEW ) { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer(yyscanner) and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file = yyscanner->yyin_r; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyscanner->yy_c_buf_p <= &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] ) { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state, yyscanner); + + yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) { + /* Consume the NUL. */ + yy_cp = ++yyscanner->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } else { +%# Disguised case statement on table modes + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = yyscanner->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = yyscanner->yy_c_buf_p;]]) +m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ +m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ +m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ + /* Do the guaranteed-needed backing up to figure + * out the match. + */ + yy_cp = yyscanner->yy_last_accepting_cpos; + yy_current_state = yyscanner->yy_last_accepting_state; +]]) +]]) +%# Disguised case statement on table modes ends +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ + /* Still need to initialize yy_cp, though + * yy_current_state was set up by + * yy_get_previous_state(). + */ + yy_cp = yyscanner->yy_c_buf_p; +]]) +]]) + goto yy_find_action; + } + } else { /* not a NUL */ + switch ( yy_get_next_buffer( yyscanner ) ) { + case EOB_ACT_END_OF_FILE: + yyscanner->yy_did_buffer_switch_on_eof = false; + + if ( yywrap( yyscanner ) ) { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(yystart(yyscanner)); + goto do_action; + } else { + if ( ! yyscanner->yy_did_buffer_switch_on_eof ) { + yyrestart( yyscanner->yyin_r, yyscanner ); + } + } + break; + case EOB_ACT_CONTINUE_SCAN: + yyscanner->yy_c_buf_p = + yyscanner->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyscanner->yy_c_buf_p; + yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyscanner->yy_c_buf_p = + &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyscanner->yy_c_buf_p; + yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } /* end EOB inner switch */ + } /* end if */ + break; + } /* case YY_END_OF_BUFFER */ + default: + yypanic("fatal flex scanner internal error--no action found", yyscanner); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +m4_undefine([[yyless]]) + +/* Redefine yyless() so it works in section 3 code. */ + +void yyless(int n, yyscan_t yyscanner) { + /* Undo effects of setting up yytext. */ + m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(n, yyscanner);]]) + yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yy_hold_char; + yyscanner->yy_c_buf_p = yyscanner->yytext_r + n; + yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; + *yyscanner->yy_c_buf_p = '\0'; + yyscanner->yyleng_r = n; +} + +static int yy_init_globals (yyscan_t yyscanner) { + /* + * This function is called from yylex_destroy(), so don't allocate here. + */ + yyscanner->yy_buffer_stack = NULL; + yyscanner->yy_buffer_stack_top = 0; + yyscanner->yy_buffer_stack_max = 0; + yyscanner->yy_c_buf_p = NULL; + yyscanner->yy_init = false; + yyscanner->yy_start = 0; + yyscanner->yy_start_stack_ptr = 0; + yyscanner->yy_start_stack_depth = 0; + yyscanner->yy_start_stack = NULL; + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yyscanner->yy_state_buf = 0; + yyscanner->yy_state_ptr = 0; + yyscanner->yy_full_match = 0; + yyscanner->yy_lp = 0; +]]) + +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], +[[ + yyscanner->yytext_ptr = 0; + yyscanner->yy_more_offset = 0; + yyscanner->yy_prev_more_offset = 0; +]]) + + yyscanner->yyin_r = NULL; + yyscanner->yyout_r = NULL; + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) { + if (ptr_yy_globals == NULL) { + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL) { + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL) { + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL) { + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} +]]) + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { + + /* Pop the buffer stack, destroying each element. */ + while(yy_current_buffer(yyscanner)) { + yy_delete_buffer( yy_current_buffer(yyscanner), yyscanner ); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyscanner->yy_buffer_stack, yyscanner); + yyscanner->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyscanner->yy_start_stack, yyscanner ); + yyscanner->yy_start_stack = NULL; + +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yyfree ( yyscanner->yy_state_buf, yyscanner); + yyscanner->yy_state_buf = NULL; +]]) + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals(yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner, yyscanner ); + yyscanner = NULL; + return 0; +} + +m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc(yy_size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return malloc(size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + free( (char *) ptr ); +} +]]) + +m4_ifdef([[M4_YY_MAIN]], [[ +int main () { + yyscan_t lexer; + yylex_init(&lexer); + yylex( lexer ); + yylex_destroy( lexer); + yylex(); + + return 0; +} +]]) + +%# Local Variables: +%# mode:c +%# c-file-style:"k&r" +%# c-basic-offset:8 +%# End: diff --git a/src/skeletons.c b/src/skeletons.c index b55cb27..ea6bf42 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -47,6 +47,11 @@ const char *c99_skel[] = { 0, }; +const char *go_skel[] = { +#include "go-flex.h" + 0, +}; + /* END digested skeletons */ /* Method table describing a language-specific back end. @@ -61,6 +66,7 @@ struct flex_backend_t { static struct flex_backend_t backends[] = { {.skel=cpp_skel}, {.skel=c99_skel}, + {.skel=go_skel}, {NULL} }; diff --git a/tests/Makefile.am b/tests/Makefile.am index efc3a84..d20fad2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -359,6 +359,16 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c top_main.$(OBJEXT): top.h top.h: top.c +# Build rules for non-C back ends + +.l.go: $(FLEX) + $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $< + +# This is a temporary fake rule for use while the Go back end still +# actually generates C. +.go: + $(CC) $< -o $*_go + # Most test productions can be autogenerated from ruleset files, but # automake has no way to specify such things with a loop in a variable # (even though make can do such things) and the resultant list is both @@ -366,7 +376,7 @@ top.h: top.c # script, ruleset.sh. $(srcdir)/ruleset.am: $(srcdir)/ruleset.sh $(srcdir)/*.rules - $(SHELL) $(srcdir)/ruleset.sh nr r c99 > $(srcdir)/ruleset.am + $(SHELL) $(srcdir)/ruleset.sh nr r c99 go > $(srcdir)/ruleset.am include $(srcdir)/ruleset.am diff --git a/tests/ruleset.am b/tests/ruleset.am index 90af507..b4571f1 100644 --- a/tests/ruleset.am +++ b/tests/ruleset.am @@ -645,6 +645,218 @@ tableopts_ver_c99_Caem_ver_SOURCES = tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 $(SHELL) $(srcdir)/testmaker.sh $@ +array_go_SOURCES = array_go.l +array_go.l: $(srcdir)/array.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +basic_go_SOURCES = basic_go.l +basic_go.l: $(srcdir)/basic.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +bol_go_SOURCES = bol_go.l +bol_go.l: $(srcdir)/bol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +ccl_go_SOURCES = ccl_go.l +ccl_go.l: $(srcdir)/ccl.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +debug_go_SOURCES = debug_go.l +debug_go.l: $(srcdir)/debug.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +extended_go_SOURCES = extended_go.l +extended_go.l: $(srcdir)/extended.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +fixedtrailing_go_SOURCES = fixedtrailing_go.l +fixedtrailing_go.l: $(srcdir)/fixedtrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +flexname_go_SOURCES = flexname_go.l +flexname_go.l: $(srcdir)/flexname.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +lineno_go_SOURCES = lineno_go.l +lineno_go.l: $(srcdir)/lineno.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +posix_go_SOURCES = posix_go.l +posix_go.l: $(srcdir)/posix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +preposix_go_SOURCES = preposix_go.l +preposix_go.l: $(srcdir)/preposix.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +quoteincomment_go_SOURCES = quoteincomment_go.l +quoteincomment_go.l: $(srcdir)/quoteincomment.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +reject_go_SOURCES = reject_go.l +reject_go.l: $(srcdir)/reject.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_go_SOURCES = tableopts_go.l +tableopts_go.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +vartrailing_go_SOURCES = vartrailing_go.l +vartrailing_go.l: $(srcdir)/vartrailing.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yyless_go_SOURCES = yyless_go.l +yyless_go.l: $(srcdir)/yyless.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yymorearraybol_go_SOURCES = yymorearraybol_go.l +yymorearraybol_go.l: $(srcdir)/yymorearraybol.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yymorearray_go_SOURCES = yymorearray_go.l +yymorearray_go.l: $(srcdir)/yymorearray.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yymore_go_SOURCES = yymore_go.l +yymore_go.l: $(srcdir)/yymore.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +yyunput_go_SOURCES = yyunput_go.l +yyunput_go.l: $(srcdir)/yyunput.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Ca_opt_SOURCES = tableopts_opt_go-Ca.opt.l +tableopts_opt_go-Ca.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Ce_opt_SOURCES = tableopts_opt_go-Ce.opt.l +tableopts_opt_go-Ce.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Cf_opt_SOURCES = tableopts_opt_go-Cf.opt.l +tableopts_opt_go-Cf.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_CxF_opt_SOURCES = tableopts_opt_go-CxF.opt.l +tableopts_opt_go-CxF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Cm_opt_SOURCES = tableopts_opt_go-Cm.opt.l +tableopts_opt_go-Cm.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Cem_opt_SOURCES = tableopts_opt_go-Cem.opt.l +tableopts_opt_go-Cem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Cae_opt_SOURCES = tableopts_opt_go-Cae.opt.l +tableopts_opt_go-Cae.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Caef_opt_SOURCES = tableopts_opt_go-Caef.opt.l +tableopts_opt_go-Caef.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_CaexF_opt_SOURCES = tableopts_opt_go-CaexF.opt.l +tableopts_opt_go-CaexF.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Cam_opt_SOURCES = tableopts_opt_go-Cam.opt.l +tableopts_opt_go-Cam.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_opt_go_Caem_opt_SOURCES = tableopts_opt_go-Caem.opt.l +tableopts_opt_go-Caem.opt.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Ca_ser_SOURCES = tableopts_ser_go-Ca.ser.l +tableopts_ser_go-Ca.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Ce_ser_SOURCES = tableopts_ser_go-Ce.ser.l +tableopts_ser_go-Ce.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Cf_ser_SOURCES = tableopts_ser_go-Cf.ser.l +tableopts_ser_go-Cf.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_CxF_ser_SOURCES = tableopts_ser_go-CxF.ser.l +tableopts_ser_go-CxF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Cm_ser_SOURCES = tableopts_ser_go-Cm.ser.l +tableopts_ser_go-Cm.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Cem_ser_SOURCES = tableopts_ser_go-Cem.ser.l +tableopts_ser_go-Cem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Cae_ser_SOURCES = tableopts_ser_go-Cae.ser.l +tableopts_ser_go-Cae.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Caef_ser_SOURCES = tableopts_ser_go-Caef.ser.l +tableopts_ser_go-Caef.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_CaexF_ser_SOURCES = tableopts_ser_go-CaexF.ser.l +tableopts_ser_go-CaexF.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Cam_ser_SOURCES = tableopts_ser_go-Cam.ser.l +tableopts_ser_go-Cam.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ser_go_Caem_ser_SOURCES = tableopts_ser_go-Caem.ser.l +tableopts_ser_go-Caem.ser.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Ca_ver_SOURCES = tableopts_ver_go-Ca.ver.l +tableopts_ver_go-Ca.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Ce_ver_SOURCES = tableopts_ver_go-Ce.ver.l +tableopts_ver_go-Ce.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Cf_ver_SOURCES = tableopts_ver_go-Cf.ver.l +tableopts_ver_go-Cf.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_CxF_ver_SOURCES = tableopts_ver_go-CxF.ver.l +tableopts_ver_go-CxF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Cm_ver_SOURCES = tableopts_ver_go-Cm.ver.l +tableopts_ver_go-Cm.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Cem_ver_SOURCES = tableopts_ver_go-Cem.ver.l +tableopts_ver_go-Cem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Cae_ver_SOURCES = tableopts_ver_go-Cae.ver.l +tableopts_ver_go-Cae.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Caef_ver_SOURCES = tableopts_ver_go-Caef.ver.l +tableopts_ver_go-Caef.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_CaexF_ver_SOURCES = tableopts_ver_go-CaexF.ver.l +tableopts_ver_go-CaexF.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Cam_ver_SOURCES = tableopts_ver_go-Cam.ver.l +tableopts_ver_go-Cam.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + +tableopts_ver_go_Caem_ver_SOURCES = tableopts_ver_go-Caem.ver.l +tableopts_ver_go-Caem.ver.l: $(srcdir)/tableopts.rules $(srcdir)/testmaker.sh $(srcdir)/testmaker.m4 + $(SHELL) $(srcdir)/testmaker.sh $@ + posixlycorrect_nr.c: posixlycorrect_nr.l $(FLEX) $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< @@ -666,8 +878,15 @@ test-yydecl-c99.sh$(EXEEXT): test-yydecl-gen.sh $(SHELL) test-yydecl-gen.sh c99 >test-yydecl-c99.sh$(EXEEXT) chmod a+x test-yydecl-c99.sh$(EXEEXT) +posixlycorrect_go.go: posixlycorrect_go.l $(FLEX) + $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $< + +test-yydecl-go.sh$(EXEEXT): test-yydecl-gen.sh + $(SHELL) test-yydecl-gen.sh go >test-yydecl-go.sh$(EXEEXT) + chmod a+x test-yydecl-go.sh$(EXEEXT) + # End generated test rules -RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr debug_nr extended_nr fixedtrailing_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr vartrailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r debug_r extended_r fixedtrailing_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r vartrailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 debug_c99 extended_c99 fixedtrailing_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 vartrailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh -RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array.txt basic_nr basic_nr.c basic_nr.l basic.txt bol_nr bol_nr.c bol_nr.l bol.txt ccl_nr ccl_nr.c ccl_nr.l ccl.txt debug_nr debug_nr.c debug_nr.l debug.txt extended_nr extended_nr.c extended_nr.l extended.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing.txt flexname_nr flexname_nr.c flexname_nr.l flexname.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat.txt lineno_nr lineno_nr.c lineno_nr.l lineno.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect.txt posix_nr posix_nr.c posix_nr.l posix.txt preposix_nr preposix_nr.c preposix_nr.l preposix.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment.txt reject_nr reject_nr.c reject_nr.l reject.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing.txt yyless_nr yyless_nr.c yyless_nr.l yyless.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray.txt yymore_nr yymore_nr.c yymore_nr.l yymore.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array.txt basic_r basic_r.c basic_r.l basic.txt bol_r bol_r.c bol_r.l bol.txt ccl_r ccl_r.c ccl_r.l ccl.txt debug_r debug_r.c debug_r.l debug.txt extended_r extended_r.c extended_r.l extended.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing.txt flexname_r flexname_r.c flexname_r.l flexname.txt lineno_r lineno_r.c lineno_r.l lineno.txt posix_r posix_r.c posix_r.l posix.txt preposix_r preposix_r.c preposix_r.l preposix.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment.txt reject_r reject_r.c reject_r.l reject.txt tableopts_r tableopts_r.c tableopts_r.l tableopts.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing.txt yyless_r yyless_r.c yyless_r.l yyless.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray.txt yymore_r yymore_r.c yymore_r.l yymore.txt yyunput_r yyunput_r.c yyunput_r.l yyunput.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array.txt basic_c99 basic_c99.c basic_c99.l basic.txt bol_c99 bol_c99.c bol_c99.l bol.txt ccl_c99 ccl_c99.c ccl_c99.l ccl.txt debug_c99 debug_c99.c debug_c99.l debug.txt extended_c99 extended_c99.c extended_c99.l extended.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing.txt flexname_c99 flexname_c99.c flexname_c99.l flexname.txt lineno_c99 lineno_c99.c lineno_c99.l lineno.txt posix_c99 posix_c99.c posix_c99.l posix.txt preposix_c99 preposix_c99.c preposix_c99.l preposix.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment.txt reject_c99 reject_c99.c reject_c99.l reject.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing.txt yyless_c99 yyless_c99.c yyless_c99.l yyless.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray.txt yymore_c99 yymore_c99.c yymore_c99.l yymore.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh +RULESET_TESTS = array_nr basic_nr bol_nr ccl_nr debug_nr extended_nr fixedtrailing_nr flexname_nr lexcompat_nr lineno_nr posixlycorrect_nr posix_nr preposix_nr quoteincomment_nr reject_nr tableopts_nr vartrailing_nr yyless_nr yymorearraybol_nr yymorearray_nr yymore_nr yyunput_nr tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ce.opt tableopts_opt_nr-Cf.opt tableopts_opt_nr-CxF.opt tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cae.opt tableopts_opt_nr-Caef.opt tableopts_opt_nr-CaexF.opt tableopts_opt_nr-Cam.opt tableopts_opt_nr-Caem.opt tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ce.ser tableopts_ser_nr-Cf.ser tableopts_ser_nr-CxF.ser tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cae.ser tableopts_ser_nr-Caef.ser tableopts_ser_nr-CaexF.ser tableopts_ser_nr-Cam.ser tableopts_ser_nr-Caem.ser tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ce.ver tableopts_ver_nr-Cf.ver tableopts_ver_nr-CxF.ver tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cae.ver tableopts_ver_nr-Caef.ver tableopts_ver_nr-CaexF.ver tableopts_ver_nr-Cam.ver tableopts_ver_nr-Caem.ver array_r basic_r bol_r ccl_r debug_r extended_r fixedtrailing_r flexname_r lineno_r posix_r preposix_r quoteincomment_r reject_r tableopts_r vartrailing_r yyless_r yymorearraybol_r yymorearray_r yymore_r yyunput_r tableopts_opt_r-Ca.opt tableopts_opt_r-Ce.opt tableopts_opt_r-Cf.opt tableopts_opt_r-CxF.opt tableopts_opt_r-Cm.opt tableopts_opt_r-Cem.opt tableopts_opt_r-Cae.opt tableopts_opt_r-Caef.opt tableopts_opt_r-CaexF.opt tableopts_opt_r-Cam.opt tableopts_opt_r-Caem.opt tableopts_ser_r-Ca.ser tableopts_ser_r-Ce.ser tableopts_ser_r-Cf.ser tableopts_ser_r-CxF.ser tableopts_ser_r-Cm.ser tableopts_ser_r-Cem.ser tableopts_ser_r-Cae.ser tableopts_ser_r-Caef.ser tableopts_ser_r-CaexF.ser tableopts_ser_r-Cam.ser tableopts_ser_r-Caem.ser tableopts_ver_r-Ca.ver tableopts_ver_r-Ce.ver tableopts_ver_r-Cf.ver tableopts_ver_r-CxF.ver tableopts_ver_r-Cm.ver tableopts_ver_r-Cem.ver tableopts_ver_r-Cae.ver tableopts_ver_r-Caef.ver tableopts_ver_r-CaexF.ver tableopts_ver_r-Cam.ver tableopts_ver_r-Caem.ver array_c99 basic_c99 bol_c99 ccl_c99 debug_c99 extended_c99 fixedtrailing_c99 flexname_c99 lineno_c99 posix_c99 preposix_c99 quoteincomment_c99 reject_c99 tableopts_c99 vartrailing_c99 yyless_c99 yymorearraybol_c99 yymorearray_c99 yymore_c99 yyunput_c99 tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ce.opt tableopts_opt_c99-Cf.opt tableopts_opt_c99-CxF.opt tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cae.opt tableopts_opt_c99-Caef.opt tableopts_opt_c99-CaexF.opt tableopts_opt_c99-Cam.opt tableopts_opt_c99-Caem.opt tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ce.ser tableopts_ser_c99-Cf.ser tableopts_ser_c99-CxF.ser tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cae.ser tableopts_ser_c99-Caef.ser tableopts_ser_c99-CaexF.ser tableopts_ser_c99-Cam.ser tableopts_ser_c99-Caem.ser tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ce.ver tableopts_ver_c99-Cf.ver tableopts_ver_c99-CxF.ver tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cae.ver tableopts_ver_c99-Caef.ver tableopts_ver_c99-CaexF.ver tableopts_ver_c99-Cam.ver tableopts_ver_c99-Caem.ver array_go basic_go bol_go ccl_go debug_go extended_go fixedtrailing_go flexname_go lineno_go posix_go preposix_go quoteincomment_go reject_go tableopts_go vartrailing_go yyless_go yymorearraybol_go yymorearray_go yymore_go yyunput_go tableopts_opt_go-Ca.opt tableopts_opt_go-Ce.opt tableopts_opt_go-Cf.opt tableopts_opt_go-CxF.opt tableopts_opt_go-Cm.opt tableopts_opt_go-Cem.opt tableopts_opt_go-Cae.opt tableopts_opt_go-Caef.opt tableopts_opt_go-CaexF.opt tableopts_opt_go-Cam.opt tableopts_opt_go-Caem.opt tableopts_ser_go-Ca.ser tableopts_ser_go-Ce.ser tableopts_ser_go-Cf.ser tableopts_ser_go-CxF.ser tableopts_ser_go-Cm.ser tableopts_ser_go-Cem.ser tableopts_ser_go-Cae.ser tableopts_ser_go-Caef.ser tableopts_ser_go-CaexF.ser tableopts_ser_go-Cam.ser tableopts_ser_go-Caem.ser tableopts_ver_go-Ca.ver tableopts_ver_go-Ce.ver tableopts_ver_go-Cf.ver tableopts_ver_go-CxF.ver tableopts_ver_go-Cm.ver tableopts_ver_go-Cem.ver tableopts_ver_go-Cae.ver tableopts_ver_go-Caef.ver tableopts_ver_go-CaexF.ver tableopts_ver_go-Cam.ver tableopts_ver_go-Caem.ver test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh test-yydecl-go.sh +RULESET_REMOVABLES = array_nr array_nr.c array_nr.l array.txt basic_nr basic_nr.c basic_nr.l basic.txt bol_nr bol_nr.c bol_nr.l bol.txt ccl_nr ccl_nr.c ccl_nr.l ccl.txt debug_nr debug_nr.c debug_nr.l debug.txt extended_nr extended_nr.c extended_nr.l extended.txt fixedtrailing_nr fixedtrailing_nr.c fixedtrailing_nr.l fixedtrailing.txt flexname_nr flexname_nr.c flexname_nr.l flexname.txt lexcompat_nr lexcompat_nr.c lexcompat_nr.l lexcompat.txt lineno_nr lineno_nr.c lineno_nr.l lineno.txt posixlycorrect_nr posixlycorrect_nr.c posixlycorrect_nr.l posixlycorrect.txt posix_nr posix_nr.c posix_nr.l posix.txt preposix_nr preposix_nr.c preposix_nr.l preposix.txt quoteincomment_nr quoteincomment_nr.c quoteincomment_nr.l quoteincomment.txt reject_nr reject_nr.c reject_nr.l reject.txt tableopts_nr tableopts_nr.c tableopts_nr.l tableopts.txt vartrailing_nr vartrailing_nr.c vartrailing_nr.l vartrailing.txt yyless_nr yyless_nr.c yyless_nr.l yyless.txt yymorearraybol_nr yymorearraybol_nr.c yymorearraybol_nr.l yymorearraybol.txt yymorearray_nr yymorearray_nr.c yymorearray_nr.l yymorearray.txt yymore_nr yymore_nr.c yymore_nr.l yymore.txt yyunput_nr yyunput_nr.c yyunput_nr.l yyunput.txt tableopts_opt_nr-Ca.opt tableopts_opt_nr-Ca.opt.c tableopts_opt_nr-Ca.opt.l tableopts_opt_nr-Ca.opt.tables tableopts_opt_nr-Ce.opt tableopts_opt_nr-Ce.opt.c tableopts_opt_nr-Ce.opt.l tableopts_opt_nr-Ce.opt.tables tableopts_opt_nr-Cf.opt tableopts_opt_nr-Cf.opt.c tableopts_opt_nr-Cf.opt.l tableopts_opt_nr-Cf.opt.tables tableopts_opt_nr-CxF.opt tableopts_opt_nr-CxF.opt.c tableopts_opt_nr-CxF.opt.l tableopts_opt_nr-CxF.opt.tables tableopts_opt_nr-Cm.opt tableopts_opt_nr-Cm.opt.c tableopts_opt_nr-Cm.opt.l tableopts_opt_nr-Cm.opt.tables tableopts_opt_nr-Cem.opt tableopts_opt_nr-Cem.opt.c tableopts_opt_nr-Cem.opt.l tableopts_opt_nr-Cem.opt.tables tableopts_opt_nr-Cae.opt tableopts_opt_nr-Cae.opt.c tableopts_opt_nr-Cae.opt.l tableopts_opt_nr-Cae.opt.tables tableopts_opt_nr-Caef.opt tableopts_opt_nr-Caef.opt.c tableopts_opt_nr-Caef.opt.l tableopts_opt_nr-Caef.opt.tables tableopts_opt_nr-CaexF.opt tableopts_opt_nr-CaexF.opt.c tableopts_opt_nr-CaexF.opt.l tableopts_opt_nr-CaexF.opt.tables tableopts_opt_nr-Cam.opt tableopts_opt_nr-Cam.opt.c tableopts_opt_nr-Cam.opt.l tableopts_opt_nr-Cam.opt.tables tableopts_opt_nr-Caem.opt tableopts_opt_nr-Caem.opt.c tableopts_opt_nr-Caem.opt.l tableopts_opt_nr-Caem.opt.tables tableopts_ser_nr-Ca.ser tableopts_ser_nr-Ca.ser.c tableopts_ser_nr-Ca.ser.l tableopts_ser_nr-Ca.ser.tables tableopts_ser_nr-Ce.ser tableopts_ser_nr-Ce.ser.c tableopts_ser_nr-Ce.ser.l tableopts_ser_nr-Ce.ser.tables tableopts_ser_nr-Cf.ser tableopts_ser_nr-Cf.ser.c tableopts_ser_nr-Cf.ser.l tableopts_ser_nr-Cf.ser.tables tableopts_ser_nr-CxF.ser tableopts_ser_nr-CxF.ser.c tableopts_ser_nr-CxF.ser.l tableopts_ser_nr-CxF.ser.tables tableopts_ser_nr-Cm.ser tableopts_ser_nr-Cm.ser.c tableopts_ser_nr-Cm.ser.l tableopts_ser_nr-Cm.ser.tables tableopts_ser_nr-Cem.ser tableopts_ser_nr-Cem.ser.c tableopts_ser_nr-Cem.ser.l tableopts_ser_nr-Cem.ser.tables tableopts_ser_nr-Cae.ser tableopts_ser_nr-Cae.ser.c tableopts_ser_nr-Cae.ser.l tableopts_ser_nr-Cae.ser.tables tableopts_ser_nr-Caef.ser tableopts_ser_nr-Caef.ser.c tableopts_ser_nr-Caef.ser.l tableopts_ser_nr-Caef.ser.tables tableopts_ser_nr-CaexF.ser tableopts_ser_nr-CaexF.ser.c tableopts_ser_nr-CaexF.ser.l tableopts_ser_nr-CaexF.ser.tables tableopts_ser_nr-Cam.ser tableopts_ser_nr-Cam.ser.c tableopts_ser_nr-Cam.ser.l tableopts_ser_nr-Cam.ser.tables tableopts_ser_nr-Caem.ser tableopts_ser_nr-Caem.ser.c tableopts_ser_nr-Caem.ser.l tableopts_ser_nr-Caem.ser.tables tableopts_ver_nr-Ca.ver tableopts_ver_nr-Ca.ver.c tableopts_ver_nr-Ca.ver.l tableopts_ver_nr-Ca.ver.tables tableopts_ver_nr-Ce.ver tableopts_ver_nr-Ce.ver.c tableopts_ver_nr-Ce.ver.l tableopts_ver_nr-Ce.ver.tables tableopts_ver_nr-Cf.ver tableopts_ver_nr-Cf.ver.c tableopts_ver_nr-Cf.ver.l tableopts_ver_nr-Cf.ver.tables tableopts_ver_nr-CxF.ver tableopts_ver_nr-CxF.ver.c tableopts_ver_nr-CxF.ver.l tableopts_ver_nr-CxF.ver.tables tableopts_ver_nr-Cm.ver tableopts_ver_nr-Cm.ver.c tableopts_ver_nr-Cm.ver.l tableopts_ver_nr-Cm.ver.tables tableopts_ver_nr-Cem.ver tableopts_ver_nr-Cem.ver.c tableopts_ver_nr-Cem.ver.l tableopts_ver_nr-Cem.ver.tables tableopts_ver_nr-Cae.ver tableopts_ver_nr-Cae.ver.c tableopts_ver_nr-Cae.ver.l tableopts_ver_nr-Cae.ver.tables tableopts_ver_nr-Caef.ver tableopts_ver_nr-Caef.ver.c tableopts_ver_nr-Caef.ver.l tableopts_ver_nr-Caef.ver.tables tableopts_ver_nr-CaexF.ver tableopts_ver_nr-CaexF.ver.c tableopts_ver_nr-CaexF.ver.l tableopts_ver_nr-CaexF.ver.tables tableopts_ver_nr-Cam.ver tableopts_ver_nr-Cam.ver.c tableopts_ver_nr-Cam.ver.l tableopts_ver_nr-Cam.ver.tables tableopts_ver_nr-Caem.ver tableopts_ver_nr-Caem.ver.c tableopts_ver_nr-Caem.ver.l tableopts_ver_nr-Caem.ver.tables array_r array_r.c array_r.l array.txt basic_r basic_r.c basic_r.l basic.txt bol_r bol_r.c bol_r.l bol.txt ccl_r ccl_r.c ccl_r.l ccl.txt debug_r debug_r.c debug_r.l debug.txt extended_r extended_r.c extended_r.l extended.txt fixedtrailing_r fixedtrailing_r.c fixedtrailing_r.l fixedtrailing.txt flexname_r flexname_r.c flexname_r.l flexname.txt lineno_r lineno_r.c lineno_r.l lineno.txt posix_r posix_r.c posix_r.l posix.txt preposix_r preposix_r.c preposix_r.l preposix.txt quoteincomment_r quoteincomment_r.c quoteincomment_r.l quoteincomment.txt reject_r reject_r.c reject_r.l reject.txt tableopts_r tableopts_r.c tableopts_r.l tableopts.txt vartrailing_r vartrailing_r.c vartrailing_r.l vartrailing.txt yyless_r yyless_r.c yyless_r.l yyless.txt yymorearraybol_r yymorearraybol_r.c yymorearraybol_r.l yymorearraybol.txt yymorearray_r yymorearray_r.c yymorearray_r.l yymorearray.txt yymore_r yymore_r.c yymore_r.l yymore.txt yyunput_r yyunput_r.c yyunput_r.l yyunput.txt tableopts_opt_r-Ca.opt tableopts_opt_r-Ca.opt.c tableopts_opt_r-Ca.opt.l tableopts_opt_r-Ca.opt.tables tableopts_opt_r-Ce.opt tableopts_opt_r-Ce.opt.c tableopts_opt_r-Ce.opt.l tableopts_opt_r-Ce.opt.tables tableopts_opt_r-Cf.opt tableopts_opt_r-Cf.opt.c tableopts_opt_r-Cf.opt.l tableopts_opt_r-Cf.opt.tables tableopts_opt_r-CxF.opt tableopts_opt_r-CxF.opt.c tableopts_opt_r-CxF.opt.l tableopts_opt_r-CxF.opt.tables tableopts_opt_r-Cm.opt tableopts_opt_r-Cm.opt.c tableopts_opt_r-Cm.opt.l tableopts_opt_r-Cm.opt.tables tableopts_opt_r-Cem.opt tableopts_opt_r-Cem.opt.c tableopts_opt_r-Cem.opt.l tableopts_opt_r-Cem.opt.tables tableopts_opt_r-Cae.opt tableopts_opt_r-Cae.opt.c tableopts_opt_r-Cae.opt.l tableopts_opt_r-Cae.opt.tables tableopts_opt_r-Caef.opt tableopts_opt_r-Caef.opt.c tableopts_opt_r-Caef.opt.l tableopts_opt_r-Caef.opt.tables tableopts_opt_r-CaexF.opt tableopts_opt_r-CaexF.opt.c tableopts_opt_r-CaexF.opt.l tableopts_opt_r-CaexF.opt.tables tableopts_opt_r-Cam.opt tableopts_opt_r-Cam.opt.c tableopts_opt_r-Cam.opt.l tableopts_opt_r-Cam.opt.tables tableopts_opt_r-Caem.opt tableopts_opt_r-Caem.opt.c tableopts_opt_r-Caem.opt.l tableopts_opt_r-Caem.opt.tables tableopts_ser_r-Ca.ser tableopts_ser_r-Ca.ser.c tableopts_ser_r-Ca.ser.l tableopts_ser_r-Ca.ser.tables tableopts_ser_r-Ce.ser tableopts_ser_r-Ce.ser.c tableopts_ser_r-Ce.ser.l tableopts_ser_r-Ce.ser.tables tableopts_ser_r-Cf.ser tableopts_ser_r-Cf.ser.c tableopts_ser_r-Cf.ser.l tableopts_ser_r-Cf.ser.tables tableopts_ser_r-CxF.ser tableopts_ser_r-CxF.ser.c tableopts_ser_r-CxF.ser.l tableopts_ser_r-CxF.ser.tables tableopts_ser_r-Cm.ser tableopts_ser_r-Cm.ser.c tableopts_ser_r-Cm.ser.l tableopts_ser_r-Cm.ser.tables tableopts_ser_r-Cem.ser tableopts_ser_r-Cem.ser.c tableopts_ser_r-Cem.ser.l tableopts_ser_r-Cem.ser.tables tableopts_ser_r-Cae.ser tableopts_ser_r-Cae.ser.c tableopts_ser_r-Cae.ser.l tableopts_ser_r-Cae.ser.tables tableopts_ser_r-Caef.ser tableopts_ser_r-Caef.ser.c tableopts_ser_r-Caef.ser.l tableopts_ser_r-Caef.ser.tables tableopts_ser_r-CaexF.ser tableopts_ser_r-CaexF.ser.c tableopts_ser_r-CaexF.ser.l tableopts_ser_r-CaexF.ser.tables tableopts_ser_r-Cam.ser tableopts_ser_r-Cam.ser.c tableopts_ser_r-Cam.ser.l tableopts_ser_r-Cam.ser.tables tableopts_ser_r-Caem.ser tableopts_ser_r-Caem.ser.c tableopts_ser_r-Caem.ser.l tableopts_ser_r-Caem.ser.tables tableopts_ver_r-Ca.ver tableopts_ver_r-Ca.ver.c tableopts_ver_r-Ca.ver.l tableopts_ver_r-Ca.ver.tables tableopts_ver_r-Ce.ver tableopts_ver_r-Ce.ver.c tableopts_ver_r-Ce.ver.l tableopts_ver_r-Ce.ver.tables tableopts_ver_r-Cf.ver tableopts_ver_r-Cf.ver.c tableopts_ver_r-Cf.ver.l tableopts_ver_r-Cf.ver.tables tableopts_ver_r-CxF.ver tableopts_ver_r-CxF.ver.c tableopts_ver_r-CxF.ver.l tableopts_ver_r-CxF.ver.tables tableopts_ver_r-Cm.ver tableopts_ver_r-Cm.ver.c tableopts_ver_r-Cm.ver.l tableopts_ver_r-Cm.ver.tables tableopts_ver_r-Cem.ver tableopts_ver_r-Cem.ver.c tableopts_ver_r-Cem.ver.l tableopts_ver_r-Cem.ver.tables tableopts_ver_r-Cae.ver tableopts_ver_r-Cae.ver.c tableopts_ver_r-Cae.ver.l tableopts_ver_r-Cae.ver.tables tableopts_ver_r-Caef.ver tableopts_ver_r-Caef.ver.c tableopts_ver_r-Caef.ver.l tableopts_ver_r-Caef.ver.tables tableopts_ver_r-CaexF.ver tableopts_ver_r-CaexF.ver.c tableopts_ver_r-CaexF.ver.l tableopts_ver_r-CaexF.ver.tables tableopts_ver_r-Cam.ver tableopts_ver_r-Cam.ver.c tableopts_ver_r-Cam.ver.l tableopts_ver_r-Cam.ver.tables tableopts_ver_r-Caem.ver tableopts_ver_r-Caem.ver.c tableopts_ver_r-Caem.ver.l tableopts_ver_r-Caem.ver.tables array_c99 array_c99.c array_c99.l array.txt basic_c99 basic_c99.c basic_c99.l basic.txt bol_c99 bol_c99.c bol_c99.l bol.txt ccl_c99 ccl_c99.c ccl_c99.l ccl.txt debug_c99 debug_c99.c debug_c99.l debug.txt extended_c99 extended_c99.c extended_c99.l extended.txt fixedtrailing_c99 fixedtrailing_c99.c fixedtrailing_c99.l fixedtrailing.txt flexname_c99 flexname_c99.c flexname_c99.l flexname.txt lineno_c99 lineno_c99.c lineno_c99.l lineno.txt posix_c99 posix_c99.c posix_c99.l posix.txt preposix_c99 preposix_c99.c preposix_c99.l preposix.txt quoteincomment_c99 quoteincomment_c99.c quoteincomment_c99.l quoteincomment.txt reject_c99 reject_c99.c reject_c99.l reject.txt tableopts_c99 tableopts_c99.c tableopts_c99.l tableopts.txt vartrailing_c99 vartrailing_c99.c vartrailing_c99.l vartrailing.txt yyless_c99 yyless_c99.c yyless_c99.l yyless.txt yymorearraybol_c99 yymorearraybol_c99.c yymorearraybol_c99.l yymorearraybol.txt yymorearray_c99 yymorearray_c99.c yymorearray_c99.l yymorearray.txt yymore_c99 yymore_c99.c yymore_c99.l yymore.txt yyunput_c99 yyunput_c99.c yyunput_c99.l yyunput.txt tableopts_opt_c99-Ca.opt tableopts_opt_c99-Ca.opt.c tableopts_opt_c99-Ca.opt.l tableopts_opt_c99-Ca.opt.tables tableopts_opt_c99-Ce.opt tableopts_opt_c99-Ce.opt.c tableopts_opt_c99-Ce.opt.l tableopts_opt_c99-Ce.opt.tables tableopts_opt_c99-Cf.opt tableopts_opt_c99-Cf.opt.c tableopts_opt_c99-Cf.opt.l tableopts_opt_c99-Cf.opt.tables tableopts_opt_c99-CxF.opt tableopts_opt_c99-CxF.opt.c tableopts_opt_c99-CxF.opt.l tableopts_opt_c99-CxF.opt.tables tableopts_opt_c99-Cm.opt tableopts_opt_c99-Cm.opt.c tableopts_opt_c99-Cm.opt.l tableopts_opt_c99-Cm.opt.tables tableopts_opt_c99-Cem.opt tableopts_opt_c99-Cem.opt.c tableopts_opt_c99-Cem.opt.l tableopts_opt_c99-Cem.opt.tables tableopts_opt_c99-Cae.opt tableopts_opt_c99-Cae.opt.c tableopts_opt_c99-Cae.opt.l tableopts_opt_c99-Cae.opt.tables tableopts_opt_c99-Caef.opt tableopts_opt_c99-Caef.opt.c tableopts_opt_c99-Caef.opt.l tableopts_opt_c99-Caef.opt.tables tableopts_opt_c99-CaexF.opt tableopts_opt_c99-CaexF.opt.c tableopts_opt_c99-CaexF.opt.l tableopts_opt_c99-CaexF.opt.tables tableopts_opt_c99-Cam.opt tableopts_opt_c99-Cam.opt.c tableopts_opt_c99-Cam.opt.l tableopts_opt_c99-Cam.opt.tables tableopts_opt_c99-Caem.opt tableopts_opt_c99-Caem.opt.c tableopts_opt_c99-Caem.opt.l tableopts_opt_c99-Caem.opt.tables tableopts_ser_c99-Ca.ser tableopts_ser_c99-Ca.ser.c tableopts_ser_c99-Ca.ser.l tableopts_ser_c99-Ca.ser.tables tableopts_ser_c99-Ce.ser tableopts_ser_c99-Ce.ser.c tableopts_ser_c99-Ce.ser.l tableopts_ser_c99-Ce.ser.tables tableopts_ser_c99-Cf.ser tableopts_ser_c99-Cf.ser.c tableopts_ser_c99-Cf.ser.l tableopts_ser_c99-Cf.ser.tables tableopts_ser_c99-CxF.ser tableopts_ser_c99-CxF.ser.c tableopts_ser_c99-CxF.ser.l tableopts_ser_c99-CxF.ser.tables tableopts_ser_c99-Cm.ser tableopts_ser_c99-Cm.ser.c tableopts_ser_c99-Cm.ser.l tableopts_ser_c99-Cm.ser.tables tableopts_ser_c99-Cem.ser tableopts_ser_c99-Cem.ser.c tableopts_ser_c99-Cem.ser.l tableopts_ser_c99-Cem.ser.tables tableopts_ser_c99-Cae.ser tableopts_ser_c99-Cae.ser.c tableopts_ser_c99-Cae.ser.l tableopts_ser_c99-Cae.ser.tables tableopts_ser_c99-Caef.ser tableopts_ser_c99-Caef.ser.c tableopts_ser_c99-Caef.ser.l tableopts_ser_c99-Caef.ser.tables tableopts_ser_c99-CaexF.ser tableopts_ser_c99-CaexF.ser.c tableopts_ser_c99-CaexF.ser.l tableopts_ser_c99-CaexF.ser.tables tableopts_ser_c99-Cam.ser tableopts_ser_c99-Cam.ser.c tableopts_ser_c99-Cam.ser.l tableopts_ser_c99-Cam.ser.tables tableopts_ser_c99-Caem.ser tableopts_ser_c99-Caem.ser.c tableopts_ser_c99-Caem.ser.l tableopts_ser_c99-Caem.ser.tables tableopts_ver_c99-Ca.ver tableopts_ver_c99-Ca.ver.c tableopts_ver_c99-Ca.ver.l tableopts_ver_c99-Ca.ver.tables tableopts_ver_c99-Ce.ver tableopts_ver_c99-Ce.ver.c tableopts_ver_c99-Ce.ver.l tableopts_ver_c99-Ce.ver.tables tableopts_ver_c99-Cf.ver tableopts_ver_c99-Cf.ver.c tableopts_ver_c99-Cf.ver.l tableopts_ver_c99-Cf.ver.tables tableopts_ver_c99-CxF.ver tableopts_ver_c99-CxF.ver.c tableopts_ver_c99-CxF.ver.l tableopts_ver_c99-CxF.ver.tables tableopts_ver_c99-Cm.ver tableopts_ver_c99-Cm.ver.c tableopts_ver_c99-Cm.ver.l tableopts_ver_c99-Cm.ver.tables tableopts_ver_c99-Cem.ver tableopts_ver_c99-Cem.ver.c tableopts_ver_c99-Cem.ver.l tableopts_ver_c99-Cem.ver.tables tableopts_ver_c99-Cae.ver tableopts_ver_c99-Cae.ver.c tableopts_ver_c99-Cae.ver.l tableopts_ver_c99-Cae.ver.tables tableopts_ver_c99-Caef.ver tableopts_ver_c99-Caef.ver.c tableopts_ver_c99-Caef.ver.l tableopts_ver_c99-Caef.ver.tables tableopts_ver_c99-CaexF.ver tableopts_ver_c99-CaexF.ver.c tableopts_ver_c99-CaexF.ver.l tableopts_ver_c99-CaexF.ver.tables tableopts_ver_c99-Cam.ver tableopts_ver_c99-Cam.ver.c tableopts_ver_c99-Cam.ver.l tableopts_ver_c99-Cam.ver.tables tableopts_ver_c99-Caem.ver tableopts_ver_c99-Caem.ver.c tableopts_ver_c99-Caem.ver.l tableopts_ver_c99-Caem.ver.tables array_go array_go.c array_go.l array.txt basic_go basic_go.c basic_go.l basic.txt bol_go bol_go.c bol_go.l bol.txt ccl_go ccl_go.c ccl_go.l ccl.txt debug_go debug_go.c debug_go.l debug.txt extended_go extended_go.c extended_go.l extended.txt fixedtrailing_go fixedtrailing_go.c fixedtrailing_go.l fixedtrailing.txt flexname_go flexname_go.c flexname_go.l flexname.txt lineno_go lineno_go.c lineno_go.l lineno.txt posix_go posix_go.c posix_go.l posix.txt preposix_go preposix_go.c preposix_go.l preposix.txt quoteincomment_go quoteincomment_go.c quoteincomment_go.l quoteincomment.txt reject_go reject_go.c reject_go.l reject.txt tableopts_go tableopts_go.c tableopts_go.l tableopts.txt vartrailing_go vartrailing_go.c vartrailing_go.l vartrailing.txt yyless_go yyless_go.c yyless_go.l yyless.txt yymorearraybol_go yymorearraybol_go.c yymorearraybol_go.l yymorearraybol.txt yymorearray_go yymorearray_go.c yymorearray_go.l yymorearray.txt yymore_go yymore_go.c yymore_go.l yymore.txt yyunput_go yyunput_go.c yyunput_go.l yyunput.txt tableopts_opt_go-Ca.opt tableopts_opt_go-Ca.opt.c tableopts_opt_go-Ca.opt.l tableopts_opt_go-Ca.opt.tables tableopts_opt_go-Ce.opt tableopts_opt_go-Ce.opt.c tableopts_opt_go-Ce.opt.l tableopts_opt_go-Ce.opt.tables tableopts_opt_go-Cf.opt tableopts_opt_go-Cf.opt.c tableopts_opt_go-Cf.opt.l tableopts_opt_go-Cf.opt.tables tableopts_opt_go-CxF.opt tableopts_opt_go-CxF.opt.c tableopts_opt_go-CxF.opt.l tableopts_opt_go-CxF.opt.tables tableopts_opt_go-Cm.opt tableopts_opt_go-Cm.opt.c tableopts_opt_go-Cm.opt.l tableopts_opt_go-Cm.opt.tables tableopts_opt_go-Cem.opt tableopts_opt_go-Cem.opt.c tableopts_opt_go-Cem.opt.l tableopts_opt_go-Cem.opt.tables tableopts_opt_go-Cae.opt tableopts_opt_go-Cae.opt.c tableopts_opt_go-Cae.opt.l tableopts_opt_go-Cae.opt.tables tableopts_opt_go-Caef.opt tableopts_opt_go-Caef.opt.c tableopts_opt_go-Caef.opt.l tableopts_opt_go-Caef.opt.tables tableopts_opt_go-CaexF.opt tableopts_opt_go-CaexF.opt.c tableopts_opt_go-CaexF.opt.l tableopts_opt_go-CaexF.opt.tables tableopts_opt_go-Cam.opt tableopts_opt_go-Cam.opt.c tableopts_opt_go-Cam.opt.l tableopts_opt_go-Cam.opt.tables tableopts_opt_go-Caem.opt tableopts_opt_go-Caem.opt.c tableopts_opt_go-Caem.opt.l tableopts_opt_go-Caem.opt.tables tableopts_ser_go-Ca.ser tableopts_ser_go-Ca.ser.c tableopts_ser_go-Ca.ser.l tableopts_ser_go-Ca.ser.tables tableopts_ser_go-Ce.ser tableopts_ser_go-Ce.ser.c tableopts_ser_go-Ce.ser.l tableopts_ser_go-Ce.ser.tables tableopts_ser_go-Cf.ser tableopts_ser_go-Cf.ser.c tableopts_ser_go-Cf.ser.l tableopts_ser_go-Cf.ser.tables tableopts_ser_go-CxF.ser tableopts_ser_go-CxF.ser.c tableopts_ser_go-CxF.ser.l tableopts_ser_go-CxF.ser.tables tableopts_ser_go-Cm.ser tableopts_ser_go-Cm.ser.c tableopts_ser_go-Cm.ser.l tableopts_ser_go-Cm.ser.tables tableopts_ser_go-Cem.ser tableopts_ser_go-Cem.ser.c tableopts_ser_go-Cem.ser.l tableopts_ser_go-Cem.ser.tables tableopts_ser_go-Cae.ser tableopts_ser_go-Cae.ser.c tableopts_ser_go-Cae.ser.l tableopts_ser_go-Cae.ser.tables tableopts_ser_go-Caef.ser tableopts_ser_go-Caef.ser.c tableopts_ser_go-Caef.ser.l tableopts_ser_go-Caef.ser.tables tableopts_ser_go-CaexF.ser tableopts_ser_go-CaexF.ser.c tableopts_ser_go-CaexF.ser.l tableopts_ser_go-CaexF.ser.tables tableopts_ser_go-Cam.ser tableopts_ser_go-Cam.ser.c tableopts_ser_go-Cam.ser.l tableopts_ser_go-Cam.ser.tables tableopts_ser_go-Caem.ser tableopts_ser_go-Caem.ser.c tableopts_ser_go-Caem.ser.l tableopts_ser_go-Caem.ser.tables tableopts_ver_go-Ca.ver tableopts_ver_go-Ca.ver.c tableopts_ver_go-Ca.ver.l tableopts_ver_go-Ca.ver.tables tableopts_ver_go-Ce.ver tableopts_ver_go-Ce.ver.c tableopts_ver_go-Ce.ver.l tableopts_ver_go-Ce.ver.tables tableopts_ver_go-Cf.ver tableopts_ver_go-Cf.ver.c tableopts_ver_go-Cf.ver.l tableopts_ver_go-Cf.ver.tables tableopts_ver_go-CxF.ver tableopts_ver_go-CxF.ver.c tableopts_ver_go-CxF.ver.l tableopts_ver_go-CxF.ver.tables tableopts_ver_go-Cm.ver tableopts_ver_go-Cm.ver.c tableopts_ver_go-Cm.ver.l tableopts_ver_go-Cm.ver.tables tableopts_ver_go-Cem.ver tableopts_ver_go-Cem.ver.c tableopts_ver_go-Cem.ver.l tableopts_ver_go-Cem.ver.tables tableopts_ver_go-Cae.ver tableopts_ver_go-Cae.ver.c tableopts_ver_go-Cae.ver.l tableopts_ver_go-Cae.ver.tables tableopts_ver_go-Caef.ver tableopts_ver_go-Caef.ver.c tableopts_ver_go-Caef.ver.l tableopts_ver_go-Caef.ver.tables tableopts_ver_go-CaexF.ver tableopts_ver_go-CaexF.ver.c tableopts_ver_go-CaexF.ver.l tableopts_ver_go-CaexF.ver.tables tableopts_ver_go-Cam.ver tableopts_ver_go-Cam.ver.c tableopts_ver_go-Cam.ver.l tableopts_ver_go-Cam.ver.tables tableopts_ver_go-Caem.ver tableopts_ver_go-Caem.ver.c tableopts_ver_go-Caem.ver.l tableopts_ver_go-Caem.ver.tables test-yydecl-nr.sh test-yydecl-r.sh test-yydecl-c99.sh test-yydecl-go.sh diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 573dc71..c616cb7 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -123,6 +123,38 @@ ifdef(`M4_TEST_TABLE_SERIALIZATION', `dnl ')dnl close postamble ')dnl close r dnl +dnl This is a fake Go wrapper that will only work as long as the "go" +dnl back end is actually generating C. +ifelse(M4_TEST_BACKEND, `go', `dnl +define(`M4_TEST_PREAMBLE', `dnl +%{ +#include "config.h" +#include +%} +%option emit="go" +')dnl close preamble +define(`M4_TEST_DO', `$1;') +define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') +define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') +m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_debug(lexer), lexer);')') +define(`M4_TEST_POSTAMBLE', `dnl +int main (int argc, char **argv) +{ + yyscan_t lexer; + yylex_init( &lexer ); + yyset_out ( stdout,lexer); + yyset_in ( stdin, lexer); + M4_TEST_INITHOOK + while( yylex(lexer) != YY_NULL ) + { + } + yylex_destroy( lexer ); + printf("TEST RETURNING OK.\n"); + return 0; +} +')dnl close postamble +')dnl close fake-go +dnl dnl A hypothetical example ifelse(M4_TEST_BACKEND, `hypothetical-go', `dnl define(`M4_TEST_PREAMBLE', `dnl diff --git a/tests/testmaker.sh b/tests/testmaker.sh index 52dfdec..2fe5478 100644 --- a/tests/testmaker.sh +++ b/tests/testmaker.sh @@ -43,7 +43,7 @@ for part in "$@"; do case ${part} in nr) backend=nr; ;; r) backend=r; options="${options} reentrant";; - c99) backend=${part}; options="${options} emit=\"${part}\"" ;; # Add new back ends on this line + c99|go) backend=${part}; options="${options} emit=\"${part}\"" ;; # Add new back ends on this line ser) serialization=yes ;; ver) serialization=yes; verification=yes; options="${options} tables-verify" ;; Ca) options="${options} align" ;; -- cgit v1.2.1 From 866e31dafd017755fe3e7fcf59e8a89a1accb4df Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 18 Nov 2020 00:02:04 -0500 Subject: Go back end: Change the prefix option to set Go package name... ...presebtly commented out. All tests pass. --- src/c99-flex.skl | 8 ++++-- src/go-flex.skl | 85 ++++++-------------------------------------------------- src/skeletons.c | 4 +++ 3 files changed, 18 insertions(+), 79 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index fdfa3e2..6fffe3b 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -85,7 +85,7 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) -/* Return all but the first "n" matched characters back to the input stream. */ +%# Return all but the first "n" matched characters back to the input stream. m4_define([[yyless]], [[ do { /* Undo effects of setting up yytext. */ @@ -123,9 +123,11 @@ const int YY_FLEX_SUBMINOR_VERSION = FLEX_SUBMINOR_VERSION; %# The complexity here is necessary so that m4 preserves %# the argument lists to each C function. %# -%# If your target language has OO you can generare a class definition, +%# If your target language has OO you can generate a class definition, %# use option yyclass to pass in the class name, and drop prefix support. - +%# In languages like Go with a coincept of package names the prefix option +%# should be used for setting that. + m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) m4preproc_define(`M4_GEN_PREFIX',`` diff --git a/src/go-flex.skl b/src/go-flex.skl index 3ef0229..c428786 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -4,6 +4,10 @@ %# a .go extension but generating C code. Its purpose is to verify build and test be %# before actually trying to generate Go. %# +%# Differences from C: +%# +%# 1. The prefix property doesn't set a prefix for function and variable names. +%# Instead it sets the Go package name. %# Macros for preproc stage. m4preproc_changecom @@ -21,6 +25,7 @@ m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) m4_define([[M4_PROPERTY_CONTEXT_FORMAT]], [[yyscanner->%s_r]]) m4_define([[M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT]], [[yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_%s]]) +m4_define([[M4_PROPERTY_PREFIX]], [main]]) %# Macro hooks used by Flex code generators start here m4_define([[M4_HOOK_INT32]], [[int32_t]]) @@ -71,7 +76,7 @@ m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) -/* Return all but the first "n" matched characters back to the input stream. */ +%# Return all but the first "n" matched characters back to the input stream. m4_define([[yyless]], [[ do { /* Undo effects of setting up yytext. */ @@ -100,84 +105,12 @@ m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ %% [0.0] Make hook macros available to Flex +// package M4_MODE_PREFIX + const int YY_FLEX_MAJOR_VERSION = FLEX_MAJOR_VERSION; const int YY_FLEX_MINOR_VERSION = FLEX_MINOR_VERSION; const int YY_FLEX_SUBMINOR_VERSION = FLEX_SUBMINOR_VERSION; -%# STARTS prefix machinery -%# -%# The complexity here is necessary so that m4 preserves -%# the argument lists to each C function. -%# -%# If your target language has OO you can generare a class definition, -%# use option yyclass to pass in the class name, and drop prefix support. - -m4_ifdef( [[M4_MODE_PREFIX]],, [[m4_define([[M4_MODE_PREFIX]], [[yy]])]]) - -m4preproc_define(`M4_GEN_PREFIX',`` -[[#ifdef yy$1 -#define ]]M4_MODE_PREFIX[[$1_ALREADY_DEFINED -#else -#define yy$1 ]]M4_MODE_PREFIX[[$1 -#endif]] -'') - -m4_ifelse(M4_MODE_PREFIX,yy,, - M4_GEN_PREFIX(`_create_buffer') - M4_GEN_PREFIX(`_delete_buffer') - M4_GEN_PREFIX(`_scan_buffer') - M4_GEN_PREFIX(`_scan_string') - M4_GEN_PREFIX(`_scan_bytes') - M4_GEN_PREFIX(`_init_buffer') - M4_GEN_PREFIX(`_flush_buffer') - M4_GEN_PREFIX(`_load_buffer_state') - M4_GEN_PREFIX(`_switch_to_buffer') - M4_GEN_PREFIX(`push_buffer_state') - M4_GEN_PREFIX(`pop_buffer_state') - M4_GEN_PREFIX(`ensure_buffer_stack') - M4_GEN_PREFIX(`lex') - M4_GEN_PREFIX(`restart') - M4_GEN_PREFIX(`lex_init') - M4_GEN_PREFIX(`lex_init_extra') - M4_GEN_PREFIX(`lex_destroy') - M4_GEN_PREFIX(`get_debug') - M4_GEN_PREFIX(`set_debug') - M4_GEN_PREFIX(`get_extra') - M4_GEN_PREFIX(`set_extra') - M4_GEN_PREFIX(`get_in') - M4_GEN_PREFIX(`set_in') - M4_GEN_PREFIX(`get_out') - M4_GEN_PREFIX(`set_out') - M4_GEN_PREFIX(`get_leng') - M4_GEN_PREFIX(`get_text') - M4_GEN_PREFIX(`get_lineno') - M4_GEN_PREFIX(`set_lineno') - M4_GEN_PREFIX(`get_column') - M4_GEN_PREFIX(`set_column') - M4_GEN_PREFIX(`wrap') -) - -m4_ifdef( [[M4_YY_BISON_LVAL]], -[[ - M4_GEN_PREFIX(`get_lval') - M4_GEN_PREFIX(`set_lval') -]]) - -m4_ifdef( [[]], -[[ - M4_GEN_PREFIX(`get_lloc') - M4_GEN_PREFIX(`set_lloc') -]]) - - -m4_ifelse(M4_MODE_PREFIX,yy,, - M4_GEN_PREFIX(`alloc') - M4_GEN_PREFIX(`realloc') - M4_GEN_PREFIX(`free') -) - -%# ENDS prefix machinery - /* STARTS platform-specific and compiler-specific definitions. */ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , @@ -333,7 +266,7 @@ void yyfree ( void *, yyscan_t yyscanner ); /* Begin user sect3 */ m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ -int M4_MODE_PREFIX[[wrap]](yyscan_t yyscanner) { +int yywrap(yyscan_t yyscanner) { return /*CONSTCOND*/1; } ]]) diff --git a/src/skeletons.c b/src/skeletons.c index ea6bf42..63d07c1 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -97,6 +97,7 @@ static bool boneseeker(const char *bone) void backend_by_name(const char *name) { + char *prefix_property; if (name != NULL) { if (strcmp(name, "nr") == 0) { backend = &backends[0]; @@ -120,6 +121,9 @@ void backend_by_name(const char *name) ctrl.traceline_re = xstrdup(skel_property("M4_PROPERTY_TRACE_LINE_REGEXP")); ctrl.traceline_template = xstrdup(skel_property("M4_PROPERTY_TRACE_LINE_TEMPLATE")); ctrl.have_state_entry_format = boneseeker("m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]]"); + prefix_property = skel_property("M4_PROPERTY_PREFIX"); + if (prefix_property != NULL) + ctrl.prefix = xstrdup(prefix_property); flex_init_regex(ctrl.traceline_re); } -- cgit v1.2.1 From 48a25d4966b68fa289dd66744bcef9467b9b9c17 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 18 Nov 2020 07:43:03 -0500 Subject: Partial move of Go back end to Go canelCasing in names. No publicly visible names are touched yet. This is all preep work. All tesrs pass. --- src/go-flex.skl | 684 ++++++++++++++++++++++++++++---------------------------- src/skeletons.c | 2 +- 2 files changed, 343 insertions(+), 343 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index c428786..6b8d3cc 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -24,7 +24,7 @@ m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) m4_define([[M4_PROPERTY_CONTEXT_FORMAT]], [[yyscanner->%s_r]]) -m4_define([[M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT]], [[yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_%s]]) +m4_define([[M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT]], [[yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_%s]]) m4_define([[M4_PROPERTY_PREFIX]], [main]]) %# Macro hooks used by Flex code generators start here @@ -39,22 +39,22 @@ m4_define([[M4_HOOK_TABLE_OPENER]], [[{]]) m4_define([[M4_HOOK_TABLE_CONTINUE]], [[},]]) m4_define([[M4_HOOK_TABLE_CLOSER]], [[};]]) m4_define([[M4_HOOK_RELATIVIZE]], [[$1]]) -m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yy_transition[$1], +m4_define([[M4_HOOK_STATE_ENTRY_FORMAT]], [[ &yyTransition[$1], ]]) m4_define([[M4_HOOK_NORMAL_STATE_CASE_ARM]], [[ case $1:]]) m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]]) m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]]) m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate(); ]]) -m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext */]]) -m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */]]) -m4_define([[M4_HOOK_CHAR_REWIND]], [[yyscanner->yy_c_buf_p = yy_cp -= $1;]]) -m4_define([[M4_HOOK_LINE_REWIND]], [[yy_lineno_rewind_to(yy_cp, yy_cp - $1, yyscanner);]]) -m4_define([[M4_HOOK_CHAR_FORWARD]], [[yyscanner->yy_c_buf_p = yy_cp = yy_bp + $1;]]) -m4_define([[M4_HOOK_LINE_FORWARD]], [[yy_lineno_rewind_to(yy_cp, yy_bp + $1, yyscanner);]]) +m4_define([[M4_HOOK_TAKE_YYTEXT]], [[yyDoBeforeAction(yyscanner, yyCp, yyBp); /* set up yytext */]]) +m4_define([[M4_HOOK_RELEASE_YYTEXT]], [[*yyCp = yyscanner->yyHoldChar; /* undo effects of setting up yytext */]]) +m4_define([[M4_HOOK_CHAR_REWIND]], [[yyscanner->yyCBufP = yyCp -= $1;]]) +m4_define([[M4_HOOK_LINE_REWIND]], [[yyLinenoRewindTo(yyCp, yyCp - $1, yyscanner);]]) +m4_define([[M4_HOOK_CHAR_FORWARD]], [[yyscanner->yyCBufP = yyCp = yyBp + $1;]]) +m4_define([[M4_HOOK_LINE_FORWARD]], [[yyLinenoRewindTo(yyCp, yyBp + $1, yyscanner);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; ]]) -m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yy_state_type $1 = $2; +m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yyStateType $1 = $2; ]]) m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; ]]) @@ -80,23 +80,23 @@ m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINA m4_define([[yyless]], [[ do { /* Undo effects of setting up yytext. */ - int yyless_macro_arg = ($1); - m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(yyless_macro_arg, yyscanner);]]) - *yy_cp = yyscanner->yy_hold_char; + int yylessMacroArg = ($1); + m4_ifdef([[M4_MODE_YYLINENO]], [[yyLessLineno(yylessMacroArg, yyscanner);]]) + *yyCp = yyscanner->yyHoldChar; YY_RESTORE_YY_MORE_OFFSET - yyscanner->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; - yy_do_before_action(yyscanner, yy_cp, yy_bp); /* set up yytext again */ + yyscanner->yyCBufP = yyCp = yyBp + yylessMacroArg - YY_MORE_ADJ; + yyDoBeforeAction(yyscanner, yyCp, yyBp); /* set up yytext again */ } while ( 0 ) ]]) %# Can't be a function given the context-arg treatment due to the goto. m4_define([[M4_HOOK_REJECT]], [[{ - *yy_cp = yyscanner->yy_hold_char; /* undo effects of setting up yytext */ - yy_cp = yyscanner->yy_full_match; /* restore poss. backed-over text */ + *yyCp = yyscanner->yyHoldChar; /* undo effects of setting up yytext */ + yyCp = yyscanner->yyFullMatch; /* restore poss. backed-over text */ m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - yyscanner->yy_lp = yyscanner->yy_full_lp; /* restore orig. accepting pos. */ + yyscanner->yy_lp = yyscanner->yyFullLp; /* restore orig. accepting pos. */ yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ - yy_current_state = *yyscanner->yy_state_ptr; /* restore curr. state */ + yyCurrentState = *yyscanner->yy_state_ptr; /* restore curr. state */ ]]) ++yyscanner->yy_lp; goto find_rule; @@ -187,7 +187,7 @@ m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) /* The state buf must be large enough to hold one state per character in the main buffer. */ -m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yy_state_type))]]) +m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yyStateType))]]) typedef struct yy_buffer_state *yybuffer; @@ -224,7 +224,7 @@ struct yy_buffer_state { /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + int yyNChars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -276,9 +276,9 @@ const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); typedef uint8_t YY_CHAR; m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl -typedef const struct yy_trans_info *yy_state_type; +typedef const struct yy_trans_info *yyStateType; ]], [[ -typedef int yy_state_type; +typedef int yyStateType; ]]) /* Watch out: yytext_ptr is a variable when yytext is an array, @@ -292,7 +292,7 @@ m4_define([[yytext_ptr]], [[yytext_r]]) static int yy_get_next_buffer ( yyscan_t yyscanner ); -struct yy_trans_info { +struct yyTransInfo { /* We require that yy_verify and yy_nxt must be of the same size int. */ m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ YY_OFFSET_TYPE yy_verify; @@ -307,9 +307,9 @@ m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ YY_OFFSET_TYPE yy_nxt; ]]) m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ - /* We generate a bogus 'struct yy_trans_info' data type + /* We generate a bogus 'struct yyTransInfo' data type * so we can guarantee that it is always declared in the skel. - * This is so we can compile "sizeof(struct yy_trans_info)" + * This is so we can compile "sizeof(struct yyTransInfo)" * in any scanner. */ int32_t yy_verify; @@ -381,11 +381,11 @@ static const YY_CHAR * yy_meta = 0; m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl /* The transition table */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = { +static const struct yyTransInfo yyTransition[M4_HOOK_TRANSTABLE_SIZE] = { M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl }; ]], [[ -static const struct yy_trans_info *yy_transition = 0; +static const struct yyTransInfo *yyTransition = 0; ]]) ]]) @@ -393,11 +393,11 @@ static const struct yy_trans_info *yy_transition = 0; m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl /* Table of pointers to start states. */ m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { +static const struct yyTransInfo *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { M4_HOOK_STARTTABLE_BODY[[]]m4_dnl }; ]], [[ -static const struct yy_trans_info **yy_start_state_list =0; +static const struct yyTransInfo **yy_start_state_list =0; ]]) ]]) @@ -459,11 +459,11 @@ static const M4_HOOK_CHK_TYPE * yy_chk = 0; m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const yy_state_type yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, +static const yyStateType yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, M4_HOOK_NULTRANS_BODY[[]]m4_dnl }; ]], [[ -static const yy_state_type * yy_NUL_trans = 0; +static const yyStateType * yy_NUL_trans = 0; ]]) ]]) @@ -497,35 +497,35 @@ struct yyguts_t { /* The rest are the same as the globals declared in the non-reentrant scanner. */ FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - yybuffer * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; + size_t yyBufferStackTop; /**< index of top of stack. */ + size_t yyBufferStackMax; /**< capacity of stack. */ + yybuffer * yyBufferStack; /**< Stack as an array. */ + char yyHoldChar; + int yyNChars; int yyleng_r; - char *yy_c_buf_p; + char *yyCBufP; bool yy_init; - int yy_start; - bool yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; + int yyStart; + bool yyDidBufferSwitchOnEof; + int yyStartStackPtr; + int yyStartStackDepth; + int *yyStartStack; + yyStateType yy_last_accepting_state; char* yy_last_accepting_cpos; int yylineno_r; int yyflexdebug_r; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; + yyStateType *yyStateBuf; + yyStateType *yy_state_ptr; + char *yyFullMatch; int yy_lp; m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl /* These are only needed for trailing context rules */ int yy_looking_for_trail_begin; - int yy_full_lp; + int yyFullLp; int *yy_full_state; ]]) ]]) @@ -564,17 +564,17 @@ m4_define([[yylloc]], [[yyscanner->yylloc_r]]) /* Returns the top of the stack, or NULL. */ yybuffer yy_current_buffer(yyscan_t yyscanner) { - return ( yyscanner->yy_buffer_stack \ - ? yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] \ + return ( yyscanner->yyBufferStack \ + ? yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] \ : NULL); } static void yy_load_buffer_state (yyscan_t yyscanner) { - yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; - yyscanner->yytext_ptr = yyscanner->yy_c_buf_p = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos; - yyscanner->yyin_r = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file; - yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; + yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; + yyscanner->yytext_ptr = yyscanner->yyCBufP = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos; + yyscanner->yyin_r = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_input_file; + yyscanner->yyHoldChar = *yyscanner->yyCBufP; } /** Discard all buffered characters. On the next scan, yyread() will be called. @@ -586,7 +586,7 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) if ( b == NULL ) { return; } - b->yy_n_chars = 0; + b->yyNChars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes @@ -627,40 +627,40 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) { yy_size_t num_to_alloc; - if (yyscanner->yy_buffer_stack == NULL) { + if (yyscanner->yyBufferStack == NULL) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + yyscanner->yyBufferStack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); - if ( yyscanner->yy_buffer_stack == NULL ) { + if ( yyscanner->yyBufferStack == NULL ) { yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } - memset(yyscanner->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyscanner->yyBufferStack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - yyscanner->yy_buffer_stack_max = num_to_alloc; - yyscanner->yy_buffer_stack_top = 0; + yyscanner->yyBufferStackMax = num_to_alloc; + yyscanner->yyBufferStackTop = 0; return; } - if (yyscanner->yy_buffer_stack_top >= (yyscanner->yy_buffer_stack_max) - 1) { + if (yyscanner->yyBufferStackTop >= (yyscanner->yyBufferStackMax) - 1) { /* Increase the buffer to prepare for a possible push. */ yy_size_t grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyscanner->yy_buffer_stack_max + grow_size; - yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyscanner->yy_buffer_stack, + num_to_alloc = yyscanner->yyBufferStackMax + grow_size; + yyscanner->yyBufferStack = (struct yy_buffer_state**)yyrealloc + (yyscanner->yyBufferStack, num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); - if (yyscanner->yy_buffer_stack == NULL) { + if (yyscanner->yyBufferStack == NULL) { yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); } /* zero only the new slots.*/ - memset(yyscanner->yy_buffer_stack + yyscanner->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyscanner->yy_buffer_stack_max = num_to_alloc; + memset(yyscanner->yyBufferStack + yyscanner->yyBufferStackMax, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyscanner->yyBufferStackMax = num_to_alloc; } } @@ -743,7 +743,7 @@ void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) return; } if ( b == yy_current_buffer(yyscanner) ) { /* Not sure if we should pop here. */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = (yybuffer) 0; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = (yybuffer) 0; } if ( b->yy_is_our_buffer ) { yyfree( (void *) b->yy_ch_buf, yyscanner ); @@ -768,20 +768,20 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) /* This block is copied from yy_switch_to_buffer. */ if ( yy_current_buffer(yyscanner) != NULL ) { /* Flush out information for old buffer. */ - *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + *yyscanner->yyCBufP = yyscanner->yyHoldChar; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos = yyscanner->yyCBufP; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } /* Only push if top exists. Otherwise, replace top. */ if (yy_current_buffer(yyscanner)) { - yyscanner->yy_buffer_stack_top++; + yyscanner->yyBufferStackTop++; } - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( yyscanner ); - yyscanner->yy_did_buffer_switch_on_eof = true; + yyscanner->yyDidBufferSwitchOnEof = true; } @@ -795,13 +795,13 @@ void yypop_buffer_state (yyscan_t yyscanner) return; } yy_delete_buffer(yy_current_buffer(yyscanner), yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; - if (yyscanner->yy_buffer_stack_top > 0) { - --yyscanner->yy_buffer_stack_top; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = NULL; + if (yyscanner->yyBufferStackTop > 0) { + --yyscanner->yyBufferStackTop; } if (yy_current_buffer(yyscanner) != NULL) { yy_load_buffer_state( yyscanner ); - yyscanner->yy_did_buffer_switch_on_eof = true; + yyscanner->yyDidBufferSwitchOnEof = true; } } @@ -816,7 +816,7 @@ void yyrestart(FILE * input_file, yyscan_t yyscanner) if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } @@ -825,8 +825,8 @@ void yyrestart(FILE * input_file, yyscan_t yyscanner) } static void yybumpline( yyscan_t yyscanner) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno++; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yycolumn=0; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno++; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yycolumn=0; } /* START special functions @@ -838,14 +838,14 @@ static void yybumpline( yyscan_t yyscanner) { /* Enter a start condition. */ void yybegin(int s, yyscan_t yyscanner) { - yyscanner->yy_start = 1 + 2 * (s); + yyscanner->yyStart = 1 + 2 * (s); } /* Translate the current start state into a value that can be later handed * to yybegin() to return to the state. */ int yystart(yyscan_t yyscanner) { - return ((yyscanner->yy_start - 1) / 2); + return ((yyscanner->yyStart - 1) / 2); } /* This used to be an fputs(), but since the string might contain NULs, @@ -858,46 +858,46 @@ void yyecho(yyscan_t yyscanner) { m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ void yyunput( int c, yyscan_t yyscanner) { - char *yy_cp; + char *yyCp; - yy_cp = yyscanner->yy_c_buf_p; + yyCp = yyscanner->yyCBufP; /* undo effects of setting up yytext */ - *yy_cp = yyscanner->yy_hold_char; + *yyCp = yyscanner->yyHoldChar; - if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + if ( yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = yyscanner->yy_n_chars + 2; - char *dest = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size + 2]; + int number_to_move = yyscanner->yyNChars + 2; + char *dest = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[ + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size + 2]; char *source = - &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move]; + &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[number_to_move]; - while ( source > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf ) { + while ( source > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf ) { *--dest = *--source; } - yy_cp += (int) (dest - source); + yyCp += (int) (dest - source); yyscanner->yytext_ptr += (int) (dest - source); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = - yyscanner->yy_n_chars = (int) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = + yyscanner->yyNChars = (int) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size; - if ( yy_cp < yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf + 2 ) { + if ( yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf + 2 ) { yypanic( "flex scanner push-back overflow", yyscanner); } } - *--yy_cp = (char) c; + *--yyCp = (char) c; m4_ifdef( [[M4_MODE_YYLINENO]], [[ if ( c == '\n' ){ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } ]]) - yyscanner->yy_hold_char = *yy_cp; - yyscanner->yy_c_buf_p = yy_cp; + yyscanner->yyHoldChar = *yyCp; + yyscanner->yyCBufP = yyCp; } ]]) @@ -905,20 +905,20 @@ int yyinput (yyscan_t yyscanner) { int c; - *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; + *yyscanner->yyCBufP = yyscanner->yyHoldChar; - if ( *yyscanner->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { - /* yy_c_buf_p now points to the character we want to return. + if ( *yyscanner->yyCBufP == YY_END_OF_BUFFER_CHAR ) { + /* yyCBufP now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( yyscanner->yy_c_buf_p < &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] ) { + if ( yyscanner->yyCBufP < &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars] ) { /* This was really a NUL. */ - *yyscanner->yy_c_buf_p = '\0'; + *yyscanner->yyCBufP = '\0'; } else { /* need more input */ - int offset = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr); - ++yyscanner->yy_c_buf_p; + int offset = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr); + ++yyscanner->yyCBufP; switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: @@ -941,26 +941,26 @@ int yyinput (yyscan_t yyscanner) if ( yywrap( yyscanner ) ) { return 0; } - if ( ! yyscanner->yy_did_buffer_switch_on_eof ) { + if ( ! yyscanner->yyDidBufferSwitchOnEof ) { yyrestart( yyscanner->yyin_r, yyscanner ); } return yyinput(yyscanner); case EOB_ACT_CONTINUE_SCAN: - yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + offset; + yyscanner->yyCBufP = yyscanner->yytext_ptr + offset; break; } } } - c = *(unsigned char *) yyscanner->yy_c_buf_p; /* cast for 8-bit char's */ - *yyscanner->yy_c_buf_p = '\0'; /* preserve yytext */ - yyscanner->yy_hold_char = *++yyscanner->yy_c_buf_p; + c = *(unsigned char *) yyscanner->yyCBufP; /* cast for 8-bit char's */ + *yyscanner->yyCBufP = '\0'; /* preserve yytext */ + yyscanner->yyHoldChar = *++yyscanner->yyCBufP; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (c == '\n'); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag ) { + if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag ) { yybumpline( yyscanner ); } ]]) @@ -1025,7 +1025,7 @@ m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ } ]]) m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive ) { + if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive ) { int c = '*'; int n; for ( n = 0; n < max_size && @@ -1296,24 +1296,24 @@ m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ static void rule_check_bol(yyscan_t yyscanner) { if ( yyscanner->yyleng_r > 0 ) { \ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); } } ]]) /* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. yy_cp and yy_bp are the + * corresponding action - sets up yytext. yyCp and yyBp are the * end abd start pointers for the input buffer segment that is * claimed as yytext. */ -void yy_do_before_action(yyscan_t yyscanner, char *yy_cp, char *yy_bp) { - yyscanner->yytext_ptr = yy_bp; \ +void yyDoBeforeAction(yyscan_t yyscanner, char *yyCp, char *yyBp) { + yyscanner->yytext_ptr = yyBp; \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; \ - yyscanner->yyleng_r = (int) (yy_cp - yyscanner->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yy_cp - yy_bp);]]) \ - yyscanner->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ + yyscanner->yyleng_r = (int) (yyCp - yyscanner->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yyCp - yyBp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yyCp - yyBp);]]) \ + yyscanner->yyHoldChar = *yyCp; \ + *yyCp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ @@ -1325,26 +1325,26 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ ]]) \ - yyscanner->yy_c_buf_p = yy_cp; + yyscanner->yyCBufP = yyCp; } m4_ifdef( [[M4_MODE_YYLINENO]], [[ /* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro * and we can get at yy_act */ -static void yy_less_lineno(int n, yyscan_t yyscanner) { +static void yyLessLineno(int n, yyscan_t yyscanner) { int yyl; for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { if ( yyscanner->yytext_r[yyl] == '\n' ) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } } } -static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { +static void yyLinenoRewindTo(char *yyCp, char *dst, yyscan_t yyscanner) { const char *p; - for ( p = yy_cp-1; p >= dst; --p) { + for ( p = yyCp-1; p >= dst; --p) { if ( *p == '\n' ) { - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->bs_yylineno--; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } } } @@ -1353,10 +1353,10 @@ static void yy_lineno_rewind_to(char *yy_cp, char *dst, yyscan_t yyscanner) { void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive = is_interactive; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive = is_interactive; } @@ -1385,14 +1385,14 @@ m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) void yysetbol(bool at_bol, yyscan_t yyscanner) { if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag = at_bol; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = at_bol; } bool yyatbol(yyscan_t yyscanner) { - return (yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yyatbol_flag); + return (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag); } /** Switch to a different input buffer. @@ -1413,12 +1413,12 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) } if ( yy_current_buffer(yyscanner) ) { /* Flush out information for old buffer. */ - *yyscanner->yy_c_buf_p = yyscanner->yy_hold_char; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_pos = yyscanner->yy_c_buf_p; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + *yyscanner->yyCBufP = yyscanner->yyHoldChar; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos = yyscanner->yyCBufP; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = new_buffer; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = new_buffer; yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during @@ -1426,7 +1426,7 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - yyscanner->yy_did_buffer_switch_on_eof = true; + yyscanner->yyDidBufferSwitchOnEof = true; } @@ -1456,7 +1456,7 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = false; b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; + b->yyNChars = b->yy_buf_size; b->yy_is_interactive = false; b->yyatbol_flag = true; b->yy_fill_buffer = false; @@ -1532,17 +1532,17 @@ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) */ static int yy_get_next_buffer (yyscan_t yyscanner) { - char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; + char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf; char *source = yyscanner->yytext_ptr; int number_to_move, i; int ret_val; - if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { + if ( yyscanner->yyCBufP > &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars + 1] ) { yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); } - if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { + if ( !yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_fill_buffer ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { + if ( yyscanner->yyCBufP - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ @@ -1558,19 +1558,19 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); + number_to_move = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) { *(dest++) = *(source++); } - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars = 0; } else { int num_to_read = - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ m4_ifdef( [[M4_MODE_USES_REJECT]], @@ -1580,10 +1580,10 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], ]], [[ /* just a shorter name for the current buffer */ - yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; + yybuffer b = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]; - int yy_c_buf_p_offset = - (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); + int yyCBufP_offset = + (int) (yyscanner->yyCBufP - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; @@ -1604,9 +1604,9 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], if ( b->yy_ch_buf == NULL ) { yypanic("fatal error - scanner input buffer overflow", yyscanner); } - yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + yyscanner->yyCBufP = &b->yy_ch_buf[yyCBufP_offset]; - num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - + num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size - number_to_move - 1; ]]) } @@ -1615,40 +1615,40 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], num_to_read = YY_READ_BUF_SIZE; } /* Read in more data. */ - yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); + yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[number_to_move], num_to_read, yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } - if ( yyscanner->yy_n_chars == 0 ) { + if ( yyscanner->yyNChars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyscanner->yyin_r, yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else { ret_val = EOB_ACT_CONTINUE_SCAN; } - if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { + if ((yyscanner->yyNChars + number_to_move) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( - (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { + int new_size = yyscanner->yyNChars + number_to_move + (yyscanner->yyNChars >> 1); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf = (char *) yyrealloc( + (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf == NULL ) { yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); } /* "- 2" to take care of EOB's */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size = (int) (new_size - 2); } - yyscanner->yy_n_chars += number_to_move; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + yyscanner->yyNChars += number_to_move; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; - yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; + yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[0]; return ret_val; } @@ -1657,24 +1657,24 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ static void yy_push_state(int _new_state, yyscan_t yyscanner) { - if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) { + if ( yyscanner->yyStartStackPtr >= yyscanner->yyStartStackDepth ) { yy_size_t new_size; - yyscanner->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int ); + yyscanner->yyStartStackDepth += YY_START_STACK_INCR; + new_size = (yy_size_t) yyscanner->yyStartStackDepth * sizeof( int ); - if ( yyscanner->yy_start_stack == NULL ) { - yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); + if ( yyscanner->yyStartStack == NULL ) { + yyscanner->yyStartStack = (int *) yyalloc( new_size, yyscanner ); } else { - yyscanner->yy_start_stack = (int *) yyrealloc( - (void *) yyscanner->yy_start_stack, new_size, yyscanner ); + yyscanner->yyStartStack = (int *) yyrealloc( + (void *) yyscanner->yyStartStack, new_size, yyscanner ); } - if ( yyscanner->yy_start_stack == NULL ) { + if ( yyscanner->yyStartStack == NULL ) { yypanic( "out of memory expanding start-condition stack", yyscanner); } } - yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr++] = yystart(yyscanner); + yyscanner->yyStartStack[yyscanner->yyStartStackPtr++] = yystart(yyscanner); yybegin(_new_state, yyscanner); } @@ -1685,10 +1685,10 @@ m4_ifdef( [[M4_YY_NO_POP_STATE]],, [[ static void yy_pop_state (yyscan_t yyscanner) { - if ( --yyscanner->yy_start_stack_ptr < 0 ) { + if ( --yyscanner->yyStartStackPtr < 0 ) { yypanic( "start-condition stack underflow", yyscanner ); } - yybegin(yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr], yyscanner); + yybegin(yyscanner->yyStartStack[yyscanner->yyStartStackPtr], yyscanner); } ]]) @@ -1697,7 +1697,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, [[ static int yy_top_state (yyscan_t yyscanner) { - return yyscanner->yy_start_stack_ptr > 0 ? yyscanner->yy_start_stack[yyscanner->yy_start_stack_ptr - 1] : yystart(yyscanner); + return yyscanner->yyStartStackPtr > 0 ? yyscanner->yyStartStack[yyscanner->yyStartStackPtr - 1] : yystart(yyscanner); } ]]) @@ -1708,13 +1708,13 @@ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* Generate code to keep backing-up information. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ - if ( yy_current_state[-1].yy_nxt ) { + if ( yyCurrentState[-1].yy_nxt ) { ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - if ( yy_accept[yy_current_state] ) { + if ( yy_accept[yyCurrentState] ) { ]]) - yyscanner->yy_last_accepting_state = yy_current_state; - yyscanner->yy_last_accepting_cpos = yy_cp; + yyscanner->yy_last_accepting_state = yyCurrentState; + yyscanner->yy_last_accepting_cpos = yyCp; } ]]) ]]) @@ -1737,8 +1737,8 @@ m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ */ M4_GEN_BACKING_UP - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { - yy_current_state = (int) yy_def[yy_current_state]; + while ( yy_chk[yy_base[yyCurrentState] + yy_c] != yyCurrentState ) { + yyCurrentState = (int) yy_def[yyCurrentState]; m4_ifdef([[M4_MODE_USEMECS]], [[ /* We've arranged it so that templates are never chained @@ -1750,41 +1750,41 @@ m4_ifdef([[M4_MODE_USEMECS]], [[ */ /* lastdfa + 2 == YY_JAMSTATE + 1 is the beginning of the templates */ - if (yy_current_state >= YY_JAMSTATE + 1) { + if (yyCurrentState >= YY_JAMSTATE + 1) { yy_c = yy_meta[yy_c]; } ]]) } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yyCurrentState = yy_nxt[yy_base[yyCurrentState] + yy_c]; ]]) m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start + yyatbol()];]]) -m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yy_current_state = yy_start_state_list[yyscanner->yy_start];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState = yy_start_state_list[yyscanner->yyStart + yyatbol()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yyCurrentState = yy_start_state_list[yyscanner->yyStart];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - yy_current_state = yyscanner->yy_start; -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yy_current_state += yyatbol(yyscanner);]]) + yyCurrentState = yyscanner->yyStart; +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState += yyatbol(yyscanner);]]) /* Set up for storing up states. */ m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyscanner->yy_state_ptr = yyscanner->yy_state_buf; - *yyscanner->yy_state_ptr++ = yy_current_state; + yyscanner->yy_state_ptr = yyscanner->yyStateBuf; + *yyscanner->yy_state_ptr++ = yyCurrentState; ]]) ]]) ]]) m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ { - const struct yy_trans_info *yy_trans_info; + const struct yyTransInfo *yyTransInfo; YY_CHAR yy_c; for ( yy_c = $1; - (yy_trans_info = &yy_current_state[yy_c])->yy_verify == yy_c; + (yyTransInfo = &yyCurrentState[yy_c])->yy_verify == yy_c; yy_c = $2 ) { - yy_current_state += yy_trans_info->yy_nxt; + yyCurrentState += yyTransInfo->yy_nxt; M4_GEN_BACKING_UP } @@ -1799,44 +1799,44 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) -/* yy_get_previous_state - get the state just before the EOB char was reached */ +/* yyGetPreviousState - get the state just before the EOB char was reached */ -static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - yy_state_type yy_current_state; - char *yy_cp; +static yyStateType yyGetPreviousState (yyscan_t yyscanner) { + yyStateType yyCurrentState; + char *yyCp; M4_GEN_START_STATE - for ( yy_cp = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_cp < yyscanner->yy_c_buf_p; ++yy_cp ) { + for ( yyCp = yyscanner->yytext_ptr + YY_MORE_ADJ; yyCp < yyscanner->yyCBufP; ++yyCp ) { /* Generate the code to find the next state. */ - m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yy_cp ? M4_EC(YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC)]])]]) - m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yy_cp))]])]]) + m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yyCp ? M4_EC(YY_SC_TO_UI(*yyCp)) : YY_NUL_EC)]])]]) + m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yyCp))]])]]) m4_ifdef([[M4_MODE_NULTRANS]], [[ /* Compressed tables back up *before* they match. */ m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) - if ( *yy_cp ) { + if ( *yyCp ) { ]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ - m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][CHAR_MAP_3];]]) - m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState][CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState*YY_NXT_LOLEN + CHAR_MAP_3];]]) ]]) - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_current_state += yy_current_state[CHAR_MAP_3].yy_nxt;]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yyCurrentState += yyCurrentState[CHAR_MAP_3].yy_nxt;]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) m4_ifdef([[M4_MODE_NULTRANS]], [[ } else { - yy_current_state = yy_NUL_trans[yy_current_state]; + yyCurrentState = yy_NUL_trans[yyCurrentState]; } ]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yyCurrentState;]]) } - return yy_current_state; + return yyCurrentState; } /* yy_try_NUL_trans - try to make a transition on the NUL character @@ -1844,55 +1844,55 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ * synopsis * next_state = yy_try_NUL_trans( current_state ); */ -static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner) +static yyStateType yy_try_NUL_trans(yyStateType yyCurrentState, yyscan_t yyscanner) { - bool yy_is_jam; + bool yyIsJam; /* Generate code for handling NUL's, if needed. */ - /* First, deal with backing up and setting up yy_cp if the scanner + /* First, deal with backing up and setting up yyCp if the scanner * finds that it should JAM on the NUL. * - * Only generate a definition for "yy_cp" if we'll generate code + * Only generate a definition for "yyCp" if we'll generate code * that uses it. Otherwise lint and the like complain. */ - m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yy_cp = yyscanner->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yyCp = yyscanner->yyCBufP;]]) %# Note that this statement block and the following three are %# not executed serially but are an if-then-else cascade %# for different table modes. m4_ifdef([[M4_MODE_NULTRANS]], [[ - yy_current_state = yy_NUL_trans[yy_current_state]; - yy_is_jam = (yy_current_state == 0); + yyCurrentState = yy_NUL_trans[yyCurrentState]; + yyIsJam = (yyCurrentState == 0); ]]) m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ -m4_ifdef([[M4_MODE_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state][YY_NUL_EC];]]) -m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + YY_NUL_EC];]]) - yy_is_jam = (yy_current_state <= 0); +m4_ifdef([[M4_MODE_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState][YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState*YY_NXT_LOLEN + YY_NUL_EC];]]) + yyIsJam = (yyCurrentState <= 0); ]]) m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ int yy_c = YY_NUL_EC; - const struct yy_trans_info *yy_trans_info; + const struct yyTransInfo *yyTransInfo; - yy_trans_info = &yy_current_state[(unsigned int) yy_c]; - yy_current_state += yy_trans_info->yy_nxt; - yy_is_jam = (yy_trans_info->yy_verify != yy_c); + yyTransInfo = &yyCurrentState[(unsigned int) yy_c]; + yyCurrentState += yyTransInfo->yy_nxt; + yyIsJam = (yyTransInfo->yy_verify != yy_c); ]]) m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ M4_GEN_NEXT_COMPRESSED_STATE(YY_NUL_EC) -yy_is_jam = (yy_current_state == YY_JAMSTATE); +yyIsJam = (yyCurrentState == YY_JAMSTATE); m4_ifdef([[M4_MODE_USES_REJECT]], [[ /* Only stack this state if it's a transition we * actually make. If we stack it on a jam, then - * the state stack and yy_c_buf_p get out of sync. + * the state stack and yyCBufP get out of sync. */ - if ( ! yy_is_jam ) { - *yyscanner->yy_state_ptr++ = yy_current_state; + if ( ! yyIsJam ) { + *yyscanner->yy_state_ptr++ = yyCurrentState; } ]]) ]]) @@ -1905,20 +1905,20 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ * compressed tables have *already* done such backing up, so * we needn't bother with it again. */ - if ( ! yy_is_jam ) { + if ( ! yyIsJam ) { M4_GEN_BACKING_UP } ]]) (void)yyscanner; /* forestall unused-argument warning */ - return yy_is_jam ? 0 : yy_current_state; + return yyIsJam ? 0 : yyCurrentState; } /** The main scanner function which does all the work. */ YY_DECL { - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; + yyStateType yyCurrentState; + char *yyCp, *yyBp; int yy_act; m4_ifdef( [[M4_YY_BISON_LVAL]], @@ -1939,16 +1939,16 @@ m4_ifdef( [[]], m4_ifdef( [[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ - if ( yyscanner->yy_state_buf == NULL ) { - yyscanner->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); + if ( yyscanner->yyStateBuf == NULL ) { + yyscanner->yyStateBuf = (yyStateType *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } - if ( yyscanner->yy_state_buf == NULL) { + if ( yyscanner->yyStateBuf == NULL) { yypanic( "out of dynamic memory in yylex()", yyscanner); } ]]) - if ( yyscanner->yy_start == 0 ) { - yyscanner->yy_start = 1; /* first start state */ + if ( yyscanner->yyStart == 0 ) { + yyscanner->yyStart = 1; /* first start state */ } if ( yyscanner->yyin_r == NULL ) { yyscanner->yyin_r = stdin; @@ -1958,7 +1958,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], } if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } @@ -1974,20 +1974,20 @@ m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ yyscanner->yy_more_len = 0; if ( yyscanner->yy_more_flag ) { - yyscanner->yy_more_len = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr); + yyscanner->yy_more_len = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr); yyscanner->yy_more_flag = false; } ]]) ]]) - yy_cp = yyscanner->yy_c_buf_p; + yyCp = yyscanner->yyCBufP; /* Support of yytext. */ - *yy_cp = yyscanner->yy_hold_char; + *yyCp = yyscanner->yyHoldChar; - /* yy_bp points to the position in yy_ch_buf of the start of + /* yyBp points to the position in yy_ch_buf of the start of * the current run. */ - yy_bp = yy_cp; + yyBp = yyCp; M4_GEN_START_STATE @@ -1995,51 +1995,51 @@ M4_GEN_START_STATE /* Generate the code to find the next match. */ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl - while ((yy_current_state = yy_nxt[yy_current_state][ M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { + while ((yyCurrentState = yy_nxt[yyCurrentState][ M4_EC(YY_SC_TO_UI(*yyCp)) ]) > 0) { ]]) m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ - while ((yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yy_cp)) ]) > 0) { + while ((yyCurrentState = yy_nxt[yyCurrentState*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yyCp)) ]) > 0) { ]]) M4_GEN_BACKING_UP - yy_cp++; + yyCp++; } - yy_current_state = -yy_current_state; + yyCurrentState = -yyCurrentState; ]]) m4_ifdef([[M4_MODE_FULLSPD]], [[ - M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yy_cp)), M4_EC(YY_SC_TO_UI(*++yy_cp))) + M4_GEN_NEXT_MATCH_FULLSPD(M4_EC(YY_SC_TO_UI(*yyCp)), M4_EC(YY_SC_TO_UI(*++yyCp))) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ do { - M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yy_cp))) + M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yyCp))) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yy_current_state;]]) - ++yy_cp; + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yyCurrentState;]]) + ++yyCp; } - m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yy_current_state] != YY_JAMBASE );]]) - m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yy_current_state != YY_JAMSTATE );]]) + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yyCurrentState] != YY_JAMBASE );]]) + m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yyCurrentState != YY_JAMSTATE );]]) m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure out * the match. */ - yy_cp = yyscanner->yy_last_accepting_cpos; - yy_current_state = yyscanner->yy_last_accepting_state; + yyCp = yyscanner->yy_last_accepting_cpos; + yyCurrentState = yyscanner->yy_last_accepting_state; ]]) ]]) ]]) yy_find_action: /* code to find the action number goes here */ - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yy_current_state[-1].yy_nxt;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yy_current_state];]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yyCurrentState[-1].yy_nxt;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yyCurrentState];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ - yy_current_state = *--yyscanner->yy_state_ptr; - yyscanner->yy_lp = yy_accept[yy_current_state]; + yyCurrentState = *--yyscanner->yy_state_ptr; + yyscanner->yy_lp = yy_accept[yyCurrentState]; m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) for ( ; ; ) { /* loop until we find out what rule we matched */ - if (yyscanner->yy_lp && yyscanner->yy_lp < yy_accept[yy_current_state + 1]) { + if (yyscanner->yy_lp && yyscanner->yy_lp < yy_accept[yyCurrentState + 1]) { yy_act = yy_acclist[yyscanner->yy_lp]; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || yyscanner->yy_looking_for_trail_begin) { @@ -2055,14 +2055,14 @@ m4_ifdef([[M4_MODE_REAL_REJECT]], [[ /* Remember matched text in case we back up * due to REJECT. */ - yyscanner->yy_full_match = yy_cp; + yyscanner->yyFullMatch = yyCp; yyscanner->yy_full_state = yyscanner->yy_state_ptr; - yyscanner->yy_full_lp = yyscanner->yy_lp; + yyscanner->yyFullLp = yyscanner->yy_lp; ]]) } else { - yyscanner->yy_full_match = yy_cp; + yyscanner->yyFullMatch = yyCp; yyscanner->yy_full_state = yyscanner->yy_state_ptr; - yyscanner->yy_full_lp = yyscanner->yy_lp; + yyscanner->yyFullLp = yyscanner->yy_lp; break; } ++yyscanner->yy_lp; @@ -2072,30 +2072,30 @@ m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ /* Remember matched text in case we back up due to * trailing context plus REJECT. */ - yyscanner->yy_full_match = yy_cp; + yyscanner->yyFullMatch = yyCp; break; ]]) } - --yy_cp; + --yyCp; /* We could consolidate the following two lines with those at * the beginning, but at the cost of complaints that we're * branching inside a loop. */ - yy_current_state = *--yyscanner->yy_state_ptr; - yyscanner->yy_lp = yy_accept[yy_current_state]; + yyCurrentState = *--yyscanner->yy_state_ptr; + yyscanner->yy_lp = yy_accept[yyCurrentState]; } /* close for */ ]]) -m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yy_current_state]; +m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yyCurrentState]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = yyscanner->yy_last_accepting_cpos; - yy_current_state = yyscanner->yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; + yyCp = yyscanner->yy_last_accepting_cpos; + yyCurrentState = yyscanner->yy_last_accepting_state; + yy_act = yy_accept[yyCurrentState]; } ]]) - yy_do_before_action(yyscanner, yy_cp, yy_bp); + yyDoBeforeAction(yyscanner, yyCp, yyBp); m4_ifdef( [[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], @@ -2136,16 +2136,16 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case 0: /* must back up */ - /* undo the effects of yy_do_before_action() */ - *yy_cp = yyscanner->yy_hold_char; + /* undo the effects of yyDoBeforeAction() */ + *yyCp = yyscanner->yyHoldChar; /* Backing-up info for compressed tables is taken \after/ */ - /* yy_cp has been incremented for the next state. */ - yy_cp = yyscanner->yy_last_accepting_cpos; - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp++;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp++;]]) + /* yyCp has been incremented for the next state. */ + yyCp = yyscanner->yy_last_accepting_cpos; + m4_ifdef([[M4_MODE_FULLSPD]], [[yyCp++;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yyCp++;]]) - yy_current_state = yyscanner->yy_last_accepting_state; + yyCurrentState = yyscanner->yy_last_accepting_state; goto yy_find_action; ]]) ]]) @@ -2154,13 +2154,13 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyscanner->yytext_ptr) - 1; + int yy_amount_of_matched_text = (int) (yyCp - yyscanner->yytext_ptr) - 1; - /* Undo the effects of yy_do_before_action(). */ - *yy_cp = yyscanner->yy_hold_char; + /* Undo the effects of yyDoBeforeAction(). */ + *yyCp = yyscanner->yyHoldChar; YY_RESTORE_YY_MORE_OFFSET - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_NEW ) { + if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called @@ -2170,64 +2170,64 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * this is the first action (other than possibly a * back-up) that will match for the new input source. */ - yyscanner->yy_n_chars = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_input_file = yyscanner->yyin_r; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = YY_BUFFER_NORMAL; + yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_input_file = yyscanner->yyin_r; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status = YY_BUFFER_NORMAL; } - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will + /* Note that here we test for yyCBufP "<=" to the position + * of the first EOB in the buffer, since yyCBufP will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ - if ( yyscanner->yy_c_buf_p <= &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] ) { /* This was really a NUL. */ - yy_state_type yy_next_state; + if ( yyscanner->yyCBufP <= &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars] ) { /* This was really a NUL. */ + yyStateType yy_next_state; - yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + yy_amount_of_matched_text; + yyscanner->yyCBufP = yyscanner->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( yyscanner ); + yyCurrentState = yyGetPreviousState( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have - * yy_get_previous_state() go ahead and do it + * yyGetPreviousState() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ - yy_next_state = yy_try_NUL_trans( yy_current_state, yyscanner); + yy_next_state = yy_try_NUL_trans( yyCurrentState, yyscanner); - yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; + yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++yyscanner->yy_c_buf_p; - yy_current_state = yy_next_state; + yyCp = ++yyscanner->yyCBufP; + yyCurrentState = yy_next_state; goto yy_match; } else { %# Disguised case statement on table modes - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_cp = yyscanner->yy_c_buf_p;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_cp = yyscanner->yy_c_buf_p;]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yyCp = yyscanner->yyCBufP;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yyCp = yyscanner->yyCBufP;]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure * out the match. */ - yy_cp = yyscanner->yy_last_accepting_cpos; - yy_current_state = yyscanner->yy_last_accepting_state; + yyCp = yyscanner->yy_last_accepting_cpos; + yyCurrentState = yyscanner->yy_last_accepting_state; ]]) ]]) %# Disguised case statement on table modes ends m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ - /* Still need to initialize yy_cp, though - * yy_current_state was set up by - * yy_get_previous_state(). + /* Still need to initialize yyCp, though + * yyCurrentState was set up by + * yyGetPreviousState(). */ - yy_cp = yyscanner->yy_c_buf_p; + yyCp = yyscanner->yyCBufP; ]]) ]]) goto yy_find_action; @@ -2235,46 +2235,46 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } else { /* not a NUL */ switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: - yyscanner->yy_did_buffer_switch_on_eof = false; + yyscanner->yyDidBufferSwitchOnEof = false; if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up - * yy_c_buf_p so that if some total + * yyCBufP so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - yyscanner->yy_c_buf_p = yyscanner->yytext_ptr + YY_MORE_ADJ; + yyscanner->yyCBufP = yyscanner->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(yystart(yyscanner)); goto do_action; } else { - if ( ! yyscanner->yy_did_buffer_switch_on_eof ) { + if ( ! yyscanner->yyDidBufferSwitchOnEof ) { yyrestart( yyscanner->yyin_r, yyscanner ); } } break; case EOB_ACT_CONTINUE_SCAN: - yyscanner->yy_c_buf_p = + yyscanner->yyCBufP = yyscanner->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( yyscanner ); + yyCurrentState = yyGetPreviousState( yyscanner ); - yy_cp = yyscanner->yy_c_buf_p; - yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; + yyCp = yyscanner->yyCBufP; + yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - yyscanner->yy_c_buf_p = - &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars]; + yyscanner->yyCBufP = + &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars]; - yy_current_state = yy_get_previous_state( yyscanner ); + yyCurrentState = yyGetPreviousState( yyscanner ); - yy_cp = yyscanner->yy_c_buf_p; - yy_bp = yyscanner->yytext_ptr + YY_MORE_ADJ; + yyCp = yyscanner->yyCBufP; + yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } /* end EOB inner switch */ } /* end if */ @@ -2293,11 +2293,11 @@ m4_undefine([[yyless]]) void yyless(int n, yyscan_t yyscanner) { /* Undo effects of setting up yytext. */ - m4_ifdef([[M4_MODE_YYLINENO]], [[yy_less_lineno(n, yyscanner);]]) - yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yy_hold_char; - yyscanner->yy_c_buf_p = yyscanner->yytext_r + n; - yyscanner->yy_hold_char = *yyscanner->yy_c_buf_p; - *yyscanner->yy_c_buf_p = '\0'; + m4_ifdef([[M4_MODE_YYLINENO]], [[yyLessLineno(n, yyscanner);]]) + yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yyHoldChar; + yyscanner->yyCBufP = yyscanner->yytext_r + n; + yyscanner->yyHoldChar = *yyscanner->yyCBufP; + *yyscanner->yyCBufP = '\0'; yyscanner->yyleng_r = n; } @@ -2305,21 +2305,21 @@ static int yy_init_globals (yyscan_t yyscanner) { /* * This function is called from yylex_destroy(), so don't allocate here. */ - yyscanner->yy_buffer_stack = NULL; - yyscanner->yy_buffer_stack_top = 0; - yyscanner->yy_buffer_stack_max = 0; - yyscanner->yy_c_buf_p = NULL; + yyscanner->yyBufferStack = NULL; + yyscanner->yyBufferStackTop = 0; + yyscanner->yyBufferStackMax = 0; + yyscanner->yyCBufP = NULL; yyscanner->yy_init = false; - yyscanner->yy_start = 0; - yyscanner->yy_start_stack_ptr = 0; - yyscanner->yy_start_stack_depth = 0; - yyscanner->yy_start_stack = NULL; + yyscanner->yyStart = 0; + yyscanner->yyStartStackPtr = 0; + yyscanner->yyStartStackDepth = 0; + yyscanner->yyStartStack = NULL; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyscanner->yy_state_buf = 0; + yyscanner->yyStateBuf = 0; yyscanner->yy_state_ptr = 0; - yyscanner->yy_full_match = 0; + yyscanner->yyFullMatch = 0; yyscanner->yy_lp = 0; ]]) @@ -2405,22 +2405,22 @@ int yylex_destroy (yyscan_t yyscanner) { /* Pop the buffer stack, destroying each element. */ while(yy_current_buffer(yyscanner)) { yy_delete_buffer( yy_current_buffer(yyscanner), yyscanner ); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] = NULL; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = NULL; yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - yyfree(yyscanner->yy_buffer_stack, yyscanner); - yyscanner->yy_buffer_stack = NULL; + yyfree(yyscanner->yyBufferStack, yyscanner); + yyscanner->yyBufferStack = NULL; /* Destroy the start condition stack. */ - yyfree( yyscanner->yy_start_stack, yyscanner ); - yyscanner->yy_start_stack = NULL; + yyfree( yyscanner->yyStartStack, yyscanner ); + yyscanner->yyStartStack = NULL; m4_ifdef( [[M4_MODE_USES_REJECT]], [[ - yyfree ( yyscanner->yy_state_buf, yyscanner); - yyscanner->yy_state_buf = NULL; + yyfree ( yyscanner->yyStateBuf, yyscanner); + yyscanner->yyStateBuf = NULL; ]]) /* Reset the globals. This is important in a non-reentrant scanner so the next time diff --git a/src/skeletons.c b/src/skeletons.c index 63d07c1..84e3a4f 100644 --- a/src/skeletons.c +++ b/src/skeletons.c @@ -97,7 +97,7 @@ static bool boneseeker(const char *bone) void backend_by_name(const char *name) { - char *prefix_property; + const char *prefix_property; if (name != NULL) { if (strcmp(name, "nr") == 0) { backend = &backends[0]; -- cgit v1.2.1 From 8b0503e1684bcb7d586678fefce270f5f64e8ceb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 01:15:19 -0500 Subject: In C88 and Go back ends, remove remnant GENTABLES conditionals. --- src/c99-flex.skl | 74 +------------------------------------------------------- src/go-flex.skl | 74 +------------------------------------------------------- 2 files changed, 2 insertions(+), 146 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 6fffe3b..7f9d4e1 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -403,164 +403,92 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ %% [2.0] data tables for the DFA are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = - { +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { M4_HOOK_NXT_BODY -]], [[ -m4_define([[YY_NXT_LOLEN]], [[(M4_HOOK_NXT_ROWS)]]) -static const M4_HOOK_NXT_TYPE *yy_nxt =0; -]]) - ]]) m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl /* Table of booleans, true if rule could match eol. */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, M4_HOOK_EOLTABLE_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_NEED_ACCEPT]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, M4_HOOK_ACCEPT_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_ACCEPT_TYPE * yy_accept = 0; -]]) - ]]) m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl /* Character equivalence-class mapping */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, M4_HOOK_ECSTABLE_BODY[[]]m4_dnl }; -]], [[ -static const YY_CHAR * yy_ec = 0; -]]) - ]]) m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl /* Character meta-equivalence-class mappings */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, M4_HOOK_MECSTABLE_BODY[[]]m4_dnl }; -]], [[ -static const YY_CHAR * yy_meta = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl /* The transition table */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const struct yy_trans_info yy_transition[M4_HOOK_TRANSTABLE_SIZE] = { M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl }; -]], [[ -static const struct yy_trans_info *yy_transition = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl /* Table of pointers to start states. */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const struct yy_trans_info *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { M4_HOOK_STARTTABLE_BODY[[]]m4_dnl }; -]], [[ -static const struct yy_trans_info **yy_start_state_list =0; -]]) - ]]) m4_ifdef( [[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, M4_HOOK_ACCLIST_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_ACCLIST_TYPE * yy_acclist = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_BASE_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, M4_HOOK_BASE_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_BASE_TYPE * yy_base = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_DEF_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, M4_HOOK_DEF_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_DEF_TYPE * yy_def = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_YYNXT_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, M4_HOOK_YYNXT_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_YYNXT_TYPE * yy_nxt = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_CHK_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, M4_HOOK_CHK_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_CHK_TYPE * yy_chk = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const yy_state_type yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, M4_HOOK_NULTRANS_BODY[[]]m4_dnl }; -]], [[ -static const yy_state_type * yy_NUL_trans = 0; -]]) - ]]) m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl /* Rule to line-number mapping */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; -]]) - ]]) %% [3.0] static declarations conditional on mode switches go here diff --git a/src/go-flex.skl b/src/go-flex.skl index 6b8d3cc..11c7cbf 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -320,164 +320,92 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ %% [2.0] data tables for the DFA are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl -static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = - { +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { M4_HOOK_NXT_BODY -]], [[ -m4_define([[YY_NXT_LOLEN]], [[(M4_HOOK_NXT_ROWS)]]) -static const M4_HOOK_NXT_TYPE *yy_nxt =0; -]]) - ]]) m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl /* Table of booleans, true if rule could match eol. */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, M4_HOOK_EOLTABLE_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_EOLTABLE_TYPE * yy_rule_can_match_eol = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_NEED_ACCEPT]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, M4_HOOK_ACCEPT_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_ACCEPT_TYPE * yy_accept = 0; -]]) - ]]) m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl /* Character equivalence-class mapping */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, M4_HOOK_ECSTABLE_BODY[[]]m4_dnl }; -]], [[ -static const YY_CHAR * yy_ec = 0; -]]) - ]]) m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl /* Character meta-equivalence-class mappings */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, M4_HOOK_MECSTABLE_BODY[[]]m4_dnl }; -]], [[ -static const YY_CHAR * yy_meta = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl /* The transition table */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const struct yyTransInfo yyTransition[M4_HOOK_TRANSTABLE_SIZE] = { M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl }; -]], [[ -static const struct yyTransInfo *yyTransition = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl /* Table of pointers to start states. */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const struct yyTransInfo *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { M4_HOOK_STARTTABLE_BODY[[]]m4_dnl }; -]], [[ -static const struct yyTransInfo **yy_start_state_list =0; -]]) - ]]) m4_ifdef( [[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, M4_HOOK_ACCLIST_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_ACCLIST_TYPE * yy_acclist = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_BASE_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, M4_HOOK_BASE_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_BASE_TYPE * yy_base = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_DEF_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, M4_HOOK_DEF_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_DEF_TYPE * yy_def = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_YYNXT_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, M4_HOOK_YYNXT_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_YYNXT_TYPE * yy_nxt = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_CHK_TYPE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, M4_HOOK_CHK_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_CHK_TYPE * yy_chk = 0; -]]) - ]]) m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const yyStateType yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, M4_HOOK_NULTRANS_BODY[[]]m4_dnl }; -]], [[ -static const yyStateType * yy_NUL_trans = 0; -]]) - ]]) m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl /* Rule to line-number mapping */ -m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl }; -]], [[ -static const M4_HOOK_DEBUGTABLE_TYPE * yy_rule_linenum = 0; -]]) - ]]) %% [3.0] static declarations conditional on mode switches go here -- cgit v1.2.1 From ce66818db5a26f2e3f20e9232b40278174b8e443 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 01:28:58 -0500 Subject: Stop emitting unbalanced markup in the skeleton. It was fixed up by generating matcing unbalanced markuo in dfa.c, but a good idea this was not. --- src/c99-flex.skl | 2 +- src/cpp-flex.skl | 1 - src/dfa.c | 2 +- src/go-flex.skl | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 7f9d4e1..9a1f090 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -403,7 +403,7 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ %% [2.0] data tables for the DFA are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl -static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = M4_HOOK_NXT_BODY ]]) diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl index 2d7abe1..e33265d 100644 --- a/src/cpp-flex.skl +++ b/src/cpp-flex.skl @@ -887,7 +887,6 @@ int yyflexdebug = m4_ifdef([[M4_MODE_DEBUG]],[[1]],[[0]]); m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl m4_ifdef( [[M4_MODE_GENTABLES]],[[m4_dnl static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = - { M4_HOOK_NXT_BODY ]], [[ #undef YY_NXT_LOLEN diff --git a/src/dfa.c b/src/dfa.c index c281a7b..c223f3a 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -506,7 +506,7 @@ size_t ntod (void) out_str ("m4_define([[M4_HOOK_NXT_TYPE]], [[%s]])", ptype->name); out_dec ("m4_define([[M4_HOOK_NXT_ROWS]], [[%d]])", num_full_table_rows); outn ("m4_define([[M4_HOOK_NXT_BODY]], [[m4_dnl"); - + outn ("M4_HOOK_TABLE_OPENER"); if (gentables) outn ("M4_HOOK_TABLE_OPENER"); diff --git a/src/go-flex.skl b/src/go-flex.skl index 11c7cbf..aaae645 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -320,7 +320,7 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ %% [2.0] data tables for the DFA are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl -static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = { +static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = M4_HOOK_NXT_BODY ]]) -- cgit v1.2.1 From e502c5d485dbba21b81692d1ae8305a3378f0bff Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 01:55:55 -0500 Subject: More massaging of the fake Go skeleton in the direction of Go. --- src/go-flex.skl | 666 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 333 insertions(+), 333 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index aaae645..7cb93ea 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -86,14 +86,14 @@ m4_define([[yyless]], [[ YY_RESTORE_YY_MORE_OFFSET yyscanner->yyCBufP = yyCp = yyBp + yylessMacroArg - YY_MORE_ADJ; yyDoBeforeAction(yyscanner, yyCp, yyBp); /* set up yytext again */ - } while ( 0 ) + } while (0) ]]) %# Can't be a function given the context-arg treatment due to the goto. m4_define([[M4_HOOK_REJECT]], [[{ *yyCp = yyscanner->yyHoldChar; /* undo effects of setting up yytext */ yyCp = yyscanner->yyFullMatch; /* restore poss. backed-over text */ -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ +m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ yyscanner->yy_lp = yyscanner->yyFullLp; /* restore orig. accepting pos. */ yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ yyCurrentState = *yyscanner->yy_state_ptr; /* restore curr. state */ @@ -113,8 +113,8 @@ const int YY_FLEX_SUBMINOR_VERSION = FLEX_SUBMINOR_VERSION; /* STARTS platform-specific and compiler-specific definitions. */ -m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , -[[m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], , +m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], , +[[m4_ifdef([[M4_YY_NEVER_INTERACTIVE]], , [[/* Feature test macros. Flex uses functions that require a minimum set of * macros defined. As defining some macros may hide function declarations that * user code might use, be conservative and respect user's definitions as much @@ -212,8 +212,8 @@ const int YY_BUFFER_NORMAL = 1; const int YY_BUFFER_EOF_PENDING = 2; struct yy_buffer_state { - FILE *yy_input_file; - char *yy_ch_buf; /* input buffer */ + FILE *yyInputFile; + char *yyChBuf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB @@ -221,7 +221,7 @@ struct yy_buffer_state { */ int yy_buf_size; - /* Number of characters read into yy_ch_buf, not including EOB + /* Number of characters read into yyChBuf, not including EOB * characters. */ int yyNChars; @@ -253,19 +253,19 @@ struct yy_buffer_state { */ bool yy_fill_buffer; - int yy_buffer_status; + int yyBufferStatus; }; /* These forwards can simply deleted when poerting to a target language * with two-pass name resoltion. */ -void *yyalloc ( yy_size_t, yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); -void yyfree ( void *, yyscan_t yyscanner ); +void *yyalloc (yy_size_t, yyscan_t yyscanner); +void *yyrealloc (void *, yy_size_t, yyscan_t yyscanner); +void yyfree (void *, yyscan_t yyscanner); /* Begin user sect3 */ -m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ +m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ int yywrap(yyscan_t yyscanner) { return /*CONSTCOND*/1; } @@ -275,7 +275,7 @@ const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); typedef uint8_t YY_CHAR; -m4_ifdef( [[M4_MODE_FULLSPD]], [[m4_dnl +m4_ifdef([[M4_MODE_FULLSPD]], [[m4_dnl typedef const struct yy_trans_info *yyStateType; ]], [[ typedef int yyStateType; @@ -290,7 +290,7 @@ m4_define([[yytext_ptr]], [[yytext_r]]) %% [1.0] DFA -static int yy_get_next_buffer ( yyscan_t yyscanner ); +static int yy_get_next_buffer (yyscan_t yyscanner); struct yyTransInfo { /* We require that yy_verify and yy_nxt must be of the same size int. */ @@ -319,89 +319,89 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ %% [2.0] data tables for the DFA are inserted here -m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl +m4_ifdef([[M4_HOOK_NXT_ROWS]],[[m4_dnl static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = M4_HOOK_NXT_BODY ]]) -m4_ifdef( [[M4_MODE_YYLINENO]],[[m4_dnl +m4_ifdef([[M4_MODE_YYLINENO]],[[m4_dnl /* Table of booleans, true if rule could match eol. */ static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, M4_HOOK_EOLTABLE_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_NEED_ACCEPT]],[[m4_dnl +m4_ifdef([[M4_HOOK_NEED_ACCEPT]],[[m4_dnl static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, M4_HOOK_ACCEPT_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_MODE_USEECS]],[[m4_dnl +m4_ifdef([[M4_MODE_USEECS]],[[m4_dnl /* Character equivalence-class mapping */ static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, M4_HOOK_ECSTABLE_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_MODE_USEMECS]],[[m4_dnl +m4_ifdef([[M4_MODE_USEMECS]],[[m4_dnl /* Character meta-equivalence-class mappings */ static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, M4_HOOK_MECSTABLE_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl +m4_ifdef([[M4_HOOK_TRANSTABLE_SIZE]],[[m4_dnl /* The transition table */ static const struct yyTransInfo yyTransition[M4_HOOK_TRANSTABLE_SIZE] = { M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl +m4_ifdef([[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl /* Table of pointers to start states. */ static const struct yyTransInfo *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { M4_HOOK_STARTTABLE_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl +m4_ifdef([[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, M4_HOOK_ACCLIST_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_BASE_TYPE]],[[m4_dnl +m4_ifdef([[M4_HOOK_BASE_TYPE]],[[m4_dnl static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, M4_HOOK_BASE_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_DEF_TYPE]],[[m4_dnl +m4_ifdef([[M4_HOOK_DEF_TYPE]],[[m4_dnl static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, M4_HOOK_DEF_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_YYNXT_TYPE]],[[m4_dnl +m4_ifdef([[M4_HOOK_YYNXT_TYPE]],[[m4_dnl static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, M4_HOOK_YYNXT_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_CHK_TYPE]],[[m4_dnl +m4_ifdef([[M4_HOOK_CHK_TYPE]],[[m4_dnl static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, M4_HOOK_CHK_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl +m4_ifdef([[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl static const yyStateType yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, M4_HOOK_NULTRANS_BODY[[]]m4_dnl }; ]]) -m4_ifdef( [[M4_MODE_DEBUG]],[[m4_dnl +m4_ifdef([[M4_MODE_DEBUG]],[[m4_dnl /* Rule to line-number mapping */ static const M4_HOOK_DEBUGTABLE_TYPE yy_rule_linenum[M4_HOOK_DEBUGTABLE_SIZE] = { 0, M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl @@ -412,7 +412,7 @@ M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl M4_YY_SC_DEFS -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl +m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl %# These must match the values in the file flexdef.h %# of the flex source code, otherwise havoc will ensue. const int YY_TRAILING_MASK = 0x2000; @@ -432,7 +432,7 @@ struct yyguts_t { int yyNChars; int yyleng_r; char *yyCBufP; - bool yy_init; + bool yyInit; int yyStart; bool yyDidBufferSwitchOnEof; int yyStartStackPtr; @@ -444,20 +444,20 @@ struct yyguts_t { int yylineno_r; int yyflexdebug_r; -m4_ifdef( [[M4_MODE_USES_REJECT]], [[ +m4_ifdef([[M4_MODE_USES_REJECT]], [[ yyStateType *yyStateBuf; yyStateType *yy_state_ptr; char *yyFullMatch; int yy_lp; -m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl +m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl /* These are only needed for trailing context rules */ int yy_looking_for_trail_begin; int yyFullLp; int *yy_full_state; ]]) ]]) -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ char yytext_r[YYLMAX]; char *yytext_ptr; int yy_more_offset; @@ -467,23 +467,23 @@ m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ bool yy_more_flag; int yy_more_len; ]]) -m4_ifdef( [[M4_YY_BISON_LVAL]], [[ +m4_ifdef([[M4_YY_BISON_LVAL]], [[ YYSTYPE * yylval_r; ]]) -m4_ifdef( [[]], [[ +m4_ifdef([[]], [[ YYLTYPE * yylloc_r; ]]) }; /* end struct yyguts_t */ -m4_ifdef( [[M4_YY_BISON_LVAL]], +m4_ifdef([[M4_YY_BISON_LVAL]], [[ /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ m4_define([[yylval]], [[yyscanner->yylval_r]]) ]]) -m4_ifdef( [[]], +m4_ifdef([[]], [[ m4_define([[yylloc]], [[yyscanner->yylloc_r]]) ]]) @@ -492,7 +492,7 @@ m4_define([[yylloc]], [[yyscanner->yylloc_r]]) /* Returns the top of the stack, or NULL. */ yybuffer yy_current_buffer(yyscan_t yyscanner) { - return ( yyscanner->yyBufferStack \ + return (yyscanner->yyBufferStack \ ? yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] \ : NULL); } @@ -501,7 +501,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner) { yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; yyscanner->yytext_ptr = yyscanner->yyCBufP = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos; - yyscanner->yyin_r = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_input_file; + yyscanner->yyin_r = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile; yyscanner->yyHoldChar = *yyscanner->yyCBufP; } @@ -511,7 +511,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner) */ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) { - if ( b == NULL ) { + if (b == NULL) { return; } b->yyNChars = 0; @@ -520,31 +520,31 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) * a transition to the end-of-buffer state. The second causes * a jam in that state. */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + b->yyChBuf[0] = YY_END_OF_BUFFER_CHAR; + b->yyChBuf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[0]; + b->yy_buf_pos = &b->yyChBuf[0]; b->yyatbol_flag = true; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yyBufferStatus = YY_BUFFER_NEW; - if ( b == yy_current_buffer(yyscanner) ) { - yy_load_buffer_state( yyscanner ); + if (b == yy_current_buffer(yyscanner)) { + yy_load_buffer_state(yyscanner); } } void yy_flush_current_buffer(yyscan_t yyscanner) { - yy_flush_buffer( yy_current_buffer(yyscanner), yyscanner); + yy_flush_buffer(yy_current_buffer(yyscanner), yyscanner); } const int YY_EXIT_FAILURE = 2; -m4_ifdef( [[M4_YY_NO_YYPANIC]],, [[ +m4_ifdef([[M4_YY_NO_YYPANIC]],, [[ /* This gfunction has a magic rewrite rule */ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); + fprintf(stderr, "%s\n", msg); + exit(YY_EXIT_FAILURE); } ]]) @@ -563,8 +563,8 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ yyscanner->yyBufferStack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); - if ( yyscanner->yyBufferStack == NULL ) { - yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + if (yyscanner->yyBufferStack == NULL) { + yypanic("out of dynamic memory in yyensure_buffer_stack()", yyscanner); } memset(yyscanner->yyBufferStack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -584,7 +584,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); if (yyscanner->yyBufferStack == NULL) { - yypanic( "out of dynamic memory in yyensure_buffer_stack()", yyscanner ); + yypanic("out of dynamic memory in yyensure_buffer_stack()", yyscanner); } /* zero only the new slots.*/ memset(yyscanner->yyBufferStack + yyscanner->yyBufferStackMax, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -600,9 +600,9 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) { int oerrno = errno; - yy_flush_buffer( b, yyscanner); + yy_flush_buffer(b, yyscanner); - b->yy_input_file = file; + b->yyInputFile = file; b->yy_fill_buffer = true; /* If b is the current buffer, then yy_init_buffer was _probably_ @@ -614,17 +614,17 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) b->bs_yycolumn = 0; } -m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], +m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], [[ b->yy_is_interactive = true; ]], [[ - m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], + m4_ifdef([[M4_YY_NEVER_INTERACTIVE]], [[ b->yy_is_interactive = false; ]], [[ - b->yy_is_interactive = (file != NULL) && (isatty( fileno(file) ) > 0); + b->yy_is_interactive = (file != NULL) && (isatty(fileno(file)) > 0); ]]) ]]) errno = oerrno; @@ -640,22 +640,22 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) { yybuffer b; - b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); - if ( b == NULL ) { - yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); + b = (yybuffer) yyalloc(sizeof(struct yy_buffer_state), yyscanner); + if ( b == NULL) { + yypanic("out of dynamic memory in yy_create_buffer()", yyscanner); } b->yy_buf_size = size; - /* yy_ch_buf has to be 2 characters longer than the size given because + /* yyChBuf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); - if ( b->yy_ch_buf == NULL ) { - yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); + b->yyChBuf = (char *) yyalloc((yy_size_t) (b->yy_buf_size + 2), yyscanner); + if (b->yyChBuf == NULL) { + yypanic("out of dynamic memory in yy_create_buffer()", yyscanner); } b->yy_is_our_buffer = true; - yy_init_buffer( b, file, yyscanner); + yy_init_buffer(b, file, yyscanner); return b; } @@ -667,16 +667,16 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) { - if ( b == NULL ) { + if (b == NULL) { return; } - if ( b == yy_current_buffer(yyscanner) ) { /* Not sure if we should pop here. */ + if (b == yy_current_buffer(yyscanner)) { /* Not sure if we should pop here. */ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = (yybuffer) 0; } - if ( b->yy_is_our_buffer ) { - yyfree( (void *) b->yy_ch_buf, yyscanner ); + if (b->yy_is_our_buffer) { + yyfree((void *) b->yyChBuf, yyscanner); } - yyfree( (void *) b, yyscanner ); + yyfree((void *) b, yyscanner); } @@ -694,7 +694,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) yyensure_buffer_stack(yyscanner); /* This block is copied from yy_switch_to_buffer. */ - if ( yy_current_buffer(yyscanner) != NULL ) { + if (yy_current_buffer(yyscanner) != NULL) { /* Flush out information for old buffer. */ *yyscanner->yyCBufP = yyscanner->yyHoldChar; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos = yyscanner->yyCBufP; @@ -708,7 +708,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); + yy_load_buffer_state(yyscanner); yyscanner->yyDidBufferSwitchOnEof = true; } @@ -728,7 +728,7 @@ void yypop_buffer_state (yyscan_t yyscanner) --yyscanner->yyBufferStackTop; } if (yy_current_buffer(yyscanner) != NULL) { - yy_load_buffer_state( yyscanner ); + yy_load_buffer_state(yyscanner); yyscanner->yyDidBufferSwitchOnEof = true; } } @@ -742,17 +742,17 @@ void yypop_buffer_state (yyscan_t yyscanner) void yyrestart(FILE * input_file, yyscan_t yyscanner) { - if ( yy_current_buffer(yyscanner) == NULL ) { + if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yy_init_buffer( yy_current_buffer(yyscanner), input_file, yyscanner); - yy_load_buffer_state( yyscanner ); + yy_init_buffer(yy_current_buffer(yyscanner), input_file, yyscanner); + yy_load_buffer_state(yyscanner); } -static void yybumpline( yyscan_t yyscanner) { +static void yybumpline(yyscan_t yyscanner) { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno++; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yycolumn=0; } @@ -783,8 +783,8 @@ void yyecho(yyscan_t yyscanner) { fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); } -m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ -void yyunput( int c, yyscan_t yyscanner) +m4_ifdef([[M4_YY_NO_YYUNPUT]],, [[ +void yyunput(int c, yyscan_t yyscanner) { char *yyCp; @@ -793,16 +793,16 @@ void yyunput( int c, yyscan_t yyscanner) /* undo effects of setting up yytext */ *yyCp = yyscanner->yyHoldChar; - if ( yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf + 2 ) { + if (yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf + 2) { /* need to shift things up to make room */ /* +2 for EOB chars. */ int number_to_move = yyscanner->yyNChars + 2; - char *dest = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[ + char *dest = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size + 2]; char *source = - &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[number_to_move]; + &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[number_to_move]; - while ( source > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf ) { + while (source > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf) { *--dest = *--source; } yyCp += (int) (dest - source); @@ -810,16 +810,16 @@ void yyunput( int c, yyscan_t yyscanner) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars = (int) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size; - if ( yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf + 2 ) { - yypanic( "flex scanner push-back overflow", yyscanner); + if (yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf + 2) { + yypanic("flex scanner push-back overflow", yyscanner); } } *--yyCp = (char) c; -m4_ifdef( [[M4_MODE_YYLINENO]], +m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( c == '\n' ){ + if (c == '\n'){ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } ]]) @@ -835,12 +835,12 @@ int yyinput (yyscan_t yyscanner) *yyscanner->yyCBufP = yyscanner->yyHoldChar; - if ( *yyscanner->yyCBufP == YY_END_OF_BUFFER_CHAR ) { + if (*yyscanner->yyCBufP == YY_END_OF_BUFFER_CHAR) { /* yyCBufP now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( yyscanner->yyCBufP < &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars] ) { + if (yyscanner->yyCBufP < &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars]) { /* This was really a NUL. */ *yyscanner->yyCBufP = '\0'; } else { @@ -848,7 +848,7 @@ int yyinput (yyscan_t yyscanner) int offset = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr); ++yyscanner->yyCBufP; - switch ( yy_get_next_buffer( yyscanner ) ) { + switch (yy_get_next_buffer(yyscanner)) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a @@ -861,16 +861,16 @@ int yyinput (yyscan_t yyscanner) */ /* Reset buffer status. */ - yyrestart( yyscanner->yyin_r, yyscanner); + yyrestart(yyscanner->yyin_r, yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: - if ( yywrap( yyscanner ) ) { + if (yywrap(yyscanner)) { return 0; } - if ( ! yyscanner->yyDidBufferSwitchOnEof ) { - yyrestart( yyscanner->yyin_r, yyscanner ); + if (! yyscanner->yyDidBufferSwitchOnEof) { + yyrestart(yyscanner->yyin_r, yyscanner); } return yyinput(yyscanner); @@ -888,15 +888,15 @@ int yyinput (yyscan_t yyscanner) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag ) { - yybumpline( yyscanner ); + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag) { + yybumpline(yyscanner); } ]]) ]]) m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[ m4_ifdef([[M4_MODE_YYLINENO]], [[ - if ( c == '\n' ) { - yybumpline( yyscanner ); + if (c == '\n') { + yybumpline(yyscanner); } ]]) ]]) @@ -910,68 +910,68 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ * section 1. */ -m4_ifdef( [[M4_MODE_NO_YYWRAP]],, [[ -extern int yywrap ( yyscan_t yyscanner ); +m4_ifdef([[M4_MODE_NO_YYWRAP]],, [[ +extern int yywrap (yyscan_t yyscanner); ]]) -m4_ifdef( [[M4_YY_STACK_USED]], +m4_ifdef([[M4_YY_STACK_USED]], [[ - m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, + m4_ifdef([[M4_YY_NO_PUSH_STATE]],, [[ - static void yy_push_state ( int _new_state, yyscan_t yyscanner); + static void yy_push_state (int _new_state, yyscan_t yyscanner); ]]) - m4_ifdef( [[M4_YY_NO_POP_STATE]],, + m4_ifdef([[M4_YY_NO_POP_STATE]],, [[ - static void yy_pop_state ( yyscan_t yyscanner ); + static void yy_pop_state (yyscan_t yyscanner); ]]) - m4_ifdef( [[M4_YY_NO_TOP_STATE]],, + m4_ifdef([[M4_YY_NO_TOP_STATE]],, [[ - static int yy_top_state ( yyscan_t yyscanner ); + static int yy_top_state (yyscan_t yyscanner); ]]) ]], [[ -m4_define( [[M4_YY_NO_PUSH_STATE]]) -m4_define( [[M4_YY_NO_POP_STATE]]) -m4_define( [[M4_YY_NO_TOP_STATE]]) +m4_define([[M4_YY_NO_PUSH_STATE]]) +m4_define([[M4_YY_NO_POP_STATE]]) +m4_define([[M4_YY_NO_TOP_STATE]]) ]]) -m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ +m4_ifdef([[M4_MODE_USER_YYREAD]],, [[ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { int result; -m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ +m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { - if( errno != EINTR) { - yypanic( "input in flex scanner failed", yyscanner); + while ((result = (int) read(fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size)) < 0) { + if(errno != EINTR) { + yypanic("input in flex scanner failed", yyscanner); break; } errno=0; clearerr(yyscanner->yyin_r); } ]]) -m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ - if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive ) { +m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive) { int c = '*'; int n; - for ( n = 0; n < max_size && - (c = getc( yyscanner->yyin_r )) != EOF && c != '\n'; ++n ) { + for (n = 0; n < max_size && + (c = getc(yyscanner->yyin_r)) != EOF && c != '\n'; ++n) { buf[n] = (char) c; } - if ( c == '\n' ) { + if (c == '\n') { buf[n++] = (char) c; } - if ( c == EOF && ferror( yyscanner->yyin_r ) ) { - yypanic( "input in flex scanner failed", yyscanner); + if (c == EOF && ferror(yyscanner->yyin_r)) { + yypanic("input in flex scanner failed", yyscanner); } result = n; } else { errno=0; - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { - if( errno != EINTR) { - yypanic( "input in flex scanner failed", yyscanner); + while ((result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + if(errno != EINTR) { + yypanic("input in flex scanner failed", yyscanner); break; } errno=0; @@ -997,7 +997,7 @@ M4_MODE_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { ]]) ]]) -m4_ifdef( [[M4_YY_NO_GET_LINENO]],, +m4_ifdef([[M4_YY_NO_GET_LINENO]],, [[ /** Get the current line number. * @param yyscanner The scanner object. @@ -1012,7 +1012,7 @@ int yyget_lineno (yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, +m4_ifdef([[M4_YY_NO_GET_COLUMN]],, [[ /** Get the current column number. * @param yyscanner The scanner object. @@ -1027,7 +1027,7 @@ int yyget_column (yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_GET_IN]],, +m4_ifdef([[M4_YY_NO_GET_IN]],, [[ /** Get the input stream. * @param yyscanner The scanner object. @@ -1037,7 +1037,7 @@ FILE *yyget_in (yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_GET_OUT]],, +m4_ifdef([[M4_YY_NO_GET_OUT]],, [[ /** Get the output stream. * @param yyscanner The scanner object. @@ -1047,7 +1047,7 @@ FILE *yyget_out (yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_GET_LENG]],, +m4_ifdef([[M4_YY_NO_GET_LENG]],, [[ /** Get the length of the current token. * @param yyscanner The scanner object. @@ -1060,7 +1060,7 @@ int yyget_leng (yyscan_t yyscanner) { /** Get the current token. * @param yyscanner The scanner object. */ -m4_ifdef( [[M4_YY_NO_GET_TEXT]],, +m4_ifdef([[M4_YY_NO_GET_TEXT]],, [[ char *yyget_text (yyscan_t yyscanner) { return yyscanner->yytext_r; @@ -1068,7 +1068,7 @@ char *yyget_text (yyscan_t yyscanner) { ]]) m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl -m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, +m4_ifdef([[M4_YY_NO_SET_EXTRA]],, [[ /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. @@ -1080,7 +1080,7 @@ void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { ]]) ]]) -m4_ifdef( [[M4_YY_NO_SET_LINENO]],, +m4_ifdef([[M4_YY_NO_SET_LINENO]],, [[ /** Set the current line number. * @param _line_number line number @@ -1090,14 +1090,14 @@ void yyset_lineno(int _line_number, yyscan_t yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); /* lineno is only valid if an input buffer exists. */ - if (cb == NULL ) { - yypanic( "yyset_lineno called with no buffer", yyscanner ); + if (cb == NULL) { + yypanic("yyset_lineno called with no buffer", yyscanner); } cb->bs_yylineno = _line_number; } ]]) -m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, +m4_ifdef([[M4_YY_NO_SET_COLUMN]],, [[ /** Set the current column. * @param _column_no column number @@ -1107,14 +1107,14 @@ void yyset_column(int _column_no, yyscan_t yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); /* column is only valid if an input buffer exists. */ - if (cb == NULL ) { - yypanic( "yyset_column called with no buffer", yyscanner ); + if (cb == NULL) { + yypanic("yyset_column called with no buffer", yyscanner); } cb->bs_yycolumn = _column_no; } ]]) -m4_ifdef( [[M4_YY_NO_SET_IN]],, +m4_ifdef([[M4_YY_NO_SET_IN]],, [[ /** Set the input stream. This does not discard the current * input buffer. @@ -1127,22 +1127,22 @@ void yyset_in(FILE * _in_str, yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_SET_OUT]],, +m4_ifdef([[M4_YY_NO_SET_OUT]],, [[ -void yyset_out( FILE * _out_str, yyscan_t yyscanner) { +void yyset_out(FILE * _out_str, yyscan_t yyscanner) { yyscanner->yyout_r = _out_str ; } ]]) -m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, +m4_ifdef([[M4_YY_NO_GET_DEBUG]],, [[ int yyget_debug (yyscan_t yyscanner) { return yyscanner->yyflexdebug_r; } ]]) -m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, +m4_ifdef([[M4_YY_NO_SET_DEBUG]],, [[ void yyset_debug(int _bdebug, yyscan_t yyscanner) { yyscanner->yyflexdebug_r = _bdebug ; @@ -1150,30 +1150,30 @@ void yyset_debug(int _bdebug, yyscan_t yyscanner) { ]]) m4_ifdef([[M4_YY_BISON_LVAL]], [[ -m4_ifdef( [[M4_YY_NO_GET_LVAL]],, +m4_ifdef([[M4_YY_NO_GET_LVAL]],, [[ YYSTYPE * yyget_lval (yyscan_t yyscanner) { return yylval; } ]]) -m4_ifdef( [[M4_YY_NO_SET_LVAL]],, +m4_ifdef([[M4_YY_NO_SET_LVAL]],, [[ void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { yylval = yylval_param; } ]]) -m4_ifdef( [[]], +m4_ifdef([[]], [[ -m4_ifdef( [[M4_YY_NO_GET_LLOC]],, +m4_ifdef([[M4_YY_NO_GET_LLOC]],, [[ YYLTYPE *yyget_lloc (yyscan_t yyscanner) { return yylloc; } ]]) -m4_ifdef( [[M4_YY_NO_SET_LLOC]],, +m4_ifdef([[M4_YY_NO_SET_LLOC]],, [[ void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { yylloc = yylloc_param; @@ -1192,27 +1192,27 @@ const int YY_START_STACK_INCR = 25; * easily add parameters. */ m4_ifdef([[YY_DECL]],, [[m4_dnl -m4_define( [[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) -m4_define( [[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) +m4_define([[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) +m4_define([[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) -m4_ifdef( [[M4_YY_BISON_LVAL]], +m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_dnl The bison pure parser is used. Redefine yylex to m4_dnl accept the lval parameter. - m4_define( [[M4_YY_LEX_PROTO]], [[\]] + m4_define([[M4_YY_LEX_PROTO]], [[\]] [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + m4_define([[M4_YY_LEX_DECLARATION]], [[\]] [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) ]]) -m4_ifdef( [[]], +m4_ifdef([[]], [[ m4_dnl Locations are used. yylex should also accept the ylloc parameter. - m4_define( [[M4_YY_LEX_PROTO]], [[\]] + m4_define([[M4_YY_LEX_PROTO]], [[\]] [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param, yyscan_t yyscanner)]]) - m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] + m4_define([[M4_YY_LEX_DECLARATION]], [[\]] [[(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)]]) ]]) @@ -1223,7 +1223,7 @@ m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ static void rule_check_bol(yyscan_t yyscanner) { - if ( yyscanner->yyleng_r > 0 ) { \ + if (yyscanner->yyleng_r > 0) { \ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); } } @@ -1243,26 +1243,26 @@ void yyDoBeforeAction(yyscan_t yyscanner, char *yyCp, char *yyBp) { yyscanner->yyHoldChar = *yyCp; \ *yyCp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if ( yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX ) \ - yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if ( yyscanner->yyleng_r >= YYLMAX ) \ - yypanic( "token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy( &yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if (yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX) \ + yypanic("token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if (yyscanner->yyleng_r >= YYLMAX) \ + yypanic("token too large, exceeds YYLMAX", yyscanner);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy(&yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy( yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy(yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ ]]) \ yyscanner->yyCBufP = yyCp; } -m4_ifdef( [[M4_MODE_YYLINENO]], [[ +m4_ifdef([[M4_MODE_YYLINENO]], [[ /* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro * and we can get at yy_act */ static void yyLessLineno(int n, yyscan_t yyscanner) { int yyl; - for ( yyl = n; yyl < yyscanner->yyleng_r; ++yyl ) { - if ( yyscanner->yytext_r[yyl] == '\n' ) { + for (yyl = n; yyl < yyscanner->yyleng_r; ++yyl) { + if (yyscanner->yytext_r[yyl] == '\n') { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } } @@ -1270,8 +1270,8 @@ static void yyLessLineno(int n, yyscan_t yyscanner) { static void yyLinenoRewindTo(char *yyCp, char *dst, yyscan_t yyscanner) { const char *p; - for ( p = yyCp-1; p >= dst; --p) { - if ( *p == '\n' ) { + for (p = yyCp-1; p >= dst; --p) { + if (*p == '\n') { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } } @@ -1279,17 +1279,17 @@ static void yyLinenoRewindTo(char *yyCp, char *dst, yyscan_t yyscanner) { ]]) void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { - if ( yy_current_buffer(yyscanner) == NULL ) { + if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive = is_interactive; } m4_ifdef([[M4_MODE_YYMORE_USED]], [[ -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} m4_define([[YY_MORE_ADJ]], [[0]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ @@ -1298,7 +1298,7 @@ yyscanner->yyleng_r -= yyscanner->yy_more_offset; } ]]) ]]) -m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) @@ -1311,10 +1311,10 @@ m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) void yysetbol(bool at_bol, yyscan_t yyscanner) { - if ( yy_current_buffer(yyscanner) == NULL ) { + if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = at_bol; } @@ -1336,10 +1336,10 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (yyscanner); - if ( yy_current_buffer(yyscanner) == new_buffer ) { + if (yy_current_buffer(yyscanner) == new_buffer) { return; } - if ( yy_current_buffer(yyscanner) ) { + if (yy_current_buffer(yyscanner)) { /* Flush out information for old buffer. */ *yyscanner->yyCBufP = yyscanner->yyHoldChar; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos = yyscanner->yyCBufP; @@ -1347,7 +1347,7 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = new_buffer; - yy_load_buffer_state( yyscanner ); + yy_load_buffer_state(yyscanner); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1358,7 +1358,7 @@ void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) } -m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, +m4_ifdef([[M4_YY_NO_SCAN_BUFFER]],, [[ /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer @@ -1370,33 +1370,33 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) { yybuffer b; - if ( size < 2 || + if (size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) { + base[size-1] != YY_END_OF_BUFFER_CHAR) { /* They forgot to leave room for the EOB's. */ return NULL; } - b = (yybuffer) yyalloc( sizeof( struct yy_buffer_state ), yyscanner ); - if ( b == NULL ) { - yypanic( "out of dynamic memory in yy_scan_buffer()", yyscanner ); + b = (yybuffer) yyalloc(sizeof(struct yy_buffer_state), yyscanner); + if (b == NULL) { + yypanic("out of dynamic memory in yy_scan_buffer()", yyscanner); } b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_buf_pos = b->yyChBuf = base; b->yy_is_our_buffer = false; - b->yy_input_file = NULL; + b->yyInputFile = NULL; b->yyNChars = b->yy_buf_size; b->yy_is_interactive = false; b->yyatbol_flag = true; b->yy_fill_buffer = false; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yyBufferStatus = YY_BUFFER_NEW; - yy_switch_to_buffer( b, yyscanner ); + yy_switch_to_buffer(b, yyscanner); return b; } ]]) -m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, +m4_ifdef([[M4_YY_NO_SCAN_BYTES]],, [[ /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. @@ -1413,18 +1413,18 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n, yyscanner ); - if ( buf == 0 ) { - yypanic( "out of dynamic memory in yy_scan_bytes()", yyscanner ); + buf = (char *) yyalloc(n, yyscanner); + if (buf == 0) { + yypanic("out of dynamic memory in yy_scan_bytes()", yyscanner); } - for ( i = 0; i < _yybytes_len; ++i ) { + for (i = 0; i < _yybytes_len; ++i) { buf[i] = yybytes[i]; } buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n, yyscanner); - if ( b == NULL ) { - yypanic( "bad buffer in yy_scan_bytes()", yyscanner ); + b = yy_scan_buffer(buf, n, yyscanner); + if (b == NULL) { + yypanic("bad buffer in yy_scan_bytes()", yyscanner); } /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -1435,7 +1435,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann } ]]) -m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, +m4_ifdef([[M4_YY_NO_SCAN_STRING]],, [[ /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. @@ -1447,7 +1447,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, */ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) { - return yy_scan_bytes( yystr, (int) strlen(yystr), yyscanner); + return yy_scan_bytes(yystr, (int) strlen(yystr), yyscanner); } ]]) @@ -1460,17 +1460,17 @@ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) */ static int yy_get_next_buffer (yyscan_t yyscanner) { - char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf; + char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf; char *source = yyscanner->yytext_ptr; int number_to_move, i; int ret_val; - if ( yyscanner->yyCBufP > &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars + 1] ) { - yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); + if (yyscanner->yyCBufP > &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1]) { + yypanic("fatal flex scanner internal error--end of buffer missed", yyscanner); } - if ( !yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_fill_buffer ) { + if (!yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_fill_buffer) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyscanner->yyCBufP - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { + if (yyscanner->yyCBufP - yyscanner->yytext_ptr - YY_MORE_ADJ == 1) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ @@ -1488,10 +1488,10 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* First move last chars to start of buffer. */ number_to_move = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr - 1); - for ( i = 0; i < number_to_move; ++i ) { + for (i = 0; i < number_to_move; ++i) { *(dest++) = *(source++); } - if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus == YY_BUFFER_EOF_PENDING) { /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ @@ -1500,61 +1500,61 @@ static int yy_get_next_buffer (yyscan_t yyscanner) int num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size - number_to_move - 1; - while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ -m4_ifdef( [[M4_MODE_USES_REJECT]], + while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */ +m4_ifdef([[M4_MODE_USES_REJECT]], [[ yypanic( - "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); + "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner); ]], [[ /* just a shorter name for the current buffer */ yybuffer b = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]; int yyCBufP_offset = - (int) (yyscanner->yyCBufP - b->yy_ch_buf); + (int) (yyscanner->yyCBufP - b->yyChBuf); - if ( b->yy_is_our_buffer ) { + if (b->yy_is_our_buffer) { int new_size = b->yy_buf_size * 2; - if ( new_size <= 0 ) { + if (new_size <= 0) { b->yy_buf_size += b->yy_buf_size / 8; } else { b->yy_buf_size *= 2; } - b->yy_ch_buf = (char *) + b->yyChBuf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + yyrealloc((void *) b->yyChBuf, + (yy_size_t) (b->yy_buf_size + 2), yyscanner); } else { /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; + b->yyChBuf = NULL; } - if ( b->yy_ch_buf == NULL ) { + if (b->yyChBuf == NULL) { yypanic("fatal error - scanner input buffer overflow", yyscanner); } - yyscanner->yyCBufP = &b->yy_ch_buf[yyCBufP_offset]; + yyscanner->yyCBufP = &b->yyChBuf[yyCBufP_offset]; num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size - number_to_move - 1; ]]) } - if ( num_to_read > YY_READ_BUF_SIZE ) { + if (num_to_read > YY_READ_BUF_SIZE) { num_to_read = YY_READ_BUF_SIZE; } /* Read in more data. */ - yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[number_to_move], num_to_read, yyscanner); + yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[number_to_move], num_to_read, yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } - if ( yyscanner->yyNChars == 0 ) { - if ( number_to_move == YY_MORE_ADJ ) { + if (yyscanner->yyNChars == 0) { + if (number_to_move == YY_MORE_ADJ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyscanner->yyin_r, yyscanner); + yyrestart(yyscanner->yyin_r, yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = YY_BUFFER_EOF_PENDING; } } else { @@ -1563,43 +1563,43 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], if ((yyscanner->yyNChars + number_to_move) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = yyscanner->yyNChars + number_to_move + (yyscanner->yyNChars >> 1); - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf = (char *) yyrealloc( - (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf == NULL ) { - yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf = (char *) yyrealloc( + (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf, (yy_size_t) new_size, yyscanner); + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf == NULL) { + yypanic("out of dynamic memory in yy_get_next_buffer()", yyscanner); } /* "- 2" to take care of EOB's */ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size = (int) (new_size - 2); } yyscanner->yyNChars += number_to_move; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; - yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[0]; + yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[0]; return ret_val; } -m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, +m4_ifdef([[M4_YY_NO_PUSH_STATE]],, [[ static void yy_push_state(int _new_state, yyscan_t yyscanner) { - if ( yyscanner->yyStartStackPtr >= yyscanner->yyStartStackDepth ) { + if (yyscanner->yyStartStackPtr >= yyscanner->yyStartStackDepth) { yy_size_t new_size; yyscanner->yyStartStackDepth += YY_START_STACK_INCR; - new_size = (yy_size_t) yyscanner->yyStartStackDepth * sizeof( int ); + new_size = (yy_size_t) yyscanner->yyStartStackDepth * sizeof(int); - if ( yyscanner->yyStartStack == NULL ) { - yyscanner->yyStartStack = (int *) yyalloc( new_size, yyscanner ); + if (yyscanner->yyStartStack == NULL) { + yyscanner->yyStartStack = (int *) yyalloc(new_size, yyscanner); } else { yyscanner->yyStartStack = (int *) yyrealloc( - (void *) yyscanner->yyStartStack, new_size, yyscanner ); + (void *) yyscanner->yyStartStack, new_size, yyscanner); } - if ( yyscanner->yyStartStack == NULL ) { - yypanic( "out of memory expanding start-condition stack", yyscanner); + if (yyscanner->yyStartStack == NULL) { + yypanic("out of memory expanding start-condition stack", yyscanner); } } yyscanner->yyStartStack[yyscanner->yyStartStackPtr++] = yystart(yyscanner); @@ -1609,19 +1609,19 @@ static void yy_push_state(int _new_state, yyscan_t yyscanner) ]]) -m4_ifdef( [[M4_YY_NO_POP_STATE]],, +m4_ifdef([[M4_YY_NO_POP_STATE]],, [[ static void yy_pop_state (yyscan_t yyscanner) { - if ( --yyscanner->yyStartStackPtr < 0 ) { - yypanic( "start-condition stack underflow", yyscanner ); + if (--yyscanner->yyStartStackPtr < 0) { + yypanic("start-condition stack underflow", yyscanner); } yybegin(yyscanner->yyStartStack[yyscanner->yyStartStackPtr], yyscanner); } ]]) -m4_ifdef( [[M4_YY_NO_TOP_STATE]],, +m4_ifdef([[M4_YY_NO_TOP_STATE]],, [[ static int yy_top_state (yyscan_t yyscanner) { @@ -1636,10 +1636,10 @@ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* Generate code to keep backing-up information. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ - if ( yyCurrentState[-1].yy_nxt ) { + if (yyCurrentState[-1].yy_nxt) { ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - if ( yy_accept[yyCurrentState] ) { + if (yy_accept[yyCurrentState]) { ]]) yyscanner->yy_last_accepting_state = yyCurrentState; yyscanner->yy_last_accepting_cpos = yyCp; @@ -1665,7 +1665,7 @@ m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ */ M4_GEN_BACKING_UP - while ( yy_chk[yy_base[yyCurrentState] + yy_c] != yyCurrentState ) { + while (yy_chk[yy_base[yyCurrentState] + yy_c] != yyCurrentState) { yyCurrentState = (int) yy_def[yyCurrentState]; m4_ifdef([[M4_MODE_USEMECS]], [[ @@ -1696,7 +1696,7 @@ m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ yyCurrentState = yyscanner->yyStart; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState += yyatbol(yyscanner);]]) /* Set up for storing up states. */ - m4_ifdef( [[M4_MODE_USES_REJECT]], [[ + m4_ifdef([[M4_MODE_USES_REJECT]], [[ yyscanner->yy_state_ptr = yyscanner->yyStateBuf; *yyscanner->yy_state_ptr++ = yyCurrentState; ]]) @@ -1708,9 +1708,9 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ const struct yyTransInfo *yyTransInfo; YY_CHAR yy_c; - for ( yy_c = $1; + for (yy_c = $1; (yyTransInfo = &yyCurrentState[yy_c])->yy_verify == yy_c; - yy_c = $2 ) + yy_c = $2) { yyCurrentState += yyTransInfo->yy_nxt; @@ -1734,7 +1734,7 @@ static yyStateType yyGetPreviousState (yyscan_t yyscanner) { char *yyCp; M4_GEN_START_STATE - for ( yyCp = yyscanner->yytext_ptr + YY_MORE_ADJ; yyCp < yyscanner->yyCBufP; ++yyCp ) { + for (yyCp = yyscanner->yytext_ptr + YY_MORE_ADJ; yyCp < yyscanner->yyCBufP; ++yyCp) { /* Generate the code to find the next state. */ m4_ifdef([[M4_MODE_NO_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[(*yyCp ? M4_EC(YY_SC_TO_UI(*yyCp)) : YY_NUL_EC)]])]]) m4_ifdef([[M4_MODE_NULTRANS]], [[m4_define([[CHAR_MAP_3]], [[M4_EC(YY_SC_TO_UI(*yyCp))]])]]) @@ -1742,7 +1742,7 @@ static yyStateType yyGetPreviousState (yyscan_t yyscanner) { m4_ifdef([[M4_MODE_NULTRANS]], [[ /* Compressed tables back up *before* they match. */ m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_BACKING_UP]]) - if ( *yyCp ) { + if (*yyCp) { ]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ @@ -1770,7 +1770,7 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis - * next_state = yy_try_NUL_trans( current_state ); + * next_state = yy_try_NUL_trans(current_state); */ static yyStateType yy_try_NUL_trans(yyStateType yyCurrentState, yyscan_t yyscanner) { @@ -1819,7 +1819,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], [[ * actually make. If we stack it on a jam, then * the state stack and yyCBufP get out of sync. */ - if ( ! yyIsJam ) { + if (! yyIsJam) { *yyscanner->yy_state_ptr++ = yyCurrentState; } ]]) @@ -1833,7 +1833,7 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ * compressed tables have *already* done such backing up, so * we needn't bother with it again. */ - if ( ! yyIsJam ) { + if (! yyIsJam) { M4_GEN_BACKING_UP } ]]) @@ -1849,59 +1849,59 @@ YY_DECL { char *yyCp, *yyBp; int yy_act; -m4_ifdef( [[M4_YY_BISON_LVAL]], +m4_ifdef([[M4_YY_BISON_LVAL]], [[ yylval = yylval_param; ]]) -m4_ifdef( [[]], +m4_ifdef([[]], [[ yylloc = yylloc_param; ]]) - if ( !yyscanner->yy_init ) { - yyscanner->yy_init = true; + if (!yyscanner->yyInit) { + yyscanner->yyInit = true; m4_ifdef([[YY_USER_INIT]], [[YY_USER_INIT]]) -m4_ifdef( [[M4_MODE_USES_REJECT]], +m4_ifdef([[M4_MODE_USES_REJECT]], [[ /* Create the reject buffer large enough to save one state per allowed character. */ - if ( yyscanner->yyStateBuf == NULL ) { + if (yyscanner->yyStateBuf == NULL) { yyscanner->yyStateBuf = (yyStateType *)yyalloc(YY_STATE_BUF_SIZE, yyscanner); } - if ( yyscanner->yyStateBuf == NULL) { - yypanic( "out of dynamic memory in yylex()", yyscanner); + if (yyscanner->yyStateBuf == NULL) { + yypanic("out of dynamic memory in yylex()", yyscanner); } ]]) - if ( yyscanner->yyStart == 0 ) { + if (yyscanner->yyStart == 0) { yyscanner->yyStart = 1; /* first start state */ } - if ( yyscanner->yyin_r == NULL ) { + if (yyscanner->yyin_r == NULL) { yyscanner->yyin_r = stdin; } - if ( yyscanner->yyout_r == NULL ) { + if (yyscanner->yyout_r == NULL) { yyscanner->yyout_r = stdout; } - if ( yy_current_buffer(yyscanner) == NULL ) { + if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yy_load_buffer_state( yyscanner ); + yy_load_buffer_state(yyscanner); } /* open scope of user declarationns */ { %% [4.0] user's declarations go here - while ( /*CONSTCOND*/1 ) { /* loops until end-of-file is reached */ -m4_ifdef( [[M4_MODE_YYMORE_USED]], [[ -m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ + while (/*CONSTCOND*/1) { /* loops until end-of-file is reached */ +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ yyscanner->yy_more_len = 0; - if ( yyscanner->yy_more_flag ) { + if (yyscanner->yy_more_flag) { yyscanner->yy_more_len = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr); yyscanner->yy_more_flag = false; } @@ -1912,7 +1912,7 @@ m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ /* Support of yytext. */ *yyCp = yyscanner->yyHoldChar; - /* yyBp points to the position in yy_ch_buf of the start of + /* yyBp points to the position in yyChBuf of the start of * the current run. */ yyBp = yyCp; @@ -1944,8 +1944,8 @@ m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ ++yyCp; } - m4_ifdef([[M4_MODE_INTERACTIVE]], [[while ( yy_base[yyCurrentState] != YY_JAMBASE );]]) - m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while ( yyCurrentState != YY_JAMSTATE );]]) + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while (yy_base[yyCurrentState] != YY_JAMBASE);]]) + m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while (yyCurrentState != YY_JAMSTATE);]]) m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ @@ -1966,7 +1966,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ yyCurrentState = *--yyscanner->yy_state_ptr; yyscanner->yy_lp = yy_accept[yyCurrentState]; m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) - for ( ; ; ) { /* loop until we find out what rule we matched */ + for (; ;) { /* loop until we find out what rule we matched */ if (yyscanner->yy_lp && yyscanner->yy_lp < yy_accept[yyCurrentState + 1]) { yy_act = yy_acclist[yyscanner->yy_lp]; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ @@ -1976,7 +1976,7 @@ m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ yy_act &= ~YY_TRAILING_HEAD_MASK; break; } - } else if (( yy_act & YY_TRAILING_MASK) != 0) { + } else if ((yy_act & YY_TRAILING_MASK) != 0) { yyscanner->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; yyscanner->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; m4_ifdef([[M4_MODE_REAL_REJECT]], [[ @@ -2016,7 +2016,7 @@ m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ } /* close for */ ]]) m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yyCurrentState]; - if ( yy_act == 0 ) { /* have to back up */ + if (yy_act == 0) { /* have to back up */ yyCp = yyscanner->yy_last_accepting_cpos; yyCurrentState = yyscanner->yy_last_accepting_state; yy_act = yy_accept[yyCurrentState]; @@ -2025,15 +2025,15 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yyCurrentSta yyDoBeforeAction(yyscanner, yyCp, yyBp); -m4_ifdef( [[M4_MODE_YYLINENO]],[[ +m4_ifdef([[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yy_prev_more_offset]], [[yyscanner->yy_more_len]])]], [[0]])]]) - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { + if (yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act]) { int yyl; - for ( yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl ) { - if ( yyscanner->yytext_r[yyl] == '\n' ) { - yybumpline( yyscanner ); + for (yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl) { + if (yyscanner->yytext_r[yyl] == '\n') { + yybumpline(yyscanner); } } @@ -2043,24 +2043,24 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], do_action: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ - if ( yyscanner->yyflexdebug_r ) { - if ( yy_act == 0 ) { - fprintf( stderr, "--scanner backing up\n" ); - } else if ( yy_act < YY_NUM_RULES ) { - fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yyscanner->yytext_r ); - } else if ( yy_act == YY_NUM_RULES ) { - fprintf( stderr, "--accepting default rule (\"%s\")\n", - yyscanner->yytext_r ); - } else if ( yy_act == YY_NUM_RULES + 1 ) { - fprintf( stderr, "--(end of buffer or a NUL)\n" ); + if (yyscanner->yyflexdebug_r) { + if (yy_act == 0) { + fprintf(stderr, "--scanner backing up\n"); + } else if (yy_act < YY_NUM_RULES) { + fprintf(stderr, "--accepting rule at line %ld (\"%s\")\n", + (long)yy_rule_linenum[yy_act], yyscanner->yytext_r); + } else if (yy_act == YY_NUM_RULES) { + fprintf(stderr, "--accepting default rule (\"%s\")\n", + yyscanner->yytext_r); + } else if (yy_act == YY_NUM_RULES + 1) { + fprintf(stderr, "--(end of buffer or a NUL)\n"); } else { - fprintf( stderr, "--EOF (start condition %d)\n", yystart(yyscanner) ); + fprintf(stderr, "--EOF (start condition %d)\n", yystart(yyscanner)); } } ]]) - switch ( yy_act ) { /* beginning of action switch */ + switch (yy_act) { /* beginning of action switch */ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case 0: /* must back up */ @@ -2082,13 +2082,13 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yyCp - yyscanner->yytext_ptr) - 1; + int yyAmountOfMatchedText = (int) (yyCp - yyscanner->yytext_ptr) - 1; /* Undo the effects of yyDoBeforeAction(). */ *yyCp = yyscanner->yyHoldChar; YY_RESTORE_YY_MORE_OFFSET - if ( yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status == YY_BUFFER_NEW ) { + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus == YY_BUFFER_NEW) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called @@ -2099,8 +2099,8 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * back-up) that will match for the new input source. */ yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_input_file = yyscanner->yyin_r; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buffer_status = YY_BUFFER_NORMAL; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile = yyscanner->yyin_r; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = YY_BUFFER_NORMAL; } /* Note that here we test for yyCBufP "<=" to the position @@ -2110,12 +2110,12 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * end-of-buffer state). Contrast this with the test * in input(). */ - if ( yyscanner->yyCBufP <= &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars] ) { /* This was really a NUL. */ + if (yyscanner->yyCBufP <= &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars]) { /* This was really a NUL. */ yyStateType yy_next_state; - yyscanner->yyCBufP = yyscanner->yytext_ptr + yy_amount_of_matched_text; + yyscanner->yyCBufP = yyscanner->yytext_ptr + yyAmountOfMatchedText; - yyCurrentState = yyGetPreviousState( yyscanner ); + yyCurrentState = yyGetPreviousState(yyscanner); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -2126,11 +2126,11 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * will run more slowly). */ - yy_next_state = yy_try_NUL_trans( yyCurrentState, yyscanner); + yy_next_state = yy_try_NUL_trans(yyCurrentState, yyscanner); yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; - if ( yy_next_state ) { + if (yy_next_state) { /* Consume the NUL. */ yyCp = ++yyscanner->yyCBufP; yyCurrentState = yy_next_state; @@ -2161,11 +2161,11 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ goto yy_find_action; } } else { /* not a NUL */ - switch ( yy_get_next_buffer( yyscanner ) ) { + switch (yy_get_next_buffer(yyscanner)) { case EOB_ACT_END_OF_FILE: yyscanner->yyDidBufferSwitchOnEof = false; - if ( yywrap( yyscanner ) ) { + if (yywrap(yyscanner)) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up @@ -2180,16 +2180,16 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ yy_act = YY_STATE_EOF(yystart(yyscanner)); goto do_action; } else { - if ( ! yyscanner->yyDidBufferSwitchOnEof ) { - yyrestart( yyscanner->yyin_r, yyscanner ); + if (! yyscanner->yyDidBufferSwitchOnEof) { + yyrestart(yyscanner->yyin_r, yyscanner); } } break; case EOB_ACT_CONTINUE_SCAN: yyscanner->yyCBufP = - yyscanner->yytext_ptr + yy_amount_of_matched_text; + yyscanner->yytext_ptr + yyAmountOfMatchedText; - yyCurrentState = yyGetPreviousState( yyscanner ); + yyCurrentState = yyGetPreviousState(yyscanner); yyCp = yyscanner->yyCBufP; yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; @@ -2197,9 +2197,9 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ case EOB_ACT_LAST_MATCH: yyscanner->yyCBufP = - &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_ch_buf[yyscanner->yyNChars]; + &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars]; - yyCurrentState = yyGetPreviousState( yyscanner ); + yyCurrentState = yyGetPreviousState(yyscanner); yyCp = yyscanner->yyCBufP; yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; @@ -2209,7 +2209,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ break; } /* case YY_END_OF_BUFFER */ default: - yypanic("fatal flex scanner internal error--no action found", yyscanner); + yypanic("fatal flex scanner internal error--no action found", yyscanner); } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ @@ -2237,13 +2237,13 @@ static int yy_init_globals (yyscan_t yyscanner) { yyscanner->yyBufferStackTop = 0; yyscanner->yyBufferStackMax = 0; yyscanner->yyCBufP = NULL; - yyscanner->yy_init = false; + yyscanner->yyInit = false; yyscanner->yyStart = 0; yyscanner->yyStartStackPtr = 0; yyscanner->yyStartStackDepth = 0; yyscanner->yyStartStack = NULL; -m4_ifdef( [[M4_MODE_USES_REJECT]], +m4_ifdef([[M4_MODE_USES_REJECT]], [[ yyscanner->yyStateBuf = 0; yyscanner->yy_state_ptr = 0; @@ -2251,7 +2251,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yyscanner->yy_lp = 0; ]]) -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ yyscanner->yytext_ptr = 0; yyscanner->yy_more_offset = 0; @@ -2279,7 +2279,7 @@ int yylex_init(yyscan_t* ptr_yy_globals) { return 1; } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc (sizeof(struct yyguts_t), NULL); if (*ptr_yy_globals == NULL) { errno = ENOMEM; @@ -2289,7 +2289,7 @@ int yylex_init(yyscan_t* ptr_yy_globals) { /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - return yy_init_globals ( *ptr_yy_globals ); + return yy_init_globals (*ptr_yy_globals); } m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl @@ -2300,7 +2300,7 @@ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ -int yylex_init_extra( M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { +int yylex_init_extra(M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals) { struct yyguts_t dummy_yyguts; yyset_extra (yy_user_defined, &dummy_yyguts); @@ -2310,7 +2310,7 @@ int yylex_init_extra( M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globa return 1; } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc (sizeof(struct yyguts_t), &dummy_yyguts); if (*ptr_yy_globals == NULL) { errno = ENOMEM; @@ -2323,7 +2323,7 @@ int yylex_init_extra( M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globa yyset_extra (yy_user_defined, *ptr_yy_globals); - return yy_init_globals ( *ptr_yy_globals ); + return yy_init_globals (*ptr_yy_globals); } ]]) @@ -2332,7 +2332,7 @@ int yylex_destroy (yyscan_t yyscanner) { /* Pop the buffer stack, destroying each element. */ while(yy_current_buffer(yyscanner)) { - yy_delete_buffer( yy_current_buffer(yyscanner), yyscanner ); + yy_delete_buffer(yy_current_buffer(yyscanner), yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = NULL; yypop_buffer_state(yyscanner); } @@ -2342,12 +2342,12 @@ int yylex_destroy (yyscan_t yyscanner) { yyscanner->yyBufferStack = NULL; /* Destroy the start condition stack. */ - yyfree( yyscanner->yyStartStack, yyscanner ); + yyfree(yyscanner->yyStartStack, yyscanner); yyscanner->yyStartStack = NULL; -m4_ifdef( [[M4_MODE_USES_REJECT]], +m4_ifdef([[M4_MODE_USES_REJECT]], [[ - yyfree ( yyscanner->yyStateBuf, yyscanner); + yyfree (yyscanner->yyStateBuf, yyscanner); yyscanner->yyStateBuf = NULL; ]]) @@ -2356,12 +2356,12 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], yy_init_globals(yyscanner); /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner, yyscanner ); + yyfree (yyscanner, yyscanner); yyscanner = NULL; return 0; } -m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, +m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, [[ void *yyalloc(yy_size_t size, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ @@ -2369,7 +2369,7 @@ void *yyalloc(yy_size_t size, yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, +m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, [[ void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ @@ -2377,7 +2377,7 @@ void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { } ]]) -m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +m4_ifdef([[M4_YY_NO_FLEX_FREE]],, [[ void yyfree(void * ptr, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ @@ -2388,7 +2388,7 @@ void yyfree(void * ptr, yyscan_t yyscanner) { * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - free( (char *) ptr ); + free((char *) ptr); } ]]) @@ -2396,8 +2396,8 @@ m4_ifdef([[M4_YY_MAIN]], [[ int main () { yyscan_t lexer; yylex_init(&lexer); - yylex( lexer ); - yylex_destroy( lexer); + yylex(lexer); + yylex_destroy(lexer); yylex(); return 0; -- cgit v1.2.1 From c1105abd8bd914c86c9a8e75330c501b227f1b56 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 06:05:23 -0500 Subject: In the Go back end, more moves towards Go-like names. Not touching the public interface yet. --- src/c99-flex.skl | 2 +- src/go-flex.skl | 661 +++++++++++++++++++++++++++---------------------------- 2 files changed, 328 insertions(+), 335 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 9a1f090..f4edf14 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -276,7 +276,7 @@ typedef struct yy_buffer_state *yybuffer; typedef size_t yy_size_t; -%# These are not part of the exported interface and cab safewky be renamed +%# These are not part of the exported interface and can safewly be renamed const int EOB_ACT_CONTINUE_SCAN = 0; const int EOB_ACT_END_OF_FILE = 1; const int EOB_ACT_LAST_MATCH = 2; diff --git a/src/go-flex.skl b/src/go-flex.skl index 7cb93ea..5c5e728 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -94,11 +94,11 @@ m4_define([[M4_HOOK_REJECT]], [[{ *yyCp = yyscanner->yyHoldChar; /* undo effects of setting up yytext */ yyCp = yyscanner->yyFullMatch; /* restore poss. backed-over text */ m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - yyscanner->yy_lp = yyscanner->yyFullLp; /* restore orig. accepting pos. */ - yyscanner->yy_state_ptr = yyscanner->yy_full_state; /* restore orig. state */ - yyCurrentState = *yyscanner->yy_state_ptr; /* restore curr. state */ + yyscanner->yyLp = yyscanner->yyFullLp; /* restore orig. accepting pos. */ + yyscanner->yyStatePtr = yyscanner->yyFullState; /* restore orig. state */ + yyCurrentState = *yyscanner->yyStatePtr; /* restore curr. state */ ]]) - ++yyscanner->yy_lp; + ++yyscanner->yyLp; goto find_rule; } ]]) @@ -172,7 +172,7 @@ const int YY_BUF_SIZE = m4_ifdef([[M4_MODE_YY_BUFSIZE]], [[M4_MODE_YY_BUFSIZE]] const int YY_NULL = 0; /* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. + * integer in range [0..255] for use as an array index. */ m4_define([[YY_SC_TO_UI]], [[((YY_CHAR)($1))]]) @@ -191,9 +191,7 @@ m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yyStateType))]]) typedef struct yy_buffer_state *yybuffer; -typedef size_t yy_size_t; - -%# These are not part of the exported interface and cab safewky be renamed +%# These are not part of the exported interface and can safely be renamed const int EOB_ACT_CONTINUE_SCAN = 0; const int EOB_ACT_END_OF_FILE = 1; const int EOB_ACT_LAST_MATCH = 2; @@ -214,12 +212,12 @@ const int YY_BUFFER_EOF_PENDING = 2; struct yy_buffer_state { FILE *yyInputFile; char *yyChBuf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ + char *yyBufPos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ - int yy_buf_size; + int yyInputBufSize; /* Number of characters read into yyChBuf, not including EOB * characters. @@ -230,20 +228,20 @@ struct yy_buffer_state { * and can realloc() it to grow it, and should free() it to * delete it. */ - bool yy_is_our_buffer; + bool yyIsOurBuffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use char-by-char * rather than a buffered read, to make sure we stop fetching input after * each newline. */ - bool yy_is_interactive; + bool yyIsInteractive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ - bool yyatbol_flag; + bool yyatbolFlag; int bs_yylineno; /**< The line count. */ int bs_yycolumn; /**< The column count. */ @@ -251,7 +249,7 @@ struct yy_buffer_state { /* Whether to try to fill the input buffer when we reach the * end of it. */ - bool yy_fill_buffer; + bool yyFillBuffer; int yyBufferStatus; }; @@ -259,8 +257,8 @@ struct yy_buffer_state { /* These forwards can simply deleted when poerting to a target language * with two-pass name resoltion. */ -void *yyalloc (yy_size_t, yyscan_t yyscanner); -void *yyrealloc (void *, yy_size_t, yyscan_t yyscanner); +void *yyalloc (size_t, yyscan_t yyscanner); +void *yyrealloc (void *, size_t, yyscan_t yyscanner); void yyfree (void *, yyscan_t yyscanner); /* Begin user sect3 */ @@ -293,18 +291,18 @@ m4_define([[yytext_ptr]], [[yytext_r]]) static int yy_get_next_buffer (yyscan_t yyscanner); struct yyTransInfo { - /* We require that yy_verify and yy_nxt must be of the same size int. */ + /* We require that yyVerify and yyNxt must be of the same size int. */ m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ - YY_OFFSET_TYPE yy_verify; + YY_OFFSET_TYPE yyVerify; - /* In cases where its sister yy_verify *is* a "yes, there is - * a transition", yy_nxt is the offset (in records) to the + /* In cases where its sister yyVerify *is* a "yes, there is + * a transition", yyNxt is the offset (in records) to the * next state. In most cases where there is no transition, - * the value of yy_nxt is irrelevant. If yy_nxt is the -1th - * record of a state, though, then yy_nxt is the action number + * the value of yyNxt is irrelevant. If yyNxt is the -1th + * record of a state, though, then yyNxt is the action number * for that state. */ - YY_OFFSET_TYPE yy_nxt; + YY_OFFSET_TYPE yyNxt; ]]) m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ /* We generate a bogus 'struct yyTransInfo' data type @@ -312,41 +310,41 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ * This is so we can compile "sizeof(struct yyTransInfo)" * in any scanner. */ - int32_t yy_verify; - int32_t yy_nxt; + int32_t yyVerify; + int32_t yyNxt; ]]) }; %% [2.0] data tables for the DFA are inserted here m4_ifdef([[M4_HOOK_NXT_ROWS]],[[m4_dnl -static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = +static const M4_HOOK_NXT_TYPE yyNxt[][M4_HOOK_NXT_ROWS] = M4_HOOK_NXT_BODY ]]) m4_ifdef([[M4_MODE_YYLINENO]],[[m4_dnl /* Table of booleans, true if rule could match eol. */ -static const M4_HOOK_EOLTABLE_TYPE yy_rule_can_match_eol[M4_HOOK_EOLTABLE_SIZE] = { 0, +static const M4_HOOK_EOLTABLE_TYPE yyRuleCanMatchEOL[M4_HOOK_EOLTABLE_SIZE] = { 0, M4_HOOK_EOLTABLE_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_NEED_ACCEPT]],[[m4_dnl -static const M4_HOOK_ACCEPT_TYPE yy_accept[M4_HOOK_ACCEPT_SIZE] = { 0, +static const M4_HOOK_ACCEPT_TYPE yyAccept[M4_HOOK_ACCEPT_SIZE] = { 0, M4_HOOK_ACCEPT_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_MODE_USEECS]],[[m4_dnl /* Character equivalence-class mapping */ -static const YY_CHAR yy_ec[M4_HOOK_ECSTABLE_SIZE] = { 0, +static const YY_CHAR yyEC[M4_HOOK_ECSTABLE_SIZE] = { 0, M4_HOOK_ECSTABLE_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_MODE_USEMECS]],[[m4_dnl /* Character meta-equivalence-class mappings */ -static const YY_CHAR yy_meta[M4_HOOK_MECSTABLE_SIZE] = { 0, +static const YY_CHAR yyMeta[M4_HOOK_MECSTABLE_SIZE] = { 0, M4_HOOK_MECSTABLE_BODY[[]]m4_dnl }; ]]) @@ -360,43 +358,43 @@ M4_HOOK_TRANSTABLE_BODY[[]]m4_dnl m4_ifdef([[M4_HOOK_STARTTABLE_SIZE]],[[m4_dnl /* Table of pointers to start states. */ -static const struct yyTransInfo *yy_start_state_list[M4_HOOK_STARTTABLE_SIZE] = { +static const struct yyTransInfo *yyStartStateList[M4_HOOK_STARTTABLE_SIZE] = { M4_HOOK_STARTTABLE_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_ACCLIST_TYPE]],[[m4_dnl -static const M4_HOOK_ACCLIST_TYPE yy_acclist[M4_HOOK_ACCLIST_SIZE] = { 0, +static const M4_HOOK_ACCLIST_TYPE yyAcclist[M4_HOOK_ACCLIST_SIZE] = { 0, M4_HOOK_ACCLIST_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_BASE_TYPE]],[[m4_dnl -static const M4_HOOK_BASE_TYPE yy_base[M4_HOOK_BASE_SIZE] = { 0, +static const M4_HOOK_BASE_TYPE yyBase[M4_HOOK_BASE_SIZE] = { 0, M4_HOOK_BASE_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_DEF_TYPE]],[[m4_dnl -static const M4_HOOK_DEF_TYPE yy_def[M4_HOOK_DEF_SIZE] = { 0, +static const M4_HOOK_DEF_TYPE yyDef[M4_HOOK_DEF_SIZE] = { 0, M4_HOOK_DEF_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_YYNXT_TYPE]],[[m4_dnl -static const M4_HOOK_YYNXT_TYPE yy_nxt[M4_HOOK_YYNXT_SIZE] = { 0, +static const M4_HOOK_YYNXT_TYPE yyNxt[M4_HOOK_YYNXT_SIZE] = { 0, M4_HOOK_YYNXT_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_CHK_TYPE]],[[m4_dnl -static const M4_HOOK_CHK_TYPE yy_chk[M4_HOOK_CHK_SIZE] = { 0, +static const M4_HOOK_CHK_TYPE yyChk[M4_HOOK_CHK_SIZE] = { 0, M4_HOOK_CHK_BODY[[]]m4_dnl }; ]]) m4_ifdef([[M4_HOOK_NULTRANS_SIZE]],[[m4_dnl -static const yyStateType yy_NUL_trans[M4_HOOK_NULTRANS_SIZE] = { 0, +static const yyStateType yyNULtrans[M4_HOOK_NULTRANS_SIZE] = { 0, M4_HOOK_NULTRANS_BODY[[]]m4_dnl }; ]]) @@ -435,37 +433,37 @@ struct yyguts_t { bool yyInit; int yyStart; bool yyDidBufferSwitchOnEof; - int yyStartStackPtr; + int yyStartStackOffset; int yyStartStackDepth; int *yyStartStack; - yyStateType yy_last_accepting_state; - char* yy_last_accepting_cpos; + yyStateType yyLastAcceptingState; + char* yyLastAcceptingCharPos; int yylineno_r; int yyflexdebug_r; m4_ifdef([[M4_MODE_USES_REJECT]], [[ yyStateType *yyStateBuf; - yyStateType *yy_state_ptr; + yyStateType *yyStatePtr; char *yyFullMatch; - int yy_lp; + int yyLp; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl /* These are only needed for trailing context rules */ - int yy_looking_for_trail_begin; + int yyLookingForTrailBegin; int yyFullLp; - int *yy_full_state; + int *yyFullState; ]]) ]]) m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ char yytext_r[YYLMAX]; char *yytext_ptr; - int yy_more_offset; - int yy_prev_more_offset; + int yyMoreOffset; + int yyPrevMoreOffset; ]], [[ char *yytext_r; - bool yy_more_flag; - int yy_more_len; + bool yyMoreFlag; + int yyMoreLen; ]]) m4_ifdef([[M4_YY_BISON_LVAL]], [[ YYSTYPE * yylval_r; @@ -500,7 +498,7 @@ yybuffer yy_current_buffer(yyscan_t yyscanner) { static void yy_load_buffer_state (yyscan_t yyscanner) { yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; - yyscanner->yytext_ptr = yyscanner->yyCBufP = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos; + yyscanner->yytext_ptr = yyscanner->yyCBufP = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufPos; yyscanner->yyin_r = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile; yyscanner->yyHoldChar = *yyscanner->yyCBufP; } @@ -523,9 +521,9 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) b->yyChBuf[0] = YY_END_OF_BUFFER_CHAR; b->yyChBuf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yyChBuf[0]; + b->yyBufPos = &b->yyChBuf[0]; - b->yyatbol_flag = true; + b->yyatbolFlag = true; b->yyBufferStatus = YY_BUFFER_NEW; if (b == yy_current_buffer(yyscanner)) { @@ -540,7 +538,7 @@ void yy_flush_current_buffer(yyscan_t yyscanner) { const int YY_EXIT_FAILURE = 2; m4_ifdef([[M4_YY_NO_YYPANIC]],, [[ -/* This gfunction has a magic rewrite rule */ +/* This function has a magic rewrite rule */ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ fprintf(stderr, "%s\n", msg); @@ -553,42 +551,42 @@ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { */ static void yyensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; + size_t numToAlloc; if (yyscanner->yyBufferStack == NULL) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + numToAlloc = 1; /* After all that talk, this was set to 1 anyways... */ yyscanner->yyBufferStack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*), yyscanner); + (numToAlloc * sizeof(struct yy_buffer_state*), yyscanner); if (yyscanner->yyBufferStack == NULL) { yypanic("out of dynamic memory in yyensure_buffer_stack()", yyscanner); } - memset(yyscanner->yyBufferStack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyscanner->yyBufferStack, 0, numToAlloc * sizeof(struct yy_buffer_state*)); - yyscanner->yyBufferStackMax = num_to_alloc; + yyscanner->yyBufferStackMax = numToAlloc; yyscanner->yyBufferStackTop = 0; return; } if (yyscanner->yyBufferStackTop >= (yyscanner->yyBufferStackMax) - 1) { /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; + size_t grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyscanner->yyBufferStackMax + grow_size; + numToAlloc = yyscanner->yyBufferStackMax + grow_size; yyscanner->yyBufferStack = (struct yy_buffer_state**)yyrealloc (yyscanner->yyBufferStack, - num_to_alloc * sizeof(struct yy_buffer_state*), + numToAlloc * sizeof(struct yy_buffer_state*), yyscanner); if (yyscanner->yyBufferStack == NULL) { yypanic("out of dynamic memory in yyensure_buffer_stack()", yyscanner); } /* zero only the new slots.*/ memset(yyscanner->yyBufferStack + yyscanner->yyBufferStackMax, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyscanner->yyBufferStackMax = num_to_alloc; + yyscanner->yyBufferStackMax = numToAlloc; } } @@ -603,7 +601,7 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) yy_flush_buffer(b, yyscanner); b->yyInputFile = file; - b->yy_fill_buffer = true; + b->yyFillBuffer = true; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. @@ -616,15 +614,15 @@ static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], [[ - b->yy_is_interactive = true; + b->yyIsInteractive = true; ]], [[ m4_ifdef([[M4_YY_NEVER_INTERACTIVE]], [[ - b->yy_is_interactive = false; + b->yyIsInteractive = false; ]], [[ - b->yy_is_interactive = (file != NULL) && (isatty(fileno(file)) > 0); + b->yyIsInteractive = (file != NULL) && (isatty(fileno(file)) > 0); ]]) ]]) errno = oerrno; @@ -636,7 +634,7 @@ m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], * @param yyscanner The scanner object. * @return the allocated buffer state. */ -yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) +yybuffer yy_create_buffer(FILE *file, int size, yyscan_t yyscanner) { yybuffer b; @@ -644,16 +642,16 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) if ( b == NULL) { yypanic("out of dynamic memory in yy_create_buffer()", yyscanner); } - b->yy_buf_size = size; + b->yyInputBufSize = size; /* yyChBuf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yyChBuf = (char *) yyalloc((yy_size_t) (b->yy_buf_size + 2), yyscanner); + b->yyChBuf = (char *) yyalloc((size_t) (b->yyInputBufSize + 2), yyscanner); if (b->yyChBuf == NULL) { yypanic("out of dynamic memory in yy_create_buffer()", yyscanner); } - b->yy_is_our_buffer = true; + b->yyIsOurBuffer = true; yy_init_buffer(b, file, yyscanner); @@ -671,9 +669,9 @@ void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) return; } if (b == yy_current_buffer(yyscanner)) { /* Not sure if we should pop here. */ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = (yybuffer) 0; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = (yybuffer)NULL; } - if (b->yy_is_our_buffer) { + if (b->yyIsOurBuffer) { yyfree((void *) b->yyChBuf, yyscanner); } yyfree((void *) b, yyscanner); @@ -697,7 +695,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) if (yy_current_buffer(yyscanner) != NULL) { /* Flush out information for old buffer. */ *yyscanner->yyCBufP = yyscanner->yyHoldChar; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos = yyscanner->yyCBufP; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufPos = yyscanner->yyCBufP; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } @@ -796,11 +794,10 @@ void yyunput(int c, yyscan_t yyscanner) if (yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf + 2) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = yyscanner->yyNChars + 2; + int numberToMove = yyscanner->yyNChars + 2; char *dest = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size + 2]; - char *source = - &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[number_to_move]; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize + 2]; + char *source = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove]; while (source > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf) { *--dest = *--source; @@ -808,7 +805,7 @@ void yyunput(int c, yyscan_t yyscanner) yyCp += (int) (dest - source); yyscanner->yytext_ptr += (int) (dest - source); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = - yyscanner->yyNChars = (int) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size; + yyscanner->yyNChars = (int) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize; if (yyCp < yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf + 2) { yypanic("flex scanner push-back overflow", yyscanner); @@ -819,7 +816,7 @@ void yyunput(int c, yyscan_t yyscanner) m4_ifdef([[M4_MODE_YYLINENO]], [[ - if (c == '\n'){ + if (c == '\n') { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } ]]) @@ -829,7 +826,7 @@ m4_ifdef([[M4_MODE_YYLINENO]], } ]]) -int yyinput (yyscan_t yyscanner) +int yyinput(yyscan_t yyscanner) { int c; @@ -886,9 +883,9 @@ int yyinput (yyscan_t yyscanner) yyscanner->yyHoldChar = *++yyscanner->yyCBufP; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = (c == '\n'); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = (c == '\n'); m4_ifdef([[M4_MODE_YYLINENO]], [[ - if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag) { + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag) { yybumpline(yyscanner); } ]]) @@ -918,7 +915,7 @@ m4_ifdef([[M4_YY_STACK_USED]], [[ m4_ifdef([[M4_YY_NO_PUSH_STATE]],, [[ - static void yy_push_state (int _new_state, yyscan_t yyscanner); + static void yy_push_state (int newState, yyscan_t yyscanner); ]]) m4_ifdef([[M4_YY_NO_POP_STATE]],, [[ @@ -936,14 +933,14 @@ m4_define([[M4_YY_NO_TOP_STATE]]) ]]) m4_ifdef([[M4_MODE_USER_YYREAD]],, [[ -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, +/* Gets input and stuffs it into "buf". Number of characters read, or YY_NULL, * is returned in "result". */ -static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { +static int yyread(char *buf, size_t maxSize, yyscan_t yyscanner) { int result; m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ((result = (int) read(fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size)) < 0) { + while ((result = (int) read(fileno(yyscanner->yyin_r), buf, (size_t) maxSize)) < 0) { if(errno != EINTR) { yypanic("input in flex scanner failed", yyscanner); break; @@ -953,10 +950,10 @@ m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ } ]]) m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ - if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive) { + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyIsInteractive) { int c = '*'; int n; - for (n = 0; n < max_size && + for (n = 0; n < maxSize && (c = getc(yyscanner->yyin_r)) != EOF && c != '\n'; ++n) { buf[n] = (char) c; } @@ -969,7 +966,7 @@ m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ result = n; } else { errno=0; - while ((result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + while ((result = (int) fread(buf, 1, (size_t) maxSize, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { if(errno != EINTR) { yypanic("input in flex scanner failed", yyscanner); break; @@ -991,7 +988,7 @@ m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -M4_MODE_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { +M4_MODE_EXTRA_TYPE yyget_extra(yyscan_t yyscanner) { return yyscanner->yyextra_r; } ]]) @@ -1002,7 +999,7 @@ m4_ifdef([[M4_YY_NO_GET_LINENO]],, /** Get the current line number. * @param yyscanner The scanner object. */ -int yyget_lineno (yyscan_t yyscanner) { +int yyget_lineno(yyscan_t yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); if (cb == NULL) { @@ -1071,11 +1068,11 @@ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl m4_ifdef([[M4_YY_NO_SET_EXTRA]],, [[ /** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. + * @param userDefined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { - yyscanner->yyextra_r = user_defined ; +void yyset_extra(M4_MODE_EXTRA_TYPE userDefined, yyscan_t yyscanner) { + yyscanner->yyextra_r = userDefined; } ]]) ]]) @@ -1083,34 +1080,34 @@ void yyset_extra(M4_MODE_EXTRA_TYPE user_defined, yyscan_t yyscanner) { m4_ifdef([[M4_YY_NO_SET_LINENO]],, [[ /** Set the current line number. - * @param _line_number line number + * @param lineNumber line number * @param yyscanner The scanner object. */ -void yyset_lineno(int _line_number, yyscan_t yyscanner) { +void yyset_lineno(int lineNumber, yyscan_t yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); /* lineno is only valid if an input buffer exists. */ if (cb == NULL) { yypanic("yyset_lineno called with no buffer", yyscanner); } - cb->bs_yylineno = _line_number; + cb->bs_yylineno = lineNumber; } ]]) m4_ifdef([[M4_YY_NO_SET_COLUMN]],, [[ /** Set the current column. - * @param _column_no column number + * @param columnNo column number * @param yyscanner The scanner object. */ -void yyset_column(int _column_no, yyscan_t yyscanner) { +void yyset_column(int columnNo, yyscan_t yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); /* column is only valid if an input buffer exists. */ if (cb == NULL) { yypanic("yyset_column called with no buffer", yyscanner); } - cb->bs_yycolumn = _column_no; + cb->bs_yycolumn = columnNo; } ]]) @@ -1118,41 +1115,41 @@ m4_ifdef([[M4_YY_NO_SET_IN]],, [[ /** Set the input stream. This does not discard the current * input buffer. - * @param _in_str A readable stream. + * @param inStream A readable stream. * @param yyscanner The scanner object. * @see yy_switch_to_buffer */ -void yyset_in(FILE * _in_str, yyscan_t yyscanner) { - yyscanner->yyin_r = _in_str ; +void yyset_in(FILE *inStream, yyscan_t yyscanner) { + yyscanner->yyin_r = inStream ; } ]]) m4_ifdef([[M4_YY_NO_SET_OUT]],, [[ -void yyset_out(FILE * _out_str, yyscan_t yyscanner) { - yyscanner->yyout_r = _out_str ; +void yyset_out(FILE *outStream, yyscan_t yyscanner) { + yyscanner->yyout_r = outStream ; } ]]) m4_ifdef([[M4_YY_NO_GET_DEBUG]],, [[ -int yyget_debug (yyscan_t yyscanner) { +int yyget_debug(yyscan_t yyscanner) { return yyscanner->yyflexdebug_r; } ]]) m4_ifdef([[M4_YY_NO_SET_DEBUG]],, [[ -void yyset_debug(int _bdebug, yyscan_t yyscanner) { - yyscanner->yyflexdebug_r = _bdebug ; +void yyset_debug(int bdebug, yyscan_t yyscanner) { + yyscanner->yyflexdebug_r = bdebug ; } ]]) m4_ifdef([[M4_YY_BISON_LVAL]], [[ m4_ifdef([[M4_YY_NO_GET_LVAL]],, [[ -YYSTYPE * yyget_lval (yyscan_t yyscanner) { +YYSTYPE *yyget_lval(yyscan_t yyscanner) { return yylval; } ]]) @@ -1224,7 +1221,7 @@ m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ static void rule_check_bol(yyscan_t yyscanner) { if (yyscanner->yyleng_r > 0) { \ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); } } ]]) @@ -1236,29 +1233,29 @@ static void rule_check_bol(yyscan_t yyscanner) { */ void yyDoBeforeAction(yyscan_t yyscanner, char *yyCp, char *yyBp) { yyscanner->yytext_ptr = yyBp; \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yy_more_len; \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yyMoreLen; \ yyscanner->yyleng_r = (int) (yyCp - yyscanner->yytext_ptr);]])]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yyCp - yyBp);]]) \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yyCp - yyBp);]]) \ yyscanner->yyHoldChar = *yyCp; \ *yyCp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if (yyscanner->yyleng_r + yyscanner->yy_more_offset >= YYLMAX) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if (yyscanner->yyleng_r + yyscanner->yyMoreOffset >= YYLMAX) \ yypanic("token too large, exceeds YYLMAX", yyscanner);]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if (yyscanner->yyleng_r >= YYLMAX) \ yypanic("token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy(&yyscanner->yytext_r[yyscanner->yy_more_offset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_prev_more_offset = yyscanner->yy_more_offset;]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yy_more_offset = 0;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy(&yyscanner->yytext_r[yyscanner->yyMoreOffset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yyMoreOffset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyPrevMoreOffset = yyscanner->yyMoreOffset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyMoreOffset = 0;]]) \ m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy(yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ ]]) \ yyscanner->yyCBufP = yyCp; } m4_ifdef([[M4_MODE_YYLINENO]], [[ -/* FIXME: gate on yy_rule_can_match_eol, this is no longer a macro - * and we can get at yy_act */ +/* FIXME: gate on yyRuleCanMatchEOL, this is no longer a macro + * and we can get at yyAct */ static void yyLessLineno(int n, yyscan_t yyscanner) { int yyl; for (yyl = n; yyl < yyscanner->yyleng_r; ++yyl) { @@ -1284,23 +1281,23 @@ void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_is_interactive = is_interactive; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyIsInteractive = is_interactive; } m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} +void yymore(yyscan_t yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext_r);} m4_define([[YY_MORE_ADJ]], [[0]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ -yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; -yyscanner->yyleng_r -= yyscanner->yy_more_offset; +yyscanner->yyMoreOffset = yyscanner->yyPrevMoreOffset; +yyscanner->yyleng_r -= yyscanner->yyMoreOffset; } ]]) ]]) m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} -m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) +void yymore(yyscan_t yyscanner) {yyscanner->yyMoreFlag = true;} +m4_define([[YY_MORE_ADJ]], [[yyscanner->yyMoreLen]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) ]]) @@ -1310,43 +1307,43 @@ m4_define([[YY_MORE_ADJ]], [[0]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) -void yysetbol(bool at_bol, yyscan_t yyscanner) { +void yysetbol(bool atBOL, yyscan_t yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); } - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag = at_bol; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = atBOL; } bool yyatbol(yyscan_t yyscanner) { - return (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbol_flag); + return (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag); } /** Switch to a different input buffer. - * @param new_buffer The new input buffer. + * @param newBuffer The new input buffer. * @param yyscanner The scanner object. */ -void yy_switch_to_buffer(yybuffer new_buffer, yyscan_t yyscanner) +void yy_switch_to_buffer(yybuffer newBuffer, yyscan_t yyscanner) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); + * yypush_buffer_state(newBuffer); */ yyensure_buffer_stack (yyscanner); - if (yy_current_buffer(yyscanner) == new_buffer) { + if (yy_current_buffer(yyscanner) == newBuffer) { return; } if (yy_current_buffer(yyscanner)) { /* Flush out information for old buffer. */ *yyscanner->yyCBufP = yyscanner->yyHoldChar; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_pos = yyscanner->yyCBufP; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufPos = yyscanner->yyCBufP; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = new_buffer; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = newBuffer; yy_load_buffer_state(yyscanner); /* We don't actually know whether we did this switch during @@ -1366,7 +1363,7 @@ m4_ifdef([[M4_YY_NO_SCAN_BUFFER]],, * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) +yybuffer yy_scan_buffer(char *base, size_t size, yyscan_t yyscanner) { yybuffer b; @@ -1380,14 +1377,14 @@ yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) if (b == NULL) { yypanic("out of dynamic memory in yy_scan_buffer()", yyscanner); } - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yyChBuf = base; - b->yy_is_our_buffer = false; + b->yyInputBufSize = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yyBufPos = b->yyChBuf = base; + b->yyIsOurBuffer = false; b->yyInputFile = NULL; - b->yyNChars = b->yy_buf_size; - b->yy_is_interactive = false; - b->yyatbol_flag = true; - b->yy_fill_buffer = false; + b->yyNChars = b->yyInputBufSize; + b->yyIsInteractive = false; + b->yyatbolFlag = true; + b->yyFillBuffer = false; b->yyBufferStatus = YY_BUFFER_NEW; yy_switch_to_buffer(b, yyscanner); @@ -1408,11 +1405,11 @@ m4_ifdef([[M4_YY_NO_SCAN_BYTES]],, yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { yybuffer b; char *buf; - yy_size_t n; + size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); + n = (size_t) (_yybytes_len + 2); buf = (char *) yyalloc(n, yyscanner); if (buf == 0) { yypanic("out of dynamic memory in yy_scan_bytes()", yyscanner); @@ -1429,28 +1426,12 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ - b->yy_is_our_buffer = true; + b->yyIsOurBuffer = true; return b; } ]]) -m4_ifdef([[M4_YY_NO_SCAN_STRING]],, -[[ -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) -{ - return yy_scan_bytes(yystr, (int) strlen(yystr), yyscanner); -} -]]) - /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: @@ -1462,13 +1443,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf; char *source = yyscanner->yytext_ptr; - int number_to_move, i; - int ret_val; + int numberToMove, i; + int retVal; if (yyscanner->yyCBufP > &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1]) { yypanic("fatal flex scanner internal error--end of buffer missed", yyscanner); } - if (!yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_fill_buffer) { + if (!yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyFillBuffer) { /* Don't try to fill the buffer, so this is an EOF. */ if (yyscanner->yyCBufP - yyscanner->yytext_ptr - YY_MORE_ADJ == 1) { /* We matched a single character, the EOB, so @@ -1486,9 +1467,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr - 1); + numberToMove = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr - 1); - for (i = 0; i < number_to_move; ++i) { + for (i = 0; i < numberToMove; ++i) { *(dest++) = *(source++); } if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus == YY_BUFFER_EOF_PENDING) { @@ -1498,7 +1479,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars = 0; } else { int num_to_read = - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size - number_to_move - 1; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - numberToMove - 1; while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */ m4_ifdef([[M4_MODE_USES_REJECT]], @@ -1513,18 +1494,18 @@ m4_ifdef([[M4_MODE_USES_REJECT]], int yyCBufP_offset = (int) (yyscanner->yyCBufP - b->yyChBuf); - if (b->yy_is_our_buffer) { - int new_size = b->yy_buf_size * 2; + if (b->yyIsOurBuffer) { + int newSize = b->yyInputBufSize * 2; - if (new_size <= 0) { - b->yy_buf_size += b->yy_buf_size / 8; + if (newSize <= 0) { + b->yyInputBufSize += b->yyInputBufSize / 8; } else { - b->yy_buf_size *= 2; + b->yyInputBufSize *= 2; } b->yyChBuf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc((void *) b->yyChBuf, - (yy_size_t) (b->yy_buf_size + 2), yyscanner); + (size_t) (b->yyInputBufSize + 2), yyscanner); } else { /* Can't grow it, we don't own it. */ b->yyChBuf = NULL; @@ -1534,8 +1515,8 @@ m4_ifdef([[M4_MODE_USES_REJECT]], } yyscanner->yyCBufP = &b->yyChBuf[yyCBufP_offset]; - num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size - - number_to_move - 1; + num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - + numberToMove - 1; ]]) } @@ -1543,89 +1524,105 @@ m4_ifdef([[M4_MODE_USES_REJECT]], num_to_read = YY_READ_BUF_SIZE; } /* Read in more data. */ - yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[number_to_move], num_to_read, yyscanner); + yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove], num_to_read, yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } if (yyscanner->yyNChars == 0) { - if (number_to_move == YY_MORE_ADJ) { - ret_val = EOB_ACT_END_OF_FILE; + if (numberToMove == YY_MORE_ADJ) { + retVal = EOB_ACT_END_OF_FILE; yyrestart(yyscanner->yyin_r, yyscanner); } else { - ret_val = EOB_ACT_LAST_MATCH; + retVal = EOB_ACT_LAST_MATCH; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = YY_BUFFER_EOF_PENDING; } } else { - ret_val = EOB_ACT_CONTINUE_SCAN; + retVal = EOB_ACT_CONTINUE_SCAN; } - if ((yyscanner->yyNChars + number_to_move) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size) { + if ((yyscanner->yyNChars + numberToMove) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyscanner->yyNChars + number_to_move + (yyscanner->yyNChars >> 1); + int newSize = yyscanner->yyNChars + numberToMove + (yyscanner->yyNChars >> 1); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf = (char *) yyrealloc( - (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf, (yy_size_t) new_size, yyscanner); + (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf, (size_t) newSize, yyscanner); if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf == NULL) { yypanic("out of dynamic memory in yy_get_next_buffer()", yyscanner); } /* "- 2" to take care of EOB's */ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yy_buf_size = (int) (new_size - 2); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize = (int) (newSize - 2); } - yyscanner->yyNChars += number_to_move; + yyscanner->yyNChars += numberToMove; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[0]; - return ret_val; + return retVal; } +m4_ifdef([[M4_YY_NO_SCAN_STRING]],, +[[ +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) +{ + return yy_scan_bytes(yystr, (int) strlen(yystr), yyscanner); +} +]]) + m4_ifdef([[M4_YY_NO_PUSH_STATE]],, [[ -static void yy_push_state(int _new_state, yyscan_t yyscanner) +static void yy_push_state(int newState, yyscan_t yyscanner) { - if (yyscanner->yyStartStackPtr >= yyscanner->yyStartStackDepth) { - yy_size_t new_size; + if (yyscanner->yyStartStackOffset >= yyscanner->yyStartStackDepth) { + size_t newSize; yyscanner->yyStartStackDepth += YY_START_STACK_INCR; - new_size = (yy_size_t) yyscanner->yyStartStackDepth * sizeof(int); + newSize = (size_t) yyscanner->yyStartStackDepth * sizeof(int); if (yyscanner->yyStartStack == NULL) { - yyscanner->yyStartStack = (int *) yyalloc(new_size, yyscanner); + yyscanner->yyStartStack = (int *) yyalloc(newSize, yyscanner); } else { yyscanner->yyStartStack = (int *) yyrealloc( - (void *) yyscanner->yyStartStack, new_size, yyscanner); + (void *) yyscanner->yyStartStack, newSize, yyscanner); } if (yyscanner->yyStartStack == NULL) { yypanic("out of memory expanding start-condition stack", yyscanner); } } - yyscanner->yyStartStack[yyscanner->yyStartStackPtr++] = yystart(yyscanner); + yyscanner->yyStartStack[yyscanner->yyStartStackOffset++] = yystart(yyscanner); - yybegin(_new_state, yyscanner); + yybegin(newState, yyscanner); } ]]) m4_ifdef([[M4_YY_NO_POP_STATE]],, [[ -static void yy_pop_state (yyscan_t yyscanner) +static void yy_pop_state(yyscan_t yyscanner) { - if (--yyscanner->yyStartStackPtr < 0) { + if (--yyscanner->yyStartStackOffset < 0) { yypanic("start-condition stack underflow", yyscanner); } - yybegin(yyscanner->yyStartStack[yyscanner->yyStartStackPtr], yyscanner); + yybegin(yyscanner->yyStartStack[yyscanner->yyStartStackOffset], yyscanner); } ]]) m4_ifdef([[M4_YY_NO_TOP_STATE]],, [[ -static int yy_top_state (yyscan_t yyscanner) +static int yy_top_state(yyscan_t yyscanner) { - return yyscanner->yyStartStackPtr > 0 ? yyscanner->yyStartStack[yyscanner->yyStartStackPtr - 1] : yystart(yyscanner); + return yyscanner->yyStartStackOffset > 0 ? yyscanner->yyStartStack[yyscanner->yyStartStackOffset - 1] : yystart(yyscanner); } ]]) @@ -1636,69 +1633,69 @@ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ /* Generate code to keep backing-up information. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ - if (yyCurrentState[-1].yy_nxt) { + if (yyCurrentState[-1].yyNxt) { ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ - if (yy_accept[yyCurrentState]) { + if (yyAccept[yyCurrentState]) { ]]) - yyscanner->yy_last_accepting_state = yyCurrentState; - yyscanner->yy_last_accepting_cpos = yyCp; + yyscanner->yyLastAcceptingState = yyCurrentState; + yyscanner->yyLastAcceptingCharPos = yyCp; } ]]) ]]) ]]) -%# yy_c was formerly YY_CHAR, changed to int because table can now +%# yyChar was formerly YY_CHAR, changed to int because table can now %# have up to 0x101 entries, since we no longer generate a separate %# NUL table. %# %# Note: on x86-64 architecture with gcc -O2, we save an instruction %# in the main loop, since the character can now be zero-extended in -%# the process of retrieving it from the input stream or the yy_ec[] -%# or yy_meta[] arrays, whereas previously it was zero-extended by a -%# register-to-register move just prior to the yy_chk[] table lookup +%# the process of retrieving it from the input stream or the yyEC[] +%# or yyMeta[] arrays, whereas previously it was zero-extended by a +%# register-to-register move just prior to the yyChk[] table lookup m4_define([[M4_GEN_NEXT_COMPRESSED_STATE]], [[ - int yy_c = $1; + int yyChar = $1; /* Save the backing-up info \before/ computing the next state * because we always compute one more state than needed - we * always proceed until we reach a jam state */ M4_GEN_BACKING_UP - while (yy_chk[yy_base[yyCurrentState] + yy_c] != yyCurrentState) { - yyCurrentState = (int) yy_def[yyCurrentState]; + while (yyChk[yyBase[yyCurrentState] + yyChar] != yyCurrentState) { + yyCurrentState = (int) yyDef[yyCurrentState]; m4_ifdef([[M4_MODE_USEMECS]], [[ /* We've arranged it so that templates are never chained * to one another. This means we can afford to make a * very simple test to see if we need to convert to - * yy_c's meta-equivalence class without worrying + * yyChar's meta-equivalence class without worrying * about erroneously looking up the meta-equivalence * class twice */ /* lastdfa + 2 == YY_JAMSTATE + 1 is the beginning of the templates */ if (yyCurrentState >= YY_JAMSTATE + 1) { - yy_c = yy_meta[yy_c]; + yyChar = yyMeta[yyChar]; } ]]) } - yyCurrentState = yy_nxt[yy_base[yyCurrentState] + yy_c]; + yyCurrentState = yyNxt[yyBase[yyCurrentState] + yyChar]; ]]) m4_define([[M4_GEN_START_STATE]], [[ /* Generate the code to find the start state. */ m4_ifdef([[M4_MODE_FULLSPD]], [[ -m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState = yy_start_state_list[yyscanner->yyStart + yyatbol()];]]) -m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yyCurrentState = yy_start_state_list[yyscanner->yyStart];]]) +m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState = yyStartStateList[yyscanner->yyStart + yyatbol()];]]) +m4_ifdef([[M4_MODE_NO_BOL_NEEDED]], [[yyCurrentState = yyStartStateList[yyscanner->yyStart];]]) ]]) m4_ifdef([[M4_MODE_NO_FULLSPD]], [[ yyCurrentState = yyscanner->yyStart; m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState += yyatbol(yyscanner);]]) /* Set up for storing up states. */ m4_ifdef([[M4_MODE_USES_REJECT]], [[ - yyscanner->yy_state_ptr = yyscanner->yyStateBuf; - *yyscanner->yy_state_ptr++ = yyCurrentState; + yyscanner->yyStatePtr = yyscanner->yyStateBuf; + *yyscanner->yyStatePtr++ = yyCurrentState; ]]) ]]) ]]) @@ -1706,13 +1703,13 @@ m4_ifdef([[M4_MODE_BOL_NEEDED]], [[yyCurrentState += yyatbol(yyscanner);]]) m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ { const struct yyTransInfo *yyTransInfo; - YY_CHAR yy_c; + YY_CHAR yyChar; - for (yy_c = $1; - (yyTransInfo = &yyCurrentState[yy_c])->yy_verify == yy_c; - yy_c = $2) + for (yyChar = $1; + (yyTransInfo = &yyCurrentState[yyChar])->yyVerify == yyChar; + yyChar = $2) { - yyCurrentState += yyTransInfo->yy_nxt; + yyCurrentState += yyTransInfo->yyNxt; M4_GEN_BACKING_UP } @@ -1724,12 +1721,12 @@ m4_define([[M4_GEN_NEXT_MATCH_FULLSPD]], [[ */ %# Conditional indirection through an equivalence map -m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yy_ec+$1)]])) +m4_ifdef([[M4_MODE_USEECS]], m4_define([[M4_EC]], [[*(yyEC+$1)]])) m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) /* yyGetPreviousState - get the state just before the EOB char was reached */ -static yyStateType yyGetPreviousState (yyscan_t yyscanner) { +static yyStateType yyGetPreviousState(yyscan_t yyscanner) { yyStateType yyCurrentState; char *yyCp; @@ -1746,42 +1743,42 @@ static yyStateType yyGetPreviousState (yyscan_t yyscanner) { ]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[ - m4_ifdef([[M4_MODE_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState][CHAR_MAP_3];]]) - m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState*YY_NXT_LOLEN + CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_GENTABLES]], [[yyCurrentState = yyNxt[yyCurrentState][CHAR_MAP_3];]]) + m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yyCurrentState = yyNxt[yyCurrentState*YYNXT_LOLEN + CHAR_MAP_3];]]) ]]) - m4_ifdef([[M4_MODE_FULLSPD]], [[yyCurrentState += yyCurrentState[CHAR_MAP_3].yy_nxt;]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yyCurrentState += yyCurrentState[CHAR_MAP_3].yyNxt;]]) m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[M4_GEN_NEXT_COMPRESSED_STATE(CHAR_MAP_3)]]) m4_ifdef([[M4_MODE_NULTRANS]], [[ } else { - yyCurrentState = yy_NUL_trans[yyCurrentState]; + yyCurrentState = yyNULtrans[yyCurrentState]; } ]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[M4_GEN_BACKING_UP]]) m4_ifdef([[M4_MODE_FULLSPD]], [[M4_GEN_BACKING_UP]]) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yyCurrentState;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yyStatePtr++ = yyCurrentState;]]) } return yyCurrentState; } -/* yy_try_NUL_trans - try to make a transition on the NUL character +/* yyTryNULtrans - try to make a transition on the NUL character * * synopsis - * next_state = yy_try_NUL_trans(current_state); + * next_state = yyTryNULtrans(current_state); */ -static yyStateType yy_try_NUL_trans(yyStateType yyCurrentState, yyscan_t yyscanner) +static yyStateType yyTryNULtrans(yyStateType yyCurrentState, yyscan_t yyscanner) { bool yyIsJam; - /* Generate code for handling NUL's, if needed. */ + /* Generate code for handling NULs, if needed. */ /* First, deal with backing up and setting up yyCp if the scanner * finds that it should JAM on the NUL. * * Only generate a definition for "yyCp" if we'll generate code - * that uses it. Otherwise lint and the like complain. + * that uses it. Otherwise validators complain. */ m4_ifdef([[M4_MODE_NEED_YY_CP]], [[char *yyCp = yyscanner->yyCBufP;]]) @@ -1789,26 +1786,26 @@ static yyStateType yy_try_NUL_trans(yyStateType yyCurrentState, yyscan_t yyscann %# not executed serially but are an if-then-else cascade %# for different table modes. m4_ifdef([[M4_MODE_NULTRANS]], [[ - yyCurrentState = yy_NUL_trans[yyCurrentState]; + yyCurrentState = yyNULtrans[yyCurrentState]; yyIsJam = (yyCurrentState == 0); ]]) m4_ifdef([[M4_MODE_NO_NULTRANS]], [[ m4_ifdef([[M4_MODE_NULTRANS_FULLTBL]], [[ -m4_ifdef([[M4_MODE_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState][YY_NUL_EC];]]) -m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yyCurrentState = yy_nxt[yyCurrentState*YY_NXT_LOLEN + YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_GENTABLES]], [[yyCurrentState = yyNxt[yyCurrentState][YY_NUL_EC];]]) +m4_ifdef([[M4_MODE_NO_GENTABLES]], [[yyCurrentState = yyNxt[yyCurrentState*YYNXT_LOLEN + YY_NUL_EC];]]) yyIsJam = (yyCurrentState <= 0); ]]) m4_ifdef([[M4_MODE_NO_NULTRANS_FULLTBL]], [[ m4_ifdef([[M4_MODE_NULTRANS_FULLSPD]], [[ - int yy_c = YY_NUL_EC; + int yyChar = YY_NUL_EC; const struct yyTransInfo *yyTransInfo; - yyTransInfo = &yyCurrentState[(unsigned int) yy_c]; - yyCurrentState += yyTransInfo->yy_nxt; - yyIsJam = (yyTransInfo->yy_verify != yy_c); + yyTransInfo = &yyCurrentState[(unsigned int) yyChar]; + yyCurrentState += yyTransInfo->yyNxt; + yyIsJam = (yyTransInfo->yyVerify != yyChar); ]]) m4_ifdef([[M4_MODE_NO_NULTRANS_FULLSPD]], [[ @@ -1820,7 +1817,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], [[ * the state stack and yyCBufP get out of sync. */ if (! yyIsJam) { - *yyscanner->yy_state_ptr++ = yyCurrentState; + *yyscanner->yyStatePtr++ = yyCurrentState; } ]]) ]]) @@ -1833,7 +1830,7 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ * compressed tables have *already* done such backing up, so * we needn't bother with it again. */ - if (! yyIsJam) { + if (!yyIsJam) { M4_GEN_BACKING_UP } ]]) @@ -1847,7 +1844,7 @@ m4_ifdef([[M4_MODE_NULTRANS_WRAP]], [[ YY_DECL { yyStateType yyCurrentState; char *yyCp, *yyBp; - int yy_act; + int yyAct; m4_ifdef([[M4_YY_BISON_LVAL]], [[ @@ -1900,10 +1897,10 @@ m4_ifdef([[M4_MODE_USES_REJECT]], while (/*CONSTCOND*/1) { /* loops until end-of-file is reached */ m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ - yyscanner->yy_more_len = 0; - if (yyscanner->yy_more_flag) { - yyscanner->yy_more_len = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr); - yyscanner->yy_more_flag = false; + yyscanner->yyMoreLen = 0; + if (yyscanner->yyMoreFlag) { + yyscanner->yyMoreLen = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr); + yyscanner->yyMoreFlag = false; } ]]) ]]) @@ -1919,14 +1916,14 @@ m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ M4_GEN_START_STATE - yy_match: + yyMatchLabel: /* Generate the code to find the next match. */ m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[m4_dnl m4_ifdef([[M4_MODE_GENTABLES]], [[m4_dnl - while ((yyCurrentState = yy_nxt[yyCurrentState][ M4_EC(YY_SC_TO_UI(*yyCp)) ]) > 0) { + while ((yyCurrentState = yyNxt[yyCurrentState][ M4_EC(YY_SC_TO_UI(*yyCp)) ]) > 0) { ]]) m4_ifdef([[M4_MODE_NO_GENTABLES]], [[ - while ((yyCurrentState = yy_nxt[yyCurrentState*YY_NXT_LOLEN + M4_EC(YY_SC_TO_UI(*yyCp)) ]) > 0) { + while ((yyCurrentState = yyNxt[yyCurrentState*YYNXT_LOLEN + M4_EC(YY_SC_TO_UI(*yyCp)) ]) > 0) { ]]) M4_GEN_BACKING_UP yyCp++; @@ -1940,11 +1937,11 @@ m4_ifdef([[M4_MODE_NO_FULLSPD_OR_FULLTBL]], [[ do { M4_GEN_NEXT_COMPRESSED_STATE(M4_EC(YY_SC_TO_UI(*yyCp))) - m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yy_state_ptr++ = yyCurrentState;]]) + m4_ifdef([[M4_MODE_USES_REJECT]], [[*yyscanner->yyStatePtr++ = yyCurrentState;]]) ++yyCp; } - m4_ifdef([[M4_MODE_INTERACTIVE]], [[while (yy_base[yyCurrentState] != YY_JAMBASE);]]) + m4_ifdef([[M4_MODE_INTERACTIVE]], [[while (yyBase[yyCurrentState] != YY_JAMBASE);]]) m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[while (yyCurrentState != YY_JAMSTATE);]]) m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ @@ -1952,48 +1949,48 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure out * the match. */ - yyCp = yyscanner->yy_last_accepting_cpos; - yyCurrentState = yyscanner->yy_last_accepting_state; + yyCp = yyscanner->yyLastAcceptingCharPos; + yyCurrentState = yyscanner->yyLastAcceptingState; ]]) ]]) ]]) - yy_find_action: + yyFindActionLabel: /* code to find the action number goes here */ - m4_ifdef([[M4_MODE_FULLSPD]], [[yy_act = yyCurrentState[-1].yy_nxt;]]) - m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yy_act = yy_accept[yyCurrentState];]]) + m4_ifdef([[M4_MODE_FULLSPD]], [[yyAct = yyCurrentState[-1].yyNxt;]]) + m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yyAct = yyAccept[yyCurrentState];]]) m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ - yyCurrentState = *--yyscanner->yy_state_ptr; - yyscanner->yy_lp = yy_accept[yyCurrentState]; + yyCurrentState = *--yyscanner->yyStatePtr; + yyscanner->yyLp = yyAccept[yyCurrentState]; m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) for (; ;) { /* loop until we find out what rule we matched */ - if (yyscanner->yy_lp && yyscanner->yy_lp < yy_accept[yyCurrentState + 1]) { - yy_act = yy_acclist[yyscanner->yy_lp]; + if (yyscanner->yyLp && yyscanner->yyLp < yyAccept[yyCurrentState + 1]) { + yyAct = yyAcclist[yyscanner->yyLp]; m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ - if ((yy_act & YY_TRAILING_HEAD_MASK) != 0 || yyscanner->yy_looking_for_trail_begin) { - if (yy_act == yyscanner->yy_looking_for_trail_begin) { - yyscanner->yy_looking_for_trail_begin = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; + if ((yyAct & YY_TRAILING_HEAD_MASK) != 0 || yyscanner->yyLookingForTrailBegin) { + if (yyAct == yyscanner->yyLookingForTrailBegin) { + yyscanner->yyLookingForTrailBegin = 0; + yyAct &= ~YY_TRAILING_HEAD_MASK; break; } - } else if ((yy_act & YY_TRAILING_MASK) != 0) { - yyscanner->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; - yyscanner->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; + } else if ((yyAct & YY_TRAILING_MASK) != 0) { + yyscanner->yyLookingForTrailBegin = yyAct & ~YY_TRAILING_MASK; + yyscanner->yyLookingForTrailBegin |= YY_TRAILING_HEAD_MASK; m4_ifdef([[M4_MODE_REAL_REJECT]], [[ /* Remember matched text in case we back up * due to REJECT. */ yyscanner->yyFullMatch = yyCp; - yyscanner->yy_full_state = yyscanner->yy_state_ptr; - yyscanner->yyFullLp = yyscanner->yy_lp; + yyscanner->yyFullState = yyscanner->yyStatePtr; + yyscanner->yyFullLp = yyscanner->yyLp; ]]) } else { yyscanner->yyFullMatch = yyCp; - yyscanner->yy_full_state = yyscanner->yy_state_ptr; - yyscanner->yyFullLp = yyscanner->yy_lp; + yyscanner->yyFullState = yyscanner->yyStatePtr; + yyscanner->yyFullLp = yyscanner->yyLp; break; } - ++yyscanner->yy_lp; + ++yyscanner->yyLp; goto find_rule; ]]) m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ @@ -2011,15 +2008,15 @@ m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ * the beginning, but at the cost of complaints that we're * branching inside a loop. */ - yyCurrentState = *--yyscanner->yy_state_ptr; - yyscanner->yy_lp = yy_accept[yyCurrentState]; + yyCurrentState = *--yyscanner->yyStatePtr; + yyscanner->yyLp = yyAccept[yyCurrentState]; } /* close for */ ]]) -m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yyCurrentState]; - if (yy_act == 0) { /* have to back up */ - yyCp = yyscanner->yy_last_accepting_cpos; - yyCurrentState = yyscanner->yy_last_accepting_state; - yy_act = yy_accept[yyCurrentState]; +m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yyAct = yyAccept[yyCurrentState]; + if (yyAct == 0) { /* have to back up */ + yyCp = yyscanner->yyLastAcceptingCharPos; + yyCurrentState = yyscanner->yyLastAcceptingState; + yyAct = yyAccept[yyCurrentState]; } ]]) @@ -2028,8 +2025,8 @@ m4_ifdef([[M4_MODE_FIND_ACTION_COMPRESSED]], [[ yy_act = yy_accept[yyCurrentSta m4_ifdef([[M4_MODE_YYLINENO]],[[ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], - [[yyscanner->yy_prev_more_offset]], [[yyscanner->yy_more_len]])]], [[0]])]]) - if (yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act]) { + [[yyscanner->yyPrevMoreOffset]], [[yyscanner->yyMoreLen]])]], [[0]])]]) + if (yyAct != YY_END_OF_BUFFER && yyRuleCanMatchEOL[yyAct]) { int yyl; for (yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl) { if (yyscanner->yytext_r[yyl] == '\n') { @@ -2040,19 +2037,19 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], } ]]) - do_action: /* This label is used only to access EOF actions. */ + doActionLabel: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ if (yyscanner->yyflexdebug_r) { - if (yy_act == 0) { + if (yyAct == 0) { fprintf(stderr, "--scanner backing up\n"); - } else if (yy_act < YY_NUM_RULES) { + } else if (yyAct < YY_NUM_RULES) { fprintf(stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yyscanner->yytext_r); - } else if (yy_act == YY_NUM_RULES) { + (long)yy_rule_linenum[yyAct], yyscanner->yytext_r); + } else if (yyAct == YY_NUM_RULES) { fprintf(stderr, "--accepting default rule (\"%s\")\n", yyscanner->yytext_r); - } else if (yy_act == YY_NUM_RULES + 1) { + } else if (yyAct == YY_NUM_RULES + 1) { fprintf(stderr, "--(end of buffer or a NUL)\n"); } else { fprintf(stderr, "--EOF (start condition %d)\n", yystart(yyscanner)); @@ -2060,21 +2057,21 @@ m4_ifdef([[M4_MODE_DEBUG]], [[ } ]]) - switch (yy_act) { /* beginning of action switch */ + switch (yyAct) { /* beginning of action switch */ m4_ifdef([[M4_MODE_NO_USES_REJECT]], [[ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ case 0: /* must back up */ /* undo the effects of yyDoBeforeAction() */ *yyCp = yyscanner->yyHoldChar; - /* Backing-up info for compressed tables is taken \after/ */ + /* Backing-up info for compressed tables is taken *after* */ /* yyCp has been incremented for the next state. */ - yyCp = yyscanner->yy_last_accepting_cpos; + yyCp = yyscanner->yyLastAcceptingCharPos; m4_ifdef([[M4_MODE_FULLSPD]], [[yyCp++;]]) m4_ifdef([[M4_MODE_FIND_ACTION_FULLTBL]], [[yyCp++;]]) - yyCurrentState = yyscanner->yy_last_accepting_state; - goto yy_find_action; + yyCurrentState = yyscanner->yyLastAcceptingState; + goto yyFindActionLabel; ]]) ]]) %% [5.0] user actions get inserted here @@ -2111,7 +2108,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * in input(). */ if (yyscanner->yyCBufP <= &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars]) { /* This was really a NUL. */ - yyStateType yy_next_state; + yyStateType yyNextState; yyscanner->yyCBufP = yyscanner->yytext_ptr + yyAmountOfMatchedText; @@ -2126,15 +2123,15 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * will run more slowly). */ - yy_next_state = yy_try_NUL_trans(yyCurrentState, yyscanner); + yyNextState = yyTryNULtrans(yyCurrentState, yyscanner); yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; - if (yy_next_state) { + if (yyNextState) { /* Consume the NUL. */ yyCp = ++yyscanner->yyCBufP; - yyCurrentState = yy_next_state; - goto yy_match; + yyCurrentState = yyNextState; + goto yyMatchLabel; } else { %# Disguised case statement on table modes m4_ifdef([[M4_MODE_FULLSPD]], [[yyCp = yyscanner->yyCBufP;]]) @@ -2145,8 +2142,8 @@ m4_ifdef([[M4_NOT_MODE_INTERACTIVE]], [[ /* Do the guaranteed-needed backing up to figure * out the match. */ - yyCp = yyscanner->yy_last_accepting_cpos; - yyCurrentState = yyscanner->yy_last_accepting_state; + yyCp = yyscanner->yyLastAcceptingCharPos; + yyCurrentState = yyscanner->yyLastAcceptingState; ]]) ]]) %# Disguised case statement on table modes ends @@ -2158,7 +2155,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ yyCp = yyscanner->yyCBufP; ]]) ]]) - goto yy_find_action; + goto yyFindActionLabel; } } else { /* not a NUL */ switch (yy_get_next_buffer(yyscanner)) { @@ -2177,8 +2174,8 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ */ yyscanner->yyCBufP = yyscanner->yytext_ptr + YY_MORE_ADJ; - yy_act = YY_STATE_EOF(yystart(yyscanner)); - goto do_action; + yyAct = YY_STATE_EOF(yystart(yyscanner)); + goto doActionLabel; } else { if (! yyscanner->yyDidBufferSwitchOnEof) { yyrestart(yyscanner->yyin_r, yyscanner); @@ -2186,14 +2183,13 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ } break; case EOB_ACT_CONTINUE_SCAN: - yyscanner->yyCBufP = - yyscanner->yytext_ptr + yyAmountOfMatchedText; + yyscanner->yyCBufP = yyscanner->yytext_ptr + yyAmountOfMatchedText; yyCurrentState = yyGetPreviousState(yyscanner); yyCp = yyscanner->yyCBufP; yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; - goto yy_match; + goto yyMatchLabel; case EOB_ACT_LAST_MATCH: yyscanner->yyCBufP = @@ -2203,7 +2199,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ yyCp = yyscanner->yyCBufP; yyBp = yyscanner->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; + goto yyFindActionLabel; } /* end EOB inner switch */ } /* end if */ break; @@ -2239,31 +2235,28 @@ static int yy_init_globals (yyscan_t yyscanner) { yyscanner->yyCBufP = NULL; yyscanner->yyInit = false; yyscanner->yyStart = 0; - yyscanner->yyStartStackPtr = 0; + yyscanner->yyStartStackOffset = 0; yyscanner->yyStartStackDepth = 0; yyscanner->yyStartStack = NULL; m4_ifdef([[M4_MODE_USES_REJECT]], [[ - yyscanner->yyStateBuf = 0; - yyscanner->yy_state_ptr = 0; - yyscanner->yyFullMatch = 0; - yyscanner->yy_lp = 0; + yyscanner->yyStateBuf = NULL; + yyscanner->yyStatePtr = NULL; + yyscanner->yyFullMatch = NULL; + yyscanner->yyLp = NULL; ]]) m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ yyscanner->yytext_ptr = 0; - yyscanner->yy_more_offset = 0; - yyscanner->yy_prev_more_offset = 0; + yyscanner->yyMoreOffset = 0; + yyscanner->yyPrevMoreOffset = 0; ]]) yyscanner->yyin_r = NULL; yyscanner->yyout_r = NULL; - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ return 0; } @@ -2273,23 +2266,23 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ -int yylex_init(yyscan_t* ptr_yy_globals) { - if (ptr_yy_globals == NULL) { +int yylex_init(yyscan_t *globalsPtr) { + if (globalsPtr == NULL) { errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) yyalloc (sizeof(struct yyguts_t), NULL); + *globalsPtr = (yyscan_t) yyalloc (sizeof(struct yyguts_t), NULL); - if (*ptr_yy_globals == NULL) { + if (*globalsPtr == NULL) { errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + memset(*globalsPtr,0x00,sizeof(struct yyguts_t)); - return yy_init_globals (*ptr_yy_globals); + return yy_init_globals (*globalsPtr); } m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl @@ -2300,35 +2293,35 @@ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ -int yylex_init_extra(M4_MODE_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals) { - struct yyguts_t dummy_yyguts; +int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { + struct yyguts_t dummyYyguts; - yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra(yyUserDefined, &dummy_yyguts); - if (ptr_yy_globals == NULL) { + if (globalsPtr == NULL) { errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) yyalloc (sizeof(struct yyguts_t), &dummy_yyguts); + *globalsPtr = (yyscan_t) yyalloc(sizeof(struct yyguts_t), &dummyYyguts); - if (*ptr_yy_globals == NULL) { + if (*globalsPtr == NULL) { errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + memset(*globalsPtr,0x00,sizeof(struct yyguts_t)); - yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra(yyUserDefined, *globalsPtr); - return yy_init_globals (*ptr_yy_globals); + return yy_init_globals(*globalsPtr); } ]]) /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) { +int yylex_destroy (yyscan_t yyscanner) { /* Pop the buffer stack, destroying each element. */ while(yy_current_buffer(yyscanner)) { @@ -2363,7 +2356,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, [[ -void *yyalloc(yy_size_t size, yyscan_t yyscanner) { +void *yyalloc(size_t size, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ return malloc(size); } @@ -2371,7 +2364,7 @@ void *yyalloc(yy_size_t size, yyscan_t yyscanner) { m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, [[ -void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { +void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ return realloc(ptr, size); } -- cgit v1.2.1 From 6c37e76ca59bd6d8828786121552d8c9b3b7f781 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 08:54:42 -0500 Subject: Improve type checking in c99 and Go back ends. --- src/c99-flex.skl | 6 +++--- src/go-flex.skl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index f4edf14..6a92292 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -623,7 +623,7 @@ void yy_flush_current_buffer(yyscan_t yyscanner) { const int YY_EXIT_FAILURE = 2; m4_ifdef( [[M4_YY_NO_YYPANIC]],, [[ -/* This gfunction has a magic rewrite rule */ +/* This function has a magic rewrite rule */ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ fprintf( stderr, "%s\n", msg ); @@ -867,7 +867,7 @@ void yyecho(yyscan_t yyscanner) { } m4_ifdef( [[M4_YY_NO_YYUNPUT]],, [[ -void yyunput( int c, yyscan_t yyscanner) +void yyunput(char c, yyscan_t yyscanner) { char *yy_cp; @@ -898,7 +898,7 @@ void yyunput( int c, yyscan_t yyscanner) } } - *--yy_cp = (char) c; + *--yy_cp = c; m4_ifdef( [[M4_MODE_YYLINENO]], [[ diff --git a/src/go-flex.skl b/src/go-flex.skl index 5c5e728..b9a0444 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -782,7 +782,7 @@ void yyecho(yyscan_t yyscanner) { } m4_ifdef([[M4_YY_NO_YYUNPUT]],, [[ -void yyunput(int c, yyscan_t yyscanner) +void yyunput(char c, yyscan_t yyscanner) { char *yyCp; @@ -812,7 +812,7 @@ void yyunput(int c, yyscan_t yyscanner) } } - *--yyCp = (char) c; + *--yyCp = c; m4_ifdef([[M4_MODE_YYLINENO]], [[ -- cgit v1.2.1 From 820199d2a90d01d9f06b57d0c56be6512788e7fa Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 09:29:22 -0500 Subject: In the C99 and Go back ends, rearrange code... ...to clean out a forward declaeation. --- src/c99-flex.skl | 404 +++++++++++++++++++++++++++---------------------------- src/go-flex.skl | 404 +++++++++++++++++++++++++++---------------------------- 2 files changed, 404 insertions(+), 404 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 6a92292..a72ccee 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -373,8 +373,6 @@ m4_define([[yytext_ptr]], [[yytext_r]]) %% [1.0] DFA -static int yy_get_next_buffer ( yyscan_t yyscanner ); - struct yy_trans_info { /* We require that yy_verify and yy_nxt must be of the same size int. */ m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ @@ -912,6 +910,208 @@ m4_ifdef( [[M4_MODE_YYLINENO]], } ]]) +%# yymore has a magic rewute rule. It's declared here, rather than with the other +%# magic functions, so yy_get_next_buffer() won't need a forward declaration. +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ +yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; +yyscanner->yyleng_r -= yyscanner->yy_more_offset; +} +]]) +]]) +m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} +m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) +]]) +]]) + +m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) +]]) + +m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { + int result; +m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ + errno=0; + while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { + if( errno != EINTR) { + yypanic( "input in flex scanner failed", yyscanner); + break; + } + errno=0; + clearerr(yyscanner->yyin_r); + } +]]) +m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive ) { + int c = '*'; + int n; + for ( n = 0; n < max_size && + (c = getc( yyscanner->yyin_r )) != EOF && c != '\n'; ++n ) { + buf[n] = (char) c; + } + if ( c == '\n' ) { + buf[n++] = (char) c; + } + if ( c == EOF && ferror( yyscanner->yyin_r ) ) { + yypanic( "input in flex scanner failed", yyscanner); + } + result = n; + } else { + errno=0; + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + if( errno != EINTR) { + yypanic( "input in flex scanner failed", yyscanner); + break; + } + errno=0; + clearerr(yyscanner->yyin_r); + } + } +]]) + return result; +} +]]) + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; + char *source = yyscanner->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { + yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); + } + if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) { + *(dest++) = *(source++); + } + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; + } else { + int num_to_read = + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ +m4_ifdef( [[M4_MODE_USES_REJECT]], +[[ + yypanic( + "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); +]], +[[ + /* just a shorter name for the current buffer */ + yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; + + int yy_c_buf_p_offset = + (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) { + b->yy_buf_size += b->yy_buf_size / 8; + } else { + b->yy_buf_size *= 2; + } + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + } else { + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + } + if ( b->yy_ch_buf == NULL ) { + yypanic("fatal error - scanner input buffer overflow", yyscanner); + } + yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - + number_to_move - 1; +]]) + } + + if ( num_to_read > YY_READ_BUF_SIZE ) { + num_to_read = YY_READ_BUF_SIZE; + } + /* Read in more data. */ + yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); + + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; + } + + if ( yyscanner->yy_n_chars == 0 ) { + if ( number_to_move == YY_MORE_ADJ ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyscanner->yyin_r, yyscanner); + } else { + ret_val = EOB_ACT_LAST_MATCH; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } else { + ret_val = EOB_ACT_CONTINUE_SCAN; + } + if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( + (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { + yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); + } + /* "- 2" to take care of EOB's */ + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); + } + + yyscanner->yy_n_chars += number_to_move; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; + + return ret_val; +} + int yyinput (yyscan_t yyscanner) { int c; @@ -1018,54 +1218,6 @@ m4_define( [[M4_YY_NO_POP_STATE]]) m4_define( [[M4_YY_NO_TOP_STATE]]) ]]) -m4_ifdef( [[M4_MODE_USER_YYREAD]],, [[ -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { - int result; -m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ - errno=0; - while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { - if( errno != EINTR) { - yypanic( "input in flex scanner failed", yyscanner); - break; - } - errno=0; - clearerr(yyscanner->yyin_r); - } -]]) -m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_is_interactive ) { - int c = '*'; - int n; - for ( n = 0; n < max_size && - (c = getc( yyscanner->yyin_r )) != EOF && c != '\n'; ++n ) { - buf[n] = (char) c; - } - if ( c == '\n' ) { - buf[n++] = (char) c; - } - if ( c == EOF && ferror( yyscanner->yyin_r ) ) { - yypanic( "input in flex scanner failed", yyscanner); - } - result = n; - } else { - errno=0; - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { - if( errno != EINTR) { - yypanic( "input in flex scanner failed", yyscanner); - break; - } - errno=0; - clearerr(yyscanner->yyin_r); - } - } -]]) - return result; -} -]]) - /* STARTS Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -1371,28 +1523,6 @@ void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { } -m4_ifdef([[M4_MODE_YYMORE_USED]], [[ -m4_ifdef( [[M4_MODE_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yy_more_offset = strlen(yyscanner->yytext_r);} -m4_define([[YY_MORE_ADJ]], [[0]]) -m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ -yyscanner->yy_more_offset = yyscanner->yy_prev_more_offset; -yyscanner->yyleng_r -= yyscanner->yy_more_offset; -} -]]) -]]) -m4_ifdef( [[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yy_more_flag = true;} -m4_define([[YY_MORE_ADJ]], [[yyscanner->yy_more_len]]) -m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) -]]) -]]) - -m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ -m4_define([[YY_MORE_ADJ]], [[0]]) -m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) -]]) - void yysetbol(bool at_bol, yyscan_t yyscanner) { if ( yy_current_buffer(yyscanner) == NULL ) { yyensure_buffer_stack (yyscanner); @@ -1534,136 +1664,6 @@ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) } ]]) -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - char *dest = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf; - char *source = yyscanner->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyscanner->yy_c_buf_p > &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] ) { - yypanic( "fatal flex scanner internal error--end of buffer missed", yyscanner); - } - if ( !yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_fill_buffer ) { - /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - YY_MORE_ADJ == 1 ) { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } else { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) { - *(dest++) = *(source++); - } - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) { - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars = 0; - } else { - int num_to_read = - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ -m4_ifdef( [[M4_MODE_USES_REJECT]], -[[ - yypanic( - "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner ); -]], -[[ - /* just a shorter name for the current buffer */ - yybuffer b = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]; - - int yy_c_buf_p_offset = - (int) (yyscanner->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) { - b->yy_buf_size += b->yy_buf_size / 8; - } else { - b->yy_buf_size *= 2; - } - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2), yyscanner ); - } else { - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - } - if ( b->yy_ch_buf == NULL ) { - yypanic("fatal error - scanner input buffer overflow", yyscanner); - } - yyscanner->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size - - number_to_move - 1; -]]) - } - - if ( num_to_read > YY_READ_BUF_SIZE ) { - num_to_read = YY_READ_BUF_SIZE; - } - /* Read in more data. */ - yyscanner->yy_n_chars = yyread(&yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[number_to_move], num_to_read, yyscanner); - - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_n_chars = yyscanner->yy_n_chars; - } - - if ( yyscanner->yy_n_chars == 0 ) { - if ( number_to_move == YY_MORE_ADJ ) { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyscanner->yyin_r, yyscanner); - } else { - ret_val = EOB_ACT_LAST_MATCH; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } else { - ret_val = EOB_ACT_CONTINUE_SCAN; - } - if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( - (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); - if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { - yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); - } - /* "- 2" to take care of EOB's */ - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size = (int) (new_size - 2); - } - - yyscanner->yy_n_chars += number_to_move; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[yyscanner->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyscanner->yytext_ptr = &yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf[0]; - - return ret_val; -} - m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, [[ static void yy_push_state(int _new_state, yyscan_t yyscanner) diff --git a/src/go-flex.skl b/src/go-flex.skl index b9a0444..b62ef80 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -288,8 +288,6 @@ m4_define([[yytext_ptr]], [[yytext_r]]) %% [1.0] DFA -static int yy_get_next_buffer (yyscan_t yyscanner); - struct yyTransInfo { /* We require that yyVerify and yyNxt must be of the same size int. */ m4_ifdef([[M4_MODE_REAL_FULLSPD]], [[ @@ -826,6 +824,208 @@ m4_ifdef([[M4_MODE_YYLINENO]], } ]]) +m4_ifdef([[M4_MODE_USER_YYREAD]],, [[ +/* Gets input and stuffs it into "buf". Number of characters read, or YY_NULL, + * is returned in "result". + */ +static int yyread(char *buf, size_t maxSize, yyscan_t yyscanner) { + int result; +m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ + errno=0; + while ((result = (int) read(fileno(yyscanner->yyin_r), buf, (size_t) maxSize)) < 0) { + if(errno != EINTR) { + yypanic("input in flex scanner failed", yyscanner); + break; + } + errno=0; + clearerr(yyscanner->yyin_r); + } +]]) +m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyIsInteractive) { + int c = '*'; + int n; + for (n = 0; n < maxSize && + (c = getc(yyscanner->yyin_r)) != EOF && c != '\n'; ++n) { + buf[n] = (char) c; + } + if (c == '\n') { + buf[n++] = (char) c; + } + if (c == EOF && ferror(yyscanner->yyin_r)) { + yypanic("input in flex scanner failed", yyscanner); + } + result = n; + } else { + errno=0; + while ((result = (int) fread(buf, 1, (size_t) maxSize, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + if(errno != EINTR) { + yypanic("input in flex scanner failed", yyscanner); + break; + } + errno=0; + clearerr(yyscanner->yyin_r); + } + } +]]) + return result; +} +]]) + +%# yymore has a magic rewute rule. It's declared here, rather than with the other +%# magic functions, so yy_get_next_buffer() won't need a forward declaration. +m4_ifdef([[M4_MODE_YYMORE_USED]], [[ +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ +void yymore(yyscan_t yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext_r);} +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ +yyscanner->yyMoreOffset = yyscanner->yyPrevMoreOffset; +yyscanner->yyleng_r -= yyscanner->yyMoreOffset; +} +]]) +]]) +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +void yymore(yyscan_t yyscanner) {yyscanner->yyMoreFlag = true;} +m4_define([[YY_MORE_ADJ]], [[yyscanner->yyMoreLen]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) +]]) +]]) + +m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ +m4_define([[YY_MORE_ADJ]], [[0]]) +m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) +]]) + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf; + char *source = yyscanner->yytext_ptr; + int numberToMove, i; + int retVal; + + if (yyscanner->yyCBufP > &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1]) { + yypanic("fatal flex scanner internal error--end of buffer missed", yyscanner); + } + if (!yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyFillBuffer) { + /* Don't try to fill the buffer, so this is an EOF. */ + if (yyscanner->yyCBufP - yyscanner->yytext_ptr - YY_MORE_ADJ == 1) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + numberToMove = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr - 1); + + for (i = 0; i < numberToMove; ++i) { + *(dest++) = *(source++); + } + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus == YY_BUFFER_EOF_PENDING) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars = 0; + } else { + int num_to_read = + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - numberToMove - 1; + + while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */ +m4_ifdef([[M4_MODE_USES_REJECT]], +[[ + yypanic( + "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner); +]], +[[ + /* just a shorter name for the current buffer */ + yybuffer b = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]; + + int yyCBufP_offset = + (int) (yyscanner->yyCBufP - b->yyChBuf); + + if (b->yyIsOurBuffer) { + int newSize = b->yyInputBufSize * 2; + + if (newSize <= 0) { + b->yyInputBufSize += b->yyInputBufSize / 8; + } else { + b->yyInputBufSize *= 2; + } + b->yyChBuf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yyChBuf, + (size_t) (b->yyInputBufSize + 2), yyscanner); + } else { + /* Can't grow it, we don't own it. */ + b->yyChBuf = NULL; + } + if (b->yyChBuf == NULL) { + yypanic("fatal error - scanner input buffer overflow", yyscanner); + } + yyscanner->yyCBufP = &b->yyChBuf[yyCBufP_offset]; + + num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - + numberToMove - 1; +]]) + } + + if (num_to_read > YY_READ_BUF_SIZE) { + num_to_read = YY_READ_BUF_SIZE; + } + /* Read in more data. */ + yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove], num_to_read, yyscanner); + + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; + } + + if (yyscanner->yyNChars == 0) { + if (numberToMove == YY_MORE_ADJ) { + retVal = EOB_ACT_END_OF_FILE; + yyrestart(yyscanner->yyin_r, yyscanner); + } else { + retVal = EOB_ACT_LAST_MATCH; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = + YY_BUFFER_EOF_PENDING; + } + } else { + retVal = EOB_ACT_CONTINUE_SCAN; + } + if ((yyscanner->yyNChars + numberToMove) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize) { + /* Extend the array by 50%, plus the number we really need. */ + int newSize = yyscanner->yyNChars + numberToMove + (yyscanner->yyNChars >> 1); + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf = (char *) yyrealloc( + (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf, (size_t) newSize, yyscanner); + if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf == NULL) { + yypanic("out of dynamic memory in yy_get_next_buffer()", yyscanner); + } + /* "- 2" to take care of EOB's */ + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize = (int) (newSize - 2); + } + + yyscanner->yyNChars += numberToMove; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; + + yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[0]; + + return retVal; +} + int yyinput(yyscan_t yyscanner) { int c; @@ -932,54 +1132,6 @@ m4_define([[M4_YY_NO_POP_STATE]]) m4_define([[M4_YY_NO_TOP_STATE]]) ]]) -m4_ifdef([[M4_MODE_USER_YYREAD]],, [[ -/* Gets input and stuffs it into "buf". Number of characters read, or YY_NULL, - * is returned in "result". - */ -static int yyread(char *buf, size_t maxSize, yyscan_t yyscanner) { - int result; -m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ - errno=0; - while ((result = (int) read(fileno(yyscanner->yyin_r), buf, (size_t) maxSize)) < 0) { - if(errno != EINTR) { - yypanic("input in flex scanner failed", yyscanner); - break; - } - errno=0; - clearerr(yyscanner->yyin_r); - } -]]) -m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ - if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyIsInteractive) { - int c = '*'; - int n; - for (n = 0; n < maxSize && - (c = getc(yyscanner->yyin_r)) != EOF && c != '\n'; ++n) { - buf[n] = (char) c; - } - if (c == '\n') { - buf[n++] = (char) c; - } - if (c == EOF && ferror(yyscanner->yyin_r)) { - yypanic("input in flex scanner failed", yyscanner); - } - result = n; - } else { - errno=0; - while ((result = (int) fread(buf, 1, (size_t) maxSize, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { - if(errno != EINTR) { - yypanic("input in flex scanner failed", yyscanner); - break; - } - errno=0; - clearerr(yyscanner->yyin_r); - } - } -]]) - return result; -} -]]) - /* STARTS Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -1285,28 +1437,6 @@ void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { } -m4_ifdef([[M4_MODE_YYMORE_USED]], [[ -m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext_r);} -m4_define([[YY_MORE_ADJ]], [[0]]) -m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ -yyscanner->yyMoreOffset = yyscanner->yyPrevMoreOffset; -yyscanner->yyleng_r -= yyscanner->yyMoreOffset; -} -]]) -]]) -m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yyMoreFlag = true;} -m4_define([[YY_MORE_ADJ]], [[yyscanner->yyMoreLen]]) -m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) -]]) -]]) - -m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[ -m4_define([[YY_MORE_ADJ]], [[0]]) -m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) -]]) - void yysetbol(bool atBOL, yyscan_t yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); @@ -1432,136 +1562,6 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscann } ]]) -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf; - char *source = yyscanner->yytext_ptr; - int numberToMove, i; - int retVal; - - if (yyscanner->yyCBufP > &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1]) { - yypanic("fatal flex scanner internal error--end of buffer missed", yyscanner); - } - if (!yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyFillBuffer) { - /* Don't try to fill the buffer, so this is an EOF. */ - if (yyscanner->yyCBufP - yyscanner->yytext_ptr - YY_MORE_ADJ == 1) { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } else { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - numberToMove = (int) (yyscanner->yyCBufP - yyscanner->yytext_ptr - 1); - - for (i = 0; i < numberToMove; ++i) { - *(dest++) = *(source++); - } - if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus == YY_BUFFER_EOF_PENDING) { - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars = 0; - } else { - int num_to_read = - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - numberToMove - 1; - - while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */ -m4_ifdef([[M4_MODE_USES_REJECT]], -[[ - yypanic( - "input buffer overflow, can't enlarge buffer because scanner uses reject", yyscanner); -]], -[[ - /* just a shorter name for the current buffer */ - yybuffer b = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]; - - int yyCBufP_offset = - (int) (yyscanner->yyCBufP - b->yyChBuf); - - if (b->yyIsOurBuffer) { - int newSize = b->yyInputBufSize * 2; - - if (newSize <= 0) { - b->yyInputBufSize += b->yyInputBufSize / 8; - } else { - b->yyInputBufSize *= 2; - } - b->yyChBuf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yyChBuf, - (size_t) (b->yyInputBufSize + 2), yyscanner); - } else { - /* Can't grow it, we don't own it. */ - b->yyChBuf = NULL; - } - if (b->yyChBuf == NULL) { - yypanic("fatal error - scanner input buffer overflow", yyscanner); - } - yyscanner->yyCBufP = &b->yyChBuf[yyCBufP_offset]; - - num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - - numberToMove - 1; -]]) - } - - if (num_to_read > YY_READ_BUF_SIZE) { - num_to_read = YY_READ_BUF_SIZE; - } - /* Read in more data. */ - yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove], num_to_read, yyscanner); - - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; - } - - if (yyscanner->yyNChars == 0) { - if (numberToMove == YY_MORE_ADJ) { - retVal = EOB_ACT_END_OF_FILE; - yyrestart(yyscanner->yyin_r, yyscanner); - } else { - retVal = EOB_ACT_LAST_MATCH; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = - YY_BUFFER_EOF_PENDING; - } - } else { - retVal = EOB_ACT_CONTINUE_SCAN; - } - if ((yyscanner->yyNChars + numberToMove) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize) { - /* Extend the array by 50%, plus the number we really need. */ - int newSize = yyscanner->yyNChars + numberToMove + (yyscanner->yyNChars >> 1); - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf = (char *) yyrealloc( - (void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf, (size_t) newSize, yyscanner); - if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf == NULL) { - yypanic("out of dynamic memory in yy_get_next_buffer()", yyscanner); - } - /* "- 2" to take care of EOB's */ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize = (int) (newSize - 2); - } - - yyscanner->yyNChars += numberToMove; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; - - yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[0]; - - return retVal; -} - m4_ifdef([[M4_YY_NO_SCAN_STRING]],, [[ /** Setup the input buffer state to scan a string. The next call to yylex() will -- cgit v1.2.1 From df34448330392a583a878b6a9990c63dde5aa412 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 17:07:37 -0500 Subject: More Go back end cleanup. Remove the Bison-bdidge kludge. Rearrange yyguts_t so the public members are grouped together. --- src/go-flex.skl | 107 +++++++++----------------------------------------------- 1 file changed, 16 insertions(+), 91 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index b62ef80..4964359 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -99,7 +99,7 @@ m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[ yyCurrentState = *yyscanner->yyStatePtr; /* restore curr. state */ ]]) ++yyscanner->yyLp; - goto find_rule; + goto findRuleLabel; } ]]) @@ -416,17 +416,25 @@ const int YY_TRAILING_HEAD_MASK = 0x4000; ]]) /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { + /* Public interface */ + FILE *yyin_r, *yyout_r; + int yyleng_r; + int yylineno_r; + int yyflexdebug_r; +m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ + char yytext_r[YYLMAX]; +]], [[ + char *yytext_r; +]]) + /* User-defined. Not touched by flex. */ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[M4_MODE_EXTRA_TYPE yyextra_r;]]) - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; size_t yyBufferStackTop; /**< index of top of stack. */ size_t yyBufferStackMax; /**< capacity of stack. */ yybuffer * yyBufferStack; /**< Stack as an array. */ char yyHoldChar; int yyNChars; - int yyleng_r; char *yyCBufP; bool yyInit; int yyStart; @@ -437,15 +445,11 @@ struct yyguts_t { yyStateType yyLastAcceptingState; char* yyLastAcceptingCharPos; - int yylineno_r; - int yyflexdebug_r; - m4_ifdef([[M4_MODE_USES_REJECT]], [[ yyStateType *yyStateBuf; yyStateType *yyStatePtr; char *yyFullMatch; int yyLp; - m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl /* These are only needed for trailing context rules */ int yyLookingForTrailBegin; @@ -454,36 +458,15 @@ m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl ]]) ]]) m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ - char yytext_r[YYLMAX]; char *yytext_ptr; int yyMoreOffset; int yyPrevMoreOffset; ]], [[ - char *yytext_r; bool yyMoreFlag; int yyMoreLen; ]]) -m4_ifdef([[M4_YY_BISON_LVAL]], [[ - YYSTYPE * yylval_r; -]]) - -m4_ifdef([[]], [[ - YYLTYPE * yylloc_r; -]]) }; /* end struct yyguts_t */ -m4_ifdef([[M4_YY_BISON_LVAL]], -[[ -/* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ -m4_define([[yylval]], [[yyscanner->yylval_r]]) -]]) - -m4_ifdef([[]], -[[ -m4_define([[yylloc]], [[yyscanner->yylloc_r]]) -]]) - /* Helpers for special functions, also part of public API */ /* Returns the top of the stack, or NULL. */ @@ -1298,40 +1281,6 @@ void yyset_debug(int bdebug, yyscan_t yyscanner) { } ]]) -m4_ifdef([[M4_YY_BISON_LVAL]], [[ -m4_ifdef([[M4_YY_NO_GET_LVAL]],, -[[ -YYSTYPE *yyget_lval(yyscan_t yyscanner) { - return yylval; -} -]]) - -m4_ifdef([[M4_YY_NO_SET_LVAL]],, -[[ -void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) { - yylval = yylval_param; -} -]]) - -m4_ifdef([[]], -[[ -m4_ifdef([[M4_YY_NO_GET_LLOC]],, -[[ -YYLTYPE *yyget_lloc (yyscan_t yyscanner) { - return yylloc; -} -]]) - -m4_ifdef([[M4_YY_NO_SET_LLOC]],, -[[ -void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner) { - yylloc = yylloc_param; -} -]]) -]]) - -]]) - /* ENDS public accessor functions */ /* Number of entries by which start-condition stack grows. */ @@ -1343,30 +1292,6 @@ const int YY_START_STACK_INCR = 25; m4_ifdef([[YY_DECL]],, [[m4_dnl m4_define([[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) m4_define([[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) - -m4_ifdef([[M4_YY_BISON_LVAL]], -[[ - m4_dnl The bison pure parser is used. Redefine yylex to - m4_dnl accept the lval parameter. - - m4_define([[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) - m4_define([[M4_YY_LEX_DECLARATION]], [[\]] - [[(YYSTYPE * yylval_param, yyscan_t yyscanner)]]) -]]) - -m4_ifdef([[]], -[[ - m4_dnl Locations are used. yylex should also accept the ylloc parameter. - - m4_define([[M4_YY_LEX_PROTO]], [[\]] - [[(YYSTYPE * yylval_param, YYLTYPE * yylloc_param, yyscan_t yyscanner)]]) - m4_define([[M4_YY_LEX_DECLARATION]], [[\]] - [[(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)]]) -]]) - -extern int yylex M4_YY_LEX_PROTO; - m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) ]]) @@ -1962,7 +1887,7 @@ m4_ifdef([[M4_MODE_NO_INTERACTIVE]], [[ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT]], [[ yyCurrentState = *--yyscanner->yyStatePtr; yyscanner->yyLp = yyAccept[yyCurrentState]; -m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[find_rule: /* we branch to this label when backing up */]]) +m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_REALLY_USED]], [[findRuleLabel: /* we branch to this label when backing up */]]) for (; ;) { /* loop until we find out what rule we matched */ if (yyscanner->yyLp && yyscanner->yyLp < yyAccept[yyCurrentState + 1]) { yyAct = yyAcclist[yyscanner->yyLp]; @@ -1991,7 +1916,7 @@ m4_ifdef([[M4_MODE_REAL_REJECT]], [[ break; } ++yyscanner->yyLp; - goto find_rule; + goto findRuleLabel; ]]) m4_ifdef([[M4_MODE_NO_VARIABLE_TRAILING_CONTEXT_RULES]], [[ /* Remember matched text in case we back up due to @@ -2340,8 +2265,8 @@ int yylex_destroy (yyscan_t yyscanner) { m4_ifdef([[M4_MODE_USES_REJECT]], [[ - yyfree (yyscanner->yyStateBuf, yyscanner); - yyscanner->yyStateBuf = NULL; + yyfree(yyscanner->yyStateBuf, yyscanner); + yyscanner->yyStateBuf = NULL; ]]) /* Reset the globals. This is important in a non-reentrant scanner so the next time -- cgit v1.2.1 From 75da1e1d8a8dc0b89803495b951627e76e821822 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 17:33:02 -0500 Subject: In the Go back end, elimate some forwards. --- src/go-flex.skl | 68 +++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index 4964359..0790613 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -254,14 +254,37 @@ struct yy_buffer_state { int yyBufferStatus; }; -/* These forwards can simply deleted when poerting to a target language - * with two-pass name resoltion. - */ -void *yyalloc (size_t, yyscan_t yyscanner); -void *yyrealloc (void *, size_t, yyscan_t yyscanner); -void yyfree (void *, yyscan_t yyscanner); -/* Begin user sect3 */ +m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc(size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return malloc(size); +} +]]) + +m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) + +m4_ifdef([[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + free((char *) ptr); +} +]]) m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ int yywrap(yyscan_t yyscanner) { @@ -2279,37 +2302,6 @@ m4_ifdef([[M4_MODE_USES_REJECT]], return 0; } -m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc(size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return malloc(size); -} -]]) - -m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return realloc(ptr, size); -} -]]) - -m4_ifdef([[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree(void * ptr, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - free((char *) ptr); -} -]]) - m4_ifdef([[M4_YY_MAIN]], [[ int main () { yyscan_t lexer; -- cgit v1.2.1 From 5a9a913893c2c8309fb0f9ea9ab8e2331e5ba9dc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 18:26:48 -0500 Subject: Eliminate forwards in the C99 back end. --- src/c99-flex.skl | 67 +++++++++++++++++++++---------------------------- tests/alloc_extra_c99.l | 2 ++ tests/mem_c99.l | 21 +++++++++------- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index a72ccee..478a9d2 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -339,14 +339,36 @@ struct yy_buffer_state { int yy_buffer_status; }; -/* These forwards can simply deleted when poerting to a target language - * with two-pass name resoltion. - */ -void *yyalloc ( yy_size_t, yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); -void yyfree ( void *, yyscan_t yyscanner ); +m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc(yy_size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return malloc(size); +} +]]) -/* Begin user sect3 */ +m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + free( (char *) ptr ); +} +]]) m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ int M4_MODE_PREFIX[[wrap]](yyscan_t yyscanner) { @@ -2444,37 +2466,6 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], return 0; } -m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc(yy_size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return malloc(size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return realloc(ptr, size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree(void * ptr, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - free( (char *) ptr ); -} -]]) - m4_ifdef([[M4_YY_MAIN]], [[ int main () { yyscan_t lexer; diff --git a/tests/alloc_extra_c99.l b/tests/alloc_extra_c99.l index 67c3526..d99a4ca 100644 --- a/tests/alloc_extra_c99.l +++ b/tests/alloc_extra_c99.l @@ -40,6 +40,8 @@ struct Check { char qux; }; +void *yyalloc(size_t, yyscan_t); + /* Save char into junk array at next position. */ static void check_extra ( yyscan_t scanner ); diff --git a/tests/mem_c99.l b/tests/mem_c99.l index fefe67b..1d206b5 100644 --- a/tests/mem_c99.l +++ b/tests/mem_c99.l @@ -37,10 +37,13 @@ #endif #define YY_BUF_SIZE 8 +void * yyalloc(yy_size_t, yyscan_t); +void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); +void yyfree ( void *, yyscan_t yyscanner ); %} %option emit="c99" bufsize=8 -%option 8bit prefix="test" +%option 8bit %option nounput nomain noyywrap noinput noyy_top_state %option warn stack nodefault %option noyyalloc noyyrealloc noyyfree @@ -86,7 +89,7 @@ static void dump_mem(FILE* fp){ fprintf(fp,"}\n"); } -void * testalloc(yy_size_t n , yyscan_t yyscanner) +void * yyalloc(yy_size_t n , yyscan_t yyscanner) { (void)yyscanner; @@ -117,7 +120,7 @@ void * testalloc(yy_size_t n , yyscan_t yyscanner) return p; } -void * testrealloc(void* p, yy_size_t n , yyscan_t yyscanner) +void * yyrealloc(void* p, yy_size_t n , yyscan_t yyscanner) { (void)yyscanner; @@ -140,7 +143,7 @@ void * testrealloc(void* p, yy_size_t n , yyscan_t yyscanner) exit(1); } -void testfree(void* p , yyscan_t yyscanner) +void yyfree(void* p , yyscan_t yyscanner) { (void)yyscanner; @@ -172,11 +175,11 @@ main (void) ptrs = calloc(1, sizeof(struct memsz)); nptrs = 0; - testlex_init(&scanner); - testset_in(stdin,scanner); - testset_out(stdout,scanner); - testlex(scanner); - testlex_destroy(scanner); + yylex_init(&scanner); + yyset_in(stdin,scanner); + yyset_out(stdout,scanner); + yylex(scanner); + yylex_destroy(scanner); free(ptrs); if ( nptrs > 0 || total_mem > 0){ -- cgit v1.2.1 From 0d6d37f246be553cb7fd68fe806549cafc174316 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 20 Nov 2020 04:15:37 -0500 Subject: In the Go back end, begin Go-ifying the public interface. struct yyguts_t becomes FlexLexer typedef. --- src/go-flex.skl | 136 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index 0790613..fe4fa3f 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -438,7 +438,7 @@ const int YY_TRAILING_MASK = 0x2000; const int YY_TRAILING_HEAD_MASK = 0x4000; ]]) /* Holds the entire state of the reentrant scanner. */ -struct yyguts_t { +typedef struct yyguts_t { /* Public interface */ FILE *yyin_r, *yyout_r; int yyleng_r; @@ -488,18 +488,18 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ bool yyMoreFlag; int yyMoreLen; ]]) -}; /* end struct yyguts_t */ +} FlexLexer; /* end struct yyguts_t */ /* Helpers for special functions, also part of public API */ /* Returns the top of the stack, or NULL. */ -yybuffer yy_current_buffer(yyscan_t yyscanner) { +yybuffer yy_current_buffer(FlexLexer *yyscanner) { return (yyscanner->yyBufferStack \ ? yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] \ : NULL); } -static void yy_load_buffer_state (yyscan_t yyscanner) +static void yy_load_buffer_state (FlexLexer *yyscanner) { yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; yyscanner->yytext_ptr = yyscanner->yyCBufP = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufPos; @@ -511,7 +511,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c yy_current_buffer(yyscanner). * @param yyscanner The scanner object. */ -void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) +void yy_flush_buffer(yybuffer b, FlexLexer *yyscanner) { if (b == NULL) { return; @@ -535,7 +535,7 @@ void yy_flush_buffer(yybuffer b, yyscan_t yyscanner) } } -void yy_flush_current_buffer(yyscan_t yyscanner) { +void yy_flush_current_buffer(FlexLexer *yyscanner) { yy_flush_buffer(yy_current_buffer(yyscanner), yyscanner); } @@ -543,7 +543,7 @@ const int YY_EXIT_FAILURE = 2; m4_ifdef([[M4_YY_NO_YYPANIC]],, [[ /* This function has a magic rewrite rule */ -static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { +static void yynoreturn yypanic(const char* msg, FlexLexer *yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ fprintf(stderr, "%s\n", msg); exit(YY_EXIT_FAILURE); @@ -553,7 +553,7 @@ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void yyensure_buffer_stack (yyscan_t yyscanner) +static void yyensure_buffer_stack (FlexLexer *yyscanner) { size_t numToAlloc; @@ -598,7 +598,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ -static void yy_init_buffer(yybuffer b, FILE * file, yyscan_t yyscanner) +static void yy_init_buffer(yybuffer b, FILE * file, FlexLexer *yyscanner) { int oerrno = errno; @@ -638,7 +638,7 @@ m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], * @param yyscanner The scanner object. * @return the allocated buffer state. */ -yybuffer yy_create_buffer(FILE *file, int size, yyscan_t yyscanner) +yybuffer yy_create_buffer(FILE *file, int size, FlexLexer *yyscanner) { yybuffer b; @@ -666,7 +666,7 @@ yybuffer yy_create_buffer(FILE *file, int size, yyscan_t yyscanner) * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ -void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) +void yy_delete_buffer(yybuffer b, FlexLexer *yyscanner) { if (b == NULL) { @@ -688,7 +688,7 @@ void yy_delete_buffer(yybuffer b, yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) +void yypush_buffer_state(yybuffer new_buffer, FlexLexer *yyscanner) { if (new_buffer == NULL) { return; @@ -719,7 +719,7 @@ void yypush_buffer_state(yybuffer new_buffer, yyscan_t yyscanner) * The next element becomes the new top. * @param yyscanner The scanner object. */ -void yypop_buffer_state (yyscan_t yyscanner) +void yypop_buffer_state (FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { return; @@ -741,7 +741,7 @@ void yypop_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ -void yyrestart(FILE * input_file, yyscan_t yyscanner) +void yyrestart(FILE * input_file, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { @@ -754,7 +754,7 @@ void yyrestart(FILE * input_file, yyscan_t yyscanner) yy_load_buffer_state(yyscanner); } -static void yybumpline(yyscan_t yyscanner) { +static void yybumpline(FlexLexer *yyscanner) { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno++; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yycolumn=0; } @@ -767,26 +767,26 @@ static void yybumpline(yyscan_t yyscanner) { */ /* Enter a start condition. */ -void yybegin(int s, yyscan_t yyscanner) { +void yybegin(int s, FlexLexer *yyscanner) { yyscanner->yyStart = 1 + 2 * (s); } /* Translate the current start state into a value that can be later handed * to yybegin() to return to the state. */ -int yystart(yyscan_t yyscanner) { +int yystart(FlexLexer *yyscanner) { return ((yyscanner->yyStart - 1) / 2); } /* This used to be an fputs(), but since the string might contain NULs, * we now use fwrite(). */ -void yyecho(yyscan_t yyscanner) { +void yyecho(FlexLexer *yyscanner) { fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); } m4_ifdef([[M4_YY_NO_YYUNPUT]],, [[ -void yyunput(char c, yyscan_t yyscanner) +void yyunput(char c, FlexLexer *yyscanner) { char *yyCp; @@ -834,7 +834,7 @@ m4_ifdef([[M4_MODE_USER_YYREAD]],, [[ /* Gets input and stuffs it into "buf". Number of characters read, or YY_NULL, * is returned in "result". */ -static int yyread(char *buf, size_t maxSize, yyscan_t yyscanner) { +static int yyread(char *buf, size_t maxSize, FlexLexer *yyscanner) { int result; m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ errno=0; @@ -882,7 +882,7 @@ m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ %# magic functions, so yy_get_next_buffer() won't need a forward declaration. m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext_r);} +void yymore(FlexLexer *yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext_r);} m4_define([[YY_MORE_ADJ]], [[0]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ yyscanner->yyMoreOffset = yyscanner->yyPrevMoreOffset; @@ -891,7 +891,7 @@ yyscanner->yyleng_r -= yyscanner->yyMoreOffset; ]]) ]]) m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -void yymore(yyscan_t yyscanner) {yyscanner->yyMoreFlag = true;} +void yymore(FlexLexer *yyscanner) {yyscanner->yyMoreFlag = true;} m4_define([[YY_MORE_ADJ]], [[yyscanner->yyMoreLen]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) ]]) @@ -909,7 +909,7 @@ m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[]]) * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (yyscan_t yyscanner) +static int yy_get_next_buffer (FlexLexer *yyscanner) { char *dest = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf; char *source = yyscanner->yytext_ptr; @@ -1032,7 +1032,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], return retVal; } -int yyinput(yyscan_t yyscanner) +int yyinput(FlexLexer *yyscanner) { int c; @@ -1114,22 +1114,22 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ */ m4_ifdef([[M4_MODE_NO_YYWRAP]],, [[ -extern int yywrap (yyscan_t yyscanner); +extern int yywrap (FlexLexer *yyscanner); ]]) m4_ifdef([[M4_YY_STACK_USED]], [[ m4_ifdef([[M4_YY_NO_PUSH_STATE]],, [[ - static void yy_push_state (int newState, yyscan_t yyscanner); + static void yy_push_state (int newState, FlexLexer *yyscanner); ]]) m4_ifdef([[M4_YY_NO_POP_STATE]],, [[ - static void yy_pop_state (yyscan_t yyscanner); + static void yy_pop_state (FlexLexer *yyscanner); ]]) m4_ifdef([[M4_YY_NO_TOP_STATE]],, [[ - static int yy_top_state (yyscan_t yyscanner); + static int yy_top_state (FlexLexer *yyscanner); ]]) ]], [[ @@ -1146,7 +1146,7 @@ m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -M4_MODE_EXTRA_TYPE yyget_extra(yyscan_t yyscanner) { +M4_MODE_EXTRA_TYPE yyget_extra(FlexLexer *yyscanner) { return yyscanner->yyextra_r; } ]]) @@ -1157,7 +1157,7 @@ m4_ifdef([[M4_YY_NO_GET_LINENO]],, /** Get the current line number. * @param yyscanner The scanner object. */ -int yyget_lineno(yyscan_t yyscanner) { +int yyget_lineno(FlexLexer *yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); if (cb == NULL) { @@ -1172,7 +1172,7 @@ m4_ifdef([[M4_YY_NO_GET_COLUMN]],, /** Get the current column number. * @param yyscanner The scanner object. */ -int yyget_column (yyscan_t yyscanner) { +int yyget_column (FlexLexer *yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); if (cb == NULL) { @@ -1187,7 +1187,7 @@ m4_ifdef([[M4_YY_NO_GET_IN]],, /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *yyget_in (yyscan_t yyscanner) { +FILE *yyget_in (FlexLexer *yyscanner) { return yyscanner->yyin_r; } ]]) @@ -1197,7 +1197,7 @@ m4_ifdef([[M4_YY_NO_GET_OUT]],, /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *yyget_out (yyscan_t yyscanner) { +FILE *yyget_out (FlexLexer *yyscanner) { return yyscanner->yyout_r; } ]]) @@ -1207,7 +1207,7 @@ m4_ifdef([[M4_YY_NO_GET_LENG]],, /** Get the length of the current token. * @param yyscanner The scanner object. */ -int yyget_leng (yyscan_t yyscanner) { +int yyget_leng (FlexLexer *yyscanner) { return yyscanner->yyleng_r; } ]]) @@ -1217,7 +1217,7 @@ int yyget_leng (yyscan_t yyscanner) { */ m4_ifdef([[M4_YY_NO_GET_TEXT]],, [[ -char *yyget_text (yyscan_t yyscanner) { +char *yyget_text (FlexLexer *yyscanner) { return yyscanner->yytext_r; } ]]) @@ -1229,7 +1229,7 @@ m4_ifdef([[M4_YY_NO_SET_EXTRA]],, * @param userDefined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void yyset_extra(M4_MODE_EXTRA_TYPE userDefined, yyscan_t yyscanner) { +void yyset_extra(M4_MODE_EXTRA_TYPE userDefined, FlexLexer *yyscanner) { yyscanner->yyextra_r = userDefined; } ]]) @@ -1241,7 +1241,7 @@ m4_ifdef([[M4_YY_NO_SET_LINENO]],, * @param lineNumber line number * @param yyscanner The scanner object. */ -void yyset_lineno(int lineNumber, yyscan_t yyscanner) { +void yyset_lineno(int lineNumber, FlexLexer *yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); /* lineno is only valid if an input buffer exists. */ @@ -1258,7 +1258,7 @@ m4_ifdef([[M4_YY_NO_SET_COLUMN]],, * @param columnNo column number * @param yyscanner The scanner object. */ -void yyset_column(int columnNo, yyscan_t yyscanner) { +void yyset_column(int columnNo, FlexLexer *yyscanner) { yybuffer cb = yy_current_buffer(yyscanner); /* column is only valid if an input buffer exists. */ @@ -1277,14 +1277,14 @@ m4_ifdef([[M4_YY_NO_SET_IN]],, * @param yyscanner The scanner object. * @see yy_switch_to_buffer */ -void yyset_in(FILE *inStream, yyscan_t yyscanner) { +void yyset_in(FILE *inStream, FlexLexer *yyscanner) { yyscanner->yyin_r = inStream ; } ]]) m4_ifdef([[M4_YY_NO_SET_OUT]],, [[ -void yyset_out(FILE *outStream, yyscan_t yyscanner) { +void yyset_out(FILE *outStream, FlexLexer *yyscanner) { yyscanner->yyout_r = outStream ; } ]]) @@ -1292,14 +1292,14 @@ void yyset_out(FILE *outStream, yyscan_t yyscanner) { m4_ifdef([[M4_YY_NO_GET_DEBUG]],, [[ -int yyget_debug(yyscan_t yyscanner) { +int yyget_debug(FlexLexer *yyscanner) { return yyscanner->yyflexdebug_r; } ]]) m4_ifdef([[M4_YY_NO_SET_DEBUG]],, [[ -void yyset_debug(int bdebug, yyscan_t yyscanner) { +void yyset_debug(int bdebug, FlexLexer *yyscanner) { yyscanner->yyflexdebug_r = bdebug ; } ]]) @@ -1313,13 +1313,13 @@ const int YY_START_STACK_INCR = 25; * easily add parameters. */ m4_ifdef([[YY_DECL]],, [[m4_dnl -m4_define([[M4_YY_LEX_PROTO]], [[(yyscan_t yyscanner)]]) -m4_define([[M4_YY_LEX_DECLARATION]], [[(yyscan_t yyscanner)]]) +m4_define([[M4_YY_LEX_PROTO]], [[(FlexLexer *yyscanner)]]) +m4_define([[M4_YY_LEX_DECLARATION]], [[(FlexLexer *yyscanner)]]) m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) ]]) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ -static void rule_check_bol(yyscan_t yyscanner) { +static void rule_check_bol(FlexLexer *yyscanner) { if (yyscanner->yyleng_r > 0) { \ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); } @@ -1331,7 +1331,7 @@ static void rule_check_bol(yyscan_t yyscanner) { * end abd start pointers for the input buffer segment that is * claimed as yytext. */ -void yyDoBeforeAction(yyscan_t yyscanner, char *yyCp, char *yyBp) { +void yyDoBeforeAction(FlexLexer *yyscanner, char *yyCp, char *yyBp) { yyscanner->yytext_ptr = yyBp; \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yyMoreLen; \ yyscanner->yyleng_r = (int) (yyCp - yyscanner->yytext_ptr);]])]]) \ @@ -1356,7 +1356,7 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ m4_ifdef([[M4_MODE_YYLINENO]], [[ /* FIXME: gate on yyRuleCanMatchEOL, this is no longer a macro * and we can get at yyAct */ -static void yyLessLineno(int n, yyscan_t yyscanner) { +static void yyLessLineno(int n, FlexLexer *yyscanner) { int yyl; for (yyl = n; yyl < yyscanner->yyleng_r; ++yyl) { if (yyscanner->yytext_r[yyl] == '\n') { @@ -1365,7 +1365,7 @@ static void yyLessLineno(int n, yyscan_t yyscanner) { } } -static void yyLinenoRewindTo(char *yyCp, char *dst, yyscan_t yyscanner) { +static void yyLinenoRewindTo(char *yyCp, char *dst, FlexLexer *yyscanner) { const char *p; for (p = yyCp-1; p >= dst; --p) { if (*p == '\n') { @@ -1375,7 +1375,7 @@ static void yyLinenoRewindTo(char *yyCp, char *dst, yyscan_t yyscanner) { } ]]) -void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { +void yy_set_interactive(bool is_interactive, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = @@ -1385,7 +1385,7 @@ void yy_set_interactive(bool is_interactive, yyscan_t yyscanner) { } -void yysetbol(bool atBOL, yyscan_t yyscanner) { +void yysetbol(bool atBOL, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = @@ -1394,7 +1394,7 @@ void yysetbol(bool atBOL, yyscan_t yyscanner) { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = atBOL; } -bool yyatbol(yyscan_t yyscanner) { +bool yyatbol(FlexLexer *yyscanner) { return (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag); } @@ -1402,7 +1402,7 @@ bool yyatbol(yyscan_t yyscanner) { * @param newBuffer The new input buffer. * @param yyscanner The scanner object. */ -void yy_switch_to_buffer(yybuffer newBuffer, yyscan_t yyscanner) +void yy_switch_to_buffer(yybuffer newBuffer, FlexLexer *yyscanner) { /* TODO. We should be able to replace this entire function body @@ -1441,7 +1441,7 @@ m4_ifdef([[M4_YY_NO_SCAN_BUFFER]],, * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -yybuffer yy_scan_buffer(char *base, size_t size, yyscan_t yyscanner) +yybuffer yy_scan_buffer(char *base, size_t size, FlexLexer *yyscanner) { yybuffer b; @@ -1480,7 +1480,7 @@ m4_ifdef([[M4_YY_NO_SCAN_BYTES]],, * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { +yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, FlexLexer *yyscanner) { yybuffer b; char *buf; size_t n; @@ -1520,7 +1520,7 @@ m4_ifdef([[M4_YY_NO_SCAN_STRING]],, * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) +yybuffer yy_scan_string(const char * yystr, FlexLexer *yyscanner) { return yy_scan_bytes(yystr, (int) strlen(yystr), yyscanner); } @@ -1528,7 +1528,7 @@ yybuffer yy_scan_string(const char * yystr, yyscan_t yyscanner) m4_ifdef([[M4_YY_NO_PUSH_STATE]],, [[ -static void yy_push_state(int newState, yyscan_t yyscanner) +static void yy_push_state(int newState, FlexLexer *yyscanner) { if (yyscanner->yyStartStackOffset >= yyscanner->yyStartStackDepth) { size_t newSize; @@ -1556,7 +1556,7 @@ static void yy_push_state(int newState, yyscan_t yyscanner) m4_ifdef([[M4_YY_NO_POP_STATE]],, [[ -static void yy_pop_state(yyscan_t yyscanner) +static void yy_pop_state(FlexLexer *yyscanner) { if (--yyscanner->yyStartStackOffset < 0) { yypanic("start-condition stack underflow", yyscanner); @@ -1568,7 +1568,7 @@ static void yy_pop_state(yyscan_t yyscanner) m4_ifdef([[M4_YY_NO_TOP_STATE]],, [[ -static int yy_top_state(yyscan_t yyscanner) +static int yy_top_state(FlexLexer *yyscanner) { return yyscanner->yyStartStackOffset > 0 ? yyscanner->yyStartStack[yyscanner->yyStartStackOffset - 1] : yystart(yyscanner); } @@ -1674,7 +1674,7 @@ m4_ifdef([[M4_MODE_NO_USEECS]], [[m4_define([[M4_EC]], [[$1]])]]) /* yyGetPreviousState - get the state just before the EOB char was reached */ -static yyStateType yyGetPreviousState(yyscan_t yyscanner) { +static yyStateType yyGetPreviousState(FlexLexer *yyscanner) { yyStateType yyCurrentState; char *yyCp; @@ -1717,7 +1717,7 @@ m4_ifdef([[M4_MODE_NULTRANS]], [[ * synopsis * next_state = yyTryNULtrans(current_state); */ -static yyStateType yyTryNULtrans(yyStateType yyCurrentState, yyscan_t yyscanner) +static yyStateType yyTryNULtrans(yyStateType yyCurrentState, FlexLexer *yyscanner) { bool yyIsJam; /* Generate code for handling NULs, if needed. */ @@ -2163,7 +2163,7 @@ m4_undefine([[yyless]]) /* Redefine yyless() so it works in section 3 code. */ -void yyless(int n, yyscan_t yyscanner) { +void yyless(int n, FlexLexer *yyscanner) { /* Undo effects of setting up yytext. */ m4_ifdef([[M4_MODE_YYLINENO]], [[yyLessLineno(n, yyscanner);]]) yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yyHoldChar; @@ -2173,7 +2173,7 @@ void yyless(int n, yyscan_t yyscanner) { yyscanner->yyleng_r = n; } -static int yy_init_globals (yyscan_t yyscanner) { +static int yy_init_globals (FlexLexer *yyscanner) { /* * This function is called from yylex_destroy(), so don't allocate here. */ @@ -2220,7 +2220,7 @@ int yylex_init(yyscan_t *globalsPtr) { return 1; } - *globalsPtr = (yyscan_t) yyalloc (sizeof(struct yyguts_t), NULL); + *globalsPtr = (yyscan_t) yyalloc (sizeof(FlexLexer), NULL); if (*globalsPtr == NULL) { errno = ENOMEM; @@ -2228,7 +2228,7 @@ int yylex_init(yyscan_t *globalsPtr) { } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*globalsPtr,0x00,sizeof(struct yyguts_t)); + memset(*globalsPtr,0x00,sizeof(FlexLexer)); return yy_init_globals (*globalsPtr); } @@ -2242,7 +2242,7 @@ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl * the yyextra field. */ int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { - struct yyguts_t dummyYyguts; + FlexLexer dummyYyguts; yyset_extra(yyUserDefined, &dummy_yyguts); @@ -2251,7 +2251,7 @@ int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { return 1; } - *globalsPtr = (yyscan_t) yyalloc(sizeof(struct yyguts_t), &dummyYyguts); + *globalsPtr = (yyscan_t) yyalloc(sizeof(FlexLexer), &dummyYyguts); if (*globalsPtr == NULL) { errno = ENOMEM; @@ -2260,7 +2260,7 @@ int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*globalsPtr,0x00,sizeof(struct yyguts_t)); + memset(*globalsPtr,0x00,sizeof(FlexLexer)); yyset_extra(yyUserDefined, *globalsPtr); @@ -2269,7 +2269,7 @@ int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { ]]) /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) { +int yylex_destroy(FlexLexer *yyscanner) { /* Pop the buffer stack, destroying each element. */ while(yy_current_buffer(yyscanner)) { -- cgit v1.2.1 From 7b3f8db536f318b272b24ca83523ea5aa61580aa Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 20 Nov 2020 05:52:06 -0500 Subject: Improve information hiding in C99 and Go back ends. Things that don't need to be declared before that DFA tables shouldn't be. --- src/c99-flex.skl | 246 ++++++++++++++++++++++++++--------------------------- src/go-flex.skl | 221 ++++++++++++++++++++++++----------------------- tests/mem_c99.l | 8 +- tests/prefix_c99.l | 4 +- 4 files changed, 238 insertions(+), 241 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index 478a9d2..ddf4185 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -272,110 +272,6 @@ m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) */ m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yy_state_type))]]) -typedef struct yy_buffer_state *yybuffer; - -typedef size_t yy_size_t; - -%# These are not part of the exported interface and can safewly be renamed -const int EOB_ACT_CONTINUE_SCAN = 0; -const int EOB_ACT_END_OF_FILE = 1; -const int EOB_ACT_LAST_MATCH = 2; -const int YY_BUFFER_NEW = 0; -const int YY_BUFFER_NORMAL = 1; - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -const int YY_BUFFER_EOF_PENDING = 2; - -struct yy_buffer_state { - FILE *yy_input_file; - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - bool yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use char-by-char - * rather than a buffered read, to make sure we stop fetching input after - * each newline. - */ - bool yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - bool yyatbol_flag; - - int bs_yylineno; /**< The line count. */ - int bs_yycolumn; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - bool yy_fill_buffer; - - int yy_buffer_status; -}; - -m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc(yy_size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return malloc(size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc(void * ptr, yy_size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return realloc(ptr, size); -} -]]) - -m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree(void * ptr, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - free( (char *) ptr ); -} -]]) - -m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ -int M4_MODE_PREFIX[[wrap]](yyscan_t yyscanner) { - return /*CONSTCOND*/1; -} -]]) - const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); typedef uint8_t YY_CHAR; @@ -386,13 +282,6 @@ typedef const struct yy_trans_info *yy_state_type; typedef int yy_state_type; ]]) -/* Watch out: yytext_ptr is a variable when yytext is an array, - * but it's a macro when yytext is a pointer. - */ -m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -m4_define([[yytext_ptr]], [[yytext_r]]) -]]) - %% [1.0] DFA struct yy_trans_info { @@ -420,7 +309,7 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ ]]) }; -%% [2.0] data tables for the DFA are inserted here +%% [2.0] payload macros for the DFA data tables are inserted here m4_ifdef( [[M4_HOOK_NXT_ROWS]],[[m4_dnl static const M4_HOOK_NXT_TYPE yy_nxt[][M4_HOOK_NXT_ROWS] = @@ -515,6 +404,78 @@ M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl M4_YY_SC_DEFS +typedef struct yy_buffer_state *yybuffer; + +%# These are not part of the exported interface and can safewly be renamed +const int EOB_ACT_CONTINUE_SCAN = 0; +const int EOB_ACT_END_OF_FILE = 1; +const int EOB_ACT_LAST_MATCH = 2; +const int YY_BUFFER_NEW = 0; +const int YY_BUFFER_NORMAL = 1; + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +const int YY_BUFFER_EOF_PENDING = 2; + +struct yy_buffer_state { + FILE *yy_input_file; + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + bool yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use char-by-char + * rather than a buffered read, to make sure we stop fetching input after + * each newline. + */ + bool yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + bool yyatbol_flag; + + int bs_yylineno; /**< The line count. */ + int bs_yycolumn; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + bool yy_fill_buffer; + + int yy_buffer_status; +}; + +/* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_define([[yytext_ptr]], [[yytext_r]]) +]]) + m4_ifdef( [[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl %# These must match the values in the file flexdef.h %# of the flex source code, otherwise havoc will ensue. @@ -591,6 +552,43 @@ m4_ifdef( [[]], m4_define([[yylloc]], [[yyscanner->yylloc_r]]) ]]) +m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc(size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return malloc(size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc(void * ptr, size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) + +m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + free( (char *) ptr ); +} +]]) + +m4_ifdef( [[M4_MODE_NO_YYWRAP]], [[ +int M4_MODE_PREFIX[[wrap]](yyscan_t yyscanner) { + return /*CONSTCOND*/1; +} +]]) + /* Helpers for special functions, also part of public API */ /* Returns the top of the stack, or NULL. */ @@ -656,7 +654,7 @@ static void yynoreturn yypanic(const char* msg, yyscan_t yyscanner) { */ static void yyensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; + size_t num_to_alloc; if (yyscanner->yy_buffer_stack == NULL) { /* First allocation is just for 2 elements, since we don't know if this @@ -679,7 +677,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) if (yyscanner->yy_buffer_stack_top >= (yyscanner->yy_buffer_stack_max) - 1) { /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; + size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyscanner->yy_buffer_stack_max + grow_size; yyscanner->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc @@ -752,7 +750,7 @@ yybuffer yy_create_buffer(FILE * file, int size, yyscan_t yyscanner) /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + b->yy_ch_buf = (char *) yyalloc( (size_t) (b->yy_buf_size + 2), yyscanner ); if ( b->yy_ch_buf == NULL ) { yypanic( "out of dynamic memory in yy_create_buffer()", yyscanner ); } @@ -964,7 +962,7 @@ static int yyread(char *buf, size_t max_size, yyscan_t yyscanner) { int result; m4_ifdef( [[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (yy_size_t) max_size )) < 0 ) { + while ( (result = (int) read( fileno(yyscanner->yyin_r), buf, (size_t) max_size )) < 0 ) { if( errno != EINTR) { yypanic( "input in flex scanner failed", yyscanner); break; @@ -990,7 +988,7 @@ m4_ifdef( [[M4_MODE_NO_CPP_USE_READ]], [[ result = n; } else { errno=0; - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + while ( (result = (int) fread(buf, 1, (size_t) max_size, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { if( errno != EINTR) { yypanic( "input in flex scanner failed", yyscanner); break; @@ -1077,7 +1075,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2), yyscanner ); + (size_t) (b->yy_buf_size + 2), yyscanner ); } else { /* Can't grow it, we don't own it. */ b->yy_ch_buf = NULL; @@ -1117,7 +1115,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]], /* Extend the array by 50%, plus the number we really need. */ int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1); yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc( - (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (yy_size_t) new_size, yyscanner ); + (void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (size_t) new_size, yyscanner ); if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) { yypanic( "out of dynamic memory in yy_get_next_buffer()", yyscanner); } @@ -1601,7 +1599,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -yybuffer yy_scan_buffer(char * base, yy_size_t size, yyscan_t yyscanner) +yybuffer yy_scan_buffer(char * base, size_t size, yyscan_t yyscanner) { yybuffer b; @@ -1643,11 +1641,11 @@ m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, yyscan_t yyscanner) { yybuffer b; char *buf; - yy_size_t n; + size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); + n = (size_t) (_yybytes_len + 2); buf = (char *) yyalloc( n, yyscanner ); if ( buf == 0 ) { yypanic( "out of dynamic memory in yy_scan_bytes()", yyscanner ); @@ -1691,10 +1689,10 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, static void yy_push_state(int _new_state, yyscan_t yyscanner) { if ( yyscanner->yy_start_stack_ptr >= yyscanner->yy_start_stack_depth ) { - yy_size_t new_size; + size_t new_size; yyscanner->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = (yy_size_t) yyscanner->yy_start_stack_depth * sizeof( int ); + new_size = (size_t) yyscanner->yy_start_stack_depth * sizeof( int ); if ( yyscanner->yy_start_stack == NULL ) { yyscanner->yy_start_stack = (int *) yyalloc( new_size, yyscanner ); diff --git a/src/go-flex.skl b/src/go-flex.skl index fe4fa3f..c75cdb4 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -189,109 +189,6 @@ m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) */ m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yyStateType))]]) -typedef struct yy_buffer_state *yybuffer; - -%# These are not part of the exported interface and can safely be renamed -const int EOB_ACT_CONTINUE_SCAN = 0; -const int EOB_ACT_END_OF_FILE = 1; -const int EOB_ACT_LAST_MATCH = 2; -const int YY_BUFFER_NEW = 0; -const int YY_BUFFER_NORMAL = 1; - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -const int YY_BUFFER_EOF_PENDING = 2; - -struct yy_buffer_state { - FILE *yyInputFile; - char *yyChBuf; /* input buffer */ - char *yyBufPos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yyInputBufSize; - - /* Number of characters read into yyChBuf, not including EOB - * characters. - */ - int yyNChars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - bool yyIsOurBuffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use char-by-char - * rather than a buffered read, to make sure we stop fetching input after - * each newline. - */ - bool yyIsInteractive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - bool yyatbolFlag; - - int bs_yylineno; /**< The line count. */ - int bs_yycolumn; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - bool yyFillBuffer; - - int yyBufferStatus; -}; - - -m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc(size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return malloc(size); -} -]]) - -m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return realloc(ptr, size); -} -]]) - -m4_ifdef([[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree(void * ptr, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - free((char *) ptr); -} -]]) - -m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ -int yywrap(yyscan_t yyscanner) { - return /*CONSTCOND*/1; -} -]]) - const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); typedef uint8_t YY_CHAR; @@ -302,13 +199,6 @@ typedef const struct yy_trans_info *yyStateType; typedef int yyStateType; ]]) -/* Watch out: yytext_ptr is a variable when yytext is an array, - * but it's a macro when yytext is a pointer. - */ -m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -m4_define([[yytext_ptr]], [[yytext_r]]) -]]) - %% [1.0] DFA struct yyTransInfo { @@ -336,7 +226,7 @@ m4_ifdef([[M4_MODE_NO_REAL_FULLSPD]], [[ ]]) }; -%% [2.0] data tables for the DFA are inserted here +%% [2.0] payload macros for the for the DFA data tables are inserted here m4_ifdef([[M4_HOOK_NXT_ROWS]],[[m4_dnl static const M4_HOOK_NXT_TYPE yyNxt[][M4_HOOK_NXT_ROWS] = @@ -431,6 +321,78 @@ M4_HOOK_DEBUGTABLE_BODY[[]]m4_dnl M4_YY_SC_DEFS +typedef struct yy_buffer_state *yybuffer; + +%# These are not part of the exported interface and can safely be renamed +const int EOB_ACT_CONTINUE_SCAN = 0; +const int EOB_ACT_END_OF_FILE = 1; +const int EOB_ACT_LAST_MATCH = 2; +const int YY_BUFFER_NEW = 0; +const int YY_BUFFER_NORMAL = 1; + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +const int YY_BUFFER_EOF_PENDING = 2; + +struct yy_buffer_state { + FILE *yyInputFile; + char *yyChBuf; /* input buffer */ + char *yyBufPos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yyInputBufSize; + + /* Number of characters read into yyChBuf, not including EOB + * characters. + */ + int yyNChars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + bool yyIsOurBuffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use char-by-char + * rather than a buffered read, to make sure we stop fetching input after + * each newline. + */ + bool yyIsInteractive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + bool yyatbolFlag; + + int bs_yylineno; /**< The line count. */ + int bs_yycolumn; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + bool yyFillBuffer; + + int yyBufferStatus; +}; + +/* Watch out: yytext_ptr is a variable when yytext is an array, + * but it's a macro when yytext is a pointer. + */ +m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ +m4_define([[yytext_ptr]], [[yytext_r]]) +]]) + m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl %# These must match the values in the file flexdef.h %# of the flex source code, otherwise havoc will ensue. @@ -490,6 +452,43 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ ]]) } FlexLexer; /* end struct yyguts_t */ +m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc(size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return malloc(size); +} +]]) + +m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) + +m4_ifdef([[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + free((char *) ptr); +} +]]) + +m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ +int yywrap(yyscan_t yyscanner) { + return /*CONSTCOND*/1; +} +]]) + /* Helpers for special functions, also part of public API */ /* Returns the top of the stack, or NULL. */ diff --git a/tests/mem_c99.l b/tests/mem_c99.l index 1d206b5..d6ec025 100644 --- a/tests/mem_c99.l +++ b/tests/mem_c99.l @@ -37,8 +37,8 @@ #endif #define YY_BUF_SIZE 8 -void * yyalloc(yy_size_t, yyscan_t); -void *yyrealloc ( void *, yy_size_t, yyscan_t yyscanner ); +void * yyalloc(size_t, yyscan_t); +void *yyrealloc ( void *, size_t, yyscan_t yyscanner ); void yyfree ( void *, yyscan_t yyscanner ); %} @@ -89,7 +89,7 @@ static void dump_mem(FILE* fp){ fprintf(fp,"}\n"); } -void * yyalloc(yy_size_t n , yyscan_t yyscanner) +void * yyalloc(size_t n , yyscan_t yyscanner) { (void)yyscanner; @@ -120,7 +120,7 @@ void * yyalloc(yy_size_t n , yyscan_t yyscanner) return p; } -void * yyrealloc(void* p, yy_size_t n , yyscan_t yyscanner) +void * yyrealloc(void* p, size_t n , yyscan_t yyscanner) { (void)yyscanner; diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l index 911a105..aad599f 100644 --- a/tests/prefix_c99.l +++ b/tests/prefix_c99.l @@ -47,7 +47,7 @@ FOO_flush_buffer( (yybuffer)0, yyscanner); FOO_init_buffer( (yybuffer)0, (FILE*)0, yyscanner); FOO_load_buffer_state( yyscanner); - FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner); + FOO_scan_buffer( (char*)0, (size_t)0, yyscanner); FOO_scan_bytes( (const char*)0, 0, yyscanner); FOO_scan_string( (const char*)0, yyscanner); FOO_switch_to_buffer( (yybuffer)0, yyscanner); @@ -63,7 +63,7 @@ FOOget_out( (yyscan_t )0 ); FOOget_text( (yyscan_t )0 ); FOOlex( (yyscan_t )0 ); - FOOlex_destroy( (yyscan_t )0 ); + //FOOlex_destroy( (yyscan_t )0 ); FOOlex_init( (yyscan_t *)0 ); //FOOset_extra( (void *)0, (yyscan_t )0 ); FOOset_in( (FILE*)0, (yyscan_t )0 ); -- cgit v1.2.1 From dd0fb2920b15fc7a5432c49299d3aad044ef1608 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 20 Nov 2020 06:11:44 -0500 Subject: In the Go back end, more moves towards Go conventions. All documented in the go-flex.skl header comment. --- src/go-flex.skl | 176 +++++++++++++++++++++++++++-------------------------- tests/testmaker.m4 | 2 +- 2 files changed, 90 insertions(+), 88 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index c75cdb4..41b14d3 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -8,7 +8,15 @@ %# %# 1. The prefix property doesn't set a prefix for function and variable names. %# Instead it sets the Go package name. - +%# +%# 2. The (normally hidden) type of the yyguts_t structure becomes FlexLexer, +%# as in the pre-existing C++ support. The obfuscation of this type by +%# a void* i s removed. +%# +%# 3. Becauser of where expansion of magic names like yytext is done, the _r suffix +%# on some public member names is not required to keep them from being clobbered +%# and has been removed. + %# Macros for preproc stage. m4preproc_changecom @@ -23,7 +31,7 @@ m4_define([[M4_PROPERTY_SOURCE_SUFFIX]], [[go]]) m4_define([[M4_PROPERTY_TRACE_LINE_REGEXP]], [[^#line ([0-9]+) "(.*)"]]) m4_define([[M4_PROPERTY_TRACE_LINE_TEMPLATE]], [[#line %d "%s"]]) m4_define([[M4_PROPERTY_CONTEXT_ARG]], [[yyscanner]]) -m4_define([[M4_PROPERTY_CONTEXT_FORMAT]], [[yyscanner->%s_r]]) +m4_define([[M4_PROPERTY_CONTEXT_FORMAT]], [[yyscanner->%s]]) m4_define([[M4_PROPERTY_BUFFERSTACK_CONTEXT_FORMAT]], [[yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_%s]]) m4_define([[M4_PROPERTY_PREFIX]], [main]]) @@ -176,12 +184,6 @@ const int YY_NULL = 0; */ m4_define([[YY_SC_TO_UI]], [[((YY_CHAR)($1))]]) -/* In the ancestal C back end this was a void pointer, meant to be - * opaque pointer. That indirection has been removed here as it - * wouldn't easily port to other langages. - */ -typedef struct yyguts_t *yyscan_t; - /* Action number for EOF rule of a given start state. */ m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) @@ -390,7 +392,7 @@ struct yy_buffer_state { * but it's a macro when yytext is a pointer. */ m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[ -m4_define([[yytext_ptr]], [[yytext_r]]) +m4_define([[yytext_ptr]], [[yytext]]) ]]) m4_ifdef([[M4_MODE_VARIABLE_TRAILING_CONTEXT_RULES]], [[m4_dnl @@ -402,18 +404,18 @@ const int YY_TRAILING_HEAD_MASK = 0x4000; /* Holds the entire state of the reentrant scanner. */ typedef struct yyguts_t { /* Public interface */ - FILE *yyin_r, *yyout_r; - int yyleng_r; - int yylineno_r; - int yyflexdebug_r; + FILE *yyin, *yyout; + int yyleng; + int yylineno; + int yyflexdebug; m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ - char yytext_r[YYLMAX]; + char yytext[YYLMAX]; ]], [[ - char *yytext_r; + char *yytext; ]]) /* User-defined. Not touched by flex. */ - m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[M4_MODE_EXTRA_TYPE yyextra_r;]]) + m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[M4_MODE_EXTRA_TYPE yyextra;]]) size_t yyBufferStackTop; /**< index of top of stack. */ size_t yyBufferStackMax; /**< capacity of stack. */ @@ -454,7 +456,7 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, [[ -void *yyalloc(size_t size, yyscan_t yyscanner) { +void *yyalloc(size_t size, FlexLexer *yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ return malloc(size); } @@ -462,7 +464,7 @@ void *yyalloc(size_t size, yyscan_t yyscanner) { m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, [[ -void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { +void *yyrealloc(void *ptr, size_t size, FlexLexer *yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ return realloc(ptr, size); } @@ -470,7 +472,7 @@ void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { m4_ifdef([[M4_YY_NO_FLEX_FREE]],, [[ -void yyfree(void * ptr, yyscan_t yyscanner) { +void yyfree(void * ptr, FlexLexer *yyscanner) { (void)yyscanner; /* forestall unused-argument warning */ /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -484,7 +486,7 @@ void yyfree(void * ptr, yyscan_t yyscanner) { ]]) m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ -int yywrap(yyscan_t yyscanner) { +int yywrap(FlexLexer *yyscanner) { return /*CONSTCOND*/1; } ]]) @@ -502,7 +504,7 @@ static void yy_load_buffer_state (FlexLexer *yyscanner) { yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; yyscanner->yytext_ptr = yyscanner->yyCBufP = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufPos; - yyscanner->yyin_r = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile; + yyscanner->yyin = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile; yyscanner->yyHoldChar = *yyscanner->yyCBufP; } @@ -746,7 +748,7 @@ void yyrestart(FILE * input_file, FlexLexer *yyscanner) if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); } yy_init_buffer(yy_current_buffer(yyscanner), input_file, yyscanner); @@ -781,7 +783,7 @@ int yystart(FlexLexer *yyscanner) { * we now use fwrite(). */ void yyecho(FlexLexer *yyscanner) { - fwrite(yyscanner->yytext_r, (size_t) yyscanner->yyleng_r, 1, yyscanner->yyout_r); + fwrite(yyscanner->yytext, (size_t) yyscanner->yyleng, 1, yyscanner->yyout); } m4_ifdef([[M4_YY_NO_YYUNPUT]],, [[ @@ -837,13 +839,13 @@ static int yyread(char *buf, size_t maxSize, FlexLexer *yyscanner) { int result; m4_ifdef([[M4_MODE_CPP_USE_READ]], [[ errno=0; - while ((result = (int) read(fileno(yyscanner->yyin_r), buf, (size_t) maxSize)) < 0) { + while ((result = (int) read(fileno(yyscanner->yyin), buf, (size_t) maxSize)) < 0) { if(errno != EINTR) { yypanic("input in flex scanner failed", yyscanner); break; } errno=0; - clearerr(yyscanner->yyin_r); + clearerr(yyscanner->yyin); } ]]) m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ @@ -851,25 +853,25 @@ m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ int c = '*'; int n; for (n = 0; n < maxSize && - (c = getc(yyscanner->yyin_r)) != EOF && c != '\n'; ++n) { + (c = getc(yyscanner->yyin)) != EOF && c != '\n'; ++n) { buf[n] = (char) c; } if (c == '\n') { buf[n++] = (char) c; } - if (c == EOF && ferror(yyscanner->yyin_r)) { + if (c == EOF && ferror(yyscanner->yyin)) { yypanic("input in flex scanner failed", yyscanner); } result = n; } else { errno=0; - while ((result = (int) fread(buf, 1, (size_t) maxSize, yyscanner->yyin_r)) == 0 && ferror(yyscanner->yyin_r)) { + while ((result = (int) fread(buf, 1, (size_t) maxSize, yyscanner->yyin)) == 0 && ferror(yyscanner->yyin)) { if(errno != EINTR) { yypanic("input in flex scanner failed", yyscanner); break; } errno=0; - clearerr(yyscanner->yyin_r); + clearerr(yyscanner->yyin); } } ]]) @@ -881,11 +883,11 @@ m4_ifdef([[M4_MODE_NO_CPP_USE_READ]], [[ %# magic functions, so yy_get_next_buffer() won't need a forward declaration. m4_ifdef([[M4_MODE_YYMORE_USED]], [[ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ -void yymore(FlexLexer *yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext_r);} +void yymore(FlexLexer *yyscanner) {yyscanner->yyMoreOffset = strlen(yyscanner->yytext);} m4_define([[YY_MORE_ADJ]], [[0]]) m4_define([[YY_RESTORE_YY_MORE_OFFSET]], [[{ yyscanner->yyMoreOffset = yyscanner->yyPrevMoreOffset; -yyscanner->yyleng_r -= yyscanner->yyMoreOffset; +yyscanner->yyleng -= yyscanner->yyMoreOffset; } ]]) ]]) @@ -947,10 +949,10 @@ static int yy_get_next_buffer (FlexLexer *yyscanner) */ yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars = 0; } else { - int num_to_read = + int numToRead = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - numberToMove - 1; - while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */ + while (numToRead <= 0) { /* Not enough room in the buffer - grow it. */ m4_ifdef([[M4_MODE_USES_REJECT]], [[ yypanic( @@ -984,16 +986,16 @@ m4_ifdef([[M4_MODE_USES_REJECT]], } yyscanner->yyCBufP = &b->yyChBuf[yyCBufP_offset]; - num_to_read = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - + numToRead = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize - numberToMove - 1; ]]) } - if (num_to_read > YY_READ_BUF_SIZE) { - num_to_read = YY_READ_BUF_SIZE; + if (numToRead > YY_READ_BUF_SIZE) { + numToRead = YY_READ_BUF_SIZE; } /* Read in more data. */ - yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove], num_to_read, yyscanner); + yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove], numToRead, yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars = yyscanner->yyNChars; } @@ -1001,7 +1003,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], if (yyscanner->yyNChars == 0) { if (numberToMove == YY_MORE_ADJ) { retVal = EOB_ACT_END_OF_FILE; - yyrestart(yyscanner->yyin_r, yyscanner); + yyrestart(yyscanner->yyin, yyscanner); } else { retVal = EOB_ACT_LAST_MATCH; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = @@ -1063,7 +1065,7 @@ int yyinput(FlexLexer *yyscanner) */ /* Reset buffer status. */ - yyrestart(yyscanner->yyin_r, yyscanner); + yyrestart(yyscanner->yyin, yyscanner); /*FALLTHROUGH*/ @@ -1072,7 +1074,7 @@ int yyinput(FlexLexer *yyscanner) return 0; } if (! yyscanner->yyDidBufferSwitchOnEof) { - yyrestart(yyscanner->yyin_r, yyscanner); + yyrestart(yyscanner->yyin, yyscanner); } return yyinput(yyscanner); @@ -1146,7 +1148,7 @@ m4_ifdef([[M4_YY_NO_GET_EXTRA]],, [[m4_dnl * @param yyscanner The scanner object. */ M4_MODE_EXTRA_TYPE yyget_extra(FlexLexer *yyscanner) { - return yyscanner->yyextra_r; + return yyscanner->yyextra; } ]]) ]]) @@ -1187,7 +1189,7 @@ m4_ifdef([[M4_YY_NO_GET_IN]],, * @param yyscanner The scanner object. */ FILE *yyget_in (FlexLexer *yyscanner) { - return yyscanner->yyin_r; + return yyscanner->yyin; } ]]) @@ -1197,7 +1199,7 @@ m4_ifdef([[M4_YY_NO_GET_OUT]],, * @param yyscanner The scanner object. */ FILE *yyget_out (FlexLexer *yyscanner) { - return yyscanner->yyout_r; + return yyscanner->yyout; } ]]) @@ -1207,7 +1209,7 @@ m4_ifdef([[M4_YY_NO_GET_LENG]],, * @param yyscanner The scanner object. */ int yyget_leng (FlexLexer *yyscanner) { - return yyscanner->yyleng_r; + return yyscanner->yyleng; } ]]) @@ -1217,7 +1219,7 @@ int yyget_leng (FlexLexer *yyscanner) { m4_ifdef([[M4_YY_NO_GET_TEXT]],, [[ char *yyget_text (FlexLexer *yyscanner) { - return yyscanner->yytext_r; + return yyscanner->yytext; } ]]) @@ -1229,7 +1231,7 @@ m4_ifdef([[M4_YY_NO_SET_EXTRA]],, * @param yyscanner The scanner object. */ void yyset_extra(M4_MODE_EXTRA_TYPE userDefined, FlexLexer *yyscanner) { - yyscanner->yyextra_r = userDefined; + yyscanner->yyextra = userDefined; } ]]) ]]) @@ -1277,14 +1279,14 @@ m4_ifdef([[M4_YY_NO_SET_IN]],, * @see yy_switch_to_buffer */ void yyset_in(FILE *inStream, FlexLexer *yyscanner) { - yyscanner->yyin_r = inStream ; + yyscanner->yyin = inStream ; } ]]) m4_ifdef([[M4_YY_NO_SET_OUT]],, [[ void yyset_out(FILE *outStream, FlexLexer *yyscanner) { - yyscanner->yyout_r = outStream ; + yyscanner->yyout = outStream ; } ]]) @@ -1292,14 +1294,14 @@ void yyset_out(FILE *outStream, FlexLexer *yyscanner) { m4_ifdef([[M4_YY_NO_GET_DEBUG]],, [[ int yyget_debug(FlexLexer *yyscanner) { - return yyscanner->yyflexdebug_r; + return yyscanner->yyflexdebug; } ]]) m4_ifdef([[M4_YY_NO_SET_DEBUG]],, [[ void yyset_debug(int bdebug, FlexLexer *yyscanner) { - yyscanner->yyflexdebug_r = bdebug ; + yyscanner->yyflexdebug = bdebug ; } ]]) @@ -1319,8 +1321,8 @@ m4_define([[YY_DECL]], [[int yylex M4_YY_LEX_DECLARATION]]) m4_ifdef([[M4_MODE_BOL_NEEDED]], [[ static void rule_check_bol(FlexLexer *yyscanner) { - if (yyscanner->yyleng_r > 0) { \ - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = (yyscanner->yytext_r[yyscanner->yyleng_r - 1] == '\n'); + if (yyscanner->yyleng > 0) { \ + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = (yyscanner->yytext[yyscanner->yyleng - 1] == '\n'); } } ]]) @@ -1333,21 +1335,21 @@ static void rule_check_bol(FlexLexer *yyscanner) { void yyDoBeforeAction(FlexLexer *yyscanner, char *yyCp, char *yyBp) { yyscanner->yytext_ptr = yyBp; \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[m4_ifdef([[M4_MODE_NO_YYTEXT_IS_ARRAY]], [[yyscanner->yytext_ptr -= yyscanner->yyMoreLen; \ - yyscanner->yyleng_r = (int) (yyCp - yyscanner->yytext_ptr);]])]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng_r = (int) (yyCp - yyBp);]]) \ - m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng_r = (int) (yyCp - yyBp);]]) \ + yyscanner->yyleng = (int) (yyCp - yyscanner->yytext_ptr);]])]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[yyscanner->yyleng = (int) (yyCp - yyBp);]]) \ + m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[yyscanner->yyleng = (int) (yyCp - yyBp);]]) \ yyscanner->yyHoldChar = *yyCp; \ *yyCp = '\0'; \ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], [[ \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[if (yyscanner->yyleng_r + yyscanner->yyMoreOffset >= YYLMAX) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[if (yyscanner->yyleng + yyscanner->yyMoreOffset >= YYLMAX) \ yypanic("token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if (yyscanner->yyleng_r >= YYLMAX) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[if (yyscanner->yyleng >= YYLMAX) \ yypanic("token too large, exceeds YYLMAX", yyscanner);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy(&yyscanner->yytext_r[yyscanner->yyMoreOffset], yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ - m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng_r += yyscanner->yyMoreOffset;]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[strncpy(&yyscanner->yytext[yyscanner->yyMoreOffset], yyscanner->yytext_ptr, yyscanner->yyleng + 1);]]) \ + m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyleng += yyscanner->yyMoreOffset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyPrevMoreOffset = yyscanner->yyMoreOffset;]]) \ m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyMoreOffset = 0;]]) \ - m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy(yyscanner->yytext_r, yyscanner->yytext_ptr, yyscanner->yyleng_r + 1);]]) \ + m4_ifdef([[M4_MODE_NO_YYMORE_USED]], [[strncpy(yyscanner->yytext, yyscanner->yytext_ptr, yyscanner->yyleng + 1);]]) \ ]]) \ yyscanner->yyCBufP = yyCp; } @@ -1357,8 +1359,8 @@ m4_ifdef([[M4_MODE_YYLINENO]], [[ * and we can get at yyAct */ static void yyLessLineno(int n, FlexLexer *yyscanner) { int yyl; - for (yyl = n; yyl < yyscanner->yyleng_r; ++yyl) { - if (yyscanner->yytext_r[yyl] == '\n') { + for (yyl = n; yyl < yyscanner->yyleng; ++yyl) { + if (yyscanner->yytext[yyl] == '\n') { yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->bs_yylineno--; } } @@ -1378,7 +1380,7 @@ void yy_set_interactive(bool is_interactive, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyIsInteractive = is_interactive; } @@ -1388,7 +1390,7 @@ void yysetbol(bool atBOL, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = atBOL; } @@ -1822,16 +1824,16 @@ m4_ifdef([[M4_MODE_USES_REJECT]], if (yyscanner->yyStart == 0) { yyscanner->yyStart = 1; /* first start state */ } - if (yyscanner->yyin_r == NULL) { - yyscanner->yyin_r = stdin; + if (yyscanner->yyin == NULL) { + yyscanner->yyin = stdin; } - if (yyscanner->yyout_r == NULL) { - yyscanner->yyout_r = stdout; + if (yyscanner->yyout == NULL) { + yyscanner->yyout = stdout; } if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin_r, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); } yy_load_buffer_state(yyscanner); @@ -1975,8 +1977,8 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], [[yyscanner->yyPrevMoreOffset]], [[yyscanner->yyMoreLen]])]], [[0]])]]) if (yyAct != YY_END_OF_BUFFER && yyRuleCanMatchEOL[yyAct]) { int yyl; - for (yyl = M4_YYL_BASE; yyl < yyscanner->yyleng_r; ++yyl) { - if (yyscanner->yytext_r[yyl] == '\n') { + for (yyl = M4_YYL_BASE; yyl < yyscanner->yyleng; ++yyl) { + if (yyscanner->yytext[yyl] == '\n') { yybumpline(yyscanner); } @@ -1987,15 +1989,15 @@ m4_define([[M4_YYL_BASE]], [[m4_ifdef([[M4_MODE_YYMORE_USED]], doActionLabel: /* This label is used only to access EOF actions. */ m4_ifdef([[M4_MODE_DEBUG]], [[ - if (yyscanner->yyflexdebug_r) { + if (yyscanner->yyflexdebug) { if (yyAct == 0) { fprintf(stderr, "--scanner backing up\n"); } else if (yyAct < YY_NUM_RULES) { fprintf(stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yyAct], yyscanner->yytext_r); + (long)yy_rule_linenum[yyAct], yyscanner->yytext); } else if (yyAct == YY_NUM_RULES) { fprintf(stderr, "--accepting default rule (\"%s\")\n", - yyscanner->yytext_r); + yyscanner->yytext); } else if (yyAct == YY_NUM_RULES + 1) { fprintf(stderr, "--(end of buffer or a NUL)\n"); } else { @@ -2043,7 +2045,7 @@ m4_ifdef([[M4_MODE_HAS_BACKING_UP]], [[ * back-up) that will match for the new input source. */ yyscanner->yyNChars = yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyNChars; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile = yyscanner->yyin_r; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputFile = yyscanner->yyin; yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyBufferStatus = YY_BUFFER_NORMAL; } @@ -2125,7 +2127,7 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ goto doActionLabel; } else { if (! yyscanner->yyDidBufferSwitchOnEof) { - yyrestart(yyscanner->yyin_r, yyscanner); + yyrestart(yyscanner->yyin, yyscanner); } } break; @@ -2165,11 +2167,11 @@ m4_undefine([[yyless]]) void yyless(int n, FlexLexer *yyscanner) { /* Undo effects of setting up yytext. */ m4_ifdef([[M4_MODE_YYLINENO]], [[yyLessLineno(n, yyscanner);]]) - yyscanner->yytext_r[yyscanner->yyleng_r] = yyscanner->yyHoldChar; - yyscanner->yyCBufP = yyscanner->yytext_r + n; + yyscanner->yytext[yyscanner->yyleng] = yyscanner->yyHoldChar; + yyscanner->yyCBufP = yyscanner->yytext + n; yyscanner->yyHoldChar = *yyscanner->yyCBufP; *yyscanner->yyCBufP = '\0'; - yyscanner->yyleng_r = n; + yyscanner->yyleng = n; } static int yy_init_globals (FlexLexer *yyscanner) { @@ -2191,7 +2193,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], yyscanner->yyStateBuf = NULL; yyscanner->yyStatePtr = NULL; yyscanner->yyFullMatch = NULL; - yyscanner->yyLp = NULL; + yyscanner->yyLp = 0; ]]) m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], @@ -2201,8 +2203,8 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], yyscanner->yyPrevMoreOffset = 0; ]]) - yyscanner->yyin_r = NULL; - yyscanner->yyout_r = NULL; + yyscanner->yyin = NULL; + yyscanner->yyout = NULL; return 0; } @@ -2213,13 +2215,13 @@ m4_ifdef([[M4_MODE_YYTEXT_IS_ARRAY]], * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ -int yylex_init(yyscan_t *globalsPtr) { +int yylex_init(FlexLexer **globalsPtr) { if (globalsPtr == NULL) { errno = EINVAL; return 1; } - *globalsPtr = (yyscan_t) yyalloc (sizeof(FlexLexer), NULL); + *globalsPtr = (FlexLexer *) yyalloc (sizeof(FlexLexer), NULL); if (*globalsPtr == NULL) { errno = ENOMEM; @@ -2240,7 +2242,7 @@ m4_ifdef([[M4_MODE_EXTRA_TYPE]], [[m4_dnl * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ -int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { +int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, FlexLexer **globalsPtr) { FlexLexer dummyYyguts; yyset_extra(yyUserDefined, &dummy_yyguts); @@ -2250,7 +2252,7 @@ int yylex_init_extra(M4_MODE_EXTRA_TYPE yyUserDefined, yyscan_t *globalsPtr) { return 1; } - *globalsPtr = (yyscan_t) yyalloc(sizeof(FlexLexer), &dummyYyguts); + *globalsPtr = (FlexLexer *) yyalloc(sizeof(FlexLexer), &dummyYyguts); if (*globalsPtr == NULL) { errno = ENOMEM; @@ -2303,7 +2305,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], m4_ifdef([[M4_YY_MAIN]], [[ int main () { - yyscan_t lexer; + FlexLexer *lexer; yylex_init(&lexer); yylex(lexer); yylex_destroy(lexer); diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index c616cb7..8af0964 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -140,7 +140,7 @@ m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_ define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { - yyscan_t lexer; + FlexLexer *lexer; yylex_init( &lexer ); yyset_out ( stdout,lexer); yyset_in ( stdin, lexer); -- cgit v1.2.1 From 9f1c6960ceea2903153e2d5d7a41bfe9b6808072 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 20 Nov 2020 07:22:12 -0500 Subject: Deal with a GCC warning elicited by upgrade to GCC 10.2.0. --- src/parse.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parse.y b/src/parse.y index f6d11cc..3b8fb9c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1055,7 +1055,7 @@ void lwarn( const char *str ) void format_pinpoint_message( const char *msg, const char arg[] ) { - char errmsg[MAXLINE]; + char errmsg[MAXLINE*2]; snprintf( errmsg, sizeof(errmsg), msg, arg ); pinpoint_message( errmsg ); @@ -1074,7 +1074,7 @@ void pinpoint_message( const char *str ) void line_warning( const char *str, int line ) { - char warning[MAXLINE]; + char warning[MAXLINE*2]; if ( ! env.nowarn ) { -- cgit v1.2.1 From b528c7efdc06ec59ce354d9db63a475514884a10 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 26 Nov 2020 07:25:25 -0500 Subject: Improve standards conformance in C99 and Go skeletons. --- src/c99-flex.skl | 19 ++++++++++++------- src/go-flex.skl | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index ddf4185..cb7af3c 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -406,12 +406,17 @@ M4_YY_SC_DEFS typedef struct yy_buffer_state *yybuffer; -%# These are not part of the exported interface and can safewly be renamed -const int EOB_ACT_CONTINUE_SCAN = 0; -const int EOB_ACT_END_OF_FILE = 1; -const int EOB_ACT_LAST_MATCH = 2; -const int YY_BUFFER_NEW = 0; -const int YY_BUFFER_NORMAL = 1; +%# These are not part of the exported interface and can safely be renamed +/* These must be #defines, not const variables, because they're used as case + * arm values. GCC will allow case arm expressions to include references to + * const variables, but this is not standard-conformant and other compilers + * may not. + */ +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might @@ -422,7 +427,7 @@ const int YY_BUFFER_NORMAL = 1; * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ -const int YY_BUFFER_EOF_PENDING = 2; +#define YY_BUFFER_EOF_PENDING 2 struct yy_buffer_state { FILE *yy_input_file; diff --git a/src/go-flex.skl b/src/go-flex.skl index 41b14d3..50de080 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -325,12 +325,17 @@ M4_YY_SC_DEFS typedef struct yy_buffer_state *yybuffer; -%# These are not part of the exported interface and can safely be renamed -const int EOB_ACT_CONTINUE_SCAN = 0; -const int EOB_ACT_END_OF_FILE = 1; -const int EOB_ACT_LAST_MATCH = 2; -const int YY_BUFFER_NEW = 0; -const int YY_BUFFER_NORMAL = 1; +%# These are not part of the exported interface and can safely be renamed. +/* These must be #defines, not const variables, because they're used as case + * arm values. GCC will allow case arm expressions to include references to + * const variables, but this is not standard-conformant and other compilers + * may not. + */ +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might @@ -341,7 +346,7 @@ const int YY_BUFFER_NORMAL = 1; * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ -const int YY_BUFFER_EOF_PENDING = 2; +#define YY_BUFFER_EOF_PENDING 2 struct yy_buffer_state { FILE *yyInputFile; -- cgit v1.2.1 From d5c3fcfb3ebacd2f98d508bbc00965afa60f1203 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Thu, 26 Nov 2020 21:24:28 +0000 Subject: Mollify picky C compilers some more (#8) --- src/c99-flex.skl | 2 +- src/go-flex.skl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c99-flex.skl b/src/c99-flex.skl index cb7af3c..08b143a 100644 --- a/src/c99-flex.skl +++ b/src/c99-flex.skl @@ -63,7 +63,7 @@ m4_define([[M4_HOOK_CHAR_FORWARD]], [[yyscanner->yy_c_buf_p = yy_cp = yy_bp + $1 m4_define([[M4_HOOK_LINE_FORWARD]], [[yy_lineno_rewind_to(yy_cp, yy_bp + $1, yyscanner);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; ]]) -m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yy_state_type $1 = $2; +m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[#define $1 $2 ]]) m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; ]]) diff --git a/src/go-flex.skl b/src/go-flex.skl index 50de080..c38d6f8 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -62,7 +62,7 @@ m4_define([[M4_HOOK_CHAR_FORWARD]], [[yyscanner->yyCBufP = yyCp = yyBp + $1;]]) m4_define([[M4_HOOK_LINE_FORWARD]], [[yyLinenoRewindTo(yyCp, yyBp + $1, yyscanner);]]) m4_define([[M4_HOOK_CONST_DEFINE_BYTE]], [[const char $1 = $2; ]]) -m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[const yyStateType $1 = $2; +m4_define([[M4_HOOK_CONST_DEFINE_STATE]], [[#define $1 $2 ]]) m4_define([[M4_HOOK_CONST_DEFINE_UINT]], [[const uint $1 = $2; ]]) -- cgit v1.2.1 From 7b022d451d83a285b1bb41d5f41692ee2ef29b16 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Thu, 26 Nov 2020 21:47:37 +0000 Subject: check that each skeleton we build has the correct number of sections (#7) Probably we could turn the section markers into m4 macros, but until then this will prevent accidents. --- src/Makefile.am | 3 +++ src/chkskel.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/chkskel.sh diff --git a/src/Makefile.am b/src/Makefile.am index 029d06a..4a4fa15 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -99,14 +99,17 @@ clean-local: cpp-flex.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp + $(SHELL) $(srcdir)/chkskel.sh $@.tmp mv -f $@.tmp $@ c99-flex.h: c99-flex.skl mkskel.sh $(SHELL) $(srcdir)/mkskel.sh c99 $(srcdir) $(m4) $(VERSION) > $@.tmp + $(SHELL) $(srcdir)/chkskel.sh $@.tmp mv -f $@.tmp $@ go-flex.h: go-flex.skl mkskel.sh $(SHELL) $(srcdir)/mkskel.sh go $(srcdir) $(m4) $(VERSION) > $@.tmp + $(SHELL) $(srcdir)/chkskel.sh $@.tmp mv -f $@.tmp $@ if ENABLE_BOOTSTRAP diff --git a/src/chkskel.sh b/src/chkskel.sh new file mode 100644 index 0000000..9603ff8 --- /dev/null +++ b/src/chkskel.sh @@ -0,0 +1,33 @@ +#! /bin/sh + +# This file is part of flex. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE. + +if test ! $# = 1; then + echo 'Usage: chkskel.sh file' >&2 + exit 1 +fi +file=$1 +lines=$(grep -c '^ "%%' "${file}") +if [ ! "${lines}" -eq 6 ]; then + echo 'ERROR: skeleton does not have the right number of %% section lines' + exit 2 +fi -- cgit v1.2.1 From 33bd31b74b23f5ba01046b3a492adb29acf75fc2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 4 Dec 2020 06:49:26 -0500 Subject: Portability fix in tests - not all languages have ++ and --. --- tests/lineno.rules | 4 ++-- tests/testmaker.m4 | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/lineno.rules b/tests/lineno.rules index 7fc9c31..3cdfcaa 100644 --- a/tests/lineno.rules +++ b/tests/lineno.rules @@ -40,8 +40,8 @@ WORD [[:alpha:]]+ DIGIT [[:digit:]] %% -"yylineno++" ++yylineno; -"yylineno--" --yylineno; +"yylineno++" M4_TEST_INCREMENT(yylineno); +"yylineno--" M4_TEST_DECREMENT(yylineno); [[:blank:]]+ {WORD} {DIGIT}+(\n{DIGIT}+)* diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 8af0964..08817ad 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -51,6 +51,8 @@ define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') define(`M4_TEST_ASSERT', `if (!($1)) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `flex_debug = 1;')') +define(`M4_TEST_INCREMENT', `++$1') +define(`M4_TEST_DECREMENT', `--$1') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -91,6 +93,8 @@ define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_debug(lexer), lexer);')') +define(`M4_TEST_INCREMENT', `++$1') +define(`M4_TEST_DECREMENT', `--$1') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -137,6 +141,8 @@ define(`M4_TEST_DO', `$1;') define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);') define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}') m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_debug(lexer), lexer);')') +define(`M4_TEST_INCREMENT', `++$1') +define(`M4_TEST_DECREMENT', `--$1') define(`M4_TEST_POSTAMBLE', `dnl int main (int argc, char **argv) { @@ -173,6 +179,8 @@ define(`M4_TEST_DO', `$1') define(`M4_TEST_FAILMESSAGE', `fmt.Fprintf(os.Stderr, "TEST FAILMESSAGE: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);') define(`M4_TEST_ASSERT', `if !$1 {fmt.Fprintf(os.Stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);}') m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `lexer.yysetDebug(lexer.yygetDebug())')') +define(`M4_TEST_INCREMENT', `++$1') +define(`M4_TEST_DECREMENT', `--$1') define(`M4_TEST_POSTAMBLE', `dnl func main(void) { lexer := new(FlexLexer) -- cgit v1.2.1 From f5960fabbac43191b424c56a7cbb8befbff5dd42 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 4 Dec 2020 11:31:27 -0500 Subject: Go back end: More Goification of names. --- src/go-flex.skl | 59 ++++++++++++++++++++++++++++++------------------------ tests/testmaker.m4 | 8 ++++++-- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index c38d6f8..39b3cd1 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -13,10 +13,17 @@ %# as in the pre-existing C++ support. The obfuscation of this type by %# a void* i s removed. %# -%# 3. Becauser of where expansion of magic names like yytext is done, the _r suffix +%# 3. Because of where expansion of magic names like yytext is done, the _r suffix %# on some public member names is not required to keep them from being clobbered %# and has been removed. - +%# +%# 4. The following names change: +%# +%# YY_END_OF_BUFFER_CHAR -> flexBufferSentinel +%# YY_READ_BUF_SIZE -> flexReadBufferSize +%# YY_BUF_SIZE -> flexInputBufferSize +%# YY_NUL -> flexEOF + %# Macros for preproc stage. m4preproc_changecom @@ -82,7 +89,7 @@ m4_define([[M4_HOOK_SET_POSTACTION]], [[m4_define([[M4_HOOK_STATE_CASE_BREAK]], m4_define([[M4_HOOK_FATAL_ERROR]], [[yypanic($1, yyscanner);]]) m4_define([[M4_HOOK_ECHO]], [[yyecho(yyscanner);]]) -m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return YY_NULL /* $1 */]])) +m4_define([[yyterminate]], m4_ifdef([[M4_MODE_YYTERMINATE]], [[M4_MODE_YYTERMINATE /* $1 */]], [[return flexEOF /* $1 */]])) %# Return all but the first "n" matched characters back to the input stream. m4_define([[yyless]], [[ @@ -158,7 +165,7 @@ m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], , * Anywhere other than C this won't be a thing, * because strings will have an associated length field. */ -const int YY_END_OF_BUFFER_CHAR = 0; +const int flexBufferSentinel = 0; /* ENDS platform-specific and compiler-specific definitions. */ @@ -168,16 +175,16 @@ const int YY_END_OF_BUFFER_CHAR = 0; * chosen a fit size foe whatever platform * we're running on. */ -const int YY_READ_BUF_SIZE = BUFSIZ; +const int flexReadBufferSize = BUFSIZ; /* Size of default input buffer. We want to be able to fit two * OS-level reads, but efficiency gains as the buffer size * increases fall off after that */ -const int YY_BUF_SIZE = m4_ifdef([[M4_MODE_YY_BUFSIZE]], [[M4_MODE_YY_BUFSIZE]], [[2 * YY_READ_BUF_SIZE]]); +const int flexInputBufferSize = m4_ifdef([[M4_MODE_YY_BUFSIZE]], [[M4_MODE_YY_BUFSIZE]], [[2 * flexReadBufferSize]]); /* Returned upon end-of-file. */ -const int YY_NULL = 0; +const int flexEOF = 0; /* Promotes a possibly negative, possibly signed char to an * integer in range [0..255] for use as an array index. @@ -189,7 +196,7 @@ m4_define([[YY_STATE_EOF]], [[YY_END_OF_BUFFER + $1 + 1]]) /* The state buf must be large enough to hold one state per character in the main buffer. */ -m4_define([[YY_STATE_BUF_SIZE]], [[((YY_BUF_SIZE + 2) * sizeof(yyStateType))]]) +m4_define([[YY_STATE_BUF_SIZE]], [[((flexInputBufferSize + 2) * sizeof(yyStateType))]]) const bool FLEX_DEBUG = m4_ifdef([[M4_MODE_DEBUG]], [[true]], [[false]]); @@ -528,8 +535,8 @@ void yy_flush_buffer(yybuffer b, FlexLexer *yyscanner) * a transition to the end-of-buffer state. The second causes * a jam in that state. */ - b->yyChBuf[0] = YY_END_OF_BUFFER_CHAR; - b->yyChBuf[1] = YY_END_OF_BUFFER_CHAR; + b->yyChBuf[0] = flexBufferSentinel; + b->yyChBuf[1] = flexBufferSentinel; b->yyBufPos = &b->yyChBuf[0]; @@ -640,7 +647,7 @@ m4_ifdef([[M4_YY_ALWAYS_INTERACTIVE]], /** Allocate and initialize an input buffer state. * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param size The character buffer size in bytes. When in doubt, use @c flexInputBufferSize. * @param yyscanner The scanner object. * @return the allocated buffer state. */ @@ -753,7 +760,7 @@ void yyrestart(FILE * input_file, FlexLexer *yyscanner) if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, flexInputBufferSize, yyscanner); } yy_init_buffer(yy_current_buffer(yyscanner), input_file, yyscanner); @@ -837,7 +844,7 @@ m4_ifdef([[M4_MODE_YYLINENO]], ]]) m4_ifdef([[M4_MODE_USER_YYREAD]],, [[ -/* Gets input and stuffs it into "buf". Number of characters read, or YY_NULL, +/* Gets input and stuffs it into "buf". Number of characters read, or flexEOF, * is returned in "result". */ static int yyread(char *buf, size_t maxSize, FlexLexer *yyscanner) { @@ -996,8 +1003,8 @@ m4_ifdef([[M4_MODE_USES_REJECT]], ]]) } - if (numToRead > YY_READ_BUF_SIZE) { - numToRead = YY_READ_BUF_SIZE; + if (numToRead > flexReadBufferSize) { + numToRead = flexReadBufferSize; } /* Read in more data. */ yyscanner->yyNChars = yyread(&yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[numberToMove], numToRead, yyscanner); @@ -1030,8 +1037,8 @@ m4_ifdef([[M4_MODE_USES_REJECT]], } yyscanner->yyNChars += numberToMove; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars] = YY_END_OF_BUFFER_CHAR; - yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1] = YY_END_OF_BUFFER_CHAR; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars] = flexBufferSentinel; + yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[yyscanner->yyNChars + 1] = flexBufferSentinel; yyscanner->yytext_ptr = &yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf[0]; @@ -1044,7 +1051,7 @@ int yyinput(FlexLexer *yyscanner) *yyscanner->yyCBufP = yyscanner->yyHoldChar; - if (*yyscanner->yyCBufP == YY_END_OF_BUFFER_CHAR) { + if (*yyscanner->yyCBufP == flexBufferSentinel) { /* yyCBufP now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. @@ -1385,7 +1392,7 @@ void yy_set_interactive(bool is_interactive, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, flexInputBufferSize, yyscanner); } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyIsInteractive = is_interactive; } @@ -1395,7 +1402,7 @@ void yysetbol(bool atBOL, FlexLexer *yyscanner) { if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, flexInputBufferSize, yyscanner); } yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyatbolFlag = atBOL; } @@ -1452,8 +1459,8 @@ yybuffer yy_scan_buffer(char *base, size_t size, FlexLexer *yyscanner) yybuffer b; if (size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR) { + base[size-2] != flexBufferSentinel || + base[size-1] != flexBufferSentinel) { /* They forgot to leave room for the EOB's. */ return NULL; } @@ -1501,7 +1508,7 @@ yybuffer yy_scan_bytes(const char * yybytes, int _yybytes_len, FlexLexer *yysca for (i = 0; i < _yybytes_len; ++i) { buf[i] = yybytes[i]; } - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + buf[_yybytes_len] = buf[_yybytes_len+1] = flexBufferSentinel; b = yy_scan_buffer(buf, n, yyscanner); if (b == NULL) { @@ -1838,7 +1845,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]], if (yy_current_buffer(yyscanner) == NULL) { yyensure_buffer_stack (yyscanner); yyscanner->yyBufferStack[yyscanner->yyBufferStackTop] = - yy_create_buffer(yyscanner->yyin, YY_BUF_SIZE, yyscanner); + yy_create_buffer(yyscanner->yyin, flexInputBufferSize, yyscanner); } yy_load_buffer_state(yyscanner); @@ -2123,8 +2130,8 @@ m4_ifdef([[M4_MODE_FIND_ACTION_REJECT_OR_INTERACTIVE]], [[ * yyCBufP so that if some total * hoser (like flex itself) wants to * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. + * flexEOF, it'll still work - another + * flexEOF will get returned. */ yyscanner->yyCBufP = yyscanner->yytext_ptr + YY_MORE_ADJ; diff --git a/tests/testmaker.m4 b/tests/testmaker.m4 index 08817ad..bddbd44 100644 --- a/tests/testmaker.m4 +++ b/tests/testmaker.m4 @@ -22,6 +22,10 @@ dnl dnl M4_TEST_FAILMESSAGE = a line of code required to issue dnl a dnl failure notification to standard error and exit with a failure status. dnl +dnl M4_TEST_INCREMENT = increment the argument variable. +dnl +dnl M4_TEST_DECREMENT = decrement the argument variable. +dnl dnl M4_TEST_POSTAMBLE = the test main. dnl dnl M4_TEST_TABLE_SERIALIZATION = define this to exercise table @@ -151,7 +155,7 @@ int main (int argc, char **argv) yyset_out ( stdout,lexer); yyset_in ( stdin, lexer); M4_TEST_INITHOOK - while( yylex(lexer) != YY_NULL ) + while( yylex(lexer) != flexEOF ) { } yylex_destroy( lexer ); @@ -187,7 +191,7 @@ func main(void) { lexer.yysetOut(os.Stdout) lexer.yysetIn(os.Stdin) M4_TEST_INITHOOK - for lexer.yylex() != YY_NULL { + for lexer.yylex() != flexEOF { } fmt.Printf("TEST RETURNING OK.\n") os.Exit(0) -- cgit v1.2.1 From 5d93876e2249adec9e3a1e8f02e28bdf9a64e4c1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 5 Feb 2021 07:33:45 -0500 Subject: Remove prrequisite from .l.go suffix rule autogen gets indigestion iv you give a suffix rule a prerequisite, so don't do that. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index d20fad2..24ab7dd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -361,7 +361,7 @@ top.h: top.c # Build rules for non-C back ends -.l.go: $(FLEX) +.l.go: $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $< # This is a temporary fake rule for use while the Go back end still -- cgit v1.2.1