diff options
-rw-r--r-- | parser.h | 2 | ||||
-rw-r--r-- | parser.y | 9 | ||||
-rw-r--r-- | txr.c | 14 |
3 files changed, 25 insertions, 0 deletions
@@ -57,10 +57,12 @@ struct parser { enum prime_parser { prime_lisp, prime_regex }; +extern const int have_yydebug; extern const wchar_t *spec_file; extern val form_to_ln_hash; extern val parser_s; extern val unique_s; +void yydebug_onoff(int); void yyerror(scanner_t *scanner, parser_t *, const char *s); void yyerr(scanner_t *scanner, const char *s); void yyerrorf(scanner_t *scanner, val s, ...); @@ -1039,6 +1039,8 @@ not_a_clause : ALL { $$ = mkexp(all_s, nil, num(parser->lineno)); } %% +const int have_yydebug = YYDEBUG; + int yylex(YYSTYPE *, yyscan_t scanner); /* C99 inline instantiations. */ @@ -1046,6 +1048,13 @@ int yylex(YYSTYPE *, yyscan_t scanner); val rlcp(val to, val from); #endif +void yydebug_onoff(int val) +{ +#if YYDEBUG + yydebug = val; +#endif +} + static val sym_helper(parser_t *parser, wchar_t *lexeme, val meta_allowed) { scanner_t *scnr = parser->scanner; @@ -148,6 +148,7 @@ static void help(void) "--gc-delta=N Invoke garbage collection when malloc activity\n" " increments by N megabytes since last collection.\n" "--debug-autoload Allow debugger to step through library auto-loading.\n" +"--yydebug Debug Yacc parser, if compiled with YYDEBUG support.\n" "\n" "Options that take no argument can be combined. The -q and -v options\n" "are mutually exclusive; the right-most one dominates.\n" @@ -525,6 +526,19 @@ int txr_main(int argc, char **argv) no_dbg_support(opt); return EXIT_FAILURE; #endif + } else if (equal(opt, lit("yydebug"))) { + if (have_yydebug) { + yydebug_onoff(1); + format(std_error, + lit("~a: option --~a takes no argument, ~a given\n"), + prog_string, opt, org, nao); + continue; + } else { + format(std_error, + lit("~a: option ~a requires YYDEBUG support compiled in\n"), + prog_string, arg, nao); + return EXIT_FAILURE; + } } else if (equal(opt, lit("noninteractive"))) { opt_noninteractive = 1; stream_set_prop(std_input, real_time_k, nil); |