token.l revision 219354
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: head/sbin/hastd/token.l 219354 2011-03-06 23:09:33Z pjd $ 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 47204076Spjd%% 48204076Spjdcontrol { DP; return CONTROL; } 49204076Spjdlisten { DP; return LISTEN; } 50204076Spjdport { DP; return PORT; } 51204076Spjdreplication { DP; return REPLICATION; } 52219351Spjdchecksum { DP; return CHECKSUM; } 53219354Spjdcompression { DP; return COMPRESSION; } 54207371Spjdtimeout { DP; return TIMEOUT; } 55211886Spjdexec { DP; return EXEC; } 56204076Spjdresource { DP; return RESOURCE; } 57204076Spjdname { DP; return NAME; } 58204076Spjdlocal { DP; return LOCAL; } 59204076Spjdremote { DP; return REMOTE; } 60204076Spjdon { DP; return ON; } 61204076Spjdfullsync { DP; return FULLSYNC; } 62204076Spjdmemsync { DP; return MEMSYNC; } 63204076Spjdasync { DP; return ASYNC; } 64219351Spjdnone { DP; return NONE; } 65219351Spjdcrc32 { DP; return CRC32; } 66219351Spjdsha256 { DP; return SHA256; } 67219354Spjdhole { DP; return HOLE; } 68219354Spjdlzf { DP; return LZF; } 69204076Spjd[0-9]+ { DP; yylval.num = atoi(yytext); return NUM; } 70204076Spjd[a-zA-Z0-9\.\-_/\:]+ { DP; yylval.str = strdup(yytext); return STR; } 71204076Spjd\{ { DP; depth++; return OB; } 72204076Spjd\} { DP; depth--; return CB; } 73204076Spjd#.*$ /* ignore comments */; 74204076Spjd\n { lineno++; } 75204076Spjd[ \t]+ /* ignore whitespace */; 76204076Spjd%% 77