alsa-utils/alsactl/alsactl_lexer.l

114 lines
2.8 KiB
Text

/*
* Advanced Linux Sound Architecture Control Program
* Copyright (c) 1998 by Perex, APS, University of South Bohemia
*
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
%{
#include "alsactl.h"
struct bytearray {
unsigned char *data;
size_t datalen;
};
#include "alsactl_parser.h"
#define YY_NO_UNPUT
#undef YY_CDECL
#define YY_CDECL int YY_PROTO(yylex( void ));
int linecount;
%}
%%
/* special characters */
"{"|"}" return yytext[0];
"("|")" return yytext[0];
"["|"]" return yytext[0];
")"[ \t]*"{" return L_DOUBLE1;
"," return yytext[0];
"=" return yytext[0];
/* tokens */
soundcard return L_SOUNDCARD;
control return L_CONTROL;
global return L_GLOBAL;
hwdep return L_HWDEP;
mixer return L_MIXER;
pcm return L_PCM;
rawmidi return L_RAWMIDI;
timer return L_TIMER;
sequencer return L_SEQUENCER;
ident return L_IDENT;
iface return L_IFACE;
name return L_NAME;
device return L_DEVICE;
subdevice return L_SUBDEVICE;
index return L_INDEX;
bool return L_BOOL;
int return L_INT;
enum return L_ENUM;
byte return L_BYTE;
/* boolean */
false|off|no return L_FALSE;
true|on|yes return L_TRUE;
/* integers */
[0-9]+ { yylval.i_value = strtol(yytext, (char **)NULL, 10); return L_INTEGER; }
0x[0-9a-f]+ { yylval.i_value = strtol(yytext, (char **)NULL, 0); return L_INTEGER; }
/* strings */
\"[^\"]*\" { yytext[strlen(yytext) - 1] = 0;
yylval.s_value = strdup(&yytext[1]);
return L_STRING; }
\'[^\']*\' { yytext[strlen(yytext) - 1] = 0;
yylval.s_value = strdup(&yytext[1]);
return L_STRING; }
[a-z0-9/\~@-Za-z_]+ { yylval.s_value = strdup(yytext);
return L_STRING; }
$[a-z0-9/\~@-Za-z_]+ { yylval.s_value = strdup(getenv(&yytext[1]));
return L_STRING; }
/* comments & whitespaces */
[#\;][^\n]*\n { linecount++; }
[ \t]+ ;
\n { linecount++; }
. fprintf( stderr, "alsactl: discarding char '%c' - line %i\n", yytext[0], linecount + 1 );
%%
#ifndef yywrap
int yywrap(void) /* do this avoid to do -lfl */
{
return 1;
}
#endif