libdice/lib/dice_lexer.l
Florian Stinglmayr 92b909158c add tiny expression library and make it a dice expression parser
Use tiny expression library (from Github) and expand it to provide
dice expression parsing. This needs more testing obviously.
2018-02-17 10:52:46 +01:00

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;
}
%%