owntone-server/src/lexer.l

69 lines
1.2 KiB
Plaintext
Raw Normal View History

2003-12-04 18:20:51 -05:00
%{
/* $Id$
*
* Simple playlist lexer
*/
#include <stdio.h>
#include <stdlib.h>
2003-12-04 18:20:51 -05:00
#include <string.h>
#include "err.h"
2003-12-04 18:20:51 -05:00
#include "playlist.h"
#include "parser.h"
extern int yydebug;
%}
%option yylineno
%option case-insensitive
qstring \"[^\"\n]*[\"\n]
2003-12-04 18:20:51 -05:00
%%
[\n\t ]+
artist { yylval.ival=ARTIST; return(ARTIST); }
album { yylval.ival=ALBUM; return(ALBUM); }
genre { yylval.ival=GENRE; return(GENRE); }
2003-12-04 18:20:51 -05:00
is |
= { yylval.ival=IS; return(IS); }
2003-12-04 18:20:51 -05:00
includes |
=~ |
~= { yylval.ival=INCLUDES; return(INCLUDES); }
2003-12-04 18:20:51 -05:00
or |
\|\| { yylval.ival=OR; return(OR); }
2003-12-04 18:20:51 -05:00
and |
&& { yylval.ival=AND; return(AND); }
2003-12-04 18:20:51 -05:00
not |
! { yylval.ival=1; return(NOT); }
2003-12-04 18:20:51 -05:00
{qstring} { yylval.cval=strdup(yytext+1);
if(yylval.cval[strlen(yylval.cval)-1] == '"');
yylval.cval[strlen(yylval.cval)-1] = '\0';
return(ID); }
2003-12-04 18:20:51 -05:00
. { return yytext[0]; }
%%
int yywrap(void) {
return 1;
}
void yyerror(char *msg) {
pl_error=1;
log_err(0,"Line %d: %s\n",yylineno, msg);
2003-12-04 18:20:51 -05:00
}