summaryrefslogtreecommitdiff
path: root/2003/i/buspctl/src/lexer.l
blob: b4498ad974db49dc153e50be95fba9dc7cdf4afe (plain)
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
%{
#include <grammar.h>

int yyparse (void);

%}

WRITE	w|write
READ	r|read

DEC	[0-9]+
HEX	0x[0-9a-fA-F]+
BIN	0b[01]+

%option noyywrap nounput

%%

{WRITE}	{
    return WRITE;
}

{READ}	{
    return READ;
}

{DEC}|{HEX}	{
    yylval = strtol (yytext, 0, 0);
    return NUM;
}

{BIN}	{
    yylval = strtol (yytext + 2, 0, 2);
    return NUM;
}

[ \t\n]+	/* Rien � battre. */

.	return ERR;

%%

int parse_string (const char *s)
{
	yy_scan_string (s);
	return yyparse ();
}