xref: /freebsd/usr.sbin/ctld/token.l (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 %{
2 /*-
3  * SPDX-License-Identifier: BSD-2-Clause
4  *
5  * Copyright (c) 2012 The FreeBSD Foundation
6  *
7  * This software was developed by Edward Tomasz Napierala under sponsorship
8  * from the FreeBSD Foundation.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #include <stdio.h>
33 #include <stdint.h>
34 #include <string.h>
35 
36 #include "y.tab.h"
37 
38 int lineno;
39 
40 #define	YY_DECL int yylex(void)
41 extern int	yylex(void);
42 
43 %}
44 
45 %option noyywrap
46 %option noinput
47 %option nounput
48 
49 %%
50 alias			{ return ALIAS; }
51 auth-group		{ return AUTH_GROUP; }
52 auth-type		{ return AUTH_TYPE; }
53 backend			{ return BACKEND; }
54 blocksize		{ return BLOCKSIZE; }
55 chap			{ return CHAP; }
56 chap-mutual		{ return CHAP_MUTUAL; }
57 ctl-lun			{ return CTL_LUN; }
58 debug			{ return DEBUG; }
59 device-id		{ return DEVICE_ID; }
60 device-type		{ return DEVICE_TYPE; }
61 discovery-auth-group	{ return DISCOVERY_AUTH_GROUP; }
62 discovery-filter	{ return DISCOVERY_FILTER; }
63 dscp			{ return DSCP; }
64 pcp			{ return PCP; }
65 foreign			{ return FOREIGN; }
66 initiator-name		{ return INITIATOR_NAME; }
67 initiator-portal	{ return INITIATOR_PORTAL; }
68 listen			{ return LISTEN; }
69 listen-iser		{ return LISTEN_ISER; }
70 lun			{ return LUN; }
71 maxproc			{ return MAXPROC; }
72 offload			{ return OFFLOAD; }
73 option			{ return OPTION; }
74 path			{ return PATH; }
75 pidfile			{ return PIDFILE; }
76 isns-server		{ return ISNS_SERVER; }
77 isns-period		{ return ISNS_PERIOD; }
78 isns-timeout		{ return ISNS_TIMEOUT; }
79 port			{ return PORT; }
80 portal-group		{ return PORTAL_GROUP; }
81 redirect		{ return REDIRECT; }
82 serial			{ return SERIAL; }
83 size			{ return SIZE; }
84 tag			{ return TAG; }
85 target			{ return TARGET; }
86 timeout			{ return TIMEOUT; }
87 af11			{ return AF11; }
88 af12			{ return AF12; }
89 af13			{ return AF13; }
90 af21			{ return AF21; }
91 af22			{ return AF22; }
92 af23			{ return AF23; }
93 af31			{ return AF31; }
94 af32			{ return AF32; }
95 af33			{ return AF33; }
96 af41			{ return AF41; }
97 af42			{ return AF42; }
98 af43			{ return AF43; }
99 be			{ return CS0;  }
100 ef			{ return EF;   }
101 cs0			{ return CS0;  }
102 cs1			{ return CS1;  }
103 cs2			{ return CS2;  }
104 cs3			{ return CS3;  }
105 cs4			{ return CS4;  }
106 cs5			{ return CS5;  }
107 cs6			{ return CS6;  }
108 cs7			{ return CS7;  }
109 \"[^"]+\"		{ yylval.str = strndup(yytext + 1,
110 			    strlen(yytext) - 2); return STR; }
111 [a-zA-Z0-9\.\-@_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; }
112 \{			{ return OPENING_BRACKET; }
113 \}			{ return CLOSING_BRACKET; }
114 #.*$			/* ignore comments */;
115 \r\n			{ lineno++; }
116 \n			{ lineno++; }
117 ;			{ return SEMICOLON; }
118 [ \t]+			/* ignore whitespace */;
119 .			{ yylval.str = strdup(yytext); return STR; }
120 %%
121