1*3fe401a5SEd Maste %{ 2*3fe401a5SEd Maste /*- 3*3fe401a5SEd Maste * Copyright (c) 2008 Kai Wang 4*3fe401a5SEd Maste * All rights reserved. 5*3fe401a5SEd Maste * 6*3fe401a5SEd Maste * Redistribution and use in source and binary forms, with or without 7*3fe401a5SEd Maste * modification, are permitted provided that the following conditions 8*3fe401a5SEd Maste * are met: 9*3fe401a5SEd Maste * 1. Redistributions of source code must retain the above copyright 10*3fe401a5SEd Maste * notice, this list of conditions and the following disclaimer 11*3fe401a5SEd Maste * in this position and unchanged. 12*3fe401a5SEd Maste * 2. Redistributions in binary form must reproduce the above copyright 13*3fe401a5SEd Maste * notice, this list of conditions and the following disclaimer in the 14*3fe401a5SEd Maste * documentation and/or other materials provided with the distribution. 15*3fe401a5SEd Maste * 16*3fe401a5SEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 17*3fe401a5SEd Maste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18*3fe401a5SEd Maste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19*3fe401a5SEd Maste * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 20*3fe401a5SEd Maste * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21*3fe401a5SEd Maste * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22*3fe401a5SEd Maste * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23*3fe401a5SEd Maste * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24*3fe401a5SEd Maste * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25*3fe401a5SEd Maste * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*3fe401a5SEd Maste */ 27*3fe401a5SEd Maste 28*3fe401a5SEd Maste #include <err.h> 29*3fe401a5SEd Maste #include <errno.h> 30*3fe401a5SEd Maste #include <stdio.h> 31*3fe401a5SEd Maste #include <string.h> 32*3fe401a5SEd Maste 33*3fe401a5SEd Maste #include "_elftc.h" 34*3fe401a5SEd Maste 35*3fe401a5SEd Maste ELFTC_VCSID("$Id: acplex.l 3174 2015-03-27 17:13:41Z emaste $"); 36*3fe401a5SEd Maste 37*3fe401a5SEd Maste #include "acpyacc.h" 38*3fe401a5SEd Maste 39*3fe401a5SEd Maste #define YY_NO_UNPUT 40*3fe401a5SEd Maste #if !defined(ELFTC_BROKEN_YY_NO_INPUT) 41*3fe401a5SEd Maste #define YY_NO_INPUT 42*3fe401a5SEd Maste #endif 43*3fe401a5SEd Maste 44*3fe401a5SEd Maste int lineno = 1; 45*3fe401a5SEd Maste 46*3fe401a5SEd Maste int yylex(void); 47*3fe401a5SEd Maste 48*3fe401a5SEd Maste %} 49*3fe401a5SEd Maste 50*3fe401a5SEd Maste %option nounput 51*3fe401a5SEd Maste %option noyywrap 52*3fe401a5SEd Maste 53*3fe401a5SEd Maste %% 54*3fe401a5SEd Maste 55*3fe401a5SEd Maste ADDLIB|addlib { return (ADDLIB); } 56*3fe401a5SEd Maste ADDMOD|addmod { return (ADDMOD); } 57*3fe401a5SEd Maste CLEAR|clear { return (CLEAR); } 58*3fe401a5SEd Maste CREATE|create { return (CREATE); } 59*3fe401a5SEd Maste DELETE|delete { return (DELETE); } 60*3fe401a5SEd Maste DIRECTORY|directory { return (DIRECTORY); } 61*3fe401a5SEd Maste END|end { return (END); } 62*3fe401a5SEd Maste EXTRACT|extract { return (EXTRACT); } 63*3fe401a5SEd Maste LIST|list { return (LIST); } 64*3fe401a5SEd Maste OPEN|open { return (OPEN); } 65*3fe401a5SEd Maste REPLACE|replace { return (REPLACE); } 66*3fe401a5SEd Maste VERBOSE|verbose { return (VERBOSE); } 67*3fe401a5SEd Maste SAVE|save { return (SAVE); } 68*3fe401a5SEd Maste "(" { return (LP); } 69*3fe401a5SEd Maste ")" { return (RP); } 70*3fe401a5SEd Maste "," { return (COMMA); } 71*3fe401a5SEd Maste 72*3fe401a5SEd Maste [-_A-Za-z0-9/:$.\\]+ { 73*3fe401a5SEd Maste yylval.str = strdup(yytext); 74*3fe401a5SEd Maste if (yylval.str == NULL) 75*3fe401a5SEd Maste err(EXIT_FAILURE, "strdup failed"); 76*3fe401a5SEd Maste return (FNAME); 77*3fe401a5SEd Maste } 78*3fe401a5SEd Maste 79*3fe401a5SEd Maste [ \t] /* whitespace */ 80*3fe401a5SEd Maste "*".* /* comment */ 81*3fe401a5SEd Maste ";".* /* comment */ 82*3fe401a5SEd Maste "+\n" { lineno++; /* '+' is line continuation char */ } 83*3fe401a5SEd Maste "\n" { lineno++; return (EOL); } 84