Loading...
1%option prefix="perf_pmu_"
2
3%{
4#include <stdlib.h>
5#include <linux/bitops.h>
6#include "pmu.h"
7#include "pmu-bison.h"
8
9static int value(int base)
10{
11 long num;
12
13 errno = 0;
14 num = strtoul(perf_pmu_text, NULL, base);
15 if (errno)
16 return PP_ERROR;
17
18 perf_pmu_lval.num = num;
19 return PP_VALUE;
20}
21
22%}
23
24num_dec [0-9]+
25
26%%
27
28{num_dec} { return value(10); }
29config { return PP_CONFIG; }
30config1 { return PP_CONFIG1; }
31config2 { return PP_CONFIG2; }
32- { return '-'; }
33: { return ':'; }
34, { return ','; }
35. { ; }
36\n { ; }
37
38%%
39
40int perf_pmu_wrap(void)
41{
42 return 1;
43}
1%option prefix="perf_pmu_"
2%option reentrant
3%option bison-bridge
4
5%{
6#include <stdlib.h>
7#include <linux/bitops.h>
8#include "pmu.h"
9#include "pmu-bison.h"
10
11char *perf_pmu_get_text(yyscan_t yyscanner);
12YYSTYPE *perf_pmu_get_lval(yyscan_t yyscanner);
13
14static int value(yyscan_t scanner, int base)
15{
16 YYSTYPE *yylval = perf_pmu_get_lval(scanner);
17 char *text = perf_pmu_get_text(scanner);
18 long num;
19
20 errno = 0;
21 num = strtoul(text, NULL, base);
22 if (errno)
23 return PP_ERROR;
24
25 yylval->num = num;
26 return PP_VALUE;
27}
28
29%}
30
31num_dec [0-9]+
32
33%%
34
35{num_dec} { return value(yyscanner, 10); }
36config { return PP_CONFIG; }
37- { return '-'; }
38: { return ':'; }
39, { return ','; }
40. { ; }
41\n { ; }
42
43%%
44
45int perf_pmu_wrap(void *scanner __maybe_unused)
46{
47 return 1;
48}