1183218Skaiw%{ 2183218Skaiw/*- 3183218Skaiw * Copyright (c) 2008 Kai Wang 4183218Skaiw * All rights reserved. 5183218Skaiw * 6183218Skaiw * Redistribution and use in source and binary forms, with or without 7183218Skaiw * modification, are permitted provided that the following conditions 8183218Skaiw * are met: 9183218Skaiw * 1. Redistributions of source code must retain the above copyright 10183218Skaiw * notice, this list of conditions and the following disclaimer 11183218Skaiw * in this position and unchanged. 12183218Skaiw * 2. Redistributions in binary form must reproduce the above copyright 13183218Skaiw * notice, this list of conditions and the following disclaimer in the 14183218Skaiw * documentation and/or other materials provided with the distribution. 15183218Skaiw * 16183218Skaiw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 17183218Skaiw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18183218Skaiw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19183218Skaiw * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 20183218Skaiw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21183218Skaiw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22183218Skaiw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23183218Skaiw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24183218Skaiw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25183218Skaiw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26183218Skaiw */ 27183218Skaiw 28183218Skaiw#include <sys/cdefs.h> 29183218Skaiw__FBSDID("$FreeBSD$"); 30183218Skaiw 31183218Skaiw#include <err.h> 32183218Skaiw#include <errno.h> 33183218Skaiw#include <stdio.h> 34183218Skaiw#include <string.h> 35183218Skaiw#include <sysexits.h> 36183218Skaiw 37183218Skaiw#include "y.tab.h" 38183218Skaiw 39183218Skaiwint lineno = 1; 40183218Skaiw 41183218Skaiwint yylex(void); 42183218Skaiw 43250926Sjkim#define YY_DECL int yylex(void) 44250926Sjkim 45183218Skaiw%} 46183218Skaiw 47250227Sjkim%option nounput 48250227Sjkim%option noinput 49183218Skaiw%option noyywrap 50183218Skaiw 51183218Skaiw%% 52183218Skaiw 53183218SkaiwADDLIB|addlib { return (ADDLIB); } 54183218SkaiwADDMOD|addmod { return (ADDMOD); } 55183218SkaiwCLEAR|clear { return (CLEAR); } 56183218SkaiwCREATE|create { return (CREATE); } 57183218SkaiwDELETE|delete { return (DELETE); } 58183218SkaiwDIRECTORY|directory { return (DIRECTORY); } 59183218SkaiwEND|end { return (END); } 60183218SkaiwEXTRACT|extract { return (EXTRACT); } 61183218SkaiwLIST|list { return (LIST); } 62183218SkaiwOPEN|open { return (OPEN); } 63183218SkaiwREPLACE|replace { return (REPLACE); } 64183218SkaiwVERBOSE|verbose { return (VERBOSE); } 65183218SkaiwSAVE|save { return (SAVE); } 66183218Skaiw"(" { return (LP); } 67183218Skaiw")" { return (RP); } 68183218Skaiw"," { return (COMMA); } 69183218Skaiw 70183218Skaiw[-_A-Za-z0-9/:$.\\]+ { 71183218Skaiw yylval.str = strdup(yytext); 72183218Skaiw if (yylval.str == NULL) 73183218Skaiw errc(EX_SOFTWARE, errno, "strdup failed"); 74183218Skaiw return (FNAME); 75183218Skaiw} 76183218Skaiw 77183218Skaiw[ \t] /* whitespace */ 78183218Skaiw"*".* /* comment */ 79183218Skaiw";".* /* comment */ 80183218Skaiw"+\n" { lineno++; /* '+' is line continuation char */ } 81183218Skaiw"\n" { lineno++; return (EOL); } 82