libdice/lib/dice_lexer.l

33 lines
515 B
Plaintext
Raw Normal View History

2018-02-14 19:31:52 +01:00
%option bison-bridge
%option reentrant
2018-02-13 20:27:38 +01:00
%{
#include "dice.h"
#include "dice_parse.h"
2018-02-14 19:31:52 +01:00
extern void dice_update_consumed(dice_t d, int off);
2018-02-13 20:27:38 +01:00
%}
%%
2018-02-14 19:31:52 +01:00
[0-9]+ {
dice_t d = yyget_extra(yyscanner);
dice_update_consumed(d, yyleng);
2018-02-14 19:31:52 +01:00
yylval->integer = atoi(yytext);
return TOK_INTEGER;
}
[d] {
dice_t d = yyget_extra(yyscanner);
dice_update_consumed(d, yyleng);
2018-02-14 19:31:52 +01:00
return TOK_DICESEP;
}
[fF] {
dice_t d = yyget_extra(yyscanner);
dice_update_consumed(d, yyleng);
return TOK_FUDGE;
}
2018-02-13 20:27:38 +01:00
%%