Newer
Older
xmpp-bot / src / grammar / expenses.l
/* expenses.l: Expenses lexical analysis file
 * TODO free memory allocated with g_string_new AFTER the parser is done (see grammar.y)
*/

%{
#include <stdio.h>
#include <glib.h>
#include "expenses.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;
report                  yylval.cmd=BOT_CMD_REPORT; return TOK_CMD_REPORT;
daily                   yylval.tsp=BOT_TS_DAILY; return TOK_TS_DAILY;
weekly                  yylval.tsp=BOT_TS_WEEKLY; return TOK_TS_WEEKLY;
monthly                 yylval.tsp=BOT_TS_MONTHLY; return TOK_TS_MONTHLY;
yearly                  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 */;

%%