File: lex.l

package info (click to toggle)
lsfcc 0.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 324 kB
  • ctags: 217
  • sloc: ansic: 1,551; yacc: 408; sh: 337; lex: 85; makefile: 55
file content (85 lines) | stat: -rw-r--r-- 1,640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%{

#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include "grammar.h"

void yyerror(char *c);
%}

%option yylineno

%%

unsigned\ char	{ yylval.num = 8; return T_SIZE; }
signed\ char	{ yylval.num = 8; return T_SIZE; }
char	{ yylval.num = 8; return T_SIZE; }
unsigned\ int	{ yylval.num = 32; return T_SIZE; }
signed\ int	{ yylval.num = 32; return T_SIZE; }
int	{ yylval.num = 32; return T_SIZE; }
__u16	{ yylval.num = 16; return T_SIZE; }
__u32	{ yylval.num = 32; return T_SIZE; }
(u_)?int8_t	{ yylval.num = 8; return T_SIZE; }
(u_)?int16_t	{ yylval.num = 16; return T_SIZE; }
(u_)?int32_t	{ yylval.num = 32; return T_SIZE; }

packet	return T_PKT;
struct	return T_PKT;
accept	return T_ACCEPT;
deny	return T_DENY;
if	return T_IF;
base	return T_BASE;

\<<	return T_LSH;
>>	return T_RSH;
\!=	return T_NE;
\<=	return T_LE;
\<	return T_LT;
>=	return T_GE;
>	return T_GT;
==	return T_EQ;
\|\|	return T_LOR;
&&	return T_LAND;
\{	return '{';
\}	return '}';
;	return ';';
\.	return '.';
\(	return '(';
\)	return ')';
\[	return '[';
\]	return ']';
\+	return '+';
\*	return '*';
-	return '-';
\/	return '/';
&	return '&';
\|	return '|';
,	return ',';
:	return ':';

([0-9]{1,3}\.){3}[0-9]{1,3}	{
			yylval.num = ntohl(inet_addr(yytext));
			return(T_NUM);
		}
0[xX][[:xdigit:]]+	{
			yylval.num = strtol(yytext, NULL, 0);
			return(T_NUM);
		}
[[:digit:]]+	{
			yylval.num = strtol(yytext, NULL, 0);
			return(T_NUM);
		}
[[:blank:]\n]+
[[:alnum:]_]+	{
			yylval.cp = strdup(yytext);
			return(T_ID);
		}

%%

void dummy() { yyunput(0, NULL); } /* shutup gcc */