2003-12-04 18:20:51 -05:00
|
|
|
%{
|
|
|
|
|
|
|
|
/* $Id$
|
|
|
|
* Simple playlist lexer
|
2003-12-29 15:41:08 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Ron Pedde (ron@pedde.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2003-12-04 18:20:51 -05:00
|
|
|
*/
|
|
|
|
|
2003-12-05 00:58:29 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2003-12-04 18:20:51 -05:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-12-05 00:58:29 -05:00
|
|
|
#include "err.h"
|
2003-12-04 18:20:51 -05:00
|
|
|
#include "playlist.h"
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
extern int yydebug;
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%option yylineno
|
2003-12-05 00:58:29 -05:00
|
|
|
%option case-insensitive
|
|
|
|
|
|
|
|
qstring \"[^\"\n]*[\"\n]
|
2003-12-04 18:20:51 -05:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
[\n\t ]+
|
|
|
|
|
2003-12-05 00:58:29 -05:00
|
|
|
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
|
|
|
|
2003-12-07 01:36:06 -05:00
|
|
|
year { yylval.ival=YEAR; return(YEAR); }
|
2003-12-04 18:20:51 -05:00
|
|
|
|
2003-12-07 01:36:06 -05:00
|
|
|
is { yylval.ival=IS; return(IS); }
|
|
|
|
includes { yylval.ival=INCLUDES; return(INCLUDES); }
|
|
|
|
= { yylval.ival=EQUALS; return(EQUALS); }
|
2003-12-04 18:20:51 -05:00
|
|
|
|
|
|
|
or |
|
2003-12-05 00:58:29 -05:00
|
|
|
\|\| { yylval.ival=OR; return(OR); }
|
2003-12-04 18:20:51 -05:00
|
|
|
|
|
|
|
and |
|
2003-12-05 00:58:29 -05:00
|
|
|
&& { yylval.ival=AND; return(AND); }
|
2003-12-04 18:20:51 -05:00
|
|
|
|
|
|
|
not |
|
2003-12-05 00:58:29 -05:00
|
|
|
! { yylval.ival=1; return(NOT); }
|
2003-12-04 18:20:51 -05:00
|
|
|
|
2003-12-07 01:36:06 -05:00
|
|
|
\<= { yylval.ival=LESSEQUAL; return(LESSEQUAL); }
|
|
|
|
\< { yylval.ival=LESS; return(LESS); }
|
|
|
|
\>= { yylval.ival=GREATEREQUAL; return(GREATEREQUAL); }
|
|
|
|
\> { yylval.ival=GREATER; return(GREATER); }
|
2003-12-04 18:20:51 -05:00
|
|
|
|
2003-12-05 00:58:29 -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
|
|
|
|
2003-12-07 01:36:06 -05:00
|
|
|
[0-9]+ { yylval.ival=atoi(yytext); return(NUM); }
|
|
|
|
|
2003-12-04 18:20:51 -05:00
|
|
|
. { return yytext[0]; }
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
int yywrap(void) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void yyerror(char *msg) {
|
2003-12-05 00:58:29 -05:00
|
|
|
pl_error=1;
|
|
|
|
log_err(0,"Line %d: %s\n",yylineno, msg);
|
2003-12-04 18:20:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|