1 %option nounput noinput
3 /* $OpenBSD: tokenizer.l,v 1.7 2010/03/22 20:40:44 espie Exp $ */
5 * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * $FreeBSD: src/usr.bin/m4/tokenizer.l,v 1.3 2012/11/17 01:54:24 svnexp Exp $
28 #include <sys/param.h>
31 extern int32_t yylval;
34 int32_t parse_radix(void);
42 radix 0[rR][0-9]+:[0-9a-zA-Z]+
45 {ws} {/* just skip it */}
46 {hex}|{oct}|{dec} { yylval = number(); return(NUMBER); }
47 {radix} { if (mimic_gnu) {
48 yylval = parse_radix(); return(NUMBER);
55 "<<" { return(LSHIFT); }
56 ">>" { return(RSHIFT); }
59 "&&" { return(LAND); }
61 "**" { if (mimic_gnu) { return (EXPONENT); } }
62 . { return yytext[0]; }
71 l = strtol(yytext, NULL, 0);
72 if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) ||
73 l > INT32_MAX || l < INT32_MIN) {
74 fprintf(stderr, "m4: numeric overflow in expr: %s\n", yytext);
88 base = strtol(yytext + 2, &next, 0);
89 if (base > 36 || next == NULL) {
90 fprintf(stderr, "m4: error in number %s\n", yytext);
94 if (*next >= '0' && *next <= '9')
96 else if (*next >= 'a' && *next <= 'z')
99 assert(*next >= 'A' && *next <= 'Z');
100 d = *next - 'A' + 10;
104 "m4: error in number %s\n", yytext);