You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

44 lines
903 B

%{
#include <stdio.h>
#include "expression.h"
#include "parser.tab.h"
%}
%option reentrant
%option bison-bridge
%option nounput
%option noinput
%option noyywrap
%%
"\n" { return WEBDICE_TOKEN_EOL; }
-?[0-9]+ {
int64_t aux;
sscanf(yytext,"%lld",&aux);
(*(*yylval).exp).constant.id = WEBDICE_CONST;
(*(*yylval).exp).constant.value = aux;
return WEBDICE_TOKEN_CONST;
}
-?[0-9]+d[0-9]+ {
int64_t count,type;
sscanf(yytext,"%lldd%lld",&count,&type);
(*(*yylval).exp).roll.id = WEBDICE_ROLL;
(*(*yylval).exp).roll.count = count;
(*(*yylval).exp).roll.type = type;
return WEBDICE_TOKEN_ROLL;
}
"(" { return WEBDICE_TOKEN_LPAREN; }
")" { return WEBDICE_TOKEN_RPAREN; }
"*" { return WEBDICE_TOKEN_MUL; }
"/" { return WEBDICE_TOKEN_DIV; }
"+" { return WEBDICE_TOKEN_ADD; }
"-" { return WEBDICE_TOKEN_SUB; }
[ \t]+ {}
. { fprintf(stderr,"%s",yytext); return WEBDICE_TOKEN_EOL; }
%%