Index: lib/ibConfLex.l =================================================================== --- lib/ibConfLex.l (revision 1589) +++ lib/ibConfLex.l (working copy) @@ -7,8 +7,8 @@ %{ +#include "ib_internal.h" #include "ibConfYacc.h" -#include "ib_internal.h" #include %} Index: lib/ibConfYacc.y =================================================================== --- lib/ibConfYacc.y (revision 1589) +++ lib/ibConfYacc.y (working copy) @@ -1,3 +1,21 @@ +%locations +%parse-param { void* yyscanner } +%parse-param { gpib_yyparse_private_t* parse_arg } +%lex-param { void* yyscanner } +%error-verbose + +%code requires{ +typedef struct +{ + ibConf_t *configs; + unsigned int configs_length; + unsigned int config_index; + ibBoard_t *boards; + unsigned int boards_length; + int board_index; +}gpib_yyparse_private_t; +} + %{ #include #include "ib_internal.h" @@ -8,23 +26,12 @@ #include "ibConfYacc.h" #include "ibConfLex.h" -#define YYERROR_VERBOSE - YY_DECL; -#define YYPARSE_PARAM parse_arg -#define YYLEX_PARAM priv(YYPARSE_PARAM)->yyscanner - -typedef struct +void yyerror(YYLTYPE* yyloc, void* yyscanner, gpib_yyparse_private_t* parse_arg, const char *s) { - yyscan_t yyscanner; - ibConf_t *configs; - unsigned int configs_length; - unsigned int config_index; - ibBoard_t *boards; - unsigned int boards_length; - int board_index; -}gpib_yyparse_private_t; + fprintf(stderr, "%s\n", s); +} static inline gpib_yyparse_private_t* priv( gpib_yyparse_private_t *parse_arg ) { @@ -42,9 +49,9 @@ return &parse_arg->boards[ parse_arg->board_index ]; } -void init_gpib_yyparse_private( gpib_yyparse_private_t *priv ) +void init_gpib_yyparse_private( void** yyscanner, gpib_yyparse_private_t *priv ) { - priv->yyscanner = 0; + *yyscanner = 0; priv->configs = NULL; priv->configs_length = 0; priv->config_index = 0; @@ -59,6 +66,7 @@ FILE *infile; int retval = 0; int i; + void* yyscanner; gpib_yyparse_private_t priv; if( ( infile = fopen( filename, "r" ) ) == NULL ) @@ -69,7 +77,7 @@ return -1; } - init_gpib_yyparse_private( &priv ); + init_gpib_yyparse_private( &yyscanner, &priv ); priv.configs = configs; priv.configs_length = configs_length; priv.boards = boards; @@ -82,15 +90,15 @@ { init_ibboard( &priv.boards[ i ] ); } - gpib_yylex_init(&priv.yyscanner); - gpib_yyrestart(infile, priv.yyscanner); - if(gpib_yyparse(&priv)) + gpib_yylex_init(&yyscanner); + gpib_yyrestart(infile, yyscanner); + if(gpib_yyparse(yyscanner, &priv)) { fprintf(stderr, "libgpib: failed to parse configuration file\n"); //XXX setIberr() retval = -1 ; } - gpib_yylex_destroy(priv.yyscanner); + gpib_yylex_destroy(yyscanner); fclose(infile); if( retval == 0 ) @@ -139,7 +147,7 @@ | interface input | error { - fprintf(stderr, "input error on line %i of %s\n", gpib_yyget_lineno(priv(parse_arg)->yyscanner), DEFAULT_CONFIG_FILE); + fprintf(stderr, "input error on line %i of %s\n", gpib_yyget_lineno(yyscanner), DEFAULT_CONFIG_FILE); YYABORT; } ; @@ -257,10 +265,7 @@ -void yyerror(char *s) -{ - fprintf(stderr, "%s\n", s); -} + Index: lib/ib_internal.h =================================================================== --- lib/ib_internal.h (revision 1589) +++ lib/ib_internal.h (working copy) @@ -39,7 +39,6 @@ int ibBoardOpen( ibBoard_t *board ); int ibBoardClose( ibBoard_t *board ); int ibGetNrBoards(void); -void yyerror(char *s); int iblcleos( const ibConf_t *conf ); void ibPutMsg (char *format,...); void ibPutErrlog(int ud,char *routine); @@ -128,7 +127,6 @@ } #include -int gpib_yyparse(void *parse_arg); int parse_gpib_conf( const char *filename, ibConf_t *configs, unsigned int configs_length, ibBoard_t *boards, unsigned int boards_length ); #define YY_DECL int gpib_yylex(YYSTYPE *gpib_lvalp, YYLTYPE *gpib_llocp, yyscan_t yyscanner)