From 68e4d78cf9f153871d9a3c07c8ce3e43eb517c3b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 14 Oct 2014 08:13:31 -0700 Subject: C++ upkeep. TXR's support for compiling as C++ pays off: C++ compiler finds serious bugs introduced in August 2 ("Big switch to reentrant lexing and parsing"). The yyerror function was being misused; some of the calls reversed the scanner and parser arguments. Since one of the two parameters is void *, this reversal wasn't caught. * parser.l (yyerror): Fix first two arguments being reversed. (num_esc): Change previously correct call to yyerror to follow reversed arguments, so that it stays correct. * parser.y (%parse-param): Change order of these directives so that the scnr parameter is before the parser parameter. This causes the yacc-generated calls to yyerror to have the arguments in the correct order. It also has the effect of changing the signature of yyparse, reversing its parameters. (parse): Update call to yyparse to new argument order. * parser.h (yyparse): Declaration removed. (yyerror): Declaration updated. * regex.c (regex_kind_t): New enum typedef. (struct regex): Use regex_kind_t rather than an enum inside the struct, which has different scoping rules under C++. * txr.c (get_self_path): Fix signed/unsigned warning. --- parser.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'parser.h') diff --git a/parser.h b/parser.h index 305b8d7b..bb85d01c 100644 --- a/parser.h +++ b/parser.h @@ -36,8 +36,7 @@ typedef struct { extern const wchar_t *spec_file; extern val form_to_ln_hash; -int yyparse(parser_t *, void *scanner); -void yyerror(parser_t *, void *scanner, const char *s); +void yyerror(void *scanner, parser_t *, const char *s); void yyerr(void *scanner, const char *s); void yyerrorf(void *scanner, val s, ...); void yybadtoken(parser_t *, int tok, val context); -- cgit v1.2.3