token.l revision 261766
1255570Strasz%{ 2255570Strasz/*- 3255570Strasz * Copyright (c) 2012 The FreeBSD Foundation 4255570Strasz * All rights reserved. 5255570Strasz * 6255570Strasz * This software was developed by Edward Tomasz Napierala under sponsorship 7255570Strasz * from the FreeBSD Foundation. 8255570Strasz * 9255570Strasz * Redistribution and use in source and binary forms, with or without 10255570Strasz * modification, are permitted provided that the following conditions 11255570Strasz * are met: 12255570Strasz * 1. Redistributions of source code must retain the above copyright 13255570Strasz * notice, this list of conditions and the following disclaimer. 14255570Strasz * 2. Redistributions in binary form must reproduce the above copyright 15255570Strasz * notice, this list of conditions and the following disclaimer in the 16255570Strasz * documentation and/or other materials provided with the distribution. 17255570Strasz * 18255570Strasz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19255570Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20255570Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21255570Strasz * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22255570Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23255570Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24255570Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25255570Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26255570Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27255570Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28255570Strasz * SUCH DAMAGE. 29255570Strasz * 30255570Strasz * $FreeBSD: head/usr.sbin/ctld/token.l 261766 2014-02-11 11:36:15Z trasz $ 31255570Strasz */ 32255570Strasz 33255570Strasz#include <stdio.h> 34255570Strasz#include <stdint.h> 35255570Strasz#include <string.h> 36255570Strasz 37255570Strasz#include "ctld.h" 38255570Strasz#include "y.tab.h" 39255570Strasz 40255570Straszint lineno; 41255570Strasz 42255570Strasz#define YY_DECL int yylex(void) 43255570Straszextern int yylex(void); 44255570Strasz 45255570Strasz%} 46255570Strasz 47255570Strasz%option noinput 48255570Strasz%option nounput 49255570Strasz 50255570Strasz%% 51255570Straszalias { return ALIAS; } 52255570Straszauth-group { return AUTH_GROUP; } 53261758Straszauth-type { return AUTH_TYPE; } 54255570Straszbackend { return BACKEND; } 55255570Straszblocksize { return BLOCKSIZE; } 56255570Straszchap { return CHAP; } 57255570Straszchap-mutual { return CHAP_MUTUAL; } 58255570Straszdebug { return DEBUG; } 59255570Straszdevice-id { return DEVICE_ID; } 60255570Straszdiscovery-auth-group { return DISCOVERY_AUTH_GROUP; } 61261754Straszinitiator-name { return INITIATOR_NAME; } 62261754Straszinitiator-portal { return INITIATOR_PORTAL; } 63255570Straszlisten { return LISTEN; } 64255570Straszlisten-iser { return LISTEN_ISER; } 65255570Straszlun { return LUN; } 66255570Straszmaxproc { return MAXPROC; } 67255570Straszoption { return OPTION; } 68255570Straszpath { return PATH; } 69255570Straszpidfile { return PIDFILE; } 70255570Straszportal-group { return PORTAL_GROUP; } 71255570Straszserial { return SERIAL; } 72255570Straszsize { return SIZE; } 73255570Strasztarget { return TARGET; } 74255570Strasztimeout { return TIMEOUT; } 75255570Strasz[0-9]+[kKmMgGtTpPeE]? { if (expand_number(yytext, &yylval.num) == 0) 76255570Strasz return NUM; 77255570Strasz else 78255570Strasz return STR; 79255570Strasz } 80255570Strasz\"[^"]+\" { yylval.str = strndup(yytext + 1, 81255570Strasz strlen(yytext) - 2); return STR; } 82255570Strasz[a-zA-Z0-9\.\-_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; } 83255570Strasz\{ { return OPENING_BRACKET; } 84255570Strasz\} { return CLOSING_BRACKET; } 85255570Strasz#.*$ /* ignore comments */; 86255570Strasz\n { lineno++; } 87255570Strasz[ \t]+ /* ignore whitespace */; 88261766Strasz. { yylval.str = strdup(yytext); return STR; } 89255570Strasz%% 90