1128080Semax%{
2128080Semax/*
3128080Semax * lexer.l
4162128Semax */
5162128Semax
6162128Semax/*-
7162128Semax * Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
8128080Semax * All rights reserved.
9128080Semax *
10128080Semax * Redistribution and use in source and binary forms, with or without
11128080Semax * modification, are permitted provided that the following conditions
12128080Semax * are met:
13128080Semax * 1. Redistributions of source code must retain the above copyright
14128080Semax *    notice, this list of conditions and the following disclaimer.
15128080Semax * 2. Redistributions in binary form must reproduce the above copyright
16128080Semax *    notice, this list of conditions and the following disclaimer in the
17128080Semax *    documentation and/or other materials provided with the distribution.
18128080Semax *
19128080Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20128080Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21128080Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22128080Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23128080Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24128080Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25128080Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26128080Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27128080Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28128080Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29128080Semax * SUCH DAMAGE.
30128080Semax *
31162128Semax * $Id: lexer.l,v 1.3 2006/09/07 21:06:53 max Exp $
32128080Semax * $FreeBSD: releng/10.2/usr.sbin/bluetooth/bthidd/lexer.l 250926 2013-05-23 05:42:35Z jkim $
33128080Semax */
34128080Semax
35128080Semax#include <bluetooth.h>
36128080Semax#include <stdlib.h>
37128080Semax#include "parser.h"
38162128Semax
39162128Semax	int	yylex	(void);
40250926Sjkim
41250926Sjkim#define	YY_DECL	int yylex(void)
42128080Semax%}
43128080Semax
44215676Sbrucec%option yylineno noyywrap nounput noinput
45128080Semax
46128080Semaxdelim				[ \t\n]
47128080Semaxws				{delim}+
48128080Semaxempty				{delim}*
49128080Semaxcomment				\#.*
50128080Semax
51128080Semaxhexdigit			[0-9a-fA-F]
52128080Semaxhexbyte				{hexdigit}{hexdigit}?
53128080Semax
54128080Semaxdevice_word			device
55128080Semaxbdaddr_word			bdaddr
56128080Semaxcontrol_psm_word		control_psm
57128080Semaxinterrupt_psm_word		interrupt_psm
58128080Semaxreconnect_initiate_word		reconnect_initiate
59128080Semaxbattery_power_word		battery_power
60128080Semaxnormally_connectable_word	normally_connectable
61128080Semaxhid_descriptor_word		hid_descriptor
62128080Semaxtrue_word			true
63128080Semaxfalse_word			false
64128080Semax
65128080Semaxbdaddrstring			{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}
66128080Semaxhexbytestring			0x{hexbyte}
67128080Semax
68128080Semax%%
69128080Semax
70128080Semax\;				return (';');
71128080Semax\:				return (':');
72128080Semax\{				return ('{');
73128080Semax\}				return ('}');
74128080Semax
75128080Semax{ws}				;
76128080Semax{empty}				;
77128080Semax{comment}			;
78128080Semax
79128080Semax{device_word}			return (T_DEVICE);
80128080Semax{bdaddr_word}			return (T_BDADDR);
81128080Semax{control_psm_word}		return (T_CONTROL_PSM);
82128080Semax{interrupt_psm_word}		return (T_INTERRUPT_PSM);
83128080Semax{reconnect_initiate_word}	return (T_RECONNECT_INITIATE);
84128080Semax{battery_power_word}		return (T_BATTERY_POWER);
85128080Semax{normally_connectable_word}	return (T_NORMALLY_CONNECTABLE);
86128080Semax{hid_descriptor_word}		return (T_HID_DESCRIPTOR);
87128080Semax{true_word}			return (T_TRUE);
88128080Semax{false_word}			return (T_FALSE);
89128080Semax
90128080Semax{bdaddrstring}			{
91128080Semax				return (bt_aton(yytext, &yylval.bdaddr)?
92128080Semax						T_BDADDRSTRING : T_ERROR);
93128080Semax				}
94128080Semax
95128080Semax{hexbytestring}			{
96162128Semax				char	*ep;
97128080Semax
98128080Semax				yylval.num = strtoul(yytext, &ep, 16);
99128080Semax
100128080Semax				return (*ep == '\0'? T_HEXBYTE : T_ERROR);
101128080Semax				}
102128080Semax
103128080Semax.				return (T_ERROR);
104128080Semax
105128080Semax%%
106128080Semax
107