Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7ca9d9036 | |||
| e543baff47 | |||
| b636a25e94 | |||
| 07e05034fc |
@@ -1,4 +1,5 @@
|
|||||||
AM_YFLAGS = -d
|
AM_YFLAGS = -d
|
||||||
|
AM_LFLAGS = -P dp
|
||||||
BUILT_SOURCES = lib/dice_parse.h
|
BUILT_SOURCES = lib/dice_parse.h
|
||||||
|
|
||||||
lib_LTLIBRARIES = libdice.la
|
lib_LTLIBRARIES = libdice.la
|
||||||
@@ -12,7 +13,7 @@ include_HEADERS = lib/dice.h
|
|||||||
|
|
||||||
AM_CFLAGS = -Ilib
|
AM_CFLAGS = -Ilib
|
||||||
|
|
||||||
libdice_la_LIBADD = ${BSD_LIBS}
|
libdice_la_LIBADD = ${BSD_LIBS} -lm
|
||||||
|
|
||||||
pkgconfig_DATA = libdice.pc
|
pkgconfig_DATA = libdice.pc
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
if [ $(uname) = "OpenBSD" ]; then
|
||||||
|
export AUTOMAKE_VERSION=1.15
|
||||||
|
export AUTOCONF_VERSION=2.69
|
||||||
|
fi
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
PATH=$PATH:/usr/local/bin
|
PATH=$PATH:/usr/local/bin
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([libdice], [0.1], [florian@n0la.org])
|
AC_INIT([libdice], [0.2], [florian@n0la.org])
|
||||||
AM_INIT_AUTOMAKE([subdir-objects])
|
AM_INIT_AUTOMAKE([subdir-objects])
|
||||||
LT_INIT()
|
LT_INIT()
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
@@ -18,9 +18,8 @@ AC_CHECK_FUNCS([arc4random_uniform],,
|
|||||||
|
|
||||||
AC_CONFIG_FILES([Makefile tests/Makefile])
|
AC_CONFIG_FILES([Makefile tests/Makefile])
|
||||||
|
|
||||||
AC_SEARCH_LIBS([cos], [m], [], [
|
AC_SEARCH_LIBS([sqrt], [m])
|
||||||
AC_MSG_ERROR([unable to find the cos() function])
|
AC_SEARCH_LIBS([cos], [m])
|
||||||
])
|
|
||||||
|
|
||||||
PKG_INSTALLDIR
|
PKG_INSTALLDIR
|
||||||
AC_CONFIG_FILES([libdice.pc])
|
AC_CONFIG_FILES([libdice.pc])
|
||||||
|
|||||||
24
lib/dice.c
24
lib/dice.c
@@ -30,12 +30,12 @@
|
|||||||
#include <bsd/stdlib.h>
|
#include <bsd/stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int yylex_init_extra(void *extra, void **state);
|
extern int dplex_init_extra(void *extra, void **state);
|
||||||
extern int yylex_destroy(void *state);
|
extern int dplex_destroy(void *state);
|
||||||
extern void yylex(void *state);
|
extern void dplex(void *state);
|
||||||
extern void yy_switch_to_buffer(void *buffer, void *scanner);
|
extern void dp_switch_to_buffer(void *buffer, void *scanner);
|
||||||
extern void *yy_scan_string(char const *s, void *scanner);
|
extern void *dp_scan_string(char const *s, void *scanner);
|
||||||
extern void yy_delete_buffer(void *b, void *scanner);
|
extern void dp_delete_buffer(void *b, void *scanner);
|
||||||
|
|
||||||
struct dice_
|
struct dice_
|
||||||
{
|
{
|
||||||
@@ -115,14 +115,14 @@ bool dice_parse(dice_t d, char const *s)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
yylex_init_extra(d, &scanner);
|
dplex_init_extra(d, &scanner);
|
||||||
buffer = yy_scan_string(s, scanner);
|
buffer = dp_scan_string(s, scanner);
|
||||||
yy_switch_to_buffer(buffer, scanner);
|
dp_switch_to_buffer(buffer, scanner);
|
||||||
|
|
||||||
ret = yyparse(scanner, d);
|
ret = dpparse(scanner, d);
|
||||||
|
|
||||||
yy_delete_buffer(buffer, scanner);
|
dp_delete_buffer(buffer, scanner);
|
||||||
yylex_destroy(scanner);
|
dplex_destroy(scanner);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
%option bison-bridge
|
%option bison-bridge
|
||||||
%option reentrant
|
%option reentrant
|
||||||
|
%option outfile="../lib/dice_lexer.c"
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#define YYSTYPE DPSTYPE
|
||||||
#include "dice.h"
|
#include "dice.h"
|
||||||
#include "dice_parse.h"
|
#include "dice_parse.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
%define api.pure full
|
%define api.pure full
|
||||||
|
%define api.prefix {dp}
|
||||||
|
|
||||||
%parse-param {void *scanner} {dice_t dice}
|
%parse-param {void *scanner} {dice_t dice}
|
||||||
%lex-param {void *scanner}
|
%lex-param {void *scanner}
|
||||||
@@ -6,14 +7,14 @@
|
|||||||
%{
|
%{
|
||||||
#include "dice.h"
|
#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);
|
dice_set(dice, DICEOPTION_ERROR, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
int yywrap(void)
|
int dpwrap(void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ includedir=@includedir@
|
|||||||
|
|
||||||
Name: libdice
|
Name: libdice
|
||||||
Description: dice rolling and math expression library
|
Description: dice rolling and math expression library
|
||||||
Version: 0.1
|
Version: @VERSION@
|
||||||
Requires:
|
Requires:
|
||||||
Conflicts:
|
Conflicts:
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|||||||
Reference in New Issue
Block a user