Florian Stinglmayr
92b909158c
Use tiny expression library (from Github) and expand it to provide dice expression parsing. This needs more testing obviously.
26 lines
406 B
Plaintext
26 lines
406 B
Plaintext
%option bison-bridge
|
|
%option reentrant
|
|
|
|
%{
|
|
#include "dice.h"
|
|
#include "dice_parse.h"
|
|
|
|
extern void dice_update_consumed(dice_t d, int off);
|
|
|
|
%}
|
|
|
|
%%
|
|
[0-9]+ {
|
|
dice_t d = yyget_extra(yyscanner);
|
|
dice_update_consumed(d, yyleng);
|
|
yylval->integer = atoi(yytext);
|
|
return TOK_INTEGER;
|
|
}
|
|
|
|
[d] {
|
|
dice_t d = yyget_extra(yyscanner);
|
|
dice_update_consumed(d, yyleng);
|
|
return TOK_DICESEP;
|
|
}
|
|
%%
|