From 9d1084d3c0618d98cdebca6a8f7969f05535dd12 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 11 Jul 2013 19:14:15 -0700 Subject: [PATCH] Remove reentrant support from tgt-pcb parsing This is just extra overhead since the pcb target does not call the scanner recursively. This also removes some compile warnings. --- tgt-pcb/fp.lex | 22 ++++++++++++---------- tgt-pcb/fp.y | 16 +++++++--------- tgt-pcb/fp_api.h | 4 +--- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/tgt-pcb/fp.lex b/tgt-pcb/fp.lex index caba03a3e..af3292252 100644 --- a/tgt-pcb/fp.lex +++ b/tgt-pcb/fp.lex @@ -3,11 +3,10 @@ %option noinput %option nounput %option noyywrap -%option reentrant %{ /* - * Copyright (C) 2011 Stephen Williams (steve@icarus.com) + * Copyright (C) 2011-2013 Stephen Williams (steve@icarus.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +26,7 @@ # include "fp_api.h" # include "fp.h" -# define YY_DECL int yylex(YYSTYPE*yylvalp, YYLTYPE*yyllocp, yyscan_t yyscanner) +# define YY_DECL int yylex(YYSTYPE*yylvalp, YYLTYPE*yyllocp) %} @@ -75,15 +74,18 @@ SPACE [ \t\f\r] %% -yyscan_t prepare_fp_lexor(FILE*fd) +void init_fp_lexor(FILE*fd) { - yyscan_t scanner; - yylex_init(&scanner); - yyrestart(fd, scanner); - return scanner; + yyrestart(fd); } -void destroy_fp_lexor(yyscan_t scanner) +void destroy_fp_lexor() { - yylex_destroy(scanner); +# ifdef FLEX_SCANNER +# if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5 +# if defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION >= 9 + yylex_destroy(); +# endif +# endif +# endif } diff --git a/tgt-pcb/fp.y b/tgt-pcb/fp.y index 41d803431..d0c3257a1 100644 --- a/tgt-pcb/fp.y +++ b/tgt-pcb/fp.y @@ -1,8 +1,6 @@ %name-prefix="fp" %pure-parser -%lex-param {yyscan_t yyscanner} -%parse-param {yyscan_t yyscanner} %parse-param {const char*file_path} %{ @@ -41,14 +39,14 @@ using namespace std; (Current).first_line = (Rhs)[1].first_line; \ } while (0) -static void yyerror(YYLTYPE*, yyscan_t , const char*, const char*msg) +static void yyerror(YYLTYPE*, const char*, const char*msg) { fprintf(stderr, "%s\n", msg); } -extern yyscan_t prepare_fp_lexor(FILE*fd); -extern void destroy_fp_lexor(yyscan_t scanner); -extern int fplex(union YYSTYPE*yylvalp, YYLTYPE*yylloc, yyscan_t scanner); +extern void init_fp_lexor(FILE*fd); +extern void destroy_fp_lexor(); +extern int fplex(union YYSTYPE*yylvalp, YYLTYPE*yylloc); static fp_pad_t cur_pad; static fp_element_t cur_element; @@ -194,10 +192,10 @@ int parse_fp_file(const string&file_path) parse_file_path = file_path; parse_fp_errors = 0; parse_fp_sorrys = 0; - yyscan_t scanner = prepare_fp_lexor(fd); - int rc = yyparse(scanner, file_path.c_str()); + init_fp_lexor(fd); + int rc = yyparse(file_path.c_str()); fclose(fd); - destroy_fp_lexor(scanner); + destroy_fp_lexor(); return rc; } diff --git a/tgt-pcb/fp_api.h b/tgt-pcb/fp_api.h index b15253d29..eadbf46d4 100644 --- a/tgt-pcb/fp_api.h +++ b/tgt-pcb/fp_api.h @@ -1,7 +1,7 @@ #ifndef __fp_api_H #define __fp_api_H /* - * Copyright (c) 2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -27,8 +27,6 @@ */ extern int parse_fp_file(const std::string&file_path); -typedef void*yyscan_t; - /* * The yyltype supports the passing of detailed source file location * information between the lexical analyzer and the parser. Defining