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: stable/11/sbin/hastd/token.l 330449 2018-03-05 07:26:05Z eadler $
34 */
35
36#include <stdio.h>
37#include <string.h>
38
39#include "hast.h"
40
41#include "y.tab.h"
42
43int depth;
44int lineno;
45
46#define	DP	do { } while (0)
47#define	YY_DECL	int yylex(void)
48
49extern int yylex(void);
50%}
51
52%option noinput
53%option nounput
54%option noyywrap
55
56%%
57control			{ DP; return CONTROL; }
58pidfile			{ DP; return PIDFILE; }
59listen			{ DP; return LISTEN; }
60replication		{ DP; return REPLICATION; }
61checksum		{ DP; return CHECKSUM; }
62compression		{ DP; return COMPRESSION; }
63timeout			{ DP; return TIMEOUT; }
64exec			{ DP; return EXEC; }
65metaflush		{ DP; return METAFLUSH; }
66resource		{ DP; return RESOURCE; }
67name			{ DP; return NAME; }
68local			{ DP; return LOCAL; }
69remote			{ DP; return REMOTE; }
70source			{ DP; return SOURCE; }
71on			{ DP; return ON; }
72off			{ DP; return OFF; }
73fullsync		{ DP; return FULLSYNC; }
74memsync			{ DP; return MEMSYNC; }
75async			{ DP; return ASYNC; }
76none			{ DP; return NONE; }
77crc32			{ DP; return CRC32; }
78sha256			{ DP; return SHA256; }
79hole			{ DP; return HOLE; }
80lzf			{ 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