Skip to content

Commit

Permalink
Fix two tests to pass under bison 2.6
Browse files Browse the repository at this point in the history
Given that bison is moving forward with the %parse-param instead of
YYPARSE_PARAM syntax, it makes sense to switch over to using the new style
declaration. In particular, this means that flex scanners that use bison
features will now require bison 2.6 or higher.

Signed-off-by: Will Estes <[email protected]>
  • Loading branch information
Elias Pipping authored and westes committed Aug 6, 2012
1 parent cd4f7bf commit 095b0bf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 0 additions & 2 deletions tests/test-bison-yylloc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "parser.h"
#include "scanner.h"

extern int testparse(yyscan_t);

int main ( int argc, char** argv )
{
yyscan_t scanner;
Expand Down
6 changes: 3 additions & 3 deletions tests/test-bison-yylloc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* PURPOSE.
*/

%parse-param { void* scanner }

/*
How to compile:
bison --defines --output-file="parser.c" --name-prefix="test" parser.y
Expand All @@ -32,10 +34,8 @@
#include "config.h"

#define YYERROR_VERBOSE 1
#define YYPARSE_PARAM scanner
#define YYLEX_PARAM scanner

int yyerror(char* msg);
extern int testget_lineno(void*);


Expand Down Expand Up @@ -89,7 +89,7 @@ line:

%%

int yyerror(char* msg) {
int yyerror(void* scanner, char* msg) {
fprintf(stderr,"%s\n",msg);
return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/test-bison-yylval/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "parser.h"
#include "scanner.h"

extern int testparse(yyscan_t);

int main ( int argc, char** argv )
{
yyscan_t scanner;
Expand Down
6 changes: 2 additions & 4 deletions tests/test-bison-yylval/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@
How to compile:
bison --defines --output-file="parser.c" --name-prefix="test" parser.y
*/
%parse-param { void* scanner }
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"

#define YYERROR_VERBOSE 1
#define YYPARSE_PARAM scanner
#define YYLEX_PARAM scanner

int yyerror(char* msg);


/* A dummy function. A check against seg-faults in yylval->str. */
int process_text(char* s) {
Expand Down Expand Up @@ -76,7 +74,7 @@ starttag: LT TAGNAME GT { process_text($2); free($2);} ;
endtag: LTSLASH TAGNAME GT { process_text($2);free($2);} ;
%%

int yyerror(char* msg) {
int yyerror(void* scanner, char* msg) {
fprintf(stderr,"%s\n",msg);
return 0;
}

0 comments on commit 095b0bf

Please sign in to comment.