1 /* $NetBSD: sel-lex.l,v 1.1.1.3 2014/04/24 12:45:42 pettai Exp $ */
5 * Copyright (c) 2004, 2008 Kungliga Tekniska Högskolan
6 * (Royal Institute of Technology, Stockholm, Sweden).
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the Institute nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 static char * handle_string(void);
54 static int lex_input(char *, int);
55 static int lex_classic_input(void);
57 struct hx_expr_input _hx509_expr_input;
66 #define YY_INPUT(buf,res,maxsize) (res = lex_input(buf, maxsize))
73 TRUE { return kw_TRUE; }
74 FALSE { return kw_FALSE; }
75 AND { return kw_AND; }
78 TAILMATCH { return kw_TAILMATCH; }
80 [A-Za-z][-A-Za-z0-9_]* {
81 yylval.string = strdup ((const char *)yytext);
84 "\"" { yylval.string = handle_string(); return STRING; }
86 [,.!={}()%] { return *yytext; }
97 while((c = input()) != EOF){
105 _hx509_sel_yyerror("unterminated string");
128 lex_input(char *buf, int max_size)
132 n = _hx509_expr_input.length - _hx509_expr_input.offset;
138 memcpy(buf, _hx509_expr_input.buf + _hx509_expr_input.offset, n);
139 _hx509_expr_input.offset += n;