xref: /freebsd/sbin/hastd/token.l (revision 5b0945b57059d1cde0831d3afea7ec56c7d79508)
1 %{
2 /*-
3  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4  *
5  * Copyright (c) 2009-2010 The FreeBSD Foundation
6  * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
7  * All rights reserved.
8  *
9  * This software was developed by Pawel Jakub Dawidek under sponsorship from
10  * the FreeBSD Foundation.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * $FreeBSD$
34  */
35 
36 #include <stdio.h>
37 #include <string.h>
38 
39 #include "hast.h"
40 
41 #include "y.tab.h"
42 
43 int depth;
44 int lineno;
45 
46 #define	DP	do { } while (0)
47 #define	YY_DECL	int yylex(void)
48 
49 extern int yylex(void);
50 %}
51 
52 %option noinput
53 %option nounput
54 %option noyywrap
55 
56 %%
57 control			{ DP; return CONTROL; }
58 pidfile			{ DP; return PIDFILE; }
59 listen			{ DP; return LISTEN; }
60 replication		{ DP; return REPLICATION; }
61 checksum		{ DP; return CHECKSUM; }
62 compression		{ DP; return COMPRESSION; }
63 timeout			{ DP; return TIMEOUT; }
64 exec			{ DP; return EXEC; }
65 metaflush		{ DP; return METAFLUSH; }
66 resource		{ DP; return RESOURCE; }
67 name			{ DP; return NAME; }
68 local			{ DP; return LOCAL; }
69 remote			{ DP; return REMOTE; }
70 source			{ DP; return SOURCE; }
71 on			{ DP; return ON; }
72 off			{ DP; return OFF; }
73 fullsync		{ DP; return FULLSYNC; }
74 memsync			{ DP; return MEMSYNC; }
75 async			{ DP; return ASYNC; }
76 none			{ DP; return NONE; }
77 crc32			{ DP; return CRC32; }
78 sha256			{ DP; return SHA256; }
79 hole			{ DP; return HOLE; }
80 lzf			{ DP; return LZF; }
81 [0-9]+			{ DP; yylval.num = atoi(yytext); return NUM; }
82 [a-zA-Z0-9\.\-_/\:\[\]]+ { DP; yylval.str = strdup(yytext); return STR; }
83 \{			{ DP; depth++; return OB; }
84 \}			{ DP; depth--; return CB; }
85 #.*$			/* ignore comments */;
86 \n			{ lineno++; }
87 [ \t]+			/* ignore whitespace */;
88 %%
89