differentiate libdice flex/bison with prefix "dp"
This allows the library to be linked with other libraries that also use flex and bison.
This commit is contained in:
24
lib/dice.c
24
lib/dice.c
@@ -30,12 +30,12 @@
|
||||
#include <bsd/stdlib.h>
|
||||
#endif
|
||||
|
||||
extern int yylex_init_extra(void *extra, void **state);
|
||||
extern int yylex_destroy(void *state);
|
||||
extern void yylex(void *state);
|
||||
extern void yy_switch_to_buffer(void *buffer, void *scanner);
|
||||
extern void *yy_scan_string(char const *s, void *scanner);
|
||||
extern void yy_delete_buffer(void *b, void *scanner);
|
||||
extern int dplex_init_extra(void *extra, void **state);
|
||||
extern int dplex_destroy(void *state);
|
||||
extern void dplex(void *state);
|
||||
extern void dp_switch_to_buffer(void *buffer, void *scanner);
|
||||
extern void *dp_scan_string(char const *s, void *scanner);
|
||||
extern void dp_delete_buffer(void *b, void *scanner);
|
||||
|
||||
struct dice_
|
||||
{
|
||||
@@ -115,14 +115,14 @@ bool dice_parse(dice_t d, char const *s)
|
||||
return false;
|
||||
}
|
||||
|
||||
yylex_init_extra(d, &scanner);
|
||||
buffer = yy_scan_string(s, scanner);
|
||||
yy_switch_to_buffer(buffer, scanner);
|
||||
dplex_init_extra(d, &scanner);
|
||||
buffer = dp_scan_string(s, scanner);
|
||||
dp_switch_to_buffer(buffer, scanner);
|
||||
|
||||
ret = yyparse(scanner, d);
|
||||
ret = dpparse(scanner, d);
|
||||
|
||||
yy_delete_buffer(buffer, scanner);
|
||||
yylex_destroy(scanner);
|
||||
dp_delete_buffer(buffer, scanner);
|
||||
dplex_destroy(scanner);
|
||||
|
||||
if (ret) {
|
||||
return false;
|
||||
|
||||
2
lib/dice_lexer.c
Normal file
2
lib/dice_lexer.c
Normal file
@@ -0,0 +1,2 @@
|
||||
/* empty file, so that autotools has something to compile
|
||||
*/
|
||||
@@ -1,7 +1,9 @@
|
||||
%option prefix="dp"
|
||||
%option bison-bridge
|
||||
%option reentrant
|
||||
|
||||
%{
|
||||
#define YYSTYPE DPSTYPE
|
||||
#include "dice.h"
|
||||
#include "dice_parse.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
%define api.pure full
|
||||
%define api.prefix {dp}
|
||||
|
||||
%parse-param {void *scanner} {dice_t dice}
|
||||
%lex-param {void *scanner}
|
||||
@@ -6,14 +7,14 @@
|
||||
%{
|
||||
#include "dice.h"
|
||||
|
||||
extern int yylex(void *lval, void *scanner);
|
||||
extern int dplex(void *lval, void *scanner);
|
||||
|
||||
void yyerror(void *scanner, dice_t dice, char const *err)
|
||||
void dperror(void *scanner, dice_t dice, char const *err)
|
||||
{
|
||||
dice_set(dice, DICEOPTION_ERROR, err);
|
||||
}
|
||||
|
||||
int yywrap(void)
|
||||
int dpwrap(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user