xref: /freebsd/usr.sbin/ctld/token.l (revision 24e4dcf4ba5e9dedcf89efd358ea3e1fe5867020)
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 controller		{ return CONTROLLER; }
58 ctl-lun			{ return CTL_LUN; }
59 debug			{ return DEBUG; }
60 device-id		{ return DEVICE_ID; }
61 device-type		{ return DEVICE_TYPE; }
62 discovery-auth-group	{ return DISCOVERY_AUTH_GROUP; }
63 discovery-filter	{ return DISCOVERY_FILTER; }
64 discovery-tcp		{ return DISCOVERY_TCP; }
65 dscp			{ return DSCP; }
66 pcp			{ return PCP; }
67 foreign			{ return FOREIGN; }
68 host-address		{ return HOST_ADDRESS; }
69 host-nqn		{ return HOST_NQN; }
70 initiator-name		{ return INITIATOR_NAME; }
71 initiator-portal	{ return INITIATOR_PORTAL; }
72 listen			{ return LISTEN; }
73 listen-iser		{ return LISTEN_ISER; }
74 lun			{ return LUN; }
75 maxproc			{ return MAXPROC; }
76 namespace		{ return NAMESPACE; }
77 offload			{ return OFFLOAD; }
78 option			{ return OPTION; }
79 path			{ return PATH; }
80 pidfile			{ return PIDFILE; }
81 isns-server		{ return ISNS_SERVER; }
82 isns-period		{ return ISNS_PERIOD; }
83 isns-timeout		{ return ISNS_TIMEOUT; }
84 port			{ return PORT; }
85 portal-group		{ return PORTAL_GROUP; }
86 redirect		{ return REDIRECT; }
87 serial			{ return SERIAL; }
88 size			{ return SIZE; }
89 tag			{ return TAG; }
90 target			{ return TARGET; }
91 tcp			{ return TCP; }
92 timeout			{ return TIMEOUT; }
93 transport-group		{ return TRANSPORT_GROUP; }
94 af11			{ return AF11; }
95 af12			{ return AF12; }
96 af13			{ return AF13; }
97 af21			{ return AF21; }
98 af22			{ return AF22; }
99 af23			{ return AF23; }
100 af31			{ return AF31; }
101 af32			{ return AF32; }
102 af33			{ return AF33; }
103 af41			{ return AF41; }
104 af42			{ return AF42; }
105 af43			{ return AF43; }
106 be			{ return CS0;  }
107 ef			{ return EF;   }
108 cs0			{ return CS0;  }
109 cs1			{ return CS1;  }
110 cs2			{ return CS2;  }
111 cs3			{ return CS3;  }
112 cs4			{ return CS4;  }
113 cs5			{ return CS5;  }
114 cs6			{ return CS6;  }
115 cs7			{ return CS7;  }
116 \"[^"]+\"		{ yylval.str = strndup(yytext + 1,
117 			    strlen(yytext) - 2); return STR; }
118 [a-zA-Z0-9\.\-@_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; }
119 \{			{ return OPENING_BRACKET; }
120 \}			{ return CLOSING_BRACKET; }
121 #.*$			/* ignore comments */;
122 \r\n			{ lineno++; }
123 \n			{ lineno++; }
124 ;			{ return SEMICOLON; }
125 [ \t]+			/* ignore whitespace */;
126 .			{ yylval.str = strdup(yytext); return STR; }
127 %%
128