acplex.l revision 183218
1100978Srwatson%{
2126097Srwatson/*-
3145167Srwatson * Copyright (c) 2008 Kai Wang
4163606Srwatson * All rights reserved.
5100978Srwatson *
6100978Srwatson * Redistribution and use in source and binary forms, with or without
7100978Srwatson * modification, are permitted provided that the following conditions
8100978Srwatson * are met:
9106392Srwatson * 1. Redistributions of source code must retain the above copyright
10106392Srwatson *    notice, this list of conditions and the following disclaimer
11106392Srwatson *    in this position and unchanged.
12106392Srwatson * 2. Redistributions in binary form must reproduce the above copyright
13100978Srwatson *    notice, this list of conditions and the following disclaimer in the
14147784Srwatson *    documentation and/or other materials provided with the distribution.
15147784Srwatson *
16147784Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
17100978Srwatson * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18100978Srwatson * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19100978Srwatson * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
20100978Srwatson * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21100978Srwatson * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22100978Srwatson * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23100978Srwatson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24100978Srwatson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25100978Srwatson * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26100978Srwatson */
27100978Srwatson
28100978Srwatson#include <sys/cdefs.h>
29100978Srwatson__FBSDID("$FreeBSD: head/usr.bin/ar/acplex.l 183218 2008-09-20 22:10:10Z kaiw $");
30100978Srwatson
31100978Srwatson#include <err.h>
32100978Srwatson#include <errno.h>
33100978Srwatson#include <stdio.h>
34100978Srwatson#include <string.h>
35100978Srwatson#include <sysexits.h>
36100978Srwatson
37100978Srwatson#include "y.tab.h"
38100978Srwatson
39100978Srwatson#define YY_NO_UNPUT
40100978Srwatsonint lineno = 1;
41166537Srwatson
42166537Srwatsonint	yylex(void);
43100978Srwatson
44166537Srwatson%}
45100978Srwatson
46145167Srwatson%option noyywrap
47129096Srwatson
48129096Srwatson%%
49100978Srwatson
50100978SrwatsonADDLIB|addlib		{ return (ADDLIB); }
51100978SrwatsonADDMOD|addmod		{ return (ADDMOD); }
52100978SrwatsonCLEAR|clear		{ return (CLEAR); }
53100978SrwatsonCREATE|create		{ return (CREATE); }
54100978SrwatsonDELETE|delete		{ return (DELETE); }
55102123SrwatsonDIRECTORY|directory	{ return (DIRECTORY); }
56102123SrwatsonEND|end			{ return (END); }
57105693SrwatsonEXTRACT|extract		{ return (EXTRACT); }
58105693SrwatsonLIST|list		{ return (LIST); }
59105693SrwatsonOPEN|open		{ return (OPEN); }
60105693SrwatsonREPLACE|replace		{ return (REPLACE); }
61102123SrwatsonVERBOSE|verbose		{ return (VERBOSE); }
62166537SrwatsonSAVE|save		{ return (SAVE); }
63166537Srwatson"("			{ return (LP); }
64166537Srwatson")"			{ return (RP); }
65166537Srwatson","			{ return (COMMA); }
66105693Srwatson
67105693Srwatson[-_A-Za-z0-9/:$.\\]+	{
68105693Srwatson	yylval.str = strdup(yytext);
69105693Srwatson	if (yylval.str == NULL)
70105693Srwatson		errc(EX_SOFTWARE, errno, "strdup failed");
71105693Srwatson	return (FNAME);
72105693Srwatson}
73105693Srwatson
74105693Srwatson[ \t]			/* whitespace */
75102123Srwatson"*".*			/* comment */
76105693Srwatson";".*			/* comment */
77166537Srwatson"+\n"			{ lineno++; /* '+' is line continuation char */ }
78100978Srwatson"\n"			{ lineno++; return (EOL); }
79105693Srwatson