xref: /freebsd/sbin/hastd/token.l (revision b3e76948)
132115b10SPawel Jakub Dawidek %{
232115b10SPawel Jakub Dawidek /*-
34d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
41de7b4b8SPedro F. Giffuni  *
532115b10SPawel Jakub Dawidek  * Copyright (c) 2009-2010 The FreeBSD Foundation
61fee97b0SPawel Jakub Dawidek  * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
732115b10SPawel Jakub Dawidek  * All rights reserved.
832115b10SPawel Jakub Dawidek  *
932115b10SPawel Jakub Dawidek  * This software was developed by Pawel Jakub Dawidek under sponsorship from
1032115b10SPawel Jakub Dawidek  * the FreeBSD Foundation.
1132115b10SPawel Jakub Dawidek  *
1232115b10SPawel Jakub Dawidek  * Redistribution and use in source and binary forms, with or without
1332115b10SPawel Jakub Dawidek  * modification, are permitted provided that the following conditions
1432115b10SPawel Jakub Dawidek  * are met:
1532115b10SPawel Jakub Dawidek  * 1. Redistributions of source code must retain the above copyright
1632115b10SPawel Jakub Dawidek  *    notice, this list of conditions and the following disclaimer.
1732115b10SPawel Jakub Dawidek  * 2. Redistributions in binary form must reproduce the above copyright
1832115b10SPawel Jakub Dawidek  *    notice, this list of conditions and the following disclaimer in the
1932115b10SPawel Jakub Dawidek  *    documentation and/or other materials provided with the distribution.
2032115b10SPawel Jakub Dawidek  *
2132115b10SPawel Jakub Dawidek  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
2232115b10SPawel Jakub Dawidek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2332115b10SPawel Jakub Dawidek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2432115b10SPawel Jakub Dawidek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
2532115b10SPawel Jakub Dawidek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2632115b10SPawel Jakub Dawidek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2732115b10SPawel Jakub Dawidek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2832115b10SPawel Jakub Dawidek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2932115b10SPawel Jakub Dawidek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3032115b10SPawel Jakub Dawidek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3132115b10SPawel Jakub Dawidek  * SUCH DAMAGE.
3232115b10SPawel Jakub Dawidek  */
3332115b10SPawel Jakub Dawidek 
3432115b10SPawel Jakub Dawidek #include <stdio.h>
3532115b10SPawel Jakub Dawidek #include <string.h>
3632115b10SPawel Jakub Dawidek 
3732115b10SPawel Jakub Dawidek #include "hast.h"
3832115b10SPawel Jakub Dawidek 
3932115b10SPawel Jakub Dawidek #include "y.tab.h"
4032115b10SPawel Jakub Dawidek 
4132115b10SPawel Jakub Dawidek int depth;
4232115b10SPawel Jakub Dawidek int lineno;
4332115b10SPawel Jakub Dawidek 
4432115b10SPawel Jakub Dawidek #define	DP	do { } while (0)
45eb8b73d6SJung-uk Kim #define	YY_DECL	int yylex(void)
46eb8b73d6SJung-uk Kim 
47eb8b73d6SJung-uk Kim extern int yylex(void);
4832115b10SPawel Jakub Dawidek %}
4932115b10SPawel Jakub Dawidek 
508a605b3fSPawel Jakub Dawidek %option noinput
518a605b3fSPawel Jakub Dawidek %option nounput
521df892f4SMikolaj Golub %option noyywrap
538a605b3fSPawel Jakub Dawidek 
5432115b10SPawel Jakub Dawidek %%
5532115b10SPawel Jakub Dawidek control			{ DP; return CONTROL; }
56bd738d63SPawel Jakub Dawidek pidfile			{ DP; return PIDFILE; }
5732115b10SPawel Jakub Dawidek listen			{ DP; return LISTEN; }
5832115b10SPawel Jakub Dawidek replication		{ DP; return REPLICATION; }
591fee97b0SPawel Jakub Dawidek checksum		{ DP; return CHECKSUM; }
608cd3d45aSPawel Jakub Dawidek compression		{ DP; return COMPRESSION; }
615571414cSPawel Jakub Dawidek timeout			{ DP; return TIMEOUT; }
620becad39SPawel Jakub Dawidek exec			{ DP; return EXEC; }
63518dd4c0SPawel Jakub Dawidek metaflush		{ DP; return METAFLUSH; }
6432115b10SPawel Jakub Dawidek resource		{ DP; return RESOURCE; }
6532115b10SPawel Jakub Dawidek name			{ DP; return NAME; }
6632115b10SPawel Jakub Dawidek local			{ DP; return LOCAL; }
6732115b10SPawel Jakub Dawidek remote			{ DP; return REMOTE; }
680b626a28SPawel Jakub Dawidek source			{ DP; return SOURCE; }
6932115b10SPawel Jakub Dawidek on			{ DP; return ON; }
70518dd4c0SPawel Jakub Dawidek off			{ DP; return OFF; }
7132115b10SPawel Jakub Dawidek fullsync		{ DP; return FULLSYNC; }
7232115b10SPawel Jakub Dawidek memsync			{ DP; return MEMSYNC; }
7332115b10SPawel Jakub Dawidek async			{ DP; return ASYNC; }
741fee97b0SPawel Jakub Dawidek none			{ DP; return NONE; }
751fee97b0SPawel Jakub Dawidek crc32			{ DP; return CRC32; }
761fee97b0SPawel Jakub Dawidek sha256			{ DP; return SHA256; }
778cd3d45aSPawel Jakub Dawidek hole			{ DP; return HOLE; }
788cd3d45aSPawel Jakub Dawidek lzf			{ DP; return LZF; }
7932115b10SPawel Jakub Dawidek [0-9]+			{ DP; yylval.num = atoi(yytext); return NUM; }
80496a87aaSPawel Jakub Dawidek [a-zA-Z0-9\.\-_/\:\[\]]+ { DP; yylval.str = strdup(yytext); return STR; }
8132115b10SPawel Jakub Dawidek \{			{ DP; depth++; return OB; }
8232115b10SPawel Jakub Dawidek \}			{ DP; depth--; return CB; }
8332115b10SPawel Jakub Dawidek #.*$			/* ignore comments */;
8432115b10SPawel Jakub Dawidek \n			{ lineno++; }
8532115b10SPawel Jakub Dawidek [ \t]+			/* ignore whitespace */;
8632115b10SPawel Jakub Dawidek %%
87