/* expenses.l: Expenses lexical analysis file
 * TODO free memory allocated with g_string_new AFTER the parser is done (see grammar.y)
 * TODO support italian-style floating point numbers e.g. 12,34
*/

%{
#include <stdio.h>
#include <glib.h>
#include "grammar.tab.h"
%}
                        
DIGIT    [0-9]

%%

{DIGIT}+                yylval.res=atoi(yytext); return TOK_INT;
{DIGIT}+"."{DIGIT}*     yylval.val=atof(yytext); return TOK_DOUBLE;
"-"|out|spesa           yylval.cmd=BOT_CMD_OUT; return TOK_CMD_OUT;
"+"|in|ricavo           yylval.cmd=BOT_CMD_IN; return TOK_CMD_IN;
del|storno              yylval.cmd=BOT_CMD_DELETE; return TOK_CMD_DEL;
reminder|ricordami      yylval.cmd=BOT_CMD_REMINDER; return TOK_CMD_REMINDER;
report                  yylval.cmd=BOT_CMD_REPORT; return TOK_CMD_REPORT;
daily|giorno            yylval.tsp=BOT_TS_DAILY; return TOK_TS_DAILY;
weekly|sett|settimana   yylval.tsp=BOT_TS_WEEKLY; return TOK_TS_WEEKLY;
monthly|mese            yylval.tsp=BOT_TS_MONTHLY; return TOK_TS_MONTHLY;
yearly|anno             yylval.tsp=BOT_TS_YEARLY; return TOK_TS_YEARLY;
[a-zA-Z0-9_]+           yylval.str=g_string_new(yytext); return TOK_USER; /* user can't have special characters */
\"[^\n]+\"              yylval.str=g_string_new(yytext); return TOK_STR;  /* anything excepts '\n'; needs to be at the bottom of flex rules here */
[ \t]+                  /* ignore whitespace */;
\n                      /* ignore end of line */;

%%
