2018-02-14 19:31:52 +01:00
|
|
|
%define api.pure full
|
2018-05-11 16:57:55 +02:00
|
|
|
%define api.prefix {dp}
|
2018-02-14 19:31:52 +01:00
|
|
|
|
|
|
|
%parse-param {void *scanner} {dice_t dice}
|
|
|
|
%lex-param {void *scanner}
|
2018-02-13 20:27:38 +01:00
|
|
|
|
|
|
|
%{
|
|
|
|
#include "dice.h"
|
|
|
|
|
2018-05-11 16:57:55 +02:00
|
|
|
extern int dplex(void *lval, void *scanner);
|
2018-02-13 20:27:38 +01:00
|
|
|
|
2018-05-11 16:57:55 +02:00
|
|
|
void dperror(void *scanner, dice_t dice, char const *err)
|
2018-02-13 20:27:38 +01:00
|
|
|
{
|
2018-02-17 10:52:46 +01:00
|
|
|
dice_set(dice, DICEOPTION_ERROR, err);
|
2018-02-13 20:27:38 +01:00
|
|
|
}
|
|
|
|
|
2018-05-11 16:57:55 +02:00
|
|
|
int dpwrap(void)
|
2018-02-13 20:27:38 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
char *str;
|
|
|
|
int integer;
|
|
|
|
double number;
|
|
|
|
}
|
|
|
|
|
2018-03-23 17:44:52 +01:00
|
|
|
%token TOK_DICESEP TOK_FUDGE
|
2018-02-13 20:27:38 +01:00
|
|
|
%token <integer> TOK_INTEGER
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
dice: TOK_INTEGER TOK_DICESEP TOK_INTEGER
|
|
|
|
{
|
|
|
|
dice_set(dice, DICEOPTION_AMOUNT, $1);
|
|
|
|
dice_set(dice, DICEOPTION_SIDES, $3);
|
2018-02-17 10:52:46 +01:00
|
|
|
|
|
|
|
YYACCEPT;
|
2018-02-13 20:27:38 +01:00
|
|
|
}
|
|
|
|
| TOK_DICESEP TOK_INTEGER
|
|
|
|
{
|
|
|
|
dice_set(dice, DICEOPTION_AMOUNT, 1);
|
|
|
|
dice_set(dice, DICEOPTION_SIDES, $2);
|
2018-02-17 10:52:46 +01:00
|
|
|
|
2018-03-23 17:44:52 +01:00
|
|
|
YYACCEPT;
|
|
|
|
}
|
|
|
|
| TOK_DICESEP TOK_FUDGE
|
|
|
|
{
|
|
|
|
dice_set(dice, DICEOPTION_AMOUNT, 1L);
|
|
|
|
dice_set(dice, DICEOPTION_FUDGE, 1L);
|
|
|
|
|
|
|
|
YYACCEPT;
|
|
|
|
}
|
|
|
|
| TOK_INTEGER TOK_DICESEP TOK_FUDGE
|
|
|
|
{
|
|
|
|
dice_set(dice, DICEOPTION_AMOUNT, $1);
|
|
|
|
dice_set(dice, DICEOPTION_FUDGE, 1L);
|
|
|
|
|
2018-02-17 10:52:46 +01:00
|
|
|
YYACCEPT;
|
2018-02-13 20:27:38 +01:00
|
|
|
}
|
|
|
|
;
|