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.
This commit is contained in:
Cary R 2013-07-11 19:14:15 -07:00
parent 21b24c7725
commit 9d1084d3c0
3 changed files with 20 additions and 22 deletions

View File

@ -3,11 +3,10 @@
%option noinput %option noinput
%option nounput %option nounput
%option noyywrap %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 * 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 * it under the terms of the GNU General Public License as published by
@ -27,7 +26,7 @@
# include "fp_api.h" # include "fp_api.h"
# include "fp.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; yyrestart(fd);
yylex_init(&scanner);
yyrestart(fd, scanner);
return scanner;
} }
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
} }

View File

@ -1,8 +1,6 @@
%name-prefix="fp" %name-prefix="fp"
%pure-parser %pure-parser
%lex-param {yyscan_t yyscanner}
%parse-param {yyscan_t yyscanner}
%parse-param {const char*file_path} %parse-param {const char*file_path}
%{ %{
@ -41,14 +39,14 @@ using namespace std;
(Current).first_line = (Rhs)[1].first_line; \ (Current).first_line = (Rhs)[1].first_line; \
} while (0) } 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); fprintf(stderr, "%s\n", msg);
} }
extern yyscan_t prepare_fp_lexor(FILE*fd); extern void init_fp_lexor(FILE*fd);
extern void destroy_fp_lexor(yyscan_t scanner); extern void destroy_fp_lexor();
extern int fplex(union YYSTYPE*yylvalp, YYLTYPE*yylloc, yyscan_t scanner); extern int fplex(union YYSTYPE*yylvalp, YYLTYPE*yylloc);
static fp_pad_t cur_pad; static fp_pad_t cur_pad;
static fp_element_t cur_element; static fp_element_t cur_element;
@ -194,10 +192,10 @@ int parse_fp_file(const string&file_path)
parse_file_path = file_path; parse_file_path = file_path;
parse_fp_errors = 0; parse_fp_errors = 0;
parse_fp_sorrys = 0; parse_fp_sorrys = 0;
yyscan_t scanner = prepare_fp_lexor(fd); init_fp_lexor(fd);
int rc = yyparse(scanner, file_path.c_str()); int rc = yyparse(file_path.c_str());
fclose(fd); fclose(fd);
destroy_fp_lexor(scanner); destroy_fp_lexor();
return rc; return rc;
} }

View File

@ -1,7 +1,7 @@
#ifndef __fp_api_H #ifndef __fp_api_H
#define __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 * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * 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); extern int parse_fp_file(const std::string&file_path);
typedef void*yyscan_t;
/* /*
* The yyltype supports the passing of detailed source file location * The yyltype supports the passing of detailed source file location
* information between the lexical analyzer and the parser. Defining * information between the lexical analyzer and the parser. Defining