File: btsrv-lexer.l

package info (click to toggle)
affix 2.1.1-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,908 kB
  • ctags: 1,247
  • sloc: ansic: 13,807; sh: 7,119; yacc: 232; makefile: 152; lex: 126; python: 56
file content (126 lines) | stat: -rw-r--r-- 2,606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%{
/* 
   Affix - Bluetooth Protocol Stack for Linux
   Copyright (C) 2001 Nokia Corporation
   Original Author: Dmitry Kasatkin <dmitry.kasatkin@nokia.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.
*/

/* 
   $Id: btsrv-lexer.l,v 1.1 2003/03/03 07:52:13 kds Exp $

   Lexical Analizer

   Fixes:	
   		Dmitry Kasatkin <dmitry.kasatkin@nokia.com>
*/

#include <stdio.h>

#include "btsrv.h"
#include "btsrv-parser.h"

int yywrap(void);

char		str[128];
extern int 	waitsemi;

%}

%option yylineno
%array

%s PARAMS

hex		0x[0-9a-fA-F]+
num		[0-9]+
comment		\#.*\n
word		[a-zA-Z\_][a-zA-Z0-9\_]*
wordlist	{word}([ ]*\,*[ ]*{word})*
fname		[A-Za-z0-9\_\.\-]+
path		(\/{fname})+
string		\".*\"


%%

[ \t]+		;

{comment}	;

<INITIAL>{
yes		return OPT_YES;
no		return OPT_NO;
managekey	return OPT_MANAGEKEY;
managepin	return OPT_MANAGEPIN;
startsvc	return OPT_STARTSVC;
initdev		return OPT_INITDEV;
device		return OPT_DEVICE;
service		return OPT_SERVICE;
profile		return OPT_PROFILE;
port		return OPT_PORT;
active		return OPT_ACTIVE;
flags		{ BEGIN PARAMS; return OPT_FLAGS; }
exec		return OPT_EXEC;
provider	return OPT_PROVIDER;
descript	return OPT_DESCRIPT;
security	{ BEGIN PARAMS; return OPT_SECURITY; }
class		{ BEGIN PARAMS; return OPT_COD; }
name		return OPT_NAME;
scan		{ BEGIN PARAMS; return OPT_SCANMODE; }
role		{ BEGIN PARAMS; return OPT_ROLE; }
pkt_type	{ BEGIN PARAMS; return OPT_PKTTYPE; }
}

{hex}		{ sscanf(yytext, "%x", &yylval.num); return NUM; }

{word}		{
			DBPRT("WORD: [%s]", yytext);
			yylval.str = yytext;
			return WORD;
		}

<PARAMS>{wordlist}	{ 
			DBPRT("WORDLIST: [%s]", yytext);
			yylval.str = yytext;
			BEGIN(INITIAL);
			return WORDLIST;
		}

{string}	{
			yylval.str = yytext+1;
			yytext[yyleng-1] = '\0';
			return STRING;
		}
	
[;\n]		{ 
			/* end of params */
			BEGIN(INITIAL);
			if (waitsemi) {
				waitsemi = 0;
				return ';';
			}
		}

.		return *yytext;

%%

int yywrap(void)
{
	return 1;
}