lexer.l revision 162128
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: head/usr.sbin/bluetooth/bthidd/lexer.l 162128 2006-09-07 21:47:49Z emax $ 33128080Semax */ 34128080Semax 35128080Semax#include <bluetooth.h> 36128080Semax#include <stdlib.h> 37128080Semax#include "parser.h" 38162128Semax 39162128Semax int yylex (void); 40128080Semax%} 41128080Semax 42128080Semax%option yylineno noyywrap nounput 43128080Semax 44128080Semaxdelim [ \t\n] 45128080Semaxws {delim}+ 46128080Semaxempty {delim}* 47128080Semaxcomment \#.* 48128080Semax 49128080Semaxhexdigit [0-9a-fA-F] 50128080Semaxhexbyte {hexdigit}{hexdigit}? 51128080Semax 52128080Semaxdevice_word device 53128080Semaxbdaddr_word bdaddr 54128080Semaxcontrol_psm_word control_psm 55128080Semaxinterrupt_psm_word interrupt_psm 56128080Semaxreconnect_initiate_word reconnect_initiate 57128080Semaxbattery_power_word battery_power 58128080Semaxnormally_connectable_word normally_connectable 59128080Semaxhid_descriptor_word hid_descriptor 60128080Semaxtrue_word true 61128080Semaxfalse_word false 62128080Semax 63128080Semaxbdaddrstring {hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte} 64128080Semaxhexbytestring 0x{hexbyte} 65128080Semax 66128080Semax%% 67128080Semax 68128080Semax\; return (';'); 69128080Semax\: return (':'); 70128080Semax\{ return ('{'); 71128080Semax\} return ('}'); 72128080Semax 73128080Semax{ws} ; 74128080Semax{empty} ; 75128080Semax{comment} ; 76128080Semax 77128080Semax{device_word} return (T_DEVICE); 78128080Semax{bdaddr_word} return (T_BDADDR); 79128080Semax{control_psm_word} return (T_CONTROL_PSM); 80128080Semax{interrupt_psm_word} return (T_INTERRUPT_PSM); 81128080Semax{reconnect_initiate_word} return (T_RECONNECT_INITIATE); 82128080Semax{battery_power_word} return (T_BATTERY_POWER); 83128080Semax{normally_connectable_word} return (T_NORMALLY_CONNECTABLE); 84128080Semax{hid_descriptor_word} return (T_HID_DESCRIPTOR); 85128080Semax{true_word} return (T_TRUE); 86128080Semax{false_word} return (T_FALSE); 87128080Semax 88128080Semax{bdaddrstring} { 89128080Semax return (bt_aton(yytext, &yylval.bdaddr)? 90128080Semax T_BDADDRSTRING : T_ERROR); 91128080Semax } 92128080Semax 93128080Semax{hexbytestring} { 94162128Semax char *ep; 95128080Semax 96128080Semax yylval.num = strtoul(yytext, &ep, 16); 97128080Semax 98128080Semax return (*ep == '\0'? T_HEXBYTE : T_ERROR); 99128080Semax } 100128080Semax 101128080Semax. return (T_ERROR); 102128080Semax 103128080Semax%% 104128080Semax 105