lexer.l revision 215676
1114879Sjulian%{ 2114879Sjulian/* 3114879Sjulian * lexer.l 4114879Sjulian * 5114879Sjulian * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com> 6114879Sjulian * All rights reserved. 7114879Sjulian * 8114879Sjulian * Redistribution and use in source and binary forms, with or without 9114879Sjulian * modification, are permitted provided that the following conditions 10114879Sjulian * are met: 11114879Sjulian * 1. Redistributions of source code must retain the above copyright 12114879Sjulian * notice, this list of conditions and the following disclaimer. 13114879Sjulian * 2. Redistributions in binary form must reproduce the above copyright 14114879Sjulian * notice, this list of conditions and the following disclaimer in the 15114879Sjulian * documentation and/or other materials provided with the distribution. 16114879Sjulian * 17114879Sjulian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18114879Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19114879Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20114879Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21114879Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22114879Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23114879Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24114879Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25114879Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26114879Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27114879Sjulian * SUCH DAMAGE. 28114879Sjulian * 29114879Sjulian * $Id: lexer.l,v 1.1 2002/11/24 20:22:39 max Exp $ 30114879Sjulian * $FreeBSD: head/usr.sbin/bluetooth/hcsecd/lexer.l 215676 2010-11-22 14:16:22Z brucec $ 31114879Sjulian */ 32114879Sjulian 33114879Sjulian#include <string.h> 34114879Sjulian#include "parser.h" 35114879Sjulian%} 36114879Sjulian 37215676Sbrucec%option yylineno noyywrap nounput noinput 38114879Sjulian 39114879Sjuliandelim [ \t\n] 40114879Sjulianws {delim}+ 41114879Sjulianempty {delim}* 42114879Sjuliancomment \#.* 43114879Sjulian 44114879Sjulianhexdigit [0-9a-fA-F] 45114879Sjulianhexbyte {hexdigit}{hexdigit} 46114879Sjulian 47114879Sjuliandevice_word device 48114879Sjulianbdaddr_word bdaddr 49114879Sjulianname_word name 50114879Sjuliankey_word key 51114879Sjuliannokey_word nokey 52114879Sjulianpin_word pin 53114879Sjuliannopin_word nopin 54114879Sjulian 55114879Sjulianbdaddrstring {hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte} 56114879Sjulianhexstring 0x{hexbyte}+ 57114879Sjulianstring \".+\" 58114879Sjulian 59114879Sjulian%% 60114879Sjulian 61114879Sjulian\; return (';'); 62114879Sjulian\: return (':'); 63114879Sjulian\{ return ('{'); 64114879Sjulian\} return ('}'); 65114879Sjulian 66114879Sjulian{ws} ; 67114879Sjulian{empty} ; 68114879Sjulian{comment} ; 69114879Sjulian 70114879Sjulian{device_word} return (T_DEVICE); 71114879Sjulian{bdaddr_word} return (T_BDADDR); 72114879Sjulian{name_word} return (T_NAME); 73114879Sjulian{key_word} return (T_KEY); 74114879Sjulian{nokey_word} return (T_NOKEY); 75114879Sjulian{pin_word} return (T_PIN); 76114879Sjulian{nopin_word} return (T_NOPIN); 77114879Sjulian 78114879Sjulian{bdaddrstring} { 79114879Sjulian yylval.string = yytext; 80114879Sjulian return (T_BDADDRSTRING); 81114879Sjulian } 82114879Sjulian 83114879Sjulian{hexstring} { 84114879Sjulian yylval.string = &yytext[2]; 85114879Sjulian return (T_HEXSTRING); 86114879Sjulian } 87114879Sjulian 88114879Sjulian{string} { 89114879Sjulian yytext[strlen(yytext) - 1] = 0; 90114879Sjulian yylval.string = &yytext[1]; 91114879Sjulian return (T_STRING); 92114879Sjulian } 93114879Sjulian 94114879Sjulian%% 95114879Sjulian 96