2012-03-16 03:09:17 +08:00
|
|
|
%option prefix="perf_pmu_"
|
2023-04-06 14:52:23 +08:00
|
|
|
%option reentrant
|
|
|
|
%option bison-bridge
|
2012-03-16 03:09:17 +08:00
|
|
|
|
|
|
|
%{
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include "pmu.h"
|
|
|
|
#include "pmu-bison.h"
|
|
|
|
|
2023-04-06 14:52:23 +08:00
|
|
|
char *perf_pmu_get_text(yyscan_t yyscanner);
|
|
|
|
YYSTYPE *perf_pmu_get_lval(yyscan_t yyscanner);
|
|
|
|
|
|
|
|
static int value(yyscan_t scanner, int base)
|
2012-03-16 03:09:17 +08:00
|
|
|
{
|
2023-04-06 14:52:23 +08:00
|
|
|
YYSTYPE *yylval = perf_pmu_get_lval(scanner);
|
|
|
|
char *text = perf_pmu_get_text(scanner);
|
2012-03-16 03:09:17 +08:00
|
|
|
long num;
|
|
|
|
|
|
|
|
errno = 0;
|
2023-04-06 14:52:23 +08:00
|
|
|
num = strtoul(text, NULL, base);
|
2012-03-16 03:09:17 +08:00
|
|
|
if (errno)
|
|
|
|
return PP_ERROR;
|
|
|
|
|
2023-04-06 14:52:23 +08:00
|
|
|
yylval->num = num;
|
2012-03-16 03:09:17 +08:00
|
|
|
return PP_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
num_dec [0-9]+
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
2023-04-06 14:52:23 +08:00
|
|
|
{num_dec} { return value(yyscanner, 10); }
|
2012-03-16 03:09:17 +08:00
|
|
|
config { return PP_CONFIG; }
|
|
|
|
- { return '-'; }
|
|
|
|
: { return ':'; }
|
|
|
|
, { return ','; }
|
|
|
|
. { ; }
|
|
|
|
\n { ; }
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
2023-04-06 14:52:23 +08:00
|
|
|
int perf_pmu_wrap(void *scanner __maybe_unused)
|
2012-03-16 03:09:17 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|