* Copyright (c) 1988-1990 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) $Header: tcplex.l,v 1.26 92/02/14 15:16:35 mccanne Exp $ (LBL)";
* Compiling with gcc under SunOS will cause problems unless we have this
* cruft here. The flex skeleton includes stddef.h which defines these types
* (under gcc). They will conflict with Sun's definitions in sys/types.h.
#define ptrdiff_t xxxptrdiff_t
#define wchar_t xxxwchar_t
* We need bpf since enum bpf_code is in YYSTYPE.
#include "y.tab.h" /* "tokdefs.h" */
#define YY_INPUT(buf, result, max)\
for (i = 0; *src && i < max; ++i)\
#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
B ([0-9A-Fa-f][0-9A-Fa-f]?)
link|ether|ppp|slip return LINK;
broadcast return TK_BROADCAST;
multicast return TK_MULTICAST;
[+\-*/:\[\]!<>()&|=] return yytext[0];
{N} { yylval.i = stoi(yytext); return NUM; }
({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N}) {
yylval.h = atoin(yytext); return HID;
{B}:{B}:{B}:{B}:{B}:{B} { yylval.e = ETHER_aton(yytext); return EID; }
{B}:+({B}:+)+ { error("bogus ethernet address %s", yytext); }
[A-Za-z][-_.A-Za-z0-9]* { yylval.s = yytext; return ID; }
"\\"[^ !()\n\t]+ { yylval.s = yytext + 1; return ID; }
[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+ { error("illegal token: %s\n", yytext); }
. { error("illegal char '%c'", *yytext); }
/* so we don't need -ll */