token.l revision 251004
1204076Spjd%{
2204076Spjd/*-
3204076Spjd * Copyright (c) 2009-2010 The FreeBSD Foundation
4219351Spjd * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
5204076Spjd * All rights reserved.
6204076Spjd *
7204076Spjd * This software was developed by Pawel Jakub Dawidek under sponsorship from
8204076Spjd * the FreeBSD Foundation.
9204076Spjd *
10204076Spjd * Redistribution and use in source and binary forms, with or without
11204076Spjd * modification, are permitted provided that the following conditions
12204076Spjd * are met:
13204076Spjd * 1. Redistributions of source code must retain the above copyright
14204076Spjd *    notice, this list of conditions and the following disclaimer.
15204076Spjd * 2. Redistributions in binary form must reproduce the above copyright
16204076Spjd *    notice, this list of conditions and the following disclaimer in the
17204076Spjd *    documentation and/or other materials provided with the distribution.
18204076Spjd *
19204076Spjd * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
20204076Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21204076Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22204076Spjd * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
23204076Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24204076Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25204076Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26204076Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27204076Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28204076Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29204076Spjd * SUCH DAMAGE.
30204076Spjd *
31204076Spjd * $FreeBSD: stable/9/sbin/hastd/token.l 251004 2013-05-26 18:28:36Z trociny $
32204076Spjd */
33204076Spjd
34204076Spjd#include <stdio.h>
35204076Spjd#include <string.h>
36204076Spjd
37204076Spjd#include "hast.h"
38204076Spjd
39204076Spjd#include "y.tab.h"
40204076Spjd
41204076Spjdint depth;
42204076Spjdint lineno;
43204076Spjd
44204076Spjd#define	DP	do { } while (0)
45204076Spjd%}
46204076Spjd
47229509Strociny%option noinput
48229509Strociny%option nounput
49251004Strociny%option noyywrap
50229509Strociny
51204076Spjd%%
52204076Spjdcontrol			{ DP; return CONTROL; }
53229509Strocinypidfile			{ DP; return PIDFILE; }
54204076Spjdlisten			{ DP; return LISTEN; }
55204076Spjdreplication		{ DP; return REPLICATION; }
56219351Spjdchecksum		{ DP; return CHECKSUM; }
57219354Spjdcompression		{ DP; return COMPRESSION; }
58207371Spjdtimeout			{ DP; return TIMEOUT; }
59211886Spjdexec			{ DP; return EXEC; }
60229509Strocinymetaflush		{ DP; return METAFLUSH; }
61204076Spjdresource		{ DP; return RESOURCE; }
62204076Spjdname			{ DP; return NAME; }
63204076Spjdlocal			{ DP; return LOCAL; }
64204076Spjdremote			{ DP; return REMOTE; }
65219818Spjdsource			{ DP; return SOURCE; }
66204076Spjdon			{ DP; return ON; }
67229509Strocinyoff			{ DP; return OFF; }
68204076Spjdfullsync		{ DP; return FULLSYNC; }
69204076Spjdmemsync			{ DP; return MEMSYNC; }
70204076Spjdasync			{ DP; return ASYNC; }
71219351Spjdnone			{ DP; return NONE; }
72219351Spjdcrc32			{ DP; return CRC32; }
73219351Spjdsha256			{ DP; return SHA256; }
74219354Spjdhole			{ DP; return HOLE; }
75219354Spjdlzf			{ DP; return LZF; }
76204076Spjd[0-9]+			{ DP; yylval.num = atoi(yytext); return NUM; }
77222117Spjd[a-zA-Z0-9\.\-_/\:\[\]]+ { DP; yylval.str = strdup(yytext); return STR; }
78204076Spjd\{			{ DP; depth++; return OB; }
79204076Spjd\}			{ DP; depth--; return CB; }
80204076Spjd#.*$			/* ignore comments */;
81204076Spjd\n			{ lineno++; }
82204076Spjd[ \t]+			/* ignore whitespace */;
83204076Spjd%%
84