summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/pmu.l
blob: 67b247be693b1f1fdb5e18d2bec043c5cf315245 (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
48
%option prefix="perf_pmu_"
%option reentrant
%option bison-bridge

%{
#include <stdlib.h>
#include <linux/bitops.h>
#include "pmu.h"
#include "pmu-bison.h"

char *perf_pmu_get_text(yyscan_t yyscanner);
YYSTYPE *perf_pmu_get_lval(yyscan_t yyscanner);

static int value(yyscan_t scanner, int base)
{
	YYSTYPE *yylval = perf_pmu_get_lval(scanner);
	char *text = perf_pmu_get_text(scanner);
	long num;

	errno = 0;
	num = strtoul(text, NULL, base);
	if (errno)
		return PP_ERROR;

	yylval->num = num;
	return PP_VALUE;
}

%}

num_dec         [0-9]+

%%

{num_dec}	{ return value(yyscanner, 10); }
config		{ return PP_CONFIG; }
-		{ return '-'; }
:		{ return ':'; }
,		{ return ','; }
.		{ ; }
\n		{ ; }

%%

int perf_pmu_wrap(void *scanner __maybe_unused)
{
	return 1;
}